Skip to content

Commit 5982d1c

Browse files
committed
Fix(dhcps):fix dhcp subnet option api dos not work issue
1 parent c4eea80 commit 5982d1c

File tree

1 file changed

+17
-0
lines changed

1 file changed

+17
-0
lines changed

components/esp_netif/lwip/esp_netif_lwip.c

+17
Original file line numberDiff line numberDiff line change
@@ -2258,6 +2258,23 @@ esp_err_t esp_netif_dhcps_option_api(esp_netif_api_msg_t *msg)
22582258
break;
22592259
}
22602260
case ESP_NETIF_SUBNET_MASK: {
2261+
esp_netif_ip_info_t *default_ip = esp_netif->ip_info;
2262+
ip4_addr_t *config_netmask = (ip4_addr_t *)opt->val;
2263+
if (!memcmp(&default_ip->netmask, config_netmask, sizeof(struct ip4_addr))) {
2264+
ESP_LOGE(TAG, "Please use esp_netif_set_ip_info interface to configure subnet mask");
2265+
/*
2266+
* This API directly changes the subnet mask of dhcp server
2267+
* but the subnet mask of the network interface has not changed
2268+
* If you need to change the subnet mask of dhcp server
2269+
* you need to change the subnet mask of the network interface first.
2270+
* If the subnet mask of dhcp server is changed
2271+
* and the subnet mask of network interface is inconsistent
2272+
* with the subnet mask of dhcp sever, it may lead to the failure of sending packets.
2273+
* If want to configure the subnet mask of dhcp server
2274+
* please use esp_netif_set_ip_info to change the subnet mask of network interface first.
2275+
*/
2276+
return ESP_ERR_ESP_NETIF_INVALID_PARAMS;
2277+
}
22612278
memcpy(opt_info, opt->val, opt->len);
22622279
break;
22632280
}

0 commit comments

Comments
 (0)