[Olsr-dev] Chagning IP address and netmask

Siamak Eskandari (spam-protected)
Sat Jul 21 16:54:16 CEST 2007


Now it works, some mistakes in my codes.


----- Original Message ----
From: Siamak Eskandari <(spam-protected)>
To: (spam-protected); (spam-protected)
Sent: Saturday, July 21, 2007 10:49:40 AM
Subject: [Olsr-dev] Chagning IP address and netmask

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
      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.

Boardwalk for $500? In 2007? Ha! 
Play Monopoly Here and Now (it's updated for today's economy) at Yahoo! Games.

Take the Internet to Go: Yahoo!Go puts the Internet in your pocket: mail, news, photos & more. 
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://lists.olsr.org/pipermail/olsr-dev/attachments/20070721/6f63eb84/attachment.html>

More information about the Olsr-dev mailing list