Kannel: Open Source WAP and SMS gateway  $Revision: 5037 $
bb_http.c
Go to the documentation of this file.
1 /* ====================================================================
2  * The Kannel Software License, Version 1.0
3  *
4  * Copyright (c) 2001-2016 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  * bb_http.c : bearerbox http adminstration commands
59  *
60  * NOTE: this is a special bearerbox module - it does call
61  * functions from core module! (other modules are fully
62  * encapsulated, and only called outside)
63  *
64  * Kalle Marjola <rpr@wapit.com> 2000 for project Kannel
65  */
66 
67 #include <errno.h>
68 #include <signal.h>
69 #include <unistd.h>
70 
71 #include "gwlib/gwlib.h"
72 #include "bearerbox.h"
73 
74 /* passed from bearerbox core */
75 
76 extern volatile sig_atomic_t bb_status;
77 
78 /* our own thingies */
79 
80 static volatile sig_atomic_t httpadmin_running;
81 
82 static long ha_port;
88 
89 
90 /*---------------------------------------------------------
91  * static functions
92  */
93 
94 /*
95  * check if the password matches. Return NULL if
96  * it does (or is not required)
97  */
99 {
100  Octstr *password;
101  static double sleep = 0.01;
102 
103  password = http_cgi_variable(cgivars, "password");
104 
105  if (status) {
106  if (ha_status_pw == NULL)
107  return NULL;
108 
109  if (password == NULL)
110  goto denied;
111 
112  if (octstr_compare(password, ha_password)!=0
113  && octstr_compare(password, ha_status_pw)!=0)
114  goto denied;
115  }
116  else {
117  if (password == NULL || octstr_compare(password, ha_password)!=0)
118  goto denied;
119  }
120  sleep = 0.0;
121  return NULL; /* allowed */
122 denied:
123  gwthread_sleep(sleep);
124  sleep += 1.0; /* little protection against brute force
125  * password cracking */
126  return octstr_create("Denied");
127 }
128 
129 /*
130  * check if we still have time to do things
131  */
133 {
134  if (bb_status == BB_SHUTDOWN || bb_status == BB_DEAD)
135  return octstr_create("Avalanche has already started, too late to "
136  "save the sheeps");
137  return NULL;
138 }
139 
140 static Octstr *httpd_status(List *cgivars, int status_type)
141 {
142  Octstr *reply;
143  if ((reply = httpd_check_authorization(cgivars, 1))!= NULL) return reply;
144  return bb_print_status(status_type);
145 }
146 
147 static Octstr *httpd_store_status(List *cgivars, int status_type)
148 {
149  Octstr *reply;
150  if ((reply = httpd_check_authorization(cgivars, 1))!= NULL) return reply;
151  return store_status(status_type);
152 }
153 
154 static Octstr *httpd_loglevel(List *cgivars, int status_type)
155 {
156  Octstr *reply;
157  Octstr *level;
158  int new_loglevel;
159 
160  if ((reply = httpd_check_authorization(cgivars, 0))!= NULL) return reply;
161  if ((reply = httpd_check_status())!= NULL) return reply;
162 
163  /* check if new loglevel is given */
164  level = http_cgi_variable(cgivars, "level");
165  if (level) {
166  new_loglevel = atoi(octstr_get_cstr(level));
167  log_set_log_level(new_loglevel);
168  return octstr_format("log-level set to %d", new_loglevel);
169  }
170  else {
171  return octstr_create("New level not given");
172  }
173 }
174 
175 static Octstr *httpd_shutdown(List *cgivars, int status_type)
176 {
177  Octstr *reply;
178  if ((reply = httpd_check_authorization(cgivars, 0))!= NULL) return reply;
179  if (bb_status == BB_SHUTDOWN)
180  bb_status = BB_DEAD;
181  else {
182  bb_shutdown();
184  }
185  return octstr_create("Bringing system down");
186 }
187 
188 static Octstr *httpd_isolate(List *cgivars, int status_type)
189 {
190  Octstr *reply;
191  if ((reply = httpd_check_authorization(cgivars, 0))!= NULL) return reply;
192  if ((reply = httpd_check_status())!= NULL) return reply;
193 
194  if (bb_isolate() == -1)
195  return octstr_create("Already isolated");
196  else
197  return octstr_create(GW_NAME " isolated from message providers");
198 }
199 
200 static Octstr *httpd_suspend(List *cgivars, int status_type)
201 {
202  Octstr *reply;
203  if ((reply = httpd_check_authorization(cgivars, 0))!= NULL) return reply;
204  if ((reply = httpd_check_status())!= NULL) return reply;
205 
206  if (bb_suspend() == -1)
207  return octstr_create("Already suspended");
208  else
209  return octstr_create(GW_NAME " suspended");
210 }
211 
212 static Octstr *httpd_resume(List *cgivars, int status_type)
213 {
214  Octstr *reply;
215  if ((reply = httpd_check_authorization(cgivars, 0))!= NULL) return reply;
216  if ((reply = httpd_check_status())!= NULL) return reply;
217 
218  if (bb_resume() == -1)
219  return octstr_create("Already running");
220  else
221  return octstr_create("Running resumed");
222 }
223 
224 static Octstr *httpd_restart(List *cgivars, int status_type)
225 {
226  Octstr *reply;
227  if ((reply = httpd_check_authorization(cgivars, 0))!= NULL) return reply;
228  if ((reply = httpd_check_status())!= NULL) return reply;
229 
230  if (bb_status == BB_SHUTDOWN) {
231  bb_status = BB_DEAD;
233  return octstr_create("Trying harder to restart");
234  }
235  bb_restart();
236  return octstr_create("Restarting.....");
237 }
238 
239 static Octstr *httpd_graceful_restart(List *cgivars, int status_type)
240 {
241  Octstr *reply;
242  if ((reply = httpd_check_authorization(cgivars, 0))!= NULL) return reply;
243  if ((reply = httpd_check_status())!= NULL) return reply;
244 
245  if (bb_status == BB_SHUTDOWN) {
246  bb_status = BB_DEAD;
247  bb_restart();
248  return octstr_create("Already in shutdown phase, restarting hard...");
249  }
251  return octstr_create("Restarting gracefully.....");
252 }
253 
254 static Octstr *httpd_flush_dlr(List *cgivars, int status_type)
255 {
256  Octstr *reply;
257  if ((reply = httpd_check_authorization(cgivars, 0))!= NULL) return reply;
258  if ((reply = httpd_check_status())!= NULL) return reply;
259 
260  if (bb_flush_dlr() == -1)
261  return octstr_create("Suspend " GW_NAME " before trying to flush DLR queue");
262  else
263  return octstr_create("DLR queue flushed");
264 }
265 
266 static Octstr *httpd_stop_smsc(List *cgivars, int status_type)
267 {
268  Octstr *reply;
269  Octstr *smsc;
270  if ((reply = httpd_check_authorization(cgivars, 0))!= NULL) return reply;
271  if ((reply = httpd_check_status())!= NULL) return reply;
272 
273  /* check if the smsc id is given */
274  smsc = http_cgi_variable(cgivars, "smsc");
275  if (smsc) {
276  if (bb_stop_smsc(smsc) == -1)
277  return octstr_format("Could not shut down smsc-id `%s'", octstr_get_cstr(smsc));
278  else
279  return octstr_format("SMSC `%s' shut down", octstr_get_cstr(smsc));
280  } else
281  return octstr_create("SMSC id not given");
282 }
283 
284 static Octstr *httpd_remove_smsc(List *cgivars, int status_type)
285 {
286  Octstr *reply;
287  Octstr *smsc;
288  if ((reply = httpd_check_authorization(cgivars, 0))!= NULL) return reply;
289  if ((reply = httpd_check_status())!= NULL) return reply;
290 
291  /* check if the smsc id is given */
292  smsc = http_cgi_variable(cgivars, "smsc");
293  if (smsc) {
294  if (bb_remove_smsc(smsc) == -1)
295  return octstr_format("Could not remove smsc-id `%s'", octstr_get_cstr(smsc));
296  else
297  return octstr_format("SMSC `%s' removed", octstr_get_cstr(smsc));
298  } else
299  return octstr_create("SMSC id not given");
300 }
301 
302 static Octstr *httpd_add_smsc(List *cgivars, int status_type)
303 {
304  Octstr *reply;
305  Octstr *smsc;
306  if ((reply = httpd_check_authorization(cgivars, 0))!= NULL) return reply;
307  if ((reply = httpd_check_status())!= NULL) return reply;
308 
309  /* check if the smsc id is given */
310  smsc = http_cgi_variable(cgivars, "smsc");
311  if (smsc) {
312  if (bb_add_smsc(smsc) == -1)
313  return octstr_format("Could not add smsc-id `%s'", octstr_get_cstr(smsc));
314  else
315  return octstr_format("SMSC `%s' added", octstr_get_cstr(smsc));
316  } else
317  return octstr_create("SMSC id not given");
318 }
319 
320 static Octstr *httpd_restart_smsc(List *cgivars, int status_type)
321 {
322  Octstr *reply;
323  Octstr *smsc;
324  if ((reply = httpd_check_authorization(cgivars, 0))!= NULL) return reply;
325  if ((reply = httpd_check_status())!= NULL) return reply;
326 
327  /* check if the smsc id is given */
328  smsc = http_cgi_variable(cgivars, "smsc");
329  if (smsc) {
330  if (bb_restart_smsc(smsc) == -1)
331  return octstr_format("Could not re-start smsc-id `%s'", octstr_get_cstr(smsc));
332  else
333  return octstr_format("SMSC `%s' re-started", octstr_get_cstr(smsc));
334  } else
335  return octstr_create("SMSC id not given");
336 }
337 
338 static Octstr *httpd_reload_lists(List *cgivars, int status_type)
339 {
340  Octstr *reply;
341  if ((reply = httpd_check_authorization(cgivars, 0))!= NULL) return reply;
342  if ((reply = httpd_check_status())!= NULL) return reply;
343 
344  if (bb_reload_lists() == -1)
345  return octstr_create("Could not re-load lists");
346  else
347  return octstr_create("Black/white lists re-loaded");
348 }
349 
350 static Octstr *httpd_remove_message(List *cgivars, int status_type)
351 {
352  Octstr *reply;
353  Octstr *message_id;
354  if ((reply = httpd_check_authorization(cgivars, 0))!= NULL) return reply;
355  if ((reply = httpd_check_status())!= NULL) return reply;
356 
357  /* check if the smsc id is given */
358  message_id = http_cgi_variable(cgivars, "id");
359  if (message_id) {
360  if (octstr_len(message_id) != UUID_STR_LEN)
361  return octstr_format("Message id should be %d characters long", UUID_STR_LEN);
362  if (bb_remove_message(message_id) == -1)
363  return octstr_format("Could not remove message id `%s'", octstr_get_cstr(message_id));
364  else
365  return octstr_format("Message id `%s' removed", octstr_get_cstr(message_id));
366  } else
367  return octstr_create("Message id not given");
368 }
369 
370 /* Known httpd commands and their functions */
371 static struct httpd_command {
372  const char *command;
373  Octstr * (*function)(List *cgivars, int status_type);
374 } httpd_commands[] = {
375  { "status", httpd_status },
376  { "store-status", httpd_store_status },
377  { "log-level", httpd_loglevel },
378  { "shutdown", httpd_shutdown },
379  { "suspend", httpd_suspend },
380  { "isolate", httpd_isolate },
381  { "resume", httpd_resume },
382  { "restart", httpd_restart },
383  { "graceful-restart", httpd_graceful_restart },
384  { "flush-dlr", httpd_flush_dlr },
385  { "stop-smsc", httpd_stop_smsc },
386  { "start-smsc", httpd_restart_smsc },
387  { "add-smsc", httpd_add_smsc },
388  { "remove-smsc", httpd_remove_smsc },
389  { "reload-lists", httpd_reload_lists },
390  { "remove-message", httpd_remove_message },
391  { NULL , NULL } /* terminate list */
392 };
393 
394 static void httpd_serve(HTTPClient *client, Octstr *ourl, List *headers,
395  Octstr *body, List *cgivars)
396 {
397  Octstr *reply, *final_reply, *url;
398  char *content_type;
399  char *header, *footer;
400  int status_type;
401  int i;
402  long pos;
403 
404  reply = final_reply = NULL; /* for compiler please */
405  url = octstr_duplicate(ourl);
406 
407  /* Set default reply format according to client
408  * Accept: header */
409  if (http_type_accepted(headers, "text/vnd.wap.wml")) {
410  status_type = BBSTATUS_WML;
411  content_type = "text/vnd.wap.wml";
412  }
413  else if (http_type_accepted(headers, "text/html")) {
414  status_type = BBSTATUS_HTML;
415  content_type = "text/html";
416  }
417  else if (http_type_accepted(headers, "text/xml")) {
418  status_type = BBSTATUS_XML;
419  content_type = "text/xml";
420  } else {
421  status_type = BBSTATUS_TEXT;
422  content_type = "text/plain";
423  }
424 
425  /* kill '/cgi-bin' prefix */
426  pos = octstr_search(url, octstr_imm("/cgi-bin/"), 0);
427  if (pos != -1)
428  octstr_delete(url, pos, 9);
429  else if (octstr_get_char(url, 0) == '/')
430  octstr_delete(url, 0, 1);
431 
432  /* look for type and kill it */
433  pos = octstr_search_char(url, '.', 0);
434  if (pos != -1) {
435  Octstr *tmp = octstr_copy(url, pos+1, octstr_len(url) - pos - 1);
436  octstr_delete(url, pos, octstr_len(url) - pos);
437 
438  if (octstr_str_compare(tmp, "txt") == 0)
439  status_type = BBSTATUS_TEXT;
440  else if (octstr_str_compare(tmp, "html") == 0)
441  status_type = BBSTATUS_HTML;
442  else if (octstr_str_compare(tmp, "xml") == 0)
443  status_type = BBSTATUS_XML;
444  else if (octstr_str_compare(tmp, "wml") == 0)
445  status_type = BBSTATUS_WML;
446 
447  octstr_destroy(tmp);
448  }
449 
450  for (i=0; httpd_commands[i].command != NULL; i++) {
451  if (octstr_str_compare(url, httpd_commands[i].command) == 0) {
452  reply = httpd_commands[i].function(cgivars, status_type);
453  break;
454  }
455  }
456 
457  /* check if command found */
458  if (httpd_commands[i].command == NULL) {
459  char *lb = bb_status_linebreak(status_type);
460  reply = octstr_format("Unknown command `%S'.%sPossible commands are:%s",
461  ourl, lb, lb);
462  for (i=0; httpd_commands[i].command != NULL; i++)
463  octstr_format_append(reply, "%s%s", httpd_commands[i].command, lb);
464  }
465 
466  gw_assert(reply != NULL);
467 
468  if (status_type == BBSTATUS_HTML) {
469  header = "<!DOCTYPE HTML PUBLIC \"-//W3C//DTD HTML 3.2//EN\">\n"
470  "<html>\n<title>" GW_NAME "</title>\n<body>\n<p>";
471  footer = "</p>\n</body></html>\n";
472  content_type = "text/html";
473  } else if (status_type == BBSTATUS_WML) {
474  header = "<?xml version=\"1.0\"?>\n"
475  "<!DOCTYPE wml PUBLIC \"-//WAPFORUM//DTD WML 1.1//EN\" "
476  "\"http://www.wapforum.org/DTD/wml_1.1.xml\">\n"
477  "\n<wml>\n <card>\n <p>";
478  footer = " </p>\n </card>\n</wml>\n";
479  content_type = "text/vnd.wap.wml";
480  } else if (status_type == BBSTATUS_XML) {
481  header = "<?xml version=\"1.0\"?>\n"
482  "<gateway>\n";
483  footer = "</gateway>\n";
484  } else {
485  header = "";
486  footer = "";
487  content_type = "text/plain";
488  }
489  final_reply = octstr_create(header);
490  octstr_append(final_reply, reply);
491  octstr_append_cstr(final_reply, footer);
492 
493  /* debug("bb.http", 0, "Result: '%s'", octstr_get_cstr(final_reply));
494  */
495  http_destroy_headers(headers);
496  headers = gwlist_create();
497  http_header_add(headers, "Content-Type", content_type);
498 
499  http_send_reply(client, HTTP_OK, headers, final_reply);
500 
501  octstr_destroy(url);
502  octstr_destroy(ourl);
503  octstr_destroy(body);
504  octstr_destroy(reply);
505  octstr_destroy(final_reply);
506  http_destroy_headers(headers);
507  http_destroy_cgiargs(cgivars);
508 }
509 
510 static void httpadmin_run(void *arg)
511 {
513  Octstr *ip, *url, *body;
514  List *headers, *cgivars;
515 
516  while(bb_status != BB_DEAD) {
517  if (bb_status == BB_SHUTDOWN)
518  bb_shutdown();
519  client = http_accept_request(ha_port, &ip, &url, &headers, &body,
520  &cgivars);
521  if (client == NULL)
522  break;
523  if (is_allowed_ip(ha_allow_ip, ha_deny_ip, ip) == 0) {
524  info(0, "HTTP admin tried from denied host <%s>, disconnected",
525  octstr_get_cstr(ip));
526  http_close_client(client);
527  continue;
528  }
529  httpd_serve(client, url, headers, body, cgivars);
530  octstr_destroy(ip);
531  }
532 
533  httpadmin_running = 0;
534 }
535 
536 
537 /*-------------------------------------------------------------
538  * public functions
539  *
540  */
541 
543 {
544  CfgGroup *grp;
545  int ssl = 0;
546 #ifdef HAVE_LIBSSL
547  Octstr *ssl_server_cert_file;
548  Octstr *ssl_server_key_file;
549 #endif /* HAVE_LIBSSL */
550 
551  if (httpadmin_running) return -1;
552 
553 
554  grp = cfg_get_single_group(cfg, octstr_imm("core"));
555  if (cfg_get_integer(&ha_port, grp, octstr_imm("admin-port")) == -1)
556  panic(0, "Missing admin-port variable, cannot start HTTP admin");
557 
558  ha_interface = cfg_get(grp, octstr_imm("admin-interface"));
559  ha_password = cfg_get(grp, octstr_imm("admin-password"));
560  if (ha_password == NULL)
561  panic(0, "You MUST set HTTP admin-password");
562 
563  ha_status_pw = cfg_get(grp, octstr_imm("status-password"));
564 
565  ha_allow_ip = cfg_get(grp, octstr_imm("admin-allow-ip"));
566  ha_deny_ip = cfg_get(grp, octstr_imm("admin-deny-ip"));
567 
568 #ifdef HAVE_LIBSSL
569  cfg_get_bool(&ssl, grp, octstr_imm("admin-port-ssl"));
570 
571  /*
572  * check if SSL is desired for HTTP servers and then
573  * load SSL client and SSL server public certificates
574  * and private keys
575  */
576  ssl_server_cert_file = cfg_get(grp, octstr_imm("ssl-server-cert-file"));
577  ssl_server_key_file = cfg_get(grp, octstr_imm("ssl-server-key-file"));
578  if (ssl_server_cert_file != NULL && ssl_server_key_file != NULL) {
579  /* we are fine here, the following call is now in conn_config_ssl(),
580  * so there is no reason to do this twice.
581 
582  use_global_server_certkey_file(ssl_server_cert_file,
583  ssl_server_key_file);
584  */
585  } else if (ssl) {
586  panic(0, "You MUST specify cert and key files within core group for SSL-enabled HTTP servers!");
587  }
588 
589  octstr_destroy(ssl_server_cert_file);
590  octstr_destroy(ssl_server_key_file);
591 #endif /* HAVE_LIBSSL */
592 
593  http_open_port_if(ha_port, ssl, ha_interface);
594 
595  if (gwthread_create(httpadmin_run, NULL) == -1)
596  panic(0, "Failed to start a new thread for HTTP admin");
597 
598  httpadmin_running = 1;
599  return 0;
600 }
601 
602 
603 void httpadmin_stop(void)
604 {
607  octstr_destroy(ha_interface);
608  octstr_destroy(ha_password);
609  octstr_destroy(ha_status_pw);
610  octstr_destroy(ha_allow_ip);
611  octstr_destroy(ha_deny_ip);
612  ha_password = NULL;
613  ha_status_pw = NULL;
614  ha_allow_ip = NULL;
615  ha_deny_ip = NULL;
616 }
static Octstr * httpd_resume(List *cgivars, int status_type)
Definition: bb_http.c:212
int httpadmin_start(Cfg *cfg)
Definition: bb_http.c:542
void info(int err, const char *fmt,...)
Definition: log.c:636
static long ha_port
Definition: bb_http.c:82
static Octstr * httpd_reload_lists(List *cgivars, int status_type)
Definition: bb_http.c:338
static Octstr * ha_deny_ip
Definition: bb_http.c:87
void http_header_add(List *headers, char *name, char *contents)
Definition: http.c:2863
int ssl
void http_close_client(HTTPClient *client)
Definition: http.c:2735
char * bb_status_linebreak(int status_type)
Definition: bearerbox.c:1097
static Octstr * httpd_flush_dlr(List *cgivars, int status_type)
Definition: bb_http.c:254
void octstr_append(Octstr *ostr1, const Octstr *ostr2)
Definition: octstr.c:1502
static void client(int port)
Definition: test_udp.c:77
static Octstr * ha_allow_ip
Definition: bb_http.c:86
static Octstr * ha_status_pw
Definition: bb_http.c:85
long octstr_search(const Octstr *haystack, const Octstr *needle, long pos)
Definition: octstr.c:1068
#define cfg_get(grp, varname)
Definition: cfg.h:86
static struct httpd_command httpd_commands[]
static Octstr * httpd_isolate(List *cgivars, int status_type)
Definition: bb_http.c:188
Octstr * store_status(int status_type)
Definition: bb_store.c:148
static volatile sig_atomic_t httpadmin_running
Definition: bb_http.c:80
void octstr_append_cstr(Octstr *ostr, const char *cstr)
Definition: octstr.c:1509
int bb_add_smsc(Octstr *id)
Definition: bearerbox.c:938
int bb_restart_smsc(Octstr *id)
Definition: bearerbox.c:933
#define octstr_get_cstr(ostr)
Definition: octstr.h:233
static Octstr * httpd_graceful_restart(List *cgivars, int status_type)
Definition: bb_http.c:239
#define octstr_copy(ostr, from, len)
Definition: octstr.h:178
long octstr_search_char(const Octstr *ostr, int ch, long pos)
Definition: octstr.c:1010
void gwthread_join_every(gwthread_func_t *func)
int is_allowed_ip(Octstr *allow_ip, Octstr *deny_ip, Octstr *ip)
Definition: utils.c:815
Octstr * http_cgi_variable(List *list, char *name)
Definition: http.c:2813
static Octstr * httpd_store_status(List *cgivars, int status_type)
Definition: bb_http.c:147
void http_destroy_headers(List *headers)
Definition: http.c:2856
static Octstr * httpd_status(List *cgivars, int status_type)
Definition: bb_http.c:140
void http_destroy_cgiargs(List *args)
Definition: http.c:2795
static Octstr * httpd_loglevel(List *cgivars, int status_type)
Definition: bb_http.c:154
int bb_remove_smsc(Octstr *id)
Definition: bearerbox.c:943
unsigned char * password
Definition: test_cimd2.c:100
static Octstr * ha_password
Definition: bb_http.c:84
void http_send_reply(HTTPClient *client, int status, List *headers, Octstr *body)
Definition: http.c:2671
Octstr * octstr_imm(const char *cstr)
Definition: octstr.c:281
Definition: http.h:142
int bb_flush_dlr(void)
Definition: bearerbox.c:916
Definition: cfg.c:164
static Octstr * httpd_restart_smsc(List *cgivars, int status_type)
Definition: bb_http.c:320
HTTPClient * http_accept_request(int port, Octstr **client_ip, Octstr **url, List **headers, Octstr **body, List **cgivars)
Definition: http.c:2574
void octstr_delete(Octstr *ostr1, long pos, long len)
Definition: octstr.c:1525
const char * command
Definition: bb_http.c:372
void httpadmin_stop(void)
Definition: bb_http.c:603
volatile sig_atomic_t bb_status
Definition: bearerbox.c:132
void log_set_log_level(enum output_level level)
Definition: log.c:229
static Octstr * httpd_remove_message(List *cgivars, int status_type)
Definition: bb_http.c:350
int bb_suspend(void)
Definition: bearerbox.c:880
int bb_reload_lists(void)
Definition: bearerbox.c:959
#define octstr_duplicate(ostr)
Definition: octstr.h:187
int bb_stop_smsc(Octstr *id)
Definition: bearerbox.c:927
int bb_graceful_restart(void)
Definition: bearerbox.c:954
Octstr * octstr_format(const char *fmt,...)
Definition: octstr.c:2462
void octstr_destroy(Octstr *ostr)
Definition: octstr.c:322
#define gwthread_create(func, arg)
Definition: gwthread.h:90
#define octstr_create(cstr)
Definition: octstr.h:125
gw_assert(wtls_machine->packet_to_send!=NULL)
void gwthread_sleep(double seconds)
const char * content_type
Definition: fakewap.c:249
static Octstr * ha_interface
Definition: bb_http.c:83
static void httpd_serve(HTTPClient *client, Octstr *ourl, List *headers, Octstr *body, List *cgivars)
Definition: bb_http.c:394
#define UUID_STR_LEN
Definition: gw_uuid.h:19
int http_open_port_if(int port, int ssl, Octstr *interface)
Definition: http.c:2472
static Cfg * cfg
Definition: smsbox.c:115
Octstr *(* function)(List *cgivars, int status_type)
Definition: bb_http.c:373
void http_close_all_ports(void)
Definition: http.c:2515
long octstr_len(const Octstr *ostr)
Definition: octstr.c:340
int cfg_get_bool(int *n, CfgGroup *grp, Octstr *varname)
Definition: cfg.c:756
Definition: octstr.c:118
int bb_shutdown(void)
Definition: bearerbox.c:832
static Octstr * httpd_check_status(void)
Definition: bb_http.c:132
int bb_resume(void)
Definition: bearerbox.c:898
static Octstr * httpd_check_authorization(List *cgivars, int status)
Definition: bb_http.c:98
int cfg_get_integer(long *n, CfgGroup *grp, Octstr *varname)
Definition: cfg.c:739
#define panic
Definition: log.h:87
void gwthread_wakeup(long thread)
Definition: cfg.c:73
int octstr_str_compare(const Octstr *ostr, const char *str)
Definition: octstr.c:971
static Octstr * httpd_suspend(List *cgivars, int status_type)
Definition: bb_http.c:200
void octstr_format_append(Octstr *os, const char *fmt,...)
Definition: octstr.c:2505
#define gwlist_create()
Definition: list.h:136
int bb_remove_message(Octstr *message_id)
Definition: bearerbox.c:964
#define MAIN_THREAD_ID
Definition: gwthread.h:77
static Octstr * httpd_shutdown(List *cgivars, int status_type)
Definition: bb_http.c:175
int http_type_accepted(List *headers, char *type)
Definition: http.c:3480
CfgGroup * cfg_get_single_group(Cfg *cfg, Octstr *name)
Definition: cfg.c:636
int bb_isolate(void)
Definition: bearerbox.c:861
static Octstr * httpd_restart(List *cgivars, int status_type)
Definition: bb_http.c:224
int bb_restart(void)
Definition: bearerbox.c:948
static Octstr * url
Definition: test_xmlrpc.c:84
int octstr_get_char(const Octstr *ostr, long pos)
Definition: octstr.c:404
void gwthread_wakeup_all(void)
static Octstr * httpd_add_smsc(List *cgivars, int status_type)
Definition: bb_http.c:302
Definition: list.c:102
static Octstr * httpd_stop_smsc(List *cgivars, int status_type)
Definition: bb_http.c:266
Octstr * bb_print_status(int status_type)
Definition: bearerbox.c:986
static void reply(HTTPClient *c, List *push_headers)
static Octstr * httpd_remove_smsc(List *cgivars, int status_type)
Definition: bb_http.c:284
static void httpadmin_run(void *arg)
Definition: bb_http.c:510
int octstr_compare(const Octstr *ostr1, const Octstr *ostr2)
Definition: octstr.c:869
See file LICENSE for details about the license agreement for using, modifying, copying or deriving work from this software.