[Top][All Lists]
[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]
[lwip-users] UDP pcb matching
From: |
Bertrand Roussel |
Subject: |
[lwip-users] UDP pcb matching |
Date: |
Wed, 6 Jul 2011 10:40:23 +0200 |
Hi,
I built a DHCP server which can answer different IP address depending on which interface it received the request from.
In udp_input, when looking for a matching PCB, at some point there is a condition that match a PCB if:
* PCB local port and UDP packet dest port are the same
* UDP dest IP is broadcast
This is fine for single interface devices, however if there is multiple interfaces listening on the same port, only the last registered PCB that match get the packet.
I changed the second condition to:
* (UDP dest IP is broadcast) and (PCB local ip and netif local ip are the same)
udp.c @ line 182:
From:
#else /* IP_SOF_BROADCAST_RECV */
(broadcast))) {
#endif /* IP_SOF_BROADCAST_RECV */
To:
#else /* IP_SOF_BROADCAST_RECV */
(broadcast && ip_addr_cmp(&(pcb->local_ip), &(inp->ip_addr)) ))) {
#endif /* IP_SOF_BROADCAST_RECV */
It should work even when there is only one interface registered.
Bertrand
- [lwip-users] UDP pcb matching,
Bertrand Roussel <=