summaryrefslogtreecommitdiff
path: root/lib
diff options
context:
space:
mode:
authorHa Thach <[email protected]>2022-11-18 21:42:39 +0700
committerGitHub <[email protected]>2022-11-18 21:42:39 +0700
commit95fb11fcffd27a055561d2171aa99199982bb563 (patch)
tree54932f50146ae201df61e0df7c177907e40564ce /lib
parent2dc7a623616aee3986ef7751ad9299de08a073e5 (diff)
parent3f3f6eee1c1b1bec43933488b27772a9f848c529 (diff)
Merge pull request #1712 from kripton/fixDhserver
dhserver: Support DHCP clients that don't send the MESSAGETYPE as first option
Diffstat (limited to 'lib')
-rw-r--r--lib/networking/dhserver.c6
1 files changed, 5 insertions, 1 deletions
diff --git a/lib/networking/dhserver.c b/lib/networking/dhserver.c
index 590739236..def431f75 100644
--- a/lib/networking/dhserver.c
+++ b/lib/networking/dhserver.c
@@ -240,7 +240,11 @@ static void udp_recv_proc(void *arg, struct udp_pcb *upcb, struct pbuf *p, const
unsigned n = p->len;
if (n > sizeof(dhcp_data)) n = sizeof(dhcp_data);
memcpy(&dhcp_data, p->payload, n);
- switch (dhcp_data.dp_options[2])
+
+ ptr = find_dhcp_option(dhcp_data.dp_options, sizeof(dhcp_data.dp_options), DHCP_MESSAGETYPE);
+ if (ptr == NULL) return;
+
+ switch (ptr[2])
{
case DHCP_DISCOVER:
entry = entry_by_mac(dhcp_data.dp_chaddr);