[PATCH 02/15] Add parser for card atr objects

Yang Gu yang.gu at intel.com
Thu Apr 1 23:20:27 PDT 2010


---
 src/stkutil.c |   20 ++++++++++++++++++++
 src/stkutil.h |    9 +++++++++
 2 files changed, 29 insertions(+), 0 deletions(-)

diff --git a/src/stkutil.c b/src/stkutil.c
index 5b258ab..a96132c 100644
--- a/src/stkutil.c
+++ b/src/stkutil.c
@@ -771,6 +771,24 @@ static gboolean parse_dataobj_card_reader_status(
 	return parse_dataobj_common_byte(iter, byte);
 }
 
+/* Defined in TS 102.223 Section 8.34 */
+static gboolean parse_dataobj_card_atr(
+		struct comprehension_tlv_iter *iter, void *user)
+{
+	struct stk_card_atr *ca = user;
+	const unsigned char *data;
+	unsigned int len = comprehension_tlv_iter_get_length(iter);
+
+	if ((len < 1) || (len > sizeof(ca->atr)))
+		return FALSE;
+
+	data = comprehension_tlv_iter_get_data(iter);
+	ca->len = len;
+	memcpy(ca->atr, data, len);
+
+	return TRUE;
+}
+
 /* Defined in 102.223 Section 8.43 */
 static gboolean parse_dataobj_imm_resp(struct comprehension_tlv_iter *iter,
 					void *user)
@@ -877,6 +895,8 @@ static dataobj_handler handler_for_type(enum stk_data_object_type type)
 		return parse_dataobj_item_icon_id_list;
 	case STK_DATA_OBJECT_TYPE_CARD_READER_STATUS:
 		return parse_dataobj_card_reader_status;
+	case STK_DATA_OBJECT_TYPE_CARD_ATR:
+		return parse_dataobj_card_atr;
 	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 4ff8c4b..8047ed1 100644
--- a/src/stkutil.h
+++ b/src/stkutil.h
@@ -460,6 +460,15 @@ struct stk_item_icon_id_list {
 };
 
 /*
+ * According to 102.223 Section 8.34 the length of CTLV is 1 byte. This means
+ * that the maximum size is 127 according to the rules of CTLVs.
+ */
+struct stk_card_atr {
+	unsigned char atr[127];
+	unsigned int len;
+};
+
+/*
  * 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



More information about the ofono mailing list