summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorBrandon Bayer <bbayer@multitech.com>2016-01-19 16:36:45 -0600
committerBrandon Bayer <bbayer@multitech.com>2016-01-21 12:01:01 -0600
commitbbf6ae9b1790c7129bf249641350b302def3ee27 (patch)
treeac27f7bf6e8d2c75b690713cce4475292ca51de9
parentbf3d2e8a736f43b99a6805e543423d811676518e (diff)
downloadsms-utils-bbf6ae9b1790c7129bf249641350b302def3ee27.tar.gz
sms-utils-bbf6ae9b1790c7129bf249641350b302def3ee27.tar.bz2
sms-utils-bbf6ae9b1790c7129bf249641350b302def3ee27.zip
fix: properly decode LE910-SVG multi-part messages0.0.13
-rw-r--r--configure.in2
-rw-r--r--src/pdu.h1
-rw-r--r--src/pdu_decode.c37
3 files changed, 28 insertions, 12 deletions
diff --git a/configure.in b/configure.in
index 9a58a1e..c804b06 100644
--- a/configure.in
+++ b/configure.in
@@ -1,5 +1,5 @@
AC_INIT([src/sms_main.c])
-AM_INIT_AUTOMAKE([sms-utils], [0.0.11])
+AM_INIT_AUTOMAKE([sms-utils], [0.0.13])
AM_CONFIG_HEADER([config.h])
AC_PROG_CC
diff --git a/src/pdu.h b/src/pdu.h
index 9dfddd4..0143f1f 100644
--- a/src/pdu.h
+++ b/src/pdu.h
@@ -54,6 +54,7 @@ enum {
PDU_ALPHABET_CDMA_DEFAULT = 2, //7-bit
PDU_ALPHABET_EIGHT = 4,
PDU_ALPHABET_CDMA_EIGHT = 8,
+ PDU_ALPHABET_DEFAULT_MULTI = 9,
};
struct pdu_info {
diff --git a/src/pdu_decode.c b/src/pdu_decode.c
index d6ad385..459916c 100644
--- a/src/pdu_decode.c
+++ b/src/pdu_decode.c
@@ -88,9 +88,6 @@ int pdu_decode_cdma_timestamp(const char *pdu_str, struct tm *tm)
{
char buf[PDU_CDMA_TIMESTAMP_LEN + 1];
char *cp;
- int off_upper;
- int off_lower;
- int off;
STRLEN_CHECK(pdu_str, PDU_CDMA_TIMESTAMP_LEN, -1);
@@ -182,6 +179,7 @@ int pdu_decode_user_data(const char *pdu_str, struct pdu_info *pdu, int *nr_octe
const char *begin = pdu_str;
int tmp;
uint8_t octets[PDU_OCTETS_MAX + 1];
+ int user_data_start_index = 0;
int i;
STRLEN_CHECK(pdu_str, HEX_BYTE_LEN, -1);
@@ -207,9 +205,21 @@ int pdu_decode_user_data(const char *pdu_str, struct pdu_info *pdu, int *nr_octe
}
*nr_octets = octet_align(pdu->user_data_len);
+ } else if (pdu->data_coding.general.alphabet == PDU_ALPHABET_DEFAULT_MULTI) {
+ //GSM style 8 bit conversion but with UDH multi-part header (LE910-SVG)
+ log_debug("data coding alphabet is nine");
+
+ if (pdu->user_data_len > PDU_UD_7BIT_MAX) {
+ log_warning("pdu contains invalid user-data-len: 0x%02X",
+ pdu->user_data_len);
+ pdu->user_data_len = PDU_UD_7BIT_MAX;
+ }
+
+ *nr_octets = octet_align(pdu->user_data_len);
} else if (pdu->data_coding.general.alphabet == PDU_ALPHABET_CDMA_DEFAULT) {
- log_debug("data coding alphabet is cdma default");
+ log_debug("data coding alphabet is cdma default");
+ // Encoding 02 is 7 bit for LE910-SVG but 8 bit for other CDMA radios
if (!strcmp(Global.core.model, "LE910-SVG")) {
if (pdu->user_data_len > PDU_UD_7BIT_MAX) {
log_warning("pdu contains invalid user-data-len: 0x%02X", pdu->user_data_len);
@@ -257,11 +267,13 @@ int pdu_decode_user_data(const char *pdu_str, struct pdu_info *pdu, int *nr_octe
pdu_str += HEX_BYTE_LEN;
}
- if (pdu->data_coding.general.alphabet == PDU_ALPHABET_DEFAULT) {
+ if ((pdu->data_coding.general.alphabet == PDU_ALPHABET_DEFAULT) ||
+ (pdu->data_coding.general.alphabet == PDU_ALPHABET_DEFAULT_MULTI)) {
// Keep UDH for concatenated SMS.
// Otherwise it is impossible to process correctly concatenated SMS.
i = 0;
- if (pdu->type.user_data_header) {
+ if (pdu->type.user_data_header ||
+ (pdu->data_coding.general.alphabet == PDU_ALPHABET_DEFAULT_MULTI)) {
for (i = 0; i <= octets[0]; ++i) {
pdu->user_data[i] = octets[i];
}
@@ -272,8 +284,10 @@ int pdu_decode_user_data(const char *pdu_str, struct pdu_info *pdu, int *nr_octe
i++;
}
}
+ user_data_start_index = i;
for (; i < pdu->user_data_len; i++) {
pdu->user_data[i] = decode_septet(octets, i);
+ log_debug("DECODE: i: %d octet: 0x%02X --> data: 0x%02X", i, octets[i], pdu->user_data[i]);
}
pdu->user_data[i] = '\0';
} else if (pdu->data_coding.general.alphabet == PDU_ALPHABET_CDMA_DEFAULT) {
@@ -296,7 +310,7 @@ int pdu_decode_user_data(const char *pdu_str, struct pdu_info *pdu, int *nr_octe
log_debug("DECODE: i: %d octet: 0x%02X --> data: 0x%02X", i, octets[i], pdu->user_data[i]);
}
//Remove padded byte for data length of 7 characters if not LE910-SVG
- if (strcmp(Global.core.model, "LE910-SVG") && pdu->user_data[i-1] == 0) {
+ if (strcmp(Global.core.model, "LE910-SVG") && (pdu->user_data[i-1] == 0)) {
log_debug("Removing padded char");
i--;
pdu->user_data_len--;
@@ -310,12 +324,13 @@ int pdu_decode_user_data(const char *pdu_str, struct pdu_info *pdu, int *nr_octe
}
//Only for GSM 7-bit character set
- if (pdu->data_coding.general.alphabet == PDU_ALPHABET_DEFAULT) {
- int read = 0;
- int store = 0;
+ if ((pdu->data_coding.general.alphabet == PDU_ALPHABET_DEFAULT) ||
+ (pdu->data_coding.general.alphabet == PDU_ALPHABET_DEFAULT_MULTI)) {
+ int read = user_data_start_index;
+ int store = user_data_start_index;
log_debug("Converting from GSM character set to IRA");
- for (read = 0; read < pdu->user_data_len; read++) {
+ for (; read < pdu->user_data_len; read++) {
if (pdu->user_data[read] == 0x1B) {
//Character from the extended set using the escape char (27)
read++;