diff options
-rw-r--r-- | src/pdu.h | 2 | ||||
-rw-r--r-- | src/pdu_decode.c | 15 | ||||
-rw-r--r-- | src/pdu_encode.c | 7 |
3 files changed, 14 insertions, 10 deletions
@@ -119,7 +119,7 @@ int pdu_user_data_read(int fd, struct pdu_info *pdu); #define cycledown(n, mod) ((mod - 1) - ((n) % (mod))) //Returns the number of octets the given septets (normal ascii) can be encoded to -#define octets_from_septets(n) ((((n) * 7) + ((-(n) * 7) & 7)) / 8) +#define octets_from_septets(n) ((((n) * 7) + ((-(n) * 7) & 7)) / 8) //Returns the number of septets the given octets will decode to #define septets_from_octets(n) ((n) * 8 / 7) diff --git a/src/pdu_decode.c b/src/pdu_decode.c index d7def28..7c36385 100644 --- a/src/pdu_decode.c +++ b/src/pdu_decode.c @@ -227,15 +227,18 @@ int pdu_decode_user_data(const char *pdu_str, struct pdu_info *pdu, int *nr_octe // CDMA 7-BIT ENCODING } else if (pdu->data_coding.general.alphabet == PDU_ALPHABET_CDMA_DEFAULT) { - // LE910-SVG stores data length as # of septets - if (!strcmp(Global.core.model, "LE910-SVG")) { - *nr_octets = octets_from_septets(pdu->user_data_len); - } - // Other CDMA radios store data length as # of octets - else { + if (!strcmp(Global.core.model, "DE910-DUAL")) { + // DE910-DUAL stores data length as # of octets + log_debug("counting PDU length byte as number of octets (DE910-DUAL)"); *nr_octets = pdu->user_data_len; pdu->user_data_len = septets_from_octets(pdu->user_data_len); } + else { + // Other CDMA radios store data length as # of septets + log_debug("counting PDU length byte as number of septets"); + *nr_octets = octets_from_septets(pdu->user_data_len); + } + if (pdu->user_data_len > PDU_UD_7BIT_MAX) { log_warning("pdu contains invalid user-data-len: 0x%02X", pdu->user_data_len); diff --git a/src/pdu_encode.c b/src/pdu_encode.c index 65d2316..f8d6160 100644 --- a/src/pdu_encode.c +++ b/src/pdu_encode.c @@ -277,13 +277,14 @@ int pdu_encode_user_data(char *pdu_str, size_t len, struct pdu_info *pdu, int *n return -1; } - if (pdu->data_coding.general.alphabet == PDU_ALPHABET_CDMA_DEFAULT) { + if ((pdu->data_coding.general.alphabet == PDU_ALPHABET_CDMA_DEFAULT) && + !strcmp(Global.core.model, "DE910-DUAL")) { // user_data_len is stored as number of encoded octets - // (but GSM is stored as originial # of septets) - log_debug("putting nr_octets into PDU as data length (CDMA)"); + log_debug("putting nr_octets into PDU as data length (DE910-DUAL)"); tmp = hex_byte_encode(pdu_str, len, *nr_octets); } else { + // user_data_len is stored as number of septets log_debug("putting user_data_len into PDU as data length"); tmp = hex_byte_encode(pdu_str, len, pdu->user_data_len); } |