Merge pull request #448 from peterharperuk/pan_fix_dhcp_server_interface

Pan fix dhcp server interface
This commit is contained in:
Matthias Ringwald 2023-01-18 18:48:07 +01:00 committed by GitHub
commit aa51c6faff
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23

View File

@ -231,6 +231,7 @@ static void udp_recv_proc(void *arg, struct udp_pcb *upcb, struct pbuf *p, const
uint8_t *ptr; uint8_t *ptr;
dhcp_entry_t *entry; dhcp_entry_t *entry;
struct pbuf *pp; struct pbuf *pp;
struct netif *nif;
unsigned int n = p->len; unsigned int n = p->len;
if (n > sizeof(dhcp_data)) n = sizeof(dhcp_data); if (n > sizeof(dhcp_data)) n = sizeof(dhcp_data);
@ -262,7 +263,12 @@ static void udp_recv_proc(void *arg, struct udp_pcb *upcb, struct pbuf *p, const
pp = pbuf_alloc(PBUF_TRANSPORT, sizeof(dhcp_data), PBUF_POOL); pp = pbuf_alloc(PBUF_TRANSPORT, sizeof(dhcp_data), PBUF_POOL);
if (pp == NULL) break; if (pp == NULL) break;
memcpy(pp->payload, &dhcp_data, sizeof(dhcp_data)); memcpy(pp->payload, &dhcp_data, sizeof(dhcp_data));
udp_sendto(upcb, pp, IP_ADDR_BROADCAST, port); nif = ip_current_input_netif();
if (nif) {
udp_sendto_if(upcb, pp, IP_ADDR_BROADCAST, port, nif);
} else {
udp_sendto(upcb, pp, IP_ADDR_BROADCAST, port);
}
pbuf_free(pp); pbuf_free(pp);
break; break;
@ -306,7 +312,12 @@ static void udp_recv_proc(void *arg, struct udp_pcb *upcb, struct pbuf *p, const
if (pp == NULL) break; if (pp == NULL) break;
memcpy(entry->mac, dhcp_data.dp_chaddr, 6); memcpy(entry->mac, dhcp_data.dp_chaddr, 6);
memcpy(pp->payload, &dhcp_data, sizeof(dhcp_data)); memcpy(pp->payload, &dhcp_data, sizeof(dhcp_data));
udp_sendto(upcb, pp, IP_ADDR_BROADCAST, port); nif = ip_current_input_netif();
if (nif) {
udp_sendto_if(upcb, pp, IP_ADDR_BROADCAST, port, nif);
} else {
udp_sendto(upcb, pp, IP_ADDR_BROADCAST, port);
}
pbuf_free(pp); pbuf_free(pp);
break; break;