Kannel: Open Source WAP and SMS gateway  svn-r5335
bb_http.c
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  * 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 
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  }
250  if (bb_graceful_restart() == -1)
251  return octstr_create("Unable to restart gracefully! Please check log file.");
252  else
253  return octstr_create("Restarting gracefully.....");
254 }
255 
256 static Octstr *httpd_flush_dlr(List *cgivars, int status_type)
257 {
258  Octstr *reply;
259  if ((reply = httpd_check_authorization(cgivars, 0))!= NULL) return reply;
260  if ((reply = httpd_check_status())!= NULL) return reply;
261 
262  if (bb_flush_dlr() == -1)
263  return octstr_create("Suspend " GW_NAME " before trying to flush DLR queue");
264  else
265  return octstr_create("DLR queue flushed");
266 }
267 
268 static Octstr *httpd_stop_smsc(List *cgivars, int status_type)
269 {
270  Octstr *reply;
271  Octstr *smsc;
272  if ((reply = httpd_check_authorization(cgivars, 0))!= NULL) return reply;
273  if ((reply = httpd_check_status())!= NULL) return reply;
274 
275  /* check if the smsc id is given */
276  smsc = http_cgi_variable(cgivars, "smsc");
277  if (smsc) {
278  if (bb_stop_smsc(smsc) == -1)
279  return octstr_format("Could not shut down smsc-id `%s'", octstr_get_cstr(smsc));
280  else
281  return octstr_format("SMSC `%s' shut down", octstr_get_cstr(smsc));
282  } else
283  return octstr_create("SMSC id not given");
284 }
285 
286 static Octstr *httpd_remove_smsc(List *cgivars, int status_type)
287 {
288  Octstr *reply;
289  Octstr *smsc;
290  if ((reply = httpd_check_authorization(cgivars, 0))!= NULL) return reply;
291  if ((reply = httpd_check_status())!= NULL) return reply;
292 
293  /* check if the smsc id is given */
294  smsc = http_cgi_variable(cgivars, "smsc");
295  if (smsc) {
296  if (bb_remove_smsc(smsc) == -1)
297  return octstr_format("Could not remove smsc-id `%s'", octstr_get_cstr(smsc));
298  else
299  return octstr_format("SMSC `%s' removed", octstr_get_cstr(smsc));
300  } else
301  return octstr_create("SMSC id not given");
302 }
303 
304 static Octstr *httpd_add_smsc(List *cgivars, int status_type)
305 {
306  Octstr *reply;
307  Octstr *smsc;
308  if ((reply = httpd_check_authorization(cgivars, 0))!= NULL) return reply;
309  if ((reply = httpd_check_status())!= NULL) return reply;
310 
311  /* check if the smsc id is given */
312  smsc = http_cgi_variable(cgivars, "smsc");
313  if (smsc) {
314  if (bb_add_smsc(smsc) == -1)
315  return octstr_format("Could not add smsc-id `%s'", octstr_get_cstr(smsc));
316  else
317  return octstr_format("SMSC `%s' added", octstr_get_cstr(smsc));
318  } else
319  return octstr_create("SMSC id not given");
320 }
321 
322 static Octstr *httpd_restart_smsc(List *cgivars, int status_type)
323 {
324  Octstr *reply;
325  Octstr *smsc;
326  if ((reply = httpd_check_authorization(cgivars, 0))!= NULL) return reply;
327  if ((reply = httpd_check_status())!= NULL) return reply;
328 
329  /* check if the smsc id is given */
330  smsc = http_cgi_variable(cgivars, "smsc");
331  if (smsc) {
332  if (bb_restart_smsc(smsc) == -1)
333  return octstr_format("Could not re-start smsc-id `%s'", octstr_get_cstr(smsc));
334  else
335  return octstr_format("SMSC `%s' re-started", octstr_get_cstr(smsc));
336  } else
337  return octstr_create("SMSC id not given");
338 }
339 
340 static Octstr *httpd_reload_lists(List *cgivars, int status_type)
341 {
342  Octstr *reply;
343  if ((reply = httpd_check_authorization(cgivars, 0))!= NULL) return reply;
344  if ((reply = httpd_check_status())!= NULL) return reply;
345 
346  if (bb_reload_lists() == -1)
347  return octstr_create("Could not re-load lists");
348  else
349  return octstr_create("Black/white lists re-loaded");
350 }
351 
352 static Octstr *httpd_remove_message(List *cgivars, int status_type)
353 {
354  Octstr *reply;
355  Octstr *message_id;
356  if ((reply = httpd_check_authorization(cgivars, 0))!= NULL) return reply;
357  if ((reply = httpd_check_status())!= NULL) return reply;
358 
359  /* check if the smsc id is given */
360  message_id = http_cgi_variable(cgivars, "id");
361  if (message_id) {
362  if (octstr_len(message_id) != UUID_STR_LEN)
363  return octstr_format("Message id should be %d characters long", UUID_STR_LEN);
364  if (bb_remove_message(message_id) == -1)
365  return octstr_format("Could not remove message id `%s'", octstr_get_cstr(message_id));
366  else
367  return octstr_format("Message id `%s' removed", octstr_get_cstr(message_id));
368  } else
369  return octstr_create("Message id not given");
370 }
371 
372 /* Known httpd commands and their functions */
373 static struct httpd_command {
374  const char *command;
375  Octstr * (*function)(List *cgivars, int status_type);
376 } httpd_commands[] = {
377  { "status", httpd_status },
378  { "store-status", httpd_store_status },
379  { "log-level", httpd_loglevel },
380  { "shutdown", httpd_shutdown },
381  { "suspend", httpd_suspend },
382  { "isolate", httpd_isolate },
383  { "resume", httpd_resume },
384  { "restart", httpd_restart },
385  { "graceful-restart", httpd_graceful_restart },
386  { "flush-dlr", httpd_flush_dlr },
387  { "stop-smsc", httpd_stop_smsc },
388  { "start-smsc", httpd_restart_smsc },
389  { "add-smsc", httpd_add_smsc },
390  { "remove-smsc", httpd_remove_smsc },
391  { "reload-lists", httpd_reload_lists },
392  { "remove-message", httpd_remove_message },
393  { NULL , NULL } /* terminate list */
394 };
395 
396 static void httpd_serve(HTTPClient *client, Octstr *ourl, List *headers,
397  Octstr *body, List *cgivars)
398 {
399  Octstr *reply, *final_reply, *url;
400  char *content_type;
401  char *header, *footer;
402  int status_type;
403  int i;
404  long pos;
405 
406  reply = final_reply = NULL; /* for compiler please */
407  url = octstr_duplicate(ourl);
408 
409  /* Set default reply format according to client
410  * Accept: header */
411  if (http_type_accepted(headers, "text/vnd.wap.wml")) {
412  status_type = BBSTATUS_WML;
413  content_type = "text/vnd.wap.wml";
414  }
415  else if (http_type_accepted(headers, "text/html")) {
416  status_type = BBSTATUS_HTML;
417  content_type = "text/html";
418  }
419  else if (http_type_accepted(headers, "text/xml")) {
420  status_type = BBSTATUS_XML;
421  content_type = "text/xml";
422  }
423  else if (http_type_accepted(headers, "application/xml")) {
424  status_type = BBSTATUS_XML;
425  content_type = "application/xml";
426  }
427  else {
428  status_type = BBSTATUS_TEXT;
429  content_type = "text/plain";
430  }
431 
432  /* kill '/cgi-bin' prefix */
433  pos = octstr_search(url, octstr_imm("/cgi-bin/"), 0);
434  if (pos != -1)
435  octstr_delete(url, pos, 9);
436  else if (octstr_get_char(url, 0) == '/')
437  octstr_delete(url, 0, 1);
438 
439  /* look for type and kill it */
440  pos = octstr_search_char(url, '.', 0);
441  if (pos != -1) {
442  Octstr *tmp = octstr_copy(url, pos+1, octstr_len(url) - pos - 1);
443  octstr_delete(url, pos, octstr_len(url) - pos);
444 
445  if (octstr_str_compare(tmp, "txt") == 0) {
446  status_type = BBSTATUS_TEXT;
447  content_type = "text/plain";
448  }
449  else if (octstr_str_compare(tmp, "html") == 0) {
450  status_type = BBSTATUS_HTML;
451  content_type = "text/html";
452  }
453  else if (octstr_str_compare(tmp, "xml") == 0) {
454  status_type = BBSTATUS_XML;
455  content_type = "application/xml";
456  }
457  else if (octstr_str_compare(tmp, "wml") == 0) {
458  status_type = BBSTATUS_WML;
459  content_type = "text/vnd.wap.wml";
460  }
461 
462  octstr_destroy(tmp);
463  }
464 
465  for (i=0; httpd_commands[i].command != NULL; i++) {
466  if (octstr_str_compare(url, httpd_commands[i].command) == 0) {
467  reply = httpd_commands[i].function(cgivars, status_type);
468  break;
469  }
470  }
471 
472  /* check if command found */
473  if (httpd_commands[i].command == NULL) {
474  char *lb = bb_status_linebreak(status_type);
475  reply = octstr_format("Unknown command `%S'.%sPossible commands are:%s",
476  ourl, lb, lb);
477  for (i=0; httpd_commands[i].command != NULL; i++)
478  octstr_format_append(reply, "%s%s", httpd_commands[i].command, lb);
479  }
480 
481  gw_assert(reply != NULL);
482 
483  if (status_type == BBSTATUS_HTML) {
484  header = "<!DOCTYPE HTML PUBLIC \"-//W3C//DTD HTML 3.2//EN\">\n"
485  "<html>\n<title>" GW_NAME "</title>\n<body>\n<p>";
486  footer = "</p>\n</body></html>\n";
487  content_type = "text/html";
488  } else if (status_type == BBSTATUS_WML) {
489  header = "<?xml version=\"1.0\"?>\n"
490  "<!DOCTYPE wml PUBLIC \"-//WAPFORUM//DTD WML 1.1//EN\" "
491  "\"http://www.wapforum.org/DTD/wml_1.1.xml\">\n"
492  "\n<wml>\n <card>\n <p>";
493  footer = " </p>\n </card>\n</wml>\n";
494  content_type = "text/vnd.wap.wml";
495  } else if (status_type == BBSTATUS_XML) {
496  header = "<?xml version=\"1.0\"?>\n"
497  "<gateway>\n";
498  footer = "</gateway>\n";
499  } else {
500  header = "";
501  footer = "";
502  content_type = "text/plain";
503  }
504  final_reply = octstr_create(header);
505  octstr_append(final_reply, reply);
506  octstr_append_cstr(final_reply, footer);
507 
508  /* debug("bb.http", 0, "Result: '%s'", octstr_get_cstr(final_reply));
509  */
510  http_destroy_headers(headers);
511  headers = gwlist_create();
512  http_header_add(headers, "Content-Type", content_type);
513 
514  http_send_reply(client, HTTP_OK, headers, final_reply);
515 
517  octstr_destroy(ourl);
518  octstr_destroy(body);
520  octstr_destroy(final_reply);
521  http_destroy_headers(headers);
522  http_destroy_cgiargs(cgivars);
523 }
524 
525 static void httpadmin_run(void *arg)
526 {
528  Octstr *ip, *url, *body;
529  List *headers, *cgivars;
530 
531  while(bb_status != BB_DEAD) {
532  if (bb_status == BB_SHUTDOWN)
533  bb_shutdown();
534  client = http_accept_request(ha_port, &ip, &url, &headers, &body,
535  &cgivars);
536  if (client == NULL)
537  break;
538  if (is_allowed_ip(ha_allow_ip, ha_deny_ip, ip) == 0) {
539  info(0, "HTTP admin tried from denied host <%s>, disconnected",
540  octstr_get_cstr(ip));
542  continue;
543  }
544  httpd_serve(client, url, headers, body, cgivars);
545  octstr_destroy(ip);
546  }
547 
548  httpadmin_running = 0;
549 }
550 
551 
552 /*-------------------------------------------------------------
553  * public functions
554  *
555  */
556 
558 {
559  CfgGroup *grp;
560  int ssl = 0;
561 #ifdef HAVE_LIBSSL
562  Octstr *ssl_server_cert_file;
563  Octstr *ssl_server_key_file;
564 #endif /* HAVE_LIBSSL */
565 
566  if (httpadmin_running) return -1;
567 
568 
569  grp = cfg_get_single_group(cfg, octstr_imm("core"));
570  if (cfg_get_integer(&ha_port, grp, octstr_imm("admin-port")) == -1)
571  panic(0, "Missing admin-port variable, cannot start HTTP admin");
572 
573  ha_interface = cfg_get(grp, octstr_imm("admin-interface"));
574  ha_password = cfg_get(grp, octstr_imm("admin-password"));
575  if (ha_password == NULL)
576  panic(0, "You MUST set HTTP admin-password");
577 
578  ha_status_pw = cfg_get(grp, octstr_imm("status-password"));
579 
580  ha_allow_ip = cfg_get(grp, octstr_imm("admin-allow-ip"));
581  ha_deny_ip = cfg_get(grp, octstr_imm("admin-deny-ip"));
582 
583 #ifdef HAVE_LIBSSL
584  cfg_get_bool(&ssl, grp, octstr_imm("admin-port-ssl"));
585 
586  /*
587  * check if SSL is desired for HTTP servers and then
588  * load SSL client and SSL server public certificates
589  * and private keys
590  */
591  ssl_server_cert_file = cfg_get(grp, octstr_imm("ssl-server-cert-file"));
592  ssl_server_key_file = cfg_get(grp, octstr_imm("ssl-server-key-file"));
593  if (ssl_server_cert_file != NULL && ssl_server_key_file != NULL) {
594  /* we are fine here, the following call is now in conn_config_ssl(),
595  * so there is no reason to do this twice.
596 
597  use_global_server_certkey_file(ssl_server_cert_file,
598  ssl_server_key_file);
599  */
600  } else if (ssl) {
601  panic(0, "You MUST specify cert and key files within core group for SSL-enabled HTTP servers!");
602  }
603 
604  octstr_destroy(ssl_server_cert_file);
605  octstr_destroy(ssl_server_key_file);
606 #endif /* HAVE_LIBSSL */
607 
609 
610  if (gwthread_create(httpadmin_run, NULL) == -1)
611  panic(0, "Failed to start a new thread for HTTP admin");
612 
613  httpadmin_running = 1;
614  return 0;
615 }
616 
617 
618 void httpadmin_stop(void)
619 {
627  ha_password = NULL;
628  ha_status_pw = NULL;
629  ha_allow_ip = NULL;
630  ha_deny_ip = NULL;
631 }
static Octstr * httpd_resume(List *cgivars, int status_type)
Definition: bb_http.c:212
int httpadmin_start(Cfg *cfg)
Definition: bb_http.c:557
void info(int err, const char *fmt,...)
Definition: log.c:672
static long ha_port
Definition: bb_http.c:82
static Octstr * httpd_reload_lists(List *cgivars, int status_type)
Definition: bb_http.c:340
static Octstr * ha_deny_ip
Definition: bb_http.c:87
void http_header_add(List *headers, char *name, char *contents)
Definition: http.c:2886
gw_assert(wtls_machine->packet_to_send !=NULL)
int ssl
void http_close_client(HTTPClient *client)
Definition: http.c:2758
char * bb_status_linebreak(int status_type)
Definition: bearerbox.c:1109
static Octstr * httpd_flush_dlr(List *cgivars, int status_type)
Definition: bb_http.c:256
void octstr_append(Octstr *ostr1, const Octstr *ostr2)
Definition: octstr.c:1504
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:1070
#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:1511
static Cfg * cfg
Definition: opensmppbox.c:95
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:1012
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:2836
static Octstr * httpd_store_status(List *cgivars, int status_type)
Definition: bb_http.c:147
void http_destroy_headers(List *headers)
Definition: http.c:2879
static Octstr * httpd_status(List *cgivars, int status_type)
Definition: bb_http.c:140
void http_destroy_cgiargs(List *args)
Definition: http.c:2818
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:2695
Octstr * octstr_imm(const char *cstr)
Definition: octstr.c:283
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:322
HTTPClient * http_accept_request(int port, Octstr **client_ip, Octstr **url, List **headers, Octstr **body, List **cgivars)
Definition: http.c:2571
void octstr_delete(Octstr *ostr1, long pos, long len)
Definition: octstr.c:1527
const char * command
Definition: bb_http.c:374
void httpadmin_stop(void)
Definition: bb_http.c:618
volatile sig_atomic_t bb_status
Definition: bearerbox.c:132
void log_set_log_level(enum output_level level)
Definition: log.c:265
static Octstr * httpd_remove_message(List *cgivars, int status_type)
Definition: bb_http.c:352
int bb_suspend(void)
Definition: bearerbox.c:880
int bb_reload_lists(void)
Definition: bearerbox.c:971
#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:2464
void octstr_destroy(Octstr *ostr)
Definition: octstr.c:324
#define gwthread_create(func, arg)
Definition: gwthread.h:90
#define octstr_create(cstr)
Definition: octstr.h:125
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:396
#define UUID_STR_LEN
Definition: gw_uuid.h:19
int http_open_port_if(int port, int ssl, Octstr *interface)
Definition: http.c:2483
Octstr *(* function)(List *cgivars, int status_type)
Definition: bb_http.c:375
void http_close_all_ports(void)
Definition: http.c:2526
long octstr_len(const Octstr *ostr)
Definition: octstr.c:342
int cfg_get_bool(int *n, CfgGroup *grp, Octstr *varname)
Definition: cfg.c:759
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:742
#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:973
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:2507
#define gwlist_create()
Definition: list.h:136
int bb_remove_message(Octstr *message_id)
Definition: bearerbox.c:976
#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:3503
CfgGroup * cfg_get_single_group(Cfg *cfg, Octstr *name)
Definition: cfg.c:639
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:406
void gwthread_wakeup_all(void)
static Octstr * httpd_add_smsc(List *cgivars, int status_type)
Definition: bb_http.c:304
Definition: list.c:102
static Octstr * httpd_stop_smsc(List *cgivars, int status_type)
Definition: bb_http.c:268
Octstr * bb_print_status(int status_type)
Definition: bearerbox.c:998
static void reply(HTTPClient *c, List *push_headers)
static Octstr * httpd_remove_smsc(List *cgivars, int status_type)
Definition: bb_http.c:286
static void httpadmin_run(void *arg)
Definition: bb_http.c:525
int octstr_compare(const Octstr *ostr1, const Octstr *ostr2)
Definition: octstr.c:871
See file LICENSE for details about the license agreement for using, modifying, copying or deriving work from this software.