mirror of
https://github.com/esp8266/Arduino.git
synced 2025-04-21 10:26:06 +03:00
use newlib api in new mDNS, fix host using mDNS (#5545)
This commit is contained in:
parent
cac22e3576
commit
eb5d636f0d
@ -203,7 +203,7 @@ bool MDNSResponder::_parseQuery(const MDNSResponder::stcMDNS_MsgHeader& p_MsgHea
|
|||||||
u8HostOrServiceReplies |= (pService->m_u8ReplyMask |= u8ReplyMaskForQuestion);
|
u8HostOrServiceReplies |= (pService->m_u8ReplyMask |= u8ReplyMaskForQuestion);
|
||||||
DEBUG_EX_INFO(if (u8ReplyMaskForQuestion) { DEBUG_OUTPUT.printf_P(PSTR("[MDNSResponder] _parseQuery: Service reply needed for (%s.%s.%s): %u (%s)\n"), (pService->m_pcName ?: m_pcHostname), pService->m_pcService, pService->m_pcProtocol, u8ReplyMaskForQuestion, IPAddress(m_pUDPContext->getRemoteAddress()).toString().c_str()); } );
|
DEBUG_EX_INFO(if (u8ReplyMaskForQuestion) { DEBUG_OUTPUT.printf_P(PSTR("[MDNSResponder] _parseQuery: Service reply needed for (%s.%s.%s): %u (%s)\n"), (pService->m_pcName ?: m_pcHostname), pService->m_pcService, pService->m_pcProtocol, u8ReplyMaskForQuestion, IPAddress(m_pUDPContext->getRemoteAddress()).toString().c_str()); } );
|
||||||
/*if ((u8ReplyMaskForQuestion) &&
|
/*if ((u8ReplyMaskForQuestion) &&
|
||||||
(0 == os_strcmp("hap", pService->m_pcService))) {
|
(0 == strcmp("hap", pService->m_pcService))) {
|
||||||
DEBUG_OUTPUT.printf_P(PSTR("[MDNSResponder] _parseQuery: Service reply needed for (%s.%s.%s): %u (%s)\n"), (pService->m_pcName ?: m_pcHostname), pService->m_pcService, pService->m_pcProtocol, u8ReplyMaskForQuestion, IPAddress(m_pUDPContext->getRemoteAddress()).toString().c_str());
|
DEBUG_OUTPUT.printf_P(PSTR("[MDNSResponder] _parseQuery: Service reply needed for (%s.%s.%s): %u (%s)\n"), (pService->m_pcName ?: m_pcHostname), pService->m_pcService, pService->m_pcProtocol, u8ReplyMaskForQuestion, IPAddress(m_pUDPContext->getRemoteAddress()).toString().c_str());
|
||||||
}*/
|
}*/
|
||||||
|
|
||||||
@ -386,7 +386,7 @@ bool MDNSResponder::_parseQuery(const MDNSResponder::stcMDNS_MsgHeader& p_MsgHea
|
|||||||
if ((u8ServiceMatchMask) && // The RR in the known answer matches an RR we are planning to send, AND
|
if ((u8ServiceMatchMask) && // The RR in the known answer matches an RR we are planning to send, AND
|
||||||
((MDNS_SERVICE_TTL / 2) <= pKnownRRAnswer->m_u32TTL)) { // The TTL of the known answer is longer than half of the new service TTL (4500s)
|
((MDNS_SERVICE_TTL / 2) <= pKnownRRAnswer->m_u32TTL)) { // The TTL of the known answer is longer than half of the new service TTL (4500s)
|
||||||
|
|
||||||
/*if ((0 == os_strcmp("hap", pService->m_pcService))) {
|
/*if ((0 == strcmp("hap", pService->m_pcService))) {
|
||||||
DEBUG_OUTPUT.printf_P(PSTR("[MDNSResponder] _parseQuery: Known answer for (%s.%s.%s): %u (%s) %u\n"), (pService->m_pcName ?: m_pcHostname), pService->m_pcService, pService->m_pcProtocol, pKnownRRAnswer->answerType(), IPAddress(m_pUDPContext->getRemoteAddress()).toString().c_str(), pKnownRRAnswer->m_u32TTL);
|
DEBUG_OUTPUT.printf_P(PSTR("[MDNSResponder] _parseQuery: Known answer for (%s.%s.%s): %u (%s) %u\n"), (pService->m_pcName ?: m_pcHostname), pService->m_pcService, pService->m_pcProtocol, pKnownRRAnswer->answerType(), IPAddress(m_pUDPContext->getRemoteAddress()).toString().c_str(), pKnownRRAnswer->m_u32TTL);
|
||||||
}*/
|
}*/
|
||||||
|
|
||||||
@ -484,7 +484,7 @@ bool MDNSResponder::_parseQuery(const MDNSResponder::stcMDNS_MsgHeader& p_MsgHea
|
|||||||
u8ReplyNeeded |= pService->m_u8ReplyMask;
|
u8ReplyNeeded |= pService->m_u8ReplyMask;
|
||||||
|
|
||||||
if ((u8ReplyNeeded) &&
|
if ((u8ReplyNeeded) &&
|
||||||
(0 == os_strcmp("hap", pService->m_pcService))) {
|
(0 == strcmp("hap", pService->m_pcService))) {
|
||||||
DEBUG_EX_INFO(DEBUG_OUTPUT.printf_P(PSTR("[MDNSResponder] _parseQuery: Sending service reply for (%s.%s.%s): %u (%s)\n"), (pService->m_pcName ?: m_pcHostname), pService->m_pcService, pService->m_pcProtocol, u8ReplyNeeded, IPAddress(m_pUDPContext->getRemoteAddress()).toString().c_str()););
|
DEBUG_EX_INFO(DEBUG_OUTPUT.printf_P(PSTR("[MDNSResponder] _parseQuery: Sending service reply for (%s.%s.%s): %u (%s)\n"), (pService->m_pcName ?: m_pcHostname), pService->m_pcService, pService->m_pcProtocol, u8ReplyNeeded, IPAddress(m_pUDPContext->getRemoteAddress()).toString().c_str()););
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -102,19 +102,19 @@ namespace MDNSImplementation {
|
|||||||
const char* pFoundDivider = strrstr(p_rpcDomain, pcDivider);
|
const char* pFoundDivider = strrstr(p_rpcDomain, pcDivider);
|
||||||
if (pFoundDivider) { // maybe already extended
|
if (pFoundDivider) { // maybe already extended
|
||||||
char* pEnd = 0;
|
char* pEnd = 0;
|
||||||
unsigned long ulIndex = strtoul((pFoundDivider + os_strlen(pcDivider)), &pEnd, 10);
|
unsigned long ulIndex = strtoul((pFoundDivider + strlen(pcDivider)), &pEnd, 10);
|
||||||
if ((ulIndex) &&
|
if ((ulIndex) &&
|
||||||
((pEnd - p_rpcDomain) == os_strlen(p_rpcDomain)) &&
|
((pEnd - p_rpcDomain) == (ptrdiff_t)strlen(p_rpcDomain)) &&
|
||||||
(!*pEnd)) { // Valid (old) index found
|
(!*pEnd)) { // Valid (old) index found
|
||||||
|
|
||||||
char acIndexBuffer[16];
|
char acIndexBuffer[16];
|
||||||
sprintf(acIndexBuffer, "%lu", (++ulIndex));
|
sprintf(acIndexBuffer, "%lu", (++ulIndex));
|
||||||
size_t stLength = ((pFoundDivider - p_rpcDomain + os_strlen(pcDivider)) + os_strlen(acIndexBuffer) + 1);
|
size_t stLength = ((pFoundDivider - p_rpcDomain + strlen(pcDivider)) + strlen(acIndexBuffer) + 1);
|
||||||
char* pNewHostname = new char[stLength];
|
char* pNewHostname = new char[stLength];
|
||||||
if (pNewHostname) {
|
if (pNewHostname) {
|
||||||
memcpy(pNewHostname, p_rpcDomain, (pFoundDivider - p_rpcDomain + os_strlen(pcDivider)));
|
memcpy(pNewHostname, p_rpcDomain, (pFoundDivider - p_rpcDomain + strlen(pcDivider)));
|
||||||
pNewHostname[pFoundDivider - p_rpcDomain + os_strlen(pcDivider)] = 0;
|
pNewHostname[pFoundDivider - p_rpcDomain + strlen(pcDivider)] = 0;
|
||||||
os_strcat(pNewHostname, acIndexBuffer);
|
strcat(pNewHostname, acIndexBuffer);
|
||||||
|
|
||||||
delete[] p_rpcDomain;
|
delete[] p_rpcDomain;
|
||||||
p_rpcDomain = pNewHostname;
|
p_rpcDomain = pNewHostname;
|
||||||
@ -131,7 +131,7 @@ namespace MDNSImplementation {
|
|||||||
}
|
}
|
||||||
|
|
||||||
if (!pFoundDivider) { // not yet extended (or failed to increment extension) -> start indexing
|
if (!pFoundDivider) { // not yet extended (or failed to increment extension) -> start indexing
|
||||||
size_t stLength = os_strlen(p_rpcDomain) + (os_strlen(pcDivider) + 1 + 1); // Name + Divider + '2' + '\0'
|
size_t stLength = strlen(p_rpcDomain) + (strlen(pcDivider) + 1 + 1); // Name + Divider + '2' + '\0'
|
||||||
char* pNewHostname = new char[stLength];
|
char* pNewHostname = new char[stLength];
|
||||||
if (pNewHostname) {
|
if (pNewHostname) {
|
||||||
sprintf(pNewHostname, "%s%s2", p_rpcDomain, pcDivider);
|
sprintf(pNewHostname, "%s%s2", p_rpcDomain, pcDivider);
|
||||||
@ -150,10 +150,10 @@ namespace MDNSImplementation {
|
|||||||
// No given host domain, use base or default
|
// No given host domain, use base or default
|
||||||
const char* cpcDefaultName = (p_pcDefaultDomain ?: "esp8266");
|
const char* cpcDefaultName = (p_pcDefaultDomain ?: "esp8266");
|
||||||
|
|
||||||
size_t stLength = os_strlen(cpcDefaultName) + 1; // '\0'
|
size_t stLength = strlen(cpcDefaultName) + 1; // '\0'
|
||||||
p_rpcDomain = new char[stLength];
|
p_rpcDomain = new char[stLength];
|
||||||
if (p_rpcDomain) {
|
if (p_rpcDomain) {
|
||||||
os_strncpy(p_rpcDomain, cpcDefaultName, stLength);
|
strncpy(p_rpcDomain, cpcDefaultName, stLength);
|
||||||
bResult = true;
|
bResult = true;
|
||||||
}
|
}
|
||||||
else {
|
else {
|
||||||
@ -364,7 +364,7 @@ bool MDNSResponder::_setHostname(const char* p_pcHostname) {
|
|||||||
|
|
||||||
size_t stLength = 0;
|
size_t stLength = 0;
|
||||||
if ((p_pcHostname) &&
|
if ((p_pcHostname) &&
|
||||||
(MDNS_DOMAIN_LABEL_MAXLENGTH >= (stLength = os_strlen(p_pcHostname)))) { // char max size for a single label
|
(MDNS_DOMAIN_LABEL_MAXLENGTH >= (stLength = strlen(p_pcHostname)))) { // char max size for a single label
|
||||||
// Copy in hostname characters as lowercase
|
// Copy in hostname characters as lowercase
|
||||||
if ((bResult = (0 != (m_pcHostname = new char[stLength + 1])))) {
|
if ((bResult = (0 != (m_pcHostname = new char[stLength + 1])))) {
|
||||||
#ifdef MDNS_FORCE_LOWERCASE_HOSTNAME
|
#ifdef MDNS_FORCE_LOWERCASE_HOSTNAME
|
||||||
@ -374,7 +374,7 @@ bool MDNSResponder::_setHostname(const char* p_pcHostname) {
|
|||||||
}
|
}
|
||||||
m_pcHostname[i] = 0;
|
m_pcHostname[i] = 0;
|
||||||
#else
|
#else
|
||||||
os_strncpy(m_pcHostname, p_pcHostname, (stLength + 1));
|
strncpy(m_pcHostname, p_pcHostname, (stLength + 1));
|
||||||
#endif
|
#endif
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
@ -408,11 +408,11 @@ MDNSResponder::stcMDNSService* MDNSResponder::_allocService(const char* p_pcName
|
|||||||
|
|
||||||
stcMDNSService* pService = 0;
|
stcMDNSService* pService = 0;
|
||||||
if (((!p_pcName) ||
|
if (((!p_pcName) ||
|
||||||
(MDNS_DOMAIN_LABEL_MAXLENGTH >= os_strlen(p_pcName))) &&
|
(MDNS_DOMAIN_LABEL_MAXLENGTH >= strlen(p_pcName))) &&
|
||||||
(p_pcService) &&
|
(p_pcService) &&
|
||||||
(MDNS_SERVICE_NAME_LENGTH >= os_strlen(p_pcService)) &&
|
(MDNS_SERVICE_NAME_LENGTH >= strlen(p_pcService)) &&
|
||||||
(p_pcProtocol) &&
|
(p_pcProtocol) &&
|
||||||
(MDNS_SERVICE_PROTOCOL_LENGTH >= os_strlen(p_pcProtocol)) &&
|
(MDNS_SERVICE_PROTOCOL_LENGTH >= strlen(p_pcProtocol)) &&
|
||||||
(p_u16Port) &&
|
(p_u16Port) &&
|
||||||
(0 != (pService = new stcMDNSService)) &&
|
(0 != (pService = new stcMDNSService)) &&
|
||||||
(pService->setName(p_pcName ?: m_pcHostname)) &&
|
(pService->setName(p_pcName ?: m_pcHostname)) &&
|
||||||
@ -528,23 +528,23 @@ MDNSResponder::stcMDNSServiceTxt* MDNSResponder::_allocServiceTxt(MDNSResponder:
|
|||||||
(p_pcKey) &&
|
(p_pcKey) &&
|
||||||
(MDNS_SERVICE_TXT_MAXLENGTH > (p_pService->m_Txts.length() +
|
(MDNS_SERVICE_TXT_MAXLENGTH > (p_pService->m_Txts.length() +
|
||||||
1 + // Length byte
|
1 + // Length byte
|
||||||
(p_pcKey ? os_strlen(p_pcKey) : 0) +
|
(p_pcKey ? strlen(p_pcKey) : 0) +
|
||||||
1 + // '='
|
1 + // '='
|
||||||
(p_pcValue ? os_strlen(p_pcValue) : 0)))) {
|
(p_pcValue ? strlen(p_pcValue) : 0)))) {
|
||||||
|
|
||||||
pTxt = new stcMDNSServiceTxt;
|
pTxt = new stcMDNSServiceTxt;
|
||||||
if (pTxt) {
|
if (pTxt) {
|
||||||
size_t stLength = (p_pcKey ? os_strlen(p_pcKey) : 0);
|
size_t stLength = (p_pcKey ? strlen(p_pcKey) : 0);
|
||||||
pTxt->m_pcKey = new char[stLength + 1];
|
pTxt->m_pcKey = new char[stLength + 1];
|
||||||
if (pTxt->m_pcKey) {
|
if (pTxt->m_pcKey) {
|
||||||
os_strncpy(pTxt->m_pcKey, p_pcKey, stLength); pTxt->m_pcKey[stLength] = 0;
|
strncpy(pTxt->m_pcKey, p_pcKey, stLength); pTxt->m_pcKey[stLength] = 0;
|
||||||
}
|
}
|
||||||
|
|
||||||
if (p_pcValue) {
|
if (p_pcValue) {
|
||||||
stLength = (p_pcValue ? os_strlen(p_pcValue) : 0);
|
stLength = (p_pcValue ? strlen(p_pcValue) : 0);
|
||||||
pTxt->m_pcValue = new char[stLength + 1];
|
pTxt->m_pcValue = new char[stLength + 1];
|
||||||
if (pTxt->m_pcValue) {
|
if (pTxt->m_pcValue) {
|
||||||
os_strncpy(pTxt->m_pcValue, p_pcValue, stLength); pTxt->m_pcValue[stLength] = 0;
|
strncpy(pTxt->m_pcValue, p_pcValue, stLength); pTxt->m_pcValue[stLength] = 0;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
pTxt->m_bTemp = p_bTemp;
|
pTxt->m_bTemp = p_bTemp;
|
||||||
@ -578,8 +578,8 @@ MDNSResponder::stcMDNSServiceTxt* MDNSResponder::_updateServiceTxt(MDNSResponder
|
|||||||
if ((p_pService) &&
|
if ((p_pService) &&
|
||||||
(p_pTxt) &&
|
(p_pTxt) &&
|
||||||
(MDNS_SERVICE_TXT_MAXLENGTH > (p_pService->m_Txts.length() -
|
(MDNS_SERVICE_TXT_MAXLENGTH > (p_pService->m_Txts.length() -
|
||||||
(p_pTxt->m_pcValue ? os_strlen(p_pTxt->m_pcValue) : 0) +
|
(p_pTxt->m_pcValue ? strlen(p_pTxt->m_pcValue) : 0) +
|
||||||
(p_pcValue ? os_strlen(p_pcValue) : 0)))) {
|
(p_pcValue ? strlen(p_pcValue) : 0)))) {
|
||||||
p_pTxt->update(p_pcValue);
|
p_pTxt->update(p_pcValue);
|
||||||
p_pTxt->m_bTemp = p_bTemp;
|
p_pTxt->m_bTemp = p_bTemp;
|
||||||
}
|
}
|
||||||
@ -615,7 +615,7 @@ MDNSResponder::stcMDNSServiceTxt* MDNSResponder::_addServiceTxt(MDNSResponder::s
|
|||||||
|
|
||||||
if ((p_pService) &&
|
if ((p_pService) &&
|
||||||
(p_pcKey) &&
|
(p_pcKey) &&
|
||||||
(os_strlen(p_pcKey))) {
|
(strlen(p_pcKey))) {
|
||||||
|
|
||||||
stcMDNSServiceTxt* pTxt = p_pService->m_Txts.find(p_pcKey);
|
stcMDNSServiceTxt* pTxt = p_pService->m_Txts.find(p_pcKey);
|
||||||
if (pTxt) {
|
if (pTxt) {
|
||||||
|
@ -126,7 +126,7 @@ bool MDNSResponder::stcMDNSServiceTxt::setKey(const char* p_pcKey,
|
|||||||
releaseKey();
|
releaseKey();
|
||||||
if (p_stLength) {
|
if (p_stLength) {
|
||||||
if (allocKey(p_stLength)) {
|
if (allocKey(p_stLength)) {
|
||||||
os_strncpy(m_pcKey, p_pcKey, p_stLength);
|
strncpy(m_pcKey, p_pcKey, p_stLength);
|
||||||
m_pcKey[p_stLength] = 0;
|
m_pcKey[p_stLength] = 0;
|
||||||
bResult = true;
|
bResult = true;
|
||||||
}
|
}
|
||||||
@ -139,7 +139,7 @@ bool MDNSResponder::stcMDNSServiceTxt::setKey(const char* p_pcKey,
|
|||||||
*/
|
*/
|
||||||
bool MDNSResponder::stcMDNSServiceTxt::setKey(const char* p_pcKey) {
|
bool MDNSResponder::stcMDNSServiceTxt::setKey(const char* p_pcKey) {
|
||||||
|
|
||||||
return setKey(p_pcKey, (p_pcKey ? os_strlen(p_pcKey) : 0));
|
return setKey(p_pcKey, (p_pcKey ? strlen(p_pcKey) : 0));
|
||||||
}
|
}
|
||||||
|
|
||||||
/*
|
/*
|
||||||
@ -177,7 +177,7 @@ bool MDNSResponder::stcMDNSServiceTxt::setValue(const char* p_pcValue,
|
|||||||
releaseValue();
|
releaseValue();
|
||||||
if (p_stLength) {
|
if (p_stLength) {
|
||||||
if (allocValue(p_stLength)) {
|
if (allocValue(p_stLength)) {
|
||||||
os_strncpy(m_pcValue, p_pcValue, p_stLength);
|
strncpy(m_pcValue, p_pcValue, p_stLength);
|
||||||
m_pcValue[p_stLength] = 0;
|
m_pcValue[p_stLength] = 0;
|
||||||
bResult = true;
|
bResult = true;
|
||||||
}
|
}
|
||||||
@ -193,7 +193,7 @@ bool MDNSResponder::stcMDNSServiceTxt::setValue(const char* p_pcValue,
|
|||||||
*/
|
*/
|
||||||
bool MDNSResponder::stcMDNSServiceTxt::setValue(const char* p_pcValue) {
|
bool MDNSResponder::stcMDNSServiceTxt::setValue(const char* p_pcValue) {
|
||||||
|
|
||||||
return setValue(p_pcValue, (p_pcValue ? os_strlen(p_pcValue) : 0));
|
return setValue(p_pcValue, (p_pcValue ? strlen(p_pcValue) : 0));
|
||||||
}
|
}
|
||||||
|
|
||||||
/*
|
/*
|
||||||
@ -237,9 +237,9 @@ size_t MDNSResponder::stcMDNSServiceTxt::length(void) const {
|
|||||||
|
|
||||||
size_t stLength = 0;
|
size_t stLength = 0;
|
||||||
if (m_pcKey) {
|
if (m_pcKey) {
|
||||||
stLength += os_strlen(m_pcKey); // Key
|
stLength += strlen(m_pcKey); // Key
|
||||||
stLength += 1; // '='
|
stLength += 1; // '='
|
||||||
stLength += (m_pcValue ? os_strlen(m_pcValue) : 0); // Value
|
stLength += (m_pcValue ? strlen(m_pcValue) : 0); // Value
|
||||||
}
|
}
|
||||||
return stLength;
|
return stLength;
|
||||||
}
|
}
|
||||||
@ -461,15 +461,15 @@ bool MDNSResponder::stcMDNSServiceTxts::c_str(char* p_pcBuffer) {
|
|||||||
*p_pcBuffer = 0;
|
*p_pcBuffer = 0;
|
||||||
for (stcMDNSServiceTxt* pTxt=m_pTxts; ((bResult) && (pTxt)); pTxt = pTxt->m_pNext) {
|
for (stcMDNSServiceTxt* pTxt=m_pTxts; ((bResult) && (pTxt)); pTxt = pTxt->m_pNext) {
|
||||||
size_t stLength;
|
size_t stLength;
|
||||||
if ((bResult = (0 != (stLength = (pTxt->m_pcKey ? os_strlen(pTxt->m_pcKey) : 0))))) {
|
if ((bResult = (0 != (stLength = (pTxt->m_pcKey ? strlen(pTxt->m_pcKey) : 0))))) {
|
||||||
if (pTxt != m_pTxts) {
|
if (pTxt != m_pTxts) {
|
||||||
*p_pcBuffer++ = ';';
|
*p_pcBuffer++ = ';';
|
||||||
}
|
}
|
||||||
os_strncpy(p_pcBuffer, pTxt->m_pcKey, stLength); p_pcBuffer[stLength] = 0;
|
strncpy(p_pcBuffer, pTxt->m_pcKey, stLength); p_pcBuffer[stLength] = 0;
|
||||||
p_pcBuffer += stLength;
|
p_pcBuffer += stLength;
|
||||||
*p_pcBuffer++ = '=';
|
*p_pcBuffer++ = '=';
|
||||||
if ((stLength = (pTxt->m_pcValue ? os_strlen(pTxt->m_pcValue) : 0))) {
|
if ((stLength = (pTxt->m_pcValue ? strlen(pTxt->m_pcValue) : 0))) {
|
||||||
os_strncpy(p_pcBuffer, pTxt->m_pcValue, stLength); p_pcBuffer[stLength] = 0;
|
strncpy(p_pcBuffer, pTxt->m_pcValue, stLength); p_pcBuffer[stLength] = 0;
|
||||||
p_pcBuffer += stLength;
|
p_pcBuffer += stLength;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
@ -503,12 +503,12 @@ bool MDNSResponder::stcMDNSServiceTxts::buffer(char* p_pcBuffer) {
|
|||||||
for (stcMDNSServiceTxt* pTxt=m_pTxts; ((bResult) && (pTxt)); pTxt = pTxt->m_pNext) {
|
for (stcMDNSServiceTxt* pTxt=m_pTxts; ((bResult) && (pTxt)); pTxt = pTxt->m_pNext) {
|
||||||
*(unsigned char*)p_pcBuffer++ = pTxt->length();
|
*(unsigned char*)p_pcBuffer++ = pTxt->length();
|
||||||
size_t stLength;
|
size_t stLength;
|
||||||
if ((bResult = (0 != (stLength = (pTxt->m_pcKey ? os_strlen(pTxt->m_pcKey) : 0))))) {
|
if ((bResult = (0 != (stLength = (pTxt->m_pcKey ? strlen(pTxt->m_pcKey) : 0))))) {
|
||||||
os_memcpy(p_pcBuffer, pTxt->m_pcKey, stLength);
|
memcpy(p_pcBuffer, pTxt->m_pcKey, stLength);
|
||||||
p_pcBuffer += stLength;
|
p_pcBuffer += stLength;
|
||||||
*p_pcBuffer++ = '=';
|
*p_pcBuffer++ = '=';
|
||||||
if ((stLength = (pTxt->m_pcValue ? os_strlen(pTxt->m_pcValue) : 0))) {
|
if ((stLength = (pTxt->m_pcValue ? strlen(pTxt->m_pcValue) : 0))) {
|
||||||
os_memcpy(p_pcBuffer, pTxt->m_pcValue, stLength);
|
memcpy(p_pcBuffer, pTxt->m_pcValue, stLength);
|
||||||
p_pcBuffer += stLength;
|
p_pcBuffer += stLength;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
@ -532,7 +532,7 @@ bool MDNSResponder::stcMDNSServiceTxts::compare(const MDNSResponder::stcMDNSServ
|
|||||||
bResult = ((pOtherTxt) &&
|
bResult = ((pOtherTxt) &&
|
||||||
(pTxt->m_pcValue) &&
|
(pTxt->m_pcValue) &&
|
||||||
(pOtherTxt->m_pcValue) &&
|
(pOtherTxt->m_pcValue) &&
|
||||||
(os_strlen(pTxt->m_pcValue) == os_strlen(pOtherTxt->m_pcValue)) &&
|
(strlen(pTxt->m_pcValue) == strlen(pOtherTxt->m_pcValue)) &&
|
||||||
(0 == strcmp(pTxt->m_pcValue, pOtherTxt->m_pcValue)));
|
(0 == strcmp(pTxt->m_pcValue, pOtherTxt->m_pcValue)));
|
||||||
}
|
}
|
||||||
// Compare B->A
|
// Compare B->A
|
||||||
@ -541,7 +541,7 @@ bool MDNSResponder::stcMDNSServiceTxts::compare(const MDNSResponder::stcMDNSServ
|
|||||||
bResult = ((pTxt) &&
|
bResult = ((pTxt) &&
|
||||||
(pOtherTxt->m_pcValue) &&
|
(pOtherTxt->m_pcValue) &&
|
||||||
(pTxt->m_pcValue) &&
|
(pTxt->m_pcValue) &&
|
||||||
(os_strlen(pOtherTxt->m_pcValue) == os_strlen(pTxt->m_pcValue)) &&
|
(strlen(pOtherTxt->m_pcValue) == strlen(pTxt->m_pcValue)) &&
|
||||||
(0 == strcmp(pOtherTxt->m_pcValue, pTxt->m_pcValue)));
|
(0 == strcmp(pOtherTxt->m_pcValue, pTxt->m_pcValue)));
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
@ -660,7 +660,7 @@ bool MDNSResponder::stcMDNS_RRDomain::addLabel(const char* p_pcLabel,
|
|||||||
bool bResult = false;
|
bool bResult = false;
|
||||||
|
|
||||||
size_t stLength = (p_pcLabel
|
size_t stLength = (p_pcLabel
|
||||||
? (os_strlen(p_pcLabel) + (p_bPrependUnderline ? 1 : 0))
|
? (strlen(p_pcLabel) + (p_bPrependUnderline ? 1 : 0))
|
||||||
: 0);
|
: 0);
|
||||||
if ((MDNS_DOMAIN_LABEL_MAXLENGTH >= stLength) &&
|
if ((MDNS_DOMAIN_LABEL_MAXLENGTH >= stLength) &&
|
||||||
(MDNS_DOMAIN_MAXLENGTH >= (m_u16NameLength + (1 + stLength)))) {
|
(MDNS_DOMAIN_MAXLENGTH >= (m_u16NameLength + (1 + stLength)))) {
|
||||||
@ -673,7 +673,7 @@ bool MDNSResponder::stcMDNS_RRDomain::addLabel(const char* p_pcLabel,
|
|||||||
m_acName[m_u16NameLength++] = '_';
|
m_acName[m_u16NameLength++] = '_';
|
||||||
--stLength;
|
--stLength;
|
||||||
}
|
}
|
||||||
os_strncpy(&(m_acName[m_u16NameLength]), p_pcLabel, stLength); m_acName[m_u16NameLength + stLength] = 0;
|
strncpy(&(m_acName[m_u16NameLength]), p_pcLabel, stLength); m_acName[m_u16NameLength + stLength] = 0;
|
||||||
m_u16NameLength += stLength;
|
m_u16NameLength += stLength;
|
||||||
}
|
}
|
||||||
bResult = true;
|
bResult = true;
|
||||||
@ -1235,10 +1235,10 @@ bool MDNSResponder::stcMDNSService::setName(const char* p_pcName) {
|
|||||||
bool bResult = false;
|
bool bResult = false;
|
||||||
|
|
||||||
releaseName();
|
releaseName();
|
||||||
size_t stLength = (p_pcName ? os_strlen(p_pcName) : 0);
|
size_t stLength = (p_pcName ? strlen(p_pcName) : 0);
|
||||||
if (stLength) {
|
if (stLength) {
|
||||||
if ((bResult = (0 != (m_pcName = new char[stLength + 1])))) {
|
if ((bResult = (0 != (m_pcName = new char[stLength + 1])))) {
|
||||||
os_strncpy(m_pcName, p_pcName, stLength);
|
strncpy(m_pcName, p_pcName, stLength);
|
||||||
m_pcName[stLength] = 0;
|
m_pcName[stLength] = 0;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
@ -1268,10 +1268,10 @@ bool MDNSResponder::stcMDNSService::setService(const char* p_pcService) {
|
|||||||
bool bResult = false;
|
bool bResult = false;
|
||||||
|
|
||||||
releaseService();
|
releaseService();
|
||||||
size_t stLength = (p_pcService ? os_strlen(p_pcService) : 0);
|
size_t stLength = (p_pcService ? strlen(p_pcService) : 0);
|
||||||
if (stLength) {
|
if (stLength) {
|
||||||
if ((bResult = (0 != (m_pcService = new char[stLength + 1])))) {
|
if ((bResult = (0 != (m_pcService = new char[stLength + 1])))) {
|
||||||
os_strncpy(m_pcService, p_pcService, stLength);
|
strncpy(m_pcService, p_pcService, stLength);
|
||||||
m_pcService[stLength] = 0;
|
m_pcService[stLength] = 0;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
@ -1301,10 +1301,10 @@ bool MDNSResponder::stcMDNSService::setProtocol(const char* p_pcProtocol) {
|
|||||||
bool bResult = false;
|
bool bResult = false;
|
||||||
|
|
||||||
releaseProtocol();
|
releaseProtocol();
|
||||||
size_t stLength = (p_pcProtocol ? os_strlen(p_pcProtocol) : 0);
|
size_t stLength = (p_pcProtocol ? strlen(p_pcProtocol) : 0);
|
||||||
if (stLength) {
|
if (stLength) {
|
||||||
if ((bResult = (0 != (m_pcProtocol = new char[stLength + 1])))) {
|
if ((bResult = (0 != (m_pcProtocol = new char[stLength + 1])))) {
|
||||||
os_strncpy(m_pcProtocol, p_pcProtocol, stLength);
|
strncpy(m_pcProtocol, p_pcProtocol, stLength);
|
||||||
m_pcProtocol[stLength] = 0;
|
m_pcProtocol[stLength] = 0;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -237,6 +237,7 @@ ARDUINO_LIBS := \
|
|||||||
ESP8266mDNS/src/LEAmDNS_Helpers.cpp \
|
ESP8266mDNS/src/LEAmDNS_Helpers.cpp \
|
||||||
ESP8266mDNS/src/LEAmDNS_Structs.cpp \
|
ESP8266mDNS/src/LEAmDNS_Structs.cpp \
|
||||||
ESP8266mDNS/src/LEAmDNS_Transfer.cpp \
|
ESP8266mDNS/src/LEAmDNS_Transfer.cpp \
|
||||||
|
ESP8266mDNS/src/ESP8266mDNS.cpp \
|
||||||
ArduinoOTA/ArduinoOTA.cpp \
|
ArduinoOTA/ArduinoOTA.cpp \
|
||||||
DNSServer/src/DNSServer.cpp \
|
DNSServer/src/DNSServer.cpp \
|
||||||
ESP8266AVRISP/src/ESP8266AVRISP.cpp \
|
ESP8266AVRISP/src/ESP8266AVRISP.cpp \
|
||||||
|
Loading…
x
Reference in New Issue
Block a user