Skip to content

Commit 35b4764

Browse files
committed
fix(esp_netif): Simplify reporting clients hostname
1 parent 9063a6c commit 35b4764

File tree

3 files changed

+4
-10
lines changed

3 files changed

+4
-10
lines changed

components/esp_netif/include/esp_netif_types.h

Lines changed: 4 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -174,10 +174,11 @@ typedef struct {
174174
esp_ip4_addr_t ip; /*!< IP address which was assigned to the station */
175175
uint8_t mac[6]; /*!< MAC address of the connected client */
176176
/* Client hostname as provided via DHCP option 12 (if available). */
177-
#ifndef CONFIG_LWIP_DHCPS_MAX_HOSTNAME_LEN
178-
#define CONFIG_LWIP_DHCPS_MAX_HOSTNAME_LEN 64
179-
#endif
177+
#ifdef CONFIG_LWIP_DHCPS_REPORT_CLIENT_HOSTNAME
180178
#define ESP_NETIF_HOSTNAME_MAX_LEN CONFIG_LWIP_DHCPS_MAX_HOSTNAME_LEN
179+
#else
180+
#define ESP_NETIF_HOSTNAME_MAX_LEN 1 /* Minimal footprint when hostname reporting is disabled - just null terminator for API compatibility */
181+
#endif
181182
char hostname[ESP_NETIF_HOSTNAME_MAX_LEN]; /*!< Optional DHCP client hostname (may be empty string) */
182183
} ip_event_assigned_ip_to_client_t;
183184

components/esp_netif/lwip/esp_netif_lwip.c

Lines changed: 0 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1142,7 +1142,6 @@ static void esp_netif_dhcps_cb(void* arg, uint8_t ip[4], uint8_t mac[6])
11421142
ESP_LOGI(TAG, "DHCP server assigned IP to a client, IP is: " IPSTR, IP2STR(&evt.ip));
11431143
ESP_LOGD(TAG, "Client's MAC: %x:%x:%x:%x:%x:%x", mac[0], mac[1], mac[2], mac[3], mac[4], mac[5]);
11441144

1145-
#if CONFIG_LWIP_DHCPS_REPORT_CLIENT_HOSTNAME
11461145
/* Try to fetch hostname for this MAC if available */
11471146
if (esp_netif && esp_netif->dhcps) {
11481147
/* 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])
11521151
}
11531152
}
11541153
}
1155-
#endif
11561154

11571155
int ret = esp_event_post(IP_EVENT, IP_EVENT_ASSIGNED_IP_TO_CLIENT, &evt, sizeof(evt), 0);
11581156
if (ESP_OK != ret) {

examples/wifi/softap_sta/main/softap_sta.c

Lines changed: 0 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -105,13 +105,8 @@ static void wifi_event_handler(void *arg, esp_event_base_t event_base,
105105
xEventGroupSetBits(s_wifi_event_group, WIFI_CONNECTED_BIT);
106106
} else if (event_base == IP_EVENT && event_id == IP_EVENT_ASSIGNED_IP_TO_CLIENT) {
107107
const ip_event_assigned_ip_to_client_t *e = (const ip_event_assigned_ip_to_client_t *)event_data;
108-
#if CONFIG_LWIP_DHCPS_REPORT_CLIENT_HOSTNAME
109108
ESP_LOGI(TAG_AP, "Assigned IP to client: " IPSTR ", MAC=" MACSTR ", hostname='%s'",
110109
IP2STR(&e->ip), MAC2STR(e->mac), e->hostname);
111-
#else
112-
ESP_LOGI(TAG_AP, "Assigned IP to client: " IPSTR ", MAC=" MACSTR,
113-
IP2STR(&e->ip), MAC2STR(e->mac));
114-
#endif
115110
}
116111
}
117112

0 commit comments

Comments
 (0)