Skip to content

Commit 121b525

Browse files
gjc13suren-gabrielyan-espressif
authored andcommitted
mdns: fix empty address change announce packets
* Original commit: espressif/esp-idf@7bbb72d
1 parent 418fb60 commit 121b525

File tree

1 file changed

+23
-1
lines changed

1 file changed

+23
-1
lines changed

components/mdns/mdns.c

Lines changed: 23 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1612,6 +1612,23 @@ static mdns_tx_packet_t * _mdns_create_probe_packet(mdns_if_t tcpip_if, mdns_ip_
16121612
return packet;
16131613
}
16141614

1615+
/**
1616+
* @brief Create announce packet for self IP addresses
1617+
*/
1618+
static mdns_tx_packet_t * _mdns_create_announce_self_ip(mdns_if_t tcpip_if, mdns_ip_protocol_t ip_protocol)
1619+
{
1620+
mdns_tx_packet_t * packet = _mdns_alloc_packet_default(tcpip_if, ip_protocol);
1621+
if (!packet) {
1622+
return NULL;
1623+
}
1624+
mdns_host_item_t * host = mdns_get_host_item(_mdns_server->hostname);
1625+
if (!_mdns_append_host(&packet->servers, host, true, false)) {
1626+
_mdns_free_tx_packet(packet);
1627+
return NULL;
1628+
}
1629+
return packet;
1630+
}
1631+
16151632
/**
16161633
* @brief Create announce packet for particular services on particular PCB
16171634
*/
@@ -1872,7 +1889,12 @@ static void _mdns_announce_pcb(mdns_if_t tcpip_if, mdns_ip_protocol_t ip_protoco
18721889
}
18731890

18741891
_pcb->state = PCB_ANNOUNCE_1;
1875-
mdns_tx_packet_t * p = _mdns_create_announce_packet(tcpip_if, ip_protocol, services, len, include_ip);
1892+
mdns_tx_packet_t * p = NULL;
1893+
if (services != NULL) {
1894+
p = _mdns_create_announce_packet(tcpip_if, ip_protocol, services, len, include_ip);
1895+
} else {
1896+
p = _mdns_create_announce_self_ip(tcpip_if, ip_protocol);
1897+
}
18761898
if (p) {
18771899
_mdns_schedule_tx_packet(p, 0);
18781900
}

0 commit comments

Comments
 (0)