Kannel: Open Source WAP and SMS gateway  svn-r5335
bearerbox.h
Go to the documentation of this file.
1 /* ====================================================================
2  * The Kannel Software License, Version 1.0
3  *
4  * Copyright (c) 2001-2018 Kannel Group
5  * Copyright (c) 1998-2001 WapIT Ltd.
6  * All rights reserved.
7  *
8  * Redistribution and use in source and binary forms, with or without
9  * modification, are permitted provided that the following conditions
10  * are met:
11  *
12  * 1. Redistributions of source code must retain the above copyright
13  * notice, this list of conditions and the following disclaimer.
14  *
15  * 2. Redistributions in binary form must reproduce the above copyright
16  * notice, this list of conditions and the following disclaimer in
17  * the documentation and/or other materials provided with the
18  * distribution.
19  *
20  * 3. The end-user documentation included with the redistribution,
21  * if any, must include the following acknowledgment:
22  * "This product includes software developed by the
23  * Kannel Group (http://www.kannel.org/)."
24  * Alternately, this acknowledgment may appear in the software itself,
25  * if and wherever such third-party acknowledgments normally appear.
26  *
27  * 4. The names "Kannel" and "Kannel Group" must not be used to
28  * endorse or promote products derived from this software without
29  * prior written permission. For written permission, please
30  * contact org@kannel.org.
31  *
32  * 5. Products derived from this software may not be called "Kannel",
33  * nor may "Kannel" appear in their name, without prior written
34  * permission of the Kannel Group.
35  *
36  * THIS SOFTWARE IS PROVIDED ``AS IS'' AND ANY EXPRESSED OR IMPLIED
37  * WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES
38  * OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE
39  * DISCLAIMED. IN NO EVENT SHALL THE KANNEL GROUP OR ITS CONTRIBUTORS
40  * BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY,
41  * OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT
42  * OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR
43  * BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY,
44  * WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE
45  * OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE,
46  * EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
47  * ====================================================================
48  *
49  * This software consists of voluntary contributions made by many
50  * individuals on behalf of the Kannel Group. For more information on
51  * the Kannel Group, please see <http://www.kannel.org/>.
52  *
53  * Portions of this software are based upon software originally written at
54  * WapIT Ltd., Helsinki, Finland for the Kannel project.
55  */
56 
57 /*
58  * bearerbox.h
59  *
60  * General typedefs and functions for bearerbox
61  */
62 
63 #include "gwlib/gwlib.h"
64 #include "msg.h"
65 #include "smscconn.h"
66 #include "bb_store.h"
67 
68 /* Default outgoing queue length */
69 #define DEFAULT_OUTGOING_SMS_QLENGTH 1000000
70 
71 /* general bearerbox state */
72 
73 enum {
75  BB_ISOLATED = 1, /* do not receive new messgaes from UDP/SMSC */
76  BB_SUSPENDED = 2, /* do not transfer any messages */
78  BB_DEAD = 4,
79  BB_FULL = 5 /* message queue too long, do not accept new messages */
80 };
81 
82 
83 /* type of output given by various status functions */
84 enum {
89 };
90 
91 /*---------------------------------------------------------------
92  * Module interface to core bearerbox
93  *
94  * Modules implement one or more of the following interfaces:
95  *
96  * XXX_start(Cfg *config) - start the module
97  * XXX_restart(Cfg *config) - restart the module, according to new config
98  * XXX_shutdown() - start the avalanche - started from UDP/SMSC
99  * XXX_die() - final cleanup
100  *
101  * XXX_addwdp() - only for SMSC/UDP: add a new WDP message to outgoing system
102  */
103 
104 
105 /*---------------
106  * bb_boxc.c (SMS and WAPBOX connections)
107  */
108 
109 int smsbox_start(Cfg *config);
110 int smsbox_restart(Cfg *config);
111 
112 int wapbox_start(Cfg *config);
113 
114 Octstr *boxc_status(int status_type);
115 /* tell total number of messages in separate wapbox incoming queues */
116 int boxc_incoming_wdp_queue(void);
117 
118 /* Clean up after box connections have died. */
119 void boxc_cleanup(void);
120 
121 /*
122  * Route the incoming message to one of the following input queues:
123  * a specific smsbox conn
124  * a random smsbox conn if no shortcut routing and msg->sms.boxc_id match.
125  * @return -1 if incoming queue full; 0 otherwise.
126  */
128 
129 
130 /*---------------
131  * bb_udp.c (UDP receiver/sender)
132  */
133 
134 int udp_start(Cfg *config);
135 /* int udp_restart(Cfg *config); */
136 int udp_shutdown(void);
137 int udp_die(void); /* called when router dies */
138 
139 /* add outgoing WDP. If fails, return -1 and msg is untouched, so
140  * caller must think of new uses for it */
141 int udp_addwdp(Msg *msg);
142 /* tell total number of messages in separate UDP outgoing port queues */
143 int udp_outgoing_queue(void);
144 
145 
146 
147 /*---------------
148  * bb_smscconn.c (SMS Center connections)
149  */
150 
151 int smsc2_start(Cfg *config);
152 int smsc2_restart(Cfg *config);
153 int smsc2_graceful_restart(Cfg *config);
154 
155 void smsc2_suspend(void); /* suspend (can still send but not receive) */
156 void smsc2_resume(int is_init); /* resume */
157 int smsc2_shutdown(void);
158 void smsc2_cleanup(void); /* final clean-up */
159 
160 Octstr *smsc2_status(int status_type);
161 
162 /* function to route outgoing SMS'es
163  *
164  * If finds a good one, puts into it and returns SMSCCONN_SUCCESS
165  * If finds only bad ones, but acceptable, queues and
166  * returns SMSCCONN_QUEUED (like all acceptable currently disconnected)
167  * if message acceptable but queues full returns SMSCCONN_FAILED_QFULL and
168  * message is not destroyed.
169  * If cannot find nothing at all, returns SMSCCONN_FAILED_DISCARDED and
170  * message is NOT destroyed (otherwise it is)
171  */
172 long smsc2_rout(Msg *msg, int resend);
173 
174 int smsc2_stop_smsc(Octstr *id); /* shutdown a specific smsc */
175 int smsc2_restart_smsc(Octstr *id); /* re-start a specific smsc */
176 int smsc2_add_smsc(Octstr *id); /* add a new smsc */
177 int smsc2_remove_smsc(Octstr *id); /* remove a specific smsc */
178 
179 int smsc2_reload_lists(void); /* reload blacklists */
180 
181 
182 /*---------------
183  * bb_http.c (HTTP Admin)
184  */
185 
186 int httpadmin_start(Cfg *config);
187 /* int http_restart(Cfg *config); */
188 void httpadmin_stop(void);
189 
190 
191 /*-----------------
192  * bb_alog.c (Custom access-log format handling)
193  */
194 
195 /* passes the access-log-format string from config to the module */
196 void bb_alog_init(const Octstr *format);
197 
198 /* cleanup for internal things */
199 void bb_alog_shutdown(void);
200 
201 /* called from bb_smscconn.c to log the various access-log events */
202 void bb_alog_sms(SMSCConn *conn, Msg *sms, const char *message);
203 
204 
205 
206 /*----------------------------------------------------------------
207  * Core bearerbox public functions;
208  * used only via HTTP adminstration
209  */
210 
211 int bb_shutdown(void);
212 int bb_isolate(void);
213 int bb_suspend(void);
214 int bb_resume(void);
215 int bb_restart(void);
216 int bb_graceful_restart(void);
217 int bb_flush_dlr(void);
218 int bb_stop_smsc(Octstr *id);
219 int bb_add_smsc(Octstr *id);
220 int bb_remove_smsc(Octstr *id);
221 int bb_restart_smsc(Octstr *id);
222 int bb_remove_message(Octstr *id);
223 int bb_reload_lists(void);
224 int bb_reload_smsc_groups(void);
225 
226 /* return string of current status */
227 Octstr *bb_print_status(int status_type);
228 
229 
230 /*----------------------------------------------------------------
231  * common function to all (in bearerbox.c)
232  */
233 
234 /* return linebreak for given output format, or NULL if format
235  * not supported */
236 char *bb_status_linebreak(int status_type);
237 
238 
void smsc2_cleanup(void)
Definition: bb_smscconn.c:1314
int bb_flush_dlr(void)
Definition: bearerbox.c:916
int route_incoming_to_boxc(Msg *msg)
Definition: bb_boxc.c:1549
int udp_start(Cfg *config)
Definition: bb_udp.c:323
int bb_restart_smsc(Octstr *id)
Definition: bearerbox.c:933
int bb_reload_smsc_groups(void)
Definition: bb_smscconn.c:627
int bb_suspend(void)
Definition: bearerbox.c:880
int bb_isolate(void)
Definition: bearerbox.c:861
int bb_restart(void)
Definition: bearerbox.c:948
long smsc2_rout(Msg *msg, int resend)
Definition: bb_smscconn.c:1716
int smsc2_restart(Cfg *config)
void bb_alog_sms(SMSCConn *conn, Msg *sms, const char *message)
Definition: bb_alog.c:374
int bb_shutdown(void)
Definition: bearerbox.c:832
int bb_resume(void)
Definition: bearerbox.c:898
int smsc2_remove_smsc(Octstr *id)
Definition: bb_smscconn.c:1083
int udp_addwdp(Msg *msg)
Definition: bb_udp.c:385
Octstr * bb_print_status(int status_type)
Definition: bearerbox.c:998
int smsc2_stop_smsc(Octstr *id)
Definition: bb_smscconn.c:968
Definition: msg.h:79
Definition: cfg.c:164
int smsbox_start(Cfg *config)
Definition: bb_boxc.c:1250
Octstr * boxc_status(int status_type)
Definition: bb_boxc.c:1386
int bb_remove_message(Octstr *id)
Definition: bearerbox.c:976
void smsc2_resume(int is_init)
Definition: bb_smscconn.c:1234
Octstr * smsc2_status(int status_type)
Definition: bb_smscconn.c:1362
int smsbox_restart(Cfg *config)
Definition: bb_boxc.c:1316
void bb_alog_shutdown(void)
Definition: bb_alog.c:367
int boxc_incoming_wdp_queue(void)
Definition: bb_boxc.c:1510
int udp_outgoing_queue(void)
Definition: bb_udp.c:460
void boxc_cleanup(void)
Definition: bb_boxc.c:1527
Definition: octstr.c:118
int smsc2_shutdown(void)
Definition: bb_smscconn.c:1276
int bb_reload_lists(void)
Definition: bearerbox.c:971
int bb_stop_smsc(Octstr *id)
Definition: bearerbox.c:927
int httpadmin_start(Cfg *config)
Definition: bb_http.c:557
int bb_remove_smsc(Octstr *id)
Definition: bearerbox.c:943
int udp_die(void)
Definition: bb_udp.c:434
int udp_shutdown(void)
Definition: bb_udp.c:424
int smsc2_add_smsc(Octstr *id)
Definition: bb_smscconn.c:1112
void httpadmin_stop(void)
Definition: bb_http.c:618
int bb_add_smsc(Octstr *id)
Definition: bearerbox.c:938
int smsc2_reload_lists(void)
Definition: bb_smscconn.c:1174
char * bb_status_linebreak(int status_type)
Definition: bearerbox.c:1109
int wapbox_start(Cfg *config)
Definition: bb_boxc.c:1339
int smsc2_graceful_restart(Cfg *config)
Definition: bb_smscconn.c:1530
int smsc2_restart_smsc(Octstr *id)
Definition: bb_smscconn.c:998
void smsc2_suspend(void)
Definition: bb_smscconn.c:1259
int smsc2_start(Cfg *config)
Definition: bb_smscconn.c:806
static XMLRPCDocument * msg
Definition: test_xmlrpc.c:86
void bb_alog_init(const Octstr *format)
Definition: bb_alog.c:359
int bb_graceful_restart(void)
Definition: bearerbox.c:954
See file LICENSE for details about the license agreement for using, modifying, copying or deriving work from this software.