Skip to contentSkip to conversation

atmodem: removed simauth init

PATCH In review James Prestwood 2 participants 7 messages Nov 9, 2017 Kbuild

lore
Share & tools
lore
#0 lore raw

PATCH 1/6 atmodem: removed simauth init

---
 drivers/atmodem/atmodem.c | 2 --
 1 file changed, 2 deletions(-)
drivers/atmodem/atmodem.c +0 -2
index 684b228..e0d5ab6 100644
@@ -50,7 +50,6 @@ static int atmodem_init(void)
 	at_call_volume_init();
 	at_gprs_init();
 	at_gprs_context_init();
-	at_sim_auth_init();
 	at_gnss_init();
 	at_lte_init();
 
@@ -59,7 +58,6 @@ static int atmodem_init(void)
 
 static void atmodem_exit(void)
 {
-	at_sim_auth_exit();
 	at_stk_exit();
 	at_sim_exit();
 	at_sms_exit();
Signature · 1 line
2.7.4
#1 lore raw

PATCH 2/6 make: remove atmodem simauth driver

---
 Makefile.am | 1 -
 1 file changed, 1 deletion(-)
Makefile.am +0 -1
index 7a5e6ce..53f1972 100644
@@ -264,7 +264,6 @@ builtin_sources += 	drivers/atmodem/atmodem.h \
 			drivers/atmodem/atutil.c \
 			drivers/atmodem/gprs.c \
 			drivers/atmodem/gprs-context.c \
-			drivers/atmodem/sim-auth.c \
 			drivers/atmodem/gnss.c \
 			drivers/atmodem/lte.c
 
Signature · 1 line
2.7.4
#2 lore raw

PATCH 3/6 atmodem: removed simauth.c from atmodem

In reply to James Prestwood
---
 drivers/atmodem/sim-auth.c | 316 ---------------------------------------------
 1 file changed, 316 deletions(-)
 delete mode 100644 drivers/atmodem/sim-auth.c
drivers/atmodem/sim-auth.c deleted +0 -316
deleted file mode 100644
index d04f561..0000000
@@ -1,316 +0,0 @@
-/*
- *
- *  oFono - Open Source Telephony
- *
- *  Copyright (C) 2008-2011  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 <stdio.h>
-
-#include <glib.h>
-
-#include <ofono/modem.h>
-#include <ofono/sim-auth.h>
-
-#include "gatchat.h"
-#include "gatresult.h"
-#include "simutil.h"
-#include "vendor.h"
-#include "util.h"
-
-#include "atmodem.h"
-
-struct sim_auth_data {
-	GAtChat *chat;
-	unsigned int vendor;
-};
-
-static const char *cuad_prefix[] = { "+CUAD:", NULL };
-static const char *ccho_prefix[] = { "+CCHO:", NULL };
-static const char *cgla_prefix[] = { "+CGLA:", NULL };
-
-static void at_discover_apps_cb(gboolean ok, GAtResult *result,
-				gpointer user_data)
-{
-	struct cb_data *cbd = user_data;
-	GAtResultIter iter;
-	ofono_sim_list_apps_cb_t cb = cbd->cb;
-	struct ofono_error error;
-	const unsigned char *dataobj;
-	gint linelen;
-	unsigned char *buffer;
-	int len;
-
-	decode_at_error(&error, g_at_result_final_response(result));
-
-	if (!ok) {
-		cb(&error, NULL, 0, cbd->data);
-		return;
-	}
-
-	g_at_result_iter_init(&iter, result);
-
-	len = 0;
-	while (g_at_result_iter_next(&iter, "+CUAD:")) {
-		if (!g_at_result_iter_next_hexstring(&iter, NULL, &linelen))
-			goto error;
-
-		len += linelen;
-	}
-
-	g_at_result_iter_init(&iter, result);
-
-	buffer = g_malloc(len);
-	len = 0;
-
-	while (g_at_result_iter_next(&iter, "+CUAD:")) {
-		g_at_result_iter_next_hexstring(&iter, &dataobj, &linelen);
-		memcpy(buffer + len, dataobj, linelen);
-		len += linelen;
-	}
-
-	cb(&error, buffer, len, cbd->data);
-
-	g_free(buffer);
-	return;
-
-error:
-	CALLBACK_WITH_FAILURE(cb, NULL, 0, cbd->data);
-}
-
-static void at_discover_apps(struct ofono_sim_auth *sa,
-				ofono_sim_list_apps_cb_t cb,
-				void *data)
-{
-	struct sim_auth_data *sad = ofono_sim_auth_get_data(sa);
-	struct cb_data *cbd = cb_data_new(cb, data);
-
-	if (g_at_chat_send(sad->chat, "AT+CUAD", cuad_prefix,
-					at_discover_apps_cb, cbd, g_free) > 0)
-		return;
-
-	g_free(cbd);
-
-	CALLBACK_WITH_FAILURE(cb, NULL, 0, data);
-}
-
-static void at_open_channel_cb(gboolean ok, GAtResult *result,
-		gpointer user_data)
-{
-	struct cb_data *cbd = user_data;
-	GAtResultIter iter;
-	ofono_sim_open_channel_cb_t cb = cbd->cb;
-	struct ofono_error error;
-	int session_id = -1;
-
-	decode_at_error(&error, g_at_result_final_response(result));
-
-	if (!ok)
-		goto error;
-
-	g_at_result_iter_init(&iter, result);
-
-	if (!g_at_result_iter_next(&iter, "+CCHO:"))
-		goto error;
-
-	if (!g_at_result_iter_next_number(&iter, &session_id))
-		goto error;
-
-	cb(&error, session_id, cbd->data);
-
-	return;
-
-error:
-	cb(&error, -1, cbd->data);
-}
-
-static void at_open_channel(struct ofono_sim_auth *sa, const uint8_t *aid,
-		ofono_sim_open_channel_cb_t cb, void *data)
-{
-	struct sim_auth_data *sad = ofono_sim_auth_get_data(sa);
-	struct cb_data *cbd = cb_data_new(cb, data);
-	char cmd[43];
-	int ret = 0;
-
-	strcpy(cmd, "AT+CCHO=\"");
-	ret += 9;
-
-	encode_hex_own_buf(aid, 16, 0, cmd + ret);
-	ret += 32;
-
-	strcpy(cmd + ret, "\"");
-
-	if (g_at_chat_send(sad->chat, cmd, ccho_prefix, at_open_channel_cb,
-			cbd, g_free) > 0)
-		return;
-
-	g_free(cbd);
-
-	CALLBACK_WITH_FAILURE(cb, -1, data);
-}
-
-static void at_close_channel_cb(gboolean ok, GAtResult *result,
-		gpointer user_data)
-{
-	struct cb_data *cbd = user_data;
-	ofono_sim_close_channel_cb_t cb = cbd->cb;
-	struct ofono_error error;
-
-	decode_at_error(&error, g_at_result_final_response(result));
-
-	if (cb)
-		cb(&error, cbd->data);
-}
-
-static void at_close_channel(struct ofono_sim_auth *sa, int session_id,
-		ofono_sim_close_channel_cb_t cb, void *data)
-{
-	struct sim_auth_data *sad = ofono_sim_auth_get_data(sa);
-	struct cb_data *cbd = cb_data_new(cb, data);
-	char cmd[15];
-
-	sprintf(cmd, "AT+CCHC=%d", session_id);
-
-	g_at_chat_send(sad->chat, cmd, NULL, at_close_channel_cb, cbd, g_free);
-}
-
-static void logical_access_cb(gboolean ok, GAtResult *result,
-		gpointer user_data)
-{
-	struct cb_data *cbd = user_data;
-	ofono_logical_access_cb_t cb = cbd->cb;
-	struct ofono_error error;
-	const char *str_data;
-	uint8_t *raw;
-	gint len = 0;
-	GAtResultIter iter;
-
-	decode_at_error(&error, g_at_result_final_response(result));
-
-	if (!ok)
-		goto error;
-
-	g_at_result_iter_init(&iter, result);
-
-	if (!g_at_result_iter_next(&iter, "+CGLA:"))
-		goto error;
-
-	if (!g_at_result_iter_next_number(&iter, &len))
-		goto error;
-
-	if (!g_at_result_iter_next_string(&iter, &str_data))
-		goto error;
-
-	raw = alloca(len / 2);
-
-	decode_hex_own_buf(str_data, len, NULL, 0, raw);
-
-	cb(&error, raw, len / 2, cbd->data);
-
-	return;
-
-error:
-	cb(&error, NULL, 0, cbd->data);
-}
-
-static void at_logical_access(struct ofono_sim_auth *sa, int session_id,
-		const uint8_t *pdu, uint16_t len, ofono_logical_access_cb_t cb,
-		void *data)
-
-{
-	struct sim_auth_data *sad = ofono_sim_auth_get_data(sa);
-	struct cb_data *cbd = cb_data_new(cb, data);
-	int ret = 0;
-	char cmd[(len * 2) + 19];
-
-	ret = sprintf(cmd, "AT+CGLA=%d,%d,\"", session_id, len * 2);
-
-	encode_hex_own_buf(pdu, len, 0, cmd + ret);
-	ret += len * 2;
-
-	strcpy(cmd + ret, "\"");
-
-	if (g_at_chat_send(sad->chat, cmd, cgla_prefix, logical_access_cb,
-			cbd, g_free) > 0)
-		return;
-
-	g_free(cbd);
-
-	CALLBACK_WITH_FAILURE(cb, NULL, 0, data);
-}
-
-static gboolean at_sim_auth_register(gpointer user)
-{
-	struct ofono_sim_auth *sa = user;
-
-	ofono_sim_auth_register(sa);
-
-	return FALSE;
-}
-
-static int at_sim_auth_probe(struct ofono_sim_auth *sa, unsigned int vendor,
-				void *data)
-{
-	GAtChat *chat = data;
-	struct sim_auth_data *sad;
-
-	sad = g_new0(struct sim_auth_data, 1);
-	sad->chat = g_at_chat_clone(chat);
-	sad->vendor = vendor;
-
-	ofono_sim_auth_set_data(sa, sad);
-	g_idle_add(at_sim_auth_register, sa);
-
-	return 0;
-}
-
-static void at_sim_auth_remove(struct ofono_sim_auth *sa)
-{
-	struct sim_auth_data *sad = ofono_sim_auth_get_data(sa);
-
-	g_idle_remove_by_data(sa);
-	ofono_sim_auth_set_data(sa, NULL);
-
-	g_at_chat_unref(sad->chat);
-	g_free(sad);
-}
-
-static struct ofono_sim_auth_driver driver = {
-	.name		= "atmodem",
-	.probe		= at_sim_auth_probe,
-	.remove		= at_sim_auth_remove,
-	.list_apps	= at_discover_apps,
-	.open_channel	= at_open_channel,
-	.close_channel	= at_close_channel,
-	.logical_access = at_logical_access
-};
-
-void at_sim_auth_init(void)
-{
-	ofono_sim_auth_driver_register(&driver);
-}
-
-void at_sim_auth_exit(void)
-{
-	ofono_sim_auth_driver_unregister(&driver);
-}
Signature · 1 line
2.7.4
#3 lore raw

PATCH 4/6 simauth: remove driver API definitions from simauth include

In reply to James Prestwood
---
 include/sim-auth.h | 37 +------------------------------------
 1 file changed, 1 insertion(+), 36 deletions(-)
include/sim-auth.h +1 -36
index ccaa7f2..17599f3 100644
@@ -32,44 +32,9 @@ extern "C" {
 
 struct ofono_sim_auth;
 
-typedef void (*ofono_sim_list_apps_cb_t)(const struct ofono_error *error,
-					const unsigned char *dataobj,
-					int len, void *data);
-
-typedef void (*ofono_sim_open_channel_cb_t)(const struct ofono_error *error,
-		int session_id, void *data);
-
-typedef void (*ofono_sim_close_channel_cb_t)(const struct ofono_error *error,
-		void *data);
-
-typedef void (*ofono_logical_access_cb_t)(const struct ofono_error *error,
-		const uint8_t *resp, uint16_t len, void *data);
-
-struct ofono_sim_auth_driver {
-	const char *name;
-	int (*probe)(struct ofono_sim_auth *sa, unsigned int vendor,
-			void *data);
-	void (*remove)(struct ofono_sim_auth *sa);
-
-	void (*list_apps)(struct ofono_sim_auth *sa,
-			ofono_sim_list_apps_cb_t cb, void *data);
-	void (*open_channel)(struct ofono_sim_auth *sa, const uint8_t *aid,
-			ofono_sim_open_channel_cb_t cb, void *data);
-	void (*close_channel)(struct ofono_sim_auth *sa, int session_id,
-			ofono_sim_close_channel_cb_t cb, void *data);
-	void (*logical_access)(struct ofono_sim_auth *sa,
-			int session_id, const uint8_t *pdu, uint16_t len,
-			ofono_logical_access_cb_t cb, void *data);
-};
-
-int ofono_sim_auth_driver_register(const struct ofono_sim_auth_driver *d);
-void ofono_sim_auth_driver_unregister(const struct ofono_sim_auth_driver *d);
-
 struct ofono_sim_auth *ofono_sim_auth_create(struct ofono_modem *modem,
-						unsigned int vendor,
-						const char *driver, void *data);
+		void *data);
 
-void ofono_sim_auth_register(struct ofono_sim_auth *sa);
 void ofono_sim_auth_remove(struct ofono_sim_auth *sa);
 
 void ofono_sim_auth_set_data(struct ofono_sim_auth *sa, void *data);
Signature · 1 line
2.7.4
#4 lore raw

PATCH 5/6 simauth: remove driver code from core simauth atom

In reply to James Prestwood
---
 src/sim-auth.c | 48 +++++-------------------------------------------
 1 file changed, 5 insertions(+), 43 deletions(-)
src/sim-auth.c +5 -43
index f5ae7b6..0567771 100644
@@ -39,8 +39,6 @@
 
 #define SIM_AUTH_MAX_RANDS	3
 
-static GSList *g_drivers = NULL;
-
 /*
  * Temporary handle used for the command authentication sequence.
  */
@@ -136,25 +134,6 @@ static void free_apps(struct ofono_sim_auth *sa)
 	g_slist_free(sa->aid_objects);
 }
 
-int ofono_sim_auth_driver_register(const struct ofono_sim_auth_driver *d)
-{
-	DBG("driver: %p, name: %s", d, d->name);
-
-	if (d->probe == NULL)
-		return -EINVAL;
-
-	g_drivers = g_slist_prepend(g_drivers, (void *) d);
-
-	return 0;
-}
-
-void ofono_sim_auth_driver_unregister(const struct ofono_sim_auth_driver *d)
-{
-	DBG("driver: %p, name: %s", d, d->name);
-
-	g_drivers = g_slist_remove(g_drivers, (void *) d);
-}
-
 static void sim_auth_unregister(struct ofono_atom *atom)
 {
 	struct ofono_sim_auth *sa = __ofono_atom_get_data(atom);
@@ -173,21 +152,15 @@ static void sim_auth_remove(struct ofono_atom *atom)
 	if (sa == NULL)
 		return;
 
-	if (sa->driver && sa->driver->remove)
-		sa->driver->remove(sa);
-
 	g_free(sa);
 }
 
+static void sim_auth_register(struct ofono_sim_auth *sa);
+
 struct ofono_sim_auth *ofono_sim_auth_create(struct ofono_modem *modem,
-						unsigned int vendor,
-						const char *driver, void *data)
+		void *data)
 {
 	struct ofono_sim_auth *sa;
-	GSList *l;
-
-	if (driver == NULL)
-		return NULL;
 
 	sa = g_new0(struct ofono_sim_auth, 1);
 
@@ -197,18 +170,7 @@ struct ofono_sim_auth *ofono_sim_auth_create(struct ofono_modem *modem,
 	sa->atom = __ofono_modem_add_atom(modem, OFONO_ATOM_TYPE_SIM_AUTH,
 						sim_auth_remove, sa);
 
-	for (l = g_drivers; l; l = l->next) {
-		const struct ofono_sim_auth_driver *drv = l->data;
-
-		if (g_strcmp0(drv->name, driver))
-			continue;
-
-		if (drv->probe(sa, vendor, data) < 0)
-			continue;
-
-		sa->driver = drv;
-		break;
-	}
+	sim_auth_register(sa);
 
 	return sa;
 }
@@ -725,7 +687,7 @@ static char *build_nai(const char *imsi)
 	return nai;
 }
 
-void ofono_sim_auth_register(struct ofono_sim_auth *sa)
+static void sim_auth_register(struct ofono_sim_auth *sa)
 {
 	DBusConnection *conn = ofono_dbus_get_connection();
 	const char *path = __ofono_atom_get_path(sa->atom);
Signature · 1 line
2.7.4
#5 lore raw

PATCH 6/6 plugins: updated plugins using simauth module

In reply to James Prestwood

The simauth creation API changed to not take the driver structure

---
 plugins/mbm.c      | 2 +-
 plugins/phonesim.c | 2 +-
 plugins/xmm7xxx.c  | 2 +-
 3 files changed, 3 insertions(+), 3 deletions(-)
plugins/mbm.c +1 -1
index fa0088c..1ae5d48 100644
@@ -452,7 +452,7 @@ static void mbm_post_sim(struct ofono_modem *modem)
 	ofono_radio_settings_create(modem, 0, "stemodem", data->modem_port);
 
 	ofono_sms_create(modem, 0, "atmodem", data->modem_port);
-	ofono_sim_auth_create(modem, 0, "atmodem", data->modem_port);
+	ofono_sim_auth_create(modem, data->modem_port);
 }
 
 static void mbm_post_online(struct ofono_modem *modem)
plugins/phonesim.c +1 -1
index 3af2c46..5620b20 100644
@@ -861,7 +861,7 @@ static void phonesim_post_sim(struct ofono_modem *modem)
 		ofono_sms_create(modem, 0, "atmodem", data->chat);
 
 	ofono_radio_settings_create(modem, 0, "phonesim", data->chat);
-	ofono_sim_auth_create(modem, 0, "atmodem", data->chat);
+	ofono_sim_auth_create(modem, data->chat);
 }
 
 static void phonesim_post_online(struct ofono_modem *modem)
plugins/xmm7xxx.c +1 -1
index a2582df..8f01e69 100644
@@ -325,7 +325,7 @@ static void xmm7xxx_post_sim(struct ofono_modem *modem)
 
 	ofono_lte_create(modem, "atmodem", data->chat);
 	ofono_radio_settings_create(modem, 0, "xmm7modem", data->chat);
-	ofono_sim_auth_create(modem, 0, "atmodem", data->chat);
+	ofono_sim_auth_create(modem, data->chat);
 }
 
 static void xmm7xxx_post_online(struct ofono_modem *modem)
Signature · 1 line
2.7.4