stkutil: Refactor SMS pdu parser

This commit is contained in:
Denis Kenzior 2010-05-27 09:26:45 -05:00
parent 9bb7bcd450
commit e7570ef1d5
1 changed files with 13 additions and 30 deletions

View File

@ -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;
/* 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);
if (obj->gsm_sms.submit.udl == 0)
return FALSE;
}
if (sms_decode(gsm_tpdu.tpdu, gsm_tpdu.len, TRUE,
gsm_tpdu.len, &obj->gsm_sms) == FALSE)
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);
}
}
if (obj->gsm_sms.type != SMS_TYPE_SUBMIT &&
obj->gsm_sms.type != SMS_TYPE_COMMAND)
return FALSE;
return TRUE;
}