Skip to content

Fix needed to DHCP server #382

@peterharperuk

Description

@peterharperuk

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);



Metadata

Metadata

Assignees

Labels

No labels
No labels

Type

No type

Projects

No projects

Milestone

Relationships

None yet

Development

No branches or pull requests

Issue actions