From f69eac8891e09fee2db7de78db67709e428846b0 Mon Sep 17 00:00:00 2001 From: Oguzhan Turk Date: Fri, 3 Jan 2025 15:02:04 +0100 Subject: [PATCH] pdn: make pdp_context_dynamic_params_get common - convert link_api_pdp_context_dynamic_params_get to pdn_pdp_context_dynamic_params_get and use it on both SLM and MOSH Signed-off-by: Oguzhan Turk --- applications/serial_lte_modem/src/slm_ppp.c | 24 +- .../releases/release-notes-changelog.rst | 4 +- include/modem/pdn.h | 97 +++++++- lib/pdn/pdn.c | 218 ++++++++++++------ .../cellular/modem_shell/src/link/link_api.c | 148 +----------- .../cellular/modem_shell/src/link/link_api.h | 23 +- 6 files changed, 258 insertions(+), 256 deletions(-) diff --git a/applications/serial_lte_modem/src/slm_ppp.c b/applications/serial_lte_modem/src/slm_ppp.c index 1e3db9578b16..7b1fb6848dcc 100644 --- a/applications/serial_lte_modem/src/slm_ppp.c +++ b/applications/serial_lte_modem/src/slm_ppp.c @@ -210,19 +210,21 @@ static int ppp_start_internal(void) return -EADDRNOTAVAIL; } - ret = pdn_dynamic_params_get(PDP_CID, &ctx->ipcp.my_options.dns1_address, - &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 && ret != -EBADMSG) { - return ret; - } - } + struct pdp_context_info populated_info = {}; - if (mtu) { + populated_info.cid = PDP_CID; + ret = pdn_pdp_context_dynamic_params_get(&populated_info); + + if (populated_info.ipv6_mtu) { + /* Set the PPP MTU to that of the LTE link. */ + /* IPv6's MTU has more priority on dual-stack. + * Because, it must be at least 1280 for IPv6, + * while MTU of IPv6 may be less. + */ + mtu = MIN(populated_info.ipv6_mtu, sizeof(ppp_data_buf)); + } else if (populated_info.ipv4_mtu) { /* Set the PPP MTU to that of the LTE link. */ - mtu = MIN(mtu, sizeof(ppp_data_buf)); + mtu = MIN(populated_info.ipv4_mtu, sizeof(ppp_data_buf)); } else { LOG_DBG("Could not retrieve MTU, using fallback value."); mtu = CONFIG_SLM_PPP_FALLBACK_MTU; diff --git a/doc/nrf/releases_and_maturity/releases/release-notes-changelog.rst b/doc/nrf/releases_and_maturity/releases/release-notes-changelog.rst index af50adfed416..98b29614f009 100644 --- a/doc/nrf/releases_and_maturity/releases/release-notes-changelog.rst +++ b/doc/nrf/releases_and_maturity/releases/release-notes-changelog.rst @@ -452,8 +452,8 @@ 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. + * mark :c:func:`pdn_dynamic_params_get` as deprecated + * move :c:func:`link_api_pdp_context_dynamic_params_get` to common place as :c:func:`pdn_pdp_context_dynamic_params_get` * :ref:`lte_lc_readme` library: diff --git a/include/modem/pdn.h b/include/modem/pdn.h index c3749d95f504..ce4de26d155a 100644 --- a/include/modem/pdn.h +++ b/include/modem/pdn.h @@ -16,6 +16,9 @@ extern "C" { #endif +#define AT_CMD_PDP_CONTEXT_READ_PDP_TYPE_STR_MAX_LEN (6 + 1) +#define APN_STR_MAX_LEN 64 + /** * @file pdn.h * @brief Public APIs for the PDN library. @@ -54,6 +57,88 @@ struct pdn_pdp_opt { uint8_t secure_pco; }; +/** + * @brief PDP context information structure. + * + * This structure holds information about the PDP context. + */ +struct pdp_context_info { + /** + * @brief Context identifier. + */ + uint32_t cid; + + /** + * @brief IPv4 Maximum Transmission Unit. + */ + uint32_t ipv4_mtu; + + /** + * @brief IPv6 Maximum Transmission Unit. + */ + uint32_t ipv6_mtu; + + /** + * @brief PDN identifier. + */ + uint32_t pdn_id; + + /** + * @brief Indicates if PDN identifier is valid. + */ + bool pdn_id_valid; + + /** + * @brief Indicates if the context is active. + */ + bool ctx_active; + + /** + * @brief PDP type as a string. + */ + char pdp_type_str[AT_CMD_PDP_CONTEXT_READ_PDP_TYPE_STR_MAX_LEN]; + + /** + * @brief Access Point Name as a string. + */ + char apn_str[APN_STR_MAX_LEN]; + + /** + * @brief PDP type. + */ + char pdp_type; + + /** + * @brief IPv4 address. + */ + struct in_addr ip_addr4; + + /** + * @brief IPv6 address. + */ + struct in6_addr ip_addr6; + + /** + * @brief Primary IPv4 DNS address. + */ + struct in_addr dns_addr4_primary; + + /** + * @brief Secondary IPv4 DNS address. + */ + struct in_addr dns_addr4_secondary; + + /** + * @brief Primary IPv6 DNS address. + */ + struct in6_addr dns_addr6_primary; + + /** + * @brief Secondary IPv6 DNS address. + */ + struct in6_addr dns_addr6_secondary; +}; + /** @brief PDN library event */ enum pdn_event { /** +CNEC ESM error code */ @@ -182,6 +267,7 @@ int pdn_id_get(uint8_t cid); /** * @brief Retrieve dynamic parameters of a given PDP context. + * This is deprecated. Use pdn_pdp_context_dynamic_params_get instead. * * @param cid The PDP context ID. * @param[out] dns4_pri The address of the primary IPv4 DNS server. Optional, can be NULL. @@ -190,22 +276,17 @@ int pdn_id_get(uint8_t cid); * * @return Zero on success or an error code on failure. */ -int pdn_dynamic_params_get(uint8_t cid, struct in_addr *dns4_pri, +__deprecated int pdn_dynamic_params_get(uint8_t cid, struct in_addr *dns4_pri, struct in_addr *dns4_sec, unsigned int *ipv4_mtu); /** * @brief Retrieve dynamic parameters of a given PDP context. * - * @param cid The PDP context ID. - * @param[out] dns6_pri The address of the primary IPv6 DNS server. Optional, can be NULL. - * @param[out] dns6_sec The address of the secondary IPv6 DNS server. Optional, can be NULL. - * @param[out] ipv6_mtu The IPv6 MTU. Optional, can be NULL. + * @param[inout] populated_info PDP context info. * * @return Zero on success or an error code on failure. */ -int pdn_dynamic_params_get_v6(uint8_t cid, struct in6_addr *dns6_pri, - struct in6_addr *dns6_sec, unsigned int *ipv6_mtu); - +int pdn_pdp_context_dynamic_params_get(struct pdp_context_info *populated_info); /** * @brief Retrieve the default Access Point Name (APN). * diff --git a/lib/pdn/pdn.c b/lib/pdn/pdn.c index f0f634f87823..89ed44cf27a3 100644 --- a/lib/pdn/pdn.c +++ b/lib/pdn/pdn.c @@ -28,12 +28,20 @@ LOG_MODULE_REGISTER(pdn, CONFIG_PDN_LOG_LEVEL); #define PDN_ACT_REASON_IPV4_ONLY (0) #define PDN_ACT_REASON_IPV6_ONLY (1) -#define APN_STR_MAX_LEN 64 - #define MODEM_CFUN_POWER_OFF 0 #define MODEM_CFUN_NORMAL 1 #define MODEM_CFUN_ACTIVATE_LTE 21 +#define AT_CMD_PDP_CONTEXT_READ_IP_ADDR_STR_MAX_LEN (255) + +#define AT_CMD_PDP_CONTEXT_READ_INFO \ + "AT+CGCONTRDP=%d" /* Use sprintf to add CID into command */ +#define AT_CMD_PDP_CONTEXT_READ_INFO_DNS_ADDR_PRIMARY_INDEX 6 +#define AT_CMD_PDP_CONTEXT_READ_INFO_DNS_ADDR_SECONDARY_INDEX 7 +#define AT_CMD_PDP_CONTEXT_READ_INFO_MTU_INDEX 12 + +#define AT_CMD_PDP_CONTEXT_READ_RSP_DELIM "\r\n" + static K_MUTEX_DEFINE(list_mutex); static sys_slist_t pdn_contexts = SYS_SLIST_STATIC_INIT(&pdn_context); @@ -624,17 +632,6 @@ int pdn_dynamic_params_get(uint8_t cid, struct in_addr *dns4_pri, char dns4_sec_str[INET_ADDRSTRLEN]; char at_cmd[sizeof("AT+CGCONTRDP=10")]; - /* Initialize out variables with default */ - if (dns4_pri) { - memset(dns4_pri, 0, sizeof(struct in_addr)); - } - if (dns4_sec) { - memset(dns4_sec, 0, sizeof(struct in_addr)); - } - if (ipv4_mtu) { - *ipv4_mtu = 0; - } - if (snprintf(at_cmd, sizeof(at_cmd), "AT+CGCONTRDP=%u", cid) >= sizeof(at_cmd)) { return -E2BIG; } @@ -643,8 +640,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); - - if (matched < 1) { + /* Need to match at least the two IP addresses, or there is an error */ + if (matched < 2) { return -EBADMSG; } @@ -654,10 +651,8 @@ int pdn_dynamic_params_get(uint8_t cid, struct in_addr *dns4_pri, } } if (dns4_sec) { - if (matched >= 2) { - if (zsock_inet_pton(AF_INET, dns4_sec_str, dns4_sec) != 1) { - return -EADDRNOTAVAIL; - } + if (zsock_inet_pton(AF_INET, dns4_sec_str, dns4_sec) != 1) { + return -EADDRNOTAVAIL; } } if (ipv4_mtu) { @@ -672,66 +667,153 @@ int pdn_dynamic_params_get(uint8_t cid, struct in_addr *dns4_pri, return 0; } -int pdn_dynamic_params_get_v6(uint8_t cid, struct in6_addr *dns6_pri, - struct in6_addr *dns6_sec, unsigned int *ipv6_mtu) +static int pdn_sa_family_from_ip_string(const char *src) { - int matched; - const char *fmt; - unsigned int mtu; - char dns6_pri_str[INET6_ADDRSTRLEN]; - char dns6_sec_str[INET6_ADDRSTRLEN]; - char at_cmd[sizeof("AT+CGCONTRDP=10")]; + char buf[INET6_ADDRSTRLEN]; - /* Initialize out variables with default */ - if (dns6_pri) { - memset(dns6_pri, 0, sizeof(struct in6_addr)); - } - if (dns6_sec) { - memset(dns6_sec, 0, sizeof(struct in6_addr)); - } - if (ipv6_mtu) { - *ipv6_mtu = 0; + if (inet_pton(AF_INET, src, buf)) { + return AF_INET; + } else if (inet_pton(AF_INET6, src, buf)) { + return AF_INET6; } + return -1; +} - if (snprintf(at_cmd, sizeof(at_cmd), "AT+CGCONTRDP=%u", cid) >= sizeof(at_cmd)) { - return -E2BIG; - } - /* "+CGCONTRDP: 0,,"ims","","", - * "0000:0000:0000:0000:0000:0000:0000:0000", - * "0000:0000:0000:0000:0000:0000:0000:0000",,,,,1500" +int pdn_pdp_context_dynamic_params_get(struct pdp_context_info *populated_info) +{ + int ret = 0; + struct at_parser parser; + size_t param_str_len; + + char cgcontrdp_at_rsp_buf[512]; + + char *at_ptr; + char *tmp_ptr; + int lines = 0; + int iterator = 0; + char dns_addr_str[AT_CMD_PDP_CONTEXT_READ_IP_ADDR_STR_MAX_LEN]; + + char at_cmd_pdp_context_read_info_cmd_str[15]; + + int family; + struct in_addr *addr; + struct in6_addr *addr6; + + if (!populated_info) { + goto clean_exit; + } + + at_ptr = cgcontrdp_at_rsp_buf; + tmp_ptr = cgcontrdp_at_rsp_buf; + + sprintf(at_cmd_pdp_context_read_info_cmd_str, + AT_CMD_PDP_CONTEXT_READ_INFO, populated_info->cid); + ret = nrf_modem_at_cmd(cgcontrdp_at_rsp_buf, sizeof(cgcontrdp_at_rsp_buf), "%s", + at_cmd_pdp_context_read_info_cmd_str); + if (ret) { + LOG_ERR( + "nrf_modem_at_cmd returned err: %d for %s", + ret, + at_cmd_pdp_context_read_info_cmd_str); + return ret; + } + + /* Check how many rows of info do we have */ + while (strncmp(tmp_ptr, "OK", 2) && + (tmp_ptr = strstr(tmp_ptr, AT_CMD_PDP_CONTEXT_READ_RSP_DELIM)) != NULL) { + tmp_ptr += 2; + lines++; + } + + /* Parse the response */ + ret = at_parser_init(&parser, at_ptr); + if (ret) { + LOG_ERR("Could not init AT parser for %s, error: %d\n", + at_cmd_pdp_context_read_info_cmd_str, ret); + return ret; + } + +parse: + /* Read primary DNS address */ + param_str_len = sizeof(dns_addr_str); + ret = at_parser_string_get( + &parser, + AT_CMD_PDP_CONTEXT_READ_INFO_DNS_ADDR_PRIMARY_INDEX, + dns_addr_str, ¶m_str_len); + if (ret) { + LOG_ERR( + "Could not parse dns str for cid %d, err: %d", + populated_info->cid, ret); + goto clean_exit; + } + dns_addr_str[param_str_len] = '\0'; + + family = pdn_sa_family_from_ip_string(dns_addr_str); + + if (family == AF_INET) { + addr = &(populated_info->dns_addr4_primary); + (void)inet_pton(AF_INET, dns_addr_str, addr); + } else if (family == AF_INET6) { + addr6 = &(populated_info->dns_addr6_primary); + (void)inet_pton(AF_INET6, dns_addr_str, addr6); + } + + /* Read secondary DNS address */ + param_str_len = sizeof(dns_addr_str); + + ret = at_parser_string_get( + &parser, + AT_CMD_PDP_CONTEXT_READ_INFO_DNS_ADDR_SECONDARY_INDEX, + dns_addr_str, ¶m_str_len); + if (ret) { + LOG_ERR("Could not parse dns str, err: %d", ret); + goto clean_exit; + } + dns_addr_str[param_str_len] = '\0'; + + family = pdn_sa_family_from_ip_string(dns_addr_str); + + if (family == AF_INET) { + addr = &(populated_info->dns_addr4_secondary); + (void)inet_pton(AF_INET, dns_addr_str, addr); + } else if (family == AF_INET6) { + addr6 = &(populated_info->dns_addr6_secondary); + (void)inet_pton(AF_INET6, dns_addr_str, addr6); + } + + /* Read link MTU if exists: + * AT command spec: + * Note: If the PDN connection has dual stack capabilities, at least one pair of + * lines with information is returned per : First one line with the IPv4 + * parameters followed by one line with the IPv6 parameters. */ - fmt = "+CGCONTRDP: %*u,,\"%*[^\"]\",\"\",\"\"," - "\"%45[0-9A-Fa-f:]\",\"%45[0-9A-Fa-f:]\",,,,,%u"; - - /* 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); - - if (matched < 1) { - return -EBADMSG; - } - - if (dns6_pri) { - if (zsock_inet_pton(AF_INET6, dns6_pri_str, dns6_pri) != 1) { - return -EADDRNOTAVAIL; + if (iterator == 1) { + ret = at_parser_num_get(&parser, AT_CMD_PDP_CONTEXT_READ_INFO_MTU_INDEX, + &(populated_info->ipv6_mtu)); + if (ret) { + /* Don't care if it fails */ + ret = 0; + populated_info->ipv6_mtu = 0; } - } - if (dns6_sec) { - if (matched >= 2) { - if (zsock_inet_pton(AF_INET6, dns6_sec_str, dns6_sec) != 1) { - return -EADDRNOTAVAIL; - } + } else { + ret = at_parser_num_get(&parser, AT_CMD_PDP_CONTEXT_READ_INFO_MTU_INDEX, + &(populated_info->ipv4_mtu)); + if (ret) { + /* Don't care if it fails */ + ret = 0; + populated_info->ipv4_mtu = 0; } } - if (ipv6_mtu) { - /* If we matched the MTU, copy it here, otherwise report zero */ - if (matched == 3) { - *ipv6_mtu = mtu; - } else { - *ipv6_mtu = 0; + + if (at_parser_cmd_next(&parser) == 0) { + iterator++; + if (iterator < lines) { + goto parse; } } - return 0; +clean_exit: + return ret; } int pdn_default_apn_get(char *buf, size_t len) diff --git a/samples/cellular/modem_shell/src/link/link_api.c b/samples/cellular/modem_shell/src/link/link_api.c index 1e26abdc98e6..ec829027def3 100644 --- a/samples/cellular/modem_shell/src/link/link_api.c +++ b/samples/cellular/modem_shell/src/link/link_api.c @@ -40,13 +40,7 @@ extern struct k_mutex mosh_at_resp_buf_mutex; #define AT_CMD_PDP_CONTEXTS_READ_APN_INDEX 3 #define AT_CMD_PDP_CONTEXTS_READ_PDP_ADDR_INDEX 4 -#define AT_CMD_PDP_CONTEXT_READ_INFO \ - "AT+CGCONTRDP=%d" /* Use sprintf to add CID into command */ -#define AT_CMD_PDP_CONTEXT_READ_INFO_PARAM_COUNT 20 -#define AT_CMD_PDP_CONTEXT_READ_INFO_CID_INDEX 1 -#define AT_CMD_PDP_CONTEXT_READ_INFO_DNS_ADDR_PRIMARY_INDEX 6 -#define AT_CMD_PDP_CONTEXT_READ_INFO_DNS_ADDR_SECONDARY_INDEX 7 -#define AT_CMD_PDP_CONTEXT_READ_INFO_MTU_INDEX 12 +#define AT_CMD_PDP_CONTEXT_READ_IP_ADDR_STR_MAX_LEN (255) #define AT_CMD_PDP_CONTEXT_READ_RSP_DELIM "\r\n" @@ -346,144 +340,6 @@ static void link_api_modem_operator_info_read_for_shell(void) /* ****************************************************************************/ -static int link_api_pdp_context_dynamic_params_get(struct pdp_context_info *populated_info) -{ - int ret = 0; - struct at_parser parser; - size_t param_str_len; - - /* Cannot use global mosh_at_resp_buf because this used from link_api_pdp_contexts_read() - * where global mosh_at_resp_buf is already used - */ - char cgcontrdp_at_rsp_buf[512]; - - char *at_ptr; - char *tmp_ptr; - int lines = 0; - int iterator = 0; - char dns_addr_str[AT_CMD_PDP_CONTEXT_READ_IP_ADDR_STR_MAX_LEN]; - - char at_cmd_pdp_context_read_info_cmd_str[15]; - - int family; - struct in_addr *addr; - struct in6_addr *addr6; - - at_ptr = cgcontrdp_at_rsp_buf; - tmp_ptr = cgcontrdp_at_rsp_buf; - - sprintf(at_cmd_pdp_context_read_info_cmd_str, - AT_CMD_PDP_CONTEXT_READ_INFO, populated_info->cid); - ret = nrf_modem_at_cmd(cgcontrdp_at_rsp_buf, sizeof(cgcontrdp_at_rsp_buf), "%s", - at_cmd_pdp_context_read_info_cmd_str); - if (ret) { - mosh_error( - "nrf_modem_at_cmd returned err: %d for %s", - ret, - at_cmd_pdp_context_read_info_cmd_str); - return ret; - } - - /* Check how many rows of info do we have */ - while (strncmp(tmp_ptr, "OK", 2) && - (tmp_ptr = strstr(tmp_ptr, AT_CMD_PDP_CONTEXT_READ_RSP_DELIM)) != NULL) { - tmp_ptr += 2; - lines++; - } - - /* Parse the response */ - ret = at_parser_init(&parser, at_ptr); - if (ret) { - mosh_error("Could not init AT parser for %s, error: %d\n", - at_cmd_pdp_context_read_info_cmd_str, ret); - return ret; - } - -parse: - /* Read primary DNS address */ - param_str_len = sizeof(dns_addr_str); - ret = at_parser_string_get( - &parser, - AT_CMD_PDP_CONTEXT_READ_INFO_DNS_ADDR_PRIMARY_INDEX, - dns_addr_str, ¶m_str_len); - if (ret) { - mosh_error( - "Could not parse dns str for cid %d, err: %d", - populated_info->cid, ret); - goto clean_exit; - } - dns_addr_str[param_str_len] = '\0'; - - family = net_utils_sa_family_from_ip_string(dns_addr_str); - - if (family == AF_INET) { - addr = &(populated_info->dns_addr4_primary); - (void)inet_pton(AF_INET, dns_addr_str, addr); - } else if (family == AF_INET6) { - addr6 = &(populated_info->dns_addr6_primary); - (void)inet_pton(AF_INET6, dns_addr_str, addr6); - } - - /* Read secondary DNS address */ - param_str_len = sizeof(dns_addr_str); - - ret = at_parser_string_get( - &parser, - AT_CMD_PDP_CONTEXT_READ_INFO_DNS_ADDR_SECONDARY_INDEX, - dns_addr_str, ¶m_str_len); - if (ret) { - mosh_error("Could not parse dns str, err: %d", ret); - goto clean_exit; - } - dns_addr_str[param_str_len] = '\0'; - - family = net_utils_sa_family_from_ip_string(dns_addr_str); - - if (family == AF_INET) { - addr = &(populated_info->dns_addr4_secondary); - (void)inet_pton(AF_INET, dns_addr_str, addr); - } else if (family == AF_INET6) { - addr6 = &(populated_info->dns_addr6_secondary); - (void)inet_pton(AF_INET6, dns_addr_str, addr6); - } - - /* Read link MTU if exists: - * AT command spec: - * Note: If the PDN connection has dual stack capabilities, at least one pair of - * lines with information is returned per : First one line with the IPv4 - * parameters followed by one line with the IPv6 parameters. - */ - if (iterator == 1) { - ret = at_parser_num_get(&parser, AT_CMD_PDP_CONTEXT_READ_INFO_MTU_INDEX, - &(populated_info->ipv6_mtu)); - if (ret) { - /* Don't care if it fails */ - ret = 0; - populated_info->ipv6_mtu = 0; - } - } else { - ret = at_parser_num_get(&parser, AT_CMD_PDP_CONTEXT_READ_INFO_MTU_INDEX, - &(populated_info->ipv4_mtu)); - if (ret) { - /* Don't care if it fails */ - ret = 0; - populated_info->ipv4_mtu = 0; - } - } - - if (at_parser_cmd_next(&parser) == 0) { - iterator++; - if (iterator < lines) { - goto parse; - } - } - -clean_exit: - return ret; -} - -/* ****************************************************************************/ - int link_api_pdp_contexts_read(struct pdp_context_info_array *pdp_info) { int ret = 0; @@ -631,7 +487,7 @@ int link_api_pdp_contexts_read(struct pdp_context_info_array *pdp_info) /* Get DNS addresses etc. for this IP context */ if (populated_info[iterator].pdp_type != PDP_TYPE_NONIP) { - (void)link_api_pdp_context_dynamic_params_get(&(populated_info[iterator])); + (void)pdn_pdp_context_dynamic_params_get(&(populated_info[iterator])); } if (at_parser_cmd_next(&parser) == 0) { diff --git a/samples/cellular/modem_shell/src/link/link_api.h b/samples/cellular/modem_shell/src/link/link_api.h index 2ce0176e7ebe..e89917f8bca4 100644 --- a/samples/cellular/modem_shell/src/link/link_api.h +++ b/samples/cellular/modem_shell/src/link/link_api.h @@ -7,6 +7,8 @@ #ifndef MOSH_LINK_API_H #define MOSH_LINK_API_H +#include + #include #include #include @@ -22,27 +24,6 @@ #define PDP_TYPE_IP4V6 0x03 #define PDP_TYPE_NONIP 0x04 -#define AT_CMD_PDP_CONTEXT_READ_PDP_TYPE_STR_MAX_LEN (6 + 1) -#define AT_CMD_PDP_CONTEXT_READ_IP_ADDR_STR_MAX_LEN (255) - -struct pdp_context_info { - uint32_t cid; - uint32_t ipv4_mtu; - uint32_t ipv6_mtu; - uint32_t pdn_id; - bool pdn_id_valid; - bool ctx_active; - char pdp_type_str[AT_CMD_PDP_CONTEXT_READ_PDP_TYPE_STR_MAX_LEN]; - char apn_str[MOSH_APN_STR_MAX_LEN]; - char pdp_type; - struct in_addr ip_addr4; - struct in6_addr ip_addr6; - struct in_addr dns_addr4_primary; - struct in_addr dns_addr4_secondary; - struct in6_addr dns_addr6_primary; - struct in6_addr dns_addr6_secondary; -}; - struct pdp_context_info_array { struct pdp_context_info *array; size_t size;