diff --git a/src/apps/mdns/mdns.c b/src/apps/mdns/mdns.c index 6fc7ce7f..98b9e801 100644 --- a/src/apps/mdns/mdns.c +++ b/src/apps/mdns/mdns.c @@ -1008,6 +1008,9 @@ mdns_add_answer(struct mdns_outpacket *reply, struct mdns_domain *domain, u16_t /* Write rd_length after when we know the answer size */ field16 = htons(reply->write_offset - answer_offset); res = pbuf_take_at(reply->pbuf, &field16, sizeof(field16), rdlen_offset); + if (res == ERR_OK) { + reply->answers++; + } return res; } @@ -1295,14 +1298,12 @@ mdns_send_outpacket(struct mdns_outpacket *outpkt) if (res != ERR_OK) { goto cleanup; } - outpkt->answers++; } if (outpkt->host_replies & REPLY_HOST_PTR_V4) { res = mdns_add_hostv4_ptr_answer(outpkt, outpkt->cache_flush, outpkt->netif); if (res != ERR_OK) { goto cleanup; } - outpkt->answers++; } #endif #if LWIP_IPV6 @@ -1314,7 +1315,6 @@ mdns_send_outpacket(struct mdns_outpacket *outpkt) if (res != ERR_OK) { goto cleanup; } - outpkt->answers++; } } } @@ -1327,7 +1327,6 @@ mdns_send_outpacket(struct mdns_outpacket *outpkt) if (res != ERR_OK) { goto cleanup; } - outpkt->answers++; } addrindex++; rev_addrs >>= 1; @@ -1347,7 +1346,6 @@ mdns_send_outpacket(struct mdns_outpacket *outpkt) if (res != ERR_OK) { goto cleanup; } - outpkt->answers++; } if (outpkt->serv_replies[i] & REPLY_SERVICE_NAME_PTR) { @@ -1355,7 +1353,6 @@ mdns_send_outpacket(struct mdns_outpacket *outpkt) if (res != ERR_OK) { goto cleanup; } - outpkt->answers++; } if (outpkt->serv_replies[i] & REPLY_SERVICE_SRV) { @@ -1363,7 +1360,6 @@ mdns_send_outpacket(struct mdns_outpacket *outpkt) if (res != ERR_OK) { goto cleanup; } - outpkt->answers++; } if (outpkt->serv_replies[i] & REPLY_SERVICE_TXT) { @@ -1371,7 +1367,6 @@ mdns_send_outpacket(struct mdns_outpacket *outpkt) if (res != ERR_OK) { goto cleanup; } - outpkt->answers++; } }