Skip to content

Commit b4f9290

Browse files
committed
fix(mdns): Revert test Cleanup mdns sender
1 parent 5c2c597 commit b4f9290

File tree

15 files changed

+558
-547
lines changed

15 files changed

+558
-547
lines changed

components/mdns/mdns_browser.c

+1-22
Original file line numberDiff line numberDiff line change
@@ -585,28 +585,7 @@ void mdns_priv_browse_result_add_srv(mdns_browse_t *browse, const char *hostname
585585
r->next = browse->result;
586586
browse->result = r;
587587
add_browse_result(out_sync_browse, r);
588-
}
589-
590-
/**4
591-
* @brief Browse sync result
592-
*/
593-
esp_err_t mdns_priv_browse_sync(mdns_browse_sync_t *browse_sync)
594-
{
595-
mdns_action_t *action = NULL;
596-
597-
action = (mdns_action_t *)mdns_mem_malloc(sizeof(mdns_action_t));
598-
if (!action) {
599-
HOOK_MALLOC_FAILED;
600-
return ESP_ERR_NO_MEM;
601-
}
602-
603-
action->type = ACTION_BROWSE_SYNC;
604-
action->data.browse_sync.browse_sync = browse_sync;
605-
if (!mdns_priv_queue_action(action)) {
606-
mdns_mem_free(action);
607-
return ESP_ERR_NO_MEM;
608-
}
609-
return ESP_OK;
588+
return;
610589
}
611590

612591
/**

components/mdns/mdns_pcb.c

+23-27
Original file line numberDiff line numberDiff line change
@@ -48,23 +48,20 @@ void mdns_priv_pcb_announce(mdns_if_t tcpip_if, mdns_ip_protocol_t ip_protocol,
4848
if (PCB_STATE_IS_PROBING(_pcb)) {
4949
mdns_priv_init_pcb_probe(tcpip_if, ip_protocol, services, len, include_ip);
5050
} else if (PCB_STATE_IS_ANNOUNCING(_pcb)) {
51-
mdns_tx_packet_t *p = mdns_priv_get_next_packet(tcpip_if, ip_protocol);
51+
mdns_tx_packet_t *p = _mdns_get_next_pcb_packet(tcpip_if, ip_protocol);
5252
if (p) {
5353
for (i = 0; i < len; i++) {
54-
if (!mdns_priv_create_answer(&p->answers, MDNS_TYPE_SDPTR, services[i]->service, NULL, false, false)
55-
|| !mdns_priv_create_answer(&p->answers, MDNS_TYPE_PTR, services[i]->service, NULL, false,
56-
false)
57-
|| !mdns_priv_create_answer(&p->answers, MDNS_TYPE_SRV, services[i]->service, NULL, true,
58-
false)
59-
|| !mdns_priv_create_answer(&p->answers, MDNS_TYPE_TXT, services[i]->service, NULL, true,
60-
false)) {
54+
if (!_mdns_alloc_answer(&p->answers, MDNS_TYPE_SDPTR, services[i]->service, NULL, false, false)
55+
|| !_mdns_alloc_answer(&p->answers, MDNS_TYPE_PTR, services[i]->service, NULL, false, false)
56+
|| !_mdns_alloc_answer(&p->answers, MDNS_TYPE_SRV, services[i]->service, NULL, true, false)
57+
|| !_mdns_alloc_answer(&p->answers, MDNS_TYPE_TXT, services[i]->service, NULL, true, false)) {
6158
break;
6259
}
6360
}
6461
if (include_ip) {
65-
mdns_priv_dealloc_answer(&p->additional, MDNS_TYPE_A, NULL);
66-
mdns_priv_dealloc_answer(&p->additional, MDNS_TYPE_AAAA, NULL);
67-
mdns_priv_append_host_list_in_services(&p->answers, services, len, true, false);
62+
_mdns_dealloc_answer(&p->additional, MDNS_TYPE_A, NULL);
63+
_mdns_dealloc_answer(&p->additional, MDNS_TYPE_AAAA, NULL);
64+
_mdns_append_host_list_in_services(&p->answers, services, len, true, false);
6865
}
6966
_pcb->state = PCB_ANNOUNCE_1;
7067
}
@@ -75,9 +72,9 @@ void mdns_priv_pcb_announce(mdns_if_t tcpip_if, mdns_ip_protocol_t ip_protocol,
7572
}
7673

7774
_pcb->state = PCB_ANNOUNCE_1;
78-
mdns_tx_packet_t *p = mdns_priv_create_announce_packet(tcpip_if, ip_protocol, services, len, include_ip);
75+
mdns_tx_packet_t *p = _mdns_create_announce_packet(tcpip_if, ip_protocol, services, len, include_ip);
7976
if (p) {
80-
mdns_priv_send_after(p, 0);
77+
mdns_send_schedule_tx_packet(p, 0);
8178
}
8279
}
8380
}
@@ -155,7 +152,7 @@ void mdns_priv_pcb_disable(mdns_if_t tcpip_if, mdns_ip_protocol_t ip_protocol)
155152
mdns_priv_netif_disable(tcpip_if);
156153

157154
if (mdns_priv_if_ready(tcpip_if, ip_protocol)) {
158-
mdns_priv_clear_tx_queue_if(tcpip_if, ip_protocol);
155+
_mdns_clear_pcb_tx_queue_head(tcpip_if, ip_protocol);
159156
deinit_pcb(tcpip_if, ip_protocol);
160157
mdns_if_t other_if = mdns_priv_netif_get_other_interface(tcpip_if);
161158
if (other_if != MDNS_MAX_INTERFACES && s_pcbs[other_if][ip_protocol].state == PCB_DUP) {
@@ -194,7 +191,7 @@ void mdns_priv_pcb_set_duplicate(mdns_if_t tcpip_if)
194191
if (mdns_priv_if_ready(other_if, i)) {
195192
//stop this interface and mark as dup
196193
if (mdns_priv_if_ready(tcpip_if, i)) {
197-
mdns_priv_clear_tx_queue_if(tcpip_if, i);
194+
_mdns_clear_pcb_tx_queue_head(tcpip_if, i);
198195
deinit_pcb(tcpip_if, i);
199196
}
200197
s_pcbs[tcpip_if][i].state = PCB_DUP;
@@ -223,13 +220,13 @@ void mdns_priv_pcb_schedule_tx_packet(mdns_tx_packet_t *p)
223220
}
224221
//fallthrough
225222
case PCB_PROBE_2:
226-
mdns_priv_send_after(p, 250);
223+
mdns_send_schedule_tx_packet(p, 250);
227224
pcb->state = (mdns_pcb_state_t)((uint8_t)(pcb->state) + 1);
228225
break;
229226
case PCB_PROBE_3:
230-
a = mdns_priv_create_announce_from_probe(p);
227+
a = _mdns_create_announce_from_probe(p);
231228
if (!a) {
232-
mdns_priv_send_after(p, 250);
229+
mdns_send_schedule_tx_packet(p, 250);
233230
break;
234231
}
235232
pcb->probe_running = false;
@@ -238,22 +235,22 @@ void mdns_priv_pcb_schedule_tx_packet(mdns_tx_packet_t *p)
238235
pcb->failed_probes = 0;
239236
mdns_mem_free(pcb->probe_services);
240237
pcb->probe_services = NULL;
241-
mdns_priv_free_tx_packet(p);
238+
_mdns_free_tx_packet(p);
242239
p = a;
243240
send_after = 250;
244241
//fallthrough
245242
case PCB_ANNOUNCE_1:
246243
//fallthrough
247244
case PCB_ANNOUNCE_2:
248-
mdns_priv_send_after(p, send_after);
245+
mdns_send_schedule_tx_packet(p, send_after);
249246
pcb->state = (mdns_pcb_state_t)((uint8_t)(pcb->state) + 1);
250247
break;
251248
case PCB_ANNOUNCE_3:
252249
pcb->state = PCB_RUNNING;
253-
mdns_priv_free_tx_packet(p);
250+
_mdns_free_tx_packet(p);
254251
break;
255252
default:
256-
mdns_priv_free_tx_packet(p);
253+
_mdns_free_tx_packet(p);
257254
break;
258255
}
259256
}
@@ -371,8 +368,7 @@ static void init_probe_new_service(mdns_if_t tcpip_if, mdns_ip_protocol_t ip_pro
371368
pcb->probe_services_len = 0;
372369
pcb->probe_running = false;
373370

374-
mdns_tx_packet_t *packet = mdns_priv_create_probe_packet(tcpip_if, ip_protocol, s, services_final_len, true,
375-
probe_ip);
371+
mdns_tx_packet_t *packet = _mdns_create_probe_packet(tcpip_if, ip_protocol, s, services_final_len, true, probe_ip);
376372
if (!packet) {
377373
mdns_mem_free(s);
378374
return;
@@ -382,15 +378,15 @@ static void init_probe_new_service(mdns_if_t tcpip_if, mdns_ip_protocol_t ip_pro
382378
pcb->probe_services = s;
383379
pcb->probe_services_len = services_final_len;
384380
pcb->probe_running = true;
385-
mdns_priv_send_after(packet, ((pcb->failed_probes > 5) ? 1000 : 120) + (esp_random() & 0x7F));
381+
mdns_send_schedule_tx_packet(packet, ((pcb->failed_probes > 5) ? 1000 : 120) + (esp_random() & 0x7F));
386382
pcb->state = PCB_PROBE_1;
387383
}
388384

389385
void mdns_priv_init_pcb_probe(mdns_if_t tcpip_if, mdns_ip_protocol_t ip_protocol, mdns_srv_item_t **services, size_t len, bool probe_ip)
390386
{
391387
mdns_pcb_t *pcb = &s_pcbs[tcpip_if][ip_protocol];
392388

393-
mdns_priv_clear_tx_queue_if(tcpip_if, ip_protocol);
389+
_mdns_clear_pcb_tx_queue_head(tcpip_if, ip_protocol);
394390

395391
if (mdns_utils_str_null_or_empty(mdns_priv_get_global_hostname())) {
396392
pcb->state = PCB_RUNNING;
@@ -436,7 +432,7 @@ void mdns_priv_pcb_send_bye_service(mdns_srv_item_t **services, size_t len, bool
436432
for (i = 0; i < MDNS_MAX_INTERFACES; i++) {
437433
for (j = 0; j < MDNS_IP_PROTOCOL_MAX; j++) {
438434
if (mdns_priv_if_ready(i, j) && s_pcbs[i][j].state == PCB_RUNNING) {
439-
mdns_priv_send_bye((mdns_if_t) i, (mdns_ip_protocol_t) j, services, len, include_ip);
435+
mdns_send_bye_pcb((mdns_if_t) i, (mdns_ip_protocol_t) j, services, len, include_ip);
440436
}
441437
}
442438
}

components/mdns/mdns_querier.c

+5-5
Original file line numberDiff line numberDiff line change
@@ -267,15 +267,15 @@ mdns_search_once_t *mdns_priv_query_find(mdns_name_t *name, uint16_t type, mdns_
267267
static mdns_tx_packet_t *create_search_packet(mdns_search_once_t *search, mdns_if_t tcpip_if, mdns_ip_protocol_t ip_protocol)
268268
{
269269
mdns_result_t *r = NULL;
270-
mdns_tx_packet_t *packet = mdns_priv_alloc_packet(tcpip_if, ip_protocol);
270+
mdns_tx_packet_t *packet = _mdns_alloc_packet_default(tcpip_if, ip_protocol);
271271
if (!packet) {
272272
return NULL;
273273
}
274274

275275
mdns_out_question_t *q = (mdns_out_question_t *)mdns_mem_malloc(sizeof(mdns_out_question_t));
276276
if (!q) {
277277
HOOK_MALLOC_FAILED;
278-
mdns_priv_free_tx_packet(packet);
278+
_mdns_free_tx_packet(packet);
279279
return NULL;
280280
}
281281
q->next = NULL;
@@ -299,7 +299,7 @@ static mdns_tx_packet_t *create_search_packet(mdns_search_once_t *search, mdns_i
299299
mdns_out_answer_t *a = (mdns_out_answer_t *)mdns_mem_malloc(sizeof(mdns_out_answer_t));
300300
if (!a) {
301301
HOOK_MALLOC_FAILED;
302-
mdns_priv_free_tx_packet(packet);
302+
_mdns_free_tx_packet(packet);
303303
return NULL;
304304
}
305305
a->type = MDNS_TYPE_PTR;
@@ -330,8 +330,8 @@ void mdns_priv_query_send(mdns_search_once_t *search, mdns_if_t tcpip_if, mdns_i
330330
if (!packet) {
331331
return;
332332
}
333-
mdns_priv_dispatch_tx_packet(packet);
334-
mdns_priv_free_tx_packet(packet);
333+
_mdns_dispatch_tx_packet(packet);
334+
_mdns_free_tx_packet(packet);
335335
}
336336
}
337337

0 commit comments

Comments
 (0)