Skip to content

Commit b59a522

Browse files
authored
Pico-W Access Point: Fix DHCP server for certain clients (dhcpcd) (#288)
1 parent 5e1c1ca commit b59a522

File tree

1 file changed

+7
-1
lines changed

1 file changed

+7
-1
lines changed

pico_w/access_point/dhcpserver/dhcpserver.c

Lines changed: 7 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -200,7 +200,13 @@ static void dhcp_server_process(void *arg, struct udp_pcb *upcb, struct pbuf *p,
200200
uint8_t *opt = (uint8_t *)&dhcp_msg.options;
201201
opt += 4; // assume magic cookie: 99, 130, 83, 99
202202

203-
switch (opt[2]) {
203+
uint8_t *msgtype = opt_find(opt, DHCP_OPT_MSG_TYPE);
204+
if (msgtype == NULL) {
205+
// A DHCP package without MSG_TYPE?
206+
goto ignore_request;
207+
}
208+
209+
switch (msgtype[2]) {
204210
case DHCPDISCOVER: {
205211
int yi = DHCPS_MAX_IP;
206212
for (int i = 0; i < DHCPS_MAX_IP; ++i) {

0 commit comments

Comments
 (0)