From: Denis Kenzior <denkenz@gmail.com>
To: ofono@lists.linux.dev
Cc: Denis Kenzior <denkenz@gmail.com>
Subject: [PATCH v2 7/8] qmi: gprs-context: Parse IPv6 context settings
Date: Mon, 6 May 2024 16:58:01 -0500 [thread overview]
Message-ID: <20240506215804.57124-7-denkenz@gmail.com> (raw)
In-Reply-To: <20240506215804.57124-1-denkenz@gmail.com>
Similarly to get_settings_ipv4, add get_settings_ipv6 function which
will parse the relevant TLVs present when GET_SETTINGS response
indicates IPv6 family is in use.
---
drivers/qmimodem/gprs-context.c | 58 +++++++++++++++++++++++++++++++++
1 file changed, 58 insertions(+)
diff --git a/drivers/qmimodem/gprs-context.c b/drivers/qmimodem/gprs-context.c
index 99d42e7b5e1f..21ef1237758e 100644
--- a/drivers/qmimodem/gprs-context.c
+++ b/drivers/qmimodem/gprs-context.c
@@ -78,6 +78,63 @@ static void pkt_status_notify(struct qmi_result *result, void *user_data)
}
}
+static void get_settings_ipv6(struct ofono_gprs_context *gc,
+ struct qmi_result *result)
+{
+ static const uint8_t RESULT_IP_ADDRESS = 0x25;
+ static const uint8_t RESULT_GATEWAY = 0x26;
+ static const uint8_t RESULT_PRIMARY_DNS = 0x27;
+ static const uint8_t RESULT_SECONDARY_DNS = 0x28;
+ static const uint8_t RESULT_MTU = 0x29;
+ const char *dns[3] = { NULL, NULL, NULL };
+ char dns1str[INET6_ADDRSTRLEN];
+ char dns2str[INET6_ADDRSTRLEN];
+ char ipv6str[INET6_ADDRSTRLEN];
+ const void *tlv;
+ uint16_t len;
+ uint32_t mtu;
+
+ tlv = qmi_result_get(result, RESULT_IP_ADDRESS, &len);
+ if (tlv && len == sizeof(struct in6_addr) + 1) {
+ const struct in6_addr *ip = tlv;
+ uint8_t prefix_len = l_get_u8(ip + 1);
+
+ inet_ntop(AF_INET6, ip, ipv6str, sizeof(ipv6str));
+ ofono_gprs_context_set_ipv6_address(gc, ipv6str);
+ ofono_gprs_context_set_ipv6_prefix_length(gc, prefix_len);
+ }
+
+ tlv = qmi_result_get(result, RESULT_GATEWAY, &len);
+ if (tlv && len == sizeof(struct in6_addr) + 1) {
+ const struct in6_addr *gw = tlv;
+
+ inet_ntop(AF_INET6, gw, ipv6str, sizeof(ipv6str));
+ ofono_gprs_context_set_ipv6_gateway(gc, ipv6str);
+ }
+
+ tlv = qmi_result_get(result, RESULT_PRIMARY_DNS, &len);
+ if (tlv && len == sizeof(struct in6_addr)) {
+ const struct in6_addr *dns1 = tlv;
+
+ inet_ntop(AF_INET6, dns1, dns1str, sizeof(dns1str));
+ dns[0] = dns1str;
+ }
+
+ tlv = qmi_result_get(result, RESULT_SECONDARY_DNS, &len);
+ if (tlv && len == sizeof(struct in6_addr)) {
+ const struct in6_addr *dns2 = tlv;
+
+ inet_ntop(AF_INET6, dns2, dns2str, sizeof(dns2str));
+ dns[1] = dns2str;
+ }
+
+ if (dns[0])
+ ofono_gprs_context_set_ipv6_dns_servers(gc, dns);
+
+ if (qmi_result_get_uint32(result, RESULT_MTU, &mtu))
+ DBG("MTU: %u", mtu);
+}
+
static void get_settings_ipv4(struct ofono_gprs_context *gc,
struct qmi_result *result)
{
@@ -164,6 +221,7 @@ static void get_settings_cb(struct qmi_result *result, void *user_data)
get_settings_ipv4(gc, result);
break;
case QMI_WDS_IP_FAMILY_IPV6:
+ get_settings_ipv6(gc, result);
break;
default:
break;
--
2.45.0
next prev parent reply other threads:[~2024-05-06 21:58 UTC|newest]
Thread overview: 9+ messages / expand[flat|nested] mbox.gz Atom feed top
2024-05-06 21:57 [PATCH v2 1/8] qmi: wds: Fix up enum naming Denis Kenzior
2024-05-06 21:57 ` [PATCH v2 2/8] qmi: gprs: use Extended Data Bearer Technology Denis Kenzior
2024-05-06 21:57 ` [PATCH v2 3/8] qmi: netreg: Print network capability Denis Kenzior
2024-05-06 21:57 ` [PATCH v2 4/8] qmi: gprs: Remove IP Support Type parsing Denis Kenzior
2024-05-06 21:57 ` [PATCH v2 5/8] qmi: gprs: Remove magic number use Denis Kenzior
2024-05-06 21:58 ` [PATCH v2 6/8] qmi: gprs-context: Split out IPv4 setting processing Denis Kenzior
2024-05-06 21:58 ` Denis Kenzior [this message]
2024-05-06 21:58 ` [PATCH v2 8/8] qmi: gprs-context: Obtain initial bearer IP support Denis Kenzior
2024-05-06 23:20 ` [PATCH v2 1/8] qmi: wds: Fix up enum naming patchwork-bot+ofono
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=20240506215804.57124-7-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 an external index of several public inboxes,
see mirroring instructions on how to clone and mirror
all data and code used by this external index.