Subject: Adding an IP Address to an Interface
To: None <netbsd-help@netbsd.org>
From: Rajnish Madan <rajnishm@delhi.tcs.co.in>
List: netbsd-help
Date: 01/15/2001 11:09:08
This is a multi-part message in MIME format.
------=_NextPart_000_0085_01C07EE3.95108E20
Content-Transfer-Encoding: quoted-printable
Content-Type: text/plain;
charset="iso-8859-1"
Hi,
I am trying to add an IP Address to an Interface.
I am using SIOCAIFADDR ioctl. But it doesn't seem to work.
Here is what i have tried to do.
sock =3D socket(AF_INET, SOCK_DGRAM, 0);
strncpy(iar.ifra_name,"ex0", strlen("ex0"));
iar.ifra_addr.sa_family =3D AF_INET;
strcpy(iar.ifra_addr.sa_data, ip_addr);
ret_val =3D ioctl(sock, SIOCAIFADDR, &iar);
Ioctl returns success, when i checked using ifconfig -a -A some junk =
alias was set.
Also if i try to delete this entry using ifconfig ex0 delete XX, the =
NetBSD is crashing.
Pls suggest/guide in this regard
Regards
Rajnish
------=_NextPart_000_0085_01C07EE3.95108E20
Content-Transfer-Encoding: quoted-printable
Content-Type: text/html;
charset="iso-8859-1"
<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.0 Transitional//EN">
<HTML><HEAD>
<META content=3D"text/html; charset=3Diso-8859-1" =
http-equiv=3DContent-Type>
<META content=3D"MSHTML 5.00.2314.1000" name=3DGENERATOR>
<STYLE></STYLE>
</HEAD>
<BODY bgColor=3D#ffffff>
<DIV><FONT face=3DArial size=3D1>Hi,</FONT></DIV>
<DIV> </DIV>
<DIV><FONT face=3DArial size=3D1>I am trying to add an IP Address to an=20
Interface.</FONT></DIV>
<DIV><FONT face=3DArial size=3D1>I am using SIOCAIFADDR ioctl. But it =
doesn't seem=20
to work.</FONT></DIV>
<DIV> </DIV>
<DIV><FONT face=3DArial size=3D1>Here is what i have tried to =
do.</FONT></DIV>
<DIV> </DIV>
<DIV><FONT face=3DArial size=3D1> =
<STRONG>sock=20
=3D socket(AF_INET, SOCK_DGRAM, 0);</STRONG></FONT></DIV>
<DIV> </DIV>
<DIV><STRONG><FONT face=3DArial =
size=3D1> =20
strncpy(iar.ifra_name,"ex0",=20
strlen("ex0"));<BR> =20
iar.ifra_addr.sa_family =3D AF_INET;</FONT></STRONG></DIV>
<DIV> </DIV>
<DIV><STRONG><FONT face=3DArial =
size=3D1> =20
strcpy(iar.ifra_addr.sa_data, ip_addr);</FONT></STRONG></DIV>
<DIV> </DIV>
<DIV><FONT face=3DArial =
size=3D1><STRONG> =20
ret_val =3D ioctl(sock, SIOCAIFADDR, &iar);</STRONG></FONT></DIV>
<DIV><FONT face=3DArial size=3D1></FONT> </DIV>
<DIV><FONT face=3DArial size=3D1>Ioctl returns success, when i checked =
using=20
ifconfig -a -A some junk alias was set.</FONT></DIV>
<DIV><FONT face=3DArial size=3D1>Also if i try to delete this entry =
using ifconfig=20
ex0 delete XX, the NetBSD is crashing.</FONT></DIV>
<DIV> </DIV>
<DIV><FONT face=3DArial size=3D1>Pls suggest/guide in this =
regard</FONT></DIV>
<DIV><FONT face=3DArial size=3D1>Regards</FONT></DIV>
<DIV><FONT face=3DArial size=3D1>Rajnish</FONT></DIV></BODY></HTML>
------=_NextPart_000_0085_01C07EE3.95108E20--