[PATCH] Fix for gw/smsc/smsc_smpp.c - bogus coding and no udh on deliver_sm

Dave White <[email protected]>
Newsgroups gmane.comp.mobile.kannel.devel
Message-ID <[email protected]>
This patch fixes the following issues:

*) Kannel coding param is overwritten with wrong values by pdu_to_msg 
(e.g. a Nokia business card, which is 8-bit data encoded as iso-8859-1, 
is processed by Kannel as 7-bit text, and will be forwarded as coding 1.)
*) UDH is ignored in SMS-MO

The patch is included as an attachment.

It has been tested for basic correctness and seems to work.

Have fun!

David WHITE
CONNECT AUSTRIA
smpp-patch.txt (text/plain, 2.3 KB)
? smpp-patch.txt
? smpp.patch
Index: gw/smsc/smsc_smpp.c
===================================================================
RCS file: /home/cvs/gateway/gw/smsc/smsc_smpp.c,v
retrieving revision 1.22
diff -u -r1.22 smsc_smpp.c
--- gw/smsc/smsc_smpp.c	2 Jan 2003 14:43:00 -0000	1.22
+++ gw/smsc/smsc_smpp.c	18 Feb 2003 12:37:58 -0000
@@ -234,6 +234,7 @@
 static Msg *pdu_to_msg(SMPP *smpp, SMPP_PDU *pdu) 
 { 
     Msg *msg; 
+    int udh_offset = 0;
  
     gw_assert(pdu->type == deliver_sm); 
      
@@ -242,10 +243,17 @@
     pdu->u.deliver_sm.source_addr = NULL; 
     msg->sms.receiver = pdu->u.deliver_sm.destination_addr; 
     pdu->u.deliver_sm.destination_addr = NULL; 
-    msg->sms.msgdata = pdu->u.deliver_sm.short_message; 
-    pdu->u.deliver_sm.short_message = NULL; 
     dcs_to_fields(&msg, pdu->u.deliver_sm.data_coding);
 
+    if (pdu->u.deliver_sm.esm_class & ESM_CLASS_SUBMIT_UDH_INDICATOR) {
+        udh_offset = octstr_get_char(pdu->u.deliver_sm.short_message,0)+1; 
+        msg->sms.udhdata = octstr_copy(pdu->u.deliver_sm.short_message,0,udh_offset);
+        msg->sms.msgdata = octstr_copy(pdu->u.deliver_sm.short_message,udh_offset,octstr_len(pdu->u.deliver_sm.short_message)-udh_offset);
+    } else {
+	msg->sms.msgdata = pdu->u.deliver_sm.short_message;
+        pdu->u.deliver_sm.short_message = NULL;
+    }
+
     /* handle default data coding */
     switch (pdu->u.deliver_sm.data_coding) { 
         case 0x00: /* default SMSC alphabet */
@@ -257,11 +265,9 @@
                 if (charset_convert(msg->sms.msgdata, octstr_get_cstr(smpp->alt_charset), "ISO-8859-1") != 0)
                     error(0, "Failed to convert msgdata from charset <%s> to <%s>, will leave as is.",
                              octstr_get_cstr(smpp->alt_charset), "ISO-8859-1");
-                msg->sms.coding = DC_7BIT;
 
             } else { /* assume GSM 03.38 7-bit alphabet */
                 charset_gsm_to_latin1(msg->sms.msgdata); 
-                msg->sms.coding = DC_7BIT;
             }
             break;
         case 0x01: /* ASCII or IA5 - not sure if I need to do anything */
@@ -288,7 +294,6 @@
              * you implement them if you feel like it 
              */
         default: 
-            msg->sms.coding = DC_7BIT;
     }
     msg->sms.pid = pdu->u.deliver_sm.protocol_id;
lmpx.com only provides a reader for public news (NNTP) servers. It is not affiliated with the servers or forums shown here and is not responsible for the content of articles, which is written by their respective authors.