diff --git a/examples/stm32/nucleo-h743zi-make-baremetal-builtin/main.c b/examples/stm32/nucleo-h743zi-make-baremetal-builtin/main.c index cc8bf28e..aae28353 100644 --- a/examples/stm32/nucleo-h743zi-make-baremetal-builtin/main.c +++ b/examples/stm32/nucleo-h743zi-make-baremetal-builtin/main.c @@ -46,10 +46,12 @@ int main(void) { mg_log_set(MG_LL_DEBUG); // Set log level // Initialise Mongoose network stack - // Specify MAC address, and IP/mask/GW in network byte order for static - // IP configuration. If IP/mask/GW are unset, DHCP is going to be used struct mg_tcpip_driver_stm32h_data driver_data = {.mdc_cr = 4}; struct mg_tcpip_if mif = {.mac = GENERATE_LOCALLY_ADMINISTERED_MAC(), + // Uncomment below for static configuration: + // .ip = mg_htonl(MG_U32(192, 168, 0, 223)), + // .mask = mg_htonl(MG_U32(255, 255, 255, 0)), + // .gw = mg_htonl(MG_U32(192, 168, 0, 1)), .driver = &mg_tcpip_driver_stm32h, .driver_data = &driver_data}; mg_tcpip_init(&mgr, &mif); diff --git a/mongoose.c b/mongoose.c index fd8ca76c..39c5c4bd 100644 --- a/mongoose.c +++ b/mongoose.c @@ -8257,7 +8257,7 @@ static void rx_ip(struct mg_tcpip_if *ifp, struct pkt *pkt) { MG_DEBUG(("UDP %M:%hu -> %M:%hu len %u", mg_print_ip4, &pkt->ip->src, mg_ntohs(pkt->udp->sport), mg_print_ip4, &pkt->ip->dst, mg_ntohs(pkt->udp->dport), (int) pkt->pay.len)); - if (pkt->udp->dport == mg_htons(68)) { + if (ifp->enable_dhcp_client && pkt->udp->dport == mg_htons(68)) { pkt->dhcp = (struct dhcp *) (pkt->udp + 1); mkpay(pkt, pkt->dhcp + 1); rx_dhcp_client(ifp, pkt); diff --git a/src/tcpip/tcpip.c b/src/tcpip/tcpip.c index c415d3d5..ce2acd80 100644 --- a/src/tcpip/tcpip.c +++ b/src/tcpip/tcpip.c @@ -694,7 +694,7 @@ static void rx_ip(struct mg_tcpip_if *ifp, struct pkt *pkt) { MG_DEBUG(("UDP %M:%hu -> %M:%hu len %u", mg_print_ip4, &pkt->ip->src, mg_ntohs(pkt->udp->sport), mg_print_ip4, &pkt->ip->dst, mg_ntohs(pkt->udp->dport), (int) pkt->pay.len)); - if (pkt->udp->dport == mg_htons(68)) { + if (ifp->enable_dhcp_client && pkt->udp->dport == mg_htons(68)) { pkt->dhcp = (struct dhcp *) (pkt->udp + 1); mkpay(pkt, pkt->dhcp + 1); rx_dhcp_client(ifp, pkt);