File tree 4 files changed +11
-6
lines changed
libraries/ESP8266mDNS/src
4 files changed +11
-6
lines changed Original file line number Diff line number Diff line change @@ -128,6 +128,7 @@ struct netifWrapper
128
128
const char * ifmac () const { return (const char *)_netif->hwaddr ; }
129
129
int ifnumber () const { return _netif->num ; }
130
130
bool ifUp () const { return !!(_netif->flags & NETIF_FLAG_UP); }
131
+ const netif* interface () const { return _netif; }
131
132
132
133
const ip_addr_t * ipFromNetifNum () const
133
134
{
Original file line number Diff line number Diff line change @@ -59,11 +59,11 @@ MDNSResponder::MDNSResponder(void)
59
59
m_pServiceQueries(0 ),
60
60
m_fnServiceTxtCallback(0 ),
61
61
#ifdef ENABLE_ESP_MDNS_RESPONDER_PASSIV_MODE
62
- m_bPassivModeEnabled (true ) {
62
+ m_bPassivModeEnabled (true ),
63
63
#else
64
- m_bPassivModeEnabled (false ) {
64
+ m_bPassivModeEnabled (false ),
65
65
#endif
66
-
66
+ m_netif ( nullptr ) {
67
67
}
68
68
69
69
/*
Original file line number Diff line number Diff line change @@ -1149,6 +1149,7 @@ class MDNSResponder {
1149
1149
bool m_bPassivModeEnabled;
1150
1150
stcProbeInformation m_HostProbeInformation;
1151
1151
IPAddress m_IPAddress;
1152
+ const netif* m_netif; // network interface associated to m_IPAddress
1152
1153
1153
1154
/* * CONTROL **/
1154
1155
/* MAINTENANCE */
Original file line number Diff line number Diff line change 22
22
*
23
23
*/
24
24
25
- #include < arch/cc.h>
26
25
#include < sys/time.h>
27
26
#include < IPAddress.h>
28
27
#include < AddrList.h>
@@ -79,8 +78,10 @@ bool MDNSResponder::_process(bool p_bUserContext) {
79
78
}
80
79
}
81
80
else {
82
- bResult = _updateProbeStatus () && // Probing
83
- _checkServiceQueryCache (); // Service query cache check
81
+ bResult = (m_netif != nullptr ) &&
82
+ (m_netif->flags & NETIF_FLAG_UP) && // network interface is up and running
83
+ _updateProbeStatus () && // Probing
84
+ _checkServiceQueryCache (); // Service query cache check
84
85
}
85
86
return bResult;
86
87
}
@@ -122,10 +123,12 @@ bool MDNSResponder::_restart(void) {
122
123
123
124
// check existence of this IP address in the interface list
124
125
bool found = false ;
126
+ m_netif = nullptr ;
125
127
for (auto a: addrList)
126
128
if (m_IPAddress == a.addr ()) {
127
129
if (a.ifUp ()) {
128
130
found = true ;
131
+ m_netif = a.interface ();
129
132
break ;
130
133
}
131
134
DEBUG_EX_INFO (DEBUG_OUTPUT.printf_P (PSTR (" [MDNSResponder] found interface for IP '%s' but it is not UP\n " ), m_IPAddress.toString ().c_str ()););
You can’t perform that action at this time.
0 commit comments