mirror of git://git.sysmocom.de/ofono
Refactor: Break out semi-octet decoder
Refactor decode_scts to use this function
This commit is contained in:
parent
8bad7e540a
commit
8bc04ba93a
|
@ -372,6 +372,11 @@ static gboolean encode_scts(const struct sms_scts *in, unsigned char *pdu,
|
||||||
return TRUE;
|
return TRUE;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
guint8 sms_decode_semi_octet(guint8 in)
|
||||||
|
{
|
||||||
|
return (in & 0x0f) * 10 + (in >> 4);
|
||||||
|
}
|
||||||
|
|
||||||
static gboolean decode_scts(const unsigned char *pdu, int len,
|
static gboolean decode_scts(const unsigned char *pdu, int len,
|
||||||
int *offset, struct sms_scts *out)
|
int *offset, struct sms_scts *out)
|
||||||
{
|
{
|
||||||
|
@ -381,22 +386,22 @@ static gboolean decode_scts(const unsigned char *pdu, int len,
|
||||||
return FALSE;
|
return FALSE;
|
||||||
|
|
||||||
next_octet(pdu, len, offset, &oct);
|
next_octet(pdu, len, offset, &oct);
|
||||||
out->year = (oct & 0x0f) * 10 + ((oct & 0xf0) >> 4);
|
out->year = sms_decode_semi_octet(oct);
|
||||||
|
|
||||||
next_octet(pdu, len, offset, &oct);
|
next_octet(pdu, len, offset, &oct);
|
||||||
out->month = (oct & 0x0f) * 10 + ((oct & 0xf0) >> 4);
|
out->month = sms_decode_semi_octet(oct);
|
||||||
|
|
||||||
next_octet(pdu, len, offset, &oct);
|
next_octet(pdu, len, offset, &oct);
|
||||||
out->day = (oct & 0x0f) * 10 + ((oct & 0xf0) >> 4);
|
out->day = sms_decode_semi_octet(oct);
|
||||||
|
|
||||||
next_octet(pdu, len, offset, &oct);
|
next_octet(pdu, len, offset, &oct);
|
||||||
out->hour = (oct & 0x0f) * 10 + ((oct & 0xf0) >> 4);
|
out->hour = sms_decode_semi_octet(oct);
|
||||||
|
|
||||||
next_octet(pdu, len, offset, &oct);
|
next_octet(pdu, len, offset, &oct);
|
||||||
out->minute = (oct & 0x0f) * 10 + ((oct & 0xf0) >> 4);
|
out->minute = sms_decode_semi_octet(oct);
|
||||||
|
|
||||||
next_octet(pdu, len, offset, &oct);
|
next_octet(pdu, len, offset, &oct);
|
||||||
out->second = (oct & 0x0f) * 10 + ((oct & 0xf0) >> 4);
|
out->second = sms_decode_semi_octet(oct);
|
||||||
|
|
||||||
next_octet(pdu, len, offset, &oct);
|
next_octet(pdu, len, offset, &oct);
|
||||||
|
|
||||||
|
|
|
@ -422,6 +422,8 @@ gboolean sms_decode_address_field(const unsigned char *pdu, int len,
|
||||||
gboolean sms_encode_address_field(const struct sms_address *in, gboolean sc,
|
gboolean sms_encode_address_field(const struct sms_address *in, gboolean sc,
|
||||||
unsigned char *pdu, int *offset);
|
unsigned char *pdu, int *offset);
|
||||||
|
|
||||||
|
guint8 sms_decode_semi_octet(guint8 in);
|
||||||
|
|
||||||
int sms_udl_in_bytes(guint8 ud_len, guint8 dcs);
|
int sms_udl_in_bytes(guint8 ud_len, guint8 dcs);
|
||||||
|
|
||||||
time_t sms_scts_to_time(const struct sms_scts *scts, struct tm *remote);
|
time_t sms_scts_to_time(const struct sms_scts *scts, struct tm *remote);
|
||||||
|
|
Loading…
Reference in New Issue