[Olsr-dev] Chagning IP address and netmask
Siamak Eskandari
(spam-protected)
Sat Jul 21 10:49:40 CEST 2007
Hi,
I made a plugin to change IP on wireless interface which runs olsrd. But the IP can't be changed. On other hand It works by using "ifconfig" command with the IP information through system( ) function from my code.
Here I try to set IP data on the network device by means of ifreq structure and ioctl function:
struct ifreq /* Defined in /usr/include/linux/if.h */
{
#define IFNAMSIZ 16
#define IFHWADDRLEN 6
union
{
char ifrn_name[IFNAMSIZ]; /* if name, e.g. "eth0" */
} ifr_ifrn;
union {
struct sockaddr ifru_addr;
struct sockaddr ifru_broadaddr;
struct sockaddr ifru_netmask;
struct sockaddr ifru_hwaddr;
short ifru_flags;
int ifru_metric;
int ifru_mtu;
} ifr_ifru;
} ifr;
struct sockaddr new_ip; /* Values has been set by other function*/
struct sockaddr new_netmask; /* Values has been set by other function*/
ifr.ifrn_name = "eth1";
ifr.ifru_addr =new_ip;
ifr.ifru_broadaddr = new_ip;
if (!ioctl (ioctl_s, SIOCSIFADDR, &ifr)) /* The function returns -1, and the ip can't be changed when olsrd running. */
/* ioctl_s is the global variable of olsrd.*/
printf(" No action done.\n");
........
........
Do I need to open the device file (eth1) (in kernel) and than use that file descriptor in the ioctl function instead ioctl_s global variable?
I appreciate if someone give me more information about what should be done here to change the IP.
Regards,
Siamak
____________________________________________________________________________________
Sick sense of humor? Visit Yahoo! TV's
Comedy with an Edge to see what's on, when.
http://tv.yahoo.com/collections/222
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://lists.olsr.org/pipermail/olsr-dev/attachments/20070721/c7622f82/attachment.html>
More information about the Olsr-dev
mailing list