Hi!

This patch allows you to set the source_addr_ton when sending the SM by
using a new cgi var called "source-addr-ton". This is necessary when
speaking to some providers. Maybe the same thing should be done for the NPI
aswell, but I have not come across any case where that would be necessary.

/ Stefan
Index: msg-decl.h
===================================================================
RCS file: /home/cvs/gateway/gw/msg-decl.h,v
retrieving revision 1.23
diff -u -r1.23 msg-decl.h
--- msg-decl.h  16 Oct 2003 16:00:44 -0000      1.23
+++ msg-decl.h  9 Nov 2003 00:57:18 -0000
@@ -47,6 +47,7 @@
                OCTSTR(charset);
                OCTSTR(boxc_id);
                OCTSTR(binfo);
+               INTEGER(sb_source_addr_ton);
        })
 
 MSG(ack,
Index: smsbox.c
===================================================================
RCS file: /home/cvs/gateway/gw/smsbox.c,v
retrieving revision 1.237
diff -u -r1.237 smsbox.c
--- smsbox.c    20 Oct 2003 12:21:33 -0000      1.237
+++ smsbox.c    9 Nov 2003 00:57:18 -0000
@@ -371,7 +371,7 @@
                                      int *validity, int *deferred,
                                      int *dlr_mask, Octstr **dlr_url, 
                                      Octstr **account, int *pid, int *alt_dcs, 
-                                     int *rpi, Octstr **binfo)
+                                     int *rpi, Octstr **binfo, int 
*sb_source_addr_ton)
 {
     Octstr *name, *val;
     long l;
@@ -458,6 +458,9 @@
        else if (octstr_case_compare(name, octstr_imm("X-Kannel-RPI")) == 0) {
            sscanf(octstr_get_cstr(val),"%d", rpi);
        }
+       else if (octstr_case_compare(name, octstr_imm("X-Kannel-Source-Addr-Ton")) == 
0) {
+           sscanf(octstr_get_cstr(val), "%d", rpi);
+       }
        octstr_destroy(name);
        octstr_destroy(val);
     }
@@ -514,7 +517,7 @@
                                   int *dlr_mask, Octstr **dlr_url,
                                   Octstr **account, int *pid, int *alt_dcs,
                                   int *rpi, List **tolist, Octstr **charset,
-                                  Octstr **binfo)
+                                  Octstr **binfo, int *sb_source_addr_ton)
 {                                    
 
     Octstr *text, *tmp, *tmp2;
@@ -602,6 +605,14 @@
        O_DESTROY(tmp);
     }
 
+    /* sb_source_addr_ton */
+    get_tag(*body, octstr_imm("source-addr-ton"), &tmp, 0,0);
+    if(tmp) {
+      if(octstr_parse_long(&tmplong, tmp, 0, 10) != -1)
+       *sb_source_addr_ton = tmplong;
+      O_DESTROY(tmp);
+    }
+
     /* dcs* (dcs/ *) */
     get_tag(*body, octstr_imm("dcs"), &tmp, 0, 0);
     if(tmp) {
@@ -720,7 +731,7 @@
                         int validity, int deferred,
                         Octstr *dlr_url, int dlr_mask, int pid, int alt_dcs,
                         int rpi, Octstr *smsc, Octstr *account,
-                        Octstr *charset, Octstr *binfo)
+                        Octstr *charset, Octstr *binfo, int sb_source_addr_ton)
 {
     msg->sms.msgdata = replytext;
     msg->sms.time = time(NULL);
@@ -797,6 +808,14 @@
        else
            warning(0, "Tried to set RPI field, denied.");
     }
+
+    if (sb_source_addr_ton != SMS_PARAM_UNDEFINED) {
+      if(urltrans_accept_x_kannel_headers(trans))
+       msg->sms.sb_source_addr_ton = sb_source_addr_ton;
+      else
+       warning(0, "Tried to set the source-addr-ton, denied.");
+    }
+    
     if (alt_dcs != SMS_PARAM_UNDEFINED) {
         if (urltrans_accept_x_kannel_headers(trans))
            msg->sms.alt_dcs = alt_dcs;
@@ -949,7 +968,7 @@
     Octstr *reply_body, *charset;
     Octstr *udh, *from, *to, *dlr_url, *account, *smsc, *binfo;
     int dlr_mask, mclass, mwi, coding, compress, pid, alt_dcs, rpi;
-    int validity, deferred;
+    int validity, deferred, sb_source_addr_ton;
 
     text_html = octstr_imm("text/html");
     text_wml = octstr_imm("text/vnd.wap.wml");
@@ -967,7 +986,7 @@
        octets = 0;
     from = to = udh = smsc = dlr_url = account = binfo = charset = NULL;
        mclass = mwi = coding = compress = pid = alt_dcs = rpi = dlr_mask 
-        = validity = deferred = -1;
+        = validity = deferred = sb_source_addr_ton = -1;
 
         get_receiver(id, &msg, &trans, &method, &req_url, &req_headers, &req_body, 
&retries);
 
@@ -985,7 +1004,7 @@
                                          &coding, &compress, &validity,
                                          &deferred, &dlr_mask, &dlr_url,
                                          &account, &pid, &alt_dcs, &rpi,
-                                         &binfo);
+                                         &binfo, &sb_source_addr_ton);
             } else if (octstr_case_compare(type, text_plain) == 0) {
                 replytext = octstr_duplicate(reply_body);
                 octstr_destroy(reply_body);
@@ -995,7 +1014,7 @@
                                          &coding, &compress, &validity,
                                          &deferred, &dlr_mask, &dlr_url,
                                          &account, &pid, &alt_dcs, &rpi,
-                                         &binfo);
+                                         &binfo, &sb_source_addr_ton);
             } else if (octstr_case_compare(type, text_xml) == 0) {
                 replytext = octstr_duplicate(reply_body);
                 octstr_destroy(reply_body);
@@ -1004,7 +1023,7 @@
                         &from, &to, &udh, NULL, NULL, &smsc, &mclass, &mwi,
                         &coding, &compress, &validity, &deferred, &dlr_mask,
                         &dlr_url, &account, &pid, &alt_dcs, &rpi, NULL, &charset,
-                        &binfo);
+                        &binfo, &sb_source_addr_ton);
             } else if (octstr_case_compare(type, octet_stream) == 0) {
                 replytext = octstr_duplicate(reply_body);
                 octstr_destroy(reply_body);
@@ -1015,7 +1034,7 @@
                                          &coding, &compress, &validity,
                                          &deferred, &dlr_mask, &dlr_url,
                                          &account, &pid, &alt_dcs, &rpi,
-                                         &binfo);
+                                         &binfo, &sb_source_addr_ton);
             } else {
                 replytext = octstr_duplicate(reply_couldnotrepresent);
             }
@@ -1035,7 +1054,7 @@
         fill_message(msg, trans, replytext, octets, from, to, udh, mclass,
             mwi, coding, compress, validity, deferred, dlr_url,
             dlr_mask, pid, alt_dcs, rpi, smsc, account, charset,
-            binfo);
+            binfo, sb_source_addr_ton);
 
         if (final_url == NULL)
             final_url = octstr_imm("");
@@ -1784,7 +1803,7 @@
                                 int validity, int deferred,
                                 int *status, int dlr_mask, Octstr *dlr_url, 
                                 Octstr *account, int pid, int alt_dcs, int rpi,
-                                List *receiver, Octstr *binfo)
+                                List *receiver, Octstr *binfo, int sb_source_addr_ton)
 {                                   
     Msg *msg = NULL;
     Octstr *newfrom, *returnerror, *receiv;
@@ -1987,6 +2006,12 @@
        goto fielderror;
     }
     msg->sms.rpi = rpi;
+
+    if ( sb_source_addr_ton < -1 || sb_source_addr_ton > 9) {
+      returnerror = octstr_create("source-addr-ton field misformed, rejected");
+      goto fielderror;
+    }
+    msg->sms.sb_source_addr_ton = sb_source_addr_ton;
     
     if ( alt_dcs < -1 || alt_dcs > 1 ) {
        returnerror = octstr_create("Alt-DCS field misformed, rejected");
@@ -2240,11 +2265,11 @@
     Octstr *from, *to, *charset, *text, *udh, *smsc, *dlr_url, *account;
     Octstr *binfo;
     int        dlr_mask, mclass, mwi, coding, compress, validity, deferred, pid;
-    int alt_dcs, rpi;
+    int alt_dcs, rpi, sb_source_addr_ton;
 
     from = to = udh = text = smsc = account = dlr_url = charset = binfo = NULL;
     mclass = mwi = coding = compress = validity = deferred = dlr_mask = 
-        pid = alt_dcs = rpi = -1;
+        pid = alt_dcs = rpi = sb_source_addr_ton = -1;
  
     /* check the username and password */
     t = authorise_user(args, client_ip);
@@ -2288,6 +2313,10 @@
     if(tmp_string != NULL)
         sscanf(octstr_get_cstr(tmp_string),"%d", &rpi);
 
+    tmp_string = http_cgi_variable(args, "source-addr-ton");
+    if(tmp_string != NULL)
+      sscanf(octstr_get_cstr(tmp_string),"%d", &sb_source_addr_ton);
+
     tmp_string = http_cgi_variable(args, "alt-dcs");
     if(tmp_string != NULL)
         sscanf(octstr_get_cstr(tmp_string),"%d", &alt_dcs);
@@ -2329,7 +2358,7 @@
     return smsbox_req_handle(t, client_ip, from, to, text, charset, udh,
                             smsc, mclass, mwi, coding, compress, validity, 
                             deferred, status, dlr_mask, dlr_url, account,
-                            pid, alt_dcs, rpi, NULL, binfo);
+                            pid, alt_dcs, rpi, NULL, binfo, sb_source_addr_ton);
     
 }
 
@@ -2348,7 +2377,7 @@
     Octstr *text;
     Octstr *from, *to, *udh, *smsc, *charset, *dlr_url, *account, *binfo;
     int dlr_mask, mclass, mwi, coding, compress, validity, deferred;
-    int pid, alt_dcs, rpi;
+    int pid, alt_dcs, rpi, sb_source_addr_ton;
  
     text_html = octstr_imm("text/html");
     text_wml = octstr_imm("text/vnd.wap.wml");
@@ -2360,7 +2389,7 @@
     tolist = NULL;
     from = to = udh = smsc = account = dlr_url = charset = binfo = NULL;
     mclass = mwi = coding = compress = validity = deferred = dlr_mask = 
-        pid = alt_dcs = rpi = -1;
+        pid = alt_dcs = rpi = sb_source_addr_ton = -1;
  
     http_header_get_content_type(headers, &type, &charset);
     if (octstr_case_compare(type, text_html) == 0 ||
@@ -2374,7 +2403,7 @@
                                  &coding, &compress, &validity, 
                                  &deferred, &dlr_mask, &dlr_url, 
                                  &account, &pid, &alt_dcs, &rpi,
-                                 &binfo);
+                                 &binfo, &sb_source_addr_ton);
     } else if (octstr_case_compare(type, text_plain) == 0 ||
                octstr_case_compare(type, octet_stream) == 0) {
        get_x_kannel_from_headers(headers, &from, &to, &udh,
@@ -2382,13 +2411,13 @@
                                  &coding, &compress, &validity, 
                                  &deferred, &dlr_mask, &dlr_url, 
                                  &account, &pid, &alt_dcs, &rpi,
-                                 &binfo);
+                                 &binfo, &sb_source_addr_ton);
     } else if (octstr_case_compare(type, text_xml) == 0) {
        get_x_kannel_from_xml(mt_push, &type, &body, headers, 
                               &from, &to, &udh, &user, &pass, &smsc, &mclass, 
                              &mwi, &coding, &compress, &validity, &deferred,
                              &dlr_mask, &dlr_url, &account, &pid, &alt_dcs,
-                             &rpi, &tolist, &charset, &binfo);
+                             &rpi, &tolist, &charset, &binfo, &sb_source_addr_ton);
     } else {
        *status = HTTP_BAD_REQUEST;
        ret = octstr_create("Invalid content-type");
@@ -2438,7 +2467,7 @@
                                    udh, smsc, mclass, mwi, coding, compress, 
                                    validity, deferred, status, dlr_mask, 
                                    dlr_url, account, pid, alt_dcs, rpi, tolist,
-                                   binfo);
+                                   binfo, sb_source_addr_ton);
 
     }
 error2:
@@ -2479,11 +2508,11 @@
     XMLRPCMethodCall *msg;
 
     int        dlr_mask, mclass, mwi, coding, compress, validity, 
-       deferred, pid, alt_dcs, rpi;
+       deferred, pid, alt_dcs, rpi, sb_source_addr_ton;
 
     from = to = udh = smsc = account = dlr_url = charset = binfo = NULL;
     mclass = mwi = coding = compress = validity = deferred = dlr_mask = 
-        pid = alt_dcs = rpi = -1;
+        pid = alt_dcs = rpi = sb_source_addr_ton = -1;
  
     user = pass = ret = NULL;
 
Index: smsc/smsc_smpp.c
===================================================================
RCS file: /home/cvs/gateway/gw/smsc/smsc_smpp.c,v
retrieving revision 1.57
diff -u -r1.57 smsc_smpp.c
--- smsc/smsc_smpp.c    6 Nov 2003 12:56:25 -0000       1.57
+++ smsc/smsc_smpp.c    9 Nov 2003 00:57:19 -0000
@@ -480,12 +480,19 @@
         octstr_duplicate(msg->sms.binfo) : octstr_duplicate(smpp->service_type);
 
     /* Check for manual override of source ton and npi values */
-    if(smpp->source_addr_ton > -1 && smpp->source_addr_npi > -1) {
+    if(smpp->source_addr_ton > -1 && smpp->source_addr_npi > -1 && 
msg->sms.sb_source_addr_ton == -1) {
         pdu->u.submit_sm.source_addr_ton = smpp->source_addr_ton;
         pdu->u.submit_sm.source_addr_npi = smpp->source_addr_npi;
         debug("bb.sms.smpp", 0, "SMPP[%s]: Manually forced source addr ton = %d, 
source add npi = %d",
               octstr_get_cstr(smpp->conn->id), smpp->source_addr_ton,
               smpp->source_addr_npi);
+           } 
+    
+           else if(msg->sms.sb_source_addr_ton > -1) {
+      pdu->u.submit_sm.source_addr_ton = msg->sms.sb_source_addr_ton;
+      debug("bb.sms.smpp", 0, "SMPP[%s]: Manually forced source addr ton (on PSSH) = 
%d", octstr_get_cstr(smpp->conn->id), msg->sms.sb_source_addr_ton);
+    
+    
     } else {
         /* setup default values */
         pdu->u.submit_sm.source_addr_ton = GSM_ADDR_TON_NATIONAL; /* national */

Reply via email to