mirror of
https://github.com/espressif/esp-idf.git
synced 2026-04-27 19:13:21 +00:00
fix(esp_netif): Simplify reporting clients hostname
This commit is contained in:
committed by
David Čermák
parent
9063a6c279
commit
35b47648e0
@@ -174,10 +174,11 @@ typedef struct {
|
||||
esp_ip4_addr_t ip; /*!< IP address which was assigned to the station */
|
||||
uint8_t mac[6]; /*!< MAC address of the connected client */
|
||||
/* Client hostname as provided via DHCP option 12 (if available). */
|
||||
#ifndef CONFIG_LWIP_DHCPS_MAX_HOSTNAME_LEN
|
||||
#define CONFIG_LWIP_DHCPS_MAX_HOSTNAME_LEN 64
|
||||
#endif
|
||||
#ifdef CONFIG_LWIP_DHCPS_REPORT_CLIENT_HOSTNAME
|
||||
#define ESP_NETIF_HOSTNAME_MAX_LEN CONFIG_LWIP_DHCPS_MAX_HOSTNAME_LEN
|
||||
#else
|
||||
#define ESP_NETIF_HOSTNAME_MAX_LEN 1 /* Minimal footprint when hostname reporting is disabled - just null terminator for API compatibility */
|
||||
#endif
|
||||
char hostname[ESP_NETIF_HOSTNAME_MAX_LEN]; /*!< Optional DHCP client hostname (may be empty string) */
|
||||
} ip_event_assigned_ip_to_client_t;
|
||||
|
||||
|
||||
@@ -1142,7 +1142,6 @@ static void esp_netif_dhcps_cb(void* arg, uint8_t ip[4], uint8_t mac[6])
|
||||
ESP_LOGI(TAG, "DHCP server assigned IP to a client, IP is: " IPSTR, IP2STR(&evt.ip));
|
||||
ESP_LOGD(TAG, "Client's MAC: %x:%x:%x:%x:%x:%x", mac[0], mac[1], mac[2], mac[3], mac[4], mac[5]);
|
||||
|
||||
#if CONFIG_LWIP_DHCPS_REPORT_CLIENT_HOSTNAME
|
||||
/* Try to fetch hostname for this MAC if available */
|
||||
if (esp_netif && esp_netif->dhcps) {
|
||||
/* Ensure zero-terminated even if not found */
|
||||
@@ -1152,7 +1151,6 @@ static void esp_netif_dhcps_cb(void* arg, uint8_t ip[4], uint8_t mac[6])
|
||||
}
|
||||
}
|
||||
}
|
||||
#endif
|
||||
|
||||
int ret = esp_event_post(IP_EVENT, IP_EVENT_ASSIGNED_IP_TO_CLIENT, &evt, sizeof(evt), 0);
|
||||
if (ESP_OK != ret) {
|
||||
|
||||
@@ -105,13 +105,8 @@ static void wifi_event_handler(void *arg, esp_event_base_t event_base,
|
||||
xEventGroupSetBits(s_wifi_event_group, WIFI_CONNECTED_BIT);
|
||||
} else if (event_base == IP_EVENT && event_id == IP_EVENT_ASSIGNED_IP_TO_CLIENT) {
|
||||
const ip_event_assigned_ip_to_client_t *e = (const ip_event_assigned_ip_to_client_t *)event_data;
|
||||
#if CONFIG_LWIP_DHCPS_REPORT_CLIENT_HOSTNAME
|
||||
ESP_LOGI(TAG_AP, "Assigned IP to client: " IPSTR ", MAC=" MACSTR ", hostname='%s'",
|
||||
IP2STR(&e->ip), MAC2STR(e->mac), e->hostname);
|
||||
#else
|
||||
ESP_LOGI(TAG_AP, "Assigned IP to client: " IPSTR ", MAC=" MACSTR,
|
||||
IP2STR(&e->ip), MAC2STR(e->mac));
|
||||
#endif
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
Reference in New Issue
Block a user