[Top][All Lists]
[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]
Re: [lwip-users] UDP not accepting repsonses to a broadcast
From: |
Leon Woestenberg |
Subject: |
Re: [lwip-users] UDP not accepting repsonses to a broadcast |
Date: |
Fri, 12 Mar 2004 02:02:55 +0100 |
User-agent: |
Mozilla Thunderbird 0.5 (Windows/20040207) |
Hello Paul,
The packet goes out ok but the replies I get back never get back to the
udp receive function.
...
The issue is with pcb->remote_ip set to IP_ADDR_BROADCAST then
ip_addr_isany(&pcb->remote_ip) fails so the input is rejected.
Correct. Read on.
The alternative is to set pcb->remote_ip to IP_ADDR_ANY but then
the udp packet is sent to 0.0.0.0 and no hosts reply (only windows
tested).
Can anyone make a suggestion on how to fix or work around this?
Yes, both your assumptions are correct, but there is a simple
workaround (also see dhcp.c/dhcp_discover() which does *exactly* the
same): Just re-associate your PCB directly after sending.
udp_bind(dhcp->pcb, IP_ADDR_ANY, DHCP_CLIENT_PORT);
/* send broadcast to any DHCP server */
udp_connect(dhcp->pcb, IP_ADDR_BROADCAST, DHCP_SERVER_PORT);
udp_send(dhcp->pcb, dhcp->p_out);
/* remove remote address association, i.e. accept from ANY*/
udp_connect(dhcp->pcb, IP_ADDR_ANY, DHCP_SERVER_PORT);
The above is for DHCP in 0.7.1, by the way.
By pure coincidence, I have implemented udp_sendto() today, which
allows you to send to a specified destination address, without
affecting the remote address association of the PCB.
This code is in CVS HEAD, together with a modified DHCP client using
this in dhcp_discover() and dhcp_bind().
We need testers, so please (also) use CVS HEAD to test this.
Regards,
Leon.