mirror of
https://github.com/esp8266/Arduino.git
synced 2025-04-21 10:26:06 +03:00
formalization of LEA's mdns rewrite (#5450)
* formalization of LEA's mdns rewrite (code), minor changes to polledTimeout * fix typo * Fix mdns examples
This commit is contained in:
parent
e4c6030e48
commit
4d15590096
@ -23,7 +23,7 @@
|
||||
Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA
|
||||
*/
|
||||
|
||||
|
||||
#include <Arduino.h>
|
||||
|
||||
namespace esp8266
|
||||
{
|
||||
@ -71,7 +71,7 @@ public:
|
||||
return expired();
|
||||
}
|
||||
|
||||
void reset(timeType newTimeout)
|
||||
void reset(const timeType newTimeout)
|
||||
{
|
||||
_timeout = newTimeout;
|
||||
reset();
|
||||
@ -82,12 +82,18 @@ public:
|
||||
_start = millis();
|
||||
}
|
||||
|
||||
protected:
|
||||
bool checkExpired(timeType t) const
|
||||
timeType getTimeout() const
|
||||
{
|
||||
return _timeout;
|
||||
}
|
||||
|
||||
bool checkExpired(const timeType t) const
|
||||
{
|
||||
return (t - _start) >= _timeout;
|
||||
}
|
||||
|
||||
protected:
|
||||
|
||||
bool expiredRetrigger()
|
||||
{
|
||||
timeType current = millis();
|
||||
|
@ -49,8 +49,7 @@
|
||||
|
||||
*/
|
||||
#include <ESP8266mDNS.h>
|
||||
#include <LEATimeFlag.h>
|
||||
|
||||
#include <PolledTimeout.h>
|
||||
/*
|
||||
Global defines and vars
|
||||
*/
|
||||
@ -71,7 +70,7 @@ const char* password = STAPSK
|
||||
|
||||
char* pcHostDomain = 0; // Negociated host domain
|
||||
bool bHostDomainConfirmed = false; // Flags the confirmation of the host domain
|
||||
LEAmDNS::MDNSResponder::hMDNSService hMDNSService = 0; // The handle of the clock service in the MDNS responder
|
||||
MDNSResponder::hMDNSService hMDNSService = 0; // The handle of the clock service in the MDNS responder
|
||||
|
||||
// TCP server at port 'SERVICE_PORT' will respond to HTTP requests
|
||||
WiFiServer server(SERVICE_PORT);
|
||||
@ -86,7 +85,7 @@ const char* getTimeString(void) {
|
||||
time_t now = time(nullptr);
|
||||
ctime_r(&now, acTimeString);
|
||||
size_t stLength;
|
||||
while (((stLength = os_strlen(acTimeString))) &&
|
||||
while (((stLength = strlen(acTimeString))) &&
|
||||
('\n' == acTimeString[stLength - 1])) {
|
||||
acTimeString[stLength - 1] = 0; // Remove trailing line break...
|
||||
}
|
||||
@ -136,8 +135,8 @@ bool setStationHostname(const char* p_pcHostname) {
|
||||
This can be triggered by calling MDNS.announce().
|
||||
|
||||
*/
|
||||
bool MDNSDynamicServiceTxtCallback(LEAmDNS::MDNSResponder* p_pMDNSResponder,
|
||||
const LEAmDNS::MDNSResponder::hMDNSService p_hService,
|
||||
bool MDNSDynamicServiceTxtCallback(MDNSResponder* p_pMDNSResponder,
|
||||
const MDNSResponder::hMDNSService p_hService,
|
||||
void* p_pUserdata) {
|
||||
Serial.println("MDNSDynamicServiceTxtCallback");
|
||||
(void) p_pUserdata;
|
||||
@ -161,9 +160,9 @@ bool MDNSDynamicServiceTxtCallback(LEAmDNS::MDNSResponder* p_pMDNSResponder,
|
||||
restarted via p_pMDNSResponder->setHostname().
|
||||
|
||||
*/
|
||||
bool MDNSProbeResultCallback(LEAmDNS::MDNSResponder* p_pMDNSResponder,
|
||||
bool MDNSProbeResultCallback(MDNSResponder* p_pMDNSResponder,
|
||||
const char* p_pcDomainName,
|
||||
const LEAmDNS::MDNSResponder::hMDNSService p_hService,
|
||||
const MDNSResponder::hMDNSService p_hService,
|
||||
bool p_bProbeResult,
|
||||
void* p_pUserdata) {
|
||||
Serial.println("MDNSProbeResultCallback");
|
||||
@ -192,7 +191,7 @@ bool MDNSProbeResultCallback(LEAmDNS::MDNSResponder* p_pMDNSResponder,
|
||||
}
|
||||
} else {
|
||||
// Change hostname, use '-' as divider between base name and index
|
||||
if (LEAmDNS::MDNSResponder::indexDomain(pcHostDomain, "-", 0)) {
|
||||
if (MDNSResponder::indexDomain(pcHostDomain, "-", 0)) {
|
||||
p_pMDNSResponder->setHostname(pcHostDomain);
|
||||
} else {
|
||||
Serial.println("MDNSProbeResultCallback: FAILED to update hostname!");
|
||||
@ -286,10 +285,10 @@ void setup(void) {
|
||||
setClock();
|
||||
|
||||
// Setup MDNS responder
|
||||
LEAmDNS::MDNS.setProbeResultCallback(MDNSProbeResultCallback, 0);
|
||||
MDNS.setProbeResultCallback(MDNSProbeResultCallback, 0);
|
||||
// Init the (currently empty) host domain string with 'esp8266'
|
||||
if ((!LEAmDNS::MDNSResponder::indexDomain(pcHostDomain, 0, "esp8266")) ||
|
||||
(!LEAmDNS::MDNS.begin(pcHostDomain))) {
|
||||
if ((!MDNSResponder::indexDomain(pcHostDomain, 0, "esp8266")) ||
|
||||
(!MDNS.begin(pcHostDomain))) {
|
||||
Serial.println("Error setting up MDNS responder!");
|
||||
while (1) { // STOP
|
||||
delay(1000);
|
||||
@ -314,17 +313,17 @@ void loop(void) {
|
||||
}
|
||||
|
||||
// Allow MDNS processing
|
||||
LEAmDNS::MDNS.update();
|
||||
MDNS.update();
|
||||
|
||||
// Update time (if needed)
|
||||
//static unsigned long ulNextTimeUpdate = UPDATE_CYCLE;
|
||||
static clsLEATimeFlag timeFlag(UPDATE_CYCLE);
|
||||
static clsMDNSTimeFlag timeFlag(UPDATE_CYCLE);
|
||||
if (timeFlag.flagged()/*ulNextTimeUpdate < millis()*/) {
|
||||
|
||||
if (hMDNSService) {
|
||||
// Just trigger a new MDNS announcement, this will lead to a call to
|
||||
// 'MDNSDynamicServiceTxtCallback', which will update the time TXT item
|
||||
LEAmDNS::MDNS.announce();
|
||||
MDNS.announce();
|
||||
}
|
||||
//ulNextTimeUpdate = (millis() + UPDATE_CYCLE); // Set update 'timer'
|
||||
timeFlag.restart();
|
||||
|
@ -63,8 +63,8 @@ const char* password
|
||||
|
||||
char* pcHostDomain = 0; // Negociated host domain
|
||||
bool bHostDomainConfirmed = false; // Flags the confirmation of the host domain
|
||||
LEAmDNS::MDNSResponder::hMDNSService hMDNSService = 0; // The handle of the http service in the MDNS responder
|
||||
LEAmDNS::MDNSResponder::hMDNSServiceQuery hMDNSServiceQuery = 0; // The handle of the 'http.tcp' service query in the MDNS responder
|
||||
MDNSResponder::hMDNSService hMDNSService = 0; // The handle of the http service in the MDNS responder
|
||||
MDNSResponder::hMDNSServiceQuery hMDNSServiceQuery = 0; // The handle of the 'http.tcp' service query in the MDNS responder
|
||||
|
||||
const String cstrNoHTTPServices = "Currently no 'http.tcp' services in the local network!<br/>";
|
||||
String strHTTPServices = cstrNoHTTPServices;
|
||||
@ -89,8 +89,8 @@ bool setStationHostname(const char* p_pcHostname) {
|
||||
/*
|
||||
MDNSServiceQueryCallback
|
||||
*/
|
||||
bool MDNSServiceQueryCallback(LEAmDNS::MDNSResponder* p_pMDNSResponder, // The MDNS responder object
|
||||
const LEAmDNS::MDNSResponder::hMDNSServiceQuery p_hServiceQuery, // Handle to the service query
|
||||
bool MDNSServiceQueryCallback(MDNSResponder* p_pMDNSResponder, // The MDNS responder object
|
||||
const MDNSResponder::hMDNSServiceQuery p_hServiceQuery, // Handle to the service query
|
||||
uint32_t p_u32AnswerIndex, // Index of the updated answer
|
||||
uint32_t p_u32ServiceQueryAnswerMask, // Mask for the updated component
|
||||
bool p_bSetContent, // true: Component set, false: component deleted
|
||||
@ -101,12 +101,12 @@ bool MDNSServiceQueryCallback(LEAmDNS::MDNSResponder* p_pMDNSResponder,
|
||||
if ((p_pMDNSResponder) &&
|
||||
(hMDNSServiceQuery == p_hServiceQuery)) {
|
||||
|
||||
if (LEAmDNS::MDNSResponder::ServiceQueryAnswerType_ServiceDomain & p_u32ServiceQueryAnswerMask) {
|
||||
if (MDNSResponder::ServiceQueryAnswerType_ServiceDomain & p_u32ServiceQueryAnswerMask) {
|
||||
Serial.printf("MDNSServiceQueryCallback: Service domain '%s' %s index %u\n",
|
||||
p_pMDNSResponder->answerServiceDomain(p_hServiceQuery, p_u32AnswerIndex),
|
||||
(p_bSetContent ? "added at" : "removed from"),
|
||||
p_u32AnswerIndex);
|
||||
} else if (LEAmDNS::MDNSResponder::ServiceQueryAnswerType_HostDomainAndPort & p_u32ServiceQueryAnswerMask) {
|
||||
} else if (MDNSResponder::ServiceQueryAnswerType_HostDomainAndPort & p_u32ServiceQueryAnswerMask) {
|
||||
if (p_bSetContent) {
|
||||
Serial.printf("MDNSServiceQueryCallback: Host domain and port added/updated for service '%s': %s:%u\n",
|
||||
p_pMDNSResponder->answerServiceDomain(p_hServiceQuery, p_u32AnswerIndex),
|
||||
@ -116,7 +116,7 @@ bool MDNSServiceQueryCallback(LEAmDNS::MDNSResponder* p_pMDNSResponder,
|
||||
Serial.printf("MDNSServiceQueryCallback: Host domain and port removed from service '%s'\n",
|
||||
p_pMDNSResponder->answerServiceDomain(p_hServiceQuery, p_u32AnswerIndex));
|
||||
}
|
||||
} else if (LEAmDNS::MDNSResponder::ServiceQueryAnswerType_IP4Address & p_u32ServiceQueryAnswerMask) {
|
||||
} else if (MDNSResponder::ServiceQueryAnswerType_IP4Address & p_u32ServiceQueryAnswerMask) {
|
||||
if (p_bSetContent) {
|
||||
Serial.printf("MDNSServiceQueryCallback: IP4 address added/updated for service '%s':\n",
|
||||
p_pMDNSResponder->answerServiceDomain(p_hServiceQuery, p_u32AnswerIndex));
|
||||
@ -127,7 +127,7 @@ bool MDNSServiceQueryCallback(LEAmDNS::MDNSResponder* p_pMDNSResponder,
|
||||
Serial.printf("MDNSServiceQueryCallback: IP4 address removed from service '%s'\n",
|
||||
p_pMDNSResponder->answerServiceDomain(p_hServiceQuery, p_u32AnswerIndex));
|
||||
}
|
||||
} else if (LEAmDNS::MDNSResponder::ServiceQueryAnswerType_Txts & p_u32ServiceQueryAnswerMask) {
|
||||
} else if (MDNSResponder::ServiceQueryAnswerType_Txts & p_u32ServiceQueryAnswerMask) {
|
||||
if (p_bSetContent) {
|
||||
Serial.printf("MDNSServiceQueryCallback: TXT items added/updated for service '%s': %s\n",
|
||||
p_pMDNSResponder->answerServiceDomain(p_hServiceQuery, p_u32AnswerIndex),
|
||||
@ -192,9 +192,9 @@ bool MDNSServiceQueryCallback(LEAmDNS::MDNSResponder* p_pMDNSResponder,
|
||||
restarted via p_pMDNSResponder->setHostname().
|
||||
|
||||
*/
|
||||
bool MDNSProbeResultCallback(LEAmDNS::MDNSResponder* p_pMDNSResponder,
|
||||
bool MDNSProbeResultCallback(MDNSResponder* p_pMDNSResponder,
|
||||
const char* p_pcDomainName,
|
||||
const LEAmDNS::MDNSResponder::hMDNSService p_hService,
|
||||
const MDNSResponder::hMDNSService p_hService,
|
||||
bool p_bProbeResult,
|
||||
void* p_pUserdata) {
|
||||
(void) p_pUserdata;
|
||||
@ -235,7 +235,7 @@ bool MDNSProbeResultCallback(LEAmDNS::MDNSResponder* p_pMDNSResponder,
|
||||
}
|
||||
} else {
|
||||
// Change hostname, use '-' as divider between base name and index
|
||||
if (LEAmDNS::MDNSResponder::indexDomain(pcHostDomain, "-", 0)) {
|
||||
if (MDNSResponder::indexDomain(pcHostDomain, "-", 0)) {
|
||||
p_pMDNSResponder->setHostname(pcHostDomain);
|
||||
} else {
|
||||
Serial.println("MDNSProbeResultCallback: FAILED to update hostname!");
|
||||
@ -322,10 +322,10 @@ void setup(void) {
|
||||
Serial.println(WiFi.localIP());
|
||||
|
||||
// Setup MDNS responder
|
||||
LEAmDNS::MDNS.setProbeResultCallback(MDNSProbeResultCallback, 0);
|
||||
MDNS.setProbeResultCallback(MDNSProbeResultCallback, 0);
|
||||
// Init the (currently empty) host domain string with 'esp8266'
|
||||
if ((!LEAmDNS::MDNSResponder::indexDomain(pcHostDomain, 0, "esp8266")) ||
|
||||
(!LEAmDNS::MDNS.begin(pcHostDomain))) {
|
||||
if ((!MDNSResponder::indexDomain(pcHostDomain, 0, "esp8266")) ||
|
||||
(!MDNS.begin(pcHostDomain))) {
|
||||
Serial.println("Error setting up MDNS responder!");
|
||||
while (1) { // STOP
|
||||
delay(1000);
|
||||
@ -350,7 +350,7 @@ void loop(void) {
|
||||
}
|
||||
|
||||
// Allow MDNS processing
|
||||
LEAmDNS::MDNS.update();
|
||||
MDNS.update();
|
||||
}
|
||||
|
||||
|
||||
|
11
libraries/ESP8266mDNS/src/ESP8266mDNS.cpp
Normal file
11
libraries/ESP8266mDNS/src/ESP8266mDNS.cpp
Normal file
@ -0,0 +1,11 @@
|
||||
#include <ESP8266mDNS.h>
|
||||
|
||||
/*
|
||||
* MDNS responder global instance
|
||||
*
|
||||
* Class type that is instantiated depends on the type mapping in ESP8266mDNS.h
|
||||
*/
|
||||
#if !defined(NO_GLOBAL_INSTANCES) && !defined(NO_GLOBAL_MDNS)
|
||||
MDNSResponder MDNS;
|
||||
#endif
|
||||
|
@ -45,5 +45,12 @@
|
||||
#include "ESP8266mDNS_Legacy.h"
|
||||
#include "LEAmDNS.h"
|
||||
|
||||
using namespace Legacy_MDNSResponder;
|
||||
//using namespace LEAmDNS;
|
||||
|
||||
#if !defined(NO_GLOBAL_INSTANCES) && !defined(NO_GLOBAL_MDNS)
|
||||
// Maps the implementation to use to the global namespace type
|
||||
//using MDNSResponder = Legacy_MDNSResponder::MDNSResponder; //legacy
|
||||
using MDNSResponder = esp8266::MDNSImplementation::MDNSResponder; //new
|
||||
|
||||
extern MDNSResponder MDNS;
|
||||
#endif
|
||||
|
||||
|
@ -40,8 +40,8 @@ License (MIT license):
|
||||
THE SOFTWARE.
|
||||
|
||||
*/
|
||||
#ifndef ESP8266MDNS_H
|
||||
#define ESP8266MDNS_H
|
||||
#ifndef ESP8266MDNS_LEGACY_H
|
||||
#define ESP8266MDNS_LEGACY_H
|
||||
|
||||
#include "ESP8266WiFi.h"
|
||||
#include "WiFiUdp.h"
|
||||
@ -139,10 +139,6 @@ private:
|
||||
void _restart();
|
||||
};
|
||||
|
||||
#if !defined(NO_GLOBAL_INSTANCES) && !defined(NO_GLOBAL_MDNS)
|
||||
extern MDNSResponder MDNS;
|
||||
#endif
|
||||
|
||||
} // namespace Legacy_MDNSResponder
|
||||
|
||||
#endif //ESP8266MDNS_H
|
||||
|
@ -1,62 +1,60 @@
|
||||
/*
|
||||
* LEATimeFlag.h
|
||||
*/
|
||||
#ifndef __LEATIMEFLAG_H
|
||||
#define __LEATIMEFLAG_H
|
||||
#ifndef __MDNSTIMEFLAG_H
|
||||
#define __MDNSTIMEFLAG_H
|
||||
|
||||
|
||||
#include <Arduino.h>
|
||||
#include <limits>
|
||||
#include <PolledTimeout.h>
|
||||
|
||||
|
||||
/**
|
||||
* clsLEATimeFlag
|
||||
/* Wrapper class around PolledTimeout
|
||||
* MDNS requires behavior that is slightly different from the default in PolledTimeout
|
||||
*/
|
||||
class clsLEATimeFlag {
|
||||
class clsMDNSTimeFlag {
|
||||
protected:
|
||||
using oneShot = esp8266::polledTimeout::oneShot;
|
||||
oneShot m_clsPolledTimeout;
|
||||
|
||||
public:
|
||||
// constructor
|
||||
clsLEATimeFlag(unsigned long p_ulTimeout = (unsigned long)(-1))
|
||||
: m_ulStart(millis()),
|
||||
m_ulTimeout(p_ulTimeout) {
|
||||
using timeType = oneShot::timeType;
|
||||
|
||||
clsMDNSTimeFlag(timeType p_Timeout)
|
||||
: m_clsPolledTimeout(p_Timeout) {
|
||||
}
|
||||
// operator bool
|
||||
operator bool(void) const {
|
||||
clsMDNSTimeFlag()
|
||||
: m_clsPolledTimeout(std::numeric_limits<timeType>::max()) {
|
||||
}
|
||||
|
||||
operator bool() const {
|
||||
return flagged();
|
||||
}
|
||||
// flagged
|
||||
bool flagged(void) const {
|
||||
return ((millis() - m_ulStart) > m_ulTimeout);
|
||||
}
|
||||
// restart
|
||||
void restart(unsigned long p_ulNewTimeout = (unsigned long)(-1)) {
|
||||
if ((unsigned long)(-1) != p_ulNewTimeout) {
|
||||
m_ulTimeout = p_ulNewTimeout;
|
||||
}
|
||||
m_ulStart = millis();
|
||||
}
|
||||
void reset(void) {
|
||||
m_ulTimeout = (unsigned long)(-1);
|
||||
m_ulStart = millis();
|
||||
|
||||
bool flagged() const {
|
||||
return m_clsPolledTimeout.checkExpired(millis());
|
||||
}
|
||||
|
||||
unsigned long start(void) const {
|
||||
return m_ulStart;
|
||||
}
|
||||
unsigned long timeout(void) const {
|
||||
return m_ulTimeout;
|
||||
}
|
||||
bool hypotheticalTimeout(unsigned long p_ulHypotheticalTimeout) const {
|
||||
return ((millis() - m_ulStart) > p_ulHypotheticalTimeout);
|
||||
void restart() {
|
||||
m_clsPolledTimeout.reset();
|
||||
}
|
||||
|
||||
protected:
|
||||
unsigned long m_ulStart;
|
||||
unsigned long m_ulTimeout;
|
||||
void restart(const timeType p_Timeout) {
|
||||
m_clsPolledTimeout.reset(p_Timeout);
|
||||
}
|
||||
|
||||
void reset() {
|
||||
m_clsPolledTimeout.reset(std::numeric_limits<timeType>::max());
|
||||
}
|
||||
|
||||
timeType getTimeout() const {
|
||||
return m_clsPolledTimeout.getTimeout();
|
||||
}
|
||||
|
||||
bool hypotheticalTimeout(const timeType p_Timeout) const {
|
||||
return m_clsPolledTimeout.checkExpired(p_Timeout);
|
||||
}
|
||||
};
|
||||
|
||||
#endif // __LEATIMEFLAG_H
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
#endif // __MDNSTIMEFLAG_H
|
||||
|
15
libraries/ESP8266mDNS/src/LEAmDNS.cpp
Executable file → Normal file
15
libraries/ESP8266mDNS/src/LEAmDNS.cpp
Executable file → Normal file
@ -24,10 +24,12 @@
|
||||
|
||||
#include "LEAmDNS_Priv.h"
|
||||
|
||||
namespace esp8266 {
|
||||
|
||||
/*
|
||||
* LEAmDNS
|
||||
*/
|
||||
namespace LEAmDNS {
|
||||
namespace MDNSImplementation {
|
||||
|
||||
/**
|
||||
* STRINGIZE
|
||||
@ -1107,14 +1109,9 @@ MDNSResponder::hMDNSService MDNSResponder::enableArduino(uint16_t p_u16Port,
|
||||
return hService;
|
||||
}
|
||||
|
||||
/*
|
||||
* MDNS responder global instance
|
||||
*/
|
||||
#if !defined(NO_GLOBAL_INSTANCES) && !defined(NO_GLOBAL_MDNS)
|
||||
MDNSResponder MDNS;
|
||||
#endif
|
||||
|
||||
} // namespace LEAmDNS
|
||||
|
||||
} //namespace MDNSImplementation
|
||||
|
||||
} //namespace esp8266
|
||||
|
||||
|
||||
|
254
libraries/ESP8266mDNS/src/LEAmDNS.h
Executable file → Normal file
254
libraries/ESP8266mDNS/src/LEAmDNS.h
Executable file → Normal file
@ -99,8 +99,8 @@
|
||||
*
|
||||
*/
|
||||
|
||||
#ifndef LEAMDNS_H
|
||||
#define LEAMDNS_H
|
||||
#ifndef MDNS_H
|
||||
#define MDNS_H
|
||||
|
||||
#include <functional> // for UdpContext.h
|
||||
#include "WiFiUdp.h"
|
||||
@ -111,10 +111,13 @@
|
||||
|
||||
#include "ESP8266WiFi.h"
|
||||
|
||||
|
||||
namespace esp8266 {
|
||||
|
||||
/**
|
||||
* LEAmDNS
|
||||
*/
|
||||
namespace LEAmDNS {
|
||||
namespace MDNSImplementation {
|
||||
|
||||
//this should be defined at build time
|
||||
#ifndef ARDUINO_BOARD
|
||||
@ -455,19 +458,19 @@ protected:
|
||||
/**
|
||||
* stcMDNSServiceTxt
|
||||
*/
|
||||
typedef struct _stcMDNSServiceTxt {
|
||||
_stcMDNSServiceTxt* m_pNext;
|
||||
struct stcMDNSServiceTxt {
|
||||
stcMDNSServiceTxt* m_pNext;
|
||||
char* m_pcKey;
|
||||
char* m_pcValue;
|
||||
bool m_bTemp;
|
||||
|
||||
_stcMDNSServiceTxt(const char* p_pcKey = 0,
|
||||
stcMDNSServiceTxt(const char* p_pcKey = 0,
|
||||
const char* p_pcValue = 0,
|
||||
bool p_bTemp = false);
|
||||
_stcMDNSServiceTxt(const _stcMDNSServiceTxt& p_Other);
|
||||
~_stcMDNSServiceTxt(void);
|
||||
stcMDNSServiceTxt(const stcMDNSServiceTxt& p_Other);
|
||||
~stcMDNSServiceTxt(void);
|
||||
|
||||
_stcMDNSServiceTxt& operator=(const _stcMDNSServiceTxt& p_Other);
|
||||
stcMDNSServiceTxt& operator=(const stcMDNSServiceTxt& p_Other);
|
||||
bool clear(void);
|
||||
|
||||
char* allocKey(size_t p_stLength);
|
||||
@ -489,19 +492,19 @@ protected:
|
||||
bool update(const char* p_pcValue);
|
||||
|
||||
size_t length(void) const;
|
||||
} stcMDNSServiceTxt;
|
||||
};
|
||||
|
||||
/**
|
||||
* stcMDNSTxts
|
||||
*/
|
||||
typedef struct _stcMDNSServiceTxts {
|
||||
struct stcMDNSServiceTxts {
|
||||
stcMDNSServiceTxt* m_pTxts;
|
||||
|
||||
_stcMDNSServiceTxts(void);
|
||||
_stcMDNSServiceTxts(const _stcMDNSServiceTxts& p_Other);
|
||||
~_stcMDNSServiceTxts(void);
|
||||
stcMDNSServiceTxts(void);
|
||||
stcMDNSServiceTxts(const stcMDNSServiceTxts& p_Other);
|
||||
~stcMDNSServiceTxts(void);
|
||||
|
||||
_stcMDNSServiceTxts& operator=(const _stcMDNSServiceTxts& p_Other);
|
||||
stcMDNSServiceTxts& operator=(const stcMDNSServiceTxts& p_Other);
|
||||
|
||||
bool clear(void);
|
||||
|
||||
@ -522,10 +525,10 @@ protected:
|
||||
size_t bufferLength(void) const;
|
||||
bool buffer(char* p_pcBuffer);
|
||||
|
||||
bool compare(const _stcMDNSServiceTxts& p_Other) const;
|
||||
bool operator==(const _stcMDNSServiceTxts& p_Other) const;
|
||||
bool operator!=(const _stcMDNSServiceTxts& p_Other) const;
|
||||
} stcMDNSServiceTxts;
|
||||
bool compare(const stcMDNSServiceTxts& p_Other) const;
|
||||
bool operator==(const stcMDNSServiceTxts& p_Other) const;
|
||||
bool operator!=(const stcMDNSServiceTxts& p_Other) const;
|
||||
};
|
||||
|
||||
/**
|
||||
* enuContentFlags
|
||||
@ -546,7 +549,7 @@ protected:
|
||||
/**
|
||||
* stcMDNS_MsgHeader
|
||||
*/
|
||||
typedef struct _stcMDNS_MsgHeader {
|
||||
struct stcMDNS_MsgHeader {
|
||||
uint16_t m_u16ID; // Identifier
|
||||
bool m_1bQR : 1; // Query/Response flag
|
||||
unsigned char m_4bOpcode : 4; // Operation code
|
||||
@ -561,7 +564,7 @@ protected:
|
||||
uint16_t m_u16NSCount; // Authority Record count
|
||||
uint16_t m_u16ARCount; // Additional Record count
|
||||
|
||||
_stcMDNS_MsgHeader(uint16_t p_u16ID = 0,
|
||||
stcMDNS_MsgHeader(uint16_t p_u16ID = 0,
|
||||
bool p_bQR = false,
|
||||
unsigned char p_ucOpcode = 0,
|
||||
bool p_bAA = false,
|
||||
@ -573,73 +576,73 @@ protected:
|
||||
uint16_t p_u16ANCount = 0,
|
||||
uint16_t p_u16NSCount = 0,
|
||||
uint16_t p_u16ARCount = 0);
|
||||
} stcMDNS_MsgHeader;
|
||||
};
|
||||
|
||||
/**
|
||||
* stcMDNS_RRDomain
|
||||
*/
|
||||
typedef struct _stcMDNS_RRDomain {
|
||||
struct stcMDNS_RRDomain {
|
||||
char m_acName[MDNS_DOMAIN_MAXLENGTH]; // Encoded domain name
|
||||
uint16_t m_u16NameLength; // Length (incl. '\0')
|
||||
|
||||
_stcMDNS_RRDomain(void);
|
||||
_stcMDNS_RRDomain(const _stcMDNS_RRDomain& p_Other);
|
||||
stcMDNS_RRDomain(void);
|
||||
stcMDNS_RRDomain(const stcMDNS_RRDomain& p_Other);
|
||||
|
||||
_stcMDNS_RRDomain& operator=(const _stcMDNS_RRDomain& p_Other);
|
||||
stcMDNS_RRDomain& operator=(const stcMDNS_RRDomain& p_Other);
|
||||
|
||||
bool clear(void);
|
||||
|
||||
bool addLabel(const char* p_pcLabel,
|
||||
bool p_bPrependUnderline = false);
|
||||
|
||||
bool compare(const _stcMDNS_RRDomain& p_Other) const;
|
||||
bool operator==(const _stcMDNS_RRDomain& p_Other) const;
|
||||
bool operator!=(const _stcMDNS_RRDomain& p_Other) const;
|
||||
bool operator>(const _stcMDNS_RRDomain& p_Other) const;
|
||||
bool compare(const stcMDNS_RRDomain& p_Other) const;
|
||||
bool operator==(const stcMDNS_RRDomain& p_Other) const;
|
||||
bool operator!=(const stcMDNS_RRDomain& p_Other) const;
|
||||
bool operator>(const stcMDNS_RRDomain& p_Other) const;
|
||||
|
||||
size_t c_strLength(void) const;
|
||||
bool c_str(char* p_pcBuffer);
|
||||
} stcMDNS_RRDomain;
|
||||
};
|
||||
|
||||
/**
|
||||
* stcMDNS_RRAttributes
|
||||
*/
|
||||
typedef struct _stcMDNS_RRAttributes {
|
||||
struct stcMDNS_RRAttributes {
|
||||
uint16_t m_u16Type; // Type
|
||||
uint16_t m_u16Class; // Class, nearly always 'IN'
|
||||
|
||||
_stcMDNS_RRAttributes(uint16_t p_u16Type = 0,
|
||||
stcMDNS_RRAttributes(uint16_t p_u16Type = 0,
|
||||
uint16_t p_u16Class = 1 /*DNS_RRCLASS_IN Internet*/);
|
||||
_stcMDNS_RRAttributes(const _stcMDNS_RRAttributes& p_Other);
|
||||
stcMDNS_RRAttributes(const stcMDNS_RRAttributes& p_Other);
|
||||
|
||||
_stcMDNS_RRAttributes& operator=(const _stcMDNS_RRAttributes& p_Other);
|
||||
} stcMDNS_RRAttributes;
|
||||
stcMDNS_RRAttributes& operator=(const stcMDNS_RRAttributes& p_Other);
|
||||
};
|
||||
|
||||
/**
|
||||
* stcMDNS_RRHeader
|
||||
*/
|
||||
typedef struct _stcMDNS_RRHeader {
|
||||
struct stcMDNS_RRHeader {
|
||||
stcMDNS_RRDomain m_Domain;
|
||||
stcMDNS_RRAttributes m_Attributes;
|
||||
|
||||
_stcMDNS_RRHeader(void);
|
||||
_stcMDNS_RRHeader(const _stcMDNS_RRHeader& p_Other);
|
||||
stcMDNS_RRHeader(void);
|
||||
stcMDNS_RRHeader(const stcMDNS_RRHeader& p_Other);
|
||||
|
||||
_stcMDNS_RRHeader& operator=(const _stcMDNS_RRHeader& p_Other);
|
||||
stcMDNS_RRHeader& operator=(const stcMDNS_RRHeader& p_Other);
|
||||
|
||||
bool clear(void);
|
||||
} stcMDNS_RRHeader;
|
||||
};
|
||||
|
||||
/**
|
||||
* stcMDNS_RRQuestion
|
||||
*/
|
||||
typedef struct _stcMDNS_RRQuestion {
|
||||
_stcMDNS_RRQuestion* m_pNext;
|
||||
_stcMDNS_RRHeader m_Header;
|
||||
struct stcMDNS_RRQuestion {
|
||||
stcMDNS_RRQuestion* m_pNext;
|
||||
stcMDNS_RRHeader m_Header;
|
||||
bool m_bUnicast; // Unicast reply requested
|
||||
|
||||
_stcMDNS_RRQuestion(void);
|
||||
} stcMDNS_RRQuestion;
|
||||
stcMDNS_RRQuestion(void);
|
||||
};
|
||||
|
||||
/**
|
||||
* enuAnswerType
|
||||
@ -656,110 +659,110 @@ protected:
|
||||
/**
|
||||
* stcMDNS_RRAnswer
|
||||
*/
|
||||
typedef struct _stcMDNS_RRAnswer {
|
||||
_stcMDNS_RRAnswer* m_pNext;
|
||||
struct stcMDNS_RRAnswer {
|
||||
stcMDNS_RRAnswer* m_pNext;
|
||||
const enuAnswerType m_AnswerType;
|
||||
_stcMDNS_RRHeader m_Header;
|
||||
stcMDNS_RRHeader m_Header;
|
||||
bool m_bCacheFlush; // Cache flush command bit
|
||||
uint32_t m_u32TTL; // Validity time in seconds
|
||||
|
||||
virtual ~_stcMDNS_RRAnswer(void);
|
||||
virtual ~stcMDNS_RRAnswer(void);
|
||||
|
||||
enuAnswerType answerType(void) const;
|
||||
|
||||
bool clear(void);
|
||||
|
||||
protected:
|
||||
_stcMDNS_RRAnswer(enuAnswerType p_AnswerType,
|
||||
stcMDNS_RRAnswer(enuAnswerType p_AnswerType,
|
||||
const stcMDNS_RRHeader& p_Header,
|
||||
uint32_t p_u32TTL);
|
||||
} stcMDNS_RRAnswer;
|
||||
};
|
||||
|
||||
#ifdef MDNS_IP4_SUPPORT
|
||||
/**
|
||||
* stcMDNS_RRAnswerA
|
||||
*/
|
||||
typedef struct _stcMDNS_RRAnswerA : public stcMDNS_RRAnswer {
|
||||
struct stcMDNS_RRAnswerA : public stcMDNS_RRAnswer {
|
||||
IPAddress m_IPAddress;
|
||||
|
||||
_stcMDNS_RRAnswerA(const stcMDNS_RRHeader& p_Header,
|
||||
stcMDNS_RRAnswerA(const stcMDNS_RRHeader& p_Header,
|
||||
uint32_t p_u32TTL);
|
||||
~_stcMDNS_RRAnswerA(void);
|
||||
~stcMDNS_RRAnswerA(void);
|
||||
|
||||
bool clear(void);
|
||||
} stcMDNS_RRAnswerA;
|
||||
};
|
||||
#endif
|
||||
|
||||
/**
|
||||
* stcMDNS_RRAnswerPTR
|
||||
*/
|
||||
typedef struct _stcMDNS_RRAnswerPTR : public stcMDNS_RRAnswer {
|
||||
struct stcMDNS_RRAnswerPTR : public stcMDNS_RRAnswer {
|
||||
stcMDNS_RRDomain m_PTRDomain;
|
||||
|
||||
_stcMDNS_RRAnswerPTR(const stcMDNS_RRHeader& p_Header,
|
||||
stcMDNS_RRAnswerPTR(const stcMDNS_RRHeader& p_Header,
|
||||
uint32_t p_u32TTL);
|
||||
~_stcMDNS_RRAnswerPTR(void);
|
||||
~stcMDNS_RRAnswerPTR(void);
|
||||
|
||||
bool clear(void);
|
||||
} stcMDNS_RRAnswerPTR;
|
||||
};
|
||||
|
||||
/**
|
||||
* stcMDNS_RRAnswerTXT
|
||||
*/
|
||||
typedef struct _stcMDNS_RRAnswerTXT : public stcMDNS_RRAnswer {
|
||||
struct stcMDNS_RRAnswerTXT : public stcMDNS_RRAnswer {
|
||||
stcMDNSServiceTxts m_Txts;
|
||||
|
||||
_stcMDNS_RRAnswerTXT(const stcMDNS_RRHeader& p_Header,
|
||||
stcMDNS_RRAnswerTXT(const stcMDNS_RRHeader& p_Header,
|
||||
uint32_t p_u32TTL);
|
||||
~_stcMDNS_RRAnswerTXT(void);
|
||||
~stcMDNS_RRAnswerTXT(void);
|
||||
|
||||
bool clear(void);
|
||||
} stcMDNS_RRAnswerTXT;
|
||||
};
|
||||
|
||||
#ifdef MDNS_IP6_SUPPORT
|
||||
/**
|
||||
* stcMDNS_RRAnswerAAAA
|
||||
*/
|
||||
typedef struct _stcMDNS_RRAnswerAAAA : public stcMDNS_RRAnswer {
|
||||
struct stcMDNS_RRAnswerAAAA : public stcMDNS_RRAnswer {
|
||||
//TODO: IP6Address m_IPAddress;
|
||||
|
||||
_stcMDNS_RRAnswerAAAA(const stcMDNS_RRHeader& p_Header,
|
||||
stcMDNS_RRAnswerAAAA(const stcMDNS_RRHeader& p_Header,
|
||||
uint32_t p_u32TTL);
|
||||
~_stcMDNS_RRAnswerAAAA(void);
|
||||
~stcMDNS_RRAnswerAAAA(void);
|
||||
|
||||
bool clear(void);
|
||||
} stcMDNS_RRAnswerAAAA;
|
||||
};
|
||||
#endif
|
||||
|
||||
/**
|
||||
* stcMDNS_RRAnswerSRV
|
||||
*/
|
||||
typedef struct _stcMDNS_RRAnswerSRV : public stcMDNS_RRAnswer {
|
||||
struct stcMDNS_RRAnswerSRV : public stcMDNS_RRAnswer {
|
||||
uint16_t m_u16Priority;
|
||||
uint16_t m_u16Weight;
|
||||
uint16_t m_u16Port;
|
||||
stcMDNS_RRDomain m_SRVDomain;
|
||||
|
||||
_stcMDNS_RRAnswerSRV(const stcMDNS_RRHeader& p_Header,
|
||||
stcMDNS_RRAnswerSRV(const stcMDNS_RRHeader& p_Header,
|
||||
uint32_t p_u32TTL);
|
||||
~_stcMDNS_RRAnswerSRV(void);
|
||||
~stcMDNS_RRAnswerSRV(void);
|
||||
|
||||
bool clear(void);
|
||||
} stcMDNS_RRAnswerSRV;
|
||||
};
|
||||
|
||||
/**
|
||||
* stcMDNS_RRAnswerGeneric
|
||||
*/
|
||||
typedef struct _stcMDNS_RRAnswerGeneric : public stcMDNS_RRAnswer {
|
||||
struct stcMDNS_RRAnswerGeneric : public stcMDNS_RRAnswer {
|
||||
uint16_t m_u16RDLength; // Length of variable answer
|
||||
uint8_t* m_pu8RDData; // Offset of start of variable answer in packet
|
||||
|
||||
_stcMDNS_RRAnswerGeneric(const stcMDNS_RRHeader& p_Header,
|
||||
stcMDNS_RRAnswerGeneric(const stcMDNS_RRHeader& p_Header,
|
||||
uint32_t p_u32TTL);
|
||||
~_stcMDNS_RRAnswerGeneric(void);
|
||||
~stcMDNS_RRAnswerGeneric(void);
|
||||
|
||||
bool clear(void);
|
||||
} stcMDNS_RRAnswerGeneric;
|
||||
};
|
||||
|
||||
|
||||
/**
|
||||
@ -775,26 +778,26 @@ protected:
|
||||
/**
|
||||
* stcProbeInformation
|
||||
*/
|
||||
typedef struct _stcProbeInformation {
|
||||
struct stcProbeInformation {
|
||||
enuProbingStatus m_ProbingStatus;
|
||||
uint8_t m_u8ProbesSent;
|
||||
clsLEATimeFlag m_NextProbeTimeFlag;
|
||||
clsMDNSTimeFlag m_NextProbeTimeFlag;
|
||||
bool m_bConflict;
|
||||
bool m_bTiebreakNeeded;
|
||||
MDNSProbeResultCallbackFn m_fnProbeResultCallback;
|
||||
void* m_pProbeResultCallbackUserdata;
|
||||
|
||||
_stcProbeInformation(void);
|
||||
stcProbeInformation(void);
|
||||
|
||||
bool clear(bool p_bClearUserdata = false);
|
||||
} stcProbeInformation;
|
||||
};
|
||||
|
||||
|
||||
/**
|
||||
* stcMDNSService
|
||||
*/
|
||||
typedef struct _stcMDNSService {
|
||||
_stcMDNSService* m_pNext;
|
||||
struct stcMDNSService {
|
||||
stcMDNSService* m_pNext;
|
||||
char* m_pcName;
|
||||
bool m_bAutoName; // Name was set automatically to hostname (if no name was supplied)
|
||||
char* m_pcService;
|
||||
@ -806,10 +809,10 @@ protected:
|
||||
void* m_pTxtCallbackUserdata;
|
||||
stcProbeInformation m_ProbeInformation;
|
||||
|
||||
_stcMDNSService(const char* p_pcName = 0,
|
||||
stcMDNSService(const char* p_pcName = 0,
|
||||
const char* p_pcService = 0,
|
||||
const char* p_pcProtocol = 0);
|
||||
~_stcMDNSService(void);
|
||||
~stcMDNSService(void);
|
||||
|
||||
bool setName(const char* p_pcName);
|
||||
bool releaseName(void);
|
||||
@ -819,54 +822,54 @@ protected:
|
||||
|
||||
bool setProtocol(const char* p_pcProtocol);
|
||||
bool releaseProtocol(void);
|
||||
} stcMDNSService;
|
||||
};
|
||||
|
||||
/**
|
||||
* stcMDNSServiceQuery
|
||||
*/
|
||||
typedef struct _stcMDNSServiceQuery {
|
||||
struct stcMDNSServiceQuery {
|
||||
/**
|
||||
* stcAnswer
|
||||
*/
|
||||
typedef struct _stcAnswer {
|
||||
struct stcAnswer {
|
||||
/**
|
||||
* stcTTL
|
||||
*/
|
||||
typedef struct _stcTTL {
|
||||
clsLEATimeFlag m_TTLTimeFlag;
|
||||
struct stcTTL {
|
||||
clsMDNSTimeFlag m_TTLTimeFlag;
|
||||
bool m_bUpdateScheduled;
|
||||
|
||||
_stcTTL(uint32_t p_u32TTL = 0);
|
||||
stcTTL(uint32_t p_u32TTL = 0);
|
||||
bool set(uint32_t p_u32TTL);
|
||||
|
||||
bool has80Percent(void) const;
|
||||
bool isOutdated(void) const;
|
||||
} stcTTL;
|
||||
};
|
||||
#ifdef MDNS_IP4_SUPPORT
|
||||
/**
|
||||
* stcIP4Address
|
||||
*/
|
||||
typedef struct _stcIP4Address {
|
||||
_stcIP4Address* m_pNext;
|
||||
struct stcIP4Address {
|
||||
stcIP4Address* m_pNext;
|
||||
IPAddress m_IPAddress;
|
||||
stcTTL m_TTL;
|
||||
|
||||
_stcIP4Address(IPAddress p_IPAddress,
|
||||
stcIP4Address(IPAddress p_IPAddress,
|
||||
uint32_t p_u32TTL = 0);
|
||||
} stcIP4Address;
|
||||
};
|
||||
#endif
|
||||
#ifdef MDNS_IP6_SUPPORT
|
||||
/**
|
||||
* stcIP6Address
|
||||
*/
|
||||
typedef struct _stcIP6Address {
|
||||
_stcIP6Address* m_pNext;
|
||||
struct stcIP6Address {
|
||||
stcIP6Address* m_pNext;
|
||||
IP6Address m_IPAddress;
|
||||
stcTTL m_TTL;
|
||||
} stcIP6Address;
|
||||
};
|
||||
#endif
|
||||
|
||||
_stcAnswer* m_pNext;
|
||||
stcAnswer* m_pNext;
|
||||
// The service domain is the first 'answer' (from PTR answer, using service and protocol) to be set
|
||||
// Defines the key for additional answer, like host domain, etc.
|
||||
stcMDNS_RRDomain m_ServiceDomain; // 1. level answer (PTR), eg. MyESP._http._tcp.local
|
||||
@ -887,8 +890,8 @@ protected:
|
||||
#endif
|
||||
uint32_t m_u32ContentFlags;
|
||||
|
||||
_stcAnswer(void);
|
||||
~_stcAnswer(void);
|
||||
stcAnswer(void);
|
||||
~stcAnswer(void);
|
||||
|
||||
bool clear(void);
|
||||
|
||||
@ -903,8 +906,8 @@ protected:
|
||||
|
||||
#ifdef MDNS_IP4_SUPPORT
|
||||
bool releaseIP4Addresses(void);
|
||||
bool addIP4Address(_stcIP4Address* p_pIP4Address);
|
||||
bool removeIP4Address(_stcIP4Address* p_pIP4Address);
|
||||
bool addIP4Address(stcIP4Address* p_pIP4Address);
|
||||
bool removeIP4Address(stcIP4Address* p_pIP4Address);
|
||||
const stcIP4Address* findIP4Address(const IPAddress& p_IPAddress) const;
|
||||
stcIP4Address* findIP4Address(const IPAddress& p_IPAddress);
|
||||
uint32_t IP4AddressCount(void) const;
|
||||
@ -913,17 +916,17 @@ protected:
|
||||
#endif
|
||||
#ifdef MDNS_IP6_SUPPORT
|
||||
bool releaseIP6Addresses(void);
|
||||
bool addIP6Address(_stcIP6Address* p_pIP6Address);
|
||||
bool removeIP6Address(_stcIP6Address* p_pIP6Address);
|
||||
bool addIP6Address(stcIP6Address* p_pIP6Address);
|
||||
bool removeIP6Address(stcIP6Address* p_pIP6Address);
|
||||
const stcIP6Address* findIP6Address(const IPAddress& p_IPAddress) const;
|
||||
stcIP6Address* findIP6Address(const IPAddress& p_IPAddress);
|
||||
uint32_t IP6AddressCount(void) const;
|
||||
const stcIP6Address* IP6AddressAtIndex(uint32_t p_u32Index) const;
|
||||
stcIP6Address* IP6AddressAtIndex(uint32_t p_u32Index);
|
||||
#endif
|
||||
} stcAnswer;
|
||||
};
|
||||
|
||||
_stcMDNSServiceQuery* m_pNext;
|
||||
stcMDNSServiceQuery* m_pNext;
|
||||
stcMDNS_RRDomain m_ServiceTypeDomain; // eg. _http._tcp.local
|
||||
MDNSServiceQueryCallbackFn m_fnCallback;
|
||||
void* m_pUserdata;
|
||||
@ -931,8 +934,8 @@ protected:
|
||||
bool m_bAwaitingAnswers;
|
||||
stcAnswer* m_pAnswers;
|
||||
|
||||
_stcMDNSServiceQuery(void);
|
||||
~_stcMDNSServiceQuery(void);
|
||||
stcMDNSServiceQuery(void);
|
||||
~stcMDNSServiceQuery(void);
|
||||
|
||||
bool clear(void);
|
||||
|
||||
@ -946,26 +949,26 @@ protected:
|
||||
|
||||
stcAnswer* findAnswerForServiceDomain(const stcMDNS_RRDomain& p_ServiceDomain);
|
||||
stcAnswer* findAnswerForHostDomain(const stcMDNS_RRDomain& p_HostDomain);
|
||||
} stcMDNSServiceQuery;
|
||||
};
|
||||
|
||||
/**
|
||||
* stcMDNSSendParameter
|
||||
*/
|
||||
typedef struct _stcMDNSSendParameter {
|
||||
struct stcMDNSSendParameter {
|
||||
protected:
|
||||
/**
|
||||
* stcDomainCacheItem
|
||||
*/
|
||||
typedef struct _stcDomainCacheItem {
|
||||
_stcDomainCacheItem* m_pNext;
|
||||
struct stcDomainCacheItem {
|
||||
stcDomainCacheItem* m_pNext;
|
||||
const void* m_pHostnameOrService; // Opaque id for host or service domain (pointer)
|
||||
bool m_bAdditionalData; // Opaque flag for special info (service domain included)
|
||||
uint16_t m_u16Offset; // Offset in UDP output buffer
|
||||
|
||||
_stcDomainCacheItem(const void* p_pHostnameOrService,
|
||||
stcDomainCacheItem(const void* p_pHostnameOrService,
|
||||
bool p_bAdditionalData,
|
||||
uint32_t p_u16Offset);
|
||||
} stcDomainCacheItem;
|
||||
};
|
||||
|
||||
public:
|
||||
uint16_t m_u16ID; // Query ID (used only in lagacy queries)
|
||||
@ -980,8 +983,8 @@ protected:
|
||||
uint16_t m_u16Offset; // Current offset in UDP write buffer (mainly for domain cache)
|
||||
stcDomainCacheItem* m_pDomainCacheItems; // Cached host and service domains
|
||||
|
||||
_stcMDNSSendParameter(void);
|
||||
~_stcMDNSSendParameter(void);
|
||||
stcMDNSSendParameter(void);
|
||||
~stcMDNSSendParameter(void);
|
||||
|
||||
bool clear(void);
|
||||
|
||||
@ -992,7 +995,7 @@ protected:
|
||||
uint16_t p_u16Offset);
|
||||
uint16_t findCachedDomainOffset(const void* p_pHostnameOrService,
|
||||
bool p_bAdditionalData) const;
|
||||
} stcMDNSSendParameter;
|
||||
};
|
||||
|
||||
// Instance variables
|
||||
stcMDNSService* m_pServices;
|
||||
@ -1247,17 +1250,8 @@ protected:
|
||||
#endif
|
||||
};
|
||||
|
||||
#if !defined(NO_GLOBAL_INSTANCES) && !defined(NO_GLOBAL_MDNS)
|
||||
extern MDNSResponder MDNS;
|
||||
#endif
|
||||
|
||||
} // namespace LEAmDNS
|
||||
|
||||
#endif // LEAMDNS_H
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
}// namespace MDNSImplementation
|
||||
|
||||
}// namespace esp8266
|
||||
|
||||
#endif // MDNS_H
|
||||
|
12
libraries/ESP8266mDNS/src/LEAmDNS_Control.cpp
Executable file → Normal file
12
libraries/ESP8266mDNS/src/LEAmDNS_Control.cpp
Executable file → Normal file
@ -41,11 +41,11 @@ extern "C" {
|
||||
#include "LEAmDNS_lwIPdefs.h"
|
||||
#include "LEAmDNS_Priv.h"
|
||||
|
||||
|
||||
namespace esp8266 {
|
||||
/*
|
||||
* namespace LEAmDNS
|
||||
* LEAmDNS
|
||||
*/
|
||||
namespace LEAmDNS {
|
||||
namespace MDNSImplementation {
|
||||
|
||||
/**
|
||||
* CONTROL
|
||||
@ -1056,6 +1056,7 @@ bool MDNSResponder::_updateProbeStatus(void) {
|
||||
//
|
||||
// Probe host domain
|
||||
if ((ProbingStatus_ReadyToStart == m_HostProbeInformation.m_ProbingStatus) && // Ready to get started AND
|
||||
//TODO: Fix the following to allow Ethernet shield or other interfaces
|
||||
(_getResponseMulticastInterface(SOFTAP_MODE | STATION_MODE) != IPAddress())) { // Has IP address
|
||||
DEBUG_EX_INFO(DEBUG_OUTPUT.printf_P(PSTR_LEA("[MDNSResponder] _updateProbeStatus: Starting host probing...\n")););
|
||||
|
||||
@ -1750,7 +1751,6 @@ uint8_t MDNSResponder::_replyMaskForService(const MDNSResponder::stcMDNS_RRHeade
|
||||
return u8ReplyMask;
|
||||
}
|
||||
|
||||
} // namespace LEAmDNS
|
||||
|
||||
|
||||
} // namespace MDNSImplementation
|
||||
|
||||
} // namespace esp8266
|
||||
|
32
libraries/ESP8266mDNS/src/LEAmDNS_Helpers.cpp
Executable file → Normal file
32
libraries/ESP8266mDNS/src/LEAmDNS_Helpers.cpp
Executable file → Normal file
@ -27,14 +27,8 @@
|
||||
#include "LEAmDNS_lwIPdefs.h"
|
||||
#include "LEAmDNS_Priv.h"
|
||||
|
||||
/*
|
||||
* namespace LEAmDNS
|
||||
*/
|
||||
namespace LEAmDNS {
|
||||
|
||||
/**
|
||||
* HELPERS
|
||||
*/
|
||||
namespace {
|
||||
|
||||
/*
|
||||
* strrstr (static)
|
||||
@ -43,7 +37,7 @@ namespace LEAmDNS {
|
||||
* Based on: https://stackoverflow.com/a/1634398/2778898
|
||||
*
|
||||
*/
|
||||
static const char* strrstr(const char*__restrict p_pcString, const char*__restrict p_pcPattern) {
|
||||
const char* strrstr(const char*__restrict p_pcString, const char*__restrict p_pcPattern) {
|
||||
|
||||
const char* pcResult = 0;
|
||||
|
||||
@ -65,6 +59,24 @@ static const char* strrstr(const char*__restrict p_pcString, const char*__restri
|
||||
return pcResult;
|
||||
}
|
||||
|
||||
|
||||
} // anonymous
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
namespace esp8266 {
|
||||
|
||||
/*
|
||||
* LEAmDNS
|
||||
*/
|
||||
namespace MDNSImplementation {
|
||||
|
||||
/**
|
||||
* HELPERS
|
||||
*/
|
||||
|
||||
/*
|
||||
* MDNSResponder::indexDomain (static)
|
||||
*
|
||||
@ -722,7 +734,9 @@ bool MDNSResponder::_releaseTempServiceTxts(MDNSResponder::stcMDNSService& p_rSe
|
||||
}
|
||||
#endif
|
||||
|
||||
} // namespace LEAmDNS
|
||||
} // namespace MDNSImplementation
|
||||
|
||||
} // namespace esp8266
|
||||
|
||||
|
||||
|
||||
|
21
libraries/ESP8266mDNS/src/LEAmDNS_Priv.h
Executable file → Normal file
21
libraries/ESP8266mDNS/src/LEAmDNS_Priv.h
Executable file → Normal file
@ -22,13 +22,16 @@
|
||||
*
|
||||
*/
|
||||
|
||||
#ifndef LEAMDNS_PRIV_H
|
||||
#define LEAMDNS_PRIV_H
|
||||
#ifndef MDNS_PRIV_H
|
||||
#define MDNS_PRIV_H
|
||||
|
||||
namespace esp8266 {
|
||||
|
||||
/*
|
||||
* namespace LEAmDNS
|
||||
* LEAmDNS
|
||||
*/
|
||||
namespace LEAmDNS {
|
||||
|
||||
namespace MDNSImplementation {
|
||||
|
||||
// Enable class debug functions
|
||||
#define ESP_8266_MDNS_INCLUDE
|
||||
@ -153,16 +156,12 @@ namespace LEAmDNS {
|
||||
#define F(A) A
|
||||
#endif
|
||||
|
||||
} // namespace LEAmDNS
|
||||
} // namespace MDNSImplementation
|
||||
|
||||
} // namespace esp8266
|
||||
|
||||
// Include the main header, so the submodlues only need to include this header
|
||||
#include "LEAmDNS.h"
|
||||
|
||||
|
||||
#endif // LEAMDNS_PRIV_H
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
#endif // MDNS_PRIV_H
|
||||
|
575
libraries/ESP8266mDNS/src/LEAmDNS_Structs.cpp
Executable file → Normal file
575
libraries/ESP8266mDNS/src/LEAmDNS_Structs.cpp
Executable file → Normal file
File diff suppressed because it is too large
Load Diff
12
libraries/ESP8266mDNS/src/LEAmDNS_Transfer.cpp
Executable file → Normal file
12
libraries/ESP8266mDNS/src/LEAmDNS_Transfer.cpp
Executable file → Normal file
@ -30,10 +30,12 @@ extern "C" {
|
||||
#include "LEAmDNS_Priv.h"
|
||||
|
||||
|
||||
namespace esp8266 {
|
||||
|
||||
/*
|
||||
* namespace LEAmDNS
|
||||
* LEAmDNS
|
||||
*/
|
||||
namespace LEAmDNS {
|
||||
namespace MDNSImplementation {
|
||||
|
||||
/**
|
||||
* CONST STRINGS
|
||||
@ -154,7 +156,7 @@ bool MDNSResponder::_prepareMDNSMessage(MDNSResponder::stcMDNSSendParameter& p_r
|
||||
bool bResult = true;
|
||||
|
||||
// Prepare header; count answers
|
||||
_stcMDNS_MsgHeader msgHeader(0, p_rSendParameter.m_bResponse, 0, p_rSendParameter.m_bAuthorative);
|
||||
stcMDNS_MsgHeader msgHeader(0, p_rSendParameter.m_bResponse, 0, p_rSendParameter.m_bAuthorative);
|
||||
// If this is a response, the answers are anwers,
|
||||
// else this is a query or probe and the answers go into auth section
|
||||
uint16_t& ru16Answers = (p_rSendParameter.m_bResponse
|
||||
@ -1627,7 +1629,9 @@ bool MDNSResponder::_writeMDNSAnswer_SRV(MDNSResponder::stcMDNSService& p_rServi
|
||||
return bResult;
|
||||
}
|
||||
|
||||
} // namespace LEAmDNS
|
||||
} // namespace MDNSImplementation
|
||||
|
||||
} // namespace esp8266
|
||||
|
||||
|
||||
|
||||
|
@ -22,8 +22,8 @@
|
||||
*
|
||||
*/
|
||||
|
||||
#ifndef LEAMDNS_LWIPDEFS_H
|
||||
#define LEAMDNS_LWIPDEFS_H
|
||||
#ifndef MDNS_LWIPDEFS_H
|
||||
#define MDNS_LWIPDEFS_H
|
||||
|
||||
#include <lwip/init.h>
|
||||
#if LWIP_VERSION_MAJOR == 1
|
||||
@ -41,4 +41,4 @@
|
||||
|
||||
#endif
|
||||
|
||||
#endif // LEAMDNS_LWIPDEFS_H
|
||||
#endif // MDNS_LWIPDEFS_H
|
||||
|
Loading…
x
Reference in New Issue
Block a user