mirror of
https://github.com/espressif/esp-idf.git
synced 2024-10-05 20:47:46 -04:00
Merge branch 'bugfix/mdns_netif_local' into 'master'
mdns: fix preset of esp_netif ptr for local interfaces Closes WIFI-1538 See merge request espressif/esp-idf!7009
This commit is contained in:
commit
f0680b99b3
@ -56,6 +56,18 @@ static esp_netif_t * s_esp_netifs[MDNS_IF_MAX] = {};
|
||||
esp_netif_t *_mdns_get_esp_netif(mdns_if_t tcpip_if)
|
||||
{
|
||||
if (tcpip_if < MDNS_IF_MAX) {
|
||||
if (s_esp_netifs[tcpip_if] == NULL) {
|
||||
// if local netif copy is NULL, try to search for the default interface key
|
||||
if (tcpip_if == MDNS_IF_STA) {
|
||||
s_esp_netifs[MDNS_IF_STA] = esp_netif_get_handle_from_ifkey("WIFI_STA_DEF");
|
||||
} else if (tcpip_if == MDNS_IF_AP) {
|
||||
s_esp_netifs[MDNS_IF_AP] = esp_netif_get_handle_from_ifkey("WIFI_AP_DEF");
|
||||
#if CONFIG_ETH_ENABLED
|
||||
} else if (tcpip_if == MDNS_IF_ETH) {
|
||||
s_esp_netifs[MDNS_IF_ETH] = esp_netif_get_handle_from_ifkey("ETH_DEF");
|
||||
#endif
|
||||
}
|
||||
}
|
||||
return s_esp_netifs[tcpip_if];
|
||||
}
|
||||
return NULL;
|
||||
@ -3106,17 +3118,6 @@ static void _mdns_handle_system_event(esp_event_base_t event_base,
|
||||
return;
|
||||
}
|
||||
|
||||
// Initialize handles to esp-netif if appropriate mdns supported interface started
|
||||
if (event_base == WIFI_EVENT && event_id == WIFI_EVENT_STA_START) {
|
||||
s_esp_netifs[MDNS_IF_STA] = esp_netif_get_handle_from_ifkey("WIFI_STA_DEF");
|
||||
} else if (event_base == WIFI_EVENT && event_id == WIFI_EVENT_AP_START) {
|
||||
s_esp_netifs[MDNS_IF_AP] = esp_netif_get_handle_from_ifkey("WIFI_AP_DEF");
|
||||
#if CONFIG_ETH_ENABLED
|
||||
} else if (event_base == ETH_EVENT && event_id == ETHERNET_EVENT_START) {
|
||||
s_esp_netifs[MDNS_IF_ETH] = esp_netif_get_handle_from_ifkey("ETH_DEF");
|
||||
#endif
|
||||
}
|
||||
|
||||
esp_netif_dhcp_status_t dcst;
|
||||
if (event_base == WIFI_EVENT) {
|
||||
switch(event_id) {
|
||||
@ -4231,6 +4232,8 @@ esp_err_t mdns_init(void)
|
||||
return ESP_ERR_NO_MEM;
|
||||
}
|
||||
memset((uint8_t*)_mdns_server, 0, sizeof(mdns_server_t));
|
||||
// zero-out local copy of netifs to initiate a fresh search by interface key whenever a netif ptr is needed
|
||||
memset(s_esp_netifs, 0, sizeof(s_esp_netifs));
|
||||
|
||||
_mdns_server->lock = xSemaphoreCreateMutex();
|
||||
if (!_mdns_server->lock) {
|
||||
|
Loading…
x
Reference in New Issue
Block a user