Skip to content

Commit

Permalink
Merge pull request #661 from gytxxsy/feat/monitor_interface_status_fo…
Browse files Browse the repository at this point in the history
…r_browsing

[mdns]: send PTR query for mdns browse when interface is ready (IDFGH-13841)
  • Loading branch information
david-cermak authored Oct 25, 2024
2 parents a5b0b9d + 010a404 commit fbd296f
Showing 1 changed file with 12 additions and 9 deletions.
21 changes: 12 additions & 9 deletions components/mdns/mdns.c
Original file line number Diff line number Diff line change
Expand Up @@ -25,7 +25,7 @@ static esp_err_t _mdns_sync_browse_action(mdns_action_type_t type, mdns_browse_s
static void _mdns_browse_sync(mdns_browse_sync_t *browse_sync);
static void _mdns_browse_finish(mdns_browse_t *browse);
static void _mdns_browse_add(mdns_browse_t *browse);
static void _mdns_browse_send(mdns_browse_t *browse);
static void _mdns_browse_send(mdns_browse_t *browse, mdns_if_t interface);

#if CONFIG_ETH_ENABLED && CONFIG_MDNS_PREDEF_NETIF_ETH
#include "esp_eth.h"
Expand Down Expand Up @@ -4476,7 +4476,11 @@ void mdns_preset_if_handle_system_event(void *arg, esp_event_base_t event_base,
post_mdns_enable_pcb(mdns_if, MDNS_IP_PROTOCOL_V6);
post_mdns_announce_pcb(mdns_if, MDNS_IP_PROTOCOL_V4);
}

mdns_browse_t *browse = _mdns_server->browse;
while (browse) {
_mdns_browse_send(browse, mdns_if);
browse = browse->next;
}
}
break;
default:
Expand Down Expand Up @@ -7119,7 +7123,9 @@ static void _mdns_browse_add(mdns_browse_t *browse)
browse->next = _mdns_server->browse;
_mdns_server->browse = browse;
}
_mdns_browse_send(browse);
for (uint8_t interface_idx = 0; interface_idx < MDNS_MAX_INTERFACES; interface_idx++) {
_mdns_browse_send(browse, (mdns_if_t)interface_idx);
}
if (found) {
_mdns_browse_item_free(browse);
}
Expand All @@ -7128,7 +7134,7 @@ static void _mdns_browse_add(mdns_browse_t *browse)
/**
* @brief Send PTR query packet to all available interfaces for browsing.
*/
static void _mdns_browse_send(mdns_browse_t *browse)
static void _mdns_browse_send(mdns_browse_t *browse, mdns_if_t interface)
{
// Using search once for sending the PTR query
mdns_search_once_t search = {0};
Expand All @@ -7141,11 +7147,8 @@ static void _mdns_browse_send(mdns_browse_t *browse)
search.result = NULL;
search.next = NULL;

uint8_t i, j;
for (i = 0; i < MDNS_MAX_INTERFACES; i++) {
for (j = 0; j < MDNS_IP_PROTOCOL_MAX; j++) {
_mdns_search_send_pcb(&search, (mdns_if_t)i, (mdns_ip_protocol_t)j);
}
for (uint8_t protocol_idx = 0; protocol_idx < MDNS_IP_PROTOCOL_MAX; protocol_idx++) {
_mdns_search_send_pcb(&search, interface, (mdns_ip_protocol_t)protocol_idx);
}
}

Expand Down

0 comments on commit fbd296f

Please sign in to comment.