gnokii-commit
[Top][All Lists]
Advanced

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

[SCM] libgnokii and core programs branch, master, updated. rel_0_6_29-42


From: Daniele Forsi
Subject: [SCM] libgnokii and core programs branch, master, updated. rel_0_6_29-429-gea2dfe0
Date: Sun, 20 Jan 2013 13:33:06 +0000

This is an automated email from the git hooks/post-receive script. It was
generated because a ref change was pushed to the repository containing
the project "libgnokii and core programs".

The branch, master has been updated
       via  ea2dfe081cc75c58f9528fb0c03ce7a6201c6b81 (commit)
      from  18d3c9a60564e83add48b083d0d18763d508d3b3 (commit)

Those revisions listed above that are new to this repository have
not appeared on any other notification email; so we list those
revisions in full, below.

- Log -----------------------------------------------------------------
http://git.savannah.gnu.org/cgit/gnokii.git/commit/?id=ea2dfe081cc75c58f9528fb0c03ce7a6201c6b81


commit ea2dfe081cc75c58f9528fb0c03ce7a6201c6b81
Author: Daniele Forsi <address@hidden>
Date:   Sun Jan 20 14:26:44 2013 +0100

    Fix false positive detection of compressed SMS
    
    When the 4 most significant bits in Coding Bits Group of the Data
    Coding Scheme (DCS) are set then compression can't be used (see
    Section 4 of ETSI TS 123 038); it can be used only if msb is zero.
    Now libgnokii correctly decodes 0xxx xxxx and 1111 xxxx (binary).

diff --git a/ChangeLog b/ChangeLog
index c732ac8..3c18dc1 100644
--- a/ChangeLog
+++ b/ChangeLog
@@ -24,6 +24,7 @@
       add static instead                                (Paweł Kot)
     o don't overwrite user-provided TP-Validity-Period
       in sms_prepare()                              (Daniele Forsi)
+    o fix false detection of compressed SMS         (Daniele Forsi)
  * at driver updates
     o in the default case autodetect if PDU SMS starts with SMSC
                                                     (Daniele Forsi)
diff --git a/common/gsm-sms.c b/common/gsm-sms.c
index fb7291d..f82249b 100644
--- a/common/gsm-sms.c
+++ b/common/gsm-sms.c
@@ -461,35 +461,68 @@ static gn_error sms_status(unsigned char status, gn_sms 
*sms)
 static gn_error sms_data_decode(unsigned char *message, unsigned char *output, 
unsigned int length,
                                 unsigned int size, unsigned int udhlen, 
gn_sms_dcs dcs)
 {
-       /* Unicode */
-       if (dcs.type & 0x20) {
-               dprintf("Compressed message\n");
+       gn_sms_dcs_alphabet_type alphabet;
+
+       /*
+        * Coding Group Bits. See Section 4 of ETSI TS 123 038
+        * 7bit is 0xxx 00xx and 1111 00xx
+        * 8bit is 0xxx 01xx and 1111 01xx
+        * UCS2 is 0xxx 10xx
+        * delete after reading is 0dxx xxxx
+        * compressed is 0xcx xxxx
+        * class is 1111xxcc and 0xx1xxcc
+       */
+       if ((dcs.type & 0x80) == 0x00) {
+               if (dcs.type & 0x40) {
+                       /* TODO: add a field to struct gn_sms_dcs to store this 
bit */
+                       dprintf("\tMessage Marked for Automatic Deletion\n");
+               }
+               if (dcs.type & 0x20) {
+                       dprintf("\tCompressed message\n");
+                       return GN_ERR_NOTIMPLEMENTED;
+               }
+               if (dcs.type & 0x10) {
+                       dprintf("\tClass: %d\n", dcs.type & 0x03);
+                       dcs.u.general.m_class = 1 + (dcs.type & 0x03);
+               }
+               alphabet = (dcs.type >> 2) & 0x03;
+       } else if ((dcs.type & 0xf0) == 0xf0) {
+               dprintf("\tClass: %d\n", dcs.type & 0x03);
+               dcs.u.general.m_class = 1 + (dcs.type & 0x03);
+               alphabet = (dcs.type >> 2) & 0x03;
+       } else {
+               dprintf("SMS Data Coding Scheme 0x%02x is not supported\n", 
dcs.type);
                return GN_ERR_NOTIMPLEMENTED;
        }
-       if ((dcs.type & 0x08) == 0x08) {
-               dprintf("Unicode message\n");
-               /*
-                * length is rawsms->length which is number of characters in
-                * the decoded text. 3rd argument of char_unicode_decode is
-                * number of bytes.
-                */
-               char_unicode_decode(output, message, 2 * length);
-       } else {
-               /* 8bit SMS */
-               if ((dcs.type & 0xf4) == 0xf4) {
-                       dprintf("8bit message\n");
-                       memcpy(output, message + udhlen, length);
-               /* 7bit SMS */
-               } else {
+       switch (alphabet) {
+       case GN_SMS_DCS_DefaultAlphabet:
+               {
                        char *aux;
 
-                       dprintf("Default Alphabet\n");
+                       dprintf("\tDefault Alphabet\n");
                        length = length - (udhlen * 8 + ((7-(udhlen%7))%7)) / 7;
                        aux = calloc(length + 1, 1);
                        char_7bit_unpack((7-udhlen)%7, size, length, message, 
aux);
                        char_default_alphabet_decode(output, aux, length);
                        free(aux);
                }
+               break;
+       case GN_SMS_DCS_8bit:
+               dprintf("\t8bit message\n");
+               memcpy(output, message + udhlen, length);
+               break;
+       case GN_SMS_DCS_UCS2:
+               dprintf("\tUnicode message\n");
+               /*
+                * length is rawsms->length which is number of characters in
+                * the decoded text. 3rd argument of char_unicode_decode is
+                * number of bytes.
+                */
+               char_unicode_decode(output, message, 2 * length);
+               break;
+       case GN_SMS_DCS_Reserved:
+               dprintf("\tReserved alphabet in DCS\n");
+               return GN_ERR_NOTIMPLEMENTED;
        }
        dprintf("%s\n", output);
        return GN_ERR_NONE;
diff --git a/include/gnokii/sms.h b/include/gnokii/sms.h
index 37ee7a7..15d7e81 100644
--- a/include/gnokii/sms.h
+++ b/include/gnokii/sms.h
@@ -144,7 +144,8 @@ typedef enum {
 typedef enum {
        GN_SMS_DCS_DefaultAlphabet = 0x00,
        GN_SMS_DCS_8bit            = 0x01,
-       GN_SMS_DCS_UCS2            = 0x02
+       GN_SMS_DCS_UCS2            = 0x02,
+       GN_SMS_DCS_Reserved        = 0x03
 } gn_sms_dcs_alphabet_type;
 
 typedef enum {

-----------------------------------------------------------------------

Summary of changes:
 ChangeLog            |    1 +
 common/gsm-sms.c     |   71 ++++++++++++++++++++++++++++++++++++-------------
 include/gnokii/sms.h |    3 +-
 3 files changed, 55 insertions(+), 20 deletions(-)


hooks/post-receive
-- 
libgnokii and core programs



reply via email to

[Prev in Thread] Current Thread [Next in Thread]