Open Source Telephony
 help / color / mirror / Atom feed
From: Yang Gu <yang.gu@intel.com>
To: ofono@ofono.org
Subject: [PATCH 1/5] stk: Add parser for send ussd commands
Date: Thu, 17 Jun 2010 18:35:07 +0800	[thread overview]
Message-ID: <1276770911-8817-1-git-send-email-yang.gu@intel.com> (raw)

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

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

diff --git a/src/stkutil.c b/src/stkutil.c
index 44a8eff..f03b25c 100644
--- a/src/stkutil.c
+++ b/src/stkutil.c
@@ -585,6 +585,24 @@ static gboolean parse_dataobj_tone(struct comprehension_tlv_iter *iter,
 	return parse_dataobj_common_byte(iter, byte);
 }
 
+/* Defined in TS 102.223 Section 8.17 */
+static gboolean parse_dataobj_ussd(struct comprehension_tlv_iter *iter,
+					void *user)
+{
+	struct stk_ussd_string *us = user;
+	unsigned int len = comprehension_tlv_iter_get_length(iter);
+	const unsigned char *data = comprehension_tlv_iter_get_data(iter);
+
+	if (len <= 1)
+		return FALSE;
+
+	us->dcs = data[0];
+	us->len = len - 1;
+	memcpy(us->string, data + 1, us->len);
+
+	return TRUE;
+}
+
 /* Defined in TS 102.223 Section 8.18 */
 static gboolean parse_dataobj_file_list(struct comprehension_tlv_iter *iter,
 					void *user)
@@ -1996,6 +2014,8 @@ static dataobj_handler handler_for_type(enum stk_data_object_type type)
 		return parse_dataobj_text;
 	case STK_DATA_OBJECT_TYPE_TONE:
 		return parse_dataobj_tone;
+	case STK_DATA_OBJECT_TYPE_USSD_STRING:
+		return parse_dataobj_ussd;
 	case STK_DATA_OBJECT_TYPE_FILE_LIST:
 		return parse_dataobj_file_list;
 	case STK_DATA_OBJECT_TYPE_LOCATION_INFO:
@@ -2710,6 +2730,44 @@ static gboolean parse_send_ss(struct stk_command *command,
 	return TRUE;
 }
 
+static void destroy_send_ussd(struct stk_command *command)
+{
+	g_free(command->send_ussd.alpha_id);
+}
+
+static gboolean parse_send_ussd(struct stk_command *command,
+					struct comprehension_tlv_iter *iter)
+{
+	struct stk_command_send_ussd *obj = &command->send_ussd;
+	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_USSD_STRING,
+				DATAOBJ_FLAG_MANDATORY | DATAOBJ_FLAG_MINIMUM,
+				&obj->ussd_string,
+				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_ussd;
+
+	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);
@@ -3672,6 +3730,9 @@ struct stk_command *stk_command_new_from_pdu(const unsigned char *pdu,
 	case STK_COMMAND_TYPE_SEND_SS:
 		ok = parse_send_ss(command, &iter);
 		break;
+	case STK_COMMAND_TYPE_SEND_USSD:
+		ok = parse_send_ussd(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 471e10f..6fb49e0 100644
--- a/src/stkutil.h
+++ b/src/stkutil.h
@@ -1117,6 +1117,14 @@ struct stk_command_send_ss {
 	struct stk_frame_id frame_id;
 };
 
+struct stk_command_send_ussd {
+	char *alpha_id;
+	struct stk_ussd_string ussd_string;
+	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;
@@ -1295,6 +1303,7 @@ struct stk_command {
 		struct stk_command_select_item select_item;
 		struct stk_command_send_sms send_sms;
 		struct stk_command_send_ss send_ss;
+		struct stk_command_send_ussd send_ussd;
 		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-17 10:35 UTC|newest]

Thread overview: 9+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2010-06-17 10:35 Yang Gu [this message]
2010-06-17 10:35 ` [PATCH 2/5] teststk: Add test for send ussd parser Yang Gu
2010-06-17 10:35 ` [PATCH 3/5] Modify " Yang Gu
2010-06-17 10:35 ` [PATCH 4/5] Refactor " Yang Gu
2010-06-21 14:18   ` Denis Kenzior
2010-06-17 10:35 ` [PATCH 5/5] stk: Add parser for timing advance objects Yang Gu
2010-06-18 19:04 ` [PATCH 1/5] stk: Add parser for send ussd commands Denis Kenzior
2010-06-20 13:52   ` Gu, Yang
2010-06-20 16:26     ` 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=1276770911-8817-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