Hi all,

As some SMPP Servers requires this feature,
here is the patch.

Comments please ?

regards

--- gateway.orig/gw/smsc/smsc_smpp.c    2012-09-27 11:17:34.588403041 +0200
+++ gateway/gw/smsc/smsc_smpp.c 2012-10-10 11:27:16.195102206 +0200
@@ -149,6 +149,8 @@
     int source_addr_npi;
     int dest_addr_ton;
     int dest_addr_npi;
+    int our_port;
+    int our_receiver_port;
     long bind_addr_ton;
     long bind_addr_npi;
     int transmit_port;
@@ -213,7 +215,7 @@
 
 
 static SMPP *smpp_create(SMSCConn *conn, Octstr *host, int transmit_port,
-                         int receive_port, Octstr *system_type,
+                         int receive_port, int our_port, int 
our_receiver_port, Octstr *system_type,
                          Octstr *username, Octstr *password,
                          Octstr *address_range,
                          int source_addr_ton, int source_addr_npi,
@@ -238,6 +240,8 @@
     counter_increase(smpp->message_id_counter);
     smpp->host = octstr_duplicate(host);
     smpp->system_type = octstr_duplicate(system_type);
+    smpp->our_port = our_port;
+    smpp->our_receiver_port = our_receiver_port;
     smpp->username = octstr_duplicate(username);
     smpp->password = octstr_duplicate(password);
     smpp->address_range = octstr_duplicate(address_range);
@@ -686,7 +690,7 @@
         case 0x00: /* default SMSC alphabet */
             /*
              * try to convert from something interesting if specified so
-             * unless it was specified binary, ie. UDH indicator was detected
+             * unless it was specified binary, i.e. UDH indicator was detected
              */
             if (smpp->alt_charset && msg->sms.coding != DC_8BIT) {
                 if (charset_convert(msg->sms.msgdata, 
octstr_get_cstr(smpp->alt_charset), SMPP_DEFAULT_CHARSET) != 0)
@@ -1127,7 +1131,12 @@
         conn = conn_open_ssl(smpp->host, smpp->transmit_port, 
smpp->ssl_client_certkey_file, smpp->conn->our_host);
     else
 #endif
+
+    if (smpp->our_port > 0)
+        conn = conn_open_tcp_with_port(smpp->host, smpp->transmit_port, 
smpp->our_port, smpp->conn->our_host );
+    else
         conn = conn_open_tcp(smpp->host, smpp->transmit_port, 
smpp->conn->our_host);
+
     if (conn == NULL) {
         error(0, "SMPP[%s]: Couldn't connect to server.",
               octstr_get_cstr(smpp->conn->id));
@@ -1175,7 +1184,12 @@
         conn = conn_open_ssl(smpp->host, smpp->transmit_port, 
smpp->ssl_client_certkey_file, smpp->conn->our_host);
     else
 #endif
+
+    if (smpp->our_port > 0)
+       conn = conn_open_tcp_with_port(smpp->host, smpp->transmit_port, 
smpp->our_port, smpp->conn->our_host );  
+    else
         conn = conn_open_tcp(smpp->host, smpp->transmit_port, 
smpp->conn->our_host);
+
     if (conn == NULL) {
        error(0, "SMPP[%s]: Couldn't connect to server.",
              octstr_get_cstr(smpp->conn->id));
@@ -1221,7 +1235,12 @@
         conn = conn_open_ssl(smpp->host, smpp->receive_port, 
smpp->ssl_client_certkey_file, smpp->conn->our_host);
     else
 #endif
+
+    if (smpp->our_receiver_port > 0)
+        conn = conn_open_tcp_with_port(smpp->host, smpp->receive_port, 
smpp->our_receiver_port, smpp->conn->our_host);
+    else
         conn = conn_open_tcp(smpp->host, smpp->receive_port, 
smpp->conn->our_host);
+
     if (conn == NULL) {
         error(0, "SMPP[%s]: Couldn't connect to server.",
               octstr_get_cstr(smpp->conn->id));
@@ -2242,6 +2261,8 @@
     long source_addr_npi;
     long dest_addr_ton;
     long dest_addr_npi;
+    long our_port;
+    long our_receiver_port;
     Octstr *my_number;
     Octstr *service_type;
     SMPP *smpp;
@@ -2269,6 +2290,12 @@
         port = 0;
     if (cfg_get_integer(&receive_port, grp, octstr_imm("receive-port")) == -1)
         receive_port = 0;
+
+    if (cfg_get_integer(&our_port, grp, octstr_imm("our-port")) == -1)
+        our_port = 0;
+    if (cfg_get_integer(&our_receiver_port, grp, 
octstr_imm("our-receiver-port")) == -1)
+        our_receiver_port = 0;
+
     cfg_get_bool(&transceiver_mode, grp, octstr_imm("transceiver-mode"));
     username = cfg_get(grp, octstr_imm("smsc-username"));
     password = cfg_get(grp, octstr_imm("smsc-password"));
@@ -2403,7 +2430,7 @@
         esm_class = ESM_CLASS_SUBMIT_STORE_AND_FORWARD_MODE;
     }
 
-    smpp = smpp_create(conn, host, port, receive_port, system_type,
+    smpp = smpp_create(conn, host, port, receive_port, our_port, 
our_receiver_port, system_type,
                        username, password, address_range,
                        source_addr_ton, source_addr_npi, dest_addr_ton,
                        dest_addr_npi, enquire_link_interval,


--- gateway.orig/gwlib/cfg.def  2012-10-10 11:29:23.525226267 +0200
+++ gateway/gwlib/cfg.def       2012-10-10 11:30:55.042102636 +0200
@@ -337,6 +337,7 @@
     OCTSTR(validityperiod)
     OCTSTR(our-port)
     OCTSTR(receive-port)
+    OCTSTR(our-receiver-port)
     OCTSTR(connect-allow-ip)
     OCTSTR(system-id)
     OCTSTR(system-type)

Reply via email to