I just had to do this for the carrier I'm connecting to here (had to force 
combinations that the autodetect didn't support) so the patch against cvs 
is attached. As per current behaviour, if you don't specify it it is 
automatically detected from the to number.

Here's an example group for the config files

igroup=smsc
smsc=smpp
smsc-id=CARRIER
host=XXX.XXX.XXX.XXX
port=999
receive-port=999
smsc-username=USERNAME
smsc-password=PASSWORD
system-type=""
address-range=""
source_addr_ton=0
source_addr_npi=0
dest_addr_ton=1
dest_addr_npi=1
connect-allow-ip = 127.0.0.1

Hope this helps

Alex

http://www.enpocket.com

On Tue, 29 Jan 2002, Andreas Fink wrote:

> >Peter L�fman wrote:
> >>
> >>  Hi,
> >>
> >>  well I solved the problem by re-compiling with the ton set to 0.
> >>  It might be possible that 1 (international) will work also, I have 
> >>not tested yet.
> >>  But with 2 (national) it did not work.
> >
> >so, how about setting this ton variable by a configuration directive
> >within the smsc group?!
> 
> well TON usually have to be set to specific values for specific types 
> of numbers. The current code does set it to 1 for international 
> numbers (the ones who start with +) and 2 for others (assuming they 
> are national) and to 0 for alphanumeric ones. The point is that in 
> kannel there's no representation for TON so we have to assume 
> something. Setting it to a fixed value only makes sense if we always 
> send international numbers or always nationals etc. In my case, I'm 
> always sending international but I might reply to national ones when 
> I get them from the SMSC as such (polling).
> 
> So its not just adding a configuration directive to say TON=value 
> because in some cases you need to set it. Its more like a behaviour. 
> So in the mentioned case it might work out ok if a + is added to the 
> number (the code removes it afterwards).
> 

-- 
Alex Judd
http://www.enpocket.com/
Index: gw/smsc_smpp.c
===================================================================
RCS file: /home/cvs/gateway/gw/smsc_smpp.c,v
retrieving revision 1.50
diff -u -r1.50 smsc_smpp.c
--- gw/smsc_smpp.c      2002/01/28 15:12:13     1.50
+++ gw/smsc_smpp.c      2002/01/29 18:29:37
@@ -70,6 +70,10 @@
     Octstr *username;
     Octstr *password;
     Octstr *address_range;
+    int source_addr_ton;
+    int source_addr_npi;
+    int dest_addr_ton;
+    int dest_addr_npi;
     int transmit_port;
     int receive_port;
     int quitting;
@@ -80,7 +84,9 @@
 static SMPP *smpp_create(SMSCConn *conn, Octstr *host, int transmit_port, 
                         int receive_port, Octstr *system_type, 
                         Octstr *username, Octstr *password,
-                        Octstr *address_range)
+                        Octstr *address_range, int source_addr_ton,
+                         int source_addr_npi, int dest_addr_ton,
+                         int dest_addr_npi)
 {
     SMPP *smpp;
     
@@ -97,6 +103,10 @@
     smpp->username = octstr_duplicate(username);
     smpp->password = octstr_duplicate(password);
     smpp->address_range = octstr_duplicate(address_range);
+    smpp->source_addr_ton = source_addr_ton;
+    smpp->source_addr_npi = source_addr_npi;
+    smpp->dest_addr_ton = dest_addr_ton;
+    smpp->dest_addr_npi = dest_addr_npi;
     smpp->transmit_port = transmit_port;
     smpp->receive_port = receive_port;
     smpp->quitting = 0;
@@ -207,33 +217,45 @@
     pdu = smpp_pdu_create(submit_sm, 
                          counter_increase(smpp->message_id_counter));
                   
-    pdu->u.submit_sm.dest_addr_ton = GSM_ADDR_TON_NATIONAL; /* national */
-    pdu->u.submit_sm.source_addr_ton = GSM_ADDR_TON_NATIONAL; /* national */
-    pdu->u.submit_sm.source_addr_npi = GSM_ADDR_NPI_E164; /* ISDN number plan */
-    pdu->u.submit_sm.dest_addr_npi = GSM_ADDR_NPI_E164; /* ISDN number plan */
-    
     pdu->u.submit_sm.source_addr = octstr_duplicate(msg->sms.sender);
     pdu->u.submit_sm.destination_addr = octstr_duplicate(msg->sms.receiver);
+
+    /* 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;
+        pdu->u.submit_sm.source_addr_npi = smpp->source_addr_npi;
+    } else {
+        pdu->u.submit_sm.source_addr_ton = GSM_ADDR_TON_NATIONAL; /* national */
+        pdu->u.submit_sm.source_addr_npi = GSM_ADDR_NPI_E164; /* ISDN number plan */
  
-    /* lets see if its international or alphanumeric sender */
-    if( octstr_get_char(pdu->u.submit_sm.source_addr,0) == '+') {
-        if (!octstr_check_range(pdu->u.submit_sm.source_addr, 1, 256, gw_isdigit)) {
-           pdu->u.submit_sm.source_addr_ton = GSM_ADDR_TON_ALPHANUMERIC; /* alphanum 
*/
-           pdu->u.submit_sm.source_addr_npi = GSM_ADDR_NPI_UNKNOWN;
-       }
-        else {
-           /* numeric sender address with + in front -> international*/
-           octstr_delete(pdu->u.submit_sm.source_addr,0,1);
-           pdu->u.submit_sm.source_addr_ton = GSM_ADDR_TON_INTERNATIONAL;
-       }
-    }
-    else    {
-       if (!octstr_check_range(pdu->u.submit_sm.source_addr,0, 256, gw_isdigit)) {
-           pdu->u.submit_sm.source_addr_ton = GSM_ADDR_TON_ALPHANUMERIC;
-           pdu->u.submit_sm.source_addr_npi = GSM_ADDR_NPI_UNKNOWN;
-       }
+        /* lets see if its international or alphanumeric sender */
+        if( octstr_get_char(pdu->u.submit_sm.source_addr,0) == '+') {
+            if (!octstr_check_range(pdu->u.submit_sm.source_addr, 1, 256, 
+gw_isdigit)) {
+               pdu->u.submit_sm.source_addr_ton = GSM_ADDR_TON_ALPHANUMERIC; /* 
+alphanum */
+               pdu->u.submit_sm.source_addr_npi = GSM_ADDR_NPI_UNKNOWN;
+               }
+            else {
+               /* numeric sender address with + in front -> international*/
+               octstr_delete(pdu->u.submit_sm.source_addr,0,1);
+               pdu->u.submit_sm.source_addr_ton = GSM_ADDR_TON_INTERNATIONAL;
+           }
+        }
+        else    {
+           if (!octstr_check_range(pdu->u.submit_sm.source_addr,0, 256, gw_isdigit)) 
+{
+               pdu->u.submit_sm.source_addr_ton = GSM_ADDR_TON_ALPHANUMERIC;
+               pdu->u.submit_sm.source_addr_npi = GSM_ADDR_NPI_UNKNOWN;
+           }
+        }
+    } 
+
+    /* Check for manual override of destination ton and npi values */
+    if(smpp->dest_addr_ton > -1 && smpp->dest_addr_npi > -1) {
+        pdu->u.submit_sm.dest_addr_ton = smpp->dest_addr_ton;
+        pdu->u.submit_sm.dest_addr_npi = smpp->dest_addr_npi;
+    } else {
+        pdu->u.submit_sm.dest_addr_ton = GSM_ADDR_TON_NATIONAL; /* national */
+        pdu->u.submit_sm.dest_addr_npi = GSM_ADDR_NPI_E164; /* ISDN number plan */
     }
-    
 
     /* if its a international number starting with +, lets remove the
        '+' and set number type to international instead */
@@ -242,20 +264,18 @@
        pdu->u.submit_sm.dest_addr_ton = 1; /* international */
     }
 
-    pdu->u.submit_sm.data_coding = fields_to_dcs(msg, 0);
-
     if (octstr_len(msg->sms.udhdata)) {
        pdu->u.submit_sm.short_message =
            octstr_format("%S%S", msg->sms.udhdata, msg->sms.msgdata);
        pdu->u.submit_sm.esm_class = SMPP_ESM_CLASS_UDH_INDICATOR;
     } else {
        pdu->u.submit_sm.short_message = octstr_duplicate(msg->sms.msgdata);
-       if(pdu->u.submit_sm.data_coding == 0 ) /*no reencoding for unicode! */
-          charset_latin1_to_gsm(pdu->u.submit_sm.short_message);               
+       charset_latin1_to_gsm(pdu->u.submit_sm.short_message);          
     }
     /* ask for the delivery reports if needed */
     if (msg->sms.dlr_mask & (DLR_SUCCESS|DLR_FAIL))
        pdu->u.submit_sm.registered_delivery = 1; 
+    pdu->u.submit_sm.data_coding = fields_to_dcs(msg, 0);
 
     return pdu;
 }
@@ -774,8 +794,8 @@
     smpp = conn->data;
     smpp->quitting = 1;
     gwthread_wakeup(smpp->transmitter);
-    gwthread_wakeup(smpp->receiver);
     gwthread_join(smpp->transmitter);
+    gwthread_wakeup(smpp->receiver);
     gwthread_join(smpp->receiver);
     smpp_destroy(smpp);
     
@@ -803,6 +823,10 @@
     Octstr *system_id;
     Octstr *system_type;
     Octstr *address_range;
+    long source_addr_ton;
+    long source_addr_npi;
+    long dest_addr_ton;
+    long dest_addr_npi;
     SMPP *smpp;
     int ok;
     
@@ -826,9 +850,19 @@
        } else
            octstr_destroy(system_id);
     }
+
+    /* if the ton and npi values are forced, set them, else set them to -1 */
+    cfg_get_integer(&source_addr_ton, grp, octstr_imm("source_addr_ton"));
+    cfg_get_integer(&source_addr_npi, grp, octstr_imm("source_addr_npi"));
+    cfg_get_integer(&dest_addr_ton, grp, octstr_imm("dest_addr_ton"));
+    cfg_get_integer(&dest_addr_npi, grp, octstr_imm("dest_addr_npi"));
     
     /* Check that config is OK */
     ok = 1;
+    if (host == NULL) {
+        error(0,"SMPP: Configuration file doesn't specify host");
+        ok = 0;
+    }
     if (username == NULL) {
        error(0, "SMPP: Configuration file doesn't specify username.");
        ok = 0;
@@ -841,7 +875,8 @@
        return -1;
 
     smpp = smpp_create(conn, host, port, receive_port, system_type, 
-                      username, password, address_range);
+                      username, password, address_range, source_addr_ton,
+                       source_addr_npi, dest_addr_ton, dest_addr_npi);
     conn->data = smpp;
     conn->name = octstr_format("SMPP:%S:%d/%d:%S:%S", 
                               host, port,
Index: gwlib/cfg.def
===================================================================
RCS file: /home/cvs/gateway/gwlib/cfg.def,v
retrieving revision 1.37
diff -u -r1.37 cfg.def
--- gwlib/cfg.def       2002/01/26 23:17:49     1.37
+++ gwlib/cfg.def       2002/01/29 18:29:37
@@ -183,6 +183,10 @@
     OCTSTR(idle-timeout)
     OCTSTR(no-sep)
     OCTSTR(appname)
+    OCTSTR(source_addr_ton)
+    OCTSTR(source_addr_npi)
+    OCTSTR(dest_addr_ton)
+    OCTSTR(dest_addr_npi)
 )
 
 

Reply via email to