From: Yang Gu <yang.gu@intel.com>
To: ofono@ofono.org
Subject: [PATCH 03/15] Add parser for c-apdu objects
Date: Fri, 02 Apr 2010 14:20:28 +0800 [thread overview]
Message-ID: <1270189240-11650-3-git-send-email-yang.gu@intel.com> (raw)
In-Reply-To: <1270189240-11650-2-git-send-email-yang.gu@intel.com>
[-- Attachment #1: Type: text/plain, Size: 2702 bytes --]
---
src/stkutil.c | 44 ++++++++++++++++++++++++++++++++++++++++++++
src/stkutil.h | 15 +++++++++++++++
2 files changed, 59 insertions(+), 0 deletions(-)
diff --git a/src/stkutil.c b/src/stkutil.c
index a96132c..99e6622 100644
--- a/src/stkutil.c
+++ b/src/stkutil.c
@@ -789,6 +789,48 @@ static gboolean parse_dataobj_card_atr(
return TRUE;
}
+/* Defined in TS 102.223 Section 8.35 */
+static gboolean parse_dataobj_c_apdu(
+ struct comprehension_tlv_iter *iter, void *user)
+{
+ struct stk_c_apdu *ca = user;
+ const unsigned char *data;
+ unsigned int len = comprehension_tlv_iter_get_length(iter);
+
+ if ((len < 4) || (len > 241))
+ return FALSE;
+
+ data = comprehension_tlv_iter_get_data(iter);
+ ca->cla = data[0];
+ ca->ins = data[1];
+ ca->p1 = data[2];
+ ca->p2 = data[3];
+
+ /* lc is 0 has the same meaning as lc is absent. But le is 0 means
+ * the maximum number of bytes expected in the response data field
+ * is 256. So we need to rely on has_le to know if it presents.
+ */
+ if (len > 5) {
+ ca->lc = data[4];
+ if (ca->lc > sizeof(ca->data))
+ return FALSE;
+
+ memcpy(ca->data, data+5, ca->lc);
+
+ if ((len - ca->lc) == 6) {
+ ca->le = data[len-1];
+ ca->has_le = TRUE;
+ } else if (len - ca->lc != 5)
+ return FALSE;
+ } else if (len == 5) {
+ ca->lc = 0;
+ ca->le = data[4];
+ ca->has_le = TRUE;
+ }
+
+ return TRUE;
+}
+
/* Defined in 102.223 Section 8.43 */
static gboolean parse_dataobj_imm_resp(struct comprehension_tlv_iter *iter,
void *user)
@@ -897,6 +939,8 @@ static dataobj_handler handler_for_type(enum stk_data_object_type type)
return parse_dataobj_card_reader_status;
case STK_DATA_OBJECT_TYPE_CARD_ATR:
return parse_dataobj_card_atr;
+ case STK_DATA_OBJECT_TYPE_C_APDU:
+ return parse_dataobj_c_apdu;
case STK_DATA_OBJECT_TYPE_IMMEDIATE_RESPONSE:
return parse_dataobj_imm_resp;
case STK_DATA_OBJECT_TYPE_TEXT_ATTRIBUTE:
diff --git a/src/stkutil.h b/src/stkutil.h
index 8047ed1..c6bd4e1 100644
--- a/src/stkutil.h
+++ b/src/stkutil.h
@@ -469,6 +469,21 @@ struct stk_card_atr {
};
/*
+ * Defined in TS 102.223 Section 8.35. According to it, the maximum size
+ * of data is 236.
+ */
+struct stk_c_apdu {
+ unsigned char cla;
+ unsigned char ins;
+ unsigned char p1;
+ unsigned char p2;
+ unsigned char lc;
+ unsigned char data[236];
+ ofono_bool_t has_le;
+ unsigned char le;
+};
+
+/*
* According to 102.223 Section 8.72 the length of text attribute CTLV is 1
* byte. This means that the maximum size is 127 according to the rules
* of CTLVs. Empty attribute options will have len of 0.
--
1.6.3.3
next prev parent reply other threads:[~2010-04-02 6:20 UTC|newest]
Thread overview: 16+ messages / expand[flat|nested] mbox.gz Atom feed top
2010-04-02 6:20 [PATCH 01/15] Add parser for card reader status objects Yang Gu
2010-04-02 6:20 ` [PATCH 02/15] Add parser for card atr objects Yang Gu
2010-04-02 6:20 ` Yang Gu [this message]
2010-04-02 6:20 ` [PATCH 04/15] Add parser for r-apdu objects Yang Gu
2010-04-02 6:20 ` [PATCH 05/15] Add parser for timer identifier objects Yang Gu
2010-04-02 6:20 ` [PATCH 06/15] Refactor function decode_scts to use semi octet decoder Yang Gu
2010-04-02 6:20 ` [PATCH 07/15] Add parser for timer value objects Yang Gu
2010-04-02 6:20 ` [PATCH 08/15] Make function decode_scts public Yang Gu
2010-04-02 6:20 ` [PATCH 09/15] Add parser for date-time and time zone objects Yang Gu
2010-04-02 6:20 ` [PATCH 10/15] Add parser for at command objects Yang Gu
2010-04-02 6:20 ` [PATCH 11/15] Add parser for at response objects Yang Gu
2010-04-02 6:20 ` [PATCH 12/15] Add parser for bc repeat indicator objects Yang Gu
2010-04-02 6:20 ` [PATCH 13/15] Add parser for dtmf string objects Yang Gu
2010-04-02 6:20 ` [PATCH 14/15] Add parser for language objects Yang Gu
2010-04-02 6:20 ` [PATCH 15/15] Add parser for browser identity objects Yang Gu
2010-04-02 16:29 ` [PATCH 01/15] Add parser for card reader status objects 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=1270189240-11650-3-git-send-email-yang.gu@intel.com \
--to=yang.gu@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 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.