Skip to content

Commit ed69fc1

Browse files
authored
Merge pull request #10794 from tymoteuszblochmobica/dns
LWIP DNS servers setting/getting fixed.
2 parents 09ea361 + 4005c77 commit ed69fc1

File tree

4 files changed

+11
-15
lines changed

4 files changed

+11
-15
lines changed

features/lwipstack/LWIPInterface.cpp

Lines changed: 0 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -94,11 +94,6 @@ static int get_ip_addr_type(const ip_addr_t *ip_addr)
9494

9595
void LWIP::add_dns_addr(struct netif *lwip_netif, const char *interface_name)
9696
{
97-
98-
if (!netif_check_default(lwip_netif)) {
99-
interface_name = NULL;
100-
}
101-
10297
// Check for existing dns address
10398
for (char numdns = 0; numdns < DNS_MAX_SERVERS; numdns++) {
10499
const ip_addr_t *dns_ip_addr = dns_getserver(numdns, interface_name);

features/lwipstack/lwip/src/core/lwip_dns.c

Lines changed: 8 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -367,7 +367,7 @@ void
367367
dns_setserver(u8_t numdns, const ip_addr_t *dnsserver, struct netif *netif)
368368
{
369369

370-
if (netif == NULL || netif_check_default(netif)) {
370+
if (netif == NULL ) {
371371
if (numdns < DNS_MAX_SERVERS) {
372372
if (dnsserver != NULL) {
373373
dns_servers[numdns] = (*dnsserver);
@@ -390,17 +390,18 @@ dns_setserver(u8_t numdns, const ip_addr_t *dnsserver, struct netif *netif)
390390
* @return IP address of the indexed DNS server or "ip_addr_any" if the DNS
391391
* server has not been configured.
392392
*/
393-
const ip_addr_t*
393+
const ip_addr_t *
394394
dns_getserver(u8_t numdns, const char *interface_name)
395395
{
396-
if (interface_name == NULL) {
397-
if (numdns < DNS_MAX_SERVERS) {
398-
return &dns_servers[numdns];
396+
if (numdns < DNS_MAX_SERVERS) {
397+
const ip_addr_t *dns_addr = dns_get_interface_server(numdns, interface_name);
398+
if (dns_addr != IP_ADDR_ANY) {
399+
return dns_addr;
399400
} else {
400-
return IP_ADDR_ANY;
401+
return &dns_servers[numdns];
401402
}
402403
} else {
403-
return dns_get_interface_server(numdns, interface_name);
404+
return IP_ADDR_ANY;
404405
}
405406
}
406407

features/netsocket/mbed_lib.json

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -52,7 +52,7 @@
5252
},
5353
"dns-retries": {
5454
"help": "Number of DNS query retries that the DNS translator makes per server, before moving on to the next server. Total retries/attempts is always limited by dns-total-attempts.",
55-
"value": 0
55+
"value": 2
5656
},
5757
"dns-cache-size": {
5858
"help": "Number of cached host name resolutions",

features/netsocket/nsapi_dns.cpp

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -105,10 +105,10 @@ static void nsapi_dns_query_async_initiate_next(void);
105105
// *INDENT-OFF*
106106
static nsapi_addr_t dns_servers[DNS_SERVERS_SIZE] = {
107107
{NSAPI_IPv4, {8, 8, 8, 8}}, // Google
108-
{NSAPI_IPv4, {209, 244, 0, 3}}, // Level 3
109-
{NSAPI_IPv4, {84, 200, 69, 80}}, // DNS.WATCH
110108
{NSAPI_IPv6, {0x20,0x01, 0x48,0x60, 0x48,0x60, 0,0, // Google
111109
0,0, 0,0, 0,0, 0x88,0x88}},
110+
{NSAPI_IPv4, {209, 244, 0, 3}}, // Level 3
111+
{NSAPI_IPv4, {84, 200, 69, 80}}, // DNS.WATCH
112112
{NSAPI_IPv6, {0x20,0x01, 0x16,0x08, 0,0x10, 0,0x25, // DNS.WATCH
113113
0,0, 0,0, 0x1c,0x04, 0xb1,0x2f}},
114114
};

0 commit comments

Comments
 (0)