[Top][All Lists]
[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]
[lwip-users] Re: [lwip] changes in IP/UDP for DHCP
From: |
Leon Woestenberg |
Subject: |
[lwip-users] Re: [lwip] changes in IP/UDP for DHCP |
Date: |
Wed, 08 Jan 2003 22:10:45 -0000 |
Hello Adam, Horst,
>On Thursday 10 January 2002 16.32, Horst wrote:
> > > udp_bind(state->pcb, IP_ADDR_ANY, DHCP_CLIENT_PORT);
> > > udp_connect(state->pcb, IP_ADDR_ANY, DHCP_SERVER_PORT);
> > ^^^^^^^^^^^^^^
> > 255.255.255.255 ?
> >
> > I think you want to send out a DHCP broadcast!? So why not use:
> > udp_connect(state->pcb, IP_ADDR_BROADCAST, DHCP_SERVER_PORT);
> >
> But the pcb needs to be connected to IP_ADDR_ANY in order to receive
incoming
> DHCP datagrams.
> /adam
That's right. Of course, before that, I sent out a broadcast, like this:
First, the client send a DHCP broadcast.:
udp_connect(state->pcb, IP_ADDR_BROADCAST, DHCP_SERVER_PORT);
udp_send(...);
Second, it has to listen to DHCP replies which might be sent to
1) an IP broadcast address
2) a unicast IP address, that might NOT match the current netif->ip_addr
both are directed to our hardware address (on the link level, i.e.
Ethernet).
So, I have to remove the remote socket (which is still IP_ADDR_BROADCAST)
and
set it to accept from any remote address (connect), but also any local
address (bind).
udp_connect(state->pcb, IP_ADDR_ANY, DHCP_SERVER_PORT);
Now, as Adam pointed out, udp_bind() and udp_connect() where OK with
IP_ADDR_BROADCAST but failed on IP_ADDR_ANY, which seems to be
fixed now.
Thanks for that, and thanks for the "dest" to "remote" replacements. I'll be
digging
DHCP code next Wednesday again.
Regards, Leon.
[This message was sent through the lwip discussion list.]