· 5 years ago · May 25, 2020, 04:24 PM
1diff --git a/cores/esp8266/IPAddress.h b/cores/esp8266/IPAddress.h
2index 6fcbee95..abced22d 100644
3--- a/cores/esp8266/IPAddress.h
4+++ b/cores/esp8266/IPAddress.h
5@@ -50,6 +50,13 @@ struct ip_addr: ipv4_addr { };
6 #endif // !LWIP_IPV6
7 #endif // lwIP-v2+
8
9+// to display a netif id with printf:
10+#define NETIFID_STR "%c%c%u"
11+#define NETIFID_VAL(netif) \
12+ ((netif)? (netif)->name[0]: '-'), \
13+ ((netif)? (netif)->name[1]: '-'), \
14+ ((netif)? netif_get_index(netif): 42)
15+
16 // A class to make it easier to handle and pass around IP addresses
17 // IPv6 update:
18 // IPAddress is now a decorator class for lwIP's ip_addr_t
19diff --git a/libraries/ESP8266SdFat b/libraries/ESP8266SdFat
20--- a/libraries/ESP8266SdFat
21+++ b/libraries/ESP8266SdFat
22@@ -1 +1 @@
23-Subproject commit b240d2231a117bbd89b79902eb54cae948ee2f42
24+Subproject commit b240d2231a117bbd89b79902eb54cae948ee2f42-dirty
25diff --git a/libraries/ESP8266mDNS/examples/LEAmDNS/mDNS_Clock_v2/mDNS_Clock_v2.ino b/libraries/ESP8266mDNS/examples/LEAmDNS/mDNS_Clock_v2/mDNS_Clock_v2.ino
26index 5c429226..0a6ad00c 100644
27--- a/libraries/ESP8266mDNS/examples/LEAmDNS/mDNS_Clock_v2/mDNS_Clock_v2.ino
28+++ b/libraries/ESP8266mDNS/examples/LEAmDNS/mDNS_Clock_v2/mDNS_Clock_v2.ino
29@@ -69,6 +69,11 @@
30 #define STAPSK "your-password"
31 #endif
32
33+#ifndef APSSID
34+#define APSSID "ap4mdnsClock"
35+#define APPSK "mdnsClock"
36+#endif
37+
38 const char* ssid = STASSID;
39 const char* password = STAPSK;
40
41@@ -181,7 +186,8 @@ void setup(void) {
42 Serial.begin(115200);
43
44 // Connect to WiFi network
45- WiFi.mode(WIFI_STA);
46+ WiFi.mode(WIFI_AP_STA);
47+ WiFi.softAP(APSSID, APPSK);
48 WiFi.begin(ssid, password);
49 Serial.println("");
50
51@@ -201,12 +207,12 @@ void setup(void) {
52
53 // Setup MDNS responder
54 // Init the (currently empty) host domain string with 'esp8266'
55- if (responder.begin("ESP8266", WIFI_STA, [](clsMDNSHost & p_rMDNSHost,
56- const char* p_pcDomainName,
57+ if (responder.begin("leamdnsv2", [](clsMDNSHost & p_rMDNSHost,
58+ const char* p_pcDomainName,
59 bool p_bProbeResult)->void {
60 Serial.printf("mDNSHost_AP::ProbeResultCallback: '%s' is %s\n", p_pcDomainName, (p_bProbeResult ? "FREE" : "USED!"));
61 // Unattended added service
62- p_rMDNSHost.addService(0, "http", "tcp", 80);
63+ p_rMDNSHost.addService(0, "espclk", "tcp", 80);
64 })) {
65 Serial.println("mDNS-AP started");
66 } else {
67diff --git a/libraries/ESP8266mDNS/src/LEAmDNS2Host.cpp b/libraries/ESP8266mDNS/src/LEAmDNS2Host.cpp
68index 1553c3df..f93315d8 100644
69--- a/libraries/ESP8266mDNS/src/LEAmDNS2Host.cpp
70+++ b/libraries/ESP8266mDNS/src/LEAmDNS2Host.cpp
71@@ -171,15 +171,14 @@ const char* clsLEAMDNSHost::indexDomainName(const char* p_pcDomainName,
72
73 */
74 // static
75-bool clsLEAMDNSHost::setNetIfHostName(netif* p_pNetIf,
76- const char* p_pcHostName)
77+bool clsLEAMDNSHost::setNetIfHostName(const char* p_pcHostName)
78 {
79- if ((p_pNetIf) &&
80- (p_pcHostName))
81- {
82- netif_set_hostname(p_pNetIf, (char*)p_pcHostName); // LWIP 1.x forces 'char*' instead of 'const char*'
83- DEBUG_EX_INFO(DEBUG_OUTPUT.printf_P(PSTR("[mDNS] setNetIfHostName host name: %s!\n"), p_pcHostName););
84- }
85+ if (p_pcHostName)
86+ for (netif* pNetIf = netif_list; pNetIf; pNetIf = pNetIf->next) if (netif_is_up(pNetIf))
87+ {
88+ netif_set_hostname(pNetIf, p_pcHostName);
89+ DEBUG_EX_INFO(DEBUG_OUTPUT.printf_P(PSTR("[mDNS] setNetIfHostName host name: %s on " NETIFID_STR "!\n"), p_pcHostName, NETIFID_VAL(pNetIf)););
90+ }
91 return true;
92 }
93
94@@ -214,9 +213,7 @@ const char* clsLEAMDNSHost::clsConsts::pcReverseTopDomain = "arpa";
95
96 */
97 clsLEAMDNSHost::clsLEAMDNSHost(void)
98- : m_pNetIf(0),
99- m_NetIfState(static_cast<typeNetIfState>(enuNetIfState::None)),
100- m_pUDPContext(0),
101+ : m_pUDPContext(0),
102 m_pcHostName(0),
103 m_pcDefaultInstanceName(0),
104 m_ProbeInformation()
105@@ -239,22 +236,20 @@ clsLEAMDNSHost::~clsLEAMDNSHost(void)
106 */
107
108 /*
109- clsLEAmDNS2_Host::begin (hostname, netif, probe_callback)
110+ clsLEAmDNS2_Host::begin (hostname, probe_callback)
111
112- Creates a new mDNS host (adding the netif to the multicast groups),
113+ setup global mDNS (adding all netif to the multicast groups),
114 sets up the instance data (hostname, ...) and starts the probing process
115
116 */
117 bool clsLEAMDNSHost::begin(const char* p_pcHostName,
118- netif* p_pNetIf,
119 clsLEAMDNSHost::fnProbeResultCallback p_fnCallback /*= 0*/)
120 {
121- DEBUG_EX_INFO(DEBUG_OUTPUT.printf_P(PSTR("%s begin(%s, netif: %u)\n"), _DH(), (p_pcHostName ? : "_"), (p_pNetIf ? netif_get_index(p_pNetIf) : 0)););
122+ DEBUG_EX_INFO(DEBUG_OUTPUT.printf_P(PSTR("%s begin(%s)\n"), _DH(), (p_pcHostName ? : "_")););
123
124 bool bResult = false;
125
126 if (!((bResult = ((setHostName(p_pcHostName)) &&
127- ((m_pNetIf = p_pNetIf)) &&
128 (_joinMulticastGroups()) &&
129 (p_fnCallback ? setProbeResultCallback(p_fnCallback) : true) &&
130 ((m_pUDPContext = _allocBackbone())) &&
131@@ -266,46 +261,6 @@ bool clsLEAMDNSHost::begin(const char* p_pcHostName,
132 return bResult;
133 }
134
135-/*
136- clsLEAmDNS2_Host::begin (hostname, probe_callback)
137-
138-*/
139-bool clsLEAMDNSHost::begin(const char* p_pcHostName,
140- clsLEAMDNSHost::fnProbeResultCallback p_fnCallback /*= 0*/)
141-{
142- DEBUG_EX_INFO(DEBUG_OUTPUT.printf_P(PSTR("%s begin(%s)\n"), _DH(), (p_pcHostName ? : "_")););
143-
144- return begin(p_pcHostName, (WiFiMode_t)wifi_get_opmode(), p_fnCallback);
145-}
146-
147-/*
148- clsLEAmDNS2_Host::begin (hostname, WiFiMode, probe_callback)
149-
150-*/
151-bool clsLEAMDNSHost::begin(const char* p_pcHostName,
152- WiFiMode_t p_WiFiMode,
153- clsLEAMDNSHost::fnProbeResultCallback p_fnCallback /*= 0*/)
154-{
155- DEBUG_EX_INFO(DEBUG_OUTPUT.printf_P(PSTR("%s begin(%s, opmode: %u)\n"), _DH(), (p_pcHostName ? : "_"), (uint32_t)p_WiFiMode););
156-
157- bool bResult = false;
158-
159- if (p_WiFiMode == WIFI_STA)
160- {
161- bResult = begin(p_pcHostName, netif_get_by_index(WIFI_STA), p_fnCallback);
162- }
163- else if (p_WiFiMode == WIFI_AP)
164- {
165- bResult = begin(p_pcHostName, netif_get_by_index(WIFI_AP), p_fnCallback);
166- }
167- else
168- {
169- DEBUG_EX_ERR(DEBUG_OUTPUT.printf_P(PSTR("%s begin: FAILED for WiFi mode '%u'! Only 'WIFI_STA' or 'WIFI_AP' is allowed (HostName: %s)!\n"), _DH(), (bResult ? "Succeeded" : "FAILED"), p_WiFiMode, (p_pcHostName ? : "-")););
170- }
171- DEBUG_EX_INFO(DEBUG_OUTPUT.printf_P(PSTR("%s begin: %s for WiFi mode '%u' (HostName: %s)!\n"), _DH(), (bResult ? "Succeeded" : "FAILED"), p_WiFiMode, (p_pcHostName ? : "-")););
172- return bResult;
173-}
174-
175 /*
176 clsLEAmDNS2_Host::close
177
178@@ -476,9 +431,18 @@ bool clsLEAMDNSHost::removeService(clsLEAMDNSHost::clsService* p_pService)
179 {
180 bool bResult = false;
181
182- if ((bResult = ((p_pService) &&
183- (m_Services.end() != std::find(m_Services.begin(), m_Services.end(), p_pService)) &&
184- (_announceService(*p_pService, false)))))
185+ if (p_pService &&
186+ (m_Services.end() != std::find(m_Services.begin(), m_Services.end(), p_pService)))
187+ {
188+ for (netif* pNetIf = netif_list; pNetIf; pNetIf = pNetIf->next)
189+ if (netif_is_up(pNetIf) &&
190+ (_announceService(pNetIf, *p_pService, false)))
191+ {
192+ bResult = true;
193+ }
194+ }
195+
196+ if (bResult)
197 {
198 m_Services.remove(p_pService);
199 delete p_pService;
200@@ -551,37 +515,55 @@ clsLEAMDNSHost::clsQuery::clsAnswerAccessor::vector clsLEAMDNSHost::queryService
201 {
202 DEBUG_EX_INFO(DEBUG_OUTPUT.printf_P(PSTR("%s queryService '_%s._%s.local'\n"), _DH(), p_pcService, p_pcProtocol););
203
204- clsQuery* pQuery = 0;
205- if ((p_pcService) && (*p_pcService) &&
206+ clsLEAMDNSHost::clsQuery::clsAnswerAccessor::vector ret;
207+
208+ if (_removeLegacyQuery() &&
209+ (p_pcService) && (*p_pcService) &&
210 (p_pcProtocol) && (*p_pcProtocol) &&
211- (p_u16Timeout) &&
212- ((pQuery = _allocQuery(clsQuery::enuQueryType::Service))) &&
213- (_buildDomainForService(p_pcService, p_pcProtocol, pQuery->m_Domain)))
214+ (p_u16Timeout))
215 {
216- if ((_removeLegacyQuery()) &&
217- ((pQuery->m_bStaticQuery = true)) &&
218- (_sendQuery(*pQuery)))
219+ std::list<clsQuery*> queries;
220+
221+ for (netif* pNetIf = netif_list; pNetIf; pNetIf = pNetIf->next)
222+ if (netif_is_up(pNetIf))
223+ {
224+ clsQuery* pQuery = 0;
225+ if (((pQuery = _allocQuery(clsQuery::enuQueryType::Service))) &&
226+ (_buildDomainForService(p_pcService, p_pcProtocol, pQuery->m_Domain)))
227+ {
228+ if (((pQuery->m_bStaticQuery = true)) && (_sendQuery(pNetIf, *pQuery)))
229+ {
230+ queries.push_back(pQuery);
231+ }
232+ else
233+ {
234+ // FAILED to send query
235+ _removeQuery(pQuery);
236+ }
237+ }
238+ }
239+
240+ if (queries.size())
241 {
242 // Wait for answers to arrive
243 DEBUG_EX_INFO(DEBUG_OUTPUT.printf_P(PSTR("%s queryService: Waiting %u ms for answers...\n"), _DH(), p_u16Timeout););
244+ //XXXFIXME could this delay be ASYNC?
245 delay(p_u16Timeout);
246
247 // All answers should have arrived by now -> stop adding new answers
248- pQuery->m_bAwaitingAnswers = false;
249+ for (auto& q : queries)
250+ {
251+ q->m_bAwaitingAnswers = false;
252+ ret.insert(ret.end(), std::make_move_iterator(q->answerAccessors().begin()), std::make_move_iterator(q->answerAccessors().end()));
253+ }
254 }
255 else
256 {
257- // FAILED to send query
258- _removeQuery(pQuery);
259+ DEBUG_EX_ERR(DEBUG_OUTPUT.printf_P(PSTR("%s queryService: INVALID input data!\n"), _DH()););
260 }
261+
262 }
263- else
264- {
265- DEBUG_EX_ERR(DEBUG_OUTPUT.printf_P(PSTR("%s queryService: INVALID input data!\n"), _DH()););
266- }
267- return ((pQuery)
268- ? pQuery->answerAccessors()
269- : clsQuery::clsAnswerAccessor::vector());
270+ return ret;
271 }
272
273 /*
274@@ -591,40 +573,58 @@ clsLEAMDNSHost::clsQuery::clsAnswerAccessor::vector clsLEAMDNSHost::queryService
275 clsLEAMDNSHost::clsQuery::clsAnswerAccessor::vector clsLEAMDNSHost::queryHost(const char* p_pcHostName,
276 const uint16_t p_u16Timeout)
277 {
278+ clsLEAMDNSHost::clsQuery::clsAnswerAccessor::vector ret;
279+
280 DEBUG_EX_INFO(DEBUG_OUTPUT.printf_P(PSTR("%s queryHost '%s.local'\n"), _DH(), p_pcHostName););
281
282- clsQuery* pQuery = 0;
283 if ((p_pcHostName) && (*p_pcHostName) &&
284 (p_u16Timeout) &&
285- ((pQuery = _allocQuery(clsQuery::enuQueryType::Host))) &&
286- (_buildDomainForHost(p_pcHostName, pQuery->m_Domain)))
287+ (_removeLegacyQuery()))
288 {
289- if ((_removeLegacyQuery()) &&
290- ((pQuery->m_bStaticQuery = true)) &&
291- (_sendQuery(*pQuery)))
292+ std::list<clsQuery*> queries;
293+
294+ for (netif* pNetIf = netif_list; pNetIf; pNetIf = pNetIf->next)
295+ if (netif_is_up(pNetIf))
296+ {
297+ clsQuery* pQuery = 0;
298+ if (((pQuery = _allocQuery(clsQuery::enuQueryType::Host))) &&
299+ (_buildDomainForHost(p_pcHostName, pQuery->m_Domain)))
300+ {
301+ if (((pQuery->m_bStaticQuery = true)) && (_sendQuery(pNetIf, *pQuery)))
302+ {
303+ queries.push_back(pQuery);
304+ }
305+ else
306+ {
307+ // FAILED to send query
308+ _removeQuery(pQuery);
309+ }
310+ }
311+ }
312+
313+ if (queries.size())
314 {
315 // Wait for answers to arrive
316 DEBUG_EX_INFO(DEBUG_OUTPUT.printf_P(PSTR("%s queryHost: Waiting %u ms for answers...\n"), _DH(), p_u16Timeout););
317+ //XXXFIXME could this delay be ASYNC?
318 delay(p_u16Timeout);
319
320 // All answers should have arrived by now -> stop adding new answers
321- pQuery->m_bAwaitingAnswers = false;
322+
323+ for (auto& q : queries)
324+ {
325+ q->m_bAwaitingAnswers = false;
326+ ret.insert(ret.end(), std::make_move_iterator(q->answerAccessors().begin()), std::make_move_iterator(q->answerAccessors().end()));
327+ }
328 }
329 else
330 {
331- // FAILED to send query
332- _removeQuery(pQuery);
333+ DEBUG_EX_ERR(DEBUG_OUTPUT.printf_P(PSTR("%s queryHost: INVALID input data!\n"), _DH()););
334 }
335 }
336- else
337- {
338- DEBUG_EX_ERR(DEBUG_OUTPUT.printf_P(PSTR("%s queryHost: INVALID input data!\n"), _DH()););
339- }
340- return ((pQuery)
341- ? pQuery->answerAccessors()
342- : clsQuery::clsAnswerAccessor::vector());
343-}
344
345+ return ret;
346+}
347 /*
348 clsLEAmDNS2_Host::removeQuery
349
350@@ -656,78 +656,97 @@ clsLEAMDNSHost::clsQuery* clsLEAMDNSHost::getQuery(void)
351 clsLEAmDNS2_Host::installServiceQuery (answer)
352
353 */
354-clsLEAMDNSHost::clsQuery* clsLEAMDNSHost::installServiceQuery(const char* p_pcService,
355+/*clsLEAMDNSHost::clsQuery* */ bool clsLEAMDNSHost::installServiceQuery(const char* p_pcService,
356 const char* p_pcProtocol,
357 clsLEAMDNSHost::clsQuery::QueryCallbackAnswerFn p_fnCallbackAnswer)
358 {
359+ bool bResult = false;
360 clsQuery* pQuery = 0;
361- if ((pQuery = _installServiceQuery(p_pcService, p_pcProtocol)))
362- {
363- pQuery->m_fnCallbackAnswer = p_fnCallbackAnswer;
364- }
365- return pQuery;
366+ for (netif* pNetIf = netif_list; pNetIf; pNetIf = pNetIf->next)
367+ if (netif_is_up(pNetIf) && (pQuery = _installServiceQuery(pNetIf, p_pcService, p_pcProtocol)))
368+ {
369+ pQuery->m_fnCallbackAnswer = p_fnCallbackAnswer;
370+ bResult = true;
371+ }
372+ return bResult;
373 }
374
375 /*
376 clsLEAmDNS2_Host::installServiceQuery (accessor)
377
378 */
379-clsLEAMDNSHost::clsQuery* clsLEAMDNSHost::installServiceQuery(const char* p_pcService,
380+/*clsLEAMDNSHost::clsQuery* */ bool clsLEAMDNSHost::installServiceQuery(const char* p_pcService,
381 const char* p_pcProtocol,
382- clsLEAMDNSHost::clsQuery::QueryCallbackAccessorFn p_fnCallbackAccessor)
383+ clsLEAMDNSHost::clsQuery::QueryCallbackAccessorFn p_fnCallbackAccessor,
384+ std::list<clsLEAMDNSHost::clsQuery*>* ret)
385 {
386+ bool bResult = false;
387 clsQuery* pQuery = 0;
388- if ((pQuery = _installServiceQuery(p_pcService, p_pcProtocol)))
389- {
390- pQuery->m_fnCallbackAccessor = p_fnCallbackAccessor;
391- }
392- return pQuery;
393+ for (netif* pNetIf = netif_list; pNetIf; pNetIf = pNetIf->next)
394+ if (netif_is_up(pNetIf) && (pQuery = _installServiceQuery(pNetIf, p_pcService, p_pcProtocol)))
395+ {
396+ pQuery->m_fnCallbackAccessor = p_fnCallbackAccessor;
397+ bResult = true;
398+ if (ret)
399+ {
400+ ret->push_back(pQuery);
401+ }
402+ }
403+ return bResult;
404 }
405
406 /*
407 clsLEAmDNS2_Host::installHostQuery (answer)
408 */
409-clsLEAMDNSHost::clsQuery* clsLEAMDNSHost::installHostQuery(const char* p_pcHostName,
410+/*clsLEAMDNSHost::clsQuery* */ bool clsLEAMDNSHost::installHostQuery(const char* p_pcHostName,
411 clsLEAMDNSHost::clsQuery::QueryCallbackAnswerFn p_fnCallbackAnswer)
412 {
413+ bool bResult = false;
414 clsQuery* pQuery = 0;
415 if ((p_pcHostName) && (*p_pcHostName))
416- {
417- clsRRDomain domain;
418- if ((pQuery = ((_buildDomainForHost(p_pcHostName, domain))
419- ? _installDomainQuery(domain, clsQuery::enuQueryType::Host)
420- : 0)))
421- {
422- pQuery->m_fnCallbackAnswer = p_fnCallbackAnswer;
423- }
424- }
425- return pQuery;
426+ for (netif* pNetIf = netif_list; pNetIf; pNetIf = pNetIf->next)
427+ if (netif_is_up(pNetIf))
428+ {
429+ clsRRDomain domain;
430+ if ((pQuery = ((_buildDomainForHost(p_pcHostName, domain))
431+ ? _installDomainQuery(pNetIf, domain, clsQuery::enuQueryType::Host)
432+ : 0)))
433+ {
434+ pQuery->m_fnCallbackAnswer = p_fnCallbackAnswer;
435+ bResult = true;
436+ }
437+ }
438+ return bResult;
439 }
440
441 /*
442 clsLEAmDNS2_Host::installHostQuery (accessor)
443 */
444-clsLEAMDNSHost::clsQuery* clsLEAMDNSHost::installHostQuery(const char* p_pcHostName,
445+/*clsLEAMDNSHost::clsQuery* */ bool clsLEAMDNSHost::installHostQuery(const char* p_pcHostName,
446 clsLEAMDNSHost::clsQuery::QueryCallbackAccessorFn p_fnCallbackAccessor)
447 {
448+ bool bResult = true;
449 clsQuery* pQuery = 0;
450 if ((p_pcHostName) && (*p_pcHostName))
451- {
452- clsRRDomain domain;
453- if ((pQuery = ((_buildDomainForHost(p_pcHostName, domain))
454- ? _installDomainQuery(domain, clsQuery::enuQueryType::Host)
455- : 0)))
456- {
457- pQuery->m_fnCallbackAccessor = p_fnCallbackAccessor;
458- }
459- }
460- return pQuery;
461+ for (netif* pNetIf = netif_list; pNetIf; pNetIf = pNetIf->next)
462+ if (netif_is_up(pNetIf))
463+ {
464+ clsRRDomain domain;
465+ if ((pQuery = ((_buildDomainForHost(p_pcHostName, domain))
466+ ? _installDomainQuery(pNetIf, domain, clsQuery::enuQueryType::Host)
467+ : 0)))
468+ {
469+ pQuery->m_fnCallbackAccessor = p_fnCallbackAccessor;
470+ bResult = true;
471+ }
472+ }
473+ return bResult;
474 }
475
476 /*
477 clsLEAmDNS2_Host::removeQuery
478 */
479-bool clsLEAMDNSHost::removeQuery(clsLEAMDNSHost::clsQuery* p_pMDNSQuery)
480+bool clsLEAMDNSHost::removeQuery(clsLEAMDNSHost::clsQuery * p_pMDNSQuery)
481 {
482 bool bResult = ((p_pMDNSQuery) &&
483 (_removeQuery(p_pMDNSQuery)));
484@@ -735,7 +754,6 @@ bool clsLEAMDNSHost::removeQuery(clsLEAMDNSHost::clsQuery* p_pMDNSQuery)
485 return bResult;
486 }
487
488-
489 /*
490 PROCESSING
491 */
492@@ -747,16 +765,21 @@ bool clsLEAMDNSHost::update(void)
493 {
494 bool bResult = false;
495
496- //if (clsBackbone::sm_pBackbone->setDelayUDPProcessing(true))
497- //{
498- bResult = ((_checkNetIfState()) && // Any changes in the netif state?
499- (_updateProbeStatus()) && // Probing and announcing
500- (_checkQueryCache()));
501+ for (netif* pNetIf = netif_list; pNetIf; pNetIf = pNetIf->next)
502+ if (netif_is_up(pNetIf))
503+ {
504+ //if (clsBackbone::sm_pBackbone->setDelayUDPProcessing(true))
505+ //{
506+ if ((_updateProbeStatus(pNetIf)) && // Probing and announcing
507+ (_checkQueryCache(pNetIf)))
508+ {
509+ bResult = true;
510+ }
511
512- // clsBackbone::sm_pBackbone->setDelayUDPProcessing(false);
513- //}
514+ // clsBackbone::sm_pBackbone->setDelayUDPProcessing(false);
515+ //}
516+ }
517 DEBUG_EX_ERR(if (!bResult) DEBUG_OUTPUT.printf_P(PSTR("%s update: FAILED (Not connected?)!\n"), _DH()););
518-
519 return bResult;
520 }
521
522@@ -766,16 +789,28 @@ bool clsLEAMDNSHost::update(void)
523 bool clsLEAMDNSHost::announce(bool p_bAnnounce /*= true*/,
524 bool p_bIncludeServices /*= true*/)
525 {
526- return _announce(p_bAnnounce, p_bIncludeServices);
527+ bool bResult = false;
528+ for (netif* pNetIf = netif_list; pNetIf; pNetIf = pNetIf->next)
529+ if (netif_is_up(pNetIf) && _announce(pNetIf, p_bAnnounce, p_bIncludeServices))
530+ {
531+ bResult = true;
532+ }
533+ return bResult;
534 }
535
536 /*
537 clsLEAmDNS2_Host::announceService
538 */
539-bool clsLEAMDNSHost::announceService(clsService* p_pService,
540+bool clsLEAMDNSHost::announceService(clsService * p_pService,
541 bool p_bAnnounce /*= true*/)
542 {
543- return _announceService(*p_pService, p_bAnnounce);
544+ bool bResult = false;
545+ for (netif* pNetIf = netif_list; pNetIf; pNetIf = pNetIf->next)
546+ if (netif_is_up(pNetIf) && _announceService(pNetIf, *p_pService, p_bAnnounce))
547+ {
548+ bResult = true;
549+ }
550+ return bResult;
551 }
552
553 /*
554@@ -885,195 +920,84 @@ bool clsLEAMDNSHost::_joinMulticastGroups(void)
555 bool bResult = false;
556
557 // Join multicast group(s)
558- if (m_pNetIf)
559- {
560- bResult = true;
561-
562-#ifdef MDNS_IPV4_SUPPORT
563- ip_addr_t multicast_addr_V4 = DNS_MQUERY_IPV4_GROUP_INIT;
564- if (!(m_pNetIf->flags & NETIF_FLAG_IGMP))
565+ for (netif* pNetIf = netif_list; pNetIf; pNetIf = pNetIf->next) if (netif_is_up(pNetIf))
566 {
567- DEBUG_EX_ERR(DEBUG_OUTPUT.printf_P(PSTR("%s _createHost: Setting flag: flags & NETIF_FLAG_IGMP\n"), _DH()););
568- m_pNetIf->flags |= NETIF_FLAG_IGMP;
569-
570- if (ERR_OK != igmp_start(m_pNetIf))
571+#ifdef MDNS_IPV4_SUPPORT
572+ ip_addr_t multicast_addr_V4 = DNS_MQUERY_IPV4_GROUP_INIT;
573+ if (!(pNetIf->flags & NETIF_FLAG_IGMP))
574 {
575- DEBUG_EX_ERR(DEBUG_OUTPUT.printf_P(PSTR("%s _createHost: igmp_start FAILED!\n"), _DH()););
576+ DEBUG_EX_ERR(DEBUG_OUTPUT.printf_P(PSTR("%s _createHost: Setting flag: flags & NETIF_FLAG_IGMP\n"), _DH()););
577+ pNetIf->flags |= NETIF_FLAG_IGMP;
578+
579+ if (ERR_OK != igmp_start(pNetIf))
580+ {
581+ DEBUG_EX_ERR(DEBUG_OUTPUT.printf_P(PSTR("%s _createHost: igmp_start FAILED!\n"), _DH()););
582+ }
583 }
584- }
585
586- bResult = ((bResult) &&
587+ if (
588 #if LWIP_VERSION_MAJOR == 1
589- (ERR_OK == igmp_joingroup(ip_2_ip4(&m_pNetIf->ip_addr), ip_2_ip4(&multicast_addr_V4))));
590+ (ERR_OK == igmp_joingroup(&pNetIf->ip_addr, &multicast_addr_V4))
591 #else
592- (ERR_OK == igmp_joingroup_netif(m_pNetIf, ip_2_ip4(&multicast_addr_V4))));
593+ (ERR_OK == igmp_joingroup_netif(pNetIf, ip_2_ip4(&multicast_addr_V4)))
594 #endif
595- DEBUG_EX_ERR(if (!bResult) DEBUG_OUTPUT.printf_P(PSTR("%s _createHost: igmp_joingroup_netif(%s) FAILED!\n"), _DH(), IPAddress(multicast_addr_V4).toString().c_str()););
596+ )
597+ {
598+ bResult = true;
599+ }
600+ else
601+ {
602+ DEBUG_EX_ERR(DEBUG_OUTPUT.printf_P(PSTR("%s _createHost: igmp_joingroup_netif(" NETIFID_STR ": %s) FAILED!\n"),
603+ _DH(), NETIFID_VAL(pNetIf), IPAddress(multicast_addr_V4).toString().c_str()););
604+ }
605 #endif
606
607 #ifdef MDNS_IPV6_SUPPORT
608- ip_addr_t multicast_addr_V6 = DNS_MQUERY_IPV6_GROUP_INIT;
609- bResult = ((bResult) &&
610- (ERR_OK == mld6_joingroup_netif(m_pNetIf, ip_2_ip6(&multicast_addr_V6))));
611- DEBUG_EX_ERR(if (!bResult) DEBUG_OUTPUT.printf_P(PSTR("%s _createHost: mld6_joingroup_netif FAILED!\n"), _DH()););
612+ ip_addr_t multicast_addr_V6 = DNS_MQUERY_IPV6_GROUP_INIT;
613+ bResult = ((bResult) &&
614+ (ERR_OK == mld6_joingroup_netif(pNetIf, ip_2_ip6(&multicast_addr_V6))));
615+ DEBUG_EX_ERR_IF(!bResult, DEBUG_OUTPUT.printf_P(PSTR("%s _createHost: mld6_joingroup_netif (" NETIFID_STR ") FAILED!\n"),
616+ _DH(), NETIFID_VAL(pNetIf)));
617 #endif
618- }
619+ }
620 return bResult;
621 }
622
623 /*
624 clsLEAmDNS2_Host::_leaveMulticastGroups
625 */
626-bool clsLEAMDNSHost::_leaveMulticastGroups(void)
627+bool clsLEAMDNSHost::_leaveMulticastGroups()
628 {
629 bool bResult = false;
630
631- if (m_pNetIf)
632- {
633- bResult = true;
634- /* _resetProbeStatus(false); // Stop probing
635-
636- _releaseQueries();
637- _releaseServices();
638- _releaseHostName();*/
639+ for (netif* pNetIf = netif_list; pNetIf; pNetIf = pNetIf->next) if (netif_is_up(pNetIf))
640+ {
641+ bResult = true;
642+ /* _resetProbeStatus(false); // Stop probing
643+ _releaseQueries();
644+ _releaseServices();
645+ _releaseHostName();*/
646
647- // Leave multicast group(s)
648+ // Leave multicast group(s)
649 #ifdef MDNS_IPV4_SUPPORT
650- ip_addr_t multicast_addr_V4 = DNS_MQUERY_IPV4_GROUP_INIT;
651+ ip_addr_t multicast_addr_V4 = DNS_MQUERY_IPV4_GROUP_INIT;
652 #if LWIP_VERSION_MAJOR == 1
653- if (ERR_OK != igmp_leavegroup(ip_2_ip4(&m_pNetIf->ip_addr), ip_2_ip4(&multicast_addr_V4)))
654+ if (ERR_OK != igmp_leavegroup(ip_2_ip4(pNetIf->ip_addr), ip_2_ip4(&multicast_addr_V4)))
655 #else
656- if (ERR_OK != igmp_leavegroup_netif(m_pNetIf, ip_2_ip4(&multicast_addr_V4)))
657-#endif
658- {
659- DEBUG_EX_ERR(DEBUG_OUTPUT.printf_P(PSTR("\n")););
660- }
661-#endif
662-#ifdef MDNS_IPV6_SUPPORT
663- ip_addr_t multicast_addr_V6 = DNS_MQUERY_IPV6_GROUP_INIT;
664- if (ERR_OK != mld6_leavegroup_netif(m_pNetIf, ip_2_ip6(&multicast_addr_V6)/*&(multicast_addr_V6.u_addr.ip6)*/))
665- {
666- DEBUG_EX_ERR(DEBUG_OUTPUT.printf_P(PSTR("\n")););
667- }
668-#endif
669- }
670- return bResult;
671-}
672-
673-
674-/*
675- NETIF
676-*/
677-
678-/*
679- clsLEAmDNS2_Host::_getNetIfState
680-
681- Returns the current netif state.
682-
683-*/
684-clsLEAMDNSHost::typeNetIfState clsLEAMDNSHost::_getNetIfState(void) const
685-{
686- typeNetIfState curNetIfState = static_cast<typeNetIfState>(enuNetIfState::None);
687-
688- if ((m_pNetIf) &&
689- (netif_is_up(m_pNetIf)))
690- {
691- curNetIfState |= static_cast<typeNetIfState>(enuNetIfState::IsUp);
692-
693- // Check if netif link is up
694- if ((netif_is_link_up(m_pNetIf)) &&
695- ((m_pNetIf != netif_get_by_index(WIFI_STA)) ||
696- (STATION_GOT_IP == wifi_station_get_connect_status())))
697- {
698- curNetIfState |= static_cast<typeNetIfState>(enuNetIfState::LinkIsUp);
699- }
700-
701-#ifdef MDNS_IPV4_SUPPORT
702- // Check for IPv4 address
703- if (_getResponderIPAddress(enuIPProtocolType::V4).isSet())
704- {
705- curNetIfState |= static_cast<typeNetIfState>(enuNetIfState::IPv4);
706- }
707-#endif
708-#ifdef MDNS_IPV6_SUPPORT
709- // Check for IPv6 address
710- if (_getResponderIPAddress(enuIPProtocolType::V6).isSet())
711- {
712- curNetIfState |= static_cast<typeNetIfState>(enuNetIfState::IPv6);
713- }
714+ if (ERR_OK != igmp_leavegroup_netif(pNetIf, ip_2_ip4(&multicast_addr_V4)))
715 #endif
716- }
717- return curNetIfState;
718-}
719-
720-/*
721- clsLEAmDNS2_Host::_checkNetIfState
722-
723- Checks the netif state.
724- If eg. a new address appears, the announcing is restarted.
725-
726-*/
727-bool clsLEAMDNSHost::_checkNetIfState(void)
728-{
729- typeNetIfState curNetIfState;
730- if (m_NetIfState != ((curNetIfState = _getNetIfState())))
731- {
732- // Some state change happened
733- DEBUG_EX_INFO(DEBUG_OUTPUT.printf_P(PSTR("%s _checkNetIfState: DID CHANGE NETIF STATE\n\n"), _DH()););
734- DEBUG_EX_INFO(
735- if ((curNetIfState & static_cast<typeNetIfState>(enuNetIfState::IsUp)) != (m_NetIfState & static_cast<typeNetIfState>(enuNetIfState::IsUp))) DEBUG_OUTPUT.printf_P(PSTR("%s _checkNetIfState: Netif is up: %s\n"), _DH(), ((curNetIfState & static_cast<typeNetIfState>(enuNetIfState::IsUp)) ? "YES" : "NO"));
736- if ((curNetIfState & static_cast<typeNetIfState>(enuNetIfState::LinkIsUp)) != (m_NetIfState & static_cast<typeNetIfState>(enuNetIfState::LinkIsUp))) DEBUG_OUTPUT.printf_P(PSTR("%s _checkNetIfState: Netif link is up: %s\n"), _DH(), ((curNetIfState & static_cast<typeNetIfState>(enuNetIfState::LinkIsUp)) ? "YES" : "NO"));
737-#ifdef MDNS_IPV4_SUPPORT
738- if ((curNetIfState & static_cast<typeNetIfState>(enuNetIfState::IPv4)) != (m_NetIfState & static_cast<typeNetIfState>(enuNetIfState::IPv4)))
739 {
740- DEBUG_OUTPUT.printf_P(PSTR("%s _checkNetIfState: IPv4 address is set: %s\n"), _DH(), ((curNetIfState & static_cast<typeNetIfState>(enuNetIfState::IPv4)) ? "YES" : "NO"));
741- if (curNetIfState & static_cast<typeNetIfState>(enuNetIfState::IPv4))
742- {
743- DEBUG_OUTPUT.printf_P(PSTR("%s _checkNetIfState: IPv4 address: %s\n"), _DH(), _getResponderIPAddress(enuIPProtocolType::V4).toString().c_str());
744- }
745- }
746+ DEBUG_EX_ERR(DEBUG_OUTPUT.printf_P(PSTR("\n")););
747+ }
748 #endif
749 #ifdef MDNS_IPV6_SUPPORT
750- if ((curNetIfState & static_cast<typeNetIfState>(enuNetIfState::IPv6)) != (m_NetIfState & static_cast<typeNetIfState>(enuNetIfState::IPv6)))
751- {
752- DEBUG_OUTPUT.printf_P(PSTR("%s _checkNetIfState: IPv6 address is set: %s\n"), _DH(), ((curNetIfState & static_cast<typeNetIfState>(enuNetIfState::IPv6)) ? "YES" : "NO"));
753- if (curNetIfState & static_cast<typeNetIfState>(enuNetIfState::IPv6))
754+ ip_addr_t multicast_addr_V6 = DNS_MQUERY_IPV6_GROUP_INIT;
755+ if (ERR_OK != mld6_leavegroup_netif(pNetIf, ip_2_ip6(&multicast_addr_V6)/*&(multicast_addr_V6.u_addr.ip6)*/))
756 {
757- DEBUG_OUTPUT.printf_P(PSTR("%s _checkNetIfState: IPv6 address: %s\n"), _DH(), _getResponderIPAddress(enuIPProtocolType::V6).toString().c_str());
758+ DEBUG_EX_ERR(DEBUG_OUTPUT.printf_P(PSTR("\n")););
759 }
760- }
761 #endif
762- );
763- if ((curNetIfState & static_cast<typeNetIfState>(enuNetIfState::LinkMask)) != (m_NetIfState & static_cast<typeNetIfState>(enuNetIfState::LinkMask)))
764- {
765- // Link came up or down
766- DEBUG_EX_INFO(DEBUG_OUTPUT.printf_P(PSTR("%s _checkNetIfState: Link state changed -> restarting\n"), _DH()););
767- restart();
768- }
769- else if (curNetIfState & static_cast<typeNetIfState>(enuNetIfState::LinkIsUp))
770- {
771- // Link is up (unchanged)
772- if ((curNetIfState & static_cast<typeNetIfState>(enuNetIfState::IPMask)) != (m_NetIfState & static_cast<typeNetIfState>(enuNetIfState::IPMask)))
773- {
774- // IP state changed
775- // TODO: If just a new IP address was added, a simple re-announcement should be enough
776- DEBUG_EX_INFO(DEBUG_OUTPUT.printf_P(PSTR("%s _checkNetIfState: IP state changed -> restarting\n"), _DH()););
777- restart();
778- }
779 }
780- /* if (enuProbingStatus::Done == m_HostProbeInformation.m_ProbingStatus) {
781- // Probing is done, prepare to (re)announce host
782- DEBUG_EX_INFO(DEBUG_OUTPUT.printf_P(PSTR("%s _checkNetIfState: Preparing to (re)announce host.\n")););
783- //m_HostProbeInformation.m_ProbingStatus = enuProbingStatus::Done;
784- m_HostProbeInformation.m_u8SentCount = 0;
785- m_HostProbeInformation.m_Timeout.reset(MDNS_ANNOUNCE_DELAY);
786- }*/
787- m_NetIfState = curNetIfState;
788- }
789-
790- bool bResult = ((curNetIfState & static_cast<typeNetIfState>(enuNetIfState::LinkMask)) && // Continue if Link is UP
791- (curNetIfState & static_cast<typeNetIfState>(enuNetIfState::IPMask))); // AND has any IP
792- DEBUG_EX_INFO(if (!bResult) DEBUG_OUTPUT.printf_P(PSTR("%s _checkNetIfState: Link is DOWN(%s) or NO IP address(%s)!\n"), _DH(), (curNetIfState & static_cast<typeNetIfState>(enuNetIfState::LinkMask) ? "NO" : "YES"), (curNetIfState & static_cast<typeNetIfState>(enuNetIfState::IPMask) ? "NO" : "YES")););
793 return bResult;
794 }
795
796@@ -1091,8 +1015,6 @@ bool clsLEAMDNSHost::_processUDPInput(void)
797
798 bool bResult = _parseMessage();
799
800- /* bResult = ((_checkNetIfState()) && // Any changes in the netif state?
801- (_parseMessage()));*/
802 DEBUG_EX_ERR(if (!bResult) DEBUG_OUTPUT.printf_P(PSTR("%s processUDPInput: FAILED!\n"), _DH()););
803
804 return bResult;
805@@ -1200,7 +1122,7 @@ const char* clsLEAMDNSHost::_instanceName(const char* p_pcInstanceName,
806 /*
807 clsLEAmDNS2_Host::_collectServiceTxts
808 */
809-bool clsLEAMDNSHost::_collectServiceTxts(clsLEAMDNSHost::clsService& p_rService)
810+bool clsLEAMDNSHost::_collectServiceTxts(clsLEAMDNSHost::clsService & p_rService)
811 {
812 if (p_rService.m_fnTxtCallback)
813 {
814@@ -1212,7 +1134,7 @@ bool clsLEAMDNSHost::_collectServiceTxts(clsLEAMDNSHost::clsService& p_rService)
815 /*
816 clsLEAmDNS2_Host::_releaseTempServiceTxts
817 */
818-bool clsLEAMDNSHost::_releaseTempServiceTxts(clsLEAMDNSHost::clsService& p_rService)
819+bool clsLEAMDNSHost::_releaseTempServiceTxts(clsLEAMDNSHost::clsService & p_rService)
820 {
821 return (p_rService.m_Txts.removeTempTxts());
822 }
823@@ -1243,7 +1165,7 @@ clsLEAMDNSHost::clsQuery* clsLEAMDNSHost::_allocQuery(clsLEAMDNSHost::clsQuery::
824 MDNSResponder:clsHost:::_removeQuery
825
826 */
827-bool clsLEAMDNSHost::_removeQuery(clsLEAMDNSHost::clsQuery* p_pQuery)
828+bool clsLEAMDNSHost::_removeQuery(clsLEAMDNSHost::clsQuery * p_pQuery)
829 {
830 bool bResult = false;
831
832@@ -1313,9 +1235,9 @@ bool clsLEAMDNSHost::_releaseQueries(void)
833 clsLEAmDNS2_Host::_findNextQueryByDomain
834
835 */
836-clsLEAMDNSHost::clsQuery* clsLEAMDNSHost::_findNextQueryByDomain(const clsLEAMDNSHost::clsRRDomain& p_Domain,
837+clsLEAMDNSHost::clsQuery* clsLEAMDNSHost::_findNextQueryByDomain(const clsLEAMDNSHost::clsRRDomain & p_Domain,
838 const clsLEAMDNSHost::clsQuery::enuQueryType p_QueryType,
839- const clsQuery* p_pPrevQuery)
840+ const clsQuery * p_pPrevQuery)
841 {
842 clsQuery* pMatchingQuery = 0;
843
844@@ -1350,7 +1272,8 @@ clsLEAMDNSHost::clsQuery* clsLEAMDNSHost::_findNextQueryByDomain(const clsLEAMDN
845 clsLEAmDNS2_Host::_installServiceQuery
846
847 */
848-clsLEAMDNSHost::clsQuery* clsLEAMDNSHost::_installServiceQuery(const char* p_pcService,
849+clsLEAMDNSHost::clsQuery* clsLEAMDNSHost::_installServiceQuery(netif* pNetIf,
850+ const char* p_pcService,
851 const char* p_pcProtocol)
852 {
853 clsQuery* pMDNSQuery = 0;
854@@ -1362,7 +1285,7 @@ clsLEAMDNSHost::clsQuery* clsLEAMDNSHost::_installServiceQuery(const char* p_pcS
855 {
856 pMDNSQuery->m_bStaticQuery = false;
857
858- if (_sendQuery(*pMDNSQuery))
859+ if (_sendQuery(pNetIf, *pMDNSQuery))
860 {
861 pMDNSQuery->m_u8SentCount = 1;
862 pMDNSQuery->m_ResendTimeout.reset(clsConsts::u32DynamicQueryResendDelay);
863@@ -1380,7 +1303,8 @@ clsLEAMDNSHost::clsQuery* clsLEAMDNSHost::_installServiceQuery(const char* p_pcS
864 /*
865 clsLEAmDNS2_Host::_installDomainQuery
866 */
867-clsLEAMDNSHost::clsQuery* clsLEAMDNSHost::_installDomainQuery(clsLEAMDNSHost::clsRRDomain& p_Domain,
868+clsLEAMDNSHost::clsQuery* clsLEAMDNSHost::_installDomainQuery(netif* pNetIf,
869+ clsLEAMDNSHost::clsRRDomain & p_Domain,
870 clsLEAMDNSHost::clsQuery::enuQueryType p_QueryType)
871 {
872 clsQuery* pQuery = 0;
873@@ -1390,7 +1314,7 @@ clsLEAMDNSHost::clsQuery* clsLEAMDNSHost::_installDomainQuery(clsLEAMDNSHost::cl
874 pQuery->m_Domain = p_Domain;
875 pQuery->m_bStaticQuery = false;
876
877- if (_sendQuery(*pQuery))
878+ if (_sendQuery(pNetIf, *pQuery))
879 {
880 pQuery->m_u8SentCount = 1;
881 pQuery->m_ResendTimeout.reset(clsConsts::u32DynamicQueryResendDelay);
882@@ -1405,13 +1329,10 @@ clsLEAMDNSHost::clsQuery* clsLEAMDNSHost::_installDomainQuery(clsLEAMDNSHost::cl
883 _printRRDomain(p_Domain);
884 DEBUG_OUTPUT.println();
885 );
886- DEBUG_EX_ERR(if (!pQuery)
887-{
888- DEBUG_OUTPUT.printf_P(PSTR("%s _installDomainQuery: FAILED for "), _DH());
889- _printRRDomain(p_Domain);
890- DEBUG_OUTPUT.println();
891- }
892- );
893+ DEBUG_EX_ERR_IF(!pQuery,
894+ DEBUG_OUTPUT.printf_P(PSTR("%s _installDomainQuery: FAILED for "), _DH());
895+ _printRRDomain(p_Domain);
896+ DEBUG_OUTPUT.println());
897 return pQuery;
898 }
899
900@@ -1436,8 +1357,8 @@ bool clsLEAMDNSHost::_hasQueriesWaitingForAnswers(void) const
901 /*
902 clsLEAmDNS2_Host::_executeQueryCallback
903 */
904-bool clsLEAMDNSHost::_executeQueryCallback(const clsQuery& p_Query,
905- const clsQuery::clsAnswer& p_Answer,
906+bool clsLEAMDNSHost::_executeQueryCallback(const clsQuery & p_Query,
907+ const clsQuery::clsAnswer & p_Answer,
908 clsQuery::clsAnswer::typeQueryAnswerType p_QueryAnswerTypeFlags,
909 bool p_bSetContent)
910 {
911diff --git a/libraries/ESP8266mDNS/src/LEAmDNS2Host.h b/libraries/ESP8266mDNS/src/LEAmDNS2Host.h
912index bdcc05e2..ab5dd400 100644
913--- a/libraries/ESP8266mDNS/src/LEAmDNS2Host.h
914+++ b/libraries/ESP8266mDNS/src/LEAmDNS2Host.h
915@@ -140,18 +140,24 @@
916 #ifdef DEBUG_ESP_MDNS_RESPONDER
917 #ifdef DEBUG_ESP_MDNS_INFO
918 #define DEBUG_EX_INFO(A) A
919+#define DEBUG_EX_INFO_IF(C,A...) do if (C) { A; } while (0)
920 #else
921 #define DEBUG_EX_INFO(A)
922+#define DEBUG_EX_INFO_IF(C,A...)
923 #endif
924 #ifdef DEBUG_ESP_MDNS_INFO2
925 #define DEBUG_EX_INFO2(A) A
926+#define DEBUG_EX_INFO2_IF(C,A...) do if (C) { A; } while (0)
927 #else
928 #define DEBUG_EX_INFO2(A)
929+#define DEBUG_EX_INFO2_IF(C,A...)
930 #endif
931 #ifdef DEBUG_ESP_MDNS_ERR
932 #define DEBUG_EX_ERR(A) A
933+#define DEBUG_EX_ERR_IF(C,A...) do if (C) { A; } while (0)
934 #else
935 #define DEBUG_EX_ERR(A)
936+#define DEBUG_EX_ERR_IF(C,A...)
937 #endif
938 #ifdef DEBUG_ESP_MDNS_TX
939 #define DEBUG_EX_TX(A) A
940@@ -267,11 +273,12 @@ protected:
941 /**
942 list
943 */
944- using list = std::list<clsLEAMDNSHost*>;
945+ //using list = std::list<clsLEAMDNSHost*>;
946
947 // File: ..._Backbone
948 /**
949 clsBackbone
950+ XXXX should be merged with holder clsLEAMDNSHost because there is no list anymore in it
951 */
952 class clsBackbone
953 {
954@@ -287,19 +294,31 @@ protected:
955 size_t hostCount(void) const;
956 bool setDelayUDPProcessing(bool p_bDelayProcessing);
957
958+ clsLEAMDNSHost* getUniqueHost()
959+ {
960+ return m_uniqueHost;
961+ }
962+
963 protected:
964 UdpContext* m_pUDPContext;
965 bool m_bDelayUDPProcessing;
966 uint32_t m_u32DelayedDatagrams;
967- list m_HostList;
968+ //list m_HostList;
969+ clsLEAMDNSHost* m_uniqueHost;
970
971 bool _allocUDPContext(void);
972 bool _releaseUDPContext(void);
973
974 bool _processUDPInput(void);
975
976- const clsLEAMDNSHost* _findHost(netif* p_pNetIf) const;
977- clsLEAMDNSHost* _findHost(netif* p_pNetIf);
978+ const clsLEAMDNSHost* _findHost() const
979+ {
980+ return m_uniqueHost;
981+ }
982+ clsLEAMDNSHost* _findHost()
983+ {
984+ return m_uniqueHost;
985+ }
986
987 const char* _DH(void) const;
988 };
989@@ -1245,8 +1264,7 @@ public:
990 static const char* indexDomainName(const char* p_pcDomainName,
991 const char* p_pcDivider = "-",
992 const char* p_pcDefaultDomainName = 0);
993- static bool setNetIfHostName(netif* p_pNetIf,
994- const char* p_pcHostName);
995+ static bool setNetIfHostName(const char* p_pcHostName);
996
997 clsLEAMDNSHost(void);
998 ~clsLEAMDNSHost(void);
999@@ -1256,12 +1274,6 @@ public:
1000 // Later call 'update()' in every 'loop' to run the process loop
1001 // (probing, announcing, responding, ...)
1002 // If no callback is given, the (maybe) already installed callback stays set
1003- bool begin(const char* p_pcHostName,
1004- netif* p_pNetIf,
1005- fnProbeResultCallback p_fnCallback = 0);
1006- bool begin(const char* p_pcHostName,
1007- WiFiMode_t p_WiFiMode,
1008- fnProbeResultCallback p_fnCallback = 0);
1009 bool begin(const char* p_pcHostName,
1010 fnProbeResultCallback p_fnCallback = 0);
1011
1012@@ -1327,16 +1339,22 @@ public:
1013 // - hasAnswerIPv6Address/answerIPv6Address service/host
1014 // - hasAnswerPort/answerPort service
1015 // - hasAnswerTxts/answerTxts service
1016- clsQuery* installServiceQuery(const char* p_pcServiceType,
1017- const char* p_pcProtocol,
1018- clsQuery::QueryCallbackAnswerFn p_fnCallbackAnswer);
1019- clsQuery* installServiceQuery(const char* p_pcServiceType,
1020- const char* p_pcProtocol,
1021- clsQuery::QueryCallbackAccessorFn p_fnCallbackAccessor);
1022- clsQuery* installHostQuery(const char* p_pcHostName,
1023- clsQuery::QueryCallbackAnswerFn p_fnCallbackAnswer);
1024- clsQuery* installHostQuery(const char* p_pcHostName,
1025- clsQuery::QueryCallbackAccessorFn p_fnCallbackAccessor);
1026+
1027+ /*
1028+ install*Query() creates several queries on the interfaces.
1029+ it no more returns a single query but a boolean until the API is adapted
1030+ */
1031+ /*clsQuery* */bool installServiceQuery(const char* p_pcServiceType,
1032+ const char* p_pcProtocol,
1033+ clsQuery::QueryCallbackAnswerFn p_fnCallbackAnswer);
1034+ /*clsQuery* */bool installServiceQuery(const char* p_pcServiceType,
1035+ const char* p_pcProtocol,
1036+ clsQuery::QueryCallbackAccessorFn p_fnCallbackAccessor,
1037+ std::list<clsQuery*>* ret = nullptr);
1038+ /*clsQuery* */bool installHostQuery(const char* p_pcHostName,
1039+ clsQuery::QueryCallbackAnswerFn p_fnCallbackAnswer);
1040+ /*clsQuery* */bool installHostQuery(const char* p_pcHostName,
1041+ clsQuery::QueryCallbackAccessorFn p_fnCallbackAccessor);
1042 // Remove a dynamic service query
1043 bool removeQuery(clsQuery* p_pQuery);
1044
1045@@ -1418,9 +1436,11 @@ protected:
1046 clsQuery* _findNextQueryByDomain(const clsRRDomain& p_Domain,
1047 const clsQuery::enuQueryType p_QueryType,
1048 const clsQuery* p_pPrevQuery);
1049- clsQuery* _installServiceQuery(const char* p_pcService,
1050+ clsQuery* _installServiceQuery(netif* pNetIf,
1051+ const char* p_pcService,
1052 const char* p_pcProtocol);
1053- clsQuery* _installDomainQuery(clsRRDomain& p_Domain,
1054+ clsQuery* _installDomainQuery(netif *pNetIf,
1055+ clsRRDomain& p_Domain,
1056 clsQuery::enuQueryType p_QueryType);
1057 bool _hasQueriesWaitingForAnswers(void) const;
1058 bool _executeQueryCallback(const clsQuery& p_Query,
1059@@ -1431,11 +1451,12 @@ protected:
1060
1061 // File: ..._Host_Control
1062 // RECEIVING
1063- bool _parseMessage(void);
1064- bool _parseQuery(const clsMsgHeader& p_Header);
1065+ bool _parseMessage();
1066+ bool _parseQuery(netif* pNetIf,
1067+ const clsMsgHeader& p_Header);
1068
1069- bool _parseResponse(const clsMsgHeader& p_Header);
1070- bool _processAnswers(const clsRRAnswer* p_pPTRAnswers);
1071+ bool _parseResponse(netif* pNetIf, const clsMsgHeader& p_Header);
1072+ bool _processAnswers(netif* pNetIf, const clsRRAnswer* p_pPTRAnswers);
1073 bool _processPTRAnswer(const clsRRAnswerPTR* p_pPTRAnswer,
1074 bool& p_rbFoundNewKeyAnswer);
1075 bool _processSRVAnswer(const clsRRAnswerSRV* p_pSRVAnswer,
1076@@ -1449,11 +1470,11 @@ protected:
1077 #endif
1078
1079 // PROBING
1080- bool _updateProbeStatus(void);
1081+ bool _updateProbeStatus(netif* pNetIf);
1082 bool _resetProbeStatus(bool p_bRestart = true);
1083 bool _hasProbesWaitingForAnswers(void) const;
1084- bool _sendHostProbe(void);
1085- bool _sendServiceProbe(clsService& p_rService);
1086+ bool _sendHostProbe(netif* pNetIf);
1087+ bool _sendServiceProbe(netif* pNetIf, clsService& p_rService);
1088 bool _cancelProbingForHost(void);
1089 bool _cancelProbingForService(clsService& p_rService);
1090 bool _callHostProbeResultCallback(bool p_bResult);
1091@@ -1461,15 +1482,18 @@ protected:
1092 bool p_bResult);
1093
1094 // ANNOUNCE
1095- bool _announce(bool p_bAnnounce,
1096+ bool _announce(netif* pNetIf,
1097+ bool p_bAnnounce,
1098 bool p_bIncludeServices);
1099- bool _announceService(clsService& p_pService,
1100+ bool _announceService(netif* pNetIf,
1101+ clsService& p_pService,
1102 bool p_bAnnounce = true);
1103
1104 // QUERY CACHE
1105- bool _checkQueryCache(void);
1106+ bool _checkQueryCache(netif* pNetIf);
1107
1108- uint32_t _replyMaskForHost(const clsRRHeader& p_RRHeader,
1109+ uint32_t _replyMaskForHost(netif* pNetIf,
1110+ const clsRRHeader& p_RRHeader,
1111 bool* p_pbFullNameMatch = 0) const;
1112 uint32_t _replyMaskForService(const clsRRHeader& p_RRHeader,
1113 clsService& p_rService,
1114@@ -1478,20 +1502,24 @@ protected:
1115
1116 // File: ..._Host_Transfer
1117 // SENDING
1118- bool _sendMessage(clsSendParameter& p_SendParameter);
1119- bool _sendMessage_Multicast(clsSendParameter& p_rSendParameter,
1120+ bool _sendMessage(netif* pNetIf, clsSendParameter& p_SendParameter);
1121+ bool _sendMessage_Multicast(netif* pNetIf,
1122+ clsSendParameter& p_rSendParameter,
1123 uint8_t p_IPProtocolTypes);
1124- bool _prepareMessage(clsSendParameter& p_SendParameter);
1125+ bool _prepareMessage(netif* pNetIf, clsSendParameter& p_SendParameter);
1126 bool _addQueryRecord(clsSendParameter& p_rSendParameter,
1127 const clsRRDomain& p_QueryDomain,
1128 uint16_t p_u16QueryType);
1129- bool _sendQuery(const clsQuery& p_Query,
1130+ bool _sendQuery(netif* netif,
1131+ const clsQuery& p_Query,
1132 clsQuery::clsAnswer::list* p_pKnownAnswers = 0);
1133- bool _sendQuery(const clsRRDomain& p_QueryDomain,
1134+ bool _sendQuery(netif* netif,
1135+ const clsRRDomain& p_QueryDomain,
1136 uint16_t p_u16RecordType,
1137 clsQuery::clsAnswer::list* p_pKnownAnswers = 0);
1138
1139- IPAddress _getResponderIPAddress(enuIPProtocolType p_IPProtocolType) const;
1140+ IPAddress _getResponderIPAddress(netif* pNetIf,
1141+ enuIPProtocolType p_IPProtocolType) const;
1142
1143 // RESOURCE RECORD
1144 bool _readRRQuestion(clsRRQuestion& p_rQuestion);
1145@@ -1640,8 +1668,6 @@ protected:
1146
1147
1148 protected:
1149- netif* m_pNetIf;
1150- typeNetIfState m_NetIfState;
1151 UdpContext* m_pUDPContext;
1152
1153 char* m_pcHostName;
1154diff --git a/libraries/ESP8266mDNS/src/LEAmDNS2Host_Control.cpp b/libraries/ESP8266mDNS/src/LEAmDNS2Host_Control.cpp
1155index a061d77d..c8cf993e 100644
1156--- a/libraries/ESP8266mDNS/src/LEAmDNS2Host_Control.cpp
1157+++ b/libraries/ESP8266mDNS/src/LEAmDNS2Host_Control.cpp
1158@@ -44,7 +44,7 @@ namespace experimental
1159 clsLEAmDNS2_Host::_parseMessage
1160
1161 */
1162-bool clsLEAMDNSHost::_parseMessage(void)
1163+bool clsLEAMDNSHost::_parseMessage()
1164 {
1165 DEBUG_EX_INFO(
1166 unsigned long ulStartTime = millis();
1167@@ -54,6 +54,7 @@ bool clsLEAMDNSHost::_parseMessage(void)
1168 m_pUDPContext->getDestAddress().toString().c_str());
1169 );
1170 //DEBUG_EX_INFO(_udpDump(););
1171+ netif* pNetIf = m_pUDPContext->getInputNetif();
1172
1173 bool bResult = false;
1174
1175@@ -76,13 +77,13 @@ bool clsLEAMDNSHost::_parseMessage(void)
1176 {
1177 // Received a response -> answers to a query
1178 //DEBUG_EX_RX(DEBUG_OUTPUT.printf_P(PSTR("%s _parseMessage: Reading answers: ID:%u, Q:%u, A:%u, NS:%u, AR:%u\n"), _DH(), header.m_u16ID, header.m_u16QDCount, header.m_u16ANCount, header.m_u16NSCount, header.m_u16ARCount););
1179- bResult = _parseResponse(header);
1180+ bResult = _parseResponse(pNetIf, header);
1181 }
1182 else
1183 {
1184 // Received a query (Questions)
1185 //DEBUG_EX_RX(DEBUG_OUTPUT.printf_P(PSTR("%s _parseMessage: Reading query: ID:%u, Q:%u, A:%u, NS:%u, AR:%u\n"), _DH(), header.m_u16ID, header.m_u16QDCount, header.m_u16ANCount, header.m_u16NSCount, header.m_u16ARCount););
1186- bResult = _parseQuery(header);
1187+ bResult = _parseQuery(m_pUDPContext->getInputNetif(), header);
1188 }
1189 }
1190 else
1191@@ -119,7 +120,8 @@ bool clsLEAMDNSHost::_parseMessage(void)
1192 Legacy queries have got only one (unicast) question and are directed to the local DNS port (not the multicast port).
1193
1194 */
1195-bool clsLEAMDNSHost::_parseQuery(const clsLEAMDNSHost::clsMsgHeader& p_MsgHeader)
1196+bool clsLEAMDNSHost::_parseQuery(netif* pNetIf,
1197+ const clsLEAMDNSHost::clsMsgHeader& p_MsgHeader)
1198 {
1199 bool bResult = true;
1200
1201@@ -134,7 +136,7 @@ bool clsLEAMDNSHost::_parseQuery(const clsLEAMDNSHost::clsMsgHeader& p_MsgHeader
1202 // Define host replies, BUT only answer queries after probing is done
1203 u32HostOrServiceReplies =
1204 sendParameter.m_u32HostReplyMask |= ((probeStatus())
1205- ? _replyMaskForHost(questionRR.m_Header, 0)
1206+ ? _replyMaskForHost(pNetIf, questionRR.m_Header, 0)
1207 : 0);
1208 DEBUG_EX_INFO(if (u32HostOrServiceReplies) DEBUG_OUTPUT.printf_P(PSTR("%s _parseQuery: Host reply needed %s\n"), _DH(), _replyFlags2String(u32HostOrServiceReplies)););
1209
1210@@ -142,7 +144,7 @@ bool clsLEAMDNSHost::_parseQuery(const clsLEAMDNSHost::clsMsgHeader& p_MsgHeader
1211 if (clsProbeInformation_Base::clsProbeInformation_Base::enuProbingStatus::InProgress == m_ProbeInformation.m_ProbingStatus)
1212 {
1213 bool bFullNameMatch = false;
1214- if ((_replyMaskForHost(questionRR.m_Header, &bFullNameMatch)) &&
1215+ if ((_replyMaskForHost(pNetIf, questionRR.m_Header, &bFullNameMatch)) &&
1216 (bFullNameMatch))
1217 {
1218 // We're in 'probing' state and someone is asking for our host domain: this might be
1219@@ -206,15 +208,12 @@ bool clsLEAMDNSHost::_parseQuery(const clsLEAMDNSHost::clsMsgHeader& p_MsgHeader
1220 // Local host check
1221 // We're a match for this legacy query, BUT
1222 // make sure, that the query comes from a local host
1223-#ifdef MDNS_IPV4_SUPPORT
1224- ip_info IPInfo_Local;
1225-#endif
1226- if ((m_pNetIf) &&
1227- (m_pUDPContext) &&
1228+ if ((m_pUDPContext) &&
1229 #ifdef MDNS_IPV4_SUPPORT
1230 (m_pUDPContext->getRemoteAddress().isV4()) &&
1231- ((wifi_get_ip_info(netif_get_index(m_pNetIf), &IPInfo_Local))) &&
1232- (ip4_addr_netcmp(ip_2_ip4((const ip_addr_t*)m_pUDPContext->getRemoteAddress()), &IPInfo_Local.ip, &IPInfo_Local.netmask))
1233+ (ip4_addr_netcmp(ip_2_ip4((const ip_addr_t*)m_pUDPContext->getRemoteAddress()),
1234+ ip_2_ip4(&m_pUDPContext->getInputNetif()->ip_addr),
1235+ ip_2_ip4(&m_pUDPContext->getInputNetif()->netmask)))
1236 #else
1237 (true)
1238 #endif
1239@@ -227,15 +226,7 @@ bool clsLEAMDNSHost::_parseQuery(const clsLEAMDNSHost::clsMsgHeader& p_MsgHeader
1240 #endif
1241 )
1242 {
1243- /* ip_info IPInfo_Local;
1244- ip_info IPInfo_Remote;
1245- if (((IPInfo_Remote.ip.addr = m_pUDPContext->getRemoteAddress())) &&
1246- (((wifi_get_ip_info(SOFTAP_IF, &IPInfo_Local)) &&
1247- (ip4_addr_netcmp(&IPInfo_Remote.ip, &IPInfo_Local.ip, &IPInfo_Local.netmask))) || // Remote IP in SOFTAP's subnet OR
1248- ((wifi_get_ip_info(STATION_IF, &IPInfo_Local)) &&
1249- (ip4_addr_netcmp(&IPInfo_Remote.ip, &IPInfo_Local.ip, &IPInfo_Local.netmask))))) // Remote IP in STATION's subnet
1250- {*/
1251- Serial.println("\n\n\nUNICAST QUERY\n\n");
1252+ DEBUG_EX_RX(DEBUG_OUTPUT.println("\n\n\nUNICAST QUERY\n\n"));
1253 DEBUG_EX_RX(DEBUG_OUTPUT.printf_P(PSTR("%s _parseQuery: Legacy DNS query from local host %s!\n"), _DH(), m_pUDPContext->getRemoteAddress().toString().c_str()););
1254
1255 sendParameter.m_u16ID = p_MsgHeader.m_u16ID;
1256@@ -257,7 +248,7 @@ bool clsLEAMDNSHost::_parseQuery(const clsLEAMDNSHost::clsMsgHeader& p_MsgHeader
1257 }
1258 else
1259 {
1260- Serial.printf("\n\n\nINVALID UNICAST QUERY from %s\n\n\n", m_pUDPContext->getRemoteAddress().toString().c_str());
1261+ DEBUG_EX_RX(DEBUG_OUTPUT.printf("\n\n\nINVALID UNICAST QUERY from %s\n\n\n", m_pUDPContext->getRemoteAddress().toString().c_str()));
1262 DEBUG_EX_RX(DEBUG_OUTPUT.printf_P(PSTR("%s _parseQuery: Legacy DNS query from NON-LOCAL host at %s!\n"), _DH(), m_pUDPContext->getRemoteAddress().toString().c_str()););
1263 bResult = false;
1264 }
1265@@ -292,7 +283,7 @@ bool clsLEAMDNSHost::_parseQuery(const clsLEAMDNSHost::clsMsgHeader& p_MsgHeader
1266 {
1267 /* - RFC6762 7.1 Suppression only for 'Shared Records' -
1268 // Find match between planned answer (sendParameter.m_u8HostReplyMask) and this 'known answer'
1269- uint32_t u32HostMatchMask = (sendParameter.m_u32HostReplyMask & _replyMaskForHost(pKnownRRAnswer->m_Header));
1270+ uint32_t u32HostMatchMask = (sendParameter.m_u32HostReplyMask & _replyMaskForHost(pNetIf, pKnownRRAnswer->m_Header));
1271 if ((u32HostMatchMask) && // The RR in the known answer matches an RR we are planning to send, AND
1272 ((Consts::u32HostTTL / 2) <= pKnownRRAnswer->m_u32TTL)) // The TTL of the known answer is longer than half of the new host TTL (120s)
1273 {
1274@@ -328,7 +319,7 @@ bool clsLEAMDNSHost::_parseQuery(const clsLEAMDNSHost::clsMsgHeader& p_MsgHeader
1275 // IPv4 address was asked for
1276 #ifdef MDNS_IPV4_SUPPORT
1277 if ((enuAnswerType::A == pKnownRRAnswer->answerType()) &&
1278- (((stcRRAnswerA*)pKnownRRAnswer)->m_IPAddress == _getResponderIPAddress(enuIPProtocolType::V4)))
1279+ (((stcRRAnswerA*)pKnownRRAnswer)->m_IPAddress == _getResponderIPAddress(pNetIf, enuIPProtocolType::V4)))
1280 {
1281
1282 DEBUG_EX_INFO2(DEBUG_OUTPUT.printf_P(PSTR("%s _parseQuery: IPv4 address already known (TTL:%u)... skipping!\n"), _DH(), pKnownRRAnswer->m_u32TTL););
1283@@ -341,7 +332,7 @@ bool clsLEAMDNSHost::_parseQuery(const clsLEAMDNSHost::clsMsgHeader& p_MsgHeader
1284 // IPv6 address was asked for
1285 #ifdef MDNS_IPV6_SUPPORT
1286 if ((enuAnswerType::AAAA == pKnownRRAnswer->answerType()) &&
1287- (((stcRRAnswerAAAA*)pKnownRRAnswer)->m_IPAddress == _getResponderIPAddress(enuIPProtocolType::V6)))
1288+ (((stcRRAnswerAAAA*)pKnownRRAnswer)->m_IPAddress == _getResponderIPAddress(pNetIf, enuIPProtocolType::V6)))
1289 {
1290
1291 DEBUG_EX_INFO(DEBUG_OUTPUT.printf_P(PSTR("%s _parseQuery: IPv6 address already known... skipping!\n"), _DH()););
1292@@ -365,7 +356,7 @@ bool clsLEAMDNSHost::_parseQuery(const clsLEAMDNSHost::clsMsgHeader& p_MsgHeader
1293 if (enuAnswerType::A == pKnownRRAnswer->answerType())
1294 {
1295 // CHECK
1296- IPAddress localIPAddress(_getResponderIPAddress(enuIPProtocolType::V4));
1297+ IPAddress localIPAddress(_getResponderIPAddress(pNetIf, enuIPProtocolType::V4));
1298 if (((clsRRAnswerA*)pKnownRRAnswer)->m_IPAddress == localIPAddress)
1299 {
1300 // SAME IP address -> We've received an old message from ourselfs (same IP)
1301@@ -393,7 +384,7 @@ bool clsLEAMDNSHost::_parseQuery(const clsLEAMDNSHost::clsMsgHeader& p_MsgHeader
1302 #ifdef MDNS_IPV6_SUPPORT
1303 if (enuAnswerType::AAAA == pKnownRRAnswer->answerType())
1304 {
1305- IPAddress localIPAddress(_getResponderIPAddress(enuIPProtocolType::V6));
1306+ IPAddress localIPAddress(_getResponderIPAddress(pNetIf, enuIPProtocolType::V6));
1307 if (((clsRRAnswerAAAA*)pKnownRRAnswer)->m_IPAddress == localIPAddress)
1308 {
1309 // SAME IP address -> We've received an old message from ourselfs (same IP)
1310@@ -559,7 +550,7 @@ bool clsLEAMDNSHost::_parseQuery(const clsLEAMDNSHost::clsMsgHeader& p_MsgHeader
1311 sendParameter.m_Response = clsSendParameter::enuResponseType::Response;
1312 sendParameter.m_bAuthorative = true;
1313
1314- bResult = _sendMessage(sendParameter);
1315+ bResult = _sendMessage(pNetIf, sendParameter);
1316 }
1317 DEBUG_EX_INFO(else
1318 {
1319@@ -618,7 +609,7 @@ bool clsLEAMDNSHost::_parseQuery(const clsLEAMDNSHost::clsMsgHeader& p_MsgHeader
1320 TXT - links the instance name to services TXTs
1321 Level 3: A/AAAA - links the host domain to an IP address
1322 */
1323-bool clsLEAMDNSHost::_parseResponse(const clsLEAMDNSHost::clsMsgHeader& p_MsgHeader)
1324+bool clsLEAMDNSHost::_parseResponse(netif* pNetIf, const clsLEAMDNSHost::clsMsgHeader& p_MsgHeader)
1325 {
1326 //DEBUG_EX_INFO(DEBUG_OUTPUT.printf_P(PSTR("%s _parseResponse\n")););
1327 //DEBUG_EX_INFO(_udpDump(););
1328@@ -675,7 +666,7 @@ bool clsLEAMDNSHost::_parseResponse(const clsLEAMDNSHost::clsMsgHeader& p_MsgHea
1329 if (bResult)
1330 {
1331 bResult = ((!pCollectedRRAnswers) ||
1332- (_processAnswers(pCollectedRRAnswers)));
1333+ (_processAnswers(pNetIf, pCollectedRRAnswers)));
1334 }
1335 else // Some failure while reading answers
1336 {
1337@@ -736,7 +727,7 @@ bool clsLEAMDNSHost::_parseResponse(const clsLEAMDNSHost::clsMsgHeader& p_MsgHea
1338 TXT (0x10): eg. MyESP._http._tcp.local TXT OP TTL c#=1
1339
1340 */
1341-bool clsLEAMDNSHost::_processAnswers(const clsLEAMDNSHost::clsRRAnswer* p_pAnswers)
1342+bool clsLEAMDNSHost::_processAnswers(netif* pNetIf, const clsLEAMDNSHost::clsRRAnswer* p_pAnswers)
1343 {
1344 bool bResult = false;
1345
1346@@ -806,14 +797,14 @@ bool clsLEAMDNSHost::_processAnswers(const clsLEAMDNSHost::clsRRAnswer* p_pAnswe
1347 bool bPossibleEcho = false;
1348 #ifdef MDNS_IPV4_SUPPORT
1349 if ((enuAnswerType::A == pRRAnswer->answerType()) &&
1350- (((clsRRAnswerA*)pRRAnswer)->m_IPAddress == _getResponderIPAddress(enuIPProtocolType::V4)))
1351+ (((clsRRAnswerA*)pRRAnswer)->m_IPAddress == _getResponderIPAddress(pNetIf, enuIPProtocolType::V4)))
1352 {
1353 bPossibleEcho = true;
1354 }
1355 #endif
1356 #ifdef MDNS_IPV6_SUPPORT
1357 if ((enuAnswerType::AAAA == pRRAnswer->answerType()) &&
1358- (((clsRRAnswerAAAA*)pRRAnswer)->m_IPAddress == _getResponderIPAddress(enuIPProtocolType::V6)))
1359+ (((clsRRAnswerAAAA*)pRRAnswer)->m_IPAddress == _getResponderIPAddress(pNetIf, enuIPProtocolType::V6)))
1360 {
1361 bPossibleEcho = true;
1362 }
1363@@ -1292,7 +1283,7 @@ bool clsLEAMDNSHost::_processAAAAAnswer(const clsLEAMDNSHost::clsRRAnswerAAAA* p
1364 Conflict management is handled in '_parseResponse ff.'
1365 Tiebraking is handled in 'parseQuery ff.'
1366 */
1367-bool clsLEAMDNSHost::_updateProbeStatus(void)
1368+bool clsLEAMDNSHost::_updateProbeStatus(netif* pNetIf)
1369 {
1370 bool bResult = true;
1371
1372@@ -1301,13 +1292,13 @@ bool clsLEAMDNSHost::_updateProbeStatus(void)
1373 if ((clsProbeInformation_Base::enuProbingStatus::ReadyToStart == m_ProbeInformation.m_ProbingStatus) && // Ready to get started AND
1374 ((
1375 #ifdef MDNS_IPV4_SUPPORT
1376- _getResponderIPAddress(enuIPProtocolType::V4).isSet() // AND has IPv4 address
1377+ _getResponderIPAddress(pNetIf, enuIPProtocolType::V4).isSet() // AND has IPv4 address
1378 #else
1379 true
1380 #endif
1381 ) || (
1382 #ifdef MDNS_IPV6_SUPPORT
1383- _getResponderIPAddress(enuIPProtocolType::V6).isSet() // OR has IPv6 address
1384+ _getResponderIPAddress(pNetIf, enuIPProtocolType::V6).isSet() // OR has IPv6 address
1385 #else
1386 true
1387 #endif
1388@@ -1325,7 +1316,7 @@ bool clsLEAMDNSHost::_updateProbeStatus(void)
1389 if (clsConsts::u32ProbeCount > m_ProbeInformation.m_u8SentCount)
1390 {
1391 // Send next probe
1392- if ((bResult = _sendHostProbe()))
1393+ if ((bResult = _sendHostProbe(pNetIf)))
1394 {
1395 DEBUG_EX_INFO(DEBUG_OUTPUT.printf_P(PSTR("%s _updateProbeStatus: Did sent host probe for '%s.local'\n\n"), _DH(), (m_pcHostName ? : "")););
1396 m_ProbeInformation.m_Timeout.reset(clsConsts::u32ProbeDelay);
1397@@ -1350,7 +1341,7 @@ bool clsLEAMDNSHost::_updateProbeStatus(void)
1398 else if ((clsProbeInformation_Base::enuProbingStatus::ReadyToAnnounce == m_ProbeInformation.m_ProbingStatus) &&
1399 (m_ProbeInformation.m_Timeout.expired()))
1400 {
1401- if ((bResult = _announce(true, false)))
1402+ if ((bResult = _announce(pNetIf, true, false)))
1403 {
1404 // Don't announce services here
1405 ++m_ProbeInformation.m_u8SentCount; // 1..
1406@@ -1389,7 +1380,7 @@ bool clsLEAMDNSHost::_updateProbeStatus(void)
1407 if (clsConsts::u32ProbeCount > pService->m_ProbeInformation.m_u8SentCount)
1408 {
1409 // Send next probe
1410- if ((bResult = _sendServiceProbe(*pService)))
1411+ if ((bResult = _sendServiceProbe(pNetIf, *pService)))
1412 {
1413 DEBUG_EX_INFO(DEBUG_OUTPUT.printf_P(PSTR("%s _updateProbeStatus: Did sent service probe for '%s' (%u)\n\n"), _DH(), _service2String(pService), (pService->m_ProbeInformation.m_u8SentCount + 1)););
1414 pService->m_ProbeInformation.m_Timeout.reset(clsConsts::u32ProbeDelay);
1415@@ -1415,7 +1406,7 @@ bool clsLEAMDNSHost::_updateProbeStatus(void)
1416 (pService->m_ProbeInformation.m_Timeout.expired()))
1417 {
1418 // Probing already finished OR waiting for next time slot
1419- if ((bResult = _announceService(*pService)))
1420+ if ((bResult = _announceService(pNetIf, *pService)))
1421 {
1422 // Announce service
1423 ++pService->m_ProbeInformation.m_u8SentCount; // 1..
1424@@ -1493,7 +1484,7 @@ bool clsLEAMDNSHost::_hasProbesWaitingForAnswers(void) const
1425 - A/AAAA (eg. esp8266.esp -> 192.168.2.120)
1426
1427 */
1428-bool clsLEAMDNSHost::_sendHostProbe(void)
1429+bool clsLEAMDNSHost::_sendHostProbe(netif* pNetIf)
1430 {
1431 DEBUG_EX_INFO(DEBUG_OUTPUT.printf_P(PSTR("%s _sendHostProbe (%s.local, %lu)\n"), _DH(), m_pcHostName, millis()););
1432
1433@@ -1532,7 +1523,7 @@ bool clsLEAMDNSHost::_sendHostProbe(void)
1434 }
1435 DEBUG_EX_ERR(if (!bResult) DEBUG_OUTPUT.printf_P(PSTR("%s _sendHostProbe: FAILED!\n"), _DH()););
1436 return ((bResult) &&
1437- (_sendMessage(sendParameter)));
1438+ (_sendMessage(pNetIf, sendParameter)));
1439 }
1440
1441 /*
1442@@ -1548,7 +1539,7 @@ bool clsLEAMDNSHost::_sendHostProbe(void)
1443 - PTR NAME (eg. _http._tcp.local -> MyESP._http._tcp.local) (TODO: Check if needed, maybe TXT is better)
1444
1445 */
1446-bool clsLEAMDNSHost::_sendServiceProbe(clsService& p_rService)
1447+bool clsLEAMDNSHost::_sendServiceProbe(netif* pNetIf, clsService& p_rService)
1448 {
1449 DEBUG_EX_INFO(DEBUG_OUTPUT.printf_P(PSTR("%s _sendServiceProbe (%s, %lu)\n"), _DH(), _service2String(&p_rService), millis()););
1450
1451@@ -1582,7 +1573,7 @@ bool clsLEAMDNSHost::_sendServiceProbe(clsService& p_rService)
1452 }
1453 DEBUG_EX_ERR(if (!bResult) DEBUG_OUTPUT.printf_P(PSTR("%s _sendServiceProbe: FAILED!\n"), _DH()););
1454 return ((bResult) &&
1455- (_sendMessage(sendParameter)));
1456+ (_sendMessage(pNetIf, sendParameter)));
1457 }
1458
1459 /*
1460@@ -1681,7 +1672,8 @@ bool clsLEAMDNSHost::_callServiceProbeResultCallback(clsLEAMDNSHost::clsService&
1461 inside the '_writeXXXAnswer' procs via 'sendParameter.m_bUnannounce = true'
1462
1463 */
1464-bool clsLEAMDNSHost::_announce(bool p_bAnnounce,
1465+bool clsLEAMDNSHost::_announce(netif* pNetIf,
1466+ bool p_bAnnounce,
1467 bool p_bIncludeServices)
1468 {
1469 bool bResult = false;
1470@@ -1727,14 +1719,15 @@ bool clsLEAMDNSHost::_announce(bool p_bAnnounce,
1471 }
1472 DEBUG_EX_ERR(if (!bResult) DEBUG_OUTPUT.printf_P(PSTR("%s _announce: FAILED!\n"), _DH()););
1473 return ((bResult) &&
1474- (_sendMessage(sendParameter)));
1475+ (_sendMessage(pNetIf, sendParameter)));
1476 }
1477
1478 /*
1479 clsLEAmDNS2_Host::_announceService
1480
1481 */
1482-bool clsLEAMDNSHost::_announceService(clsLEAMDNSHost::clsService& p_rService,
1483+bool clsLEAMDNSHost::_announceService(netif* pNetIf,
1484+ clsLEAMDNSHost::clsService& p_rService,
1485 bool p_bAnnounce /*= true*/)
1486 {
1487 bool bResult = false;
1488@@ -1760,7 +1753,7 @@ bool clsLEAMDNSHost::_announceService(clsLEAMDNSHost::clsService& p_rService,
1489 }
1490 DEBUG_EX_ERR(if (!bResult) DEBUG_OUTPUT.printf_P(PSTR("%s _announceService: FAILED!\n"), _DH()););
1491 return ((bResult) &&
1492- (_sendMessage(sendParameter)));
1493+ (_sendMessage(pNetIf, sendParameter)));
1494 }
1495
1496
1497@@ -1779,7 +1772,7 @@ bool clsLEAMDNSHost::_announceService(clsLEAMDNSHost::clsService& p_rService,
1498 When no update arrived (in time), the component is removed from the answer (cache).
1499
1500 */
1501-bool clsLEAMDNSHost::_checkQueryCache(void)
1502+bool clsLEAMDNSHost::_checkQueryCache(netif* pNetIf)
1503 {
1504 bool bResult = true;
1505
1506@@ -1794,7 +1787,7 @@ bool clsLEAMDNSHost::_checkQueryCache(void)
1507 if ((!pQuery->m_bStaticQuery) &&
1508 (pQuery->m_ResendTimeout.expired()))
1509 {
1510- if ((bResult = _sendQuery(*pQuery)))
1511+ if ((bResult = _sendQuery(pNetIf, *pQuery)))
1512 {
1513 // The re-query rate is increased to more than one hour (RFC 6762 5.2)
1514 ++pQuery->m_u8SentCount;
1515@@ -1827,7 +1820,7 @@ bool clsLEAMDNSHost::_checkQueryCache(void)
1516 {
1517 if (!pQAnswer->m_TTLServiceDomain.finalTimeoutLevel())
1518 {
1519- bResult = ((_sendQuery(*pQuery)) &&
1520+ bResult = ((_sendQuery(pNetIf, *pQuery)) &&
1521 (pQAnswer->m_TTLServiceDomain.restart()));
1522 DEBUG_EX_INFO(
1523 DEBUG_OUTPUT.printf_P(PSTR("%s _checkQueryCache: PTR update scheduled for "), _DH());
1524@@ -1859,7 +1852,7 @@ bool clsLEAMDNSHost::_checkQueryCache(void)
1525 {
1526 if (!pQAnswer->m_TTLHostDomainAndPort.finalTimeoutLevel())
1527 {
1528- bResult = ((_sendQuery(pQAnswer->m_ServiceDomain, DNS_RRTYPE_SRV)) &&
1529+ bResult = ((_sendQuery(pNetIf, pQAnswer->m_ServiceDomain, DNS_RRTYPE_SRV)) &&
1530 (pQAnswer->m_TTLHostDomainAndPort.restart()));
1531 DEBUG_EX_INFO(
1532 DEBUG_OUTPUT.printf_P(PSTR("%s _checkQueryCache: SRV update scheduled for "), _DH());
1533@@ -1905,7 +1898,7 @@ bool clsLEAMDNSHost::_checkQueryCache(void)
1534 {
1535 if (!pQAnswer->m_TTLTxts.finalTimeoutLevel())
1536 {
1537- bResult = ((_sendQuery(pQAnswer->m_ServiceDomain, DNS_RRTYPE_TXT)) &&
1538+ bResult = ((_sendQuery(pNetIf, pQAnswer->m_ServiceDomain, DNS_RRTYPE_TXT)) &&
1539 (pQAnswer->m_TTLTxts.restart()));
1540 DEBUG_EX_INFO(
1541 DEBUG_OUTPUT.printf_P(PSTR("%s _checkQueryCache: TXT update scheduled for "), _DH());
1542@@ -1948,7 +1941,7 @@ bool clsLEAMDNSHost::_checkQueryCache(void)
1543 {
1544 // Needs update
1545 if ((bAUpdateQuerySent) ||
1546- ((bResult = _sendQuery(pQAnswer->m_HostDomain, DNS_RRTYPE_A))))
1547+ ((bResult = _sendQuery(pNetIf, pQAnswer->m_HostDomain, DNS_RRTYPE_A))))
1548 {
1549 pIPv4Address->m_TTL.restart();
1550 bAUpdateQuerySent = true;
1551@@ -2001,7 +1994,7 @@ bool clsLEAMDNSHost::_checkQueryCache(void)
1552 {
1553 // Needs update
1554 if ((bAAAAUpdateQuerySent) ||
1555- ((bResult = _sendQuery(pQAnswer->m_HostDomain, DNS_RRTYPE_AAAA))))
1556+ ((bResult = _sendQuery(pNetIf, pQAnswer->m_HostDomain, DNS_RRTYPE_AAAA))))
1557 {
1558 pIPv6Address->m_TTL.restart();
1559 bAAAAUpdateQuerySent = true;
1560@@ -2064,7 +2057,8 @@ bool clsLEAMDNSHost::_checkQueryCache(void)
1561
1562 In addition, a full name match (question domain == host domain) is marked.
1563 */
1564-uint32_t clsLEAMDNSHost::_replyMaskForHost(const clsLEAMDNSHost::clsRRHeader& p_RRHeader,
1565+uint32_t clsLEAMDNSHost::_replyMaskForHost(netif* pNetIf,
1566+ const clsLEAMDNSHost::clsRRHeader& p_RRHeader,
1567 bool* p_pbFullNameMatch /*= 0*/) const
1568 {
1569 //DEBUG_EX_INFO(DEBUG_OUTPUT.printf_P(PSTR("%s _replyMaskForHost\n")););
1570@@ -2082,8 +2076,8 @@ uint32_t clsLEAMDNSHost::_replyMaskForHost(const clsLEAMDNSHost::clsRRHeader& p_
1571 // PTR request
1572 #ifdef MDNS_IPV4_SUPPORT
1573 clsRRDomain reverseIPv4Domain;
1574- if ((_getResponderIPAddress(enuIPProtocolType::V4).isSet()) &&
1575- (_buildDomainForReverseIPv4(_getResponderIPAddress(enuIPProtocolType::V4), reverseIPv4Domain)) &&
1576+ if ((_getResponderIPAddress(pNetIf, enuIPProtocolType::V4).isSet()) &&
1577+ (_buildDomainForReverseIPv4(_getResponderIPAddress(pNetIf, enuIPProtocolType::V4), reverseIPv4Domain)) &&
1578 (p_RRHeader.m_Domain == reverseIPv4Domain))
1579 {
1580 // Reverse domain match
1581@@ -2092,8 +2086,8 @@ uint32_t clsLEAMDNSHost::_replyMaskForHost(const clsLEAMDNSHost::clsRRHeader& p_
1582 #endif
1583 #ifdef MDNS_IPV6_SUPPORT
1584 clsRRDomain reverseIPv6Domain;
1585- if ((_getResponderIPAddress(enuIPProtocolType::V6).isSet()) &&
1586- (_buildDomainForReverseIPv6(_getResponderIPAddress(enuIPProtocolType::V6), reverseIPv6Domain)) &&
1587+ if ((_getResponderIPAddress(pNetIf, enuIPProtocolType::V6).isSet()) &&
1588+ (_buildDomainForReverseIPv6(_getResponderIPAddress(pNetIf, enuIPProtocolType::V6), reverseIPv6Domain)) &&
1589 (p_RRHeader.m_Domain == reverseIPv6Domain))
1590 {
1591 // Reverse domain match
1592diff --git a/libraries/ESP8266mDNS/src/LEAmDNS2Host_Debug.cpp b/libraries/ESP8266mDNS/src/LEAmDNS2Host_Debug.cpp
1593index bc7316be..f0edcd42 100644
1594--- a/libraries/ESP8266mDNS/src/LEAmDNS2Host_Debug.cpp
1595+++ b/libraries/ESP8266mDNS/src/LEAmDNS2Host_Debug.cpp
1596@@ -45,18 +45,11 @@ const char* clsLEAMDNSHost::_DH(const clsLEAMDNSHost::clsService* p_pService /*=
1597 static char acBuffer[16 + 64];
1598
1599 *acBuffer = 0;
1600- if (m_pNetIf)
1601- {
1602- sprintf_P(acBuffer, PSTR("[mDNS %c%c%u]"), m_pNetIf->name[0], m_pNetIf->name[1], m_pNetIf->num);
1603- if (p_pService)
1604- {
1605- strcat_P(acBuffer, PSTR(">"));
1606- strcat(acBuffer, _service2String(p_pService));
1607- }
1608- }
1609- else
1610+ sprintf_P(acBuffer, PSTR("[mDNS]"));
1611+ if (p_pService)
1612 {
1613- strcpy_P(acBuffer, PSTR("[mDNS]"));
1614+ strcat_P(acBuffer, PSTR(">"));
1615+ strcat(acBuffer, _service2String(p_pService));
1616 }
1617 return acBuffer;
1618 }
1619diff --git a/libraries/ESP8266mDNS/src/LEAmDNS2Host_Transfer.cpp b/libraries/ESP8266mDNS/src/LEAmDNS2Host_Transfer.cpp
1620index 0165d296..6e6f74d9 100644
1621--- a/libraries/ESP8266mDNS/src/LEAmDNS2Host_Transfer.cpp
1622+++ b/libraries/ESP8266mDNS/src/LEAmDNS2Host_Transfer.cpp
1623@@ -50,14 +50,16 @@ namespace experimental
1624 Any reply flags in installed services are removed at the end!
1625
1626 */
1627-bool clsLEAMDNSHost::_sendMessage(clsLEAMDNSHost::clsSendParameter& p_rSendParameter)
1628+bool clsLEAMDNSHost::_sendMessage(netif* pNetIf, clsLEAMDNSHost::clsSendParameter& p_rSendParameter)
1629 {
1630 bool bResult = false;
1631-
1632 uint8_t u8AvailableProtocols = 0;
1633+
1634+ DEBUG_EX_INFO(DEBUG_OUTPUT.printf_P(PSTR("%s _sendMessage: if=" NETIFID_STR "\n"), _DH(), NETIFID_VAL(pNetIf)));
1635+
1636 #ifdef MDNS_IPV4_SUPPORT
1637 // Only send out IPv4 messages, if we've got an IPv4 address
1638- if (_getResponderIPAddress(enuIPProtocolType::V4).isSet())
1639+ if (_getResponderIPAddress(pNetIf, enuIPProtocolType::V4).isSet())
1640 {
1641 u8AvailableProtocols |= static_cast<uint8_t>(enuIPProtocolType::V4);
1642 }
1643@@ -68,7 +70,7 @@ bool clsLEAMDNSHost::_sendMessage(clsLEAMDNSHost::clsSendParameter& p_rSendParam
1644 #endif
1645 #ifdef MDNS_IPV6_SUPPORT
1646 // Only send out IPv6 messages, if we've got an IPv6 address
1647- if (_getResponderIPAddress(enuIPProtocolType::V6).isSet())
1648+ if (_getResponderIPAddress(pNetIf, enuIPProtocolType::V6).isSet())
1649 {
1650 u8AvailableProtocols |= static_cast<uint8_t>(enuIPProtocolType::V6);
1651 }
1652@@ -94,7 +96,7 @@ bool clsLEAMDNSHost::_sendMessage(clsLEAMDNSHost::clsSendParameter& p_rSendParam
1653 DEBUG_EX_ERR(if (!ipRemote.isSet()) DEBUG_OUTPUT.printf_P(PSTR("%s _sendMessage: MISSING remote address for unicast response!\n"), _DH()););
1654
1655 bResult = ((ipRemote.isSet()) &&
1656- (_prepareMessage(p_rSendParameter)) &&
1657+ (_prepareMessage(pNetIf, p_rSendParameter)) &&
1658 (m_pUDPContext->send(ipRemote, m_pUDPContext->getRemotePort())) /*&&
1659 (Serial.println("Did send UC"), true)*/);
1660 DEBUG_EX_ERR(if (!bResult) DEBUG_OUTPUT.printf_P(PSTR("%s _sendMessage (V4): FAILED!\n"), _DH()););
1661@@ -113,7 +115,7 @@ bool clsLEAMDNSHost::_sendMessage(clsLEAMDNSHost::clsSendParameter& p_rSendParam
1662 (ipRemote.isV4())) && // OR IPv4
1663 (u8AvailableProtocols & static_cast<uint8_t>(enuIPProtocolType::V4))) // AND IPv4 protocol available
1664 {
1665- bResult = _sendMessage_Multicast(p_rSendParameter, static_cast<uint8_t>(enuIPProtocolType::V4));
1666+ bResult = _sendMessage_Multicast(pNetIf, p_rSendParameter, static_cast<uint8_t>(enuIPProtocolType::V4));
1667 }
1668 #endif
1669 #ifdef MDNS_IPV6_SUPPORT
1670@@ -121,7 +123,7 @@ bool clsLEAMDNSHost::_sendMessage(clsLEAMDNSHost::clsSendParameter& p_rSendParam
1671 (ipRemote.isV6())) && // OR IPv6
1672 (u8AvailableProtocols & static_cast<uint8_t>(enuIPProtocolType::V6))) // AND IPv6 protocol available
1673 {
1674- bResult = _sendMessage_Multicast(p_rSendParameter, static_cast<uint8_t>(enuIPProtocolType::V6));
1675+ bResult = _sendMessage_Multicast(pNetIf, p_rSendParameter, static_cast<uint8_t>(enuIPProtocolType::V6));
1676 }
1677 #endif
1678 }
1679@@ -130,7 +132,7 @@ bool clsLEAMDNSHost::_sendMessage(clsLEAMDNSHost::clsSendParameter& p_rSendParam
1680 {
1681 // Multicast query -> Send by all available protocols
1682 bResult = ((u8AvailableProtocols) &&
1683- (_sendMessage_Multicast(p_rSendParameter, u8AvailableProtocols)));
1684+ (_sendMessage_Multicast(pNetIf, p_rSendParameter, u8AvailableProtocols)));
1685 }
1686
1687 // Finally clear service reply masks
1688@@ -152,21 +154,23 @@ bool clsLEAMDNSHost::_sendMessage(clsLEAMDNSHost::clsSendParameter& p_rSendParam
1689 Fills the UDP output buffer (via _prepareMessage) and sends the buffer
1690 via the selected WiFi protocols
1691 */
1692-bool clsLEAMDNSHost::_sendMessage_Multicast(clsLEAMDNSHost::clsSendParameter& p_rSendParameter,
1693+bool clsLEAMDNSHost::_sendMessage_Multicast(netif* pNetIf, clsLEAMDNSHost::clsSendParameter& p_rSendParameter,
1694 uint8_t p_IPProtocolTypes)
1695 {
1696 bool bIPv4Result = true;
1697 bool bIPv6Result = true;
1698
1699+ DEBUG_EX_INFO(DEBUG_OUTPUT.printf_P(PSTR("%s _sendMessage_Multicast: if=" NETIFID_STR "\n"), _DH(), NETIFID_VAL(pNetIf)));
1700+
1701 #ifdef MDNS_IPV4_SUPPORT
1702 if (p_IPProtocolTypes & static_cast<uint8_t>(enuIPProtocolType::V4))
1703 {
1704 IPAddress ip4MulticastAddress(DNS_MQUERY_IPV4_GROUP_INIT);
1705
1706 DEBUG_EX_INFO(DEBUG_OUTPUT.printf_P(PSTR("%s _sendMessage_Multicast IPv4: Will send to '%s'.\n"), _DH(), ip4MulticastAddress.toString().c_str()););
1707- DEBUG_EX_INFO(if (!_getResponderIPAddress(enuIPProtocolType::V4)) DEBUG_OUTPUT.printf_P(PSTR("%s _sendMessage_Multicast IPv4: NO IPv4 address!.\n"), _DH()););
1708- bIPv4Result = ((_prepareMessage(p_rSendParameter)) &&
1709- (m_pUDPContext->setMulticastInterface(m_pNetIf), true) &&
1710+ DEBUG_EX_INFO(if (!_getResponderIPAddress(pNetIf, enuIPProtocolType::V4)) DEBUG_OUTPUT.printf_P(PSTR("%s _sendMessage_Multicast IPv4: NO IPv4 address!.\n"), _DH()););
1711+ bIPv4Result = ((_prepareMessage(pNetIf, p_rSendParameter)) &&
1712+ (m_pUDPContext->setMulticastInterface(pNetIf), true) &&
1713 (m_pUDPContext->send(ip4MulticastAddress, DNS_MQUERY_PORT)) &&
1714 (m_pUDPContext->setMulticastInterface(0), true) /*&&
1715 (Serial.println("Did send MC V4"), true)*/);
1716@@ -186,17 +190,17 @@ bool clsLEAMDNSHost::_sendMessage_Multicast(clsLEAMDNSHost::clsSendParameter& p_
1717 IPAddress ip6MulticastAddress(DNS_MQUERY_IPV6_GROUP_INIT);
1718
1719 DEBUG_EX_INFO(DEBUG_OUTPUT.printf_P(PSTR("%s _sendMessage_Multicast IPv6: Will send to '%s'.\n"), _DH(), ip6MulticastAddress.toString().c_str()););
1720- DEBUG_EX_INFO(if (!_getResponderIPAddress(enuIPProtocolType::V6)) DEBUG_OUTPUT.printf_P(PSTR("%s _sendMessage_Multicast IPv6: NO IPv6 address!.\n"), _DH()););
1721+ DEBUG_EX_INFO(if (!_getResponderIPAddress(pNetIf, enuIPProtocolType::V6)) DEBUG_OUTPUT.printf_P(PSTR("%s _sendMessage_Multicast IPv6: NO IPv6 address!.\n"), _DH()););
1722 DEBUG_EX_ERR(
1723 bool bPrepareMessage = false;
1724 bool bUDPContextSend = false;
1725 );
1726- bIPv6Result = ((DEBUG_EX_ERR(bPrepareMessage =)_prepareMessage(p_rSendParameter)) &&
1727- (m_pUDPContext->setMulticastInterface(m_pNetIf), true) &&
1728+ bIPv6Result = ((DEBUG_EX_ERR(bPrepareMessage =)_prepareMessage(pNetIf, p_rSendParameter)) &&
1729+ (m_pUDPContext->setMulticastInterface(pNetIf), true) &&
1730 (DEBUG_EX_ERR(bUDPContextSend =)m_pUDPContext->send(ip6MulticastAddress, DNS_MQUERY_PORT)) &&
1731 (m_pUDPContext->setMulticastInterface(0), true) /*&&
1732 (Serial.println("Did send MC V6"), true)*/);
1733- DEBUG_EX_ERR(if (!bIPv6Result) DEBUG_OUTPUT.printf_P(PSTR("%s _sendMessage_Multicast (IPv6): FAILED! (%s, %s, %s)\n"), _DH(), (_getResponderIPAddress(enuIPProtocolType::V6).isSet() ? "1" : "0"), (bPrepareMessage ? "1" : "0"), (bUDPContextSend ? "1" : "0")););
1734+ DEBUG_EX_ERR(if (!bIPv6Result) DEBUG_OUTPUT.printf_P(PSTR("%s _sendMessage_Multicast (IPv6): FAILED! (%s, %s, %s)\n"), _DH(), (_getResponderIPAddress(pNetIf, enuIPProtocolType::V6).isSet() ? "1" : "0"), (bPrepareMessage ? "1" : "0"), (bUDPContextSend ? "1" : "0")););
1735
1736 if ((clsConsts::u32SendCooldown) &&
1737 (can_yield()))
1738@@ -220,7 +224,7 @@ bool clsLEAMDNSHost::_sendMessage_Multicast(clsLEAMDNSHost::clsSendParameter& p_
1739 output buffer.
1740
1741 */
1742-bool clsLEAMDNSHost::_prepareMessage(clsLEAMDNSHost::clsSendParameter& p_rSendParameter)
1743+bool clsLEAMDNSHost::_prepareMessage(netif* pNetIf, clsLEAMDNSHost::clsSendParameter& p_rSendParameter)
1744 {
1745 //DEBUG_EX_INFO(DEBUG_OUTPUT.printf_P(PSTR("%s _prepareMDNSMessage\n")););
1746 bool bResult = true;
1747@@ -288,25 +292,25 @@ bool clsLEAMDNSHost::_prepareMessage(clsLEAMDNSHost::clsSendParameter& p_rSendPa
1748 // A
1749 if ((bResult) &&
1750 (p_rSendParameter.m_u32HostReplyMask & static_cast<uint32_t>(enuContentFlag::A)) &&
1751- (_getResponderIPAddress(enuIPProtocolType::V4).isSet()))
1752+ (_getResponderIPAddress(pNetIf, enuIPProtocolType::V4).isSet()))
1753 {
1754
1755 u32NSECContent |= static_cast<uint32_t>(enuContentFlag::A);
1756 ((static_cast<typeSequence>(enuSequence::Count) == sequence)
1757 ? ++ru16Answers
1758- : (bResult = _writeMDNSAnswer_A(_getResponderIPAddress(enuIPProtocolType::V4), p_rSendParameter)));
1759+ : (bResult = _writeMDNSAnswer_A(_getResponderIPAddress(pNetIf, enuIPProtocolType::V4), p_rSendParameter)));
1760 DEBUG_EX_ERR(if (!bResult) DEBUG_OUTPUT.printf_P(PSTR("%s _prepareMDNSMessage: _writeMDNSAnswer_A(A) FAILED!\n"), _DH()););
1761 }
1762 // PTR_IPv4
1763 if ((bResult) &&
1764 (p_rSendParameter.m_u32HostReplyMask & static_cast<uint32_t>(enuContentFlag::PTR_IPv4)) &&
1765- (_getResponderIPAddress(enuIPProtocolType::V4).isSet()))
1766+ (_getResponderIPAddress(pNetIf, enuIPProtocolType::V4).isSet()))
1767 {
1768
1769 u32NSECContent |= static_cast<uint32_t>(enuContentFlag::PTR_IPv4);
1770 ((static_cast<typeSequence>(enuSequence::Count) == sequence)
1771 ? ++ru16Answers
1772- : (bResult = _writeMDNSAnswer_PTR_IPv4(_getResponderIPAddress(enuIPProtocolType::V4), p_rSendParameter)));
1773+ : (bResult = _writeMDNSAnswer_PTR_IPv4(_getResponderIPAddress(pNetIf, enuIPProtocolType::V4), p_rSendParameter)));
1774 DEBUG_EX_ERR(if (!bResult) DEBUG_OUTPUT.printf_P(PSTR("%s _prepareMDNSMessage: _writeMDNSAnswer_PTR_IPv4 FAILED!\n"), _DH()););
1775 }
1776 #endif
1777@@ -314,25 +318,25 @@ bool clsLEAMDNSHost::_prepareMessage(clsLEAMDNSHost::clsSendParameter& p_rSendPa
1778 // AAAA
1779 if ((bResult) &&
1780 (p_rSendParameter.m_u32HostReplyMask & static_cast<uint32_t>(enuContentFlag::AAAA)) &&
1781- (_getResponderIPAddress(enuIPProtocolType::V6).isSet()))
1782+ (_getResponderIPAddress(pNetIf, (enuIPProtocolType::V6)).isSet()))
1783 {
1784
1785 u32NSECContent |= static_cast<uint32_t>(enuContentFlag::AAAA);
1786 ((static_cast<typeSequence>(enuSequence::Count) == sequence)
1787 ? ++ru16Answers
1788- : (bResult = _writeMDNSAnswer_AAAA(_getResponderIPAddress(enuIPProtocolType::V6), p_rSendParameter)));
1789+ : (bResult = _writeMDNSAnswer_AAAA(_getResponderIPAddress(pNetIf, (enuIPProtocolType::V6)), p_rSendParameter)));
1790 DEBUG_EX_ERR(if (!bResult) DEBUG_OUTPUT.printf_P(PSTR("%s _prepareMDNSMessage: _writeMDNSAnswer_AAAA(A) FAILED!\n"), _DH()););
1791 }
1792 // PTR_IPv6
1793 if ((bResult) &&
1794 (p_rSendParameter.m_u32HostReplyMask & static_cast<uint32_t>(enuContentFlag::PTR_IPv6)) &&
1795- (_getResponderIPAddress(enuIPProtocolType::V6).isSet()))
1796+ (_getResponderIPAddress(pNetIf, (enuIPProtocolType::V6)).isSet()))
1797 {
1798
1799 u32NSECContent |= static_cast<uint32_t>(enuContentFlag::PTR_IPv6);
1800 ((static_cast<typeSequence>(enuSequence::Count) == sequence)
1801 ? ++ru16Answers
1802- : (bResult = _writeMDNSAnswer_PTR_IPv6(_getResponderIPAddress(enuIPProtocolType::V6), p_rSendParameter)));
1803+ : (bResult = _writeMDNSAnswer_PTR_IPv6(_getResponderIPAddress(pNetIf, (enuIPProtocolType::V6)), p_rSendParameter)));
1804 DEBUG_EX_ERR(if (!bResult) DEBUG_OUTPUT.printf_P(PSTR("%s _prepareMDNSMessage: _writeMDNSAnswer_PTR_IPv6 FAILED!\n"), _DH()););
1805 }
1806 #endif
1807@@ -446,13 +450,13 @@ bool clsLEAMDNSHost::_prepareMessage(clsLEAMDNSHost::clsSendParameter& p_rSendPa
1808 // Answer A needed?
1809 if ((bResult) &&
1810 (bNeedsAdditionalAnswerA) &&
1811- (_getResponderIPAddress(enuIPProtocolType::V4).isSet()))
1812+ (_getResponderIPAddress(pNetIf, (enuIPProtocolType::V4)).isSet()))
1813 {
1814 // Additional A
1815 u32NSECContent |= static_cast<uint32_t>(enuContentFlag::A);
1816 ((static_cast<typeSequence>(enuSequence::Count) == sequence)
1817 ? ++ru16AdditionalAnswers
1818- : (bResult = _writeMDNSAnswer_A(_getResponderIPAddress(enuIPProtocolType::V4), p_rSendParameter)));
1819+ : (bResult = _writeMDNSAnswer_A(_getResponderIPAddress(pNetIf, (enuIPProtocolType::V4)), p_rSendParameter)));
1820
1821 DEBUG_EX_ERR(if (!bResult) DEBUG_OUTPUT.printf_P(PSTR("%s _prepareMDNSMessage: _writeMDNSAnswer_A(B) FAILED!\n"), _DH()););
1822 }
1823@@ -461,13 +465,13 @@ bool clsLEAMDNSHost::_prepareMessage(clsLEAMDNSHost::clsSendParameter& p_rSendPa
1824 // Answer AAAA needed?
1825 if ((bResult) &&
1826 (bNeedsAdditionalAnswerAAAA) &&
1827- (_getResponderIPAddress(enuIPProtocolType::V6).isSet()))
1828+ (_getResponderIPAddress(pNetIf, (enuIPProtocolType::V6)).isSet()))
1829 {
1830 // Additional AAAA
1831 u32NSECContent |= static_cast<uint32_t>(enuContentFlag::AAAA);
1832 ((static_cast<typeSequence>(enuSequence::Count) == sequence)
1833 ? ++ru16AdditionalAnswers
1834- : (bResult = _writeMDNSAnswer_AAAA(_getResponderIPAddress(enuIPProtocolType::V6), p_rSendParameter)));
1835+ : (bResult = _writeMDNSAnswer_AAAA(_getResponderIPAddress(pNetIf, (enuIPProtocolType::V6)), p_rSendParameter)));
1836
1837 DEBUG_EX_ERR(if (!bResult) DEBUG_OUTPUT.printf_P(PSTR("%s _prepareMDNSMessage: _writeMDNSAnswer_AAAA(B) FAILED!\n"), _DH()););
1838 }
1839@@ -503,14 +507,14 @@ bool clsLEAMDNSHost::_prepareMessage(clsLEAMDNSHost::clsSendParameter& p_rSendPa
1840 #ifdef MDNS_IPV4_SUPPORT
1841 // Write separate answer for host PTR IPv4
1842 && ((!u32NSECContent_PTR_IPv4) ||
1843- ((!_getResponderIPAddress(enuIPProtocolType::V4).isSet()) ||
1844- (_writeMDNSAnswer_NSEC_PTR_IPv4(_getResponderIPAddress(enuIPProtocolType::V4), p_rSendParameter))))
1845+ ((!_getResponderIPAddress(pNetIf, (enuIPProtocolType::V4)).isSet()) ||
1846+ (_writeMDNSAnswer_NSEC_PTR_IPv4(_getResponderIPAddress(pNetIf, (enuIPProtocolType::V4)), p_rSendParameter))))
1847 #endif
1848 #ifdef MDNS_IPV6_SUPPORT
1849 // Write separate answer for host PTR IPv6
1850 && ((!u32NSECContent_PTR_IPv6) ||
1851- ((!_getResponderIPAddress(enuIPProtocolType::V6).isSet()) ||
1852- (_writeMDNSAnswer_NSEC_PTR_IPv6(_getResponderIPAddress(enuIPProtocolType::V6), p_rSendParameter))))
1853+ ((!_getResponderIPAddress(pNetIf, (enuIPProtocolType::V6)).isSet()) ||
1854+ (_writeMDNSAnswer_NSEC_PTR_IPv6(_getResponderIPAddress(pNetIf, (enuIPProtocolType::V6)), p_rSendParameter))))
1855 #endif
1856 )));
1857
1858@@ -556,7 +560,8 @@ bool clsLEAMDNSHost::_addQueryRecord(clsLEAMDNSHost::clsSendParameter& p_rSendPa
1859 Creates and sends a query for the given domain and query type.
1860
1861 */
1862-bool clsLEAMDNSHost::_sendQuery(const clsLEAMDNSHost::clsQuery& p_Query,
1863+bool clsLEAMDNSHost::_sendQuery(netif* pNetIf,
1864+ const clsLEAMDNSHost::clsQuery& p_Query,
1865 clsLEAMDNSHost::clsQuery::clsAnswer::list* p_pKnownAnswers /*= 0*/)
1866 {
1867 bool bResult = false;
1868@@ -584,9 +589,8 @@ bool clsLEAMDNSHost::_sendQuery(const clsLEAMDNSHost::clsQuery& p_Query,
1869
1870 // TODO: Add known answers to query
1871 (void)p_pKnownAnswers;
1872-
1873 bResult = ((bResult) &&
1874- (_sendMessage(sendParameter)));
1875+ (_sendMessage(pNetIf, sendParameter)));
1876 DEBUG_EX_ERR(if (!bResult) DEBUG_OUTPUT.printf_P(PSTR("%s _sendQuery: FAILED!\n"), _DH()););
1877 return bResult;
1878 }
1879@@ -597,7 +601,8 @@ bool clsLEAMDNSHost::_sendQuery(const clsLEAMDNSHost::clsQuery& p_Query,
1880 Creates and sends a query for the given domain and record type.
1881
1882 */
1883-bool clsLEAMDNSHost::_sendQuery(const clsLEAMDNSHost::clsRRDomain& p_QueryDomain,
1884+bool clsLEAMDNSHost::_sendQuery(netif* pNetIf,
1885+ const clsLEAMDNSHost::clsRRDomain& p_QueryDomain,
1886 uint16_t p_u16RecordType,
1887 clsLEAMDNSHost::clsQuery::clsAnswer::list* p_pKnownAnswers /*= 0*/)
1888 {
1889@@ -605,7 +610,7 @@ bool clsLEAMDNSHost::_sendQuery(const clsLEAMDNSHost::clsRRDomain& p_QueryDomain
1890
1891 clsSendParameter sendParameter;
1892 bResult = ((_addQueryRecord(sendParameter, p_QueryDomain, p_u16RecordType)) &&
1893- (_sendMessage(sendParameter)));
1894+ (_sendMessage(pNetIf, sendParameter)));
1895
1896 // TODO: Add known answer records
1897 (void) p_pKnownAnswers;
1898@@ -617,16 +622,16 @@ bool clsLEAMDNSHost::_sendQuery(const clsLEAMDNSHost::clsRRDomain& p_QueryDomain
1899 /*
1900 MDNSResponder::_getResponderIPAddress
1901 */
1902-IPAddress clsLEAMDNSHost::_getResponderIPAddress(enuIPProtocolType p_IPProtocolType) const
1903+IPAddress clsLEAMDNSHost::_getResponderIPAddress(netif* pNetIf, enuIPProtocolType p_IPProtocolType) const
1904 {
1905 IPAddress ipResponder;
1906 #ifdef MDNS_IPV4_SUPPORT
1907 if (enuIPProtocolType::V4 == p_IPProtocolType)
1908 {
1909 #if LWIP_VERSION_MAJOR == 1
1910- ipResponder = ip_2_ip4(m_pNetIf->ip_addr);
1911+ ipResponder = ip_2_ip4(pNetIf->ip_addr);
1912 #else
1913- ipResponder = netif_ip_addr4(m_pNetIf);
1914+ ipResponder = netif_ip_addr4(pNetIf);
1915 #endif
1916 }
1917 #endif
1918@@ -638,13 +643,13 @@ IPAddress clsLEAMDNSHost::_getResponderIPAddress(enuIPProtocolType p_IPProtocolT
1919 {
1920 for (int idx = 0; idx < LWIP_IPV6_NUM_ADDRESSES; ++idx)
1921 {
1922- //DEBUG_EX_INFO(if ip6_addr_isvalid(netif_ip6_addr_state(&m_rNetIf, idx)) DEBUG_OUTPUT.printf_P(PSTR("%s _getResponderIPAddress: Checking IPv6 address %s (LL: %s)\n"), _DH(), IPAddress(netif_ip_addr6(m_pNetIf, idx)).toString().c_str(), (bCheckLinkLocal ? "YES" : "NO")););
1923- if ((ip6_addr_isvalid(netif_ip6_addr_state(m_pNetIf, idx))) &&
1924+ //DEBUG_EX_INFO(if ip6_addr_isvalid(netif_ip6_addr_state(&pNetIf, idx)) DEBUG_OUTPUT.printf_P(PSTR("%s _getResponderIPAddress: Checking IPv6 address %s (LL: %s)\n"), _DH(), IPAddress(netif_ip_addr6(pNetIf, idx)).toString().c_str(), (bCheckLinkLocal ? "YES" : "NO")););
1925+ if ((ip6_addr_isvalid(netif_ip6_addr_state(pNetIf, idx))) &&
1926 (((!bCheckLinkLocal) ||
1927- (ip6_addr_islinklocal(netif_ip6_addr(m_pNetIf, idx))))))
1928+ (ip6_addr_islinklocal(netif_ip6_addr(pNetIf, idx))))))
1929 {
1930- //DEBUG_EX_INFO(DEBUG_OUTPUT.printf_P(PSTR("%s _getResponderIPAddress: Selected IPv6 address %s (LL: %s)\n"), _DH(), IPAddress(netif_ip_addr6(m_pNetIf, idx)).toString().c_str(), (bCheckLinkLocal ? "YES" : "NO")););
1931- ipResponder = netif_ip_addr6(m_pNetIf, idx);
1932+ //DEBUG_EX_INFO(DEBUG_OUTPUT.printf_P(PSTR("%s _getResponderIPAddress: Selected IPv6 address %s (LL: %s)\n"), _DH(), IPAddress(netif_ip_addr6(pNetIf, idx)).toString().c_str(), (bCheckLinkLocal ? "YES" : "NO")););
1933+ ipResponder = netif_ip_addr6(pNetIf, idx);
1934 break;
1935 }
1936 }
1937diff --git a/libraries/ESP8266mDNS/src/LEAmDNS2_Backbone.cpp b/libraries/ESP8266mDNS/src/LEAmDNS2_Backbone.cpp
1938index 4eb45918..d4ab972a 100644
1939--- a/libraries/ESP8266mDNS/src/LEAmDNS2_Backbone.cpp
1940+++ b/libraries/ESP8266mDNS/src/LEAmDNS2_Backbone.cpp
1941@@ -41,7 +41,8 @@ namespace experimental
1942 clsLEAMDNSHost::clsBackbone::clsBackbone(void)
1943 : m_pUDPContext(0),
1944 m_bDelayUDPProcessing(false),
1945- m_u32DelayedDatagrams(0)
1946+ m_u32DelayedDatagrams(0),
1947+ m_uniqueHost(0)
1948 {
1949 }
1950
1951@@ -71,10 +72,9 @@ UdpContext* clsLEAMDNSHost::clsBackbone::addHost(clsLEAMDNSHost* p_pHost)
1952 {
1953 UdpContext* pUDPContext = 0;
1954
1955- if ((m_pUDPContext) &&
1956- (p_pHost))
1957+ if ((m_pUDPContext) && (p_pHost) && (m_uniqueHost == nullptr))
1958 {
1959- m_HostList.push_back(p_pHost);
1960+ m_uniqueHost = p_pHost;
1961 pUDPContext = m_pUDPContext;
1962 }
1963 DEBUG_EX_INFO(DEBUG_OUTPUT.printf_P(PSTR("%s addHost: %s to add host!\n"), _DH(), (pUDPContext ? "Succeeded" : "FAILED")););
1964@@ -89,11 +89,9 @@ bool clsLEAMDNSHost::clsBackbone::removeHost(clsLEAMDNSHost* p_pHost)
1965 {
1966 bool bResult = false;
1967
1968- if ((p_pHost) &&
1969- (m_HostList.end() != std::find(m_HostList.begin(), m_HostList.end(), p_pHost)))
1970+ if ((p_pHost) && (m_uniqueHost == p_pHost))
1971 {
1972- // Remove host object
1973- m_HostList.remove(p_pHost);
1974+ m_uniqueHost = nullptr;
1975 bResult = true;
1976 }
1977 DEBUG_EX_INFO(DEBUG_OUTPUT.printf_P(PSTR("%s removeHost: %s to remove host!\n"), _DH(), (bResult ? "Succeeded" : "FAILED")););
1978@@ -107,7 +105,7 @@ bool clsLEAMDNSHost::clsBackbone::removeHost(clsLEAMDNSHost* p_pHost)
1979 */
1980 size_t clsLEAMDNSHost::clsBackbone::hostCount(void) const
1981 {
1982- return m_HostList.size();
1983+ return m_uniqueHost == nullptr ? 0 : 1;
1984 }
1985
1986 /*
1987@@ -218,32 +216,23 @@ bool clsLEAMDNSHost::clsBackbone::_processUDPInput(void)
1988 while ((m_pUDPContext) &&
1989 (m_pUDPContext->next()))
1990 {
1991- netif* pNetIf = m_pUDPContext->getInputNetif();//ip_current_input_netif(); // Probably changed inbetween!!!!
1992- clsLEAMDNSHost* pHost = 0;
1993- if ((pNetIf) &&
1994- ((pHost = _findHost(pNetIf))))
1995- {
1996- DEBUG_EX_INFO(
1997- if (u32LoopCounter++)
1998- {
1999- DEBUG_OUTPUT.printf_P(PSTR("%s _processUDPInput: Multi-Loop (%u)!\n"), _DH(), u32LoopCounter);
2000- if ((remoteIPAddr.isSet()) &&
2001- (remoteIPAddr != m_pUDPContext->getRemoteAddress()))
2002- {
2003- DEBUG_OUTPUT.printf_P(PSTR("%s _processUDPInput: Changed IP address %s->%s!\n"), _DH(), remoteIPAddr.toString().c_str(), m_pUDPContext->getRemoteAddress().toString().c_str());
2004- }
2005- }
2006- remoteIPAddr = m_pUDPContext->getRemoteAddress();
2007- );
2008- bResult = pHost->_processUDPInput();
2009- DEBUG_EX_INFO2(if (!bResult) DEBUG_OUTPUT.printf_P(PSTR("%s _processUDPInput: FAILED to process UDP input!\n"), _DH()););
2010-
2011- DEBUG_EX_ERR(if ((-1) != m_pUDPContext->peek()) DEBUG_OUTPUT.printf_P(PSTR("%s _processUDPInput: !!!! CONTENT LEFT IN UDP BUFFER !!!!\n"), _DH()););
2012- }
2013- else
2014- {
2015- DEBUG_EX_ERR(DEBUG_OUTPUT.printf_P(PSTR("%s _processUDPInput: Received UDP datagramm for unused netif at index: %u\n"), _DH(), (pNetIf ? netif_get_index(pNetIf) : (-1))););
2016- }
2017+ clsLEAMDNSHost* pHost = _findHost();
2018+ DEBUG_EX_INFO_IF(u32LoopCounter++,
2019+ DEBUG_OUTPUT.printf_P(PSTR("%s _processUDPInput: Multi-Loop (%u)!\n"), _DH(), u32LoopCounter);
2020+ DEBUG_EX_INFO_IF((remoteIPAddr.isSet()) && (remoteIPAddr != m_pUDPContext->getRemoteAddress()),
2021+ DEBUG_OUTPUT.printf_P(PSTR("%s _processUDPInput: Changed IP address %s->%s!\n"),
2022+ _DH(),
2023+ remoteIPAddr.toString().c_str(),
2024+ m_pUDPContext->getRemoteAddress().toString().c_str())));
2025+ DEBUG_EX_INFO(remoteIPAddr = m_pUDPContext->getRemoteAddress());
2026+
2027+ bResult = pHost->_processUDPInput();
2028+
2029+ DEBUG_EX_INFO2_IF(!bResult,
2030+ DEBUG_OUTPUT.printf_P(PSTR("%s _processUDPInput: FAILED to process UDP input!\n"), _DH()));
2031+ DEBUG_EX_ERR_IF((-1) != m_pUDPContext->peek(),
2032+ DEBUG_OUTPUT.printf_P(PSTR("%s _processUDPInput: !!!! CONTENT LEFT IN UDP BUFFER !!!!\n"),
2033+ _DH()));
2034 m_pUDPContext->flush();
2035 }
2036 }
2037@@ -255,34 +244,6 @@ bool clsLEAMDNSHost::clsBackbone::_processUDPInput(void)
2038 return bResult;
2039 }
2040
2041-/*
2042- clsLEAmDNS2_Host::clsBackbone::_findHost
2043-*/
2044-const clsLEAMDNSHost* clsLEAMDNSHost::clsBackbone::_findHost(netif* p_pNetIf) const
2045-{
2046- //DEBUG_EX_INFO(DEBUG_OUTPUT.printf_P(PSTR("%s _findHost\n"), _DH()););
2047- const clsLEAMDNSHost* pResult = 0;
2048- for (const clsLEAMDNSHost* pHost : m_HostList)
2049- {
2050- if ((p_pNetIf) &&
2051- (pHost->m_pNetIf == p_pNetIf))
2052- {
2053- pResult = pHost;
2054- break;
2055- }
2056- }
2057- return pResult;
2058-}
2059-
2060-/*
2061- MDNSResponder::_findHost
2062-*/
2063-clsLEAMDNSHost* clsLEAMDNSHost::clsBackbone::_findHost(netif* p_pNetIf)
2064-{
2065- return (clsLEAMDNSHost*)(((const clsLEAMDNSHost::clsBackbone*)this)->_findHost(p_pNetIf));
2066-}
2067-
2068-
2069 /*
2070 MISC
2071 */
2072diff --git a/libraries/ESP8266mDNS/src/LEAmDNS2_Legacy.cpp b/libraries/ESP8266mDNS/src/LEAmDNS2_Legacy.cpp
2073index 151555d1..910a8d59 100644
2074--- a/libraries/ESP8266mDNS/src/LEAmDNS2_Legacy.cpp
2075+++ b/libraries/ESP8266mDNS/src/LEAmDNS2_Legacy.cpp
2076@@ -56,14 +56,11 @@ clsLEAMDNSHost_Legacy::~clsLEAMDNSHost_Legacy(void)
2077 */
2078 bool clsLEAMDNSHost_Legacy::begin(const char* p_pcHostname)
2079 {
2080- bool bResult = (((!(WIFI_STA & (WiFiMode_t)wifi_get_opmode()))
2081- || (addHostForNetIf(p_pcHostname, netif_get_by_index(WIFI_STA))))
2082- && ((!(WIFI_AP & (WiFiMode_t)wifi_get_opmode()))
2083- || (addHostForNetIf(p_pcHostname, netif_get_by_index(WIFI_AP)))));
2084- return ((bResult)
2085- && (0 != m_HostInformations.size()));
2086+ return addHostForNetIf(p_pcHostname)
2087+ && (0 != m_HostInformations.size());
2088 }
2089
2090+
2091 /*
2092 clsLEAMDNSHost_Legacy::begin (String)
2093
2094@@ -130,19 +127,26 @@ bool clsLEAMDNSHost_Legacy::end(void)
2095 NEW!
2096
2097 */
2098-bool clsLEAMDNSHost_Legacy::addHostForNetIf(const char* p_pcHostname,
2099- netif* p_pNetIf)
2100+bool clsLEAMDNSHost_Legacy::addHostForNetIf(const char* p_pcHostname)
2101 {
2102- clsLEAMDNSHost* pHost = 0;
2103+ bool bResult = true;
2104
2105- if (((pHost = new esp8266::experimental::clsLEAMDNSHost))
2106- && (!((pHost->begin(p_pcHostname, p_pNetIf /*, default callback*/))
2107- && (m_HostInformations.push_back(stcHostInformation(pHost)), true))))
2108+ if (m_HostInformations.size() > 0)
2109 {
2110- delete pHost;
2111- pHost = 0;
2112+ //XXXFIXME only one pHost instance, many things can be simplified
2113+ bResult = false;
2114 }
2115- return (0 != pHost);
2116+ else
2117+ {
2118+ clsLEAMDNSHost* pHost = new esp8266::experimental::clsLEAMDNSHost;
2119+ if (pHost
2120+ && (!((pHost->begin(p_pcHostname /*, default callback*/))
2121+ && (m_HostInformations.push_back(stcHostInformation(pHost)), true))))
2122+ {
2123+ bResult = false;
2124+ }
2125+ }
2126+ return bResult;
2127 }
2128
2129 /*
2130@@ -795,24 +799,41 @@ clsLEAMDNSHost_Legacy::hMDNSServiceQuery clsLEAMDNSHost_Legacy::installServiceQu
2131
2132 for (stcHostInformation& hostInformation : m_HostInformations)
2133 {
2134- clsLEAMDNSHost::clsQuery* pQuery = hostInformation.m_pHost->installServiceQuery(p_pcService, p_pcProtocol, [this, p_fnCallback](const clsLEAMDNSHost::clsQuery& /*p_Query*/,
2135- const clsLEAMDNSHost::clsQuery::clsAnswerAccessor & p_AnswerAccessor,
2136- clsLEAMDNSHost::clsQuery::clsAnswer::typeQueryAnswerType p_QueryAnswerTypeFlags, // flags for the updated answer item
2137- bool p_bSetContent)->void
2138+ std::list<clsLEAMDNSHost::clsQuery*> queries;
2139+
2140+ /*clsLEAMDNSHost::clsQuery* pQuery =*/
2141+ hostInformation.m_pHost->installServiceQuery(p_pcService, p_pcProtocol, [this, p_fnCallback](const clsLEAMDNSHost::clsQuery& /*p_Query*/,
2142+ const clsLEAMDNSHost::clsQuery::clsAnswerAccessor & p_AnswerAccessor,
2143+ clsLEAMDNSHost::clsQuery::clsAnswer::typeQueryAnswerType p_QueryAnswerTypeFlags, // flags for the updated answer item
2144+ bool p_bSetContent)->void
2145 {
2146 if (p_fnCallback) // void(const stcMDNSServiceInfo& p_MDNSServiceInfo, MDNSResponder::AnswerType p_AnswerType, bool p_bSetContent)
2147 {
2148 p_fnCallback(stcMDNSServiceInfo(p_AnswerAccessor), _answerFlagsToAnswerType(p_QueryAnswerTypeFlags), p_bSetContent);
2149 }
2150- });
2151- if (pQuery)
2152+ }, &queries);
2153+
2154+ if (queries.size())
2155 {
2156 if (!hResult)
2157 {
2158+ // - hMDNSServiceQuery handle is 'const void*'
2159+ // used to retrieve pQuery when updating or removing.
2160+
2161+ // - unexplained - before multi interface change:
2162+ // there is a loop, only the first is returned, why ?
2163+
2164 // Store first query as result and key
2165- hResult = (hMDNSServiceQuery)pQuery;
2166+ //hResult = (hMDNSServiceQuery)pQuery; <- before netif, only the first query is returned
2167+
2168+ // - netif transformation: even more returned values (a list per loop),
2169+ // still, only the first handle is returned.
2170+ hResult = (hMDNSServiceQuery) * queries.begin(); // take the first
2171 }
2172- hostInformation.m_HandleToPtr[hResult] = pQuery;
2173+ // this was overwritten ?
2174+ //hostInformation.m_HandleToPtr[hResult] = pQuery;
2175+ // ... overwritten with only the first query
2176+ hostInformation.m_HandleToPtr[hResult] = *queries.begin();
2177 }
2178 }
2179 return hResult;
2180diff --git a/libraries/ESP8266mDNS/src/LEAmDNS2_Legacy.h b/libraries/ESP8266mDNS/src/LEAmDNS2_Legacy.h
2181index 9ab1f14d..c574cfee 100644
2182--- a/libraries/ESP8266mDNS/src/LEAmDNS2_Legacy.h
2183+++ b/libraries/ESP8266mDNS/src/LEAmDNS2_Legacy.h
2184@@ -154,8 +154,7 @@ public:
2185 // NEW! The ESP-default network interfaces are 'auto-added' via 'begin' when active
2186 // Additional netifs may be added, but if done so after calling 'update' for the
2187 // first time, 'notifyAPChange' should be called to restart the probing/announcing process
2188- bool addHostForNetIf(const char* p_pcHostname,
2189- netif* p_pNetIf);
2190+ bool addHostForNetIf(const char* p_pcHostname);
2191
2192 // Change hostname (probing is restarted)
2193 // Caution! The final hostname (after probing) may be different for every host