Skip to contentSkip to conversation

atutil: Add logic for cgcontrdp to get address and netmask

PATCH In review Ankit Navik 2 participants 5 messages Sep 13, 2017 Kbuild

lore
Share & tools
lore
#0 lore raw

PATCH 1/4 atutil: Add logic for cgcontrdp to get address and netmask

---
 drivers/atmodem/atutil.c | 40 ++++++++++++++++++++++++++++++++++++++++
 drivers/atmodem/atutil.h |  3 +++
 2 files changed, 43 insertions(+)
drivers/atmodem/atutil.c +40 -0
index 1487348..6f4e8a2 100644
@@ -27,6 +27,7 @@
 #include <gatchat.h>
 #include <string.h>
 #include <stdlib.h>
+#include <errno.h>
 
 #define OFONO_API_SUBJECT_TO_CHANGE
 #include <ofono/log.h>
@@ -614,3 +615,42 @@ void at_util_sim_state_query_free(struct at_util_sim_state_query *req)
 
 	g_free(req);
 }
+
+/*
+ * CGCONTRDP returns addr + netmask in the same string in the form
+ * of "a.b.c.d.m.m.m.m" for IPv4.
+ * address/netmask must be able to hold
+ * 255.255.255.255 + null = 16 characters
+ */
+int at_util_get_ipv4_address_and_netmask(const char *addrnetmask,
+						char *address, char *netmask)
+{
+	const char *s = addrnetmask;
+	const char *net = NULL;
+
+	int ret = -EINVAL;
+	int i;
+
+	/* Count 7 dots for ipv4, less or more means error. */
+	for (i = 0; i < 9; i++, s++) {
+		s = strchr(s, '.');
+
+		if (!s)
+			break;
+
+		if (i == 3) {
+			/* set netmask ptr and break the string */
+			net = s + 1;
+		}
+	}
+
+	if (i == 7) {
+		memcpy(address, addrnetmask, net - addrnetmask);
+		address[net - addrnetmask - 1] = '\0';
+		strcpy(netmask, net);
+
+		ret = 0;
+	}
+
+	return ret;
+}
drivers/atmodem/atutil.h +3 -0
index 5cb88b7..7113a4c 100644
@@ -83,6 +83,9 @@ struct at_util_sim_state_query *at_util_sim_state_query_new(GAtChat *chat,
 						GDestroyNotify destroy);
 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);
+
 struct cb_data {
 	void *cb;
 	void *data;
Signature · 1 line
1.9.1
#1 lore raw

PATCH 2/4 ifxmodem: support automatic context activation

Add support for automatic context activation by adding read_settings. It also adds detach_shutdown to make sure context is cleaned up when network registration is lost.

---
 drivers/atmodem/vendor.h        |   1 +
 drivers/ifxmodem/gprs-context.c | 180 +++++++++++++++++++++++++++++++++++-----
 drivers/ifxmodem/ifxmodem.h     |   1 +
 3 files changed, 163 insertions(+), 19 deletions(-)
drivers/atmodem/vendor.h +1 -0
index 71a9af7..d52ad52 100644
@@ -47,4 +47,5 @@ enum ofono_vendor {
 	OFONO_VENDOR_UBLOX,
 	OFONO_VENDOR_UBLOX_TOBY_L2,
 	OFONO_VENDOR_CINTERION,
+	OFONO_VENDOR_XMM,
 };
drivers/ifxmodem/gprs-context.c +161 -19

266 lines not on this page · raw message

drivers/ifxmodem/ifxmodem.h +1 -0
index 43badc9..7f6d870 100644
@@ -20,6 +20,7 @@
  */
 
 #include <drivers/atmodem/atutil.h>
+#include <drivers/atmodem/vendor.h>
 
 extern void ifx_voicecall_init(void);
 extern void ifx_voicecall_exit(void);
Signature · 1 line
1.9.1
#2 lore raw

PATCH 3/4 Add support for Intel xmm7xxx series modems

In reply to Ankit Navik

This adds plugin for xmm7xxx series modems

---
 Makefile.am       |   3 +
 plugins/xmm7xxx.c | 399 ++++++++++++++++++++++++++++++++++++++++++++++++++++++
 2 files changed, 402 insertions(+)
 create mode 100644 plugins/xmm7xxx.c
Makefile.am +3 -0
index c46e85a..070821f 100644
@@ -507,6 +507,9 @@ builtin_sources += plugins/quectel.c
 builtin_modules += ublox
 builtin_sources += plugins/ublox.c
 
+builtin_modules += xmm7xxx
+builtin_sources += plugins/xmm7xxx.c
+
 if BLUETOOTH
 if BLUEZ4
 builtin_modules += sap
plugins/xmm7xxx.c new file +399 -0

399 lines not on this page · raw message

Signature · 1 line
1.9.1
#3 lore raw

PATCH 4/4 udevng/xmm7xxx: Allow to detect xmm7xxx series modems

In reply to Ankit Navik

The Intel xmm7xxx series modem uses id as 8087:0930

---
 plugins/udevng.c | 39 +++++++++++++++++++++++++++++++++++++++
 1 file changed, 39 insertions(+)
plugins/udevng.c +39 -0
index 518eda8..787ee0f 100644
@@ -1121,6 +1121,42 @@ static gboolean setup_gemalto(struct modem_info* modem)
 	return TRUE;
 }
 
+static gboolean setup_xmm7xxx(struct modem_info *modem)
+{
+	const char *mdm = NULL, *net = NULL;
+	GSList *list;
+
+	DBG("%s %s\n", __DATE__, __TIME__);
+	DBG("%s %s %s %s %s %s\n", modem->syspath, modem->devname,
+		modem->driver, modem->vendor, modem->model, modem->sysattr);
+
+	for (list = modem->devices; list; list = list->next) {
+		struct device_info *info = list->data;
+
+		DBG("%s %s %s %s %s %s %s\n", info->devpath, info->devnode,
+				info->interface, info->number, info->label,
+				info->sysattr, info->subsystem);
+
+		if (g_strcmp0(info->subsystem, "tty") == 0) {
+			if (g_strcmp0(info->number, "02") == 0)
+				mdm = info->devnode;
+		} else if (g_strcmp0(info->subsystem, "net") == 0) {
+			if (g_strcmp0(info->number, "00") == 0)
+				net = info->devnode;
+		}
+	}
+
+	if (mdm == NULL || net == NULL)
+		return FALSE;
+
+	DBG("modem=%s net=%s\n", mdm, net);
+
+	ofono_modem_set_string(modem->modem, "Modem", mdm);
+	ofono_modem_set_string(modem->modem, "NetworkInterface", net);
+
+	return TRUE;
+}
+
 static struct {
 	const char *name;
 	gboolean (*setup)(struct modem_info *modem);
@@ -1148,6 +1184,7 @@ static struct {
 	{ "quectelqmi",	setup_quectelqmi},
 	{ "ublox",	setup_ublox	},
 	{ "gemalto",	setup_gemalto	},
+	{ "xmm7xxx",	setup_xmm7xxx	},
 	/* Following are non-USB modems */
 	{ "ifx",	setup_ifx		},
 	{ "u8500",	setup_isi_serial	},
@@ -1524,6 +1561,8 @@ static struct {
 	{ "gemalto",	"qmi_wwan",	"1e2d",	"0053"	},
 	{ "telit",	"cdc_ncm",	"1bc7", "0036"	},
 	{ "telit",	"cdc_acm",	"1bc7", "0036"	},
+	{ "xmm7xxx",	"cdc_acm",	"8087", "0930"	},
+	{ "xmm7xxx",	"cdc_ncm",	"8087", "0930"	},
 	{ }
 };
 
Signature · 1 line
1.9.1
#4 lore raw
In reply to Ankit Navik

Hi Ankit,

Quoted 5 lines · Ankit Navik
---
  drivers/atmodem/atutil.c | 40 ++++++++++++++++++++++++++++++++++++++++
  drivers/atmodem/atutil.h |  3 +++
  2 files changed, 43 insertions(+)

All four patches have been applied, thanks.

Regards,
-Denis