Concatenated MT - configurable registered_delivery behaviour

Paul Cook <[email protected]>
Newsgroups gmane.comp.mobile.kannel.devel
Message-ID <CAK8_ccOCbNziad1RRzX8q4OZRf=pkwW6JreWy_1M1afaHfAWDA@mail.gmail.com>
Hi,

We have a number of clients who use kannel as a client to submit to our
messaging service.
A common problem they encounter is that when sending a long MT, it is split
correctly into multiple parts, but registered_delivery is set to 0 for all
parts greater than 0.

This attached patch makes that behavior optional, by adding the following
config line to an smsc group:

 concatenated-sms-dlr-for-all-parts = true

If set, then registered_delivery will not be altered for the subsequent
parts of the concatenated set, and the client app will receive delivery
receipts for all parts.


Please consider this patch for inclusion in the next release


Thanks


Paul Cook
patch.diff (application/octet-stream, 6.2 KB)
diff -Naur orig-gateway-1.5.0/gw/smsbox.c gateway-1.5.0/gw/smsbox.c
--- orig-gateway-1.5.0/gw/smsbox.c	2010-10-07 15:03:35.000000000 +0100
+++ gateway-1.5.0/gw/smsbox.c	2012-08-07 16:25:49.991913516 +0100
@@ -150,6 +150,8 @@
 static Dict *client_dict = NULL;
 static List *sendsms_reply_hdrs = NULL;
 
+static int concatenated_sms_dlr_for_all_parts = 0;
+
 /***********************************************************************
  * Communication with the bearerbox.
  */
@@ -361,7 +363,7 @@
     else
     	msg_sequence = 0;
 
-    list = sms_split(msg, header, footer, suffix, split_chars, catenate,
+    list = sms_split(msg, header, footer, suffix, split_chars, catenate, concatenated_sms_dlr_for_all_parts,
     	    	     msg_sequence, max_msgs, sms_max_length);
     msg_count = gwlist_len(list);
     
@@ -3411,6 +3413,8 @@
     /* should smsbox reply to sendsms immediate or wait for bearerbox ack */
     cfg_get_bool(&immediate_sendsms_reply, grp, octstr_imm("immediate-sendsms-reply"));
 
+    cfg_get_bool(&concatenated_sms_dlr_for_all_parts, grp, octstr_imm("concatenated-sms-dlr-for-all-parts"));
+
     /* determine which timezone we use for access logging */
     if ((p = cfg_get(grp, octstr_imm("access-log-time"))) != NULL) {
         lf = (octstr_case_compare(p, octstr_imm("gmt")) == 0) ? 0 : 1;
diff -Naur orig-gateway-1.5.0/gw/sms.c gateway-1.5.0/gw/sms.c
--- orig-gateway-1.5.0/gw/sms.c	2010-10-07 15:03:35.000000000 +0100
+++ gateway-1.5.0/gw/sms.c	2012-08-07 16:25:49.991913516 +0100
@@ -301,7 +301,7 @@
 
 List *sms_split(Msg *orig, Octstr *header, Octstr *footer, 
                 Octstr *nonlast_suffix, Octstr *split_chars, 
-                int catenate, unsigned long msg_sequence,
+                int catenate, int concatenated_sms_dlr_for_all_parts, unsigned long msg_sequence,
                 int max_messages, int max_octets)
 {
     long max_part_len, udh_len, hf_len, nlsuf_len;
@@ -347,11 +347,12 @@
          * if its a DLR request message getting split, 
          * only ask DLR for the first one 
          */
-        if ((msgno > 1) && DLR_IS_ENABLED(part->sms.dlr_mask)) {
+        if (!concatenated_sms_dlr_for_all_parts && (msgno > 1) && DLR_IS_ENABLED(part->sms.dlr_mask)) {
             octstr_destroy(part->sms.dlr_url);
             part->sms.dlr_url = NULL;
             part->sms.dlr_mask = 0;
         }
+
         octstr_destroy(part->sms.msgdata);
         if (sms_msgdata_len(temp) <= max_part_len || msgno == max_messages)
             last = 1;
diff -Naur orig-gateway-1.5.0/gw/smscconn.c gateway-1.5.0/gw/smscconn.c
--- orig-gateway-1.5.0/gw/smscconn.c	2010-10-07 15:03:35.000000000 +0100
+++ gateway-1.5.0/gw/smscconn.c	2012-08-07 16:25:49.987913516 +0100
@@ -238,6 +238,8 @@
     if (cfg_get_integer(&conn->max_sms_octets, grp, octstr_imm("max-sms-octets")) == -1)
         conn->max_sms_octets = MAX_SMS_OCTETS;
 
+    cfg_get_bool(&conn->concatenated_sms_dlr_for_all_parts, grp, octstr_imm("concatenated-sms-dlr-for-all-parts"));
+
     /* open a smsc-id specific log-file in exlusive mode */
     if (conn->log_file)
         conn->log_idx = log_open(octstr_get_cstr(conn->log_file), 
@@ -532,7 +534,7 @@
         normalize_number(uf, &(msg->sms.receiver));
 
         /* split msg */
-        parts = sms_split(msg, NULL, NULL, NULL, NULL, 1, 
+        parts = sms_split(msg, NULL, NULL, NULL, NULL, 1, conn->concatenated_sms_dlr_for_all_parts,
             counter_increase(split_msg_counter) & 0xff, 0xff, conn->max_sms_octets);
         if (gwlist_len(parts) == 1) {
             /* don't create split_parts of sms fit into one */
diff -Naur orig-gateway-1.5.0/gw/smscconn_p.h gateway-1.5.0/gw/smscconn_p.h
--- orig-gateway-1.5.0/gw/smscconn_p.h	2010-10-07 15:03:35.000000000 +0100
+++ gateway-1.5.0/gw/smscconn_p.h	2012-08-07 16:25:49.987913516 +0100
@@ -236,6 +236,7 @@
     void (*start_conn) (SMSCConn *conn);
     void (*stop_conn) (SMSCConn *conn);
 
+    int concatenated_sms_dlr_for_all_parts;
 
     void *data;			/* SMSC specific stuff */
 };
diff -Naur orig-gateway-1.5.0/gw/sms.h gateway-1.5.0/gw/sms.h
--- orig-gateway-1.5.0/gw/sms.h	2010-10-07 15:03:35.000000000 +0100
+++ gateway-1.5.0/gw/sms.h	2012-08-07 16:25:49.983913516 +0100
@@ -189,6 +189,7 @@
  */
 List *sms_split(Msg *orig, Octstr *header, Octstr *footer,
                 Octstr *nonlast_suffix, Octstr *split_chars, int catenate,
+                int concatenated_sms_dlr_for_all_parts,
                 unsigned long msg_sequence, int max_messages, int max_octets);
 
 /**
diff -Naur orig-gateway-1.5.0/gw/wapbox.c gateway-1.5.0/gw/wapbox.c
--- orig-gateway-1.5.0/gw/wapbox.c	2010-10-07 15:03:35.000000000 +0100
+++ gateway-1.5.0/gw/wapbox.c	2012-08-07 16:25:49.991913516 +0100
@@ -457,7 +457,7 @@
     } else {
         msg_sequence = counter_increase(sequence_counter) & 0xff;
         msg = pack_sms_datagram(dgram);
-        sms_datagrams = sms_split(msg, NULL, NULL, NULL, NULL, concatenation, 
+        sms_datagrams = sms_split(msg, NULL, NULL, NULL, NULL, concatenation, 1,
                                   msg_sequence, max_messages, MAX_SMS_OCTETS);
         debug("wap",0,"WDP (wapbox): delivering %ld segments to bearerbox",
               gwlist_len(sms_datagrams));
diff -Naur orig-gateway-1.5.0/gwlib/cfg.def gateway-1.5.0/gwlib/cfg.def
--- orig-gateway-1.5.0/gwlib/cfg.def	2010-10-07 15:03:35.000000000 +0100
+++ gateway-1.5.0/gwlib/cfg.def	2012-08-07 16:25:49.915913519 +0100
@@ -283,6 +283,7 @@
     OCTSTR(immediate-sendsms-reply)
     OCTSTR(max-pending-requests)
     OCTSTR(http-timeout)
+    OCTSTR(concatenated-sms-dlr-for-all-parts)
 )
 
 
@@ -412,6 +413,7 @@
     OCTSTR(generic-status-sent)
     OCTSTR(generic-status-error)
     OCTSTR(generic-foreign-id-regex)
+    OCTSTR(concatenated-sms-dlr-for-all-parts)
 )
 
 
diff -Naur orig-gateway-1.5.0/utils/mtbatch.c gateway-1.5.0/utils/mtbatch.c
--- orig-gateway-1.5.0/utils/mtbatch.c	2010-10-07 15:03:35.000000000 +0100
+++ gateway-1.5.0/utils/mtbatch.c	2012-08-07 16:25:49.935913516 +0100
@@ -217,7 +217,7 @@
         msg->sms.boxc_id = octstr_duplicate(smsbox_id);
     }
     
-    list = sms_split(msg, NULL, NULL, NULL, NULL, 1, 0, 100, MAX_SMS_OCTETS);
+    list = sms_split(msg, NULL, NULL, NULL, NULL, 1, 1, 0, 100, MAX_SMS_OCTETS);
     msg_count = gwlist_len(list);
     gwlist_destroy(list, msg_destroy_item);
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.