[Patch] Manually setting EMS class

Jakub Burgis <[email protected]>
Newsgroups gmane.comp.mobile.kannel.devel
Message-ID <137000795429B94EBF0C76C014F369DF218DFEFA56@matchbox.blitztelecom.local>
We recently had the need to connect Kannel to an SMSC that preferred an ems_class of 0 for generic SMS messages instead of Kannel's default of 3. The only things I could find were archived list postings referencing patching the source, but since we're running multiple routes on the same installation, a config item was preferred.

I've added a new smsc config entry, "esm-class-submit", which takes the same values as defined in smpp_pdu.h. The default if not defined is still 3, but I'm now able to define "esm-class-submit = 0" on a per-route basis and see it reflected in the outgoing PDU dumps.

Although our testing seems fine, I'm hoping someone more familiar with the source could take a quick glance to see if it's likely to break anything else. If it turns out to be useful to anyone else, even better.
ems_class_sender.patch (application/octet-stream, 3 KB)
diff -ru gateway-orig/gw/smsc/smsc_smpp.c gateway/gw/smsc/smsc_smpp.c
--- gateway-orig/gw/smsc/smsc_smpp.c	2008-07-31 15:09:06.000000000 +0100
+++ gateway/gw/smsc/smsc_smpp.c	2008-07-31 15:22:04.000000000 +0100
@@ -164,6 +164,7 @@
     long connection_timeout;
     long wait_ack;
     int wait_ack_action;
+    long esm_class_submit;
     SMSCConn *conn; 
 } SMPP; 
  
@@ -216,7 +217,7 @@
                          Octstr *my_number, int smpp_msg_id_type, 
                          int autodetect_addr, Octstr *alt_charset, Octstr *alt_addr_charset,
                          Octstr *service_type, long connection_timeout,
-                         long wait_ack, int wait_ack_action) 
+                         long wait_ack, int wait_ack_action, long esm_class_submit) 
 { 
     SMPP *smpp; 
      
@@ -259,6 +260,7 @@
     smpp->wait_ack_action = wait_ack_action;
     smpp->bind_addr_ton = 0;
     smpp->bind_addr_npi = 0;
+    smpp->esm_class_submit = esm_class_submit;
  
     return smpp; 
 } 
@@ -858,7 +860,7 @@
      * set the esm_class field
      * default is store and forward, plus udh and rpi if requested
      */
-    pdu->u.submit_sm.esm_class = ESM_CLASS_SUBMIT_STORE_AND_FORWARD_MODE;
+    pdu->u.submit_sm.esm_class = smpp->esm_class_submit;
     if (octstr_len(msg->sms.udhdata))
         pdu->u.submit_sm.esm_class = pdu->u.submit_sm.esm_class |
             ESM_CLASS_SUBMIT_UDH_INDICATOR;
@@ -2008,6 +2010,7 @@
     Octstr *alt_charset;
     Octstr *alt_addr_charset;
     long connection_timeout, wait_ack, wait_ack_action;
+    long esm_class_submit;
 
     my_number = alt_addr_charset = alt_charset = NULL;
     transceiver_mode = 0;
@@ -2098,6 +2101,10 @@
     else
         /* convert decimal to BCD */
         version = ((version / 10) << 4) + (version % 10);
+        
+    /* use store-and-forward if not defined in config */
+    if (cfg_get_integer(&esm_class_submit, grp, octstr_imm("esm-class-submit")) == -1)
+        esm_class_submit = ESM_CLASS_SUBMIT_STORE_AND_FORWARD_MODE;
 
     /* check for any specified priority value in range [0-5] */
     if (cfg_get_integer(&priority, grp, octstr_imm("priority")) == -1)
@@ -2146,7 +2153,7 @@
                        dest_addr_npi, enquire_link_interval, 
                        max_pending_submits, version, priority, validity, my_number, 
                        smpp_msg_id_type, autodetect_addr, alt_charset, alt_addr_charset,
-                       service_type, connection_timeout, wait_ack, wait_ack_action); 
+                       service_type, connection_timeout, wait_ack, wait_ack_action, esm_class_submit); 
  
     cfg_get_integer(&smpp->bind_addr_ton, grp, octstr_imm("bind-addr-ton"));
     cfg_get_integer(&smpp->bind_addr_npi, grp, octstr_imm("bind-addr-npi"));
diff -ru gateway-orig/gwlib/cfg.def gateway/gwlib/cfg.def
--- gateway-orig/gwlib/cfg.def	2008-07-31 15:09:07.000000000 +0100
+++ gateway/gwlib/cfg.def	2008-07-31 13:09:19.000000000 +0100
@@ -372,6 +372,7 @@
     OCTSTR(preferred-prefix-regex)
     OCTSTR(max-error-count)
     OCTSTR(alt-addr-charset)
+    OCTSTR(esm-class-submit)
 )
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.