esp_netif: Fix dhcps state transitions
When the DHCP server is stopped before starting the netif,
it should remain stopped -- as per compatibility with previous tcpip_adapter behavior
@@ -726,7 +726,7 @@ static esp_err_t esp_netif_start_api(esp_netif_api_msg_t *msg)
}
if (esp_netif->flags & ESP_NETIF_DHCP_SERVER) {
#if ESP_DHCPS
- if (esp_netif->dhcps_status != ESP_NETIF_DHCP_STARTED) {
+ if (esp_netif->dhcps_status == ESP_NETIF_DHCP_INIT) {
if (p_netif != NULL && netif_is_up(p_netif)) {
esp_netif_ip_info_t *default_ip = esp_netif->ip_info;
ip4_addr_t lwip_ip;
@@ -745,9 +745,11 @@ static esp_err_t esp_netif_start_api(esp_netif_api_msg_t *msg)
esp_netif->dhcps_status = ESP_NETIF_DHCP_INIT;
return ESP_OK;
}
- }
+ } else if (esp_netif->dhcps_status == ESP_NETIF_DHCP_STARTED) {
ESP_LOGD(TAG, "DHCP server already started");
return ESP_ERR_ESP_NETIF_DHCP_ALREADY_STARTED;
+ }
+ return ESP_OK;
#else
LOG_NETIF_DISABLED_AND_DO("DHCP Server", return ESP_ERR_NOT_SUPPORTED);
#endif
