All of lore.kernel.org
 help / color / mirror / Atom feed
* [PATCH 1/6] atmodem: Add lte atom driver
@ 2017-09-01  5:53 Ankit Navik
  2017-09-01  5:53 ` [PATCH 2/6] Add support for Intel xmm7xxx series modem driver Ankit Navik
                   ` (2 more replies)
  0 siblings, 3 replies; 6+ messages in thread
From: Ankit Navik @ 2017-09-01  5:53 UTC (permalink / raw)
  To: ofono

[-- Attachment #1: Type: text/plain, Size: 5396 bytes --]

Adds atmodem driver for setting the default APN command.
The default APN is manage by config storage.
---
 Makefile.am               |   3 +-
 drivers/atmodem/atmodem.c |   2 +
 drivers/atmodem/atmodem.h |   3 +
 drivers/atmodem/lte.c     | 142 ++++++++++++++++++++++++++++++++++++++++++++++
 4 files changed, 149 insertions(+), 1 deletion(-)
 create mode 100644 drivers/atmodem/lte.c

diff --git a/Makefile.am b/Makefile.am
index 078e3f1..18a806b 100644
--- a/Makefile.am
+++ b/Makefile.am
@@ -264,7 +264,8 @@ builtin_sources += 	drivers/atmodem/atmodem.h \
 			drivers/atmodem/gprs.c \
 			drivers/atmodem/gprs-context.c \
 			drivers/atmodem/sim-auth.c \
-			drivers/atmodem/gnss.c
+			drivers/atmodem/gnss.c \
+			drivers/atmodem/lte.c
 
 builtin_modules += nwmodem
 builtin_sources += drivers/atmodem/atutil.h \
diff --git a/drivers/atmodem/atmodem.c b/drivers/atmodem/atmodem.c
index 3a55ac2..684b228 100644
--- a/drivers/atmodem/atmodem.c
+++ b/drivers/atmodem/atmodem.c
@@ -52,6 +52,7 @@ static int atmodem_init(void)
 	at_gprs_context_init();
 	at_sim_auth_init();
 	at_gnss_init();
+	at_lte_init();
 
 	return 0;
 }
@@ -76,6 +77,7 @@ static void atmodem_exit(void)
 	at_gprs_exit();
 	at_gprs_context_exit();
 	at_gnss_exit();
+	at_lte_exit();
 }
 
 OFONO_PLUGIN_DEFINE(atmodem, "AT modem driver", VERSION,
diff --git a/drivers/atmodem/atmodem.h b/drivers/atmodem/atmodem.h
index 6be1fe5..b737066 100644
--- a/drivers/atmodem/atmodem.h
+++ b/drivers/atmodem/atmodem.h
@@ -74,3 +74,6 @@ extern void at_sim_auth_exit(void);
 
 extern void at_gnss_init(void);
 extern void at_gnss_exit(void);
+
+extern void at_lte_init(void);
+extern void at_lte_exit(void);
diff --git a/drivers/atmodem/lte.c b/drivers/atmodem/lte.c
new file mode 100644
index 0000000..61a4cd2
--- /dev/null
+++ b/drivers/atmodem/lte.c
@@ -0,0 +1,142 @@
+/*
+ *
+ *  oFono - Open Source Telephony
+ *
+ *  Copyright (C) 2017  Intel Corporation. All rights reserved.
+ *
+ *  This program is free software; you can redistribute it and/or modify
+ *  it under the terms of the GNU General Public License version 2 as
+ *  published by the Free Software Foundation.
+ *
+ *  This program is distributed in the hope that it will be useful,
+ *  but WITHOUT ANY WARRANTY; without even the implied warranty of
+ *  MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
+ *  GNU General Public License for more details.
+ *
+ *  You should have received a copy of the GNU General Public License
+ *  along with this program; if not, write to the Free Software
+ *  Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA  02110-1301  USA
+ *
+ */
+
+#ifdef HAVE_CONFIG_H
+#include <config.h>
+#endif
+
+#define _GNU_SOURCE
+#include <stdlib.h>
+#include <stdio.h>
+#include <string.h>
+#include <errno.h>
+
+#include <glib.h>
+
+#include <ofono/modem.h>
+#include <ofono/gprs-context.h>
+#include <ofono/log.h>
+#include <ofono/lte.h>
+
+#include "gatchat.h"
+#include "gatresult.h"
+
+#include "atmodem.h"
+
+struct lte_driver_data {
+	GAtChat *chat;
+};
+
+static void at_lte_set_default_attach_info_cb(gboolean ok, GAtResult *result,
+							gpointer user_data)
+{
+	struct cb_data *cbd = user_data;
+	ofono_lte_cb_t cb = cbd->cb;
+	struct ofono_error error;
+
+	DBG("ok %d", ok);
+
+	decode_at_error(&error, g_at_result_final_response(result));
+	cb(&error, cbd->data);
+}
+
+static void at_lte_set_default_attach_info(const struct ofono_lte *lte,
+			const struct ofono_lte_default_attach_info *info,
+			ofono_lte_cb_t cb, void *data)
+{
+	struct lte_driver_data *ldd = ofono_lte_get_data(lte);
+	char buf[32 + OFONO_GPRS_MAX_APN_LENGTH + 1];
+	struct cb_data *cbd = cb_data_new(cb, data);
+
+	DBG("LTE config with APN: %s", info->apn);
+
+	if (strlen(info->apn) > 0)
+		snprintf(buf, sizeof(buf), "AT+CGDCONT=0,\"IP\",\"%s\"",
+				info->apn);
+	else
+		snprintf(buf, sizeof(buf), "AT+CGDCONT=0,\"IP\"");
+
+	/* We can't do much in case of failure so don't check response. */
+	if (g_at_chat_send(ldd->chat, buf, NULL,
+			at_lte_set_default_attach_info_cb, cbd, g_free) > 0)
+		return;
+
+	CALLBACK_WITH_FAILURE(cb, data);
+}
+
+static gboolean lte_delayed_register(gpointer user_data)
+{
+	struct ofono_lte *lte = user_data;
+
+	ofono_lte_register(lte);
+
+	return FALSE;
+}
+
+static int at_lte_probe(struct ofono_lte *lte, void *data)
+{
+	GAtChat *chat = data;
+	struct lte_driver_data *ldd;
+
+	DBG("at lte probe");
+
+	ldd = g_try_new0(struct lte_driver_data, 1);
+	if (!ldd)
+		return -ENOMEM;
+
+	ldd->chat = g_at_chat_clone(chat);
+
+	ofono_lte_set_data(lte, ldd);
+
+	g_idle_add(lte_delayed_register, lte);
+
+	return 0;
+}
+
+static void at_lte_remove(struct ofono_lte *lte)
+{
+	struct lte_driver_data *ldd = ofono_lte_get_data(lte);
+
+	DBG("at lte remove");
+
+	g_at_chat_unref(ldd->chat);
+
+	ofono_lte_set_data(lte, NULL);
+
+	g_free(ldd);
+}
+
+static struct ofono_lte_driver driver = {
+	.name				= "atmodem",
+	.probe				= at_lte_probe,
+	.remove				= at_lte_remove,
+	.set_default_attach_info	= at_lte_set_default_attach_info,
+};
+
+void at_lte_init(void)
+{
+	ofono_lte_driver_register(&driver);
+}
+
+void at_lte_exit(void)
+{
+	ofono_lte_driver_unregister(&driver);
+}
-- 
1.9.1


^ permalink raw reply related	[flat|nested] 6+ messages in thread

* [PATCH 2/6] Add support for Intel xmm7xxx series modem driver
  2017-09-01  5:53 [PATCH 1/6] atmodem: Add lte atom driver Ankit Navik
@ 2017-09-01  5:53 ` Ankit Navik
  2017-09-05 15:48   ` Denis Kenzior
  2017-09-01  5:53 ` [PATCH 3/6] atutil: Add logic for cgcontrdp to get address and netmask Ankit Navik
  2017-09-05 15:44 ` [PATCH 1/6] atmodem: Add lte atom driver Denis Kenzior
  2 siblings, 1 reply; 6+ messages in thread
From: Ankit Navik @ 2017-09-01  5:53 UTC (permalink / raw)
  To: ofono

[-- Attachment #1: Type: text/plain, Size: 9784 bytes --]

This adds driver as xmm7modem for radio-settings
---
 Makefile.am                        |   5 +
 drivers/xmm7modem/radio-settings.c | 233 +++++++++++++++++++++++++++++++++++++
 drivers/xmm7modem/xmm7modem.c      |  50 ++++++++
 drivers/xmm7modem/xmm7modem.h      |  27 +++++
 4 files changed, 315 insertions(+)
 create mode 100644 drivers/xmm7modem/radio-settings.c
 create mode 100644 drivers/xmm7modem/xmm7modem.c
 create mode 100644 drivers/xmm7modem/xmm7modem.h

diff --git a/Makefile.am b/Makefile.am
index 18a806b..658e152 100644
--- a/Makefile.am
+++ b/Makefile.am
@@ -396,6 +396,11 @@ builtin_sources += drivers/atmodem/atutil.h \
 			drivers/gemaltomodem/gemaltomodem.c \
 			drivers/gemaltomodem/location-reporting.c
 
+builtin_modules += xmm7modem
+builtin_sources += drivers/atmodem/atutil.h \
+			drivers/xmm7modem/xmm7modem.h \
+			drivers/xmm7modem/xmm7modem.c \
+			drivers/xmm7modem/radio-settings.c
 
 if PHONESIM
 builtin_modules += phonesim
diff --git a/drivers/xmm7modem/radio-settings.c b/drivers/xmm7modem/radio-settings.c
new file mode 100644
index 0000000..8888b31
--- /dev/null
+++ b/drivers/xmm7modem/radio-settings.c
@@ -0,0 +1,233 @@
+/*
+ *
+ *  oFono - Open Source Telephony
+ *
+ *  Copyright (C) 2017  Intel Corporation. All rights reserved.
+ *
+ *  This program is free software; you can redistribute it and/or modify
+ *  it under the terms of the GNU General Public License version 2 as
+ *  published by the Free Software Foundation.
+ *
+ *  This program is distributed in the hope that it will be useful,
+ *  but WITHOUT ANY WARRANTY; without even the implied warranty of
+ *  MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
+ *  GNU General Public License for more details.
+ *
+ *  You should have received a copy of the GNU General Public License
+ *  along with this program; if not, write to the Free Software
+ *  Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA  02110-1301  USA
+ *
+ */
+
+#ifdef HAVE_CONFIG_H
+#include <config.h>
+#endif
+
+#define _GNU_SOURCE
+#include <string.h>
+#include <stdlib.h>
+#include <stdio.h>
+#include <errno.h>
+
+#include <glib.h>
+
+#include <ofono/log.h>
+#include <ofono/modem.h>
+#include <ofono/radio-settings.h>
+
+#include "gatchat.h"
+#include "gatresult.h"
+
+#include "xmm7modem.h"
+
+static const char *none_prefix[] = { NULL };
+static const char *xact_prefix[] = { "+XACT:", NULL };
+
+struct radio_settings_data {
+	GAtChat *chat;
+};
+
+static void xact_query_cb(gboolean ok, GAtResult *result, gpointer user_data)
+{
+	struct cb_data *cbd = user_data;
+	ofono_radio_settings_rat_mode_query_cb_t cb = cbd->cb;
+	enum ofono_radio_access_mode mode;
+	struct ofono_error error;
+	GAtResultIter iter;
+	int value, preferred;
+
+	decode_at_error(&error, g_at_result_final_response(result));
+
+	if (!ok) {
+		cb(&error, -1, cbd->data);
+		return;
+	}
+
+	g_at_result_iter_init(&iter, result);
+
+	if (g_at_result_iter_next(&iter, "+XACT:") == FALSE)
+		goto error;
+
+	if (g_at_result_iter_next_number(&iter, &value) == FALSE)
+		goto error;
+
+	if (g_at_result_iter_next_number(&iter, &preferred) == FALSE)
+		goto error;
+
+	switch (value) {
+	case 0:
+		mode = OFONO_RADIO_ACCESS_MODE_GSM;
+		break;
+	case 1:
+		mode = OFONO_RADIO_ACCESS_MODE_UMTS;
+		break;
+	case 2:
+		mode = OFONO_RADIO_ACCESS_MODE_LTE;
+		break;
+	case 3:
+		mode = OFONO_RADIO_ACCESS_MODE_UMTS;
+		break;
+	case 4:
+		mode = OFONO_RADIO_ACCESS_MODE_LTE;
+		break;
+	case 5:
+		mode = OFONO_RADIO_ACCESS_MODE_LTE;
+		break;
+	case 6:
+		mode = OFONO_RADIO_ACCESS_MODE_ANY;
+		break;
+	default:
+		CALLBACK_WITH_FAILURE(cb, -1, cbd->data);
+		return;
+	}
+
+	cb(&error, mode, cbd->data);
+
+	return;
+
+error:
+	CALLBACK_WITH_FAILURE(cb, -1, cbd->data);
+}
+
+static void xmm_query_rat_mode(struct ofono_radio_settings *rs,
+				ofono_radio_settings_rat_mode_query_cb_t cb,
+				void *data)
+{
+	struct radio_settings_data *rsd = ofono_radio_settings_get_data(rs);
+	struct cb_data *cbd = cb_data_new(cb, data);
+
+	if (g_at_chat_send(rsd->chat, "AT+XACT?", xact_prefix,
+					xact_query_cb, cbd, g_free) > 0)
+		return;
+
+	CALLBACK_WITH_FAILURE(cb, -1, data);
+	g_free(cbd);
+}
+
+static void xact_modify_cb(gboolean ok, GAtResult *result, gpointer user_data)
+{
+	struct cb_data *cbd = user_data;
+	ofono_radio_settings_rat_mode_set_cb_t cb = cbd->cb;
+	struct ofono_error error;
+
+	decode_at_error(&error, g_at_result_final_response(result));
+	cb(&error, cbd->data);
+}
+
+static void xmm_set_rat_mode(struct ofono_radio_settings *rs,
+				enum ofono_radio_access_mode mode,
+				ofono_radio_settings_rat_mode_set_cb_t cb,
+				void *data)
+{
+	struct radio_settings_data *rsd = ofono_radio_settings_get_data(rs);
+	struct cb_data *cbd = cb_data_new(cb, data);
+	char buf[20];
+	int value = 6, preferred = 2;
+
+	switch (mode) {
+	case OFONO_RADIO_ACCESS_MODE_ANY:
+		value = 6;
+		break;
+	case OFONO_RADIO_ACCESS_MODE_GSM:
+		value = 0;
+		break;
+	case OFONO_RADIO_ACCESS_MODE_UMTS:
+		value = 1;
+		break;
+	case OFONO_RADIO_ACCESS_MODE_LTE:
+		value = 2;
+		break;
+	}
+
+	if (value == 6)
+		snprintf(buf, sizeof(buf), "AT+XACT=%u,%u", value, preferred);
+	else
+		snprintf(buf, sizeof(buf), "AT+XACT=%u", value);
+
+	if (g_at_chat_send(rsd->chat, buf, none_prefix,
+					xact_modify_cb, cbd, g_free) > 0)
+		return;
+
+	CALLBACK_WITH_FAILURE(cb, data);
+	g_free(cbd);
+}
+
+static void xact_support_cb(gboolean ok, GAtResult *result, gpointer user_data)
+{
+	struct ofono_radio_settings *rs = user_data;
+
+	if(!ok) {
+		ofono_radio_settings_remove(rs);
+		return;
+	}
+
+	ofono_radio_settings_register(rs);
+}
+
+static int xmm_radio_settings_probe(struct ofono_radio_settings *rs,
+					unsigned int vendor, void *user)
+{
+	GAtChat *chat = user;
+	struct radio_settings_data *rsd;
+
+	rsd = g_try_new0(struct radio_settings_data, 1);
+	if (rsd == NULL)
+		return -ENOMEM;
+
+	rsd->chat = g_at_chat_clone(chat);
+
+	ofono_radio_settings_set_data(rs, rsd);
+
+	g_at_chat_send(rsd->chat, "AT+XACT=?", xact_prefix,
+					xact_support_cb, rs, NULL);
+
+	return 0;
+}
+
+static void xmm_radio_settings_remove(struct ofono_radio_settings *rs)
+{
+	struct radio_settings_data *rsd = ofono_radio_settings_get_data(rs);
+
+	ofono_radio_settings_set_data(rs, NULL);
+
+	g_at_chat_unref(rsd->chat);
+	g_free(rsd);
+}
+
+static struct ofono_radio_settings_driver driver = {
+	.name			= "xmm7modem",
+	.probe			= xmm_radio_settings_probe,
+	.remove			= xmm_radio_settings_remove,
+	.query_rat_mode		= xmm_query_rat_mode,
+	.set_rat_mode		= xmm_set_rat_mode
+};
+
+void xmm_radio_settings_init(void)
+{
+	ofono_radio_settings_driver_register(&driver);
+}
+
+void xmm_radio_settings_exit(void)
+{
+	ofono_radio_settings_driver_unregister(&driver);
+}
diff --git a/drivers/xmm7modem/xmm7modem.c b/drivers/xmm7modem/xmm7modem.c
new file mode 100644
index 0000000..db1864e
--- /dev/null
+++ b/drivers/xmm7modem/xmm7modem.c
@@ -0,0 +1,50 @@
+/*
+ *
+ *  oFono - Open Source Telephony
+ *
+ *  Copyright (C) 2017  Intel Corporation. All rights reserved.
+ *
+ *  This program is free software; you can redistribute it and/or modify
+ *  it under the terms of the GNU General Public License version 2 as
+ *  published by the Free Software Foundation.
+ *
+ *  This program is distributed in the hope that it will be useful,
+ *  but WITHOUT ANY WARRANTY; without even the implied warranty of
+ *  MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
+ *  GNU General Public License for more details.
+ *
+ *  You should have received a copy of the GNU General Public License
+ *  along with this program; if not, write to the Free Software
+ *  Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA  02110-1301  USA
+ *
+ */
+
+#ifdef HAVE_CONFIG_H
+#include <config.h>
+#endif
+
+#include <glib.h>
+#include <gatchat.h>
+
+#define OFONO_API_SUBJECT_TO_CHANGE
+#include <ofono/plugin.h>
+#include <ofono/types.h>
+#include <ofono/modem.h>
+
+#include "xmm7modem.h"
+
+static int xmm7modem_init(void)
+{
+	xmm_radio_settings_init();
+
+	return 0;
+}
+
+static void xmm7modem_exit(void)
+{
+	xmm_radio_settings_exit();
+}
+
+OFONO_PLUGIN_DEFINE(xmm7modem, "Intel xmm7xxx series modem driver",
+			VERSION, OFONO_PLUGIN_PRIORITY_DEFAULT,
+			xmm7modem_init, xmm7modem_exit)
diff --git a/drivers/xmm7modem/xmm7modem.h b/drivers/xmm7modem/xmm7modem.h
new file mode 100644
index 0000000..44fa3d6
--- /dev/null
+++ b/drivers/xmm7modem/xmm7modem.h
@@ -0,0 +1,27 @@
+/*
+ *
+ *  oFono - Open Source Telephony
+ *
+ *  Copyright (C) 2017  Intel Corporation. All rights reserved.
+ *
+ *  This program is free software; you can redistribute it and/or modify
+ *  it under the terms of the GNU General Public License version 2 as
+ *  published by the Free Software Foundation.
+ *
+ *  This program is distributed in the hope that it will be useful,
+ *  but WITHOUT ANY WARRANTY; without even the implied warranty of
+ *  MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
+ *  GNU General Public License for more details.
+ *
+ *  You should have received a copy of the GNU General Public License
+ *  along with this program; if not, write to the Free Software
+ *  Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA  02110-1301  USA
+ *
+ */
+
+#include <drivers/atmodem/atutil.h>
+
+#define XMM7MODEM "xmm7modem"
+
+extern void xmm_radio_settings_init(void);
+extern void xmm_radio_settings_exit(void);
-- 
1.9.1


^ permalink raw reply related	[flat|nested] 6+ messages in thread

* [PATCH 3/6] atutil: Add logic for cgcontrdp to get address and netmask
  2017-09-01  5:53 [PATCH 1/6] atmodem: Add lte atom driver Ankit Navik
  2017-09-01  5:53 ` [PATCH 2/6] Add support for Intel xmm7xxx series modem driver Ankit Navik
@ 2017-09-01  5:53 ` Ankit Navik
  2017-09-05 16:11   ` Denis Kenzior
  2017-09-05 15:44 ` [PATCH 1/6] atmodem: Add lte atom driver Denis Kenzior
  2 siblings, 1 reply; 6+ messages in thread
From: Ankit Navik @ 2017-09-01  5:53 UTC (permalink / raw)
  To: ofono

[-- Attachment #1: Type: text/plain, Size: 1956 bytes --]

---
 drivers/atmodem/atutil.c | 44 ++++++++++++++++++++++++++++++++++++++++++++
 drivers/atmodem/atutil.h |  3 +++
 2 files changed, 47 insertions(+)

diff --git a/drivers/atmodem/atutil.c b/drivers/atmodem/atutil.c
index 1487348..1067f20 100644
--- a/drivers/atmodem/atutil.c
+++ b/drivers/atmodem/atutil.c
@@ -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,46 @@ 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.
+ * TODO: Add logic for IPv6.
+ */
+int at_util_set_address_and_netmask(const char *addrnetmask, char *address,
+					char *netmask)
+{
+	char *dup = strdup(addrnetmask);
+	char *s = dup;
+
+	const char *addr = s;
+	const char *net = NULL;
+
+	int ret = -EINVAL;
+	int i;
+
+	/* Count 7 dots for ipv4, less or more means error. */
+	for (i = 0; i < 8; i++, s++) {
+		s = strchr(s, '.');
+
+		if (!s)
+			break;
+
+		if (i == 3) {
+			/* set netmask ptr and break the string */
+			net = s + 1;
+			s[0] = 0;
+		}
+	}
+
+	if (i == 7) {
+		strncpy(address, addr, strlen(addr));
+		strncpy(netmask, net, strlen(net));
+
+		ret = 0;
+	}
+
+	free(dup);
+
+	return ret;
+}
diff --git a/drivers/atmodem/atutil.h b/drivers/atmodem/atutil.h
index 5cb88b7..cc8fc52 100644
--- a/drivers/atmodem/atutil.h
+++ b/drivers/atmodem/atutil.h
@@ -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_set_address_and_netmask(const char *addrnetmask, char *address,
+						char *netmask);
+
 struct cb_data {
 	void *cb;
 	void *data;
-- 
1.9.1


^ permalink raw reply related	[flat|nested] 6+ messages in thread

* Re: [PATCH 1/6] atmodem: Add lte atom driver
  2017-09-01  5:53 [PATCH 1/6] atmodem: Add lte atom driver Ankit Navik
  2017-09-01  5:53 ` [PATCH 2/6] Add support for Intel xmm7xxx series modem driver Ankit Navik
  2017-09-01  5:53 ` [PATCH 3/6] atutil: Add logic for cgcontrdp to get address and netmask Ankit Navik
@ 2017-09-05 15:44 ` Denis Kenzior
  2 siblings, 0 replies; 6+ messages in thread
From: Denis Kenzior @ 2017-09-05 15:44 UTC (permalink / raw)
  To: ofono

[-- Attachment #1: Type: text/plain, Size: 521 bytes --]

Hi Ankit,

On 09/01/2017 12:53 AM, Ankit Navik wrote:
> Adds atmodem driver for setting the default APN command.
> The default APN is manage by config storage.
> ---
>   Makefile.am               |   3 +-
>   drivers/atmodem/atmodem.c |   2 +
>   drivers/atmodem/atmodem.h |   3 +
>   drivers/atmodem/lte.c     | 142 ++++++++++++++++++++++++++++++++++++++++++++++
>   4 files changed, 149 insertions(+), 1 deletion(-)
>   create mode 100644 drivers/atmodem/lte.c
> 

Applied, thanks.

Regards,
-Denis


^ permalink raw reply	[flat|nested] 6+ messages in thread

* Re: [PATCH 2/6] Add support for Intel xmm7xxx series modem driver
  2017-09-01  5:53 ` [PATCH 2/6] Add support for Intel xmm7xxx series modem driver Ankit Navik
@ 2017-09-05 15:48   ` Denis Kenzior
  0 siblings, 0 replies; 6+ messages in thread
From: Denis Kenzior @ 2017-09-05 15:48 UTC (permalink / raw)
  To: ofono

[-- Attachment #1: Type: text/plain, Size: 608 bytes --]

Hi Ankit,

On 09/01/2017 12:53 AM, Ankit Navik wrote:
> This adds driver as xmm7modem for radio-settings
> ---
>   Makefile.am                        |   5 +
>   drivers/xmm7modem/radio-settings.c | 233 +++++++++++++++++++++++++++++++++++++
>   drivers/xmm7modem/xmm7modem.c      |  50 ++++++++
>   drivers/xmm7modem/xmm7modem.h      |  27 +++++
>   4 files changed, 315 insertions(+)
>   create mode 100644 drivers/xmm7modem/radio-settings.c
>   create mode 100644 drivers/xmm7modem/xmm7modem.c
>   create mode 100644 drivers/xmm7modem/xmm7modem.h
> 

Applied, thanks.

Regards,
-Denis


^ permalink raw reply	[flat|nested] 6+ messages in thread

* Re: [PATCH 3/6] atutil: Add logic for cgcontrdp to get address and netmask
  2017-09-01  5:53 ` [PATCH 3/6] atutil: Add logic for cgcontrdp to get address and netmask Ankit Navik
@ 2017-09-05 16:11   ` Denis Kenzior
  0 siblings, 0 replies; 6+ messages in thread
From: Denis Kenzior @ 2017-09-05 16:11 UTC (permalink / raw)
  To: ofono

[-- Attachment #1: Type: text/plain, Size: 2628 bytes --]

Hi Ankit,

On 09/01/2017 12:53 AM, Ankit Navik wrote:
> ---
>   drivers/atmodem/atutil.c | 44 ++++++++++++++++++++++++++++++++++++++++++++
>   drivers/atmodem/atutil.h |  3 +++
>   2 files changed, 47 insertions(+)
> 
> diff --git a/drivers/atmodem/atutil.c b/drivers/atmodem/atutil.c
> index 1487348..1067f20 100644
> --- a/drivers/atmodem/atutil.c
> +++ b/drivers/atmodem/atutil.c
> @@ -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,46 @@ 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.
> + * TODO: Add logic for IPv6.
> + */
Put a comment here stating that address/netmask must be able to hold
255.255.255.255 + null = 16 characters

> +int at_util_set_address_and_netmask(const char *addrnetmask, char *address,
> +					char *netmask)

Lets call this at_util_get_ipv4_address_and_netmask

> +{
> +	char *dup = strdup(addrnetmask);

You could avoid a strdup entirely by marking the position of the 4th dot 
and doing some pointer math...

> +	char *s = dup;
> +
> +	const char *addr = s;
> +	const char *net = NULL;
> +
> +	int ret = -EINVAL;
> +	int i;
> +
> +	/* Count 7 dots for ipv4, less or more means error. */
> +	for (i = 0; i < 8; i++, s++) {

This doesn't actually check that the number of dots > 7 ...

> +		s = strchr(s, '.');
> +
> +		if (!s)
> +			break;
> +
> +		if (i == 3) {
> +			/* set netmask ptr and break the string */
> +			net = s + 1;
> +			s[0] = 0;
> +		}
> +	}
> +
> +	if (i == 7) {
> +		strncpy(address, addr, strlen(addr));
> +		strncpy(netmask, net, strlen(net));

This would appear not to copy the null terminator.  Not sure this is 
intended?

> +
> +		ret = 0;
> +	}
> +
> +	free(dup);
> +
> +	return ret;
> +}
> diff --git a/drivers/atmodem/atutil.h b/drivers/atmodem/atutil.h
> index 5cb88b7..cc8fc52 100644
> --- a/drivers/atmodem/atutil.h
> +++ b/drivers/atmodem/atutil.h
> @@ -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_set_address_and_netmask(const char *addrnetmask, char *address,
> +						char *netmask);
> +
>   struct cb_data {
>   	void *cb;
>   	void *data;
> 

Regards,
-Denis

^ permalink raw reply	[flat|nested] 6+ messages in thread

end of thread, other threads:[~2017-09-05 16:11 UTC | newest]

Thread overview: 6+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2017-09-01  5:53 [PATCH 1/6] atmodem: Add lte atom driver Ankit Navik
2017-09-01  5:53 ` [PATCH 2/6] Add support for Intel xmm7xxx series modem driver Ankit Navik
2017-09-05 15:48   ` Denis Kenzior
2017-09-01  5:53 ` [PATCH 3/6] atutil: Add logic for cgcontrdp to get address and netmask Ankit Navik
2017-09-05 16:11   ` Denis Kenzior
2017-09-05 15:44 ` [PATCH 1/6] atmodem: Add lte atom driver Denis Kenzior

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.