Skip to contentSkip to conversation

xmm7modem: change to assign datapath for activated PDP

PATCH In review Antara Borwankar 2 participants 2 messages Feb 12, 2019 – Feb 13, 2019

lore
Share & tools
lore
#0 lore raw

PATCH 3/3 xmm7modem: change to assign datapath for activated PDP

Changed the handling of +CGCONTRDP AT command reply in ifxmodem modem driver for XMM7MODEM vendor for routing data over the selected path.

---
 drivers/ifxmodem/gprs-context.c | 14 +++++++++++---
 1 file changed, 11 insertions(+), 3 deletions(-)
drivers/ifxmodem/gprs-context.c +11 -3
index 7f3628b..70d10af 100644
@@ -269,8 +269,10 @@ static void cgcontrdp_cb(gboolean ok, GAtResult *result, gpointer user_data)
 
 	const char *laddrnetmask = NULL;
 	const char *gw = NULL;
-	const char *interface;
 	const char *dns[3];
+	const char *ctrlpath;
+	const char *datapath;
+	char buf[64];
 
 	DBG("ok %d", ok);
 
@@ -327,9 +329,9 @@ static void cgcontrdp_cb(gboolean ok, GAtResult *result, gpointer user_data)
 	DBG("DNS2: %s\n", gcd->dns2);
 	DBG("Gateway: %s\n", gcd->gateway);
 
-	interface = ofono_modem_get_string(modem, "NetworkInterface");
+	ctrlpath = ofono_modem_get_string(modem, "CtrlPath");
+	datapath = ofono_modem_get_string(modem, "DataPath");
 
-	ofono_gprs_context_set_interface(gc, interface);
 	ofono_gprs_context_set_ipv4_address(gc, gcd->address, TRUE);
 
 	if (gcd->netmask[0])
@@ -340,6 +342,12 @@ static void cgcontrdp_cb(gboolean ok, GAtResult *result, gpointer user_data)
 
 	ofono_gprs_context_set_ipv4_dns_servers(gc, dns);
 
+	sprintf(buf, "AT+XDATACHANNEL=1,1,\"%s\",\"%s%u\",2,%u", ctrlpath,
+				datapath, gcd->active_context, gcd->active_context);
+	g_at_chat_send(gcd->chat, buf, none_prefix, NULL, NULL, NULL);
+	sprintf(buf, "AT+CGDATA=\"M-RAW_IP\",%u", gcd->active_context);
+	g_at_chat_send(gcd->chat, buf, none_prefix, NULL, NULL, NULL);
+
 	CALLBACK_WITH_SUCCESS(gcd->cb, gcd->cb_data);
 }
 
Signature · 1 line
1.9.1
#1 lore raw

Hi Antara,

Quoted 12 lines · Antara Borwankar

Changed the handling of +CGCONTRDP AT command reply in ifxmodem modem driver for XMM7MODEM vendor for routing data over the selected path.

---
  drivers/ifxmodem/gprs-context.c | 14 +++++++++++---
  1 file changed, 11 insertions(+), 3 deletions(-)
drivers/ifxmodem/gprs-context.c +0 -0
index 7f3628b..70d10af 100644

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

Quoted 8 lines
drivers/ifxmodem/gprs-context.c +3 -1
@@ -269,8 +269,10 @@ static void cgcontrdp_cb(gboolean ok, GAtResult *result, gpointer user_data)
 
  	const char *laddrnetmask = NULL;
  	const char *gw = NULL;
-	const char *interface;
  	const char *dns[3];
+	const char *ctrlpath;
+	const char *datapath;
+	char buf[64];

Is this buffer large enough to hold the required AT commands? It seems like it might easily overflow?

Quoted 16 lines
drivers/ifxmodem/gprs-context.c +2 -2
  	DBG("ok %d", ok);
 
@@ -327,9 +329,9 @@ static void cgcontrdp_cb(gboolean ok, GAtResult *result, gpointer user_data)
  	DBG("DNS2: %s\n", gcd->dns2);
  	DBG("Gateway: %s\n", gcd->gateway);
 
-	interface = ofono_modem_get_string(modem, "NetworkInterface");
+	ctrlpath = ofono_modem_get_string(modem, "CtrlPath");
+	datapath = ofono_modem_get_string(modem, "DataPath");
 
-	ofono_gprs_context_set_interface(gc, interface);
  	ofono_gprs_context_set_ipv4_address(gc, gcd->address, TRUE);
 
  	if (gcd->netmask[0])

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

Quoted 5 lines
drivers/ifxmodem/gprs-context.c +2 -0
@@ -340,6 +342,12 @@ static void cgcontrdp_cb(gboolean ok, GAtResult *result, gpointer user_data)
 
  	ofono_gprs_context_set_ipv4_dns_servers(gc, dns);
 
+	sprintf(buf, "AT+XDATACHANNEL=1,1,\"%s\",\"%s%u\",2,%u", ctrlpath,
+				datapath, gcd->active_context, gcd->active_context);

e.g. here

Also, as I mentioned previously, mapping interfaces based on active_context id is not a good idea. Can we use ofono_gprs_context->interface for this directly somehow?

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

Quoted 5 lines
drivers/ifxmodem/gprs-context.c +4 -0
+	g_at_chat_send(gcd->chat, buf, none_prefix, NULL, NULL, NULL);
+	sprintf(buf, "AT+CGDATA=\"M-RAW_IP\",%u", gcd->active_context);
+	g_at_chat_send(gcd->chat, buf, none_prefix, NULL, NULL, NULL);
+
  	CALLBACK_WITH_SUCCESS(gcd->cb, gcd->cb_data);

To be pedantic, since you're issuing 2 other commands, you should call this only once those succeed.

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

Quoted 3 lines
drivers/ifxmodem/gprs-context.c +0 -0
  }
 

Regards,
-Denis