Merge pull request #11375 from tymoteuszblochmobica/nsapi_dns

NSAPI DNS query IP version check for non LWIP stacks.
pull/11810/head
Martin Kojtal 2019-11-04 15:30:28 +01:00 committed by GitHub
commit 412b0ae5d5
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
1 changed files with 13 additions and 4 deletions

View File

@ -505,8 +505,13 @@ static nsapi_size_or_error_t nsapi_dns_query_multiple(NetworkStack *stack, const
break;
}
if (version != NSAPI_UNSPEC && (dns_addr.get_ip_version() != version)) {
retries = MBED_CONF_NSAPI_DNS_RETRIES;
index++;
continue;
}
// send the question
int len = dns_append_question(packet, 1, host, version);
int len = dns_append_question(packet, 1, host, dns_addr.get_ip_version());
err = socket.sendto(dns_addr, packet, len);
// send may fail for various reasons, including wrong address type - move on
@ -1039,9 +1044,6 @@ static void nsapi_dns_query_async_send(void *ptr)
return;
}
// send the question
int len = dns_append_question(packet, query->dns_message_id, query->host, query->version);
while (true) {
SocketAddress dns_addr;
nsapi_size_or_error_t err = nsapi_dns_get_server_addr(query->stack, &(query->dns_server), &(query->total_attempts), &(query->send_success), &dns_addr, query->interface_name);
@ -1051,6 +1053,13 @@ static void nsapi_dns_query_async_send(void *ptr)
return;
}
if (query->version != NSAPI_UNSPEC && dns_addr.get_ip_version() != query->version) {
query->dns_server++;
continue;
}
// send the question
int len = dns_append_question(packet, query->dns_message_id, query->host, dns_addr.get_ip_version());
err = query->socket->sendto(dns_addr, packet, len);
if (err < 0) {