<html><head><style type="text/css"><!-- DIV {margin:0px;} --></style></head><body><div style="font-family:times new roman, new york, times, serif;font-size:12pt"><DIV>Hi,</DIV>
<DIV> </DIV>
<DIV>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.</DIV>
<DIV> </DIV>
<DIV>Here I try to set IP data on the network device by means of ifreq structure and ioctl function:</DIV>
<DIV> </DIV>
<DIV>
<P> struct ifreq /* Defined in /usr/include/linux/if.h */<BR>{<BR> #define IFNAMSIZ 16<BR> #define IFHWADDRLEN 6<BR> union<BR> {<BR> char ifrn_name[IFNAMSIZ]; /* if name, e.g. "eth0" */<BR> } ifr_ifrn;</P>
<P> union {<BR> struct sockaddr ifru_addr;<BR> struct sockaddr ifru_broadaddr;<BR> struct sockaddr ifru_netmask;<BR> struct sockaddr ifru_hwaddr;<BR> short ifru_flags;<BR> int ifru_metric;<BR> int ifru_mtu;<BR> } ifr_ifru;<BR>} ifr;</P>
<P> </P>
<P> struct sockaddr new_ip; /* Values has been set by other function*/</P>
<P> struct sockaddr new_netmask; /* Values has been set by other function*/</P>
<P> </P>
<P> ifr.ifrn_name = "eth1";</P>
<P> ifr.ifru_addr =new_ip;</P>
<P> ifr.ifru_broadaddr = new_ip;</P>
<P> </P>
<P> if (!ioctl (ioctl_s, SIOCSIFADDR, &ifr)) /* The function returns -1, and the ip can't be changed when olsrd running. */</P>
<P>/* ioctl_s is the global variable of olsrd.*/</P>
<P> printf(" No action done.\n");</P>
<P>........</P>
<DIV style="FONT-SIZE: 12pt; FONT-FAMILY: times new roman, new york, times, serif">........</DIV>
<DIV style="FONT-SIZE: 12pt; FONT-FAMILY: times new roman, new york, times, serif">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?</DIV>
<DIV style="FONT-SIZE: 12pt; FONT-FAMILY: times new roman, new york, times, serif">I appreciate if someone give me more information about what should be done here to change the IP.</DIV>
<DIV style="FONT-SIZE: 12pt; FONT-FAMILY: times new roman, new york, times, serif"> </DIV>
<DIV style="FONT-SIZE: 12pt; FONT-FAMILY: times new roman, new york, times, serif">Regards,</DIV>
<DIV style="FONT-SIZE: 12pt; FONT-FAMILY: times new roman, new york, times, serif"> </DIV>
<DIV style="FONT-SIZE: 12pt; FONT-FAMILY: times new roman, new york, times, serif">Siamak</DIV></DIV></div><br>
<hr size=1>Boardwalk for $500? In 2007? Ha! <br><a href="http://us.rd.yahoo.com/evt=48223/*http://get.games.yahoo.com/proddesc?gamekey=monopolyherenow">Play Monopoly Here and Now</a> (it's updated for today's economy) at Yahoo! Games.</body></html>