Skip to content

Cellular: Fix to not use all zero address for DNS #12114

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
Dec 17, 2019
Merged
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
24 changes: 18 additions & 6 deletions features/cellular/framework/AT/AT_CellularContext.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -486,14 +486,26 @@ nsapi_error_t AT_CellularContext::activate_ip_context()
while (pdp) {
SocketAddress addr;
if (addr.set_ip_address(pdp->dns_secondary_addr)) {
tr_info("DNS secondary %s", pdp->dns_secondary_addr);
char ifn[5]; // "ce" + two digit _cid + zero
add_dns_server(addr, get_interface_name(ifn));
nsapi_addr_t taddr = addr.get_addr();
for (int i = 0; i < ((taddr.version == NSAPI_IPv6) ? NSAPI_IPv6_BYTES : NSAPI_IPv4_BYTES); i++) {
if (taddr.bytes[i] != 0) { // check the address is not all zero
tr_info("DNS secondary %s", pdp->dns_secondary_addr);
char ifn[5]; // "ce" + two digit _cid + zero
add_dns_server(addr, get_interface_name(ifn));
break;
}
}
}
if (addr.set_ip_address(pdp->dns_primary_addr)) {
tr_info("DNS primary %s", pdp->dns_primary_addr);
char ifn[5]; // "ce" + two digit _cid + zero
add_dns_server(addr, get_interface_name(ifn));
nsapi_addr_t taddr = addr.get_addr();
for (int i = 0; i < ((taddr.version == NSAPI_IPv6) ? NSAPI_IPv6_BYTES : NSAPI_IPv4_BYTES); i++) {
if (taddr.bytes[i] != 0) { // check the address is not all zero
tr_info("DNS primary %s", pdp->dns_primary_addr);
char ifn[5]; // "ce" + two digit _cid + zero
add_dns_server(addr, get_interface_name(ifn));
break;
}
}
}
pdp = pdp->next;
}
Expand Down