From e7afdff6ca0c23956ecd5791adb3ba1288e94a6c Mon Sep 17 00:00:00 2001 From: David Cermak Date: Thu, 14 Jul 2022 10:34:06 +0200 Subject: [PATCH] esp_netif: Make set_link_speed() conditional on MIB2_STATS --- .../esp_netif/include/lwip/esp_netif_net_stack.h | 13 ++++++++----- components/esp_netif/lwip/esp_netif_lwip.c | 16 ++++++++++++---- 2 files changed, 20 insertions(+), 9 deletions(-) diff --git a/components/esp_netif/include/lwip/esp_netif_net_stack.h b/components/esp_netif/include/lwip/esp_netif_net_stack.h index 2c4d125280..e908b96a60 100644 --- a/components/esp_netif/include/lwip/esp_netif_net_stack.h +++ b/components/esp_netif/include/lwip/esp_netif_net_stack.h @@ -13,19 +13,22 @@ #if defined(CONFIG_ESP_NETIF_TCPIP_LWIP) +typedef err_t (*init_fn_t)(struct netif*); +typedef void (*input_fn_t)(void *netif, void *buffer, size_t len, void *eb); + struct esp_netif_netstack_lwip_vanilla_config { - err_t (*init_fn)(struct netif*); - void (*input_fn)(void *netif, void *buffer, size_t len, void *eb); + init_fn_t init_fn; + input_fn_t input_fn; }; struct esp_netif_netstack_lwip_ppp_config { - void (*input_fn)(void *netif, void *buffer, size_t len, void *eb); + input_fn_t input_fn; esp_netif_ppp_config_t ppp_events; }; struct esp_netif_netstack_lwip_slip_config { - err_t (*init_fn)(struct netif*); - void (*input_fn)(void *netif, void *buffer, size_t len, void *eb); + init_fn_t init_fn; + input_fn_t input_fn; esp_netif_slip_config_t slip_config; }; diff --git a/components/esp_netif/lwip/esp_netif_lwip.c b/components/esp_netif/lwip/esp_netif_lwip.c index a70d40d1e2..d702136028 100644 --- a/components/esp_netif/lwip/esp_netif_lwip.c +++ b/components/esp_netif/lwip/esp_netif_lwip.c @@ -1684,9 +1684,9 @@ struct array_mac_ip_t { static esp_err_t esp_netif_dhcps_get_clients_by_mac_api(esp_netif_api_msg_t *msg) { esp_netif_t *netif = msg->esp_netif; - struct array_mac_ip_t *params = msg->data; - for (int i = 0; i < params->num; i++) { - dhcp_search_ip_on_mac(netif->dhcps, params->mac_ip_pair[i].mac, (ip4_addr_t*)¶ms->mac_ip_pair[i].ip); + struct array_mac_ip_t *mac_ip_list = msg->data; + for (int i = 0; i < mac_ip_list->num; i++) { + dhcp_search_ip_on_mac(netif->dhcps, mac_ip_list->mac_ip_pair[i].mac, (ip4_addr_t*)&mac_ip_list->mac_ip_pair[i].ip); } return ESP_OK; } @@ -2184,18 +2184,26 @@ esp_err_t esp_netif_get_netif_impl_name(esp_netif_t *esp_netif, char* name) return ESP_OK; } +#if MIB2_STATS static esp_err_t esp_netif_set_link_speed_api(esp_netif_api_msg_t *msg) { uint32_t speed = *((uint32_t*)msg->data); esp_err_t error = ESP_OK; ESP_LOGD(TAG, "%s esp_netif:%p", __func__, msg->esp_netif); - NETIF_INIT_SNMP(netif, snmp_ifType_ethernet_csmacd, speed); + NETIF_INIT_SNMP(msg->esp_netif->lwip_netif, snmp_ifType_ethernet_csmacd, speed); LWIP_UNUSED_ARG(speed); // Maybe unused if SNMP disabled return error; } esp_err_t esp_netif_set_link_speed(esp_netif_t *esp_netif, uint32_t speed) _RUN_IN_LWIP_TASK(esp_netif_set_link_speed_api, esp_netif, &speed) +#else +esp_err_t esp_netif_set_link_speed(esp_netif_t *esp_netif, uint32_t speed) +{ + // link speed is used only to collect interface related statistics (if MIB2_STATS enabled) + return ESP_OK; +} +#endif /* MIB2_STATS */ #if CONFIG_LWIP_IPV6