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