From d762f9a1a5155692c4698ceca537b6b12133304e Mon Sep 17 00:00:00 2001 From: Abhik Roy Date: Thu, 26 Jan 2023 20:59:04 +0530 Subject: [PATCH] esp-lwip: Added check in esp_netif_new() to restrict configuring DHCP server and client together. --- components/esp_netif/lwip/esp_netif_lwip.c | 10 ++++++++++ 1 file changed, 10 insertions(+) diff --git a/components/esp_netif/lwip/esp_netif_lwip.c b/components/esp_netif/lwip/esp_netif_lwip.c index 3cf86f1980..3425f1d505 100644 --- a/components/esp_netif/lwip/esp_netif_lwip.c +++ b/components/esp_netif/lwip/esp_netif_lwip.c @@ -677,6 +677,16 @@ esp_netif_t *esp_netif_new(const esp_netif_config_t *esp_netif_config) return NULL; } +#if ESP_DHCPS + // DHCP server and client cannot be configured together + if((esp_netif_config->base->flags & ESP_NETIF_DHCP_SERVER) && + (esp_netif_config->base->flags & ESP_NETIF_DHCP_CLIENT)) { + ESP_LOGE(TAG, "%s: Failed to configure netif with config=%p (DHCP server and client cannot be configured together)", + __func__, esp_netif_config); + return NULL; + } +#endif + // Create parent esp-netif object esp_netif_t *esp_netif = calloc(1, sizeof(struct esp_netif_obj)); if (!esp_netif) {