All of lore.kernel.org
 help / color / mirror / Atom feed
* [PATCH 1/4] Remove initialisers for enum ofono_atom_type.
@ 2011-01-19  8:07 Andrzej Zaborowski
  2011-01-19  8:07 ` [PATCH 1/2] simutil: SIM applications directory decoding utils Andrzej Zaborowski
                   ` (5 more replies)
  0 siblings, 6 replies; 16+ messages in thread
From: Andrzej Zaborowski @ 2011-01-19  8:07 UTC (permalink / raw)
  To: ofono

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

They have no effect, enum already ensures the values are unique.
---
 src/ofono.h |   48 ++++++++++++++++++++++++------------------------
 1 files changed, 24 insertions(+), 24 deletions(-)

diff --git a/src/ofono.h b/src/ofono.h
index 77567c2..badc2ee 100644
--- a/src/ofono.h
+++ b/src/ofono.h
@@ -103,30 +103,30 @@ void __ofono_modem_append_properties(struct ofono_modem *modem,
 struct ofono_atom;
 
 enum ofono_atom_type {
-	OFONO_ATOM_TYPE_DEVINFO = 0,
-	OFONO_ATOM_TYPE_CALL_BARRING = 1,
-	OFONO_ATOM_TYPE_CALL_FORWARDING = 2,
-	OFONO_ATOM_TYPE_CALL_METER = 3,
-	OFONO_ATOM_TYPE_CALL_SETTINGS = 4,
-	OFONO_ATOM_TYPE_NETREG = 5,
-	OFONO_ATOM_TYPE_PHONEBOOK = 6,
-	OFONO_ATOM_TYPE_SMS = 7,
-	OFONO_ATOM_TYPE_SIM = 8,
-	OFONO_ATOM_TYPE_USSD = 9,
-	OFONO_ATOM_TYPE_VOICECALL = 10,
-	OFONO_ATOM_TYPE_HISTORY = 11,
-	OFONO_ATOM_TYPE_SSN = 12,
-	OFONO_ATOM_TYPE_MESSAGE_WAITING = 13,
-	OFONO_ATOM_TYPE_CBS = 14,
-	OFONO_ATOM_TYPES_CALL_VOLUME = 15,
-	OFONO_ATOM_TYPE_GPRS = 16,
-	OFONO_ATOM_TYPE_GPRS_CONTEXT = 17,
-	OFONO_ATOM_TYPE_RADIO_SETTINGS = 18,
-	OFONO_ATOM_TYPE_AUDIO_SETTINGS = 19,
-	OFONO_ATOM_TYPE_STK = 20,
-	OFONO_ATOM_TYPE_NETTIME = 21,
-	OFONO_ATOM_TYPE_CTM = 22,
-	OFONO_ATOM_TYPE_CDMA_VOICECALL_MANAGER = 23,
+	OFONO_ATOM_TYPE_DEVINFO,
+	OFONO_ATOM_TYPE_CALL_BARRING,
+	OFONO_ATOM_TYPE_CALL_FORWARDING,
+	OFONO_ATOM_TYPE_CALL_METER,
+	OFONO_ATOM_TYPE_CALL_SETTINGS,
+	OFONO_ATOM_TYPE_NETREG,
+	OFONO_ATOM_TYPE_PHONEBOOK,
+	OFONO_ATOM_TYPE_SMS,
+	OFONO_ATOM_TYPE_SIM,
+	OFONO_ATOM_TYPE_USSD,
+	OFONO_ATOM_TYPE_VOICECALL,
+	OFONO_ATOM_TYPE_HISTORY,
+	OFONO_ATOM_TYPE_SSN,
+	OFONO_ATOM_TYPE_MESSAGE_WAITING,
+	OFONO_ATOM_TYPE_CBS,
+	OFONO_ATOM_TYPES_CALL_VOLUME,
+	OFONO_ATOM_TYPE_GPRS,
+	OFONO_ATOM_TYPE_GPRS_CONTEXT,
+	OFONO_ATOM_TYPE_RADIO_SETTINGS,
+	OFONO_ATOM_TYPE_AUDIO_SETTINGS,
+	OFONO_ATOM_TYPE_STK,
+	OFONO_ATOM_TYPE_NETTIME,
+	OFONO_ATOM_TYPE_CTM,
+	OFONO_ATOM_TYPE_CDMA_VOICECALL_MANAGER,
 };
 
 enum ofono_atom_watch_condition {
-- 
1.7.1.86.g0e460.dirty


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

* [PATCH 1/2] simutil: SIM applications directory decoding utils.
  2011-01-19  8:07 [PATCH 1/4] Remove initialisers for enum ofono_atom_type Andrzej Zaborowski
@ 2011-01-19  8:07 ` Andrzej Zaborowski
  2011-01-20 17:24   ` Denis Kenzior
  2011-01-19  8:07 ` [PATCH 2/2] unit: Add a test for applications directory decoding utility Andrzej Zaborowski
                   ` (4 subsequent siblings)
  5 siblings, 1 reply; 16+ messages in thread
From: Andrzej Zaborowski @ 2011-01-19  8:07 UTC (permalink / raw)
  To: ofono

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

---
 src/simutil.c |   57 +++++++++++++++++++++++++++++++++++++++++++++++++++++++++
 src/simutil.h |    8 ++++++++
 2 files changed, 65 insertions(+), 0 deletions(-)

diff --git a/src/simutil.c b/src/simutil.c
index 8abf3d5..b3e2f52 100644
--- a/src/simutil.c
+++ b/src/simutil.c
@@ -1465,3 +1465,60 @@ gboolean sim_sst_is_active(unsigned char *efsst, unsigned char len,
 
 	return (efsst[index / 4] >> (((index % 4) * 2) + 1)) & 1;
 }
+
+GSList *sim_parse_app_template_entries(const unsigned char *buffer, int len)
+{
+	GSList *ret = NULL;
+	const unsigned char *dataobj;
+	int dataobj_len;
+
+	/* Find all the application entries */
+	while ((dataobj = ber_tlv_find_by_tag(buffer, 0x61, len,
+						&dataobj_len)) != NULL) {
+		struct ofono_sim_app_record app;
+		const unsigned char *aid, *label;
+		int label_len;
+
+		/* Find the aid (mandatory) */
+		aid = ber_tlv_find_by_tag(dataobj, 0x4f, dataobj_len,
+						&app.aid_len);
+		if (!aid || app.aid_len < 0x01 || app.aid_len > 0x10)
+			goto error;
+
+		memcpy(app.aid, aid, app.aid_len);
+
+		/* Find the label (optional) */
+		label = ber_tlv_find_by_tag(dataobj, 0x50, dataobj_len,
+						&label_len);
+		if (label) {
+			/*
+			 * Label field uses the extra complicated
+			 * encoding in 102.221 Annex A
+			 */
+			app.label = sim_string_to_utf8(label, label_len);
+
+			if (app.label == NULL)
+				goto error;
+		} else
+			app.label = NULL;
+
+		ret = g_slist_prepend(ret, g_memdup(&app, sizeof(app)));
+
+		len -= (dataobj - buffer) + dataobj_len;
+		buffer = dataobj + dataobj_len;
+	}
+
+	return ret;
+
+error:
+	while (ret) {
+		GSList *t = ret;
+
+		g_free(((struct ofono_sim_app_record *) ret->data)->label);
+
+		ret = ret->next;
+		g_slist_free_1(t);
+	}
+
+	return NULL;
+}
diff --git a/src/simutil.h b/src/simutil.h
index 554f798..0093edc 100644
--- a/src/simutil.h
+++ b/src/simutil.h
@@ -255,6 +255,12 @@ struct sim_ef_info {
 	enum sim_file_access perm_update;
 };
 
+struct ofono_sim_app_record {
+	unsigned char aid[16];
+	int aid_len;
+	char *label;
+};
+
 struct simple_tlv_iter {
 	unsigned int max;
 	unsigned int pos;
@@ -446,3 +452,5 @@ gboolean sim_sst_is_available(unsigned char *service_sst, unsigned char len,
 						enum sim_sst_service index);
 gboolean sim_sst_is_active(unsigned char *service_sst, unsigned char len,
 						enum sim_sst_service index);
+
+GSList *sim_parse_app_template_entries(const unsigned char *buffer, int len);
-- 
1.7.1.86.g0e460.dirty


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

* [PATCH 2/2] unit: Add a test for applications directory decoding utility.
  2011-01-19  8:07 [PATCH 1/4] Remove initialisers for enum ofono_atom_type Andrzej Zaborowski
  2011-01-19  8:07 ` [PATCH 1/2] simutil: SIM applications directory decoding utils Andrzej Zaborowski
@ 2011-01-19  8:07 ` Andrzej Zaborowski
  2011-01-20 17:24   ` Denis Kenzior
  2011-01-19  8:07 ` [PATCH 2/4] Add SIM authentication atom's driver definitions Andrzej Zaborowski
                   ` (3 subsequent siblings)
  5 siblings, 1 reply; 16+ messages in thread
From: Andrzej Zaborowski @ 2011-01-19  8:07 UTC (permalink / raw)
  To: ofono

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

---
 unit/test-simutil.c |   32 ++++++++++++++++++++++++++++++++
 1 files changed, 32 insertions(+), 0 deletions(-)

diff --git a/unit/test-simutil.c b/unit/test-simutil.c
index 7cb5c10..1f350f6 100644
--- a/unit/test-simutil.c
+++ b/unit/test-simutil.c
@@ -444,6 +444,36 @@ static void test_3g_status_data(void)
 	g_free(response);
 }
 
+static char *at_cuad_response = "611B4F10A0000000871002FFFFFFFF8905080000"
+	"FFFFFFFFFFFFFFFFFFFFFFFFFF611F4F0CA000000063504B43532D"
+	"313550094D49445066696C657351043F007F80";
+
+static void test_application_entry_decode(void) {
+	unsigned char *ef_dir;
+	long len;
+	GSList *entries;
+	struct ofono_sim_app_record *app[2];
+
+	ef_dir = decode_hex(at_cuad_response, -1, &len, 0);
+	entries = sim_parse_app_template_entries(ef_dir, len);
+
+	g_assert(g_slist_length(entries) == 2);
+
+	app[0] = entries->next->data;
+	app[1] = entries->data;
+
+	g_assert(app[0]->aid_len == 0x10);
+	g_assert(!memcmp(app[0]->aid, &ef_dir[4], 0x10));
+	g_assert(app[0]->label == NULL);
+
+	g_assert(app[1]->aid_len == 0x0c);
+	g_assert(!memcmp(app[1]->aid, &ef_dir[37], 0x0c));
+	g_assert(app[1]->label != NULL);
+	g_assert(!strcmp(app[1]->label, "MIDPfiles"));
+
+	g_free(ef_dir);
+}
+
 int main(int argc, char **argv)
 {
 	g_test_init(&argc, &argv, NULL);
@@ -458,6 +488,8 @@ int main(int argc, char **argv)
 	g_test_add_func("/testsimutil/EONS Handling", test_eons);
 	g_test_add_func("/testsimutil/Elementary File DB", test_ef_db);
 	g_test_add_func("/testsimutil/3G Status response", test_3g_status_data);
+	g_test_add_func("/testsimutil/Application entries decoding",
+			test_application_entry_decode);
 
 	return g_test_run();
 }
-- 
1.7.1.86.g0e460.dirty


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

* [PATCH 2/4] Add SIM authentication atom's driver definitions.
  2011-01-19  8:07 [PATCH 1/4] Remove initialisers for enum ofono_atom_type Andrzej Zaborowski
  2011-01-19  8:07 ` [PATCH 1/2] simutil: SIM applications directory decoding utils Andrzej Zaborowski
  2011-01-19  8:07 ` [PATCH 2/2] unit: Add a test for applications directory decoding utility Andrzej Zaborowski
@ 2011-01-19  8:07 ` Andrzej Zaborowski
  2011-01-20 17:24   ` Denis Kenzior
  2011-01-19  8:07 ` [PATCH 3/4] Add the sim-auth atom Andrzej Zaborowski
                   ` (2 subsequent siblings)
  5 siblings, 1 reply; 16+ messages in thread
From: Andrzej Zaborowski @ 2011-01-19  8:07 UTC (permalink / raw)
  To: ofono

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

Structures and function declarations for the SIM authentication
atom as proposed by Pekka Pessi, with just one method at the
moment.
---
 Makefile.am        |    2 +-
 include/sim-auth.h |   64 ++++++++++++++++++++++++++++++++++++++++++++++++++++
 2 files changed, 65 insertions(+), 1 deletions(-)
 create mode 100644 include/sim-auth.h

diff --git a/Makefile.am b/Makefile.am
index c1c34ca..7ea1b2d 100644
--- a/Makefile.am
+++ b/Makefile.am
@@ -13,7 +13,7 @@ pkginclude_HEADERS = include/log.h include/plugin.h include/history.h \
 			include/radio-settings.h include/stk.h \
 			include/audio-settings.h include/nettime.h \
 			include/ctm.h include/cdma-voicecall.h \
-			include/cdma-sms.h
+			include/cdma-sms.h include/sim-auth.h
 
 nodist_pkginclude_HEADERS = include/version.h
 
diff --git a/include/sim-auth.h b/include/sim-auth.h
new file mode 100644
index 0000000..0a62adc
--- /dev/null
+++ b/include/sim-auth.h
@@ -0,0 +1,64 @@
+/*
+ *
+ *  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
+ *
+ */
+
+#ifndef __OFONO_SIM_AUTH_H
+#define __OFONO_SIM_AUTH_H
+
+#ifdef __cplusplus
+extern "C" {
+#endif
+
+#include <ofono/types.h>
+
+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);
+
+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);
+};
+
+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 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);
+void *ofono_sim_auth_get_data(struct ofono_sim_auth *sa);
+
+#ifdef __cplusplus
+}
+#endif
+
+#endif /* __OFONO_SIM_AUTH_H */
-- 
1.7.1.86.g0e460.dirty


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

* [PATCH 3/4] Add the sim-auth atom.
  2011-01-19  8:07 [PATCH 1/4] Remove initialisers for enum ofono_atom_type Andrzej Zaborowski
                   ` (2 preceding siblings ...)
  2011-01-19  8:07 ` [PATCH 2/4] Add SIM authentication atom's driver definitions Andrzej Zaborowski
@ 2011-01-19  8:07 ` Andrzej Zaborowski
  2011-01-20 17:25   ` Denis Kenzior
  2011-01-19  8:07 ` [PATCH 4/4] atmodem: sim-auth atom driver Andrzej Zaborowski
  2011-01-20 17:23 ` [PATCH 1/4] Remove initialisers for enum ofono_atom_type Denis Kenzior
  5 siblings, 1 reply; 16+ messages in thread
From: Andrzej Zaborowski @ 2011-01-19  8:07 UTC (permalink / raw)
  To: ofono

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

Add dummy SIM authentication atom.
---
 Makefile.am    |    2 +-
 src/ofono.h    |    2 +
 src/sim-auth.c |  134 ++++++++++++++++++++++++++++++++++++++++++++++++++++++++
 3 files changed, 137 insertions(+), 1 deletions(-)
 create mode 100644 src/sim-auth.c

diff --git a/Makefile.am b/Makefile.am
index 7ea1b2d..10892a6 100644
--- a/Makefile.am
+++ b/Makefile.am
@@ -353,7 +353,7 @@ src_ofonod_SOURCES = $(gdbus_sources) $(builtin_sources) src/ofono.ver \
 			src/nettime.c src/stkagent.c src/stkagent.h \
 			src/simfs.c src/simfs.h src/audio-settings.c \
 			src/smsagent.c src/smsagent.h src/ctm.c \
-			src/cdma-voicecall.c
+			src/cdma-voicecall.c src/sim-auth.c
 
 src_ofonod_LDADD = $(builtin_libadd) @GLIB_LIBS@ @DBUS_LIBS@ @CAPNG_LIBS@ -ldl
 
diff --git a/src/ofono.h b/src/ofono.h
index badc2ee..e48dbf6 100644
--- a/src/ofono.h
+++ b/src/ofono.h
@@ -127,6 +127,7 @@ enum ofono_atom_type {
 	OFONO_ATOM_TYPE_NETTIME,
 	OFONO_ATOM_TYPE_CTM,
 	OFONO_ATOM_TYPE_CDMA_VOICECALL_MANAGER,
+	OFONO_ATOM_TYPE_SIM_AUTH,
 };
 
 enum ofono_atom_watch_condition {
@@ -418,3 +419,4 @@ void __ofono_nettime_info_received(struct ofono_modem *modem,
 					struct ofono_network_time *info);
 
 #include <ofono/cdma-voicecall.h>
+#include <ofono/sim-auth.h>
diff --git a/src/sim-auth.c b/src/sim-auth.c
new file mode 100644
index 0000000..5d2f075
--- /dev/null
+++ b/src/sim-auth.c
@@ -0,0 +1,134 @@
+/*
+ *
+ *  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 <glib.h>
+#include <errno.h>
+#include <unistd.h>
+
+#include "ofono.h"
+
+#include "simutil.h"
+
+static GSList *g_drivers = NULL;
+
+struct ofono_sim_auth {
+	const struct ofono_sim_auth_driver *driver;
+	void *driver_data;
+	struct ofono_atom *atom;
+};
+
+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)
+{
+}
+
+static void sim_auth_remove(struct ofono_atom *atom)
+{
+	struct ofono_sim_auth *sa = __ofono_atom_get_data(atom);
+
+	DBG("atom: %p", atom);
+
+	if (sa == NULL)
+		return;
+
+	if (sa->driver && sa->driver->remove)
+		sa->driver->remove(sa);
+
+	g_free(sa);
+}
+
+struct ofono_sim_auth *ofono_sim_auth_create(struct ofono_modem *modem,
+						unsigned int vendor,
+						const char *driver, void *data)
+{
+	struct ofono_sim_auth *sa;
+	GSList *l;
+
+	if (driver == NULL)
+		return NULL;
+
+	sa = g_try_new0(struct ofono_sim_auth, 1);
+
+	if (sa == NULL)
+		return NULL;
+
+	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;
+	}
+
+	return sa;
+}
+
+void ofono_sim_auth_register(struct ofono_sim_auth *sa)
+{
+	__ofono_atom_register(sa->atom, sim_auth_unregister);
+}
+
+void ofono_sim_auth_remove(struct ofono_sim_auth *sa)
+{
+	__ofono_atom_free(sa->atom);
+}
+
+void ofono_sim_auth_set_data(struct ofono_sim_auth *sa, void *data)
+{
+	sa->driver_data = data;
+}
+
+void *ofono_sim_auth_get_data(struct ofono_sim_auth *sa)
+{
+	return sa->driver_data;
+}
-- 
1.7.1.86.g0e460.dirty


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

* [PATCH 4/4] atmodem: sim-auth atom driver.
  2011-01-19  8:07 [PATCH 1/4] Remove initialisers for enum ofono_atom_type Andrzej Zaborowski
                   ` (3 preceding siblings ...)
  2011-01-19  8:07 ` [PATCH 3/4] Add the sim-auth atom Andrzej Zaborowski
@ 2011-01-19  8:07 ` Andrzej Zaborowski
  2011-01-20 16:21   ` Jeevaka.Badrappan
  2011-01-20 17:25   ` Denis Kenzior
  2011-01-20 17:23 ` [PATCH 1/4] Remove initialisers for enum ofono_atom_type Denis Kenzior
  5 siblings, 2 replies; 16+ messages in thread
From: Andrzej Zaborowski @ 2011-01-19  8:07 UTC (permalink / raw)
  To: ofono

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

---
 Makefile.am                |    3 +-
 drivers/atmodem/atmodem.c  |    2 +
 drivers/atmodem/atmodem.h  |    3 +
 drivers/atmodem/sim-auth.c |  162 ++++++++++++++++++++++++++++++++++++++++++++
 4 files changed, 169 insertions(+), 1 deletions(-)
 create mode 100644 drivers/atmodem/sim-auth.c

diff --git a/Makefile.am b/Makefile.am
index 10892a6..9c8083b 100644
--- a/Makefile.am
+++ b/Makefile.am
@@ -169,7 +169,8 @@ builtin_sources += $(gatchat_sources) \
 				drivers/atmodem/atutil.h \
 				drivers/atmodem/atutil.c \
 				drivers/atmodem/gprs.c \
-				drivers/atmodem/gprs-context.c
+				drivers/atmodem/gprs-context.c \
+				drivers/atmodem/sim-auth.c
 
 builtin_modules += nwmodem
 builtin_sources += drivers/atmodem/atutil.h \
diff --git a/drivers/atmodem/atmodem.c b/drivers/atmodem/atmodem.c
index c88f6b2..e140281 100644
--- a/drivers/atmodem/atmodem.c
+++ b/drivers/atmodem/atmodem.c
@@ -51,12 +51,14 @@ static int atmodem_init(void)
 	at_call_volume_init();
 	at_gprs_init();
 	at_gprs_context_init();
+	at_sim_auth_init();
 
 	return 0;
 }
 
 static void atmodem_exit(void)
 {
+	at_sim_auth_exit();
 	at_stk_exit();
 	at_sim_exit();
 	at_sms_exit();
diff --git a/drivers/atmodem/atmodem.h b/drivers/atmodem/atmodem.h
index c7f0eed..1b7cf67 100644
--- a/drivers/atmodem/atmodem.h
+++ b/drivers/atmodem/atmodem.h
@@ -71,3 +71,6 @@ extern void at_gprs_exit(void);
 
 extern void at_gprs_context_init(void);
 extern void at_gprs_context_exit(void);
+
+extern void at_sim_auth_init(void);
+extern void at_sim_auth_exit(void);
diff --git a/drivers/atmodem/sim-auth.c b/drivers/atmodem/sim-auth.c
new file mode 100644
index 0000000..6e255d6
--- /dev/null
+++ b/drivers/atmodem/sim-auth.c
@@ -0,0 +1,162 @@
+/*
+ *
+ *  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 <glib.h>
+
+#include <ofono/modem.h>
+#include <ofono/sim-auth.h>
+
+#include "gatchat.h"
+#include "gatresult.h"
+#include "simutil.h"
+#include "vendor.h"
+
+#include "atmodem.h"
+
+struct sim_auth_data {
+	GAtChat *chat;
+	unsigned int vendor;
+};
+
+static const char *cuad_prefix[] = { "+CUAD:", 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 (cbd && 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 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);
+
+	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,
+};
+
+void at_sim_auth_init(void)
+{
+	ofono_sim_auth_driver_register(&driver);
+}
+
+void at_sim_auth_exit(void)
+{
+	ofono_sim_auth_driver_unregister(&driver);
+}
-- 
1.7.1.86.g0e460.dirty


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

* RE: [PATCH 4/4] atmodem: sim-auth atom driver.
  2011-01-19  8:07 ` [PATCH 4/4] atmodem: sim-auth atom driver Andrzej Zaborowski
@ 2011-01-20 16:21   ` Jeevaka.Badrappan
  2011-01-20 17:30     ` Denis Kenzior
  2011-01-20 17:25   ` Denis Kenzior
  1 sibling, 1 reply; 16+ messages in thread
From: Jeevaka.Badrappan @ 2011-01-20 16:21 UTC (permalink / raw)
  To: ofono

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

Hi Andrzej,

ofono-bounces(a)ofono.org wrote:
> +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;
> +	}

missing check for buffer memory allocation failure 

> +
> +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;

missing check for "sad" memory allocation failure 

Regards,
Jeevaka

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

* Re: [PATCH 1/4] Remove initialisers for enum ofono_atom_type.
  2011-01-19  8:07 [PATCH 1/4] Remove initialisers for enum ofono_atom_type Andrzej Zaborowski
                   ` (4 preceding siblings ...)
  2011-01-19  8:07 ` [PATCH 4/4] atmodem: sim-auth atom driver Andrzej Zaborowski
@ 2011-01-20 17:23 ` Denis Kenzior
  5 siblings, 0 replies; 16+ messages in thread
From: Denis Kenzior @ 2011-01-20 17:23 UTC (permalink / raw)
  To: ofono

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

Hi Andrew,

On 01/19/2011 02:07 AM, Andrzej Zaborowski wrote:
> They have no effect, enum already ensures the values are unique.
> ---
>  src/ofono.h |   48 ++++++++++++++++++++++++------------------------
>  1 files changed, 24 insertions(+), 24 deletions(-)
> 

Patch has been applied, thanks.

Regards,
-Denis

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

* Re: [PATCH 1/2] simutil: SIM applications directory decoding utils.
  2011-01-19  8:07 ` [PATCH 1/2] simutil: SIM applications directory decoding utils Andrzej Zaborowski
@ 2011-01-20 17:24   ` Denis Kenzior
  0 siblings, 0 replies; 16+ messages in thread
From: Denis Kenzior @ 2011-01-20 17:24 UTC (permalink / raw)
  To: ofono

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

Hi Andrew,

On 01/19/2011 02:07 AM, Andrzej Zaborowski wrote:
> ---
>  src/simutil.c |   57 +++++++++++++++++++++++++++++++++++++++++++++++++++++++++
>  src/simutil.h |    8 ++++++++
>  2 files changed, 65 insertions(+), 0 deletions(-)
> 

Patch has been applied with one minor amend on my part:

> +struct ofono_sim_app_record {
> +	unsigned char aid[16];
> +	int aid_len;
> +	char *label;
> +};
> +

The struct name was changed to sim_app_record since it is not part of
the ofono public / private API.

Regards,
-Denis

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

* Re: [PATCH 2/2] unit: Add a test for applications directory decoding utility.
  2011-01-19  8:07 ` [PATCH 2/2] unit: Add a test for applications directory decoding utility Andrzej Zaborowski
@ 2011-01-20 17:24   ` Denis Kenzior
  0 siblings, 0 replies; 16+ messages in thread
From: Denis Kenzior @ 2011-01-20 17:24 UTC (permalink / raw)
  To: ofono

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

Hi Andrew,

On 01/19/2011 02:07 AM, Andrzej Zaborowski wrote:
> ---
>  unit/test-simutil.c |   32 ++++++++++++++++++++++++++++++++
>  1 files changed, 32 insertions(+), 0 deletions(-)
> 

Patch has been applied, thanks.

Regards,
-Denis

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

* Re: [PATCH 2/4] Add SIM authentication atom's driver definitions.
  2011-01-19  8:07 ` [PATCH 2/4] Add SIM authentication atom's driver definitions Andrzej Zaborowski
@ 2011-01-20 17:24   ` Denis Kenzior
  0 siblings, 0 replies; 16+ messages in thread
From: Denis Kenzior @ 2011-01-20 17:24 UTC (permalink / raw)
  To: ofono

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

Hi Andrew,

On 01/19/2011 02:07 AM, Andrzej Zaborowski wrote:
> Structures and function declarations for the SIM authentication
> atom as proposed by Pekka Pessi, with just one method at the
> moment.
> ---
>  Makefile.am        |    2 +-
>  include/sim-auth.h |   64 ++++++++++++++++++++++++++++++++++++++++++++++++++++
>  2 files changed, 65 insertions(+), 1 deletions(-)
>  create mode 100644 include/sim-auth.h
> 

Patch has been applied, thanks.

Regards,
-Denis

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

* Re: [PATCH 3/4] Add the sim-auth atom.
  2011-01-19  8:07 ` [PATCH 3/4] Add the sim-auth atom Andrzej Zaborowski
@ 2011-01-20 17:25   ` Denis Kenzior
  0 siblings, 0 replies; 16+ messages in thread
From: Denis Kenzior @ 2011-01-20 17:25 UTC (permalink / raw)
  To: ofono

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

Hi Andrew,

On 01/19/2011 02:07 AM, Andrzej Zaborowski wrote:
> Add dummy SIM authentication atom.
> ---
>  Makefile.am    |    2 +-
>  src/ofono.h    |    2 +
>  src/sim-auth.c |  134 ++++++++++++++++++++++++++++++++++++++++++++++++++++++++
>  3 files changed, 137 insertions(+), 1 deletions(-)
>  create mode 100644 src/sim-auth.c
> 

Patch has been applied, thanks.

Regards,
-Denis

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

* Re: [PATCH 4/4] atmodem: sim-auth atom driver.
  2011-01-19  8:07 ` [PATCH 4/4] atmodem: sim-auth atom driver Andrzej Zaborowski
  2011-01-20 16:21   ` Jeevaka.Badrappan
@ 2011-01-20 17:25   ` Denis Kenzior
  1 sibling, 0 replies; 16+ messages in thread
From: Denis Kenzior @ 2011-01-20 17:25 UTC (permalink / raw)
  To: ofono

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

Hi Andrew,

On 01/19/2011 02:07 AM, Andrzej Zaborowski wrote:
> ---
>  Makefile.am                |    3 +-
>  drivers/atmodem/atmodem.c  |    2 +
>  drivers/atmodem/atmodem.h  |    3 +
>  drivers/atmodem/sim-auth.c |  162 ++++++++++++++++++++++++++++++++++++++++++++
>  4 files changed, 169 insertions(+), 1 deletions(-)
>  create mode 100644 drivers/atmodem/sim-auth.c
> 

Patch has been applied, thanks.

Regards,
-Denis

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

* Re: [PATCH 4/4] atmodem: sim-auth atom driver.
  2011-01-20 16:21   ` Jeevaka.Badrappan
@ 2011-01-20 17:30     ` Denis Kenzior
  2011-01-21 17:07       ` Pekka Pessi
  0 siblings, 1 reply; 16+ messages in thread
From: Denis Kenzior @ 2011-01-20 17:30 UTC (permalink / raw)
  To: ofono

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

Hi Jeevaka,

>> +	buffer = g_malloc(len);
> 
> missing check for buffer memory allocation failure 
> 

Actually he's using g_malloc, so the application will simply abort.

>> +	sad = g_new0(struct sim_auth_data, 1);
> 
> missing check for "sad" memory allocation failure 

Same here.

My view is that checking mallocs of small structures is pretty much
pointless on Linux.

Regards,
-Denis

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

* Re: [PATCH 4/4] atmodem: sim-auth atom driver.
  2011-01-20 17:30     ` Denis Kenzior
@ 2011-01-21 17:07       ` Pekka Pessi
  2011-01-21 17:25         ` Denis Kenzior
  0 siblings, 1 reply; 16+ messages in thread
From: Pekka Pessi @ 2011-01-21 17:07 UTC (permalink / raw)
  To: ofono

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

Hi Denis,

2011/1/20 Denis Kenzior <denkenz@gmail.com>:
> My view is that checking mallocs of small structures is pretty much
> pointless on Linux.


The glib functions that ofono uses extensively don't do any malloc
checking, and it makes checking on the  ofono side bit pointless. If
malloc fails, ofono will crash. If it has not get killed by oom
police.

-- 
Pekka.Pessi mail at nokia.com

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

* Re: [PATCH 4/4] atmodem: sim-auth atom driver.
  2011-01-21 17:07       ` Pekka Pessi
@ 2011-01-21 17:25         ` Denis Kenzior
  0 siblings, 0 replies; 16+ messages in thread
From: Denis Kenzior @ 2011-01-21 17:25 UTC (permalink / raw)
  To: ofono

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

Hi Pekka,

On 01/21/2011 11:07 AM, Pekka Pessi wrote:
> Hi Denis,
> 
> 2011/1/20 Denis Kenzior <denkenz@gmail.com>:
>> My view is that checking mallocs of small structures is pretty much
>> pointless on Linux.
> 
> 
> The glib functions that ofono uses extensively don't do any malloc
> checking, and it makes checking on the  ofono side bit pointless. If
> malloc fails, ofono will crash. If it has not get killed by oom
> police.
> 

Well the g_try_ series do allow you to recover from a bad malloc, which
is what we generally use.

Regards,
-Denis

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

end of thread, other threads:[~2011-01-21 17:25 UTC | newest]

Thread overview: 16+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2011-01-19  8:07 [PATCH 1/4] Remove initialisers for enum ofono_atom_type Andrzej Zaborowski
2011-01-19  8:07 ` [PATCH 1/2] simutil: SIM applications directory decoding utils Andrzej Zaborowski
2011-01-20 17:24   ` Denis Kenzior
2011-01-19  8:07 ` [PATCH 2/2] unit: Add a test for applications directory decoding utility Andrzej Zaborowski
2011-01-20 17:24   ` Denis Kenzior
2011-01-19  8:07 ` [PATCH 2/4] Add SIM authentication atom's driver definitions Andrzej Zaborowski
2011-01-20 17:24   ` Denis Kenzior
2011-01-19  8:07 ` [PATCH 3/4] Add the sim-auth atom Andrzej Zaborowski
2011-01-20 17:25   ` Denis Kenzior
2011-01-19  8:07 ` [PATCH 4/4] atmodem: sim-auth atom driver Andrzej Zaborowski
2011-01-20 16:21   ` Jeevaka.Badrappan
2011-01-20 17:30     ` Denis Kenzior
2011-01-21 17:07       ` Pekka Pessi
2011-01-21 17:25         ` Denis Kenzior
2011-01-20 17:25   ` Denis Kenzior
2011-01-20 17:23 ` [PATCH 1/4] Remove initialisers for enum ofono_atom_type 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.