[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: |
Adam Dunkels |
Subject: |
[lwip-users] Re: [lwip] changes in IP/UDP for DHCP |
Date: |
Thu, 09 Jan 2003 01:36:39 -0000 |
Hi Leon!
On Thursday 10 January 2002 13.56, you wrote:
> I used:
>
> udp_bind(state->pcb, IP_ADDR_ANY, DHCP_CLIENT_PORT);
> udp_connect(state->pcb, IP_ADDR_ANY, DHCP_SERVER_PORT);
>
> the problem is, IP_ADDR_ANY is defined 0, interpreted NULL by
> udp_connect, and so, not set. It remains the old value.
You are right - udp_connect() (and udp_bind()) are flawed. This is among the
oldest code is lwIP, and it hasn't been given enough attention until now.
Both functions should be changed so that they use ip_addr_set() instead of
the current implementation. This is the way the code should look like (from
the current CVS):
err_t
udp_bind(struct udp_pcb *pcb, struct ip_addr *ipaddr, u16_t port)
{
struct udp_pcb *ipcb;
ip_addr_set(&pcb->local_ip, ipaddr);
pcb->local_port = port;
[...]
err_t
udp_connect(struct udp_pcb *pcb, struct ip_addr *ipaddr, u16_t port)
{
struct udp_pcb *ipcb;
ip_addr_set(&pcb->dest_ip, ipaddr);
pcb->dest_port = port;
[...]
> Also, as a small sidenote, I found it confusing having
> pcb->local_* and pcb->dest_*.
>
> More appropriate are pcb->local_* and pcb->remote_* which
> are location based identifiers. dest and src are always
> respective to a communication direction.
Yes, you are most definately right. I have been meaning to change this for a
long time, but I hadn't come around to it until now. Thanks! The CVS code now
is updated with s/dest_/remote_/.
/adam
--
Adam Dunkels <address@hidden>
http://www.sics.se/~adam
[This message was sent through the lwip discussion list.]