From: Yang Gu <gyagp0@gmail.com>
To: ofono@ofono.org
Subject: [PATCH 5/8] stk: Fix the parser of send sms
Date: Wed, 26 May 2010 22:39:11 +0800 [thread overview]
Message-ID: <1274884754-12977-5-git-send-email-yang.gu@intel.com> (raw)
In-Reply-To: <1274884754-12977-1-git-send-email-yang.gu@intel.com>
[-- Attachment #1: Type: text/plain, Size: 2834 bytes --]
---
src/stkutil.c | 52 +++++++++++++++++++++++++++++++++++++++++++---------
1 files changed, 43 insertions(+), 9 deletions(-)
diff --git a/src/stkutil.c b/src/stkutil.c
index 12af7fc..3adb9e3 100644
--- a/src/stkutil.c
+++ b/src/stkutil.c
@@ -61,11 +61,15 @@ typedef gboolean (*dataobj_writer)(struct stk_tlv_builder *,
/*
* Defined in TS 102.223 Section 8.13
- * GSM SMS PDUs are limited to 164 bytes according to 23.040
+ * The type of gsm sms can be SMS-COMMAND AND SMS-SUBMIT. According to 23.040,
+ * the maximum length is 164 bytes. But for SMS-SUBMIT, sms may be packed by
+ * ME. Thus the maximum length of messsage could be 160 bytes, instead of 140
+ * bytes. So the total maximum length could be 184 bytes. Refer TS 31.111,
+ * section 6.4.10 for details.
*/
struct gsm_sms_tpdu {
unsigned int len;
- unsigned char tpdu[164];
+ unsigned char tpdu[184];
};
static char *decode_text(unsigned char dcs, int len, const unsigned char *data)
@@ -2453,6 +2457,7 @@ static gboolean parse_send_sms(struct stk_command *command,
if (command->dst != STK_DEVICE_IDENTITY_TYPE_NETWORK)
return FALSE;
+ memset(&gsm_tpdu, 0, sizeof(gsm_tpdu));
ret = parse_dataobj(iter, STK_DATA_OBJECT_TYPE_ALPHA_ID, 0,
&obj->alpha_id,
STK_DATA_OBJECT_TYPE_ADDRESS, 0,
@@ -2469,20 +2474,49 @@ static gboolean parse_send_sms(struct stk_command *command,
&obj->frame_id,
STK_DATA_OBJECT_TYPE_INVALID);
+ command->destructor = destroy_send_sms;
+
if (ret == FALSE)
return FALSE;
- command->destructor = destroy_send_sms;
+ if (gsm_tpdu.len == 0 && obj->cdma_sms.len == 0)
+ return FALSE;
+
+ if (gsm_tpdu.len > 0 && obj->cdma_sms.len > 0)
+ return FALSE;
if (gsm_tpdu.len > 0) {
if (sms_decode(gsm_tpdu.tpdu, gsm_tpdu.len, TRUE, gsm_tpdu.len,
- &obj->gsm_sms) == FALSE) {
- command->destructor(command);
- return FALSE;
+ &obj->gsm_sms) == FALSE) {
+ /* packing by ME must be not required */
+ if ((command->qualifier & 0x01) == 0)
+ return FALSE;
+
+ if (obj->gsm_sms.type != SMS_TYPE_SUBMIT)
+ return FALSE;
+
+ if (obj->gsm_sms.submit.udl == 0)
+ return FALSE;
+ }
+
+ /* packing is needed */
+ if (command->qualifier & 0x01) {
+ unsigned char *packed;
+ long packed_size;
+ unsigned char *in;
+ struct sms_submit *s = &obj->gsm_sms.submit;
+
+ if (obj->gsm_sms.type != SMS_TYPE_SUBMIT)
+ return FALSE;
+
+ /* Set dcs to default alphabet */
+ s->dcs = 0xF0;
+
+ in = gsm_tpdu.tpdu + gsm_tpdu.len - s->udl;
+ packed = pack_7bit(in, s->udl, 0,
+ FALSE, &packed_size, 0);
+ memcpy(s->ud, packed, packed_size);
}
- } else if (obj->cdma_sms.len == 0) {
- command->destructor(command);
- return FALSE;
}
return TRUE;
--
1.7.0.4
next prev parent reply other threads:[~2010-05-26 14:39 UTC|newest]
Thread overview: 9+ messages / expand[flat|nested] mbox.gz Atom feed top
2010-05-26 14:39 [PATCH 1/8] stk: Make parse_dataobj not consume extra data Yang Gu
2010-05-26 14:39 ` [PATCH 2/8] stk: Add parser for launch browser commands Yang Gu
2010-05-26 14:39 ` [PATCH 3/8] teststk: Add check of len in byte array Yang Gu
2010-05-26 14:39 ` [PATCH 4/8] teststk: Use check_common_text() to check string Yang Gu
2010-05-26 14:39 ` Yang Gu [this message]
2010-05-26 14:39 ` [PATCH 6/8] teststk: Add cases for send sms parser Yang Gu
2010-05-26 14:39 ` [PATCH 7/8] teststk: Add test for launch browser parser Yang Gu
2010-05-26 14:39 ` [PATCH 8/8] Move destructor prior to return Yang Gu
2010-05-27 17:48 ` [PATCH 1/8] stk: Make parse_dataobj not consume extra data 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=1274884754-12977-5-git-send-email-yang.gu@intel.com \
--to=gyagp0@gmail.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.