Re :Re: dynamic rescan of SMSC configuration

"Manish Nema" <[email protected]>
Newsgroups gmane.comp.mobile.kannel.devel
Message-ID <1245400453.S.8012.58533.f4mail-235-210.rediffmail.com.old.1245406368.54958@webmail.rediffmail.com>
Hi Alejandro, &nbsp;Please find attached cvs diff -u taken on cvs HEAD.Thanks,Manish NemaOn Fri, 19 Jun 2009 10:35:44 +0200 Alejandro Guerrieri  wrote  Manish,  Please send a diff -u of what you've done and we'll take a look at it&nbsp;in&nbsp;context. Also please base it on the latest CVS HEAD.  Regards,   --Alejandro [email protected]    On 19/06/2009, at 10:03, Manish Nema wrote:&nbsp;Earlier I have posted the requirement for dynamic rescan of SMSC configuration at kannel users mail group,   &nbsp;  &nbsp;Thanks Alejandro for all help.     I thought to write few lines for the requirements, here is how I have done that    1) in bb_smscconn.c i have created a function int rescan_smsc(), please find the attached bb_smscconn.c    2) created one global Octstr* gCfgFilename in be
 arerbox.c and initialize it in main   if (argv[cf_index] == NULL)  &nbsp;&nbsp;&nbsp; {  &nbsp;&nbsp; &nbsp;&nbsp;&nbsp; &nbsp;gCfgFilename = octstr_create("kannel.conf");  &nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; filename = octstr_create("kannel.conf");  &nbsp;&nbsp;&nbsp; }  &nbsp;&nbsp;&nbsp; else  &nbsp;&nbsp;&nbsp; {  &nbsp;&nbsp; &nbsp;&nbsp;&nbsp; &nbsp;gCfgFilename = octstr_create(argv[cf_index]);  &nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; filename = octstr_create(argv[cf_index]);  &nbsp;&nbsp;&nbsp; }    &nbsp;This is to store configuration file name on bearbox startup  &nbsp;  3) added following in bb_http.c     &nbsp; a) added   &nbsp;&nbsp;&nbsp;&nbsp;&nbsp; { "reload-smsc",httpd_reload_smscs },  &nbsp;&nbsp; in httpd_commands    &nbsp;b)&nbsp; created function httpd_reloa
 d_smscs    &nbsp;&nbsp;&nbsp;&nbsp;&nbsp; &nbsp;&nbsp;&nbsp; static Octstr *httpd_reload_smscs(List *cgivars, int status_type)  &nbsp;&nbsp;&nbsp; {  &nbsp;&nbsp;&nbsp; &nbsp;&nbsp;&nbsp; &nbsp;&nbsp;&nbsp; Octstr *reply;  &nbsp;&nbsp;&nbsp; &nbsp;&nbsp;&nbsp; &nbsp;&nbsp;&nbsp; if ((reply = httpd_check_authorization(cgivars, 0))!= NULL) return reply;  &nbsp;&nbsp;&nbsp; &nbsp;&nbsp;&nbsp; &nbsp;&nbsp;&nbsp; if ((reply = httpd_check_status())!= NULL) return reply;    &nbsp;&nbsp;&nbsp; &nbsp;&nbsp;&nbsp; &nbsp;&nbsp;&nbsp; if (rescan_smsc() == -1)  &nbsp;&nbsp;&nbsp; &nbsp;&nbsp;&nbsp; &nbsp;&nbsp;&nbsp; &nbsp;&nbsp;&nbsp; return octstr_create("Could not re-load SMSC configuration");  &nbsp;&nbsp;&nbsp; &nbsp;&nbsp;&nbsp; &nbsp;&nbsp;&nbsp; else  &nbsp;&nbsp;&nbsp; &nbsp;&nbsp;&nbsp; &nb
 sp;&nbsp;&nbsp; &nbsp;&nbsp;&nbsp; return octstr_create("Successfully rescanned SMSC configuration");      &nbsp;&nbsp;&nbsp; }&nbsp;&nbsp;&nbsp;     &nbsp;I am not sure that if the implementation of rescan_smsc() is 100% correct/valid/safe, I request all the expert/developers&nbsp; to please give their suggestion/feedback.    It wish if this requirement can be implemented in future releases of the kannel.    Thanks,  Manish Nema
HEAD_diff_kannel.txt (text/plain, english, 43.6 KB)
? HEAD_diff_kannel.txt
Index: gw/bb_http.c
===================================================================
RCS file: /home/cvs/gateway/gw/bb_http.c,v
retrieving revision 1.53
diff -u -r1.53 bb_http.c
--- gw/bb_http.c	12 Jan 2009 16:46:56 -0000	1.53
+++ gw/bb_http.c	19 Jun 2009 10:10:52 -0000
@@ -1,58 +1,58 @@
-/* ==================================================================== 
- * The Kannel Software License, Version 1.0 
- * 
- * Copyright (c) 2001-2009 Kannel Group  
- * Copyright (c) 1998-2001 WapIT Ltd.   
- * All rights reserved. 
- * 
- * Redistribution and use in source and binary forms, with or without 
- * modification, are permitted provided that the following conditions 
- * are met: 
- * 
- * 1. Redistributions of source code must retain the above copyright 
- *    notice, this list of conditions and the following disclaimer. 
- * 
- * 2. Redistributions in binary form must reproduce the above copyright 
- *    notice, this list of conditions and the following disclaimer in 
- *    the documentation and/or other materials provided with the 
- *    distribution. 
- * 
- * 3. The end-user documentation included with the redistribution, 
- *    if any, must include the following acknowledgment: 
- *       "This product includes software developed by the 
- *        Kannel Group (http://www.kannel.org/)." 
- *    Alternately, this acknowledgment may appear in the software itself, 
- *    if and wherever such third-party acknowledgments normally appear. 
- * 
- * 4. The names "Kannel" and "Kannel Group" must not be used to 
- *    endorse or promote products derived from this software without 
- *    prior written permission. For written permission, please  
- *    contact [email protected]. 
- * 
- * 5. Products derived from this software may not be called "Kannel", 
- *    nor may "Kannel" appear in their name, without prior written 
- *    permission of the Kannel Group. 
- * 
- * THIS SOFTWARE IS PROVIDED ``AS IS'' AND ANY EXPRESSED OR IMPLIED 
- * WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES 
- * OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE 
- * DISCLAIMED.  IN NO EVENT SHALL THE KANNEL GROUP OR ITS CONTRIBUTORS 
- * BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY,  
- * OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT  
- * OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR  
- * BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY,  
- * WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE  
- * OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE,  
- * EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. 
- * ==================================================================== 
- * 
- * This software consists of voluntary contributions made by many 
- * individuals on behalf of the Kannel Group.  For more information on  
- * the Kannel Group, please see <http://www.kannel.org/>. 
- * 
- * Portions of this software are based upon software originally written at  
- * WapIT Ltd., Helsinki, Finland for the Kannel project.  
- */ 
+/* ====================================================================
+ * The Kannel Software License, Version 1.0
+ *
+ * Copyright (c) 2001-2009 Kannel Group
+ * Copyright (c) 1998-2001 WapIT Ltd.
+ * All rights reserved.
+ *
+ * Redistribution and use in source and binary forms, with or without
+ * modification, are permitted provided that the following conditions
+ * are met:
+ *
+ * 1. Redistributions of source code must retain the above copyright
+ *    notice, this list of conditions and the following disclaimer.
+ *
+ * 2. Redistributions in binary form must reproduce the above copyright
+ *    notice, this list of conditions and the following disclaimer in
+ *    the documentation and/or other materials provided with the
+ *    distribution.
+ *
+ * 3. The end-user documentation included with the redistribution,
+ *    if any, must include the following acknowledgment:
+ *       "This product includes software developed by the
+ *        Kannel Group (http://www.kannel.org/)."
+ *    Alternately, this acknowledgment may appear in the software itself,
+ *    if and wherever such third-party acknowledgments normally appear.
+ *
+ * 4. The names "Kannel" and "Kannel Group" must not be used to
+ *    endorse or promote products derived from this software without
+ *    prior written permission. For written permission, please
+ *    contact [email protected].
+ *
+ * 5. Products derived from this software may not be called "Kannel",
+ *    nor may "Kannel" appear in their name, without prior written
+ *    permission of the Kannel Group.
+ *
+ * THIS SOFTWARE IS PROVIDED ``AS IS'' AND ANY EXPRESSED OR IMPLIED
+ * WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES
+ * OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE
+ * DISCLAIMED.  IN NO EVENT SHALL THE KANNEL GROUP OR ITS CONTRIBUTORS
+ * BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY,
+ * OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT
+ * OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR
+ * BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY,
+ * WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE
+ * OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE,
+ * EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
+ * ====================================================================
+ *
+ * This software consists of voluntary contributions made by many
+ * individuals on behalf of the Kannel Group.  For more information on
+ * the Kannel Group, please see <http://www.kannel.org/>.
+ *
+ * Portions of this software are based upon software originally written at
+ * WapIT Ltd., Helsinki, Finland for the Kannel project.
+ */
 
 /*
  * bb_http.c : bearerbox http adminstration commands
@@ -136,7 +136,7 @@
 	    	    	     "save the sheeps");
     return NULL;
 }
-    
+
 static Octstr *httpd_status(List *cgivars, int status_type)
 {
     Octstr *reply;
@@ -156,10 +156,10 @@
     Octstr *reply;
     Octstr *level;
     int new_loglevel;
-    
+
     if ((reply = httpd_check_authorization(cgivars, 0))!= NULL) return reply;
     if ((reply = httpd_check_status())!= NULL) return reply;
- 
+
     /* check if new loglevel is given */
     level = http_cgi_variable(cgivars, "level");
     if (level) {
@@ -214,7 +214,7 @@
     Octstr *reply;
     if ((reply = httpd_check_authorization(cgivars, 0))!= NULL) return reply;
     if ((reply = httpd_check_status())!= NULL) return reply;
- 
+
     if (bb_resume() == -1)
 	return octstr_create("Already running");
     else
@@ -226,7 +226,7 @@
     Octstr *reply;
     if ((reply = httpd_check_authorization(cgivars, 0))!= NULL) return reply;
     if ((reply = httpd_check_status())!= NULL) return reply;
- 
+
     if (bb_status == BB_SHUTDOWN) {
         bb_status = BB_DEAD;
         gwthread_wakeup_all();
@@ -289,13 +289,30 @@
     Octstr *reply;
     if ((reply = httpd_check_authorization(cgivars, 0))!= NULL) return reply;
     if ((reply = httpd_check_status())!= NULL) return reply;
- 
+
     if (bb_reload_lists() == -1)
         return octstr_create("Could not re-load lists");
     else
         return octstr_create("Black/white lists re-loaded");
 }
 
+/*
+ * Manish Nema 18-06-2009, reload of smsc configuration
+ */
+static Octstr *httpd_reload_smscs(List *cgivars, int status_type)
+{
+		Octstr *reply;
+	    if ((reply = httpd_check_authorization(cgivars, 0))!= NULL) return reply;
+	    if ((reply = httpd_check_status())!= NULL) return reply;
+
+	    if (rescan_smsc() == -1)
+			return octstr_create("Could not re-load SMSC configuration");
+		else
+			return octstr_create("Successfully rescanned SMSC configuration");
+
+
+}
+
 /* Known httpd commands and their functions */
 static struct httpd_command {
     const char *command;
@@ -313,6 +330,7 @@
     { "stop-smsc", httpd_stop_smsc },
     { "start-smsc", httpd_restart_smsc },
     { "reload-lists", httpd_reload_lists },
+    { "reload-smsc",httpd_reload_smscs }, // Manish Nema : for reloading of smsc configuration 18-06-2009
     { NULL , NULL } /* terminate list */
 };
 
@@ -414,7 +432,7 @@
     final_reply = octstr_create(header);
     octstr_append(final_reply, reply);
     octstr_append_cstr(final_reply, footer);
-    
+
     /* debug("bb.http", 0, "Result: '%s'", octstr_get_cstr(final_reply));
      */
     http_destroy_headers(headers);
@@ -441,7 +459,7 @@
     while(bb_status != BB_DEAD) {
 	if (bb_status == BB_SHUTDOWN)
 	    bb_shutdown();
-    	client = http_accept_request(ha_port, &ip, &url, &headers, &body, 
+    	client = http_accept_request(ha_port, &ip, &url, &headers, &body,
 	    	    	    	     &cgivars);
 	if (client == NULL)
 	    break;
@@ -467,12 +485,12 @@
 int httpadmin_start(Cfg *cfg)
 {
     CfgGroup *grp;
-    int ssl = 0; 
+    int ssl = 0;
 #ifdef HAVE_LIBSSL
     Octstr *ssl_server_cert_file;
     Octstr *ssl_server_key_file;
 #endif /* HAVE_LIBSSL */
-    
+
     if (httpadmin_running) return -1;
 
 
@@ -484,7 +502,7 @@
     ha_password = cfg_get(grp, octstr_imm("admin-password"));
     if (ha_password == NULL)
 	panic(0, "You MUST set HTTP admin-password");
-    
+
     ha_status_pw = cfg_get(grp, octstr_imm("status-password"));
 
     ha_allow_ip = cfg_get(grp, octstr_imm("admin-allow-ip"));
@@ -492,19 +510,19 @@
 
 #ifdef HAVE_LIBSSL
     cfg_get_bool(&ssl, grp, octstr_imm("admin-port-ssl"));
-    
+
     /*
      * check if SSL is desired for HTTP servers and then
-     * load SSL client and SSL server public certificates 
+     * load SSL client and SSL server public certificates
      * and private keys
-     */    
+     */
     ssl_server_cert_file = cfg_get(grp, octstr_imm("ssl-server-cert-file"));
     ssl_server_key_file = cfg_get(grp, octstr_imm("ssl-server-key-file"));
     if (ssl_server_cert_file != NULL && ssl_server_key_file != NULL) {
         /* we are fine here, the following call is now in conn_config_ssl(),
          * so there is no reason to do this twice.
 
-        use_global_server_certkey_file(ssl_server_cert_file, 
+        use_global_server_certkey_file(ssl_server_cert_file,
             ssl_server_key_file);
         */
     } else if (ssl) {
@@ -529,7 +547,7 @@
 {
     http_close_all_ports();
     gwthread_join_every(httpadmin_run);
-    octstr_destroy(ha_interface);    
+    octstr_destroy(ha_interface);
     octstr_destroy(ha_password);
     octstr_destroy(ha_status_pw);
     octstr_destroy(ha_allow_ip);
Index: gw/bb_smscconn.c
===================================================================
RCS file: /home/cvs/gateway/gw/bb_smscconn.c,v
retrieving revision 1.101
diff -u -r1.101 bb_smscconn.c
--- gw/bb_smscconn.c	6 May 2009 18:47:34 -0000	1.101
+++ gw/bb_smscconn.c	19 Jun 2009 10:10:52 -0000
@@ -1,58 +1,58 @@
-/* ==================================================================== 
- * The Kannel Software License, Version 1.0 
- * 
- * Copyright (c) 2001-2009 Kannel Group  
- * Copyright (c) 1998-2001 WapIT Ltd.   
- * All rights reserved. 
- * 
- * Redistribution and use in source and binary forms, with or without 
- * modification, are permitted provided that the following conditions 
- * are met: 
- * 
- * 1. Redistributions of source code must retain the above copyright 
- *    notice, this list of conditions and the following disclaimer. 
- * 
- * 2. Redistributions in binary form must reproduce the above copyright 
- *    notice, this list of conditions and the following disclaimer in 
- *    the documentation and/or other materials provided with the 
- *    distribution. 
- * 
- * 3. The end-user documentation included with the redistribution, 
- *    if any, must include the following acknowledgment: 
- *       "This product includes software developed by the 
- *        Kannel Group (http://www.kannel.org/)." 
- *    Alternately, this acknowledgment may appear in the software itself, 
- *    if and wherever such third-party acknowledgments normally appear. 
- * 
- * 4. The names "Kannel" and "Kannel Group" must not be used to 
- *    endorse or promote products derived from this software without 
- *    prior written permission. For written permission, please  
- *    contact [email protected]. 
- * 
- * 5. Products derived from this software may not be called "Kannel", 
- *    nor may "Kannel" appear in their name, without prior written 
- *    permission of the Kannel Group. 
- * 
- * THIS SOFTWARE IS PROVIDED ``AS IS'' AND ANY EXPRESSED OR IMPLIED 
- * WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES 
- * OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE 
- * DISCLAIMED.  IN NO EVENT SHALL THE KANNEL GROUP OR ITS CONTRIBUTORS 
- * BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY,  
- * OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT  
- * OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR  
- * BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY,  
- * WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE  
- * OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE,  
- * EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. 
- * ==================================================================== 
- * 
- * This software consists of voluntary contributions made by many 
- * individuals on behalf of the Kannel Group.  For more information on  
- * the Kannel Group, please see <http://www.kannel.org/>. 
- * 
- * Portions of this software are based upon software originally written at  
- * WapIT Ltd., Helsinki, Finland for the Kannel project.  
- */ 
+/* ====================================================================
+ * The Kannel Software License, Version 1.0
+ *
+ * Copyright (c) 2001-2009 Kannel Group
+ * Copyright (c) 1998-2001 WapIT Ltd.
+ * All rights reserved.
+ *
+ * Redistribution and use in source and binary forms, with or without
+ * modification, are permitted provided that the following conditions
+ * are met:
+ *
+ * 1. Redistributions of source code must retain the above copyright
+ *    notice, this list of conditions and the following disclaimer.
+ *
+ * 2. Redistributions in binary form must reproduce the above copyright
+ *    notice, this list of conditions and the following disclaimer in
+ *    the documentation and/or other materials provided with the
+ *    distribution.
+ *
+ * 3. The end-user documentation included with the redistribution,
+ *    if any, must include the following acknowledgment:
+ *       "This product includes software developed by the
+ *        Kannel Group (http://www.kannel.org/)."
+ *    Alternately, this acknowledgment may appear in the software itself,
+ *    if and wherever such third-party acknowledgments normally appear.
+ *
+ * 4. The names "Kannel" and "Kannel Group" must not be used to
+ *    endorse or promote products derived from this software without
+ *    prior written permission. For written permission, please
+ *    contact [email protected].
+ *
+ * 5. Products derived from this software may not be called "Kannel",
+ *    nor may "Kannel" appear in their name, without prior written
+ *    permission of the Kannel Group.
+ *
+ * THIS SOFTWARE IS PROVIDED ``AS IS'' AND ANY EXPRESSED OR IMPLIED
+ * WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES
+ * OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE
+ * DISCLAIMED.  IN NO EVENT SHALL THE KANNEL GROUP OR ITS CONTRIBUTORS
+ * BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY,
+ * OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT
+ * OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR
+ * BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY,
+ * WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE
+ * OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE,
+ * EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
+ * ====================================================================
+ *
+ * This software consists of voluntary contributions made by many
+ * individuals on behalf of the Kannel Group.  For more information on
+ * the Kannel Group, please see <http://www.kannel.org/>.
+ *
+ * Portions of this software are based upon software originally written at
+ * WapIT Ltd., Helsinki, Finland for the Kannel project.
+ */
 
 /*
  * SMSC Connection interface for Bearerbox.
@@ -65,7 +65,7 @@
  * Kalle Marjola 2000 for project Kannel
  * Alexander Malysh <amalysh at kannel.org> 2003, 2004, 2005
  */
- 
+
 #include "gw-config.h"
 
 #include <errno.h>
@@ -115,6 +115,13 @@
 /* incoming sms queue control */
 extern long max_incoming_sms_qlength;
 
+/**
+ * Global configuration file (initialized in main)
+ * Manish Nema : 18-06-2009
+ */
+extern Octstr * gCfgFilename;
+
+
 /* our own thingies */
 
 static volatile sig_atomic_t smsc_running;
@@ -193,7 +200,7 @@
 static void handle_split(SMSCConn *conn, Msg *msg, long reason)
 {
     struct split_parts *split = msg->sms.split_parts;
-    
+
     /*
      * If temporarely failed, try again immediately but only if connection active.
      * Because if connection is not active we will loop for ever here consuming 100% CPU
@@ -205,7 +212,7 @@
         msg_destroy(msg);
         return;
     }
-    
+
     /*
      * if the reason is not a success and status is still success
      * then set status of a split to the reason.
@@ -233,7 +240,7 @@
      * we will split it again in smscconn_send(...).
      */
     msg_destroy(msg);
-        
+
     if (counter_decrease(split->parts_left) <= 1) {
         /* all splited parts were processed */
         counter_destroy(split->parts_left);
@@ -257,7 +264,7 @@
         octstr_destroy(reply);
         return;
     }
-    
+
     counter_increase(outgoing_sms_counter);
     load_increase(outgoing_sms_load);
     if (conn) counter_increase(conn->sent);
@@ -294,7 +301,7 @@
         octstr_destroy(reply);
         return;
     }
-    
+
     switch (reason) {
     case SMSCCONN_FAILED_TEMPORARILY:
         /*
@@ -309,7 +316,7 @@
              */
            if (sms_resend_retry >= 0 && sms->sms.resend_try >= sms_resend_retry) {
                warning(0, "Maximum retries for message exceeded, discarding it!");
-               bb_smscconn_send_failed(NULL, sms, SMSCCONN_FAILED_DISCARDED, 
+               bb_smscconn_send_failed(NULL, sms, SMSCCONN_FAILED_DISCARDED,
                                        octstr_create("Retries Exceeded"));
                break;
            }
@@ -318,7 +325,7 @@
        }
        gwlist_produce(outgoing_sms, sms);
        break;
-       
+
     case SMSCCONN_FAILED_SHUTDOWN:
         gwlist_produce(outgoing_sms, sms);
         break;
@@ -388,7 +395,7 @@
         msg_destroy(sms);
         return SMSCCONN_FAILED_REJECTED;
     }
-    
+
     if (black_list &&
 	numhash_find_number(black_list, sms->sms.sender) == 1) {
 	info(0, "Number <%s> is in black-list, message discarded",
@@ -439,7 +446,7 @@
                 msg_destroy(sms);
                 return SMSCCONN_SUCCESS;
             case concat_complete:
-                /* Combined sms received! save new one since it is now combined. */ 
+                /* Combined sms received! save new one since it is now combined. */
                 msg_destroy(sms);
                 /* Change the sms. */
                 sms = msg_duplicate(copy);
@@ -463,7 +470,7 @@
          */
         rc = route_incoming_to_boxc(copy);
     }
-    
+
     if (rc == -1 || (rc != SMSCCONN_SUCCESS && rc != SMSCCONN_QUEUED)) {
         warning(0, "incoming messages queue too long, dropping a message");
         if (sms->sms.sms_type == report_mo)
@@ -597,7 +604,7 @@
 
     /* create split sms counter */
     split_msg_counter = counter_create();
-    
+
     /* create smsc list and rwlock for it */
     smsc_list = gwlist_create();
     gw_rwlock_init_static(&smsc_list_lock);
@@ -610,7 +617,7 @@
     white_list_url = cfg_get(grp, octstr_imm("white-list"));
     if (white_list_url != NULL) {
         if ((white_list = numhash_create(octstr_get_cstr(white_list_url))) == NULL)
-            panic(0, "Could not get white-list at URL <%s>", 
+            panic(0, "Could not get white-list at URL <%s>",
                   octstr_get_cstr(white_list_url));
     }
     if ((os = cfg_get(grp, octstr_imm("white-list-regex"))) != NULL) {
@@ -618,11 +625,11 @@
             panic(0, "Could not compile pattern '%s'", octstr_get_cstr(os));
         octstr_destroy(os);
     }
-    
+
     black_list_url = cfg_get(grp, octstr_imm("black-list"));
     if (black_list_url != NULL) {
         if ((black_list = numhash_create(octstr_get_cstr(black_list_url))) == NULL)
-            panic(0, "Could not get black-list at URL <%s>", 
+            panic(0, "Could not get black-list at URL <%s>",
                   octstr_get_cstr(black_list_url));
     }
     if ((os = cfg_get(grp, octstr_imm("black-list-regex"))) != NULL) {
@@ -636,7 +643,7 @@
         sms_resend_frequency = 60;
     }
     info(0, "Set SMS resend frequency to %ld seconds.", sms_resend_frequency);
-            
+
     if (cfg_get_integer(&sms_resend_retry, grp, octstr_imm("sms-resend-retry")) == -1) {
         sms_resend_retry = -1;
         info(0, "SMS resend retry set to unlimited.");
@@ -659,18 +666,18 @@
 
     smsc_groups = cfg_get_multi_group(cfg, octstr_imm("smsc"));
     gwlist_add_producer(smsc_list);
-    for (i = 0; i < gwlist_len(smsc_groups) && 
+    for (i = 0; i < gwlist_len(smsc_groups) &&
         (grp = gwlist_get(smsc_groups, i)) != NULL; i++) {
-        conn = smscconn_create(grp, 1); 
+        conn = smscconn_create(grp, 1);
         if (conn == NULL)
             panic(0, "Cannot start with SMSC connection failing");
         gwlist_append(smsc_list, conn);
     }
     gwlist_remove_producer(smsc_list);
-    
+
     if ((router_thread = gwthread_create(sms_router, NULL)) == -1)
 	panic(0, "Failed to start a new thread for SMS routing");
-    
+
     gwlist_add_producer(incoming_sms);
     smsc_running = 1;
     return 0;
@@ -699,6 +706,83 @@
     return i;
 }
 
+int rescan_smsc(void)
+{
+
+	int i=0;
+
+	CfgGroup *grp = NULL;
+	SMSCConn *conn = NULL;
+
+	Cfg *cfg =  cfg_create(gCfgFilename);
+
+	if (!smsc_running)
+	        return -1;
+
+	debug("smscconn", 0, "Rescanning SMSC configuration");
+
+	if (cfg_read(cfg) == -1)
+	        panic(0, "Couldn't read configuration from `%s'.", octstr_get_cstr(gCfgFilename));
+
+
+
+	gw_rwlock_wrlock(&smsc_list_lock);
+	debug("smscconn", 0, "Write-lock obtained on smsc_list");
+	for (i = 0; i < gwlist_len(smsc_list); i++) {
+
+		conn = gwlist_get(smsc_list, i);
+		if (conn != NULL && smscconn_status(conn) == SMSCCONN_DEAD)
+		{
+		   info(0, "HTTP (rescan smsc): Could not shutdown already dead smsc-id `%s'",
+		   octstr_get_cstr(conn->id));
+		} else {
+		   info(0,"HTTP (rescan smsc): Shutting down smsc-id `%s'", octstr_get_cstr(conn->id));
+		   smscconn_shutdown(conn, 1);   /* shutdown the smsc */
+		}
+		smscconn_destroy(conn);
+	}
+	gwlist_destroy(smsc_list, NULL);
+	debug("smscconn", 0, "destroyed old smsc_list");
+	smsc_list = NULL;
+	smsc_list = gwlist_create();
+
+
+	/**
+	 * Re-read configuration
+	 */
+
+	debug("smscconn", 0, "destroyed smsc_groups");
+	gwlist_destroy(smsc_groups, NULL);
+	debug("smscconn", 0, "Rescanning-smsc configuration");
+	smsc_groups = cfg_get_multi_group(cfg, octstr_imm("smsc"));
+
+	gwlist_add_producer(smsc_list);
+	debug("smscconn", 0, "Scanned smsc connections starting them now ... ");
+	for (i = 0; i < gwlist_len(smsc_groups) &&
+		(grp = gwlist_get(smsc_groups, i)) != NULL; i++) {
+		conn = smscconn_create(grp, 1);
+		if (conn == NULL)
+			panic(0, "Cannot start with SMSC connection failing");
+		gwlist_append(smsc_list, conn);
+	}
+	gwlist_remove_producer(smsc_list);
+
+	debug("smscconn", 0, "finished starting smsc");
+	gw_rwlock_unlock(&smsc_list_lock);
+
+	debug("smscconn", 0, "waking up router thread");
+
+
+	//TODO: check if it is valid
+	/* wake-up the router */
+	if (router_thread >= 0)
+	      gwthread_wakeup(router_thread);
+
+	debug("smscconn", 0, "Rescan finished");
+	cfg_destroy(cfg);
+	return 0;
+
+}
 int smsc2_stop_smsc(Octstr *id)
 {
     SMSCConn *conn;
@@ -749,7 +833,7 @@
         /* find the group with equal smsc id */
         hit = 0;
         grp = NULL;
-        for (group_index = 0; group_index < gwlist_len(smsc_groups) && 
+        for (group_index = 0; group_index < gwlist_len(smsc_groups) &&
              (grp = gwlist_get(smsc_groups, group_index)) != NULL; group_index++) {
             smscid = cfg_get(grp, octstr_imm("smsc-id"));
             if (smscid != NULL && octstr_compare(smscid, id) == 0) {
@@ -767,7 +851,7 @@
             error(0, "HTTP: Could not find config for smsc-id `%s'", octstr_get_cstr(id));
             break;
         }
-        
+
         info(0,"HTTP: Re-starting smsc-id `%s'", octstr_get_cstr(id));
 
         new_conn = smscconn_create(grp, 1);
@@ -775,7 +859,7 @@
             error(0, "Start of SMSC connection failed, smsc-id `%s'", octstr_get_cstr(id));
             continue; /* keep old connection on the list */
         }
-        
+
         /* drop old connection from the active smsc list */
         gwlist_delete(smsc_list, i, 1);
         /* destroy the connection */
@@ -785,11 +869,11 @@
         num++;
     }
     gw_rwlock_unlock(&smsc_list_lock);
-    
+
     /* wake-up the router */
     if (router_thread >= 0)
         gwthread_wakeup(router_thread);
-    
+
     return 0;
 }
 
@@ -807,7 +891,7 @@
         smscconn_start(conn);
     }
     gw_rwlock_unlock(&smsc_list_lock);
-    
+
     if (router_thread >= 0)
         gwthread_wakeup(router_thread);
 }
@@ -874,7 +958,7 @@
         return;
 
     debug("smscconn", 0, "final clean-up for SMSCConn");
-    
+
     gw_rwlock_wrlock(&smsc_list_lock);
     for (i = 0; i < gwlist_len(smsc_list); i++) {
         conn = gwlist_get(smsc_list, i);
@@ -884,7 +968,7 @@
     smsc_list = NULL;
     gw_rwlock_unlock(&smsc_list_lock);
     gwlist_destroy(smsc_groups, NULL);
-    octstr_destroy(unified_prefix);    
+    octstr_destroy(unified_prefix);
     numhash_destroy(white_list);
     numhash_destroy(black_list);
     octstr_destroy(white_list_url);
@@ -941,8 +1025,8 @@
         conn = gwlist_get(smsc_list, i);
 
         if ((smscconn_info(conn, &info) == -1)) {
-            /* 
-             * we do not delete SMSCs from the list 
+            /*
+             * we do not delete SMSCs from the list
              * this way we can show in the status which links are dead
              */
             continue;
@@ -966,7 +1050,7 @@
             octstr_append_cstr(tmp, "[");
             octstr_append(tmp, conn_admin_id);
             octstr_append_cstr(tmp, "]    ");
-        } 
+        }
         if (status_type == BBSTATUS_XML) {
             octstr_append_cstr(tmp, "<smsc>\n\t\t<name>");
             octstr_append(tmp, conn_name);
@@ -998,7 +1082,7 @@
             default:
                 sprintf(tmp3, "unknown");
         }
-	
+
         if (status_type == BBSTATUS_XML)
             octstr_format_append(tmp, "<status>%s</status>\n\t\t<received>%ld</received>"
                 "\n\t\t<sent>%ld</sent>\n\t\t<failed>%ld</failed>\n\t\t"
@@ -1173,11 +1257,11 @@
 static long route_incoming_to_smsc(SMSCConn *conn, Msg *msg)
 {
     Octstr *smsc;
-    
+
     /* sanity check */
     if (!conn || !msg)
         return -1;
-        
+
     /* check for dlr rerouting */
     if (!conn->reroute_dlr && (msg->sms.sms_type == report_mo || msg->sms.sms_type == report_mt))
         return -1;
@@ -1194,7 +1278,7 @@
         /* drop into outbound queue again for routing */
         return smsc2_rout(msg, 0);
     }
-    
+
     if (conn->reroute_to_smsc) {
         /* change message direction */
         store_save_ack(msg, ack_success);
@@ -1205,7 +1289,7 @@
         msg->sms.smsc_id = octstr_duplicate(conn->reroute_to_smsc);
         return smsc2_rout(msg, 0);
     }
-    
+
     if (conn->reroute_by_receiver && msg->sms.receiver &&
                  (smsc = dict_get(conn->reroute_by_receiver, msg->sms.receiver))) {
         /* change message direction */
@@ -1219,7 +1303,7 @@
         return smsc2_rout(msg, 0);
     }
 
-    return -1; 
+    return -1;
 }
 
 
@@ -1262,7 +1346,7 @@
 {
     if (incoming_concat_msgs != NULL) /* already initialised? */
         return;
-    incoming_concat_msgs = dict_create(max_incoming_sms_qlength > 0 ? max_incoming_sms_qlength : 1024, 
+    incoming_concat_msgs = dict_create(max_incoming_sms_qlength > 0 ? max_incoming_sms_qlength : 1024,
                                        destroy_concatMsg);
     concat_lock = mutex_create();
     debug("bb.sms",0,"smsbox MO concatenated message handling enabled");
@@ -1405,9 +1489,9 @@
 
     debug("bb.sms.splits", 0, "Got part %d [ref %d, total parts %d] of message from %s. Dump follows:",
           part, refnum,totalparts, octstr_get_cstr(msg->sms.sender));
-     
+
     msg_dump(msg,0);
-     
+
     key = octstr_format("%S %S %S %d", msg->sms.sender, msg->sms.receiver, smscid, refnum);
     mutex_lock(concat_lock);
     if ((cmsg = dict_get(incoming_concat_msgs, key)) == NULL) {
@@ -1437,11 +1521,11 @@
     }
 
     /* check if we have seen message part before... */
-    if (cmsg->parts[part - 1] != NULL) {	  
+    if (cmsg->parts[part - 1] != NULL) {
         warning(0, "Duplicate message part %d, ref %d, from %s, to %s. Discarded!",
                 part, refnum, octstr_get_cstr(msg->sms.sender), octstr_get_cstr(msg->sms.receiver));
         store_save_ack(msg, ack_success);
-        msg_destroy(msg); 
+        msg_destroy(msg);
         *pmsg = msg = NULL;
     } else {
         cmsg->parts[part -1] = msg;
@@ -1467,12 +1551,12 @@
         octstr_append(msg->sms.msgdata, cmsg->parts[i]->sms.msgdata);
 
     /* Attempt to save the new one, if that fails, then reply with fail. */
-    if (store_save(msg) == -1) {	  
+    if (store_save(msg) == -1) {
         mutex_unlock(concat_lock);
         msg_destroy(msg);
         *pmsg = msg = NULL;
         return concat_error;
-    } else 
+    } else
         *pmsg = msg; /* return the message part. */
 
     /* Delete it from the queue and from the Dict. */
@@ -1506,7 +1590,7 @@
 {
     numhash_destroy(white_list);
     numhash_destroy(black_list);
-    
+
     if (white_list_url != NULL) {
         white_list = numhash_create(octstr_get_cstr(white_list_url));
     }
Index: gw/bearerbox.c
===================================================================
RCS file: /home/cvs/gateway/gw/bearerbox.c,v
retrieving revision 1.169
diff -u -r1.169 bearerbox.c
--- gw/bearerbox.c	12 Jan 2009 16:46:56 -0000	1.169
+++ gw/bearerbox.c	19 Jun 2009 10:10:52 -0000
@@ -1,62 +1,62 @@
-/* ==================================================================== 
- * The Kannel Software License, Version 1.0 
- * 
- * Copyright (c) 2001-2009 Kannel Group  
- * Copyright (c) 1998-2001 WapIT Ltd.   
- * All rights reserved. 
- * 
- * Redistribution and use in source and binary forms, with or without 
- * modification, are permitted provided that the following conditions 
- * are met: 
- * 
- * 1. Redistributions of source code must retain the above copyright 
- *    notice, this list of conditions and the following disclaimer. 
- * 
- * 2. Redistributions in binary form must reproduce the above copyright 
- *    notice, this list of conditions and the following disclaimer in 
- *    the documentation and/or other materials provided with the 
- *    distribution. 
- * 
- * 3. The end-user documentation included with the redistribution, 
- *    if any, must include the following acknowledgment: 
- *       "This product includes software developed by the 
- *        Kannel Group (http://www.kannel.org/)." 
- *    Alternately, this acknowledgment may appear in the software itself, 
- *    if and wherever such third-party acknowledgments normally appear. 
- * 
- * 4. The names "Kannel" and "Kannel Group" must not be used to 
- *    endorse or promote products derived from this software without 
- *    prior written permission. For written permission, please  
- *    contact [email protected]. 
- * 
- * 5. Products derived from this software may not be called "Kannel", 
- *    nor may "Kannel" appear in their name, without prior written 
- *    permission of the Kannel Group. 
- * 
- * THIS SOFTWARE IS PROVIDED ``AS IS'' AND ANY EXPRESSED OR IMPLIED 
- * WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES 
- * OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE 
- * DISCLAIMED.  IN NO EVENT SHALL THE KANNEL GROUP OR ITS CONTRIBUTORS 
- * BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY,  
- * OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT  
- * OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR  
- * BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY,  
- * WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE  
- * OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE,  
- * EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. 
- * ==================================================================== 
- * 
- * This software consists of voluntary contributions made by many 
- * individuals on behalf of the Kannel Group.  For more information on  
- * the Kannel Group, please see <http://www.kannel.org/>. 
- * 
- * Portions of this software are based upon software originally written at  
- * WapIT Ltd., Helsinki, Finland for the Kannel project.  
- */ 
+/* ====================================================================
+ * The Kannel Software License, Version 1.0
+ *
+ * Copyright (c) 2001-2009 Kannel Group
+ * Copyright (c) 1998-2001 WapIT Ltd.
+ * All rights reserved.
+ *
+ * Redistribution and use in source and binary forms, with or without
+ * modification, are permitted provided that the following conditions
+ * are met:
+ *
+ * 1. Redistributions of source code must retain the above copyright
+ *    notice, this list of conditions and the following disclaimer.
+ *
+ * 2. Redistributions in binary form must reproduce the above copyright
+ *    notice, this list of conditions and the following disclaimer in
+ *    the documentation and/or other materials provided with the
+ *    distribution.
+ *
+ * 3. The end-user documentation included with the redistribution,
+ *    if any, must include the following acknowledgment:
+ *       "This product includes software developed by the
+ *        Kannel Group (http://www.kannel.org/)."
+ *    Alternately, this acknowledgment may appear in the software itself,
+ *    if and wherever such third-party acknowledgments normally appear.
+ *
+ * 4. The names "Kannel" and "Kannel Group" must not be used to
+ *    endorse or promote products derived from this software without
+ *    prior written permission. For written permission, please
+ *    contact [email protected].
+ *
+ * 5. Products derived from this software may not be called "Kannel",
+ *    nor may "Kannel" appear in their name, without prior written
+ *    permission of the Kannel Group.
+ *
+ * THIS SOFTWARE IS PROVIDED ``AS IS'' AND ANY EXPRESSED OR IMPLIED
+ * WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES
+ * OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE
+ * DISCLAIMED.  IN NO EVENT SHALL THE KANNEL GROUP OR ITS CONTRIBUTORS
+ * BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY,
+ * OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT
+ * OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR
+ * BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY,
+ * WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE
+ * OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE,
+ * EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
+ * ====================================================================
+ *
+ * This software consists of voluntary contributions made by many
+ * individuals on behalf of the Kannel Group.  For more information on
+ * the Kannel Group, please see <http://www.kannel.org/>.
+ *
+ * Portions of this software are based upon software originally written at
+ * WapIT Ltd., Helsinki, Finland for the Kannel project.
+ */
 
 /*
  * bearerbox.c
- * 
+ *
  * this is the core module of the bearerbox. It starts everything and
  * listens to HTTP requests and traps signals.
  * All started modules are responsible for the rest.
@@ -122,9 +122,15 @@
  */
 List *isolated;
 
+/**
+ * Manish Nema : 18-06-2009
+ * GlobalConfiguration file reference
+ */
+Octstr *gCfgFilename;
+
 volatile sig_atomic_t bb_status;
 
-/* 
+/*
  * Flags for main thread to check what is to do.
  */
 enum {
@@ -147,7 +153,7 @@
 {
     sig_atomic_t old = bb_status;
     bb_status = BB_SHUTDOWN;
-    
+
     if (old == BB_SUSPENDED)
         gwlist_remove_producer(suspended);
     if (old == BB_SUSPENDED || old == BB_ISOLATED)
@@ -223,7 +229,7 @@
 {
     static int started = 0;
 
-    if (started) 
+    if (started)
         return 0;
 
     smsbox_start(cfg);
@@ -240,14 +246,14 @@
     Msg *msg;
 
     gwlist_add_producer(flow_threads);
-    
+
     while (bb_status != BB_DEAD) {
 
         if ((msg = gwlist_consume(outgoing_wdp)) == NULL)
             break;
 
         gw_assert(msg_type(msg) == wdp_datagram);
-	
+
         /*
         if (msg->list == sms)
             smsc_addwdp(msg);
@@ -267,9 +273,9 @@
 {
     static int started = 0;
 
-    if (started) 
+    if (started)
         return 0;
-    
+
     wapbox_start(cfg);
 
     debug("bb", 0, "starting WDP router");
@@ -285,7 +291,7 @@
 {
     static int started = 0;
 
-    if (started) 
+    if (started)
         return 0;
 
     udp_start(cfg);
@@ -312,8 +318,8 @@
     	smsp = -1;
     if (cfg_get_integer(&wapp, grp, octstr_imm("wapbox-port")) == -1)
     	wapp = -1;
-    
-#ifndef NO_SMS    
+
+#ifndef NO_SMS
     grp = cfg_get_single_group(cfg, octstr_imm("smsbox"));
     if (smsp != -1 && grp == NULL) {
         error(0, "No 'smsbox' group in configuration, but smsbox-port set");
@@ -322,8 +328,8 @@
 #else
     warning(0, "Kannel was compiled without SMS support");
 #endif
-    
-#ifndef NO_WAP	
+
+#ifndef NO_WAP
     grp = cfg_get_single_group(cfg, octstr_imm("wapbox"));
     if (wapp != -1 && grp == NULL) {
         error(0, "No 'wapbox' group in configuration, but wapbox-port set");
@@ -332,7 +338,7 @@
 #else
     warning(0, "Kannel was compiled without WAP support");
 #endif
-    
+
     return 0;
 }
 
@@ -340,7 +346,7 @@
 /*
  * check our own variables
  */
-static int check_args(int i, int argc, char **argv) 
+static int check_args(int i, int argc, char **argv)
 {
     if (strcmp(argv[i], "-S")==0 || strcmp(argv[i], "--suspended")==0)
         bb_status = BB_SUSPENDED;
@@ -367,7 +373,7 @@
 
     /* defaults: use localtime and markers for access-log */
     lf = m = 1;
-	
+
     grp = cfg_get_single_group(cfg, octstr_imm("core"));
 
     log = cfg_get(grp, octstr_imm("log-file"));
@@ -424,9 +430,9 @@
 
     /*
      * Make sure we have "ssl-server-cert-file" and "ssl-server-key-file" specified
-     * in the core group since we need it to run SSL-enabled internal box 
+     * in the core group since we need it to run SSL-enabled internal box
      * connections configured via "smsbox-port-ssl = yes" and "wapbox-port-ssl = yes".
-     * Check only these, because for "admin-port-ssl" and "sendsms-port-ssl" for the 
+     * Check only these, because for "admin-port-ssl" and "sendsms-port-ssl" for the
      * SSL-enabled HTTP servers are probed within gw/bb_http.c:httpadmin_start()
      */
 #ifdef HAVE_LIBSSL
@@ -471,7 +477,7 @@
     load_add_interval(incoming_sms_load, -1);
 
     setup_signal_handlers();
-    
+
     /* http-admin is REQUIRED */
     httpadmin_start(cfg);
 
@@ -487,15 +493,15 @@
         cfg_get_integer(&max_incoming_sms_qlength, grp,
                                   octstr_imm("sms-incoming-queue-limit")) == -1)
         max_incoming_sms_qlength = -1;
-        
+
     if (cfg_get_integer(&max_outgoing_sms_qlength, grp,
                                   octstr_imm("sms-outgoing-queue-limit")) == -1)
         max_outgoing_sms_qlength = -1;
 
-#ifndef NO_SMS    
+#ifndef NO_SMS
     {
         List *list;
-	
+
         list = cfg_get_multi_group(cfg, octstr_imm("smsc"));
         if (list != NULL) {
             start_smsc(cfg);
@@ -503,7 +509,7 @@
         }
     }
 #endif
-    
+
 #ifndef NO_WAP
     grp = cfg_get_single_group(cfg, octstr_imm("core"));
     val = cfg_get(grp, octstr_imm("wdp-interface-name"));
@@ -514,7 +520,7 @@
     if (cfg_get_single_group(cfg, octstr_imm("wapbox")) != NULL)
         start_wap(cfg);
 #endif
-    
+
     return cfg;
 }
 
@@ -532,7 +538,7 @@
          counter_value(incoming_wdp_counter),
          counter_value(outgoing_wdp_counter));
 #endif
-    
+
     while ((msg = gwlist_extract_first(incoming_wdp)) != NULL)
         msg_destroy(msg);
     while ((msg = gwlist_extract_first(outgoing_wdp)) != NULL)
@@ -543,7 +549,7 @@
 
     counter_destroy(incoming_wdp_counter);
     counter_destroy(outgoing_wdp_counter);
-    
+
 #ifndef NO_SMS
     /* XXX we should record these so that they are not forever lost... */
     if (gwlist_len(incoming_sms) > 0 || gwlist_len(outgoing_sms) > 0)
@@ -557,7 +563,7 @@
 
     gwlist_destroy(incoming_sms, msg_destroy_item);
     gwlist_destroy(outgoing_sms, msg_destroy_item);
-    
+
     counter_destroy(incoming_sms_counter);
     counter_destroy(outgoing_sms_counter);
 
@@ -594,7 +600,7 @@
     Octstr *filename;
 
     bb_status = BB_RUNNING;
-    
+
     gwlib_init();
     start_time = time(NULL);
 
@@ -606,22 +612,30 @@
     cf_index = get_and_set_debugs(argc, argv, check_args);
 
     if (argv[cf_index] == NULL)
-        filename = octstr_create("kannel.conf");
+    {
+    	gCfgFilename = octstr_create("kannel.conf");
+    	filename = octstr_create("kannel.conf");
+    }
     else
-        filename = octstr_create(argv[cf_index]);
-    cfg = cfg_create(filename); 
-    
+    {
+    	gCfgFilename = octstr_create(argv[cf_index]);
+    	filename = octstr_create(argv[cf_index]);
+    }
+
+
+    cfg = cfg_create(filename);
+
     if (cfg_read(cfg) == -1)
         panic(0, "Couldn't read configuration from `%s'.", octstr_get_cstr(filename));
-    
+
     octstr_destroy(filename);
 
     dlr_init(cfg);
-    
+
     report_versions("bearerbox");
 
     flow_threads = gwlist_create();
-    
+
     init_bearerbox(cfg);
 
     info(0, "----------------------------------------");
@@ -631,7 +645,7 @@
 
     if (store_load(dispatch_into_queue) == -1)
         panic(0, "Cannot start with store-file failing");
-    
+
     info(0, "MAIN: Start-up done, entering mainloop");
     if (bb_status == BB_SUSPENDED) {
         info(0, "Gateway is now SUSPENDED by startup arguments");
@@ -640,11 +654,11 @@
         gwlist_remove_producer(suspended);
     } else {
         smsc2_resume();
-        gwlist_remove_producer(suspended);	
+        gwlist_remove_producer(suspended);
         gwlist_remove_producer(isolated);
     }
 
-    while (bb_status != BB_SHUTDOWN && bb_status != BB_DEAD && 
+    while (bb_status != BB_SHUTDOWN && bb_status != BB_DEAD &&
            gwlist_producer_count(flow_threads) > 0) {
         /* debug("bb", 0, "Main Thread: going to sleep."); */
         /*
@@ -718,9 +732,9 @@
 int bb_shutdown(void)
 {
     static int called = 0;
-    
+
     mutex_lock(status_mutex);
-    
+
     if (called) {
         mutex_unlock(status_mutex);
         return -1;
@@ -739,7 +753,7 @@
     debug("bb", 0, "shutting down udp");
     udp_shutdown();
 #endif
-    
+
     return 0;
 }
 
@@ -842,7 +856,7 @@
         return octstr_create("Un-supported format");
 
     t = time(NULL) - start_time;
-    
+
     if (bb_status == BB_RUNNING)
         s = "running";
     else if (bb_status == BB_ISOLATED)
@@ -899,7 +913,7 @@
                "DLR: %ld queued, using %s storage\n\n";
         footer = "";
     }
-    
+
     ret = octstr_format(frmt,
         octstr_get_cstr(version),
         s, t/3600/24, t/3600%24, t/60%60, t%60,
@@ -914,11 +928,11 @@
         dlr_messages(), dlr_type());
 
     octstr_destroy(version);
-    
+
     append_status(ret, str, boxc_status, status_type);
     append_status(ret, str, smsc2_status, status_type);
     octstr_append_cstr(ret, footer);
-    
+
     return ret;
 }
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.