Skip to content

Commit

Permalink
applications: slm: try to continue even no DNS record was sent
Browse files Browse the repository at this point in the history
We shouldn't expect 2 DNS records from ISP.
Because it sends sometimes 1 and even 0.
It must try to continue like in MOSH.

Signed-off-by: Oguzhan Turk <[email protected]>
  • Loading branch information
TaeZStkyoht committed Dec 23, 2024
1 parent 6266884 commit bfb7fc6
Show file tree
Hide file tree
Showing 3 changed files with 17 additions and 12 deletions.
8 changes: 4 additions & 4 deletions applications/serial_lte_modem/src/slm_ppp.c
Original file line number Diff line number Diff line change
Expand Up @@ -214,10 +214,10 @@ static int ppp_start_internal(void)
&ctx->ipcp.my_options.dns2_address, &mtu);
if (ret) {
/* If any error happened on pdn getting with IPv4, try to parse with IPv6 */
ret = pdn_dynamic_params_get_v6(PDP_CID, NULL, NULL, &mtu);
if (ret) {
return ret;
}
pdn_dynamic_params_get_v6(PDP_CID, NULL, NULL, &mtu);
/* Don't check fallback's return value and try to continue.
* ISP may not send DNS records.
*/
}

if (mtu) {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -453,6 +453,7 @@ Modem libraries
* :ref:`pdn_readme` library:

* Added the :c:func:`pdn_dynamic_params_get_v6` function to get PDN parameters for IPv6-only.
* Changed logic DNS record expectation. Because ISP sends sometimes 1 and even 0.

* :ref:`lte_lc_readme` library:

Expand Down
20 changes: 12 additions & 8 deletions lib/pdn/pdn.c
Original file line number Diff line number Diff line change
Expand Up @@ -632,8 +632,8 @@ int pdn_dynamic_params_get(uint8_t cid, struct in_addr *dns4_pri,

/* If IPv4 is enabled, it will be the first response line. */
matched = nrf_modem_at_scanf(at_cmd, fmt, &dns4_pri_str, &dns4_sec_str, &mtu);
/* Need to match at least the two IP addresses, or there is an error */
if (matched < 2) {

if (matched < 1) {
return -EBADMSG;
}

Expand All @@ -643,8 +643,10 @@ int pdn_dynamic_params_get(uint8_t cid, struct in_addr *dns4_pri,
}
}
if (dns4_sec) {
if (zsock_inet_pton(AF_INET, dns4_sec_str, dns4_sec) != 1) {
return -EADDRNOTAVAIL;
if (matched >= 2) {
if (zsock_inet_pton(AF_INET, dns4_sec_str, dns4_sec) != 1) {
return -EADDRNOTAVAIL;
}
}
}
if (ipv4_mtu) {
Expand Down Expand Up @@ -681,8 +683,8 @@ int pdn_dynamic_params_get_v6(uint8_t cid, struct in6_addr *dns6_pri,

/* If IPv6 is enabled, it will be the first response line. */
matched = nrf_modem_at_scanf(at_cmd, fmt, &dns6_pri_str, &dns6_sec_str, &mtu);
/* Need to match at least the two IP addresses, or there is an error */
if (matched < 2) {

if (matched < 1) {
return -EBADMSG;
}

Expand All @@ -692,8 +694,10 @@ int pdn_dynamic_params_get_v6(uint8_t cid, struct in6_addr *dns6_pri,
}
}
if (dns6_sec) {
if (zsock_inet_pton(AF_INET6, dns6_sec_str, dns6_sec) != 1) {
return -EADDRNOTAVAIL;
if (matched >= 2) {
if (zsock_inet_pton(AF_INET6, dns6_sec_str, dns6_sec) != 1) {
return -EADDRNOTAVAIL;
}
}
}
if (ipv6_mtu) {
Expand Down

0 comments on commit bfb7fc6

Please sign in to comment.