Skip to content

LWIP DNS servers setting/getting fixed. #10794

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Merged
merged 1 commit into from
Jun 11, 2019
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
5 changes: 0 additions & 5 deletions features/lwipstack/LWIPInterface.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -94,11 +94,6 @@ static int get_ip_addr_type(const ip_addr_t *ip_addr)

void LWIP::add_dns_addr(struct netif *lwip_netif, const char *interface_name)
{

if (!netif_check_default(lwip_netif)) {
interface_name = NULL;
}

// Check for existing dns address
for (char numdns = 0; numdns < DNS_MAX_SERVERS; numdns++) {
const ip_addr_t *dns_ip_addr = dns_getserver(numdns, interface_name);
Expand Down
15 changes: 8 additions & 7 deletions features/lwipstack/lwip/src/core/lwip_dns.c
Original file line number Diff line number Diff line change
Expand Up @@ -367,7 +367,7 @@ void
dns_setserver(u8_t numdns, const ip_addr_t *dnsserver, struct netif *netif)
{

if (netif == NULL || netif_check_default(netif)) {
if (netif == NULL ) {
if (numdns < DNS_MAX_SERVERS) {
if (dnsserver != NULL) {
dns_servers[numdns] = (*dnsserver);
Expand All @@ -390,17 +390,18 @@ dns_setserver(u8_t numdns, const ip_addr_t *dnsserver, struct netif *netif)
* @return IP address of the indexed DNS server or "ip_addr_any" if the DNS
* server has not been configured.
*/
const ip_addr_t*
const ip_addr_t *
dns_getserver(u8_t numdns, const char *interface_name)
{
if (interface_name == NULL) {
if (numdns < DNS_MAX_SERVERS) {
return &dns_servers[numdns];
if (numdns < DNS_MAX_SERVERS) {
const ip_addr_t *dns_addr = dns_get_interface_server(numdns, interface_name);
if (dns_addr != IP_ADDR_ANY) {
return dns_addr;
} else {
return IP_ADDR_ANY;
return &dns_servers[numdns];
}
} else {
return dns_get_interface_server(numdns, interface_name);
return IP_ADDR_ANY;
}
}

Expand Down
2 changes: 1 addition & 1 deletion features/netsocket/mbed_lib.json
Original file line number Diff line number Diff line change
Expand Up @@ -52,7 +52,7 @@
},
"dns-retries": {
"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.",
"value": 0
"value": 2
},
"dns-cache-size": {
"help": "Number of cached host name resolutions",
Expand Down
4 changes: 2 additions & 2 deletions features/netsocket/nsapi_dns.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -105,10 +105,10 @@ static void nsapi_dns_query_async_initiate_next(void);
// *INDENT-OFF*
static nsapi_addr_t dns_servers[DNS_SERVERS_SIZE] = {
{NSAPI_IPv4, {8, 8, 8, 8}}, // Google
{NSAPI_IPv4, {209, 244, 0, 3}}, // Level 3
{NSAPI_IPv4, {84, 200, 69, 80}}, // DNS.WATCH
{NSAPI_IPv6, {0x20,0x01, 0x48,0x60, 0x48,0x60, 0,0, // Google
0,0, 0,0, 0,0, 0x88,0x88}},
{NSAPI_IPv4, {209, 244, 0, 3}}, // Level 3
{NSAPI_IPv4, {84, 200, 69, 80}}, // DNS.WATCH
{NSAPI_IPv6, {0x20,0x01, 0x16,0x08, 0,0x10, 0,0x25, // DNS.WATCH
0,0, 0,0, 0x1c,0x04, 0xb1,0x2f}},
};
Expand Down