From c69f3aec91c3180976a7cc9d97a52dd0da2fed6e Mon Sep 17 00:00:00 2001 From: xueyunfei Date: Fri, 10 Nov 2023 11:19:41 +0800 Subject: [PATCH 1/2] Fix(dhcps):fix dhcp subnet option api dos not work issue --- components/esp_netif/lwip/esp_netif_lwip.c | 17 +++++++++++++++++ 1 file changed, 17 insertions(+) diff --git a/components/esp_netif/lwip/esp_netif_lwip.c b/components/esp_netif/lwip/esp_netif_lwip.c index 81aba2a9884..d1364e97d6b 100644 --- a/components/esp_netif/lwip/esp_netif_lwip.c +++ b/components/esp_netif/lwip/esp_netif_lwip.c @@ -2223,6 +2223,23 @@ esp_err_t esp_netif_dhcps_option_api(esp_netif_api_msg_t *msg) break; } case ESP_NETIF_SUBNET_MASK: { + esp_netif_ip_info_t *default_ip = esp_netif->ip_info; + ip4_addr_t *config_netmask = (ip4_addr_t *)opt->val; + if (!memcmp(&default_ip->netmask, config_netmask, sizeof(struct ip4_addr))) { + ESP_LOGE(TAG, "Please use esp_netif_set_ip_info interface to configure subnet mask"); + /* + * This API directly changes the subnet mask of dhcp server + * but the subnet mask of the network interface has not changed + * If you need to change the subnet mask of dhcp server + * you need to change the subnet mask of the network interface first. + * If the subnet mask of dhcp server is changed + * and the subnet mask of network interface is inconsistent + * with the subnet mask of dhcp sever, it may lead to the failure of sending packets. + * If want to configure the subnet mask of dhcp server + * please use esp_netif_set_ip_info to change the subnet mask of network interface first. + */ + return ESP_ERR_ESP_NETIF_INVALID_PARAMS; + } memcpy(opt_info, opt->val, opt->len); break; } From 97b9c24c628f6fa33a154ec33982dcadde0cc795 Mon Sep 17 00:00:00 2001 From: xueyunfei Date: Tue, 5 Dec 2023 15:56:20 +0800 Subject: [PATCH 2/2] fix(dhcp server):dhcp server can not restore address pool --- components/esp_netif/lwip/esp_netif_lwip.c | 3 --- 1 file changed, 3 deletions(-) diff --git a/components/esp_netif/lwip/esp_netif_lwip.c b/components/esp_netif/lwip/esp_netif_lwip.c index d1364e97d6b..fa2579d6b84 100644 --- a/components/esp_netif/lwip/esp_netif_lwip.c +++ b/components/esp_netif/lwip/esp_netif_lwip.c @@ -2280,10 +2280,7 @@ esp_err_t esp_netif_dhcps_option_api(esp_netif_api_msg_t *msg) if ((end_ip - start_ip + 1 > DHCPS_MAX_LEASE) || (start_ip >= end_ip)) { return ESP_ERR_ESP_NETIF_INVALID_PARAMS; } - } else { - return ESP_ERR_ESP_NETIF_INVALID_PARAMS; } - memcpy(opt_info, opt->val, opt->len); break; }