public inbox for ecos-discuss@sourceware.org
 help / color / mirror / Atom feed
* [ECOS] Runtime network reinit
@ 2005-05-09 15:53 Goran Pantar
  2005-05-11 20:42 ` Andrew Lunn
  0 siblings, 1 reply; 2+ messages in thread
From: Goran Pantar @ 2005-05-09 15:53 UTC (permalink / raw)
  To: ecos-discuss

Hi,
I have initialised the Network stack using fixed IP adresses. I would
now like the possibility to change the IP address at runtime. Is this
possible in eCos?

Parts of my network intialisation procedure:
..
   s = socket(AF_INET, SOCK_DGRAM, 0);
..
   ioctl(s, SIOCSIFHWADDR, &ifr);
   close(s);
..
   eth0_bootp_data.bp_op = BOOTREPLY;
   eth0_bootp_data.bp_htype = HTYPE_ETHERNET;
   eth0_bootp_data.bp_hlen = ETHER_ADDR_LEN;
   for(i = 0;  i < eth0_bootp_data.bp_hlen;  i++)
   {
     eth0_bootp_data.bp_chaddr[i] = 0xFF;
   }
   eth0_bootp_data.bp_ciaddr.s_addr = *(in_addr_t *)NetHeader.addr_ip;
   eth0_bootp_data.bp_yiaddr.s_addr = *(in_addr_t *)NetHeader.addr_ip;
   eth0_bootp_data.bp_siaddr.s_addr = *(in_addr_t
*)NetHeader.addr_server;
   eth0_bootp_data.bp_giaddr.s_addr = *(in_addr_t
*)NetHeader.addr_gateway;
..
   init_net(eth0_name, &eth0_bootp_data);
..

The obove procedure initializes the network sucessfully and all the
services are working. But when I run the same procedure (with changed IP
addresses) init_net fails with a diag print: SIOCIFADDR: File exist.


Thanks,
Goran Pantar 


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

^ permalink raw reply	[flat|nested] 2+ messages in thread

* Re: [ECOS] Runtime network reinit
  2005-05-09 15:53 [ECOS] Runtime network reinit Goran Pantar
@ 2005-05-11 20:42 ` Andrew Lunn
  0 siblings, 0 replies; 2+ messages in thread
From: Andrew Lunn @ 2005-05-11 20:42 UTC (permalink / raw)
  To: Goran Pantar; +Cc: ecos-discuss

On Mon, May 09, 2005 at 12:11:15PM +0200, Goran Pantar wrote:
> Hi,
> I have initialised the Network stack using fixed IP adresses. I would
> now like the possibility to change the IP address at runtime. Is this
> possible in eCos?
> 
> Parts of my network intialisation procedure:
> ..
>    s = socket(AF_INET, SOCK_DGRAM, 0);
> ..
>    ioctl(s, SIOCSIFHWADDR, &ifr);
>    close(s);
> ..
>    eth0_bootp_data.bp_op = BOOTREPLY;
>    eth0_bootp_data.bp_htype = HTYPE_ETHERNET;
>    eth0_bootp_data.bp_hlen = ETHER_ADDR_LEN;
>    for(i = 0;  i < eth0_bootp_data.bp_hlen;  i++)
>    {
>      eth0_bootp_data.bp_chaddr[i] = 0xFF;
>    }
>    eth0_bootp_data.bp_ciaddr.s_addr = *(in_addr_t *)NetHeader.addr_ip;
>    eth0_bootp_data.bp_yiaddr.s_addr = *(in_addr_t *)NetHeader.addr_ip;
>    eth0_bootp_data.bp_siaddr.s_addr = *(in_addr_t
> *)NetHeader.addr_server;
>    eth0_bootp_data.bp_giaddr.s_addr = *(in_addr_t
> *)NetHeader.addr_gateway;
> ..
>    init_net(eth0_name, &eth0_bootp_data);
> ..
> 
> The obove procedure initializes the network sucessfully and all the
> services are working. But when I run the same procedure (with changed IP
> addresses) init_net fails with a diag print: SIOCIFADDR: File exist.

You probably need to make a couple of ioctl calls to remove the
current addressing information before you can call init_net again.

        Andrew

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

^ permalink raw reply	[flat|nested] 2+ messages in thread

end of thread, other threads:[~2005-05-11 20:23 UTC | newest]

Thread overview: 2+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2005-05-09 15:53 [ECOS] Runtime network reinit Goran Pantar
2005-05-11 20:42 ` Andrew Lunn

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for read-only IMAP folder(s) and NNTP newsgroup(s).