@@ -143,7 +143,7 @@ esp_netif_t *_mdns_get_esp_netif(mdns_if_t tcpip_if)
143
143
/*
144
144
* @brief Clean internal mdns interface's pointer
145
145
*/
146
- static inline void _mdns_clean_netif_ptr (mdns_if_t tcpip_if )
146
+ void _mdns_clean_netif_ptr (mdns_if_t tcpip_if )
147
147
{
148
148
if (tcpip_if < MDNS_MAX_INTERFACES ) {
149
149
s_esp_netifs [tcpip_if ].netif = NULL ;
@@ -168,125 +168,7 @@ static mdns_if_t _mdns_get_if_from_esp_netif(esp_netif_t *esp_netif)
168
168
}
169
169
return MDNS_MAX_INTERFACES ;
170
170
}
171
- /**
172
- * @brief Check if interface is duplicate (two interfaces on the same subnet)
173
- */
174
- bool _mdns_if_is_dup (mdns_if_t tcpip_if )
175
- {
176
- mdns_if_t other_if = _mdns_get_other_if (tcpip_if );
177
- if (other_if == MDNS_MAX_INTERFACES ) {
178
- return false;
179
- }
180
- mdns_pcb_state_t state_v4 = mdns_utils_get_pcb (tcpip_if , MDNS_IP_PROTOCOL_V4 )-> state ;
181
- mdns_pcb_state_t state_v6 = mdns_utils_get_pcb (tcpip_if , MDNS_IP_PROTOCOL_V6 )-> state ;
182
- mdns_pcb_state_t other_state_v4 = mdns_utils_get_pcb (other_if , MDNS_IP_PROTOCOL_V4 )-> state ;
183
- mdns_pcb_state_t other_state_v6 = mdns_utils_get_pcb (other_if , MDNS_IP_PROTOCOL_V6 )-> state ;
184
-
185
- if (state_v4 == PCB_DUP || state_v6 == PCB_DUP || other_state_v4 == PCB_DUP || other_state_v6 == PCB_DUP ) {
186
- return true;
187
- }
188
- return false;
189
- }
190
-
191
- static esp_err_t mdns_pcb_deinit_local (mdns_if_t tcpip_if , mdns_ip_protocol_t ip_proto )
192
- {
193
- esp_err_t err = _mdns_pcb_deinit (tcpip_if , ip_proto );
194
- mdns_pcb_t * _pcb = mdns_utils_get_pcb (tcpip_if , ip_proto );
195
- if (_pcb == NULL || err != ESP_OK ) {
196
- return err ;
197
- }
198
- mdns_mem_free (_pcb -> probe_services );
199
- _pcb -> state = PCB_OFF ;
200
- _pcb -> probe_ip = false;
201
- _pcb -> probe_services = NULL ;
202
- _pcb -> probe_services_len = 0 ;
203
- _pcb -> probe_running = false;
204
- _pcb -> failed_probes = 0 ;
205
- return ESP_OK ;
206
- }
207
-
208
- /**
209
- * @brief Restart the responder on particular PCB
210
- */
211
- static void _mdns_restart_pcb (mdns_if_t tcpip_if , mdns_ip_protocol_t ip_protocol )
212
- {
213
- size_t srv_count = 0 ;
214
- mdns_srv_item_t * a = mdns_utils_get_services ();
215
- while (a ) {
216
- srv_count ++ ;
217
- a = a -> next ;
218
- }
219
- if (srv_count == 0 ) {
220
- // proble only IP
221
- _mdns_init_pcb_probe (tcpip_if , ip_protocol , NULL , 0 , true);
222
- return ;
223
- }
224
- mdns_srv_item_t * services [srv_count ];
225
- size_t i = 0 ;
226
- a = mdns_utils_get_services ();
227
- while (a ) {
228
- services [i ++ ] = a ;
229
- a = a -> next ;
230
- }
231
- _mdns_init_pcb_probe (tcpip_if , ip_protocol , services , srv_count , true);
232
- }
233
-
234
- /**
235
- * @brief Disable mDNS interface
236
- */
237
- void _mdns_disable_pcb (mdns_if_t tcpip_if , mdns_ip_protocol_t ip_protocol )
238
- {
239
- _mdns_clean_netif_ptr (tcpip_if );
240
-
241
- if (mdns_is_netif_ready (tcpip_if , ip_protocol )) {
242
- _mdns_clear_pcb_tx_queue_head (tcpip_if , ip_protocol );
243
- mdns_pcb_deinit_local (tcpip_if , ip_protocol );
244
- mdns_if_t other_if = _mdns_get_other_if (tcpip_if );
245
- if (other_if != MDNS_MAX_INTERFACES && mdns_utils_get_pcb (other_if , ip_protocol )-> state == PCB_DUP ) {
246
- mdns_utils_get_pcb (other_if , ip_protocol )-> state = PCB_OFF ;
247
- _mdns_enable_pcb (other_if , ip_protocol );
248
- }
249
- }
250
- mdns_utils_get_pcb (tcpip_if , ip_protocol )-> state = PCB_OFF ;
251
- }
252
171
253
- /**
254
- * @brief Enable mDNS interface
255
- */
256
- void _mdns_enable_pcb (mdns_if_t tcpip_if , mdns_ip_protocol_t ip_protocol )
257
- {
258
- if (!mdns_is_netif_ready (tcpip_if , ip_protocol )) {
259
- if (_mdns_pcb_init (tcpip_if , ip_protocol )) {
260
- mdns_utils_get_pcb (tcpip_if , ip_protocol )-> failed_probes = 0 ;
261
- return ;
262
- }
263
- }
264
- _mdns_restart_pcb (tcpip_if , ip_protocol );
265
- }
266
-
267
- /**
268
- * @brief Set interface as duplicate if another is found on the same subnet
269
- */
270
- void _mdns_dup_interface (mdns_if_t tcpip_if )
271
- {
272
- uint8_t i ;
273
- mdns_if_t other_if = _mdns_get_other_if (tcpip_if );
274
- if (other_if == MDNS_MAX_INTERFACES ) {
275
- return ; // no other interface found
276
- }
277
- for (i = 0 ; i < MDNS_IP_PROTOCOL_MAX ; i ++ ) {
278
- if (mdns_is_netif_ready (other_if , i )) {
279
- //stop this interface and mark as dup
280
- if (mdns_is_netif_ready (tcpip_if , i )) {
281
- _mdns_clear_pcb_tx_queue_head (tcpip_if , i );
282
- mdns_pcb_deinit_local (tcpip_if , i );
283
- }
284
- mdns_utils_get_pcb (tcpip_if , i )-> state = PCB_DUP ;
285
- // _mdns_server->interfaces[tcpip_if].pcbs[i].state = PCB_DUP;
286
- _mdns_announce_pcb (other_if , i , NULL , 0 , true);
287
- }
288
- }
289
- }
290
172
291
173
/**
292
174
* @brief Dispatch interface changes based on system events
@@ -379,11 +261,8 @@ void mdns_preset_if_handle_system_event(void *arg, esp_event_base_t event_base,
379
261
}
380
262
post_mdns_enable_pcb (mdns_if , MDNS_IP_PROTOCOL_V6 );
381
263
post_mdns_announce_pcb (mdns_if , MDNS_IP_PROTOCOL_V4 );
382
- mdns_browse_t * browse = mdns_utils_get_browse ();
383
- while (browse ) {
384
- _mdns_browse_send (browse , mdns_if );
385
- browse = browse -> next ;
386
- }
264
+ mdns_browse_send_all (mdns_if );
265
+
387
266
}
388
267
break ;
389
268
default :
@@ -543,14 +422,3 @@ esp_err_t mdns_netif_deinit(void)
543
422
}
544
423
return ESP_OK ;
545
424
}
546
-
547
- esp_err_t mdns_netif_free (void )
548
- {
549
- for (int i = 0 ; i < MDNS_MAX_INTERFACES ; i ++ ) {
550
- for (int j = 0 ; j < MDNS_IP_PROTOCOL_MAX ; j ++ ) {
551
- mdns_pcb_deinit_local (i , j );
552
- }
553
- }
554
- return ESP_OK ;
555
-
556
- }
0 commit comments