diff options
author | Denis Kenzior <denkenz@gmail.com> | 2010-05-27 09:26:45 -0500 |
---|---|---|
committer | Denis Kenzior <denkenz@gmail.com> | 2010-05-27 09:26:45 -0500 |
commit | e7570ef1d571dd71fd3964af49e99e8efe83eec2 (patch) | |
tree | ab1b104d113171d118b33c5f513ba4f5cc56338e | |
parent | 9bb7bcd450f990f77aa833df6b2ae8762a94adcd (diff) | |
download | ofono-e7570ef1d571dd71fd3964af49e99e8efe83eec2.tar.bz2 |
stkutil: Refactor SMS pdu parser
-rw-r--r-- | src/stkutil.c | 43 |
1 files changed, 13 insertions, 30 deletions
diff --git a/src/stkutil.c b/src/stkutil.c index 1ec54113..9dede5e8 100644 --- a/src/stkutil.c +++ b/src/stkutil.c @@ -2478,39 +2478,22 @@ static gboolean parse_send_sms(struct stk_command *command, 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) { - /* 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; + /* We don't process CDMA pdus for now */ + if (obj->cdma_sms.len > 0) + return TRUE; - if (obj->gsm_sms.type != SMS_TYPE_SUBMIT) - return FALSE; + /* packing is needed */ + if (command->qualifier & 0x01) + return sms_decode_unpacked_stk_pdu(gsm_tpdu.tpdu, gsm_tpdu.len, + &obj->gsm_sms); - /* Set dcs to default alphabet */ - s->dcs = 0xF0; + if (sms_decode(gsm_tpdu.tpdu, gsm_tpdu.len, TRUE, + gsm_tpdu.len, &obj->gsm_sms) == FALSE) + return FALSE; - 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); - } - } + if (obj->gsm_sms.type != SMS_TYPE_SUBMIT && + obj->gsm_sms.type != SMS_TYPE_COMMAND) + return FALSE; return TRUE; } |