esp-netif: use dhcp server netmask
Use the configured esp-netif netmask to update the dhcp struct when starting the server or starting the netif itself. Use the netmask in dhcps setters and getters.
This commit is contained in:
parent
fa57bdbdbe
commit
2fce539d1e
2 changed files with 13 additions and 1 deletions
|
@ -73,6 +73,7 @@ typedef enum{
|
||||||
|
|
||||||
/** @brief Supported options for DHCP client or DHCP server */
|
/** @brief Supported options for DHCP client or DHCP server */
|
||||||
typedef enum{
|
typedef enum{
|
||||||
|
ESP_NETIF_SUBNET_MASK = 1, /**< Network mask */
|
||||||
ESP_NETIF_DOMAIN_NAME_SERVER = 6, /**< Domain name server */
|
ESP_NETIF_DOMAIN_NAME_SERVER = 6, /**< Domain name server */
|
||||||
ESP_NETIF_ROUTER_SOLICITATION_ADDRESS = 32, /**< Solicitation router address */
|
ESP_NETIF_ROUTER_SOLICITATION_ADDRESS = 32, /**< Solicitation router address */
|
||||||
ESP_NETIF_REQUESTED_IP_ADDRESS = 50, /**< Request specific IP address */
|
ESP_NETIF_REQUESTED_IP_ADDRESS = 50, /**< Request specific IP address */
|
||||||
|
|
|
@ -627,8 +627,11 @@ static esp_err_t esp_netif_start_api(esp_netif_api_msg_t *msg)
|
||||||
if (p_netif != NULL && netif_is_up(p_netif)) {
|
if (p_netif != NULL && netif_is_up(p_netif)) {
|
||||||
esp_netif_ip_info_t *default_ip = esp_netif->ip_info;
|
esp_netif_ip_info_t *default_ip = esp_netif->ip_info;
|
||||||
ip4_addr_t lwip_ip;
|
ip4_addr_t lwip_ip;
|
||||||
|
ip4_addr_t lwip_netmask;
|
||||||
memcpy(&lwip_ip, &default_ip->ip, sizeof(struct ip4_addr));
|
memcpy(&lwip_ip, &default_ip->ip, sizeof(struct ip4_addr));
|
||||||
|
memcpy(&lwip_netmask, &default_ip->netmask, sizeof(struct ip4_addr));
|
||||||
dhcps_set_new_lease_cb(esp_netif_dhcps_cb);
|
dhcps_set_new_lease_cb(esp_netif_dhcps_cb);
|
||||||
|
dhcps_set_option_info(SUBNET_MASK, (void*)&lwip_netmask, sizeof(lwip_netmask));
|
||||||
dhcps_start(p_netif, lwip_ip);
|
dhcps_start(p_netif, lwip_ip);
|
||||||
esp_netif->dhcps_status = ESP_NETIF_DHCP_STARTED;
|
esp_netif->dhcps_status = ESP_NETIF_DHCP_STARTED;
|
||||||
ESP_LOGD(TAG, "DHCP server started successfully");
|
ESP_LOGD(TAG, "DHCP server started successfully");
|
||||||
|
@ -986,8 +989,11 @@ static esp_err_t esp_netif_dhcps_start_api(esp_netif_api_msg_t *msg)
|
||||||
if (p_netif != NULL && netif_is_up(p_netif)) {
|
if (p_netif != NULL && netif_is_up(p_netif)) {
|
||||||
esp_netif_ip_info_t *default_ip = esp_netif->ip_info;
|
esp_netif_ip_info_t *default_ip = esp_netif->ip_info;
|
||||||
ip4_addr_t lwip_ip;
|
ip4_addr_t lwip_ip;
|
||||||
|
ip4_addr_t lwip_netmask;
|
||||||
memcpy(&lwip_ip, &default_ip->ip, sizeof(struct ip4_addr));
|
memcpy(&lwip_ip, &default_ip->ip, sizeof(struct ip4_addr));
|
||||||
|
memcpy(&lwip_netmask, &default_ip->netmask, sizeof(struct ip4_addr));
|
||||||
dhcps_set_new_lease_cb(esp_netif_dhcps_cb);
|
dhcps_set_new_lease_cb(esp_netif_dhcps_cb);
|
||||||
|
dhcps_set_option_info(SUBNET_MASK, (void*)&lwip_netmask, sizeof(lwip_netmask));
|
||||||
dhcps_start(p_netif, lwip_ip);
|
dhcps_start(p_netif, lwip_ip);
|
||||||
esp_netif->dhcps_status = ESP_NETIF_DHCP_STARTED;
|
esp_netif->dhcps_status = ESP_NETIF_DHCP_STARTED;
|
||||||
ESP_LOGD(TAG, "DHCP server started successfully");
|
ESP_LOGD(TAG, "DHCP server started successfully");
|
||||||
|
@ -1547,6 +1553,7 @@ esp_err_t esp_netif_dhcps_option(esp_netif_t *esp_netif, esp_netif_dhcp_option_m
|
||||||
*(uint32_t *)opt_val = *(uint32_t *)opt_info;
|
*(uint32_t *)opt_val = *(uint32_t *)opt_info;
|
||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
|
case ESP_NETIF_SUBNET_MASK:
|
||||||
case REQUESTED_IP_ADDRESS: {
|
case REQUESTED_IP_ADDRESS: {
|
||||||
memcpy(opt_val, opt_info, opt_len);
|
memcpy(opt_val, opt_info, opt_len);
|
||||||
break;
|
break;
|
||||||
|
@ -1584,6 +1591,10 @@ esp_err_t esp_netif_dhcps_option(esp_netif_t *esp_netif, esp_netif_dhcp_option_m
|
||||||
}
|
}
|
||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
|
case ESP_NETIF_SUBNET_MASK: {
|
||||||
|
memcpy(opt_info, opt_val, opt_len);
|
||||||
|
break;
|
||||||
|
}
|
||||||
case REQUESTED_IP_ADDRESS: {
|
case REQUESTED_IP_ADDRESS: {
|
||||||
esp_netif_ip_info_t info;
|
esp_netif_ip_info_t info;
|
||||||
uint32_t softap_ip = 0;
|
uint32_t softap_ip = 0;
|
||||||
|
|
Loading…
Reference in a new issue