mirror of
https://github.com/esp8266/Arduino.git
synced 2025-07-30 16:24:09 +03:00
Merge branch 'master' into feature/issue-2246-multi-wifi-hidden
This commit is contained in:
@ -35,17 +35,11 @@ extern "C" uint32_t _EEPROM_start;
|
||||
|
||||
EEPROMClass::EEPROMClass(uint32_t sector)
|
||||
: _sector(sector)
|
||||
, _data(0)
|
||||
, _size(0)
|
||||
, _dirty(false)
|
||||
{
|
||||
}
|
||||
|
||||
EEPROMClass::EEPROMClass(void)
|
||||
: _sector((((uint32_t)&_EEPROM_start - 0x40200000) / SPI_FLASH_SEC_SIZE))
|
||||
, _data(0)
|
||||
, _size(0)
|
||||
, _dirty(false)
|
||||
{
|
||||
}
|
||||
|
||||
|
@ -68,9 +68,9 @@ public:
|
||||
|
||||
protected:
|
||||
uint32_t _sector;
|
||||
uint8_t* _data;
|
||||
size_t _size;
|
||||
bool _dirty;
|
||||
uint8_t* _data = nullptr;
|
||||
size_t _size = 0;
|
||||
bool _dirty = false;
|
||||
};
|
||||
|
||||
#if !defined(NO_GLOBAL_INSTANCES) && !defined(NO_GLOBAL_EEPROM)
|
||||
|
@ -47,12 +47,10 @@ extern "C" {
|
||||
#include "include/UdpContext.h"
|
||||
//#define DEBUG_SSDP Serial
|
||||
|
||||
#define SSDP_INTERVAL 1200
|
||||
#define SSDP_PORT 1900
|
||||
#define SSDP_METHOD_SIZE 10
|
||||
#define SSDP_URI_SIZE 2
|
||||
#define SSDP_BUFFER_SIZE 64
|
||||
#define SSDP_MULTICAST_TTL 2
|
||||
|
||||
// ssdp ipv6 is FF05::C
|
||||
// lwip-v2's igmp_joingroup only supports IPv4
|
||||
@ -125,19 +123,8 @@ struct SSDPTimer {
|
||||
ETSTimer timer;
|
||||
};
|
||||
|
||||
SSDPClass::SSDPClass() :
|
||||
_server(0),
|
||||
_timer(0),
|
||||
_port(80),
|
||||
_ttl(SSDP_MULTICAST_TTL),
|
||||
_interval(SSDP_INTERVAL),
|
||||
_respondToAddr(0,0,0,0),
|
||||
_respondToPort(0),
|
||||
_pending(false),
|
||||
_st_is_uuid(false),
|
||||
_delay(0),
|
||||
_process_time(0),
|
||||
_notify_time(0)
|
||||
SSDPClass::SSDPClass()
|
||||
: _respondToAddr(0,0,0,0)
|
||||
{
|
||||
_uuid[0] = '\0';
|
||||
_modelNumber[0] = '\0';
|
||||
|
@ -46,6 +46,9 @@ class UdpContext;
|
||||
#define SSDP_MODEL_VERSION_SIZE 32
|
||||
#define SSDP_MANUFACTURER_SIZE 64
|
||||
#define SSDP_MANUFACTURER_URL_SIZE 128
|
||||
#define SSDP_INTERVAL_SECONDS 1200
|
||||
#define SSDP_MULTICAST_TTL 2
|
||||
#define SSDP_HTTP_PORT 80
|
||||
|
||||
typedef enum {
|
||||
NONE,
|
||||
@ -101,20 +104,20 @@ class SSDPClass{
|
||||
void _stopTimer();
|
||||
static void _onTimerStatic(SSDPClass* self);
|
||||
|
||||
UdpContext* _server;
|
||||
SSDPTimer* _timer;
|
||||
uint16_t _port;
|
||||
uint8_t _ttl;
|
||||
uint32_t _interval;
|
||||
UdpContext* _server = nullptr;
|
||||
SSDPTimer* _timer = nullptr;
|
||||
uint16_t _port = SSDP_HTTP_PORT;
|
||||
uint8_t _ttl = SSDP_MULTICAST_TTL;
|
||||
uint32_t _interval = SSDP_INTERVAL_SECONDS;
|
||||
|
||||
IPAddress _respondToAddr;
|
||||
uint16_t _respondToPort;
|
||||
uint16_t _respondToPort = 0;
|
||||
|
||||
bool _pending;
|
||||
bool _st_is_uuid;
|
||||
unsigned short _delay;
|
||||
unsigned long _process_time;
|
||||
unsigned long _notify_time;
|
||||
bool _pending = false;
|
||||
bool _st_is_uuid = false;
|
||||
unsigned short _delay = 0;
|
||||
unsigned long _process_time = 0;
|
||||
unsigned long _notify_time = 0;
|
||||
|
||||
char _schemaURL[SSDP_SCHEMA_URL_SIZE];
|
||||
char _uuid[SSDP_UUID_SIZE];
|
||||
|
@ -39,47 +39,12 @@ namespace esp8266webserver {
|
||||
template <typename ServerType>
|
||||
ESP8266WebServerTemplate<ServerType>::ESP8266WebServerTemplate(IPAddress addr, int port)
|
||||
: _server(addr, port)
|
||||
, _currentMethod(HTTP_ANY)
|
||||
, _currentVersion(0)
|
||||
, _currentStatus(HC_NONE)
|
||||
, _statusChange(0)
|
||||
, _keepAlive(false)
|
||||
, _currentHandler(nullptr)
|
||||
, _firstHandler(nullptr)
|
||||
, _lastHandler(nullptr)
|
||||
, _currentArgCount(0)
|
||||
, _currentArgs(nullptr)
|
||||
, _currentArgsHavePlain(0)
|
||||
, _postArgsLen(0)
|
||||
, _postArgs(nullptr)
|
||||
, _headerKeysCount(0)
|
||||
, _currentHeaders(nullptr)
|
||||
, _contentLength(0)
|
||||
, _chunked(false)
|
||||
, _corsEnabled(false)
|
||||
{
|
||||
}
|
||||
|
||||
template <typename ServerType>
|
||||
ESP8266WebServerTemplate<ServerType>::ESP8266WebServerTemplate(int port)
|
||||
: _server(port)
|
||||
, _currentMethod(HTTP_ANY)
|
||||
, _currentVersion(0)
|
||||
, _currentStatus(HC_NONE)
|
||||
, _statusChange(0)
|
||||
, _currentHandler(nullptr)
|
||||
, _firstHandler(nullptr)
|
||||
, _lastHandler(nullptr)
|
||||
, _currentArgCount(0)
|
||||
, _currentArgs(nullptr)
|
||||
, _currentArgsHavePlain(0)
|
||||
, _postArgsLen(0)
|
||||
, _postArgs(nullptr)
|
||||
, _headerKeysCount(0)
|
||||
, _currentHeaders(nullptr)
|
||||
, _contentLength(0)
|
||||
, _chunked(false)
|
||||
, _corsEnabled(false)
|
||||
{
|
||||
}
|
||||
|
||||
|
@ -263,35 +263,35 @@ protected:
|
||||
|
||||
ServerType _server;
|
||||
ClientType _currentClient;
|
||||
HTTPMethod _currentMethod;
|
||||
HTTPMethod _currentMethod = HTTP_ANY;
|
||||
String _currentUri;
|
||||
uint8_t _currentVersion;
|
||||
HTTPClientStatus _currentStatus;
|
||||
unsigned long _statusChange;
|
||||
bool _keepAlive;
|
||||
uint8_t _currentVersion = 0;
|
||||
HTTPClientStatus _currentStatus = HC_NONE;
|
||||
unsigned long _statusChange = 0;
|
||||
|
||||
RequestHandlerType* _currentHandler;
|
||||
RequestHandlerType* _firstHandler;
|
||||
RequestHandlerType* _lastHandler;
|
||||
RequestHandlerType* _currentHandler = nullptr;
|
||||
RequestHandlerType* _firstHandler = nullptr;
|
||||
RequestHandlerType* _lastHandler = nullptr;
|
||||
THandlerFunction _notFoundHandler;
|
||||
THandlerFunction _fileUploadHandler;
|
||||
|
||||
int _currentArgCount;
|
||||
RequestArgument* _currentArgs;
|
||||
int _currentArgsHavePlain;
|
||||
int _currentArgCount = 0;
|
||||
RequestArgument* _currentArgs = nullptr;
|
||||
int _currentArgsHavePlain = 0;
|
||||
std::unique_ptr<HTTPUpload> _currentUpload;
|
||||
int _postArgsLen;
|
||||
RequestArgument* _postArgs;
|
||||
int _postArgsLen = 0;
|
||||
RequestArgument* _postArgs = nullptr;
|
||||
|
||||
int _headerKeysCount;
|
||||
RequestArgument* _currentHeaders;
|
||||
int _headerKeysCount = 0;
|
||||
RequestArgument* _currentHeaders = nullptr;
|
||||
|
||||
size_t _contentLength;
|
||||
size_t _contentLength = 0;
|
||||
String _responseHeaders;
|
||||
|
||||
String _hostHeader;
|
||||
bool _chunked;
|
||||
bool _corsEnabled;
|
||||
bool _chunked = false;
|
||||
bool _corsEnabled = false;
|
||||
bool _keepAlive = false;
|
||||
|
||||
String _snonce; // Store noance and opaque for future comparison
|
||||
String _sopaque;
|
||||
|
@ -21,7 +21,7 @@
|
||||
#include <memory>
|
||||
|
||||
|
||||
#ifdef DEBUG_ESP_SSL
|
||||
#if defined(DEBUG_ESP_SSL) && defined(DEBUG_ESP_PORT)
|
||||
#define DEBUG_BSSL(fmt, ...) DEBUG_ESP_PORT.printf_P((PGM_P)PSTR( "BSSL:" fmt), ## __VA_ARGS__)
|
||||
#else
|
||||
#define DEBUG_BSSL(...)
|
||||
|
@ -827,15 +827,21 @@ bool ESP8266WiFiGenericClass::resumeFromShutdown (WiFiState* state)
|
||||
}
|
||||
}
|
||||
// state->state.fwconfig.bssid is not real bssid (it's what user may have provided when bssid_set==1)
|
||||
if (WiFi.begin((const char*)state->state.fwconfig.ssid,
|
||||
auto beginResult = WiFi.begin((const char*)state->state.fwconfig.ssid,
|
||||
(const char*)state->state.fwconfig.password,
|
||||
state->state.channel,
|
||||
nullptr/*(const uint8_t*)state->state.fwconfig.bssid*/, // <- try with gw's mac address?
|
||||
true) == WL_CONNECT_FAILED)
|
||||
true);
|
||||
if (beginResult == WL_CONNECT_FAILED)
|
||||
{
|
||||
DEBUG_WIFI("core: resume: WiFi.begin failed\n");
|
||||
return false;
|
||||
}
|
||||
if (beginResult == WL_WRONG_PASSWORD)
|
||||
{
|
||||
DEBUG_WIFI("core: resume: WiFi.begin wrong password\n");
|
||||
return false;
|
||||
}
|
||||
}
|
||||
|
||||
if (state->state.mode & WIFI_AP)
|
||||
|
@ -60,6 +60,9 @@ static void printWiFiStatus(wl_status_t status)
|
||||
case WL_CONNECT_FAILED:
|
||||
DEBUG_WIFI_MULTI("[WIFIM] Connecting failed.\n");
|
||||
break;
|
||||
case WL_WRONG_PASSWORD:
|
||||
DEBUG_WIFI_MULTI("[WIFIM] Wrong password.\n");
|
||||
break;
|
||||
default:
|
||||
DEBUG_WIFI_MULTI("[WIFIM] Connecting failed (%d).\n", status);
|
||||
break;
|
||||
|
@ -624,8 +624,9 @@ wl_status_t ESP8266WiFiSTAClass::status() {
|
||||
case STATION_NO_AP_FOUND:
|
||||
return WL_NO_SSID_AVAIL;
|
||||
case STATION_CONNECT_FAIL:
|
||||
case STATION_WRONG_PASSWORD:
|
||||
return WL_CONNECT_FAILED;
|
||||
case STATION_WRONG_PASSWORD:
|
||||
return WL_WRONG_PASSWORD;
|
||||
case STATION_IDLE:
|
||||
return WL_IDLE_STATUS;
|
||||
default:
|
||||
|
@ -59,7 +59,7 @@ extern "C" {
|
||||
|
||||
#endif
|
||||
|
||||
#ifdef DEBUG_ESP_SSL
|
||||
#if defined(DEBUG_ESP_SSL) && defined(DEBUG_ESP_PORT)
|
||||
#define DEBUG_BSSL(fmt, ...) DEBUG_ESP_PORT.printf_P((PGM_P)PSTR( "BSSL:" fmt), ## __VA_ARGS__)
|
||||
#else
|
||||
#define DEBUG_BSSL(...)
|
||||
@ -664,7 +664,7 @@ extern "C" {
|
||||
if (!xc->done_cert) {
|
||||
br_sha1_update(&xc->sha1_cert, buf, len);
|
||||
br_x509_decoder_push(&xc->ctx, (const void*)buf, len);
|
||||
#ifdef DEBUG_ESP_SSL
|
||||
#if defined(DEBUG_ESP_SSL) && defined(DEBUG_ESP_PORT)
|
||||
DEBUG_BSSL("CERT: ");
|
||||
for (size_t i=0; i<len; i++) {
|
||||
DEBUG_ESP_PORT.printf_P(PSTR("%02x "), buf[i] & 0xff);
|
||||
|
@ -44,18 +44,12 @@ extern "C" {
|
||||
WiFiServer::WiFiServer(const IPAddress& addr, uint16_t port)
|
||||
: _port(port)
|
||||
, _addr(addr)
|
||||
, _listen_pcb(nullptr)
|
||||
, _unclaimed(nullptr)
|
||||
, _discarded(nullptr)
|
||||
{
|
||||
}
|
||||
|
||||
WiFiServer::WiFiServer(uint16_t port)
|
||||
: _port(port)
|
||||
, _addr(IP_ANY_TYPE)
|
||||
, _listen_pcb(nullptr)
|
||||
, _unclaimed(nullptr)
|
||||
, _discarded(nullptr)
|
||||
{
|
||||
}
|
||||
|
||||
|
@ -70,10 +70,10 @@ class WiFiServer : public Server {
|
||||
protected:
|
||||
uint16_t _port;
|
||||
IPAddress _addr;
|
||||
tcp_pcb* _listen_pcb;
|
||||
tcp_pcb* _listen_pcb = nullptr;
|
||||
|
||||
ClientContext* _unclaimed;
|
||||
ClientContext* _discarded;
|
||||
ClientContext* _unclaimed = nullptr;
|
||||
ClientContext* _discarded = nullptr;
|
||||
enum { _ndDefault, _ndFalse, _ndTrue } _noDelay = _ndDefault;
|
||||
|
||||
public:
|
||||
|
@ -55,7 +55,8 @@ typedef enum {
|
||||
WL_CONNECTED = 3,
|
||||
WL_CONNECT_FAILED = 4,
|
||||
WL_CONNECTION_LOST = 5,
|
||||
WL_DISCONNECTED = 6
|
||||
WL_WRONG_PASSWORD = 6,
|
||||
WL_DISCONNECTED = 7
|
||||
} wl_status_t;
|
||||
|
||||
/* Encryption modes */
|
||||
|
@ -27,7 +27,8 @@
|
||||
|
||||
#include "ESP8266mDNS.h"
|
||||
#include "LEAmDNS_Priv.h"
|
||||
|
||||
#include <LwipIntf.h> // LwipIntf::stateUpCB()
|
||||
#include "lwip/igmp.h"
|
||||
|
||||
namespace esp8266
|
||||
{
|
||||
@ -61,13 +62,7 @@ MDNSResponder::MDNSResponder(void)
|
||||
m_pUDPContext(0),
|
||||
m_pcHostname(0),
|
||||
m_pServiceQueries(0),
|
||||
m_fnServiceTxtCallback(0),
|
||||
#ifdef ENABLE_ESP_MDNS_RESPONDER_PASSIV_MODE
|
||||
m_bPassivModeEnabled(true),
|
||||
#else
|
||||
m_bPassivModeEnabled(false),
|
||||
#endif
|
||||
m_netif(nullptr)
|
||||
m_fnServiceTxtCallback(0)
|
||||
{
|
||||
}
|
||||
|
||||
@ -93,104 +88,29 @@ MDNSResponder::~MDNSResponder(void)
|
||||
Finally the responder is (re)started
|
||||
|
||||
*/
|
||||
bool MDNSResponder::begin(const char* p_pcHostname, const IPAddress& p_IPAddress, uint32_t p_u32TTL)
|
||||
bool MDNSResponder::begin(const char* p_pcHostname, const IPAddress& /*p_IPAddress*/, uint32_t /*p_u32TTL*/)
|
||||
{
|
||||
|
||||
(void)p_u32TTL; // ignored
|
||||
bool bResult = false;
|
||||
|
||||
if (0 == m_pUDPContext)
|
||||
if (_setHostname(p_pcHostname))
|
||||
{
|
||||
if (_setHostname(p_pcHostname))
|
||||
{
|
||||
|
||||
//// select interface
|
||||
|
||||
m_netif = nullptr;
|
||||
IPAddress ipAddress = p_IPAddress;
|
||||
|
||||
if (!ipAddress.isSet())
|
||||
{
|
||||
|
||||
IPAddress sta = WiFi.localIP();
|
||||
IPAddress ap = WiFi.softAPIP();
|
||||
|
||||
if (sta.isSet())
|
||||
{
|
||||
DEBUG_EX_INFO(DEBUG_OUTPUT.printf_P(PSTR("[MDNSResponder] STA interface selected\n")));
|
||||
ipAddress = sta;
|
||||
}
|
||||
else if (ap.isSet())
|
||||
{
|
||||
DEBUG_EX_INFO(DEBUG_OUTPUT.printf_P(PSTR("[MDNSResponder] AP interface selected\n")));
|
||||
ipAddress = ap;
|
||||
}
|
||||
else
|
||||
{
|
||||
DEBUG_EX_INFO(DEBUG_OUTPUT.printf_P(PSTR("[MDNSResponder] standard interfaces are not up, please specify one in ::begin()\n")));
|
||||
return false;
|
||||
}
|
||||
|
||||
// continue to ensure interface is UP
|
||||
}
|
||||
|
||||
// check existence of this IP address in the interface list
|
||||
bool found = false;
|
||||
m_netif = nullptr;
|
||||
for (auto a : addrList)
|
||||
if (ipAddress == a.addr())
|
||||
{
|
||||
if (a.ifUp())
|
||||
{
|
||||
found = true;
|
||||
m_netif = a.interface();
|
||||
break;
|
||||
}
|
||||
DEBUG_EX_INFO(DEBUG_OUTPUT.printf_P(PSTR("[MDNSResponder] found interface for IP '%s' but it is not UP\n"), ipAddress.toString().c_str()););
|
||||
}
|
||||
if (!found)
|
||||
{
|
||||
DEBUG_EX_INFO(DEBUG_OUTPUT.printf_P(PSTR("[MDNSResponder] interface defined by IP '%s' not found\n"), ipAddress.toString().c_str()););
|
||||
return false;
|
||||
}
|
||||
|
||||
//// done selecting the interface
|
||||
|
||||
if (m_netif->num == STATION_IF)
|
||||
{
|
||||
|
||||
m_GotIPHandler = WiFi.onStationModeGotIP([this](const WiFiEventStationModeGotIP & pEvent)
|
||||
{
|
||||
(void) pEvent;
|
||||
// Ensure that _restart() runs in USER context
|
||||
schedule_function([this]()
|
||||
{
|
||||
MDNSResponder::_restart();
|
||||
});
|
||||
});
|
||||
|
||||
m_DisconnectedHandler = WiFi.onStationModeDisconnected([this](const WiFiEventStationModeDisconnected & pEvent)
|
||||
{
|
||||
(void) pEvent;
|
||||
// Ensure that _restart() runs in USER context
|
||||
schedule_function([this]()
|
||||
{
|
||||
MDNSResponder::_restart();
|
||||
});
|
||||
});
|
||||
}
|
||||
|
||||
bResult = _restart();
|
||||
}
|
||||
DEBUG_EX_ERR(if (!bResult)
|
||||
{
|
||||
DEBUG_OUTPUT.printf_P(PSTR("[MDNSResponder] begin: FAILED for '%s'!\n"), (p_pcHostname ? : "-"));
|
||||
});
|
||||
bResult = _restart();
|
||||
}
|
||||
else
|
||||
|
||||
LwipIntf::stateUpCB
|
||||
(
|
||||
[this](netif * intf)
|
||||
{
|
||||
DEBUG_EX_INFO(DEBUG_OUTPUT.printf_P(PSTR("[MDNSResponder] begin: Ignoring multiple calls to begin (Ignored host domain: '%s')!\n"), (p_pcHostname ? : "-")););
|
||||
(void)intf;
|
||||
DEBUG_EX_INFO(DEBUG_OUTPUT.printf_P(PSTR("[MDNSResponder] new Interface '%c%c' is UP! restarting\n"), intf->name[0], intf->name[1]));
|
||||
_restart();
|
||||
}
|
||||
);
|
||||
DEBUG_EX_ERR(if (!bResult)
|
||||
{
|
||||
DEBUG_OUTPUT.printf_P(PSTR("[MDNSResponder] begin: FAILED for '%s'!\n"), (p_pcHostname ? : "-"));
|
||||
});
|
||||
|
||||
return bResult;
|
||||
}
|
||||
|
||||
@ -207,9 +127,6 @@ bool MDNSResponder::close(void)
|
||||
|
||||
if (0 != m_pUDPContext)
|
||||
{
|
||||
m_GotIPHandler.reset(); // reset WiFi event callbacks.
|
||||
m_DisconnectedHandler.reset();
|
||||
|
||||
_announce(false, true);
|
||||
_resetProbeStatus(false); // Stop probing
|
||||
_releaseServiceQueries();
|
||||
@ -1329,11 +1246,6 @@ bool MDNSResponder::notifyAPChange(void)
|
||||
*/
|
||||
bool MDNSResponder::update(void)
|
||||
{
|
||||
|
||||
if (m_bPassivModeEnabled)
|
||||
{
|
||||
m_bPassivModeEnabled = false;
|
||||
}
|
||||
return _process(true);
|
||||
}
|
||||
|
||||
@ -1374,6 +1286,94 @@ MDNSResponder::hMDNSService MDNSResponder::enableArduino(uint16_t p_u16Port,
|
||||
return hService;
|
||||
}
|
||||
|
||||
/*
|
||||
|
||||
MULTICAST GROUPS
|
||||
|
||||
*/
|
||||
|
||||
/*
|
||||
MDNSResponder::_joinMulticastGroups
|
||||
*/
|
||||
bool MDNSResponder::_joinMulticastGroups(void)
|
||||
{
|
||||
bool bResult = false;
|
||||
|
||||
// Join multicast group(s)
|
||||
for (netif* pNetIf = netif_list; pNetIf; pNetIf = pNetIf->next)
|
||||
{
|
||||
if (netif_is_up(pNetIf))
|
||||
{
|
||||
#ifdef MDNS_IPV4_SUPPORT
|
||||
ip_addr_t multicast_addr_V4 = DNS_MQUERY_IPV4_GROUP_INIT;
|
||||
if (!(pNetIf->flags & NETIF_FLAG_IGMP))
|
||||
{
|
||||
DEBUG_EX_ERR(DEBUG_OUTPUT.printf_P(PSTR("[MDNSResponder] _createHost: Setting flag: flags & NETIF_FLAG_IGMP\n")););
|
||||
pNetIf->flags |= NETIF_FLAG_IGMP;
|
||||
|
||||
if (ERR_OK != igmp_start(pNetIf))
|
||||
{
|
||||
DEBUG_EX_ERR(DEBUG_OUTPUT.printf_P(PSTR("[MDNSResponder] _createHost: igmp_start FAILED!\n")););
|
||||
}
|
||||
}
|
||||
|
||||
if ((ERR_OK == igmp_joingroup_netif(pNetIf, ip_2_ip4(&multicast_addr_V4))))
|
||||
{
|
||||
bResult = true;
|
||||
}
|
||||
else
|
||||
{
|
||||
DEBUG_EX_ERR(DEBUG_OUTPUT.printf_P(PSTR("[MDNSResponder] _createHost: igmp_joingroup_netif(" NETIFID_STR ": %s) FAILED!\n"),
|
||||
NETIFID_VAL(pNetIf), IPAddress(multicast_addr_V4).toString().c_str()););
|
||||
}
|
||||
#endif
|
||||
|
||||
#ifdef MDNS_IPV6_SUPPORT
|
||||
ip_addr_t multicast_addr_V6 = DNS_MQUERY_IPV6_GROUP_INIT;
|
||||
bResult = ((bResult) &&
|
||||
(ERR_OK == mld6_joingroup_netif(pNetIf, ip_2_ip6(&multicast_addr_V6))));
|
||||
DEBUG_EX_ERR_IF(!bResult, DEBUG_OUTPUT.printf_P(PSTR("[MDNSResponder] _createHost: mld6_joingroup_netif (" NETIFID_STR ") FAILED!\n"),
|
||||
NETIFID_VAL(pNetIf)));
|
||||
#endif
|
||||
}
|
||||
}
|
||||
return bResult;
|
||||
}
|
||||
|
||||
/*
|
||||
clsLEAmDNS2_Host::_leaveMulticastGroups
|
||||
*/
|
||||
bool MDNSResponder::_leaveMulticastGroups()
|
||||
{
|
||||
bool bResult = false;
|
||||
|
||||
for (netif* pNetIf = netif_list; pNetIf; pNetIf = pNetIf->next)
|
||||
{
|
||||
if (netif_is_up(pNetIf))
|
||||
{
|
||||
bResult = true;
|
||||
|
||||
// Leave multicast group(s)
|
||||
#ifdef MDNS_IPV4_SUPPORT
|
||||
ip_addr_t multicast_addr_V4 = DNS_MQUERY_IPV4_GROUP_INIT;
|
||||
if (ERR_OK != igmp_leavegroup_netif(pNetIf, ip_2_ip4(&multicast_addr_V4)))
|
||||
{
|
||||
DEBUG_EX_ERR(DEBUG_OUTPUT.printf_P(PSTR("\n")););
|
||||
}
|
||||
#endif
|
||||
#ifdef MDNS_IPV6_SUPPORT
|
||||
ip_addr_t multicast_addr_V6 = DNS_MQUERY_IPV6_GROUP_INIT;
|
||||
if (ERR_OK != mld6_leavegroup_netif(pNetIf, ip_2_ip6(&multicast_addr_V6)/*&(multicast_addr_V6.u_addr.ip6)*/))
|
||||
{
|
||||
DEBUG_EX_ERR(DEBUG_OUTPUT.printf_P(PSTR("\n")););
|
||||
}
|
||||
#endif
|
||||
}
|
||||
}
|
||||
return bResult;
|
||||
}
|
||||
|
||||
|
||||
|
||||
} //namespace MDNSImplementation
|
||||
|
||||
|
@ -164,6 +164,10 @@ namespace MDNSImplementation
|
||||
*/
|
||||
#define MDNS_QUERYSERVICES_WAIT_TIME 1000
|
||||
|
||||
/*
|
||||
Timeout for udpContext->sendtimeout()
|
||||
*/
|
||||
#define MDNS_UDPCONTEXT_TIMEOUT 50
|
||||
|
||||
/**
|
||||
MDNSResponder
|
||||
@ -185,6 +189,8 @@ public:
|
||||
{
|
||||
return begin(p_strHostname.c_str(), p_IPAddress, p_u32TTL);
|
||||
}
|
||||
bool _joinMulticastGroups(void);
|
||||
bool _leaveMulticastGroups(void);
|
||||
|
||||
// Finish MDNS processing
|
||||
bool close(void);
|
||||
@ -1184,6 +1190,7 @@ protected:
|
||||
~stcMDNSSendParameter(void);
|
||||
|
||||
bool clear(void);
|
||||
bool clearCachedNames(void);
|
||||
|
||||
bool shiftOffset(uint16_t p_u16Shift);
|
||||
|
||||
@ -1199,12 +1206,8 @@ protected:
|
||||
UdpContext* m_pUDPContext;
|
||||
char* m_pcHostname;
|
||||
stcMDNSServiceQuery* m_pServiceQueries;
|
||||
WiFiEventHandler m_DisconnectedHandler;
|
||||
WiFiEventHandler m_GotIPHandler;
|
||||
MDNSDynamicServiceTxtCallbackFunc m_fnServiceTxtCallback;
|
||||
bool m_bPassivModeEnabled;
|
||||
stcProbeInformation m_HostProbeInformation;
|
||||
const netif* m_netif; // network interface to run on
|
||||
|
||||
/** CONTROL **/
|
||||
/* MAINTENANCE */
|
||||
@ -1259,11 +1262,6 @@ protected:
|
||||
uint16_t p_u16QueryType,
|
||||
stcMDNSServiceQuery::stcAnswer* p_pKnownAnswers = 0);
|
||||
|
||||
const IPAddress _getResponseMulticastInterface() const
|
||||
{
|
||||
return IPAddress(m_netif->ip_addr);
|
||||
}
|
||||
|
||||
uint8_t _replyMaskForHost(const stcMDNS_RRHeader& p_RRHeader,
|
||||
bool* p_pbFullNameMatch = 0) const;
|
||||
uint8_t _replyMaskForService(const stcMDNS_RRHeader& p_RRHeader,
|
||||
|
@ -33,7 +33,7 @@
|
||||
#ifdef MDNS_IPV4_SUPPORT
|
||||
#include <lwip/igmp.h>
|
||||
#endif
|
||||
#ifdef MDNS_IPV6_SUPPORT
|
||||
#ifdef MDNS2_IPV6_SUPPORT
|
||||
#include <lwip/mld6.h>
|
||||
#endif
|
||||
|
||||
@ -172,7 +172,7 @@ const char* clsLEAMDNSHost::clsConsts::pcUDP = "udp";
|
||||
#ifdef MDNS_IPV4_SUPPORT
|
||||
const char* clsLEAMDNSHost::clsConsts::pcReverseIPv4Domain = "in-addr";
|
||||
#endif
|
||||
#ifdef MDNS_IPV6_SUPPORT
|
||||
#ifdef MDNS2_IPV6_SUPPORT
|
||||
const char* clsLEAMDNSHost::clsConsts::pcReverseIPv6Domain = "ip6";
|
||||
#endif
|
||||
const char* clsLEAMDNSHost::clsConsts::pcReverseTopDomain = "arpa";
|
||||
@ -904,7 +904,7 @@ bool clsLEAMDNSHost::_joinMulticastGroups(void)
|
||||
}
|
||||
#endif
|
||||
|
||||
#ifdef MDNS_IPV6_SUPPORT
|
||||
#ifdef MDNS2_IPV6_SUPPORT
|
||||
ip_addr_t multicast_addr_V6 = DNS_MQUERY_IPV6_GROUP_INIT;
|
||||
bResult = ((bResult) &&
|
||||
(ERR_OK == mld6_joingroup_netif(pNetIf, ip_2_ip6(&multicast_addr_V6))));
|
||||
@ -937,7 +937,7 @@ bool clsLEAMDNSHost::_leaveMulticastGroups()
|
||||
DEBUG_EX_ERR(DEBUG_OUTPUT.printf_P(PSTR("\n")););
|
||||
}
|
||||
#endif
|
||||
#ifdef MDNS_IPV6_SUPPORT
|
||||
#ifdef MDNS2_IPV6_SUPPORT
|
||||
ip_addr_t multicast_addr_V6 = DNS_MQUERY_IPV6_GROUP_INIT;
|
||||
if (ERR_OK != mld6_leavegroup_netif(pNetIf, ip_2_ip6(&multicast_addr_V6)/*&(multicast_addr_V6.u_addr.ip6)*/))
|
||||
{
|
||||
|
@ -110,7 +110,7 @@
|
||||
|
||||
#define MDNS_IPV4_SUPPORT
|
||||
#if LWIP_IPV6
|
||||
#define MDNS_IPV6_SUPPORT // If we've got IPv6 support, then we need IPv6 support :-)
|
||||
#define MDNS2_IPV6_SUPPORT // If we've got IPv6 support, then we need IPv6 support :-)
|
||||
#endif
|
||||
|
||||
namespace esp8266
|
||||
@ -136,7 +136,7 @@ protected:
|
||||
#ifdef MDNS_IPV4_SUPPORT
|
||||
static constexpr uint16_t u16IPv4Size = 4; // IPv4 address size in bytes
|
||||
#endif
|
||||
#ifdef MDNS_IPV6_SUPPORT
|
||||
#ifdef MDNS2_IPV6_SUPPORT
|
||||
static constexpr uint16_t u16IPv6Size = 16; // IPv6 address size in bytes
|
||||
#endif
|
||||
static constexpr size_t stServiceTxtMaxLength = 1300; // Maximum length for all service txts for one service
|
||||
@ -168,7 +168,7 @@ protected:
|
||||
#ifdef MDNS_IPV4_SUPPORT
|
||||
static const char* pcReverseIPv4Domain; // "in-addr";
|
||||
#endif
|
||||
#ifdef MDNS_IPV6_SUPPORT
|
||||
#ifdef MDNS2_IPV6_SUPPORT
|
||||
static const char* pcReverseIPv6Domain; // "ip6";
|
||||
#endif
|
||||
static const char* pcReverseTopDomain; // "arpa";
|
||||
@ -246,7 +246,7 @@ protected:
|
||||
#ifdef MDNS_IPV4_SUPPORT
|
||||
V4 = 0x01,
|
||||
#endif
|
||||
#ifdef MDNS_IPV6_SUPPORT
|
||||
#ifdef MDNS2_IPV6_SUPPORT
|
||||
V6 = 0x02,
|
||||
#endif
|
||||
};
|
||||
@ -784,7 +784,7 @@ protected:
|
||||
bool clear(void);
|
||||
};
|
||||
|
||||
#ifdef MDNS_IPV6_SUPPORT
|
||||
#ifdef MDNS2_IPV6_SUPPORT
|
||||
/**
|
||||
clsRRAnswerAAAA
|
||||
*/
|
||||
@ -935,7 +935,7 @@ public:
|
||||
#ifdef MDNS_IPV4_SUPPORT
|
||||
IPv4Address = 0x10, // IPv4 address
|
||||
#endif
|
||||
#ifdef MDNS_IPV6_SUPPORT
|
||||
#ifdef MDNS2_IPV6_SUPPORT
|
||||
IPv6Address = 0x20, // IPv6 address
|
||||
#endif
|
||||
};
|
||||
@ -1004,7 +1004,7 @@ public:
|
||||
#ifdef MDNS_IPV4_SUPPORT
|
||||
clsIPAddressWithTTL::list m_IPv4Addresses; // 3. level answer (A, using host domain), eg. 123.456.789.012
|
||||
#endif
|
||||
#ifdef MDNS_IPV6_SUPPORT
|
||||
#ifdef MDNS2_IPV6_SUPPORT
|
||||
clsIPAddressWithTTL::list m_IPv6Addresses; // 3. level answer (AAAA, using host domain), eg. 1234::09
|
||||
#endif
|
||||
typeQueryAnswerType m_QueryAnswerFlags; // enuQueryAnswerType
|
||||
@ -1029,7 +1029,7 @@ public:
|
||||
const clsIPAddressWithTTL* IPv4AddressAtIndex(uint32_t p_u32Index) const;
|
||||
clsIPAddressWithTTL* IPv4AddressAtIndex(uint32_t p_u32Index);
|
||||
#endif
|
||||
#ifdef MDNS_IPV6_SUPPORT
|
||||
#ifdef MDNS2_IPV6_SUPPORT
|
||||
bool releaseIPv6Addresses(void);
|
||||
bool addIPv6Address(clsIPAddressWithTTL* p_pIPAddress);
|
||||
bool removeIPv6Address(clsIPAddressWithTTL* p_pIPAddress);
|
||||
@ -1081,7 +1081,7 @@ public:
|
||||
bool IPv4AddressAvailable(void) const;
|
||||
clsIPAddressVector IPv4Addresses(void) const;
|
||||
#endif
|
||||
#ifdef MDNS_IPV6_SUPPORT
|
||||
#ifdef MDNS2_IPV6_SUPPORT
|
||||
bool IPv6AddressAvailable(void) const;
|
||||
clsIPAddressVector IPv6Addresses(void) const;
|
||||
#endif
|
||||
@ -1362,7 +1362,7 @@ protected:
|
||||
#ifdef MDNS_IPV4_SUPPORT
|
||||
bool _processAAnswer(const clsRRAnswerA* p_pAAnswer);
|
||||
#endif
|
||||
#ifdef MDNS_IPV6_SUPPORT
|
||||
#ifdef MDNS2_IPV6_SUPPORT
|
||||
bool _processAAAAAnswer(const clsRRAnswerAAAA* p_pAAAAAnswer);
|
||||
#endif
|
||||
|
||||
@ -1426,7 +1426,7 @@ protected:
|
||||
uint16_t p_u16RDLength);
|
||||
bool _readRRAnswerTXT(clsRRAnswerTXT& p_rRRAnswerTXT,
|
||||
uint16_t p_u16RDLength);
|
||||
#ifdef MDNS_IPV6_SUPPORT
|
||||
#ifdef MDNS2_IPV6_SUPPORT
|
||||
bool _readRRAnswerAAAA(clsRRAnswerAAAA& p_rRRAnswerAAAA,
|
||||
uint16_t p_u16RDLength);
|
||||
#endif
|
||||
@ -1455,7 +1455,7 @@ protected:
|
||||
bool _buildDomainForReverseIPv4(IPAddress p_IPv4Address,
|
||||
clsRRDomain& p_rReverseIPv4Domain) const;
|
||||
#endif
|
||||
#ifdef MDNS_IPV6_SUPPORT
|
||||
#ifdef MDNS2_IPV6_SUPPORT
|
||||
bool _buildDomainForReverseIPv6(IPAddress p_IPv4Address,
|
||||
clsRRDomain& p_rReverseIPv6Domain) const;
|
||||
#endif
|
||||
@ -1520,7 +1520,7 @@ protected:
|
||||
clsSendParameter& p_rSendParameter);
|
||||
bool _writeMDNSAnswer_TXT(clsService& p_rService,
|
||||
clsSendParameter& p_rSendParameter);
|
||||
#ifdef MDNS_IPV6_SUPPORT
|
||||
#ifdef MDNS2_IPV6_SUPPORT
|
||||
bool _writeMDNSAnswer_AAAA(IPAddress p_IPAddress,
|
||||
clsSendParameter& p_rSendParameter);
|
||||
bool _writeMDNSAnswer_PTR_IPv6(IPAddress p_IPAddress,
|
||||
@ -1537,7 +1537,7 @@ protected:
|
||||
bool _writeMDNSAnswer_NSEC_PTR_IPv4(IPAddress p_IPAddress,
|
||||
clsSendParameter& p_rSendParameter);
|
||||
#endif
|
||||
#ifdef MDNS_IPV6_SUPPORT
|
||||
#ifdef MDNS2_IPV6_SUPPORT
|
||||
bool _writeMDNSAnswer_NSEC_PTR_IPv6(IPAddress p_IPAddress,
|
||||
clsSendParameter& p_rSendParameter);
|
||||
#endif
|
||||
|
@ -218,7 +218,7 @@ bool clsLEAMDNSHost::_parseQuery(netif* pNetIf,
|
||||
(true)
|
||||
#endif
|
||||
&&
|
||||
#ifdef MDNS_IPV6_SUPPORT
|
||||
#ifdef MDNS2_IPV6_SUPPORT
|
||||
(m_pUDPContext->getRemoteAddress().isV6()) &&
|
||||
(ip6_addr_islinklocal(ip_2_ip6((const ip_addr_t*)m_pUDPContext->getRemoteAddress())))
|
||||
#else
|
||||
@ -304,7 +304,7 @@ bool clsLEAMDNSHost::_parseQuery(netif* pNetIf,
|
||||
sendParameter.m_u32HostReplyMask &= ~static_cast<uint32_t>(enuContentFlag::PTR_IPv4);
|
||||
}
|
||||
#endif
|
||||
#ifdef MDNS_IPV6_SUPPORT
|
||||
#ifdef MDNS2_IPV6_SUPPORT
|
||||
if (u32HostMatchMask & static_cast<uint32_t>(enuContentFlag::PTR_IPv6))
|
||||
{
|
||||
// IPv6 PTR was asked for, but is already known -> skipping
|
||||
@ -330,7 +330,7 @@ bool clsLEAMDNSHost::_parseQuery(netif* pNetIf,
|
||||
else if (u32HostMatchMask & static_cast<uint32_t>(enuContentFlag::AAAA))
|
||||
{
|
||||
// IPv6 address was asked for
|
||||
#ifdef MDNS_IPV6_SUPPORT
|
||||
#ifdef MDNS2_IPV6_SUPPORT
|
||||
if ((enuAnswerType::AAAA == pKnownRRAnswer->answerType()) &&
|
||||
(((stcRRAnswerAAAA*)pKnownRRAnswer)->m_IPAddress == _getResponderIPAddress(pNetIf, enuIPProtocolType::V6)))
|
||||
{
|
||||
@ -381,7 +381,7 @@ bool clsLEAMDNSHost::_parseQuery(netif* pNetIf,
|
||||
}
|
||||
}
|
||||
#endif
|
||||
#ifdef MDNS_IPV6_SUPPORT
|
||||
#ifdef MDNS2_IPV6_SUPPORT
|
||||
if (enuAnswerType::AAAA == pKnownRRAnswer->answerType())
|
||||
{
|
||||
IPAddress localIPAddress(_getResponderIPAddress(pNetIf, enuIPProtocolType::V6));
|
||||
@ -775,7 +775,7 @@ bool clsLEAMDNSHost::_processAnswers(netif* pNetIf, const clsLEAMDNSHost::clsRRA
|
||||
bResult = _processAAnswer((clsRRAnswerA*)pRRAnswer);
|
||||
}
|
||||
#endif
|
||||
#ifdef MDNS_IPV6_SUPPORT
|
||||
#ifdef MDNS2_IPV6_SUPPORT
|
||||
// AAAA -> IPv6Address
|
||||
else if (enuAnswerType::AAAA == pRRAnswer->answerType())
|
||||
{
|
||||
@ -802,7 +802,7 @@ bool clsLEAMDNSHost::_processAnswers(netif* pNetIf, const clsLEAMDNSHost::clsRRA
|
||||
bPossibleEcho = true;
|
||||
}
|
||||
#endif
|
||||
#ifdef MDNS_IPV6_SUPPORT
|
||||
#ifdef MDNS2_IPV6_SUPPORT
|
||||
if ((enuAnswerType::AAAA == pRRAnswer->answerType()) &&
|
||||
(((clsRRAnswerAAAA*)pRRAnswer)->m_IPAddress == _getResponderIPAddress(pNetIf, enuIPProtocolType::V6)))
|
||||
{
|
||||
@ -1159,7 +1159,7 @@ bool clsLEAMDNSHost::_processAAnswer(const clsLEAMDNSHost::clsRRAnswerA* p_pAAns
|
||||
}
|
||||
#endif
|
||||
|
||||
#ifdef MDNS_IPV6_SUPPORT
|
||||
#ifdef MDNS2_IPV6_SUPPORT
|
||||
/*
|
||||
clsLEAmDNS2_Host::_processAAAAAnswer (level 3)
|
||||
*/
|
||||
@ -1298,7 +1298,7 @@ bool clsLEAMDNSHost::_updateProbeStatus()
|
||||
true
|
||||
#endif
|
||||
) || (
|
||||
#ifdef MDNS_IPV6_SUPPORT
|
||||
#ifdef MDNS2_IPV6_SUPPORT
|
||||
_getResponderIPAddress(pNetIf, enuIPProtocolType::V6).isSet() // OR has IPv6 address
|
||||
#else
|
||||
true
|
||||
@ -1511,7 +1511,7 @@ bool clsLEAMDNSHost::_sendHostProbe()
|
||||
#ifdef MDNS_IPV4_SUPPORT
|
||||
sendParameter.m_u32HostReplyMask |= static_cast<uint32_t>(enuContentFlag::A); // Add A answer
|
||||
#endif
|
||||
#ifdef MDNS_IPV6_SUPPORT
|
||||
#ifdef MDNS2_IPV6_SUPPORT
|
||||
sendParameter.m_u32HostReplyMask |= static_cast<uint32_t>(enuContentFlag::AAAA); // Add AAAA answer
|
||||
#endif
|
||||
}
|
||||
@ -1705,7 +1705,7 @@ bool clsLEAMDNSHost::_announce(bool p_bAnnounce,
|
||||
sendParameter.m_u32HostReplyMask |= static_cast<uint32_t>(enuContentFlag::A); // A answer
|
||||
sendParameter.m_u32HostReplyMask |= static_cast<uint32_t>(enuContentFlag::PTR_IPv4); // PTR_IPv4 answer
|
||||
#endif
|
||||
#ifdef MDNS_IPV6_SUPPORT
|
||||
#ifdef MDNS2_IPV6_SUPPORT
|
||||
sendParameter.m_u32HostReplyMask |= static_cast<uint32_t>(enuContentFlag::AAAA); // AAAA answer
|
||||
sendParameter.m_u32HostReplyMask |= static_cast<uint32_t>(enuContentFlag::PTR_IPv6); // PTR_IPv6 answer
|
||||
#endif
|
||||
@ -1892,7 +1892,7 @@ bool clsLEAMDNSHost::_checkQueryCache()
|
||||
pQAnswer->releaseIPv4Addresses();
|
||||
queryAnswerContentFlags |= static_cast<clsQuery::clsAnswer::typeQueryAnswerType>(clsQuery::clsAnswer::enuQueryAnswerType::IPv4Address);
|
||||
#endif
|
||||
#ifdef MDNS_IPV6_SUPPORT
|
||||
#ifdef MDNS2_IPV6_SUPPORT
|
||||
pQAnswer->releaseIPv6Addresses();
|
||||
queryAnswerContentFlags |= static_cast<clsQuery::clsAnswer::typeQueryAnswerType>(clsQuery::clsAnswer::enuQueryAnswerType::IPv6Address);
|
||||
#endif
|
||||
@ -1991,7 +1991,7 @@ bool clsLEAMDNSHost::_checkQueryCache()
|
||||
pQAnswer->removeIPv4Address(pIPv4Address);
|
||||
}
|
||||
#endif
|
||||
#ifdef MDNS_IPV6_SUPPORT
|
||||
#ifdef MDNS2_IPV6_SUPPORT
|
||||
// IPv6Address (from AAAA)
|
||||
clsQuery::clsAnswer::clsIPAddressWithTTL::list expiredIPv6Addresses;
|
||||
bool bAAAAUpdateQuerySent = false;
|
||||
@ -2095,7 +2095,7 @@ uint32_t clsLEAMDNSHost::_replyMaskForHost(netif* pNetIf,
|
||||
u32ReplyMask |= static_cast<uint32_t>(enuContentFlag::PTR_IPv4);
|
||||
}
|
||||
#endif
|
||||
#ifdef MDNS_IPV6_SUPPORT
|
||||
#ifdef MDNS2_IPV6_SUPPORT
|
||||
clsRRDomain reverseIPv6Domain;
|
||||
if ((_getResponderIPAddress(pNetIf, enuIPProtocolType::V6).isSet()) &&
|
||||
(_buildDomainForReverseIPv6(_getResponderIPAddress(pNetIf, enuIPProtocolType::V6), reverseIPv6Domain)) &&
|
||||
@ -2121,7 +2121,7 @@ uint32_t clsLEAMDNSHost::_replyMaskForHost(netif* pNetIf,
|
||||
u32ReplyMask |= static_cast<uint32_t>(enuContentFlag::A);
|
||||
}
|
||||
#endif
|
||||
#ifdef MDNS_IPV6_SUPPORT
|
||||
#ifdef MDNS2_IPV6_SUPPORT
|
||||
if ((DNS_RRTYPE_AAAA == p_RRHeader.m_Attributes.m_u16Type) ||
|
||||
(DNS_RRTYPE_ANY == p_RRHeader.m_Attributes.m_u16Type))
|
||||
{
|
||||
|
@ -141,7 +141,7 @@ bool clsLEAMDNSHost::_printRRAnswer(const clsLEAMDNSHost::clsRRAnswer& p_RRAnswe
|
||||
}
|
||||
break;
|
||||
}
|
||||
#ifdef MDNS_IPV6_SUPPORT
|
||||
#ifdef MDNS2_IPV6_SUPPORT
|
||||
case DNS_RRTYPE_AAAA:
|
||||
DEBUG_OUTPUT.printf_P(PSTR("AAAA IP:%s"), ((clsRRAnswerAAAA*&)p_RRAnswer)->m_IPAddress.toString().c_str());
|
||||
break;
|
||||
@ -175,7 +175,7 @@ const char* clsLEAMDNSHost::_RRType2Name(uint16_t p_u16RRType) const
|
||||
#endif
|
||||
case DNS_RRTYPE_PTR: strcpy_P(acRRName, PSTR("PTR")); break;
|
||||
case DNS_RRTYPE_TXT: strcpy_P(acRRName, PSTR("TXT")); break;
|
||||
#ifdef MDNS_IPV6_SUPPORT
|
||||
#ifdef MDNS2_IPV6_SUPPORT
|
||||
case DNS_RRTYPE_AAAA: strcpy_P(acRRName, PSTR("AAAA")); break;
|
||||
#endif
|
||||
case DNS_RRTYPE_SRV: strcpy_P(acRRName, PSTR("SRV")); break;
|
||||
@ -288,7 +288,7 @@ const char* clsLEAMDNSHost::_NSECBitmap2String(const clsNSECBitmap* p_pNSECBitma
|
||||
{
|
||||
strcat_P(acFlagsString, PSTR("PTR ")); // 4
|
||||
}
|
||||
#ifdef MDNS_IPV6_SUPPORT
|
||||
#ifdef MDNS2_IPV6_SUPPORT
|
||||
if (p_pNSECBitmap->getBit(DNS_RRTYPE_AAAA))
|
||||
{
|
||||
strcat_P(acFlagsString, PSTR("AAAA ")); // 5
|
||||
|
@ -1898,7 +1898,7 @@ bool clsLEAMDNSHost::clsRRAnswerTXT::clear(void)
|
||||
|
||||
*/
|
||||
|
||||
#ifdef MDNS_IPV6_SUPPORT
|
||||
#ifdef MDNS2_IPV6_SUPPORT
|
||||
/*
|
||||
clsLEAMDNSHost::clsRRAnswerAAAA::clsRRAnswerAAAA constructor
|
||||
|
||||
@ -2398,7 +2398,7 @@ bool clsLEAMDNSHost::clsQuery::clsAnswer::clear(void)
|
||||
(true)
|
||||
#endif
|
||||
&&
|
||||
#ifdef MDNS_IPV6_SUPPORT
|
||||
#ifdef MDNS2_IPV6_SUPPORT
|
||||
(releaseIPv6Addresses())
|
||||
#else
|
||||
(true)
|
||||
@ -2528,7 +2528,7 @@ const clsLEAMDNSHost::clsQuery::clsAnswer::clsIPAddressWithTTL* clsLEAMDNSHost::
|
||||
}
|
||||
#endif
|
||||
|
||||
#ifdef MDNS_IPV6_SUPPORT
|
||||
#ifdef MDNS2_IPV6_SUPPORT
|
||||
/*
|
||||
clsLEAMDNSHost::clsQuery::clsAnswer::releaseIPv6Addresses
|
||||
|
||||
@ -2793,7 +2793,7 @@ clsLEAMDNSHost::clsQuery::clsAnswerAccessor::clsIPAddressVector clsLEAMDNSHost::
|
||||
}
|
||||
#endif
|
||||
|
||||
#ifdef MDNS_IPV6_SUPPORT
|
||||
#ifdef MDNS2_IPV6_SUPPORT
|
||||
/*
|
||||
clsLEAMDNSHost::clsQuery::clsAnswerAccessor::IPv6AddressAvailable
|
||||
|
||||
@ -2913,7 +2913,7 @@ size_t clsLEAMDNSHost::clsQuery::clsAnswerAccessor::printTo(Print& p_Print) cons
|
||||
}
|
||||
}
|
||||
#endif
|
||||
#ifdef MDNS_IPV6_SUPPORT
|
||||
#ifdef MDNS2_IPV6_SUPPORT
|
||||
if (IPv6AddressAvailable())
|
||||
{
|
||||
stLen += p_Print.print(cpcI);
|
||||
|
@ -84,7 +84,7 @@ bool clsLEAMDNSHost::_sendMessage(netif* pNetIf, clsLEAMDNSHost::clsSendParamete
|
||||
DEBUG_OUTPUT.printf_P(PSTR("%s _sendMessage: No IPv4 address available!\n"), _DH());
|
||||
});
|
||||
#endif
|
||||
#ifdef MDNS_IPV6_SUPPORT
|
||||
#ifdef MDNS2_IPV6_SUPPORT
|
||||
// Only send out IPv6 messages, if we've got an IPv6 address
|
||||
if (_getResponderIPAddress(pNetIf, enuIPProtocolType::V6).isSet())
|
||||
{
|
||||
@ -128,7 +128,7 @@ bool clsLEAMDNSHost::_sendMessage(netif* pNetIf, clsLEAMDNSHost::clsSendParamete
|
||||
bResult = _sendMessage_Multicast(pNetIf, p_rSendParameter, static_cast<uint8_t>(enuIPProtocolType::V4));
|
||||
}
|
||||
#endif
|
||||
#ifdef MDNS_IPV6_SUPPORT
|
||||
#ifdef MDNS2_IPV6_SUPPORT
|
||||
if (((!ipRemote.isSet()) || // NO remote IP
|
||||
(ipRemote.isV6())) && // OR IPv6
|
||||
(u8AvailableProtocols & static_cast<uint8_t>(enuIPProtocolType::V6))) // AND IPv6 protocol available
|
||||
@ -182,7 +182,7 @@ bool clsLEAMDNSHost::_sendMessage_Multicast(netif* pNetIf, clsLEAMDNSHost::clsSe
|
||||
}
|
||||
#endif
|
||||
|
||||
#ifdef MDNS_IPV6_SUPPORT
|
||||
#ifdef MDNS2_IPV6_SUPPORT
|
||||
if (p_IPProtocolTypes & static_cast<uint8_t>(enuIPProtocolType::V6))
|
||||
{
|
||||
IPAddress ip6MulticastAddress(DNS_MQUERY_IPV6_GROUP_INIT);
|
||||
@ -308,7 +308,7 @@ bool clsLEAMDNSHost::_prepareMessage(netif* pNetIf, clsLEAMDNSHost::clsSendParam
|
||||
DEBUG_EX_ERR(if (!bResult) DEBUG_OUTPUT.printf_P(PSTR("%s _prepareMDNSMessage: _writeMDNSAnswer_PTR_IPv4 FAILED!\n"), _DH()););
|
||||
}
|
||||
#endif
|
||||
#ifdef MDNS_IPV6_SUPPORT
|
||||
#ifdef MDNS2_IPV6_SUPPORT
|
||||
// AAAA
|
||||
if ((bResult) &&
|
||||
(p_rSendParameter.m_u32HostReplyMask & static_cast<uint32_t>(enuContentFlag::AAAA)) &&
|
||||
@ -383,7 +383,7 @@ bool clsLEAMDNSHost::_prepareMessage(netif* pNetIf, clsLEAMDNSHost::clsSendParam
|
||||
#ifdef MDNS_IPV4_SUPPORT
|
||||
bool bNeedsAdditionalAnswerA = false;
|
||||
#endif
|
||||
#ifdef MDNS_IPV6_SUPPORT
|
||||
#ifdef MDNS2_IPV6_SUPPORT
|
||||
bool bNeedsAdditionalAnswerAAAA = false;
|
||||
#endif
|
||||
for (clsService::list::iterator it = m_Services.begin(); ((bResult) && (it != m_Services.end())); it++)
|
||||
@ -420,7 +420,7 @@ bool clsLEAMDNSHost::_prepareMessage(netif* pNetIf, clsLEAMDNSHost::clsSendParam
|
||||
bNeedsAdditionalAnswerA = true;
|
||||
}
|
||||
#endif
|
||||
#ifdef MDNS_IPV6_SUPPORT
|
||||
#ifdef MDNS2_IPV6_SUPPORT
|
||||
if ((bResult) &&
|
||||
(!(p_rSendParameter.m_u32HostReplyMask & static_cast<uint32_t>(enuContentFlag::AAAA)))) // Add IPv6 address
|
||||
{
|
||||
@ -455,7 +455,7 @@ bool clsLEAMDNSHost::_prepareMessage(netif* pNetIf, clsLEAMDNSHost::clsSendParam
|
||||
DEBUG_EX_ERR(if (!bResult) DEBUG_OUTPUT.printf_P(PSTR("%s _prepareMDNSMessage: _writeMDNSAnswer_A(B) FAILED!\n"), _DH()););
|
||||
}
|
||||
#endif
|
||||
#ifdef MDNS_IPV6_SUPPORT
|
||||
#ifdef MDNS2_IPV6_SUPPORT
|
||||
// Answer AAAA needed?
|
||||
if ((bResult) &&
|
||||
(bNeedsAdditionalAnswerAAAA) &&
|
||||
@ -481,7 +481,7 @@ bool clsLEAMDNSHost::_prepareMessage(netif* pNetIf, clsLEAMDNSHost::clsSendParam
|
||||
uint32_t u32NSECContent_PTR_IPv4 = (u32NSECContent & static_cast<uint32_t>(enuContentFlag::PTR_IPv4));
|
||||
u32NSECContent &= ~static_cast<uint32_t>(enuContentFlag::PTR_IPv4);
|
||||
#endif
|
||||
#ifdef MDNS_IPV6_SUPPORT
|
||||
#ifdef MDNS2_IPV6_SUPPORT
|
||||
uint32_t u32NSECContent_PTR_IPv6 = (u32NSECContent & static_cast<uint32_t>(enuContentFlag::PTR_IPv6));
|
||||
u32NSECContent &= ~static_cast<uint32_t>(enuContentFlag::PTR_IPv6);
|
||||
#endif
|
||||
@ -491,7 +491,7 @@ bool clsLEAMDNSHost::_prepareMessage(netif* pNetIf, clsLEAMDNSHost::clsSendParam
|
||||
#ifdef MDNS_IPV4_SUPPORT
|
||||
+ (u32NSECContent_PTR_IPv4 ? 1 : 0)
|
||||
#endif
|
||||
#ifdef MDNS_IPV6_SUPPORT
|
||||
#ifdef MDNS2_IPV6_SUPPORT
|
||||
+ (u32NSECContent_PTR_IPv6 ? 1 : 0)
|
||||
#endif
|
||||
))
|
||||
@ -504,7 +504,7 @@ bool clsLEAMDNSHost::_prepareMessage(netif* pNetIf, clsLEAMDNSHost::clsSendParam
|
||||
((!_getResponderIPAddress(pNetIf, (enuIPProtocolType::V4)).isSet()) ||
|
||||
(_writeMDNSAnswer_NSEC_PTR_IPv4(_getResponderIPAddress(pNetIf, (enuIPProtocolType::V4)), p_rSendParameter))))
|
||||
#endif
|
||||
#ifdef MDNS_IPV6_SUPPORT
|
||||
#ifdef MDNS2_IPV6_SUPPORT
|
||||
// Write separate answer for host PTR IPv6
|
||||
&& ((!u32NSECContent_PTR_IPv6) ||
|
||||
((!_getResponderIPAddress(pNetIf, (enuIPProtocolType::V6)).isSet()) ||
|
||||
@ -566,7 +566,7 @@ bool clsLEAMDNSHost::_sendQuery(const clsLEAMDNSHost::clsQuery& p_Query,
|
||||
#ifdef MDNS_IPV4_SUPPORT
|
||||
bResult = _addQueryRecord(sendParameter, p_Query.m_Domain, DNS_RRTYPE_A);
|
||||
#endif
|
||||
#ifdef MDNS_IPV6_SUPPORT
|
||||
#ifdef MDNS2_IPV6_SUPPORT
|
||||
bResult = _addQueryRecord(sendParameter, p_Query.m_Domain, DNS_RRTYPE_AAAA);
|
||||
#endif
|
||||
break;
|
||||
@ -623,7 +623,7 @@ IPAddress clsLEAMDNSHost::_getResponderIPAddress(netif* pNetIf, enuIPProtocolTyp
|
||||
ipResponder = netif_ip_addr4(pNetIf);
|
||||
}
|
||||
#endif
|
||||
#ifdef MDNS_IPV6_SUPPORT
|
||||
#ifdef MDNS2_IPV6_SUPPORT
|
||||
if (enuIPProtocolType::V6 == p_IPProtocolType)
|
||||
{
|
||||
bool bCheckLinkLocal = true;
|
||||
@ -731,7 +731,7 @@ bool clsLEAMDNSHost::_readRRAnswer(clsLEAMDNSHost::clsRRAnswer*& p_rpRRAnswer)
|
||||
p_rpRRAnswer = new clsRRAnswerTXT(header, u32TTL);
|
||||
bResult = _readRRAnswerTXT(*(clsRRAnswerTXT*&)p_rpRRAnswer, u16RDLength);
|
||||
break;
|
||||
#ifdef MDNS_IPV6_SUPPORT
|
||||
#ifdef MDNS2_IPV6_SUPPORT
|
||||
case DNS_RRTYPE_AAAA:
|
||||
p_rpRRAnswer = new clsRRAnswerAAAA(header, u32TTL);
|
||||
bResult = _readRRAnswerAAAA(*(clsRRAnswerAAAA*&)p_rpRRAnswer, u16RDLength);
|
||||
@ -779,7 +779,7 @@ bool clsLEAMDNSHost::_readRRAnswer(clsLEAMDNSHost::clsRRAnswer*& p_rpRRAnswer)
|
||||
}
|
||||
break;
|
||||
}
|
||||
#ifdef MDNS_IPV6_SUPPORT
|
||||
#ifdef MDNS2_IPV6_SUPPORT
|
||||
case DNS_RRTYPE_AAAA:
|
||||
DEBUG_OUTPUT.printf_P(PSTR("AAAA IP:%s"), ((clsRRAnswerAAAA*&)p_rpRRAnswer)->m_IPAddress.toString().c_str());
|
||||
break;
|
||||
@ -968,7 +968,7 @@ bool clsLEAMDNSHost::_readRRAnswerTXT(clsLEAMDNSHost::clsRRAnswerTXT& p_rRRAnswe
|
||||
return bResult;
|
||||
}
|
||||
|
||||
#ifdef MDNS_IPV6_SUPPORT
|
||||
#ifdef MDNS2_IPV6_SUPPORT
|
||||
bool clsLEAMDNSHost::_readRRAnswerAAAA(clsLEAMDNSHost::clsRRAnswerAAAA& p_rRRAnswerAAAA,
|
||||
uint16_t p_u16RDLength)
|
||||
{
|
||||
@ -1280,7 +1280,7 @@ bool clsLEAMDNSHost::_buildDomainForReverseIPv4(IPAddress p_IPv4Address,
|
||||
}
|
||||
#endif
|
||||
|
||||
#ifdef MDNS_IPV6_SUPPORT
|
||||
#ifdef MDNS2_IPV6_SUPPORT
|
||||
/*
|
||||
MDNSResponder::_buildDomainForReverseIPv6
|
||||
|
||||
@ -2014,7 +2014,7 @@ bool clsLEAMDNSHost::_writeMDNSAnswer_TXT(clsLEAMDNSHost::clsService& p_rService
|
||||
return bResult;
|
||||
}
|
||||
|
||||
#ifdef MDNS_IPV6_SUPPORT
|
||||
#ifdef MDNS2_IPV6_SUPPORT
|
||||
/*
|
||||
MDNSResponder::_writeMDNSAnswer_AAAA
|
||||
|
||||
@ -2189,7 +2189,7 @@ clsLEAMDNSHost::clsNSECBitmap* clsLEAMDNSHost::_createNSECBitmap(uint32_t p_u32N
|
||||
{
|
||||
pNSECBitmap->setBit(DNS_RRTYPE_PTR); // 12/0x0C
|
||||
}
|
||||
#ifdef MDNS_IPV6_SUPPORT
|
||||
#ifdef MDNS2_IPV6_SUPPORT
|
||||
if (p_u32NSECContent & static_cast<uint32_t>(enuContentFlag::AAAA))
|
||||
{
|
||||
pNSECBitmap->setBit(DNS_RRTYPE_AAAA); // 28/0x1C
|
||||
@ -2335,7 +2335,7 @@ bool clsLEAMDNSHost::_writeMDNSAnswer_NSEC_PTR_IPv4(IPAddress p_IPAddress,
|
||||
#endif
|
||||
|
||||
|
||||
#ifdef MDNS_IPV6_SUPPORT
|
||||
#ifdef MDNS2_IPV6_SUPPORT
|
||||
/*
|
||||
MDNSResponder::_writeMDNSAnswer_NSEC_PTR_IPv6(host)
|
||||
|
||||
|
@ -85,10 +85,8 @@ bool MDNSResponder::_process(bool p_bUserContext)
|
||||
}
|
||||
else
|
||||
{
|
||||
bResult = (m_netif != nullptr) &&
|
||||
(m_netif->flags & NETIF_FLAG_UP) && // network interface is up and running
|
||||
_updateProbeStatus() && // Probing
|
||||
_checkServiceQueryCache(); // Service query cache check
|
||||
bResult = _updateProbeStatus() && // Probing
|
||||
_checkServiceQueryCache(); // Service query cache check
|
||||
}
|
||||
return bResult;
|
||||
}
|
||||
@ -99,13 +97,10 @@ bool MDNSResponder::_process(bool p_bUserContext)
|
||||
bool MDNSResponder::_restart(void)
|
||||
{
|
||||
|
||||
return ((m_netif != nullptr) &&
|
||||
(m_netif->flags & NETIF_FLAG_UP) && // network interface is up and running
|
||||
(_resetProbeStatus(true)) && // Stop and restart probing
|
||||
return ((_resetProbeStatus(true)) && // Stop and restart probing
|
||||
(_allocUDPContext())); // Restart UDP
|
||||
}
|
||||
|
||||
|
||||
/**
|
||||
RECEIVING
|
||||
*/
|
||||
@ -192,8 +187,7 @@ bool MDNSResponder::_parseQuery(const MDNSResponder::stcMDNS_MsgHeader& p_MsgHea
|
||||
{
|
||||
// Define host replies, BUT only answer queries after probing is done
|
||||
u8HostOrServiceReplies =
|
||||
sendParameter.m_u8HostReplyMask |= (((m_bPassivModeEnabled) ||
|
||||
(ProbingStatus_Done == m_HostProbeInformation.m_ProbingStatus))
|
||||
sendParameter.m_u8HostReplyMask |= (((ProbingStatus_Done == m_HostProbeInformation.m_ProbingStatus))
|
||||
? _replyMaskForHost(questionRR.m_Header, 0)
|
||||
: 0);
|
||||
DEBUG_EX_INFO(if (u8HostOrServiceReplies)
|
||||
@ -222,8 +216,7 @@ bool MDNSResponder::_parseQuery(const MDNSResponder::stcMDNS_MsgHeader& p_MsgHea
|
||||
for (stcMDNSService* pService = m_pServices; pService; pService = pService->m_pNext)
|
||||
{
|
||||
// Define service replies, BUT only answer queries after probing is done
|
||||
uint8_t u8ReplyMaskForQuestion = (((m_bPassivModeEnabled) ||
|
||||
(ProbingStatus_Done == pService->m_ProbeInformation.m_ProbingStatus))
|
||||
uint8_t u8ReplyMaskForQuestion = (((ProbingStatus_Done == pService->m_ProbeInformation.m_ProbingStatus))
|
||||
? _replyMaskForService(questionRR.m_Header, *pService, 0)
|
||||
: 0);
|
||||
u8HostOrServiceReplies |= (pService->m_u8ReplyMask |= u8ReplyMaskForQuestion);
|
||||
@ -364,9 +357,8 @@ bool MDNSResponder::_parseQuery(const MDNSResponder::stcMDNS_MsgHeader& p_MsgHea
|
||||
// IP4 address was asked for
|
||||
#ifdef MDNS_IP4_SUPPORT
|
||||
if ((AnswerType_A == pKnownRRAnswer->answerType()) &&
|
||||
(((stcMDNS_RRAnswerA*)pKnownRRAnswer)->m_IPAddress == _getResponseMulticastInterface()))
|
||||
(((stcMDNS_RRAnswerA*)pKnownRRAnswer)->m_IPAddress == m_pUDPContext->getInputNetif()->ip_addr))
|
||||
{
|
||||
|
||||
DEBUG_EX_INFO(DEBUG_OUTPUT.printf_P(PSTR("[MDNSResponder] _parseQuery: IP4 address already known... skipping!\n")););
|
||||
sendParameter.m_u8HostReplyMask &= ~ContentFlag_A;
|
||||
} // else: RData NOT IP4 length !!
|
||||
@ -399,7 +391,8 @@ bool MDNSResponder::_parseQuery(const MDNSResponder::stcMDNS_MsgHeader& p_MsgHea
|
||||
#ifdef MDNS_IP4_SUPPORT
|
||||
if (AnswerType_A == pKnownRRAnswer->answerType())
|
||||
{
|
||||
IPAddress localIPAddress(_getResponseMulticastInterface());
|
||||
|
||||
IPAddress localIPAddress(m_pUDPContext->getInputNetif()->ip_addr);
|
||||
if (((stcMDNS_RRAnswerA*)pKnownRRAnswer)->m_IPAddress == localIPAddress)
|
||||
{
|
||||
// SAME IP address -> We've received an old message from ourselfs (same IP)
|
||||
@ -1221,9 +1214,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() != IPAddress())) // Has IP address
|
||||
if (ProbingStatus_ReadyToStart == m_HostProbeInformation.m_ProbingStatus)
|
||||
{
|
||||
DEBUG_EX_INFO(DEBUG_OUTPUT.printf_P(PSTR("[MDNSResponder] _updateProbeStatus: Starting host probing...\n")););
|
||||
|
||||
@ -2007,11 +1998,17 @@ uint8_t MDNSResponder::_replyMaskForHost(const MDNSResponder::stcMDNS_RRHeader&
|
||||
// PTR request
|
||||
#ifdef MDNS_IP4_SUPPORT
|
||||
stcMDNS_RRDomain reverseIP4Domain;
|
||||
if ((_buildDomainForReverseIP4(_getResponseMulticastInterface(), reverseIP4Domain)) &&
|
||||
(p_RRHeader.m_Domain == reverseIP4Domain))
|
||||
for (netif* pNetIf = netif_list; pNetIf; pNetIf = pNetIf->next)
|
||||
{
|
||||
// Reverse domain match
|
||||
u8ReplyMask |= ContentFlag_PTR_IP4;
|
||||
if (netif_is_up(pNetIf))
|
||||
{
|
||||
if ((_buildDomainForReverseIP4(pNetIf->ip_addr, reverseIP4Domain)) &&
|
||||
(p_RRHeader.m_Domain == reverseIP4Domain))
|
||||
{
|
||||
// Reverse domain match
|
||||
u8ReplyMask |= ContentFlag_PTR_IP4;
|
||||
}
|
||||
}
|
||||
}
|
||||
#endif
|
||||
#ifdef MDNS_IP6_SUPPORT
|
||||
|
@ -168,31 +168,23 @@ bool MDNSResponder::_allocUDPContext(void)
|
||||
{
|
||||
DEBUG_EX_INFO(DEBUG_OUTPUT.println("[MDNSResponder] _allocUDPContext"););
|
||||
|
||||
bool bResult = false;
|
||||
|
||||
_releaseUDPContext();
|
||||
_joinMulticastGroups();
|
||||
|
||||
#ifdef MDNS_IP4_SUPPORT
|
||||
ip_addr_t multicast_addr = DNS_MQUERY_IPV4_GROUP_INIT;
|
||||
#endif
|
||||
#ifdef MDNS_IP6_SUPPORT
|
||||
//TODO: set multicast address (lwip_joingroup() is IPv4 only at the time of writing)
|
||||
multicast_addr.addr = DNS_MQUERY_IPV6_GROUP_INIT;
|
||||
#endif
|
||||
if (ERR_OK == igmp_joingroup(ip_2_ip4(&m_netif->ip_addr), ip_2_ip4(&multicast_addr)))
|
||||
m_pUDPContext = new UdpContext;
|
||||
m_pUDPContext->ref();
|
||||
|
||||
if (m_pUDPContext->listen(IP4_ADDR_ANY, DNS_MQUERY_PORT))
|
||||
{
|
||||
m_pUDPContext = new UdpContext;
|
||||
m_pUDPContext->ref();
|
||||
|
||||
if (m_pUDPContext->listen(IP4_ADDR_ANY, DNS_MQUERY_PORT))
|
||||
{
|
||||
m_pUDPContext->setMulticastTTL(MDNS_MULTICAST_TTL);
|
||||
m_pUDPContext->onRx(std::bind(&MDNSResponder::_callProcess, this));
|
||||
|
||||
bResult = m_pUDPContext->connect(&multicast_addr, DNS_MQUERY_PORT);
|
||||
}
|
||||
m_pUDPContext->setMulticastTTL(MDNS_MULTICAST_TTL);
|
||||
m_pUDPContext->onRx(std::bind(&MDNSResponder::_callProcess, this));
|
||||
}
|
||||
return bResult;
|
||||
else
|
||||
{
|
||||
return false;
|
||||
}
|
||||
|
||||
return true;
|
||||
}
|
||||
|
||||
/*
|
||||
@ -205,6 +197,7 @@ bool MDNSResponder::_releaseUDPContext(void)
|
||||
{
|
||||
m_pUDPContext->unref();
|
||||
m_pUDPContext = 0;
|
||||
_leaveMulticastGroups();
|
||||
}
|
||||
return true;
|
||||
}
|
||||
|
@ -2408,12 +2408,25 @@ bool MDNSResponder::stcMDNSSendParameter::clear(void)
|
||||
delete m_pQuestions;
|
||||
m_pQuestions = pNext;
|
||||
}
|
||||
|
||||
return clearCachedNames();;
|
||||
}
|
||||
/*
|
||||
MDNSResponder::stcMDNSSendParameter::clear cached names
|
||||
*/
|
||||
bool MDNSResponder::stcMDNSSendParameter::clearCachedNames(void)
|
||||
{
|
||||
|
||||
m_u16Offset = 0;
|
||||
|
||||
while (m_pDomainCacheItems)
|
||||
{
|
||||
stcDomainCacheItem* pNext = m_pDomainCacheItems->m_pNext;
|
||||
delete m_pDomainCacheItems;
|
||||
m_pDomainCacheItems = pNext;
|
||||
}
|
||||
m_pDomainCacheItems = nullptr;
|
||||
|
||||
return true;
|
||||
}
|
||||
|
||||
|
@ -89,8 +89,8 @@ bool MDNSResponder::_sendMDNSMessage(MDNSResponder::stcMDNSSendParameter& p_rSen
|
||||
});
|
||||
IPAddress ipRemote;
|
||||
ipRemote = m_pUDPContext->getRemoteAddress();
|
||||
bResult = ((_prepareMDNSMessage(p_rSendParameter, _getResponseMulticastInterface())) &&
|
||||
(m_pUDPContext->send(ipRemote, m_pUDPContext->getRemotePort())));
|
||||
bResult = ((_prepareMDNSMessage(p_rSendParameter, m_pUDPContext->getInputNetif()->ip_addr)) &&
|
||||
(m_pUDPContext->sendTimeout(ipRemote, m_pUDPContext->getRemotePort(), MDNS_UDPCONTEXT_TIMEOUT)));
|
||||
}
|
||||
else // Multicast response
|
||||
{
|
||||
@ -121,25 +121,32 @@ bool MDNSResponder::_sendMDNSMessage_Multicast(MDNSResponder::stcMDNSSendParamet
|
||||
|
||||
bool bResult = false;
|
||||
|
||||
IPAddress fromIPAddress;
|
||||
fromIPAddress = _getResponseMulticastInterface();
|
||||
m_pUDPContext->setMulticastInterface(fromIPAddress);
|
||||
for (netif* pNetIf = netif_list; pNetIf; pNetIf = pNetIf->next)
|
||||
{
|
||||
if (netif_is_up(pNetIf))
|
||||
{
|
||||
IPAddress fromIPAddress;
|
||||
//fromIPAddress = _getResponseMulticastInterface();
|
||||
fromIPAddress = pNetIf->ip_addr;
|
||||
m_pUDPContext->setMulticastInterface(fromIPAddress);
|
||||
|
||||
#ifdef MDNS_IP4_SUPPORT
|
||||
IPAddress toMulticastAddress(DNS_MQUERY_IPV4_GROUP_INIT);
|
||||
IPAddress toMulticastAddress(DNS_MQUERY_IPV4_GROUP_INIT);
|
||||
#endif
|
||||
#ifdef MDNS_IP6_SUPPORT
|
||||
//TODO: set multicast address
|
||||
IPAddress toMulticastAddress(DNS_MQUERY_IPV6_GROUP_INIT);
|
||||
//TODO: set multicast address
|
||||
IPAddress toMulticastAddress(DNS_MQUERY_IPV6_GROUP_INIT);
|
||||
#endif
|
||||
DEBUG_EX_INFO(DEBUG_OUTPUT.printf_P(PSTR("[MDNSResponder] _sendMDNSMessage_Multicast: Will send to '%s'.\n"), toMulticastAddress.toString().c_str()););
|
||||
bResult = ((_prepareMDNSMessage(p_rSendParameter, fromIPAddress)) &&
|
||||
(m_pUDPContext->send(toMulticastAddress, DNS_MQUERY_PORT)));
|
||||
DEBUG_EX_INFO(DEBUG_OUTPUT.printf_P(PSTR("[MDNSResponder] _sendMDNSMessage_Multicast: Will send to '%s'.\n"), toMulticastAddress.toString().c_str()););
|
||||
bResult = ((_prepareMDNSMessage(p_rSendParameter, fromIPAddress)) &&
|
||||
(m_pUDPContext->sendTimeout(toMulticastAddress, DNS_MQUERY_PORT, MDNS_UDPCONTEXT_TIMEOUT)));
|
||||
|
||||
DEBUG_EX_ERR(if (!bResult)
|
||||
{
|
||||
DEBUG_OUTPUT.printf_P(PSTR("[MDNSResponder] _sendMDNSMessage_Multicast: FAILED!\n"));
|
||||
});
|
||||
DEBUG_EX_ERR(if (!bResult)
|
||||
{
|
||||
DEBUG_OUTPUT.printf_P(PSTR("[MDNSResponder] _sendMDNSMessage_Multicast: FAILED!\n"));
|
||||
});
|
||||
}
|
||||
}
|
||||
return bResult;
|
||||
}
|
||||
|
||||
@ -157,6 +164,7 @@ bool MDNSResponder::_prepareMDNSMessage(MDNSResponder::stcMDNSSendParameter& p_r
|
||||
{
|
||||
DEBUG_EX_INFO(DEBUG_OUTPUT.printf_P(PSTR("[MDNSResponder] _prepareMDNSMessage\n")););
|
||||
bool bResult = true;
|
||||
p_rSendParameter.clearCachedNames(); // Need to remove cached names, p_SendParameter might have been used before on other interface
|
||||
|
||||
// Prepare header; count answers
|
||||
stcMDNS_MsgHeader msgHeader(p_rSendParameter.m_u16ID, p_rSendParameter.m_bResponse, 0, p_rSendParameter.m_bAuthorative);
|
||||
|
@ -42,7 +42,8 @@ void setup() {
|
||||
"WL_CONNECTED = 3\n"
|
||||
"WL_CONNECT_FAILED = 4\n"
|
||||
"WL_CONNECTION_LOST = 5\n"
|
||||
"WL_DISCONNECTED = 6\n"
|
||||
"WL_WRONG_PASSWORD = 6\n"
|
||||
"WL_DISCONNECTED = 7\n"
|
||||
);
|
||||
}
|
||||
|
||||
|
Reference in New Issue
Block a user