Skip to contentSkip to conversation

xmm7modem: handling of IPv6 address for activated context

PATCH In review Antara Borwankar 2 participants 2 messages Apr 3, 2019 – Apr 4, 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

---
 drivers/ifxmodem/gprs-context.c | 38 ++++++++++++++++++++++++++++----------
 1 file changed, 28 insertions(+), 10 deletions(-)
drivers/ifxmodem/gprs-context.c +28 -10
index 6042004..2c5456b 100644
@@ -352,10 +352,17 @@ static void cgcontrdp_cb(gboolean ok, GAtResult *result, gpointer user_data)
 
 	DBG("DNS: %s, %s\n", gcd->dns1, gcd->dns2);
 
-	if (!laddrnetmask || at_util_get_ipv4_address_and_netmask(laddrnetmask,
-					gcd->address, gcd->netmask) < 0) {
-		failed_setup(gc, NULL, TRUE);
-		return;
+	if (gcd->proto == OFONO_GPRS_PROTO_IP) {
+		if (!laddrnetmask || at_util_get_ipv4_address_and_netmask(laddrnetmask,
+						gcd->address, gcd->netmask) < 0) {
+			failed_setup(gc, NULL, TRUE);
+			return;
+		}
+	}
+
+	if (gcd->proto == OFONO_GPRS_PROTO_IPV6) {
+		if (laddrnetmask)
+			strncpy(gcd->address, laddrnetmask, sizeof(gcd->address));
 	}
 
 	if (gw)
@@ -373,15 +380,26 @@ static void cgcontrdp_cb(gboolean ok, GAtResult *result, gpointer user_data)
 	interface = ofono_gprs_context_get_interface(gc);
 	datapath = get_datapath(modem, interface);
 
-	ofono_gprs_context_set_ipv4_address(gc, gcd->address, TRUE);
+	if (gcd->proto == OFONO_GPRS_PROTO_IP) {
+		ofono_gprs_context_set_ipv4_address(gc, gcd->address, TRUE);
 
-	if (gcd->netmask[0])
-		ofono_gprs_context_set_ipv4_netmask(gc, gcd->netmask);
+		if (gcd->netmask[0])
+			ofono_gprs_context_set_ipv4_netmask(gc, gcd->netmask);
 
-	if (gcd->gateway[0])
-		ofono_gprs_context_set_ipv4_gateway(gc, gcd->gateway);
+		if (gcd->gateway[0])
+			ofono_gprs_context_set_ipv4_gateway(gc, gcd->gateway);
 
-	ofono_gprs_context_set_ipv4_dns_servers(gc, dns);
+		ofono_gprs_context_set_ipv4_dns_servers(gc, dns);
+	}
+
+	if (gcd->proto == OFONO_GPRS_PROTO_IPV6) {
+		ofono_gprs_context_set_ipv6_address(gc, gcd->address);
+
+		if (gcd->gateway[0])
+			ofono_gprs_context_set_ipv6_gateway(gc, gcd->gateway);
+
+		ofono_gprs_context_set_ipv6_dns_servers(gc, dns);
+	}
 
 	snprintf(buf, sizeof(buf), "AT+XDATACHANNEL=1,1,\"%s\",\"%s\",2,%u",
 			ctrlpath, datapath, gcd->active_context);
Signature · 1 line
1.9.1
#1 lore raw

Hi Antara,

Quoted 18 lines · Antara Borwankar

Handled IPv6 address after activating PDP context

---
  drivers/ifxmodem/gprs-context.c | 38 ++++++++++++++++++++++++++++----------
  1 file changed, 28 insertions(+), 10 deletions(-)
drivers/ifxmodem/gprs-context.c +1 -4
index 6042004..2c5456b 100644
@@ -352,10 +352,17 @@ static void cgcontrdp_cb(gboolean ok, GAtResult *result, gpointer user_data)
 
  	DBG("DNS: %s, %s\n", gcd->dns1, gcd->dns2);
 
-	if (!laddrnetmask || at_util_get_ipv4_address_and_netmask(laddrnetmask,
-					gcd->address, gcd->netmask) < 0) {
-		failed_setup(gc, NULL, TRUE);
-		return;
+	if (gcd->proto == OFONO_GPRS_PROTO_IP) {

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

Quoted 10 lines
drivers/ifxmodem/gprs-context.c +10 -0
+		if (!laddrnetmask || at_util_get_ipv4_address_and_netmask(laddrnetmask,
+						gcd->address, gcd->netmask) < 0) {
+			failed_setup(gc, NULL, TRUE);
+			return;
+		}
+	}
+
+	if (gcd->proto == OFONO_GPRS_PROTO_IPV6) {
+		if (laddrnetmask)
+			strncpy(gcd->address, laddrnetmask, sizeof(gcd->address));

So what +CGPIAF setting is being assumed here? If IPv6_AddressFormat==0, then aren't you also copying parts of the netmask into gcd->address? FYI, the core doesn't validate the ipv6 address from the driver and broadcasts it directly over D-Bus.

Quoted 18 lines
drivers/ifxmodem/gprs-context.c +4 -5
  	}
 
  	if (gw)
@@ -373,15 +380,26 @@ static void cgcontrdp_cb(gboolean ok, GAtResult *result, gpointer user_data)
  	interface = ofono_gprs_context_get_interface(gc);
  	datapath = get_datapath(modem, interface);
 
-	ofono_gprs_context_set_ipv4_address(gc, gcd->address, TRUE);
+	if (gcd->proto == OFONO_GPRS_PROTO_IP) {
+		ofono_gprs_context_set_ipv4_address(gc, gcd->address, TRUE);
 
-	if (gcd->netmask[0])
-		ofono_gprs_context_set_ipv4_netmask(gc, gcd->netmask);
+		if (gcd->netmask[0])
+			ofono_gprs_context_set_ipv4_netmask(gc, gcd->netmask);
 
-	if (gcd->gateway[0])
-		ofono_gprs_context_set_ipv4_gateway(gc, gcd->gateway);

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

Quoted 10 lines
drivers/ifxmodem/gprs-context.c +8 -1
+		if (gcd->gateway[0])
+			ofono_gprs_context_set_ipv4_gateway(gc, gcd->gateway);
 
-	ofono_gprs_context_set_ipv4_dns_servers(gc, dns);
+		ofono_gprs_context_set_ipv4_dns_servers(gc, dns);
+	}
+
+	if (gcd->proto == OFONO_GPRS_PROTO_IPV6) {
+		ofono_gprs_context_set_ipv6_address(gc, gcd->address);
+

What about the prefix length?

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

Quoted 5 lines
drivers/ifxmodem/gprs-context.c +5 -0
+		if (gcd->gateway[0])
+			ofono_gprs_context_set_ipv6_gateway(gc, gcd->gateway);
+
+		ofono_gprs_context_set_ipv6_dns_servers(gc, dns);
+	}

Also, I think we're ending up with too many if statements. They should be combined and the DBG statements moved into the relevant if block.

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

Quoted 4 lines
drivers/ifxmodem/gprs-context.c +0 -0
  	snprintf(buf, sizeof(buf), "AT+XDATACHANNEL=1,1,\"%s\",\"%s\",2,%u",
  			ctrlpath, datapath, gcd->active_context);
 

Regards,
-Denis