Skip to content

Commit cab2f39

Browse files
author
Ari Parkkila
committed
Cellular: Add DNS servers from PDP contexts to nsapi_dns
1 parent 818c1d6 commit cab2f39

File tree

1 file changed

+22
-1
lines changed

1 file changed

+22
-1
lines changed

features/cellular/framework/AT/AT_CellularContext.cpp

Lines changed: 22 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -458,7 +458,28 @@ nsapi_error_t AT_CellularContext::do_activate_context()
458458

459459
nsapi_error_t AT_CellularContext::activate_ip_context()
460460
{
461-
return find_and_activate_context();
461+
nsapi_error_t ret = find_and_activate_context();
462+
#if !NSAPI_PPP_AVAILABLE
463+
if (ret == NSAPI_ERROR_OK) {
464+
pdpContextList_t params_list;
465+
if (get_pdpcontext_params(params_list) == NSAPI_ERROR_OK) {
466+
pdpcontext_params_t *pdp = params_list.get_head();
467+
while (pdp) {
468+
SocketAddress addr;
469+
if (addr.set_ip_address(pdp->dns_secondary_addr)) {
470+
tr_info("DNS secondary %s", pdp->dns_secondary_addr);
471+
add_dns_server(addr, get_interface_name(NULL));
472+
}
473+
if (addr.set_ip_address(pdp->dns_primary_addr)) {
474+
tr_info("DNS primary %s", pdp->dns_primary_addr);
475+
add_dns_server(addr, get_interface_name(NULL));
476+
}
477+
pdp = pdp->next;
478+
}
479+
}
480+
}
481+
#endif
482+
return ret;
462483
}
463484

464485
nsapi_error_t AT_CellularContext::activate_non_ip_context()

0 commit comments

Comments
 (0)