mirror of
https://github.com/esp8266/Arduino.git
synced 2025-04-21 10:26:06 +03:00
Ignore unknown records (AAAA) in the query response; this way we can extract the IPv4 address and connect to the server.
This commit is contained in:
parent
d60d744b59
commit
30720ce87a
@ -470,8 +470,8 @@ void MDNSResponder::_parsePacket(){
|
|||||||
}
|
}
|
||||||
|
|
||||||
int numAnswers = packetHeader[3];
|
int numAnswers = packetHeader[3];
|
||||||
// Assume that the PTR answer always comes first and that it is always accompanied by a TXT, SRV and A answer in the same packet.
|
// Assume that the PTR answer always comes first and that it is always accompanied by a TXT, SRV, AAAA (optional) and A answer in the same packet.
|
||||||
if (numAnswers != 4) {
|
if (numAnswers < 4) {
|
||||||
#ifdef MDNS_DEBUG_RX
|
#ifdef MDNS_DEBUG_RX
|
||||||
Serial.println("Expected a packet with 4 answers, returning");
|
Serial.println("Expected a packet with 4 answers, returning");
|
||||||
#endif
|
#endif
|
||||||
@ -550,7 +550,7 @@ void MDNSResponder::_parsePacket(){
|
|||||||
#endif
|
#endif
|
||||||
}
|
}
|
||||||
|
|
||||||
if (answerType == MDNS_TYPE_TXT) {
|
else if (answerType == MDNS_TYPE_TXT) {
|
||||||
partsCollected |= 0x02;
|
partsCollected |= 0x02;
|
||||||
_conn_readS(hostName, answerRdlength); // Read rdata
|
_conn_readS(hostName, answerRdlength); // Read rdata
|
||||||
#ifdef MDNS_DEBUG_RX
|
#ifdef MDNS_DEBUG_RX
|
||||||
@ -561,7 +561,7 @@ void MDNSResponder::_parsePacket(){
|
|||||||
#endif
|
#endif
|
||||||
}
|
}
|
||||||
|
|
||||||
if (answerType == MDNS_TYPE_SRV) {
|
else if (answerType == MDNS_TYPE_SRV) {
|
||||||
partsCollected |= 0x04;
|
partsCollected |= 0x04;
|
||||||
uint16_t answerPrio = _conn_read16(); // Read priority
|
uint16_t answerPrio = _conn_read16(); // Read priority
|
||||||
uint16_t answerWeight = _conn_read16(); // Read weight
|
uint16_t answerWeight = _conn_read16(); // Read weight
|
||||||
@ -589,12 +589,19 @@ void MDNSResponder::_parsePacket(){
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
if (answerType == MDNS_TYPE_A) {
|
else if (answerType == MDNS_TYPE_A) {
|
||||||
partsCollected |= 0x08;
|
partsCollected |= 0x08;
|
||||||
for (int i = 0; i < 4; i++) {
|
for (int i = 0; i < 4; i++) {
|
||||||
answerIp[i] = _conn_read8();
|
answerIp[i] = _conn_read8();
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
else {
|
||||||
|
#ifdef MDNS_DEBUG_RX
|
||||||
|
Serial.printf("Ignoring unsupported type %d\n", tmp8);
|
||||||
|
#endif
|
||||||
|
for (int n = 0; n < answerRdlength; n++)
|
||||||
|
(void)_conn_read8();
|
||||||
|
}
|
||||||
|
|
||||||
if ((partsCollected == 0x0F) && serviceMatch) {
|
if ((partsCollected == 0x0F) && serviceMatch) {
|
||||||
#ifdef MDNS_DEBUG_RX
|
#ifdef MDNS_DEBUG_RX
|
||||||
|
Loading…
x
Reference in New Issue
Block a user