Main Page | Alphabetical List | Data Structures | Directories | File List | Data Fields | Globals

bearerbox.h

Go to the documentation of this file.
00001 /* ==================================================================== 
00002  * The Kannel Software License, Version 1.0 
00003  * 
00004  * Copyright (c) 2001-2008 Kannel Group  
00005  * Copyright (c) 1998-2001 WapIT Ltd.   
00006  * All rights reserved. 
00007  * 
00008  * Redistribution and use in source and binary forms, with or without 
00009  * modification, are permitted provided that the following conditions 
00010  * are met: 
00011  * 
00012  * 1. Redistributions of source code must retain the above copyright 
00013  *    notice, this list of conditions and the following disclaimer. 
00014  * 
00015  * 2. Redistributions in binary form must reproduce the above copyright 
00016  *    notice, this list of conditions and the following disclaimer in 
00017  *    the documentation and/or other materials provided with the 
00018  *    distribution. 
00019  * 
00020  * 3. The end-user documentation included with the redistribution, 
00021  *    if any, must include the following acknowledgment: 
00022  *       "This product includes software developed by the 
00023  *        Kannel Group (http://www.kannel.org/)." 
00024  *    Alternately, this acknowledgment may appear in the software itself, 
00025  *    if and wherever such third-party acknowledgments normally appear. 
00026  * 
00027  * 4. The names "Kannel" and "Kannel Group" must not be used to 
00028  *    endorse or promote products derived from this software without 
00029  *    prior written permission. For written permission, please  
00030  *    contact org@kannel.org. 
00031  * 
00032  * 5. Products derived from this software may not be called "Kannel", 
00033  *    nor may "Kannel" appear in their name, without prior written 
00034  *    permission of the Kannel Group. 
00035  * 
00036  * THIS SOFTWARE IS PROVIDED ``AS IS'' AND ANY EXPRESSED OR IMPLIED 
00037  * WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES 
00038  * OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE 
00039  * DISCLAIMED.  IN NO EVENT SHALL THE KANNEL GROUP OR ITS CONTRIBUTORS 
00040  * BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY,  
00041  * OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT  
00042  * OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR  
00043  * BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY,  
00044  * WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE  
00045  * OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE,  
00046  * EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. 
00047  * ==================================================================== 
00048  * 
00049  * This software consists of voluntary contributions made by many 
00050  * individuals on behalf of the Kannel Group.  For more information on  
00051  * the Kannel Group, please see <http://www.kannel.org/>. 
00052  * 
00053  * Portions of this software are based upon software originally written at  
00054  * WapIT Ltd., Helsinki, Finland for the Kannel project.  
00055  */ 
00056 
00057 /*
00058  * bearerbox.h
00059  *
00060  * General typedefs and functions for bearerbox
00061  */
00062 
00063 #include "gwlib/gwlib.h"
00064 #include "msg.h"
00065 #include "smscconn.h"
00066 #include "bb_store.h"
00067 
00068 
00069 /* general bearerbox state */
00070 
00071 enum {
00072     BB_RUNNING = 0,
00073     BB_ISOLATED = 1,    /* do not receive new messgaes from UDP/SMSC */
00074     BB_SUSPENDED = 2,   /* do not transfer any messages */
00075     BB_SHUTDOWN = 3,
00076     BB_DEAD = 4,
00077     BB_FULL = 5         /* message queue too long, do not accept new messages */
00078 };
00079 
00080 
00081 /* type of output given by various status functions */
00082 enum {
00083     BBSTATUS_HTML = 0,
00084     BBSTATUS_TEXT = 1,
00085     BBSTATUS_WML = 2,
00086     BBSTATUS_XML = 3
00087 };
00088 
00089 /*---------------------------------------------------------------
00090  * Module interface to core bearerbox
00091  *
00092  * Modules implement one or more of the following interfaces:
00093  *
00094  * XXX_start(Cfg *config) - start the module
00095  * XXX_restart(Cfg *config) - restart the module, according to new config
00096  * XXX_shutdown() - start the avalanche - started from UDP/SMSC
00097  * XXX_die() - final cleanup
00098  *
00099  * XXX_addwdp() - only for SMSC/UDP: add a new WDP message to outgoing system
00100  */
00101 
00102 
00103 /*---------------
00104  * bb_boxc.c (SMS and WAPBOX connections)
00105  */
00106 
00107 int smsbox_start(Cfg *config);
00108 int smsbox_restart(Cfg *config);
00109 
00110 int wapbox_start(Cfg *config);
00111 
00112 Octstr *boxc_status(int status_type);
00113 /* tell total number of messages in separate wapbox incoming queues */
00114 int boxc_incoming_wdp_queue(void);
00115 
00116 /* Clean up after box connections have died. */
00117 void boxc_cleanup(void);
00118 
00119 /*
00120  * Route the incoming message to one of the following input queues:
00121  *   a specific smsbox conn
00122  *   a random smsbox conn if no shortcut routing and msg->sms.boxc_id match.
00123  * @return -1 if incoming queue full; 0 otherwise.
00124  */
00125 int route_incoming_to_boxc(Msg *msg);
00126 
00127 
00128 /*---------------
00129  * bb_udp.c (UDP receiver/sender)
00130  */
00131 
00132 int udp_start(Cfg *config);
00133 /* int udp_restart(Cfg *config); */
00134 int udp_shutdown(void);
00135 int udp_die(void);  /* called when router dies */
00136 
00137 /* add outgoing WDP. If fails, return -1 and msg is untouched, so
00138  * caller must think of new uses for it */
00139 int udp_addwdp(Msg *msg);
00140 /* tell total number of messages in separate UDP outgoing port queues */
00141 int udp_outgoing_queue(void);
00142 
00143 
00144 
00145 /*---------------
00146  * bb_smscconn.c (SMS Center connections)
00147  */
00148 
00149 int smsc2_start(Cfg *config);
00150 int smsc2_restart(Cfg *config);
00151 
00152 void smsc2_suspend(void);    /* suspend (can still send but not receive) */
00153 void smsc2_resume(void);     /* resume */
00154 int smsc2_shutdown(void);
00155 void smsc2_cleanup(void); /* final clean-up */
00156 
00157 Octstr *smsc2_status(int status_type);
00158 
00159 /* function to route outgoing SMS'es
00160  *
00161  * If finds a good one, puts into it and returns SMSCCONN_SUCCESS
00162  * If finds only bad ones, but acceptable, queues and
00163  *  returns SMSCCONN_QUEUED  (like all acceptable currently disconnected)
00164  * if message acceptable but queues full returns SMSCCONN_FAILED_QFULL and
00165  * message is not destroyed.
00166  * If cannot find nothing at all, returns SMSCCONN_FAILED_DISCARDED and
00167  * message is NOT destroyed (otherwise it is)
00168  */
00169 long smsc2_rout(Msg *msg, int resend);
00170 
00171 int smsc2_stop_smsc(Octstr *id);   /* shutdown a specific smsc */
00172 int smsc2_restart_smsc(Octstr *id);  /* re-start a specific smsc */
00173 
00174 
00175 /*---------------
00176  * bb_http.c (HTTP Admin)
00177  */
00178 
00179 int httpadmin_start(Cfg *config);
00180 /* int http_restart(Cfg *config); */
00181 void httpadmin_stop(void);
00182 
00183 
00184 /*-----------------
00185  * bb_alog.c (Custom access-log format handling)
00186  */
00187 
00188 /* passes the access-log-format string from config to the module */
00189 void bb_alog_init(const Octstr *format);
00190 
00191 /* cleanup for internal things */
00192 void bb_alog_shutdown(void);
00193 
00194 /* called from bb_smscconn.c to log the various access-log events */
00195 void bb_alog_sms(SMSCConn *conn, Msg *sms, const char *message);
00196 
00197 
00198 
00199 /*----------------------------------------------------------------
00200  * Core bearerbox public functions;
00201  * used only via HTTP adminstration
00202  */
00203 
00204 int bb_shutdown(void);
00205 int bb_isolate(void);
00206 int bb_suspend(void);
00207 int bb_resume(void);
00208 int bb_restart(void);
00209 int bb_flush_dlr(void);
00210 int bb_stop_smsc(Octstr *id);
00211 int bb_restart_smsc(Octstr *id);
00212 
00213 /* return string of current status */
00214 Octstr *bb_print_status(int status_type);
00215 
00216 
00217 /*----------------------------------------------------------------
00218  * common function to all (in bearerbox.c)
00219  */
00220 
00221 /* return linebreak for given output format, or NULL if format
00222  * not supported */
00223 char *bb_status_linebreak(int status_type);
00224 
00225 
See file LICENSE for details about the license agreement for using, modifying, copying or deriving work from this software.