Unable to start DHCP server on ethernet port
Posted: Sun Aug 18, 2024 2:25 pm
I am using IDF version 5.2.1 and an ESP32-WROOM module.
I have a KSZ8863 3 port switch that provides two Ethernet ports (using 2 port mode). Everything is working well sending packets through the TAP interfaces. ARP, ICMP, UDP packet flow all as expected.
Now I want to take one port and make it an isolated port that provides a DHCP Server to devices connected to that port. The other port can be a static or DHCP client port as configured by the user.
When I try to enable the DHCP server on one or both ports, I get errors.
I have set the appropriate flags in the esp_netif_inherent_config_t structure:
When I run the code I get the message:
dhcps_start(): could not obtain pcb and
esp_netif_lwip: DHCP server cannot be started.
Looking at the framework code:
it looks like the two reasons for this would be udp_new() didn't return a valid object for dhcps_pcb (whatever that is), or more likely that the ip4_addr_isany_val(ip) function returned true (guessing it doesn't want the default IP in esp_netif->ip_info to have a value).
Is there some other condition I need to satisfy before bringing up the interface? If the DHCP server is starting, it seems like it would need to have an IP set so it can act as a DHCP server.
Any thoughts?
Thanks!
Mike
I have a KSZ8863 3 port switch that provides two Ethernet ports (using 2 port mode). Everything is working well sending packets through the TAP interfaces. ARP, ICMP, UDP packet flow all as expected.
Now I want to take one port and make it an isolated port that provides a DHCP Server to devices connected to that port. The other port can be a static or DHCP client port as configured by the user.
When I try to enable the DHCP server on one or both ports, I get errors.
I have set the appropriate flags in the esp_netif_inherent_config_t structure:
Code: Select all
esp_netif_config.flags &= ~ESP_NETIF_DHCP_CLIENT;
esp_netif_config.flags |= ESP_NETIF_DHCP_SERVER;
esp_netif_config.flags |= ESP_NETIF_AUTOUP;
dhcps_start(): could not obtain pcb and
esp_netif_lwip: DHCP server cannot be started.
Looking at the framework code:
Code: Select all
dhcps->dhcps_pcb = udp_new();
if( dhcps->dhcps_pcb == NULL || ip4_addr_isany_val(ip)) {
DHCPS_LOG("dhcps_start(): could not obtain pcb\n");
return ERR_ARG;
}
Is there some other condition I need to satisfy before bringing up the interface? If the DHCP server is starting, it seems like it would need to have an IP set so it can act as a DHCP server.
Any thoughts?
Thanks!
Mike