From: Denis Kenzior <denkenz@gmail.com>
To: ofono@lists.linux.dev
Cc: Denis Kenzior <denkenz@gmail.com>
Subject: [PATCH 6/8] qmi: gprs-context: Split out IPv4 setting processing
Date: Mon, 6 May 2024 15:39:28 -0500 [thread overview]
Message-ID: <20240506203952.55806-6-denkenz@gmail.com> (raw)
In-Reply-To: <20240506203952.55806-1-denkenz@gmail.com>
Prepare to support IPv6 bearers by moving IPv4 bearer context processing
into its own function. get_settings_ipv4() will be called if the
reported IP Family TLV reports ipv4.
---
drivers/qmimodem/gprs-context.c | 69 ++++++++++++++++++++-------------
1 file changed, 43 insertions(+), 26 deletions(-)
diff --git a/drivers/qmimodem/gprs-context.c b/drivers/qmimodem/gprs-context.c
index 9ac57c893725..99d42e7b5e1f 100644
--- a/drivers/qmimodem/gprs-context.c
+++ b/drivers/qmimodem/gprs-context.c
@@ -78,44 +78,20 @@ static void pkt_status_notify(struct qmi_result *result, void *user_data)
}
}
-static void get_settings_cb(struct qmi_result *result, void *user_data)
+static void get_settings_ipv4(struct ofono_gprs_context *gc,
+ struct qmi_result *result)
{
- static const uint8_t RESULT_PDP_TYPE = 0x11; /* uint8 */
- static const uint8_t RESULT_APN = 0x14; /* string */
static const uint8_t RESULT_PRIMARY_DNS = 0x15;
static const uint8_t RESULT_SECONDARY_DNS = 0x16;
static const uint8_t RESULT_IP_ADDRESS = 0x1e;
static const uint8_t RESULT_GATEWAY = 0x20;
static const uint8_t RESULT_GATEWAY_NETMASK = 0x21;
- static const uint8_t RESULT_IP_FAMILY = 0x2b; /* uint8 */
- struct cb_data *cbd = user_data;
- ofono_gprs_context_cb_t cb = cbd->cb;
- struct ofono_gprs_context *gc = cbd->user;
- uint8_t pdp_type, ip_family;
uint32_t ip_addr;
struct in_addr addr;
char* straddr;
- char* apn;
const char *dns[3] = { NULL, NULL, NULL };
char dns_buf[2][INET_ADDRSTRLEN];
- DBG("");
-
- if (qmi_result_set_error(result, NULL))
- goto done;
-
- apn = qmi_result_get_string(result, RESULT_APN);
- if (apn) {
- DBG("APN: %s", apn);
- l_free(apn);
- }
-
- if (qmi_result_get_uint8(result, RESULT_PDP_TYPE, &pdp_type))
- DBG("PDP type %d", pdp_type);
-
- if (qmi_result_get_uint8(result, RESULT_IP_FAMILY, &ip_family))
- DBG("IP family %d", ip_family);
-
if (qmi_result_get_uint32(result, RESULT_IP_ADDRESS, &ip_addr)) {
addr.s_addr = htonl(ip_addr);
straddr = inet_ntoa(addr);
@@ -151,6 +127,47 @@ static void get_settings_cb(struct qmi_result *result, void *user_data)
if (dns[0])
ofono_gprs_context_set_ipv4_dns_servers(gc, dns);
+}
+
+static void get_settings_cb(struct qmi_result *result, void *user_data)
+{
+ static const uint8_t RESULT_PDP_TYPE = 0x11; /* uint8 */
+ static const uint8_t RESULT_APN = 0x14; /* string */
+ static const uint8_t RESULT_IP_FAMILY = 0x2b; /* uint8 */
+ struct cb_data *cbd = user_data;
+ ofono_gprs_context_cb_t cb = cbd->cb;
+ struct ofono_gprs_context *gc = cbd->user;
+ uint8_t pdp_type, ip_family;
+ char* apn;
+
+ DBG("");
+
+ if (qmi_result_set_error(result, NULL))
+ goto done;
+
+ apn = qmi_result_get_string(result, RESULT_APN);
+ if (apn) {
+ DBG("APN: %s", apn);
+ l_free(apn);
+ }
+
+ if (qmi_result_get_uint8(result, RESULT_PDP_TYPE, &pdp_type))
+ DBG("PDP type %d", pdp_type);
+
+ if (!qmi_result_get_uint8(result, RESULT_IP_FAMILY, &ip_family)) {
+ ofono_error("No IP family in results");
+ goto done;
+ }
+
+ switch (ip_family) {
+ case QMI_WDS_IP_FAMILY_IPV4:
+ get_settings_ipv4(gc, result);
+ break;
+ case QMI_WDS_IP_FAMILY_IPV6:
+ break;
+ default:
+ break;
+ }
done:
CALLBACK_WITH_SUCCESS(cb, cbd->data);
--
2.45.0
next prev parent reply other threads:[~2024-05-06 20:39 UTC|newest]
Thread overview: 8+ messages / expand[flat|nested] mbox.gz Atom feed top
2024-05-06 20:39 [PATCH 1/8] qmi: wds: Fix up enum naming Denis Kenzior
2024-05-06 20:39 ` [PATCH 2/8] qmi: gprs: use Extended Data Bearer Technology Denis Kenzior
2024-05-06 20:39 ` [PATCH 3/8] qmi: netreg: Print network capability Denis Kenzior
2024-05-06 20:39 ` [PATCH 4/8] qmi: gprs: Remove IP Support Type parsing Denis Kenzior
2024-05-06 20:39 ` [PATCH 5/8] qmi: gprs: Remove magic number use Denis Kenzior
2024-05-06 20:39 ` Denis Kenzior [this message]
2024-05-06 20:39 ` [PATCH 7/8] qmi: gprs-context: Parse IPv6 context settings Denis Kenzior
2024-05-06 20:39 ` [PATCH 8/8] qmi: gprs-context: Obtain initial bearer IP support Denis Kenzior
Reply instructions:
You may reply publicly to this message via plain-text email
using any one of the following methods:
* Save the following mbox file, import it into your mail client,
and reply-to-all from there: mbox
Avoid top-posting and favor interleaved quoting:
https://en.wikipedia.org/wiki/Posting_style#Interleaved_style
* Reply using the --to, --cc, and --in-reply-to
switches of git-send-email(1):
git send-email \
--in-reply-to=20240506203952.55806-6-denkenz@gmail.com \
--to=denkenz@gmail.com \
--cc=ofono@lists.linux.dev \
/path/to/YOUR_REPLY
https://kernel.org/pub/software/scm/git/docs/git-send-email.html
* If your mail client supports setting the In-Reply-To header
via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line
before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for read-only IMAP folder(s) and NNTP newsgroup(s).