Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Fix needed to DHCP server #382

Closed
peterharperuk opened this issue May 17, 2023 · 0 comments
Closed

Fix needed to DHCP server #382

peterharperuk opened this issue May 17, 2023 · 0 comments
Assignees
Milestone

Comments

@peterharperuk
Copy link
Contributor

peterharperuk commented May 17, 2023

If you have two netifs there's a chance a DHCP request will be received on one and the response sent on the other. Fix below...

This is the patch against the access_point example

server/dhcpserver.c
116c116
< static int dhcp_socket_sendto(struct udp_pcb **udp, struct netif *nif, const void *buf, size_t len, uint32_t ip, uint16_t port) {
---
> static int dhcp_socket_sendto(struct udp_pcb **udp, const void *buf, size_t len, uint32_t ip, uint16_t port) {
130,138c130
<
<     err_t err;
<     if(nif != NULL) {
<         err = udp_sendto_if(*udp, p, &dest, port, nif);
<     }
<     else {
<         err = udp_sendto(*udp, p, &dest, port);
<     }
<
---
>     err_t err = udp_sendto(*udp, p, &dest, port);
191d182
<     struct netif *nif = ip_current_input_netif();
294c285
<     dhcp_socket_sendto(&d->udp, nif, &dhcp_msg, opt - (uint8_t *)&dhcp_msg, 0xffffffff, PORT_DHCP_CLIENT);
---
>     dhcp_socket_sendto(&d->udp, &dhcp_msg, opt - (uint8_t *)&dhcp_msg, 0xffffffff, PORT_DHCP_CLIENT);



@peterharperuk peterharperuk added this to the 1.5.1 milestone May 17, 2023
@peterharperuk peterharperuk self-assigned this May 17, 2023
peterharperuk added a commit to peterharperuk/pico-examples that referenced this issue Jun 6, 2023
The DHCP server broadcasts messages. This are being sent via the
default netif which might be completely the wrong network. We want to
send messages to the netif we got the original message from.

Fixes raspberrypi#382
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

1 participant