Skip to content
Merged
Show file tree
Hide file tree
Changes from 1 commit
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Prev Previous commit
Next Next commit
mDNS: store network interface, checking it is up
  • Loading branch information
d-a-v committed Jul 24, 2019
commit 3c6b4814520d118acf55d59bde75cbdd4701ce2d
1 change: 1 addition & 0 deletions cores/esp8266/AddrList.h
Original file line number Diff line number Diff line change
Expand Up @@ -128,6 +128,7 @@ struct netifWrapper
const char* ifmac () const { return (const char*)_netif->hwaddr; }
int ifnumber () const { return _netif->num; }
bool ifUp () const { return !!(_netif->flags & NETIF_FLAG_UP); }
const netif* interface () const { return _netif; }

const ip_addr_t* ipFromNetifNum () const
{
Expand Down
6 changes: 3 additions & 3 deletions libraries/ESP8266mDNS/src/LEAmDNS.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -59,11 +59,11 @@ MDNSResponder::MDNSResponder(void)
m_pServiceQueries(0),
m_fnServiceTxtCallback(0),
#ifdef ENABLE_ESP_MDNS_RESPONDER_PASSIV_MODE
m_bPassivModeEnabled(true) {
m_bPassivModeEnabled(true),
#else
m_bPassivModeEnabled(false) {
m_bPassivModeEnabled(false),
#endif

m_netif(nullptr) {
}

/*
Expand Down
1 change: 1 addition & 0 deletions libraries/ESP8266mDNS/src/LEAmDNS.h
Original file line number Diff line number Diff line change
Expand Up @@ -1149,6 +1149,7 @@ class MDNSResponder {
bool m_bPassivModeEnabled;
stcProbeInformation m_HostProbeInformation;
IPAddress m_IPAddress;
const netif* m_netif; // network interface associated to m_IPAddress

/** CONTROL **/
/* MAINTENANCE */
Expand Down
9 changes: 6 additions & 3 deletions libraries/ESP8266mDNS/src/LEAmDNS_Control.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -22,7 +22,6 @@
*
*/

#include <arch/cc.h>
#include <sys/time.h>
#include <IPAddress.h>
#include <AddrList.h>
Expand Down Expand Up @@ -79,8 +78,10 @@ bool MDNSResponder::_process(bool p_bUserContext) {
}
}
else {
bResult = _updateProbeStatus() && // Probing
_checkServiceQueryCache(); // Service query cache check
bResult = (m_netif != nullptr) &&
(m_netif->flags & NETIF_FLAG_UP) && // network interface is up and running
_updateProbeStatus() && // Probing
_checkServiceQueryCache(); // Service query cache check
}
return bResult;
}
Expand Down Expand Up @@ -122,10 +123,12 @@ bool MDNSResponder::_restart(void) {

// check existence of this IP address in the interface list
bool found = false;
m_netif = nullptr;
for (auto a: addrList)
if (m_IPAddress == a.addr()) {
if (a.ifUp()) {
found = true;
m_netif = a.interface();
break;
}
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()););
Expand Down