Skip to contentSkip to conversation

xmm7modem: handling of IPv6 address for activated context

PATCH In review Antara Borwankar 2 participants 2 messages Apr 24, 2019 – Apr 29, 2019

lore
Share & tools
lore
#0 lore raw

PATCH 1/1 xmm7modem: handling of IPv6 address for activated context

Handled IPv6 address after activating PDP context.
Received IPv6 address is of format addr + netmask in the same string in the form of "a1.a2.a3.a4.a5.a6.a7.a8.a9.a10.a11.a12.a13.a14.a15.a16. m1.m2.m3.m4.m5.m6.m7.m8.m9.m10.m11.m12.m13.m14.m15.m16"

---
 drivers/atmodem/atutil.c        | 39 +++++++++++++++++++++++++++++++++
 drivers/atmodem/atutil.h        |  3 +++
 drivers/ifxmodem/gprs-context.c | 48 +++++++++++++++++++++++++++++------------
 3 files changed, 76 insertions(+), 14 deletions(-)
drivers/atmodem/atutil.c +39 -0
index 98e3a2f..adcca85 100644
@@ -656,6 +656,45 @@ int at_util_get_ipv4_address_and_netmask(const char *addrnetmask,
 	return ret;
 }
 
+/*
+ * CGCONTRDP returns addr + netmask in the same string in the form
+ * of "a1.a2.a3.a4.a5.a6.a7.a8.a9.a10.a11.a12.a13.a14.a15.a16.m1.m2.
+ * m3.m4.m5.m6.m7.m8.m9.m10.m11.m12.m13.m14.m15.m16" for IPv6.
+ * address/netmask must be able to hold 64 characters.
+ */
+int at_util_get_ipv6_address_and_netmask(const char *addrnetmask,
+						char *address, char *netmask)
+{
+	const char *s = addrnetmask;
+	const char *net = NULL;
+
+	int ret = -EINVAL;
+	int i;
+
+	/* Count 31 dots for ipv6, less or more means error. */
+	for (i = 0; i < 33; i++, s++) {
+		s = strchr(s, '.');
+
+		if (!s)
+			break;
+
+		if (i == 15) {
+			/* set netmask ptr and break the string */
+			net = s + 1;
+		}
+	}
+
+	if (i == 31) {
+		memcpy(address, addrnetmask, net - addrnetmask);
+		address[net - addrnetmask - 1] = '\0';
+		strcpy(netmask, net);
+
+		ret = 0;
+	}
+
+	return ret;
+}
+
 int at_util_gprs_auth_method_to_auth_prot(
 					enum ofono_gprs_auth_method auth_method)
 {
drivers/atmodem/atutil.h +3 -0
index 69e8b49..61800ff 100644
@@ -86,6 +86,9 @@ void at_util_sim_state_query_free(struct at_util_sim_state_query *req);
 
 int at_util_get_ipv4_address_and_netmask(const char *addrnetmask,
 						char *address, char *netmask);
+int at_util_get_ipv6_address_and_netmask(const char *addrnetmask,
+						char *address, char *netmask);
+
 
 int at_util_gprs_auth_method_to_auth_prot(
 				enum ofono_gprs_auth_method auth_method);
drivers/ifxmodem/gprs-context.c +34 -14

66 lines not on this page · raw message

Signature · 1 line
1.9.1
#1 lore raw

Hi Antara,

Quoted 10 lines · Antara Borwankar

Handled IPv6 address after activating PDP context.
Received IPv6 address is of format addr + netmask in the same string in the form of "a1.a2.a3.a4.a5.a6.a7.a8.a9.a10.a11.a12.a13.a14.a15.a16. m1.m2.m3.m4.m5.m6.m7.m8.m9.m10.m11.m12.m13.m14.m15.m16"

---
  drivers/atmodem/atutil.c        | 39 +++++++++++++++++++++++++++++++++
  drivers/atmodem/atutil.h        |  3 +++
  drivers/ifxmodem/gprs-context.c | 48 +++++++++++++++++++++++++++++------------
  3 files changed, 76 insertions(+), 14 deletions(-)

I went ahead and applied this version after fixing up some lines which had > 80 chars. But:

drivers/ifxmodem/gprs-context.c static void cgcontrdp_cb(gboolean ok, GAtResult *result, gpointer user_data) · line 388

Quoted 1 line
drivers/ifxmodem/gprs-context.c +1 -0
+		ofono_gprs_context_set_ipv6_prefix_length(gc, IPV6_DEFAULT_PREFIX_LEN);

This really should be addressed at some point. Assuming a default netmask won't work in every situation.

Regards,
-Denis