Those of you connected to a large multinational SMSC who does not
support NATIONAL TON... ;-) ... may find this patch useful where you want
users to be able to set their originator / source address in national
format.

It is based on the unified prefix code.

-- 
Benjamin Lee

Level 2 71-75 City Rd, South Melbourne, VIC 3006 Australia
Phone +61 3 8699 1333  Mobile +61 414 717 573  Fax +61 3 8699 1388
--- smsc_smpp.c.original        Wed Mar 26 02:57:11 2003
+++ smsc_smpp.c Wed Mar 26 02:57:22 2003
@@ -106,6 +106,7 @@
     int smpp_msg_id_type;  /* msg id in C string, hex or decimal */
     int autodetect_addr;
     Octstr *alt_charset;
+    Octstr *sender_prefix;
     SMSCConn *conn; 
 } SMPP; 
  
@@ -120,7 +121,8 @@
                          int max_pending_submits, int version, int priority,
                          Octstr *my_number, int smpp_msg_id_type, 
                          int autodetect_addr, Octstr *alt_charset, 
-                         Octstr *service_type) 
+                         Octstr *service_type, 
+                                                Octstr *sender_prefix) 
 { 
     SMPP *smpp; 
      
@@ -157,6 +159,7 @@
     smpp->smpp_msg_id_type = smpp_msg_id_type;    
     smpp->autodetect_addr = autodetect_addr;
     smpp->alt_charset = octstr_duplicate(alt_charset);
+    smpp->sender_prefix = octstr_duplicate(sender_prefix);
  
     return smpp; 
 } 
@@ -177,6 +180,7 @@
         octstr_destroy(smpp->address_range); 
         octstr_destroy(smpp->my_number);
         octstr_destroy(smpp->alt_charset);
+        octstr_destroy(smpp->sender_prefix);
         gw_free(smpp); 
     } 
 } 
@@ -336,6 +340,8 @@
     struct tm gmtime, localtime, tm;
     int gwqdiff;
 
+    char *uf;
+
     pdu = smpp_pdu_create(submit_sm,  
                          counter_increase(smpp->message_id_counter)); 
                    
@@ -345,6 +351,10 @@
     /* Set the service type of the outgoing message */
     pdu->u.submit_sm.service_type = octstr_duplicate(smpp->service_type);
   
+    /* Unify / normalize the source address according to sender-prefix config value */
+    uf = smpp->sender_prefix ? octstr_get_cstr(smpp->sender_prefix) : NULL; 
+    normalize_number(uf, &(pdu->u.submit_sm.source_addr));
+  
     /* Check for manual override of source ton and npi values */ 
     if(smpp->source_addr_ton > -1 && smpp->source_addr_npi > -1) { 
         pdu->u.submit_sm.source_addr_ton = smpp->source_addr_ton; 
@@ -1295,6 +1305,7 @@
     long smpp_msg_id_type;
     int autodetect_addr;
     Octstr *alt_charset;
+    Octstr *sender_prefix;
  
     my_number = alt_charset = NULL; 
     transceiver_mode = 0;
@@ -1405,13 +1416,17 @@
     /* check for an alternative charset */
     alt_charset = cfg_get(grp, octstr_imm("alt-charset"));
 
+    /* check for unifying sender prefix */
+    sender_prefix = cfg_get(grp, octstr_imm("sender-prefix")); 
+
     smpp = smpp_create(conn, host, port, receive_port, system_type,  
                       username, password, address_range,
                        source_addr_ton, source_addr_npi, dest_addr_ton,  
                        dest_addr_npi, alt_dcs, enquire_link_interval, 
                        max_pending_submits, version, priority, my_number, 
                        smpp_msg_id_type, autodetect_addr, alt_charset, 
-                       service_type); 
+                       service_type, 
+                       sender_prefix); 
  
     conn->data = smpp; 
     conn->name = octstr_format("SMPP:%S:%d/%d:%S:%S",  
@@ -1433,6 +1448,7 @@
     octstr_destroy(smsc_id);
     octstr_destroy(alt_charset); 
     octstr_destroy(service_type);
+    octstr_destroy(sender_prefix);
 
     conn->status = SMSCCONN_CONNECTING; 
        

Reply via email to