aboutsummaryrefslogtreecommitdiffstats
path: root/src/nmt
diff options
context:
space:
mode:
authorAndreas Eversberg <jolly@eversberg.eu>2017-11-11 08:11:50 +0100
committerAndreas Eversberg <jolly@eversberg.eu>2017-11-11 09:35:46 +0100
commit8a74805ea6c41e8e17983da6cec06e2466c072d1 (patch)
tree5900949e0e739bdd4e0c0f7316998233a78d0429 /src/nmt
parent486d2d5dbeaff62e9701589e73f64122e4bdd516 (diff)
NMT: Add support for receiving 8-Bit-SMS, because it is mandatory
Benefone Dragon uses this coding scheme for SMS-Submit.
Diffstat (limited to 'src/nmt')
-rw-r--r--src/nmt/sms.c28
1 files changed, 22 insertions, 6 deletions
diff --git a/src/nmt/sms.c b/src/nmt/sms.c
index d1d2fc6..abb6edf 100644
--- a/src/nmt/sms.c
+++ b/src/nmt/sms.c
@@ -360,8 +360,8 @@ static void sms_submit_report(nmt_t *nmt, uint8_t ref, int error)
* receive from lower layer
*/
-/* decdoe message from 8 bit data */
-static void decode_message(const uint8_t *data, int length, char *message)
+/* decode 7-bit character message from 8 bit data */
+static void decode_message_7(const uint8_t *data, int length, char *message)
{
int fill;
int i;
@@ -408,6 +408,7 @@ static int decode_sms_submit(nmt_t *nmt, const uint8_t *data, int length)
int orig_digits, dest_digits, msg_chars;
uint8_t orig_type, orig_plan, dest_type, dest_plan;
int tp_vpf_present = 0;
+ int coding = 0;
int rc;
/* decode ref */
@@ -515,7 +516,13 @@ static int decode_sms_submit(nmt_t *nmt, const uint8_t *data, int length)
PDEBUG(DSMS, DEBUG_NOTICE, "short data coding scheme IE\n");
return -FSC_ERROR_IN_MS;
}
- if (data[0] != 0) {
+ if (data[0] == 0x00) {
+ PDEBUG(DSMS, DEBUG_DEBUG, "SMS coding is 7 bits (got 0x%02x)\n", data[0]);
+ coding = 7;
+ } else if ((data[0] & 0xf0) == 0x30) {
+ PDEBUG(DSMS, DEBUG_DEBUG, "SMS coding is 8 bits (got 0x%02x)\n", data[0]);
+ coding = 8;
+ } else {
PDEBUG(DSMS, DEBUG_NOTICE, "SMS coding unsupported (got 0x%02x)\n", data[0]);
return -FSC_ERROR_IN_MS;
}
@@ -539,14 +546,23 @@ static int decode_sms_submit(nmt_t *nmt, const uint8_t *data, int length)
}
msg_data = data + 1;
msg_chars = data[0];
- msg_len = (msg_chars * 7 + 7) / 8;
+ if (coding == 7)
+ msg_len = (msg_chars * 7 + 7) / 8;
+ else
+ msg_len = msg_chars;
if (length < 1 + msg_len) {
PDEBUG(DSMS, DEBUG_NOTICE, "short read user data IE\n");
return -FSC_ERROR_IN_MS;
}
char message[msg_chars + 1];
- decode_message(msg_data, msg_len, message);
- PDEBUG(DSMS, DEBUG_DEBUG, "Decoded message: '%s'\n", message);
+ if (coding == 7) {
+ decode_message_7(msg_data, msg_len, message);
+ PDEBUG(DSMS, DEBUG_DEBUG, "Decoded message: '%s'\n", message);
+ } else {
+ memcpy(message, msg_data, msg_len);
+ message[msg_len] = '\0';
+ PDEBUG(DSMS, DEBUG_DEBUG, "Included message: '%s'\n", message);
+ }
PDEBUG(DSMS, DEBUG_INFO, "Submitting SMS to upper layer\n");