[PATCH] Local address patch

"Simon Beale" <[email protected]>
Newsgroups gmane.comp.mobile.kannel.devel
Message-ID <[email protected]>
Hi

This is a patch so that you can specify which local address an SMPP
connection goes out from, as currently, if you have multiple IP addresses on
an interface, you can't specify which address you wish to make the
connection from.

It uses an optional parameter 'our-host' in the SMPP configuration section
which takes an IP address as its argument.

Simon
kannel.our_host.diff (application/octet-stream, 4.5 KB)
Only in kannel-snapshot-ngame: config.cache
Only in kannel-snapshot-ngame: config.log
diff -u -r kannel-snapshot/doc/userguide/userguide.xml kannel-snapshot-ngame/doc/userguide/userguide.xml
--- kannel-snapshot/doc/userguide/userguide.xml	Thu Mar 21 03:54:32 2002
+++ kannel-snapshot-ngame/doc/userguide/userguide.xml	Thu Mar 21 17:52:42 2002
@@ -2225,6 +2225,7 @@
 smsc-password = foo
 system-type = "VMA"
 address-range = ""
+our-host = 123.45.56.78
 </programlisting>
 
 <informaltable frame=none>
@@ -2292,6 +2293,14 @@
        According to the SMPP 3.4 spec this is supposed to
        affect which MS's can send messages to this account.
        Doesn't seem to work, though.
+     </entry></row>
+
+   <row><entry><literal>our-host (m)</literal></entry>
+     <entry><literal>string</literal></entry>
+     <entry valign=bottom>
+       Specicy the outgoing address for connections
+       from a multihomed machine. If its not defined
+       it uses the default for the machine.
      </entry></row>
 
    </tbody></tgroup></informaltable>
Only in kannel-snapshot-ngame/gw: cscope.out
diff -u -r kannel-snapshot/gw/smsc_smpp.c kannel-snapshot-ngame/gw/smsc_smpp.c
--- kannel-snapshot/gw/smsc_smpp.c	Tue Jan 29 21:38:36 2002
+++ kannel-snapshot-ngame/gw/smsc_smpp.c	Thu Mar 21 15:31:42 2002
@@ -70,6 +70,7 @@
     Octstr *username;
     Octstr *password;
     Octstr *address_range;
+    Octstr *our_host;
     int transmit_port;
     int receive_port;
     int quitting;
@@ -80,7 +81,7 @@
 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, Octstr *our_host)
 {
     SMPP *smpp;
     
@@ -97,6 +98,7 @@
     smpp->username = octstr_duplicate(username);
     smpp->password = octstr_duplicate(password);
     smpp->address_range = octstr_duplicate(address_range);
+    smpp->our_host = octstr_duplicate(our_host);
     smpp->transmit_port = transmit_port;
     smpp->receive_port = receive_port;
     smpp->quitting = 0;
@@ -118,6 +120,7 @@
 	octstr_destroy(smpp->password);
 	octstr_destroy(smpp->system_type);
 	octstr_destroy(smpp->address_range);
+	octstr_destroy(smpp->our_host);
 	gw_free(smpp);
     }
 }
@@ -332,8 +335,7 @@
     SMPP_PDU *bind;
     Connection *conn;
 
-    conn = conn_open_tcp(smpp->host, smpp->transmit_port, NULL
-		    /* smpp->our_host */);
+    conn = conn_open_tcp(smpp->host, smpp->transmit_port, smpp->our_host );
     if (conn == NULL) {
     	error(0, "SMPP: Couldn't connect to server.");
 	return NULL;
@@ -368,8 +370,7 @@
     SMPP_PDU *bind;
     Connection *conn;
 
-    conn = conn_open_tcp(smpp->host, smpp->receive_port, NULL
-		    /* smpp->our_host */);
+    conn = conn_open_tcp(smpp->host, smpp->receive_port, smpp->our_host );
     if (conn == NULL) {
     	error(0, "SMPP: Couldn't connect to server.");
 	return NULL;
@@ -804,6 +805,7 @@
     Octstr *system_id;
     Octstr *system_type;
     Octstr *address_range;
+    Octstr *our_host;
     SMPP *smpp;
     int ok;
     
@@ -816,6 +818,7 @@
     password = cfg_get(grp, octstr_imm("smsc-password"));
     system_type = cfg_get(grp, octstr_imm("system-type"));
     address_range = cfg_get(grp, octstr_imm("address-range"));
+    our_host = cfg_get(grp, octstr_imm("our-host"));
     
     system_id = cfg_get(grp, octstr_imm("system-id"));
     if (system_id != NULL) {
@@ -845,7 +848,7 @@
     	return -1;
 
     smpp = smpp_create(conn, host, port, receive_port, system_type, 
-    	    	       username, password, address_range);
+    	    	       username, password, address_range, our_host);
     conn->data = smpp;
     conn->name = octstr_format("SMPP:%S:%d/%d:%S:%S", 
     	    	    	       host, port,
@@ -857,6 +860,7 @@
     octstr_destroy(password);
     octstr_destroy(system_type);
     octstr_destroy(address_range);
+    octstr_destroy(our_host);
 
     conn->status = SMSCCONN_CONNECTING;
       
Only in kannel-snapshot-ngame/gwlib: cscope.out
diff -u -r kannel-snapshot/gwlib/socket.c kannel-snapshot-ngame/gwlib/socket.c
--- kannel-snapshot/gwlib/socket.c	Mon Oct  8 20:43:04 2001
+++ kannel-snapshot-ngame/gwlib/socket.c	Thu Mar 21 16:24:21 2002
@@ -117,7 +117,7 @@
     addr.sin_port = htons(port);
     addr.sin_addr = *(struct in_addr *) hostinfo.h_addr;
 
-    if (our_port > 0) {
+    if (our_port > 0 || (interface_name != NULL && strcmp(interface_name, "*") != 0))  {
         int reuse;
 
         o_addr = empty_sockaddr_in;
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.