From: Andrzej Zaborowski <andrew.zaborowski@intel.com>
To: ofono@ofono.org
Subject: [PATCH 2/5] simutil: SIM applications directory decoding utils.
Date: Mon, 17 Jan 2011 18:38:51 +0100 [thread overview]
Message-ID: <1295285934-9306-2-git-send-email-andrew.zaborowski@intel.com> (raw)
In-Reply-To: <1295285934-9306-1-git-send-email-andrew.zaborowski@intel.com>
[-- Attachment #1: Type: text/plain, Size: 2290 bytes --]
---
src/simutil.c | 57 +++++++++++++++++++++++++++++++++++++++++++++++++++++++++
src/simutil.h | 2 ++
2 files changed, 59 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 ad84907..4418ec9 100644
--- a/src/simutil.h
+++ b/src/simutil.h
@@ -446,3 +446,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
next prev parent reply other threads:[~2011-01-17 17:38 UTC|newest]
Thread overview: 8+ messages / expand[flat|nested] mbox.gz Atom feed top
2011-01-17 17:38 [PATCH 1/5] Add SIM authentication atom's driver definitions Andrzej Zaborowski
2011-01-17 17:38 ` Andrzej Zaborowski [this message]
2011-01-18 19:22 ` [PATCH 2/5] simutil: SIM applications directory decoding utils Denis Kenzior
2011-01-17 17:38 ` [PATCH 3/5] unit: Add a test for applications directory decoding utility Andrzej Zaborowski
2011-01-17 17:38 ` [PATCH 4/5] Add the sim-auth atom Andrzej Zaborowski
2011-01-17 17:38 ` [PATCH 5/5] atmodem: sim-auth atom driver Andrzej Zaborowski
2011-01-18 19:30 ` Denis Kenzior
2011-01-18 19:21 ` [PATCH 1/5] Add SIM authentication atom's driver definitions Denis Kenzior
Reply instructions:
You may reply publicly to this message via plain-text email
using any one of the following methods:
* Save the following mbox file, import it into your mail client,
and reply-to-all from there: mbox
Avoid top-posting and favor interleaved quoting:
https://en.wikipedia.org/wiki/Posting_style#Interleaved_style
* Reply using the --to, --cc, and --in-reply-to
switches of git-send-email(1):
git send-email \
--in-reply-to=1295285934-9306-2-git-send-email-andrew.zaborowski@intel.com \
--to=andrew.zaborowski@intel.com \
--cc=ofono@ofono.org \
/path/to/YOUR_REPLY
https://kernel.org/pub/software/scm/git/docs/git-send-email.html
* If your mail client supports setting the In-Reply-To header
via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line
before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox