Open Source Telephony
 help / color / mirror / Atom feed
From: Yang Gu <yang.gu@intel.com>
To: ofono@ofono.org
Subject: [PATCH 01/12] stk: Add parser for send ss commands
Date: Sun, 13 Jun 2010 17:43:11 +0800	[thread overview]
Message-ID: <1276422202-16240-1-git-send-email-yang.gu@intel.com> (raw)

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

---
 src/stkutil.c |   70 +++++++++++++++++++++++++++++++++++++++++++++++++++++++++
 src/stkutil.h |   15 ++++++++++++
 2 files changed, 85 insertions(+), 0 deletions(-)

diff --git a/src/stkutil.c b/src/stkutil.c
index 8ac1dba..642e141 100644
--- a/src/stkutil.c
+++ b/src/stkutil.c
@@ -499,6 +499,32 @@ static gboolean parse_dataobj_gsm_sms_tpdu(struct comprehension_tlv_iter *iter,
 	return TRUE;
 }
 
+/* Defined in TS 102.223 Section 8.14 */
+static gboolean parse_dataobj_ss(struct comprehension_tlv_iter *iter,
+					void *user)
+{
+	struct stk_ss *ss = user;
+	const unsigned char *data;
+	unsigned int len;
+	char *s;
+
+	len = comprehension_tlv_iter_get_length(iter);
+	if (len < 2)
+		return FALSE;
+
+	data = comprehension_tlv_iter_get_data(iter);
+
+	s = g_try_malloc(len * 2 - 1);
+	if (s == NULL)
+		return FALSE;
+
+	ss->ton_npi = data[0];
+	ss->ss = s;
+	sim_extract_bcd_number(data + 1, len - 1, ss->ss);
+
+	return TRUE;
+}
+
 /* Defined in TS 102.223 Section 8.15 */
 static gboolean parse_dataobj_text(struct comprehension_tlv_iter *iter,
 					void *user)
@@ -1864,6 +1890,8 @@ static dataobj_handler handler_for_type(enum stk_data_object_type type)
 		return parse_dataobj_result;
 	case STK_DATA_OBJECT_TYPE_GSM_SMS_TPDU:
 		return parse_dataobj_gsm_sms_tpdu;
+	case STK_DATA_OBJECT_TYPE_SS_STRING:
+		return parse_dataobj_ss;
 	case STK_DATA_OBJECT_TYPE_TEXT:
 		return parse_dataobj_text;
 	case STK_DATA_OBJECT_TYPE_TONE:
@@ -2537,6 +2565,45 @@ static gboolean parse_send_sms(struct stk_command *command,
 	return TRUE;
 }
 
+static void destroy_send_ss(struct stk_command *command)
+{
+	g_free(command->send_ss.alpha_id);
+	g_free(command->send_ss.ss.ss);
+}
+
+static gboolean parse_send_ss(struct stk_command *command,
+					struct comprehension_tlv_iter *iter)
+{
+	struct stk_command_send_ss *obj = &command->send_ss;
+	gboolean ret;
+
+	if (command->src != STK_DEVICE_IDENTITY_TYPE_UICC)
+		return FALSE;
+
+	if (command->dst != STK_DEVICE_IDENTITY_TYPE_NETWORK)
+		return FALSE;
+
+	ret = parse_dataobj(iter, STK_DATA_OBJECT_TYPE_ALPHA_ID, 0,
+				&obj->alpha_id,
+				STK_DATA_OBJECT_TYPE_SS_STRING,
+				DATAOBJ_FLAG_MANDATORY | DATAOBJ_FLAG_MINIMUM,
+				&obj->ss,
+				STK_DATA_OBJECT_TYPE_ICON_ID, 0,
+				&obj->icon_id,
+				STK_DATA_OBJECT_TYPE_TEXT_ATTRIBUTE, 0,
+				&obj->text_attr,
+				STK_DATA_OBJECT_TYPE_FRAME_ID, 0,
+				&obj->frame_id,
+				STK_DATA_OBJECT_TYPE_INVALID);
+
+	command->destructor = destroy_send_ss;
+
+	if (ret == FALSE)
+		return FALSE;
+
+	return TRUE;
+}
+
 static void destroy_setup_call(struct stk_command *command)
 {
 	g_free(command->setup_call.alpha_id_usr_cfm);
@@ -3062,6 +3129,9 @@ struct stk_command *stk_command_new_from_pdu(const unsigned char *pdu,
 	case STK_COMMAND_TYPE_SEND_SMS:
 		ok = parse_send_sms(command, &iter);
 		break;
+	case STK_COMMAND_TYPE_SEND_SS:
+		ok = parse_send_ss(command, &iter);
+		break;
 	case STK_COMMAND_TYPE_SETUP_CALL:
 		ok = parse_setup_call(command, &iter);
 		break;
diff --git a/src/stkutil.h b/src/stkutil.h
index 2da787d..d73d5e1 100644
--- a/src/stkutil.h
+++ b/src/stkutil.h
@@ -525,6 +525,12 @@ struct stk_result {
 	unsigned char *additional;
 };
 
+/* Defined in TS 102.223 Section 8.14 */
+struct stk_ss {
+	unsigned char ton_npi;
+	char *ss;
+};
+
 /* Define the struct of single file in TS102.223 Section 8.18.
  * According to TS 11.11 Section 6.2, each file id has two bytes, and the
  * maximum Dedicated File level is 2. So the maximum size of file is 8, which
@@ -933,6 +939,14 @@ struct stk_command_send_sms {
 	struct stk_frame_id frame_id;
 };
 
+struct stk_command_send_ss {
+	char *alpha_id;
+	struct stk_ss ss;
+	struct stk_icon_id icon_id;
+	struct stk_text_attribute text_attr;
+	struct stk_frame_id frame_id;
+};
+
 struct stk_command_setup_call {
 	char *alpha_id_usr_cfm;
 	struct stk_address addr;
@@ -1028,6 +1042,7 @@ struct stk_command {
 		struct stk_command_setup_menu setup_menu;
 		struct stk_command_select_item select_item;
 		struct stk_command_send_sms send_sms;
+		struct stk_command_send_ss send_ss;
 		struct stk_command_setup_call setup_call;
 		struct stk_command_setup_event_list setup_event_list;
 		struct stk_command_perform_card_apdu perform_card_apdu;
-- 
1.7.0.4


             reply	other threads:[~2010-06-13  9:43 UTC|newest]

Thread overview: 23+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2010-06-13  9:43 Yang Gu [this message]
2010-06-13  9:43 ` [PATCH 02/12] teststk: Add test for send ss parser Yang Gu
2010-06-13  9:43 ` [PATCH 03/12] stk: Add parser for send ussd commands Yang Gu
2010-06-16 22:44   ` Denis Kenzior
2010-06-13  9:43 ` [PATCH 04/12] teststk: Add test for send ussd parser Yang Gu
2010-06-13  9:43 ` [PATCH 05/12] Modify " Yang Gu
2010-06-16 22:48   ` Denis Kenzior
2010-06-17 10:33     ` Gu, Yang
2010-06-17  9:35       ` Denis Kenzior
2010-06-13  9:43 ` [PATCH 06/12] Refactor " Yang Gu
2010-06-16 22:49   ` Denis Kenzior
2010-06-21 14:09     ` Aki Niemi
2010-06-21 14:08   ` Aki Niemi
2010-06-13  9:43 ` [PATCH 07/12] Add several proactive command parsers Yang Gu
2010-06-13  9:43 ` [PATCH 08/12] stk: Add parser for cell broadcast page objects Yang Gu
2010-06-13  9:43 ` [PATCH 09/12] stk: Add parser for bcch channel list objects Yang Gu
2010-06-13  9:43 ` [PATCH 10/12] stk: Add parser for timing advance objects Yang Gu
2010-06-16 22:50   ` Denis Kenzior
2010-06-16 23:19   ` andrzej zaborowski
2010-06-17  1:44     ` Gu, Yang
2010-06-13  9:43 ` [PATCH 11/12] stk: Add parser for PDP activation param objects Yang Gu
2010-06-13  9:43 ` [PATCH 12/12] stk: Add parser for UTRAN meas qualifier objects Yang Gu
2010-06-16 22:42 ` [PATCH 01/12] stk: Add parser for send ss commands 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=1276422202-16240-1-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 a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox