esp_netif: Remove restarting DHCP client and server if it has already been started
To be in line with previous behaviour in tcpip_adapter, do nothing and return appropriate error if the DHCP client/server has already been started
@@ -950,6 +950,11 @@ static esp_err_t esp_netif_dhcpc_start_api(esp_netif_api_msg_t *msg)
return ESP_ERR_INVALID_ARG;
}
+ if (esp_netif->dhcpc_status == ESP_NETIF_DHCP_STARTED) {
+ ESP_LOGD(TAG, "dhcp client already started");
+ return ESP_ERR_ESP_NETIF_DHCP_ALREADY_STARTED;
+ }
+
struct netif *p_netif = esp_netif->lwip_netif;
esp_netif_reset_ip_info(esp_netif);
@@ -1019,6 +1024,11 @@ static esp_err_t esp_netif_dhcps_start_api(esp_netif_api_msg_t *msg)
return ESP_ERR_INVALID_ARG;
}
+ if (esp_netif->dhcps_status == ESP_NETIF_DHCP_STARTED) {
+ ESP_LOGD(TAG, "dhcp server already started");
+ return ESP_ERR_ESP_NETIF_DHCP_ALREADY_STARTED;
+ }
+
struct netif *p_netif = esp_netif->lwip_netif;
if (p_netif != NULL && netif_is_up(p_netif)) {
esp_netif_ip_info_t *default_ip = esp_netif->ip_info;
