mirror of
https://github.com/espressif/esp-protocols.git
synced 2025-07-16 20:12:13 +02:00
Merge pull request #301 from zwx1995esp/fix/delegated_service_PTR_response
fix(mdns): Fix delegated service PTR response (IDFGH-10237)
This commit is contained in:
@ -1725,13 +1725,16 @@ static bool _mdns_create_answer_from_service(mdns_tx_packet_t *packet, mdns_serv
|
|||||||
mdns_parsed_question_t *question, bool shared, bool send_flush)
|
mdns_parsed_question_t *question, bool shared, bool send_flush)
|
||||||
{
|
{
|
||||||
mdns_host_item_t *host = mdns_get_host_item(service->hostname);
|
mdns_host_item_t *host = mdns_get_host_item(service->hostname);
|
||||||
|
bool is_delegated = (host != &_mdns_self_host);
|
||||||
if (question->type == MDNS_TYPE_PTR || question->type == MDNS_TYPE_ANY) {
|
if (question->type == MDNS_TYPE_PTR || question->type == MDNS_TYPE_ANY) {
|
||||||
|
// According to RFC6763-section12.1, for DNS-SD, SRV, TXT and all address records
|
||||||
|
// should be included in additional records.
|
||||||
if (!_mdns_alloc_answer(&packet->answers, MDNS_TYPE_PTR, service, NULL, false, false) ||
|
if (!_mdns_alloc_answer(&packet->answers, MDNS_TYPE_PTR, service, NULL, false, false) ||
|
||||||
!_mdns_alloc_answer(&packet->answers, MDNS_TYPE_SRV, service, NULL, send_flush, false) ||
|
!_mdns_alloc_answer(is_delegated ? &packet->additional : &packet->answers, MDNS_TYPE_SRV, service, NULL, send_flush, false) ||
|
||||||
!_mdns_alloc_answer(&packet->answers, MDNS_TYPE_TXT, service, NULL, send_flush, false) ||
|
!_mdns_alloc_answer(is_delegated ? &packet->additional : &packet->answers, MDNS_TYPE_TXT, service, NULL, send_flush, false) ||
|
||||||
!_mdns_alloc_answer(shared ? &packet->additional : &packet->answers, MDNS_TYPE_A, service, host, send_flush,
|
!_mdns_alloc_answer((shared || is_delegated) ? &packet->additional : &packet->answers, MDNS_TYPE_A, service, host, send_flush,
|
||||||
false) ||
|
false) ||
|
||||||
!_mdns_alloc_answer(shared ? &packet->additional : &packet->answers, MDNS_TYPE_AAAA, service, host,
|
!_mdns_alloc_answer((shared || is_delegated) ? &packet->additional : &packet->answers, MDNS_TYPE_AAAA, service, host,
|
||||||
send_flush, false)) {
|
send_flush, false)) {
|
||||||
return false;
|
return false;
|
||||||
}
|
}
|
||||||
|
Reference in New Issue
Block a user