[PATCH] Hex Digits in submit_sm_resp and dlr

"Mi Reflejo" <[email protected]>
Newsgroups gmane.comp.mobile.kannel.devel
Message-ID <[email protected]>
There is a patch for "detect" if the comming number for msg_id
containing only decimal digits, otherwise we deal with this as hex.

According to http://bugs.kannel.org/view_bug_advanced_page.php?f_id=0000334

Regards,
Martin Conte.
hex_detection.patch (application/octet-stream, 2.1 KB)
--- gw/smsc/smsc_smpp.c.orig    2006-06-03 23:46:27.000000000 -0600
+++ gw/smsc/smsc_smpp.c 2006-06-03 23:42:53.000000000 -0600
@@ -1264,7 +1264,7 @@
             /* the default, C string */
             tmp = octstr_duplicate(msgid);
         } else {
-            if (smpp->smpp_msg_id_type & 0x02) {
+            if ((smpp->smpp_msg_id_type & 0x02) || (!octstr_is_all_decimal(msgid))) {
                 tmp = octstr_format("%lu", strtoll(octstr_get_cstr(msgid), NULL, 16));
             } else {
                 tmp = octstr_format("%lu", strtoll(octstr_get_cstr(msgid), NULL, 10));
@@ -1480,7 +1480,7 @@
                     /* the default, C string */
                     tmp = octstr_duplicate(pdu->u.submit_sm_resp.message_id);
                 } else {
-                    if (smpp->smpp_msg_id_type & 0x01) {
+                    if ((smpp->smpp_msg_id_type & 0x01) || (!octstr_is_all_decimal(pdu->u.submit_sm_resp.message_id))) {
                         tmp = octstr_format("%lu", strtoll(  /* hex */
                             octstr_get_cstr(pdu->u.submit_sm_resp.message_id), NULL, 16));
                     } else {
--- gwlib/octstr.c.orig       2006-06-03 23:47:26.000000000 -0600
+++ gwlib/octstr.c    2006-06-03 23:35:53.000000000 -0600
@@ -2612,6 +2612,20 @@
     return 1;
 }

+int octstr_is_all_decimal(Octstr *os)
+{
+    int len, i;
+    int ch;
+    seems_valid(os);
+    len = octstr_len(os);
+    for (i = 0; i < len; ++i) {
+        ch = octstr_get_char(os, i);
+        if (!gw_isdigit(ch))
+            return 0;
+    }
+    return 1;
+}
+
 /*
  * function octstr_convert_to_html_entities()
  *      make data HTML safe by converting appropriate characters to HTML entities
--- gwlib/octstr.h.orig       2006-06-03 23:53:16.000000000 -0600
+++ gwlib/octstr.h    2006-06-03 23:55:12.000000000 -0600
@@ -723,6 +723,11 @@
 int octstr_is_all_hex(Octstr *os);

 /*
+ * Return 1, if octstr 'os' contains only decimal chars, 0 otherwise.
+ */
+int octstr_is_all_decimal(Octstr *os);
+
+/*
  * make data HTML safe by converting appropriate characters to HTML entities.
  * conversion is done in place
  */
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.