mirror of
https://github.com/lwip-tcpip/lwip.git
synced 2024-07-04 20:08:57 +00:00
first attempt to fix bug #21655 (DHCP doesn't work reliably with multiple netifs): if LWIP_DHCP is enabled, UDP packets to DHCP_CLIENT_PORT are passed to netif->dhcp->pcb only (if that exists) and not to any other pcb for the same port (only solution to let UDP pcbs 'bind' to a netif instead of an IP address)
This commit is contained in:
parent
b714cd5f4b
commit
cedd5c21e6
|
@ -502,6 +502,12 @@ HISTORY
|
||||||
|
|
||||||
++ Bug fixes:
|
++ Bug fixes:
|
||||||
|
|
||||||
|
2007-11-30 Simon Goldschmidt
|
||||||
|
* udp.c: first attempt to fix bug #21655 (DHCP doesn't work reliably with multiple
|
||||||
|
netifs): if LWIP_DHCP is enabled, UDP packets to DHCP_CLIENT_PORT are passed
|
||||||
|
to netif->dhcp->pcb only (if that exists) and not to any other pcb for the same
|
||||||
|
port (only solution to let UDP pcbs 'bind' to a netif instead of an IP address)
|
||||||
|
|
||||||
2007-11-27 Simon Goldschmidt
|
2007-11-27 Simon Goldschmidt
|
||||||
* ip.c: fixed bug #21643 (udp_send/raw_send don't fail if netif is down) by
|
* ip.c: fixed bug #21643 (udp_send/raw_send don't fail if netif is down) by
|
||||||
letting ip_route only use netifs that are up.
|
letting ip_route only use netifs that are up.
|
||||||
|
|
|
@ -61,6 +61,7 @@
|
||||||
#include "lwip/stats.h"
|
#include "lwip/stats.h"
|
||||||
#include "lwip/snmp.h"
|
#include "lwip/snmp.h"
|
||||||
#include "arch/perf.h"
|
#include "arch/perf.h"
|
||||||
|
#include "lwip/dhcp.h"
|
||||||
|
|
||||||
#include <string.h>
|
#include <string.h>
|
||||||
|
|
||||||
|
@ -128,6 +129,26 @@ udp_input(struct pbuf *p, struct netif *inp)
|
||||||
ip4_addr1(&iphdr->src), ip4_addr2(&iphdr->src),
|
ip4_addr1(&iphdr->src), ip4_addr2(&iphdr->src),
|
||||||
ip4_addr3(&iphdr->src), ip4_addr4(&iphdr->src), ntohs(udphdr->src)));
|
ip4_addr3(&iphdr->src), ip4_addr4(&iphdr->src), ntohs(udphdr->src)));
|
||||||
|
|
||||||
|
#if LWIP_DHCP
|
||||||
|
pcb = NULL;
|
||||||
|
/* when LWIP_DHCP is active, packets to DHCP_CLIENT_PORT may only be processed by
|
||||||
|
the dhcp module, no other UDP pcb may use the local UDP port DHCP_CLIENT_PORT */
|
||||||
|
if (dest == DHCP_CLIENT_PORT) {
|
||||||
|
/* all packets for DHCP_CLIENT_PORT not coming from DHCP_SERVER_PORT are dropped! */
|
||||||
|
if (src == DHCP_SERVER_PORT) {
|
||||||
|
if ((inp->dhcp != NULL) && (inp->dhcp->pcb != NULL)) {
|
||||||
|
/* accept the packe if
|
||||||
|
(- broadcast or directed to us) -> DHCP is link-layer-addressed, local ip is always ANY!
|
||||||
|
- inp->dhcp->pcb->remote == ANY or iphdr->src */
|
||||||
|
if ((ip_addr_isany(&inp->dhcp->pcb->remote_ip) ||
|
||||||
|
ip_addr_cmp(&(inp->dhcp->pcb->remote_ip), &(iphdr->src)))) {
|
||||||
|
pcb = inp->dhcp->pcb;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
} else
|
||||||
|
#endif /* LWIP_DHCP */
|
||||||
|
{
|
||||||
local_match = 0;
|
local_match = 0;
|
||||||
uncon_pcb = NULL;
|
uncon_pcb = NULL;
|
||||||
/* Iterate through the UDP pcb list for a matching pcb.
|
/* Iterate through the UDP pcb list for a matching pcb.
|
||||||
|
@ -173,6 +194,7 @@ udp_input(struct pbuf *p, struct netif *inp)
|
||||||
if (pcb == NULL) {
|
if (pcb == NULL) {
|
||||||
pcb = uncon_pcb;
|
pcb = uncon_pcb;
|
||||||
}
|
}
|
||||||
|
}
|
||||||
|
|
||||||
/* Check checksum if this is a match or if it was directed at us. */
|
/* Check checksum if this is a match or if it was directed at us. */
|
||||||
if (pcb != NULL || ip_addr_cmp(&inp->ip_addr, &iphdr->dest)) {
|
if (pcb != NULL || ip_addr_cmp(&inp->ip_addr, &iphdr->dest)) {
|
||||||
|
|
Loading…
Reference in New Issue
Block a user