This is the mail archive of the ecos-discuss@sources.redhat.com mailing list for the eCos project.


Index Nav: [Date Index] [Subject Index] [Author Index] [Thread Index]
Message Nav: [Date Prev] [Date Next] [Thread Prev] [Thread Next]
Other format: [Raw text]

Change IP during run-time


Hi,

I want to change the IP address of my "eth0" interface during run-time.
Is that possible? I tried to do it using ioctl but encountered some
problems:

1. First i tried to just change the current IP with the below calls but
the old IP address still answers ping calls toghether with the new IP
address. I could successfull ping two addresses. That's not goos since i
want to old address to stop responding.

struct sockaddr_in *inaddr = (struct sockaddr_in *)&ifreq.ifr_addr;
inet_aton("111.22.33.444", &inaddr->sin_addr  );
ioctl( sock, SIOCSIFADDR, &ifreq );


2. The next thing to try was to delete the interface and then
change/create the new one:

if (ioctl(sock, SIOCDIFADDR, &ifreq)) { /* delete IF addr */
inet_aton("111.22.33.444", &inaddr->sin_addr  );
ioctl( sock, SIOCSIFADDR, &ifreq );

With this code i only get ping responses from the new IP address
(good...) but when creating a new socket and sending out data then the
package source (i logg all ethernet traffic) are set to the OLD IP
address.

Any ideas how to change IP address of the board during run-time?

Regards, Daniel Lidsten

--
Before posting, please read the FAQ: http://ecos.sourceware.org/fom/ecos
and search the list archive: http://ecos.sourceware.org/ml/ecos-discuss


Index Nav: [Date Index] [Subject Index] [Author Index] [Thread Index]
Message Nav: [Date Prev] [Date Next] [Thread Prev] [Thread Next]