Hi All

While setting up a LVS environment we found the need to have Kannel bind to 
a particlar interface. Here are patches to make the http admin, and sendsms 
http servers bind to an optional specific interface.

Files modified: http.c, http.h, bb_http.c, smsbox.c

added following configs:
smsbox group
     sendsms-interface
core
     admin-interface


Nisan

--- cvs/gateway/gwlib/http.h    Fri Apr 26 12:39:19 2002
+++ ./gwlib/http.h    Wed Jul 10 20:34:09 2002
@@ -273,6 +273,11 @@
   */
  int http_open_port(int port, int ssl);

+/*
+* Same as http_open_port except that it binds to a particular
+* interface
+*/
+int http_open_port_if(int port, int ssl, Octstr *interface);

  /*
   * Accept a request from a client to the specified open port. Return NULL



--- cvs/gateway/gwlib/http.c    Thu Jun 13 14:54:14 2002
+++ ./gwlib/http.c    Wed Jul 10 20:33:27 2002
@@ -1821,16 +1821,19 @@
  }


-int http_open_port(int port, int ssl)
+int http_open_port_if(int port, int ssl, Octstr *interface)
  {
+
      struct server *p;

-    if (ssl) debug("gwlib.http", 0, "HTTP: Opening SSL server at port 
%d.", port);
-    else debug("gwlib.http", 0, "HTTP: Opening server at port %d.", port);
+    if (ssl) debug("gwlib.http", 0, "HTTP: Opening SSL server at port %d. 
Interface %s", port,
+ 
interface==NULL?"ANY":octstr_get_cstr(interface));
+    else debug("gwlib.http", 0, "HTTP: Opening server at port %d. 
Interface %s", port,
+ 
interface==NULL?"ANY":octstr_get_cstr(interface));
      p = gw_malloc(sizeof(*p));
      p->port = port;
      p->ssl = ssl;
-    p->fd = make_server_socket(port, NULL);
+    p->fd = make_server_socket(port, 
interface==NULL?NULL:octstr_get_cstr(interface));
         /* XXX add interface_name if required */
      if (p->fd == -1) {
         gw_free(p);
@@ -1844,8 +1847,14 @@
      gwthread_wakeup(server_thread_id);

      return 0;
+
+
  }

+int http_open_port(int port, int ssl)
+{
+    return http_open_port_if(port,ssl,NULL);
+}

  void http_close_port(int port)
  {



--- cvs/gateway/gw/bb_http.c    Wed May 29 07:12:11 2002
+++ ./bb_http.c Wed Jul 10 21:02:53 2002
@@ -24,6 +24,7 @@
  static volatile sig_atomic_t httpadmin_running;

  static long    ha_port;
+static Octstr *ha_interface;
  static Octstr  *ha_password;
  static Octstr  *ha_status_pw;
  static Octstr  *ha_allow_ip;
@@ -348,6 +349,8 @@
      if (cfg_get_integer(&ha_port, grp, octstr_imm("admin-port")) == -1)
         panic(0, "Missing admin-port variable, cannot start HTTP admin");

+    ha_interface = cfg_get(grp, octstr_imm("admin-interface"));
+
      ha_password = cfg_get(grp, octstr_imm("admin-password"));
      if (ha_password == NULL)
         panic(0, "You MUST set HTTP admin-password");
@@ -382,7 +385,7 @@
      octstr_destroy(ssl_server_key_file);
  #endif /* HAVE_LIBSSL */

-    http_open_port(ha_port, ssl);
+    http_open_port_if(ha_port, ssl, ha_interface);

      if (gwthread_create(httpadmin_run, NULL) == -1)
         panic(0, "Failed to start a new thread for HTTP admin");
@@ -397,6 +400,7 @@
      http_close_all_ports();
      gwthread_join_every(httpadmin_run);
      octstr_destroy(ha_password);
+    octstr_destroy(ha_interface);
      octstr_destroy(ha_status_pw);
      octstr_destroy(ha_allow_ip);
      octstr_destroy(ha_deny_ip);


--- cvs/gateway/gw/smsbox.c     Thu Jun 13 14:54:13 2002
+++ ./smsbox.c  Wed Jul 10 21:50:33 2002
@@ -42,6 +42,7 @@
  static int bb_ssl = 0;
  static long sendsms_port = 0;
  static Octstr *sendsms_url = NULL;
+static Octstr *sendsms_interface = NULL;
  static Octstr *sendota_url = NULL;
  static Octstr *xmlrpc_url = NULL;
  static Octstr *bb_host;
@@ -2774,6 +2775,8 @@
      }

      cfg_get_integer(&sendsms_port, grp, octstr_imm("sendsms-port"));
+       sendsms_interface= cfg_get(grp, octstr_imm("sendsms-interface"));
+
      cfg_get_integer(&sms_max_length, grp, octstr_imm("sms-length"));

  #ifdef HAVE_LIBSSL
@@ -2817,7 +2820,7 @@
      }

      if (sendsms_port > 0) {
-       if (http_open_port(sendsms_port, ssl) == -1) {
+       if (http_open_port_if(sendsms_port, ssl,sendsms_interface) == -1) {
             if (only_try_http)
                 error(0, "Failed to open HTTP socket, ignoring it");
             else
@@ -2934,6 +2937,7 @@
      octstr_destroy(reply_requestfailed);
      octstr_destroy(reply_couldnotfetch);
      octstr_destroy(reply_couldnotrepresent);
+       octstr_destroy(sendsms_interface);
      numhash_destroy(black_list);
      numhash_destroy(white_list);
      cfg_destroy(cfg);






Reply via email to