Kannel: Open Source WAP and SMS gateway  svn-r5262
smsc_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  * smsc_http.c - interface to various HTTP based content/SMS gateways
59  *
60  * HTTP based "SMSC Connection" is meant for gateway connections,
61  * and has following features:
62  *
63  * o Kannel listens to certain (HTTP server) port for MO SMS messages.
64  * The exact format of these HTTP calls are defined by type of HTTP based
65  * connection. Kannel replies to these messages as ACK, but does not
66  * support immediate reply. Thus, if Kannel is linked to another Kannel,
67  * only 'max-messages = 0' services are practically supported - any
68  * replies must be done with SMS PUSH (sendsms)
69  *
70  * o For MT messages, Kannel does HTTP GET or POST to given address, in format
71  * defined by type of HTTP based protocol
72  *
73  * The 'type' of requests and replies are defined by 'system-type' variable.
74  * The only type of HTTP requests currently supported are basic Kannel.
75  * If new support is added, smsc_http_create is modified accordingly and new
76  * functions added.
77  *
78  *
79  * KANNEL->KANNEL linking: (UDH not supported in MO messages)
80  *
81  *****
82  * FOR CLIENT/END-POINT KANNEL:
83  *
84  * group = smsc
85  * smsc = http
86  * system-type = kannel
87  * port = NNN
88  * smsc-username = XXX
89  * smsc-password = YYY
90  * send-url = "server.host:PORT"
91  *
92  *****
93  * FOR SERVER/RELAY KANNEL:
94  *
95  * group = smsbox
96  * sendsms-port = PORT
97  * ...
98  *
99  * group = sms-service
100  * keyword = ...
101  * url = "client.host:NNN/sms?user=XXX&pass=YYY&from=%p&to=%P&text=%a"
102  * max-messages = 0
103  *
104  * group = send-sms
105  * username = XXX
106  * password = YYY
107  *
108  * Kalle Marjola for Project Kannel 2001
109  * Stipe Tolj <st@tolj.org>
110  * Alexander Malysh <amalysh at kannel.org>
111  * Tobias Weber <weber@wapme.de>
112  */
113 
114 #include <sys/types.h>
115 #include <sys/socket.h>
116 #include <unistd.h>
117 #include <errno.h>
118 #include <time.h>
119 #include <limits.h>
120 
121 #include "gwlib/gwlib.h"
122 #include "smscconn.h"
123 #include "smscconn_p.h"
124 #include "bb_smscconn_cb.h"
125 #include "msg.h"
126 #include "sms.h"
127 #include "dlr.h"
128 #include "urltrans.h"
129 #include "meta_data.h"
130 
131 #include "smsc_http_p.h"
132 
133 #define DEFAULT_CHARSET "UTF-8"
134 #define DEFAULT_UCS2_CHARSET "UTF-16BE"
135 
137 {
138  if (conndata == NULL)
139  return;
140  if (conndata->http_ref)
141  http_caller_destroy(conndata->http_ref);
142  octstr_destroy(conndata->allow_ip);
143  octstr_destroy(conndata->send_url);
144  octstr_destroy(conndata->dlr_url);
145  octstr_destroy(conndata->username);
146  octstr_destroy(conndata->password);
147  octstr_destroy(conndata->proxy);
148  octstr_destroy(conndata->system_id);
149  octstr_destroy(conndata->alt_charset);
150  counter_destroy(conndata->open_sends);
151  gwlist_destroy(conndata->msg_to_send, NULL);
152  if (conndata->max_pending_sends)
154 
155  gw_free(conndata);
156 }
157 
158 
159 /*
160  * Thread to listen to HTTP requests from SMSC entity
161  */
162 static void httpsmsc_receiver(void *arg)
163 {
164  SMSCConn *conn = arg;
165  ConnData *conndata = conn->data;
167  Octstr *ip, *url, *body;
168  List *headers, *cgivars;
169 
170  /* Make sure we log into our own log-file if defined */
171  log_thread_to(conn->log_idx);
172 
173  while (conndata->shutdown == 0) {
174  /* reset */
175  ip = url = body = NULL;
176  headers = cgivars = NULL;
177 
178  /* XXX if conn->is_stopped, do not receive new messages.. */
179 
180  client = http_accept_request(conndata->port, &ip, &url,
181  &headers, &body, &cgivars);
182  if (client == NULL)
183  break;
184 
185  if (cgivars != NULL) {
186  octstr_append_char(url, '?');
187  http_cgivar_dump_into(cgivars, url);
188  }
189 
190  debug("smsc.http", 0, "HTTP[%s]: Got request `%s'",
191  octstr_get_cstr(conn->id), octstr_get_cstr(url));
192 
193  if (connect_denied(conndata->allow_ip, ip)) {
194  info(0, "HTTP[%s]: Connection `%s' tried from denied "
195  "host %s, ignored", octstr_get_cstr(conn->id),
196  octstr_get_cstr(url), octstr_get_cstr(ip));
197  http_close_client(client);
198  } else
199  conndata->callbacks->receive_sms(conn, client, headers, body, cgivars);
200 
201  debug("smsc.http", 0, "HTTP[%s]: Destroying client information",
202  octstr_get_cstr(conn->id));
203  octstr_destroy(url);
204  octstr_destroy(ip);
205  octstr_destroy(body);
206  http_destroy_headers(headers);
207  http_destroy_cgiargs(cgivars);
208  }
209  debug("smsc.http", 0, "HTTP[%s]: httpsmsc_receiver dying",
210  octstr_get_cstr(conn->id));
211 
212  conndata->shutdown = 1;
213  http_close_port(conndata->port);
214 
215  /* unblock http_receive_result() if there are no open sends */
216  if (counter_value(conndata->open_sends) == 0)
218 
219  if (conndata->sender_thread != -1) {
220  gwthread_wakeup(conndata->sender_thread);
221  gwthread_join(conndata->sender_thread);
222  }
223  if (conndata->send_cb_thread != -1) {
224  gwthread_wakeup(conndata->send_cb_thread);
225  gwthread_join(conndata->send_cb_thread);
226  }
227 
228  mutex_lock(conn->flow_mutex);
229  conn->status = SMSCCONN_DEAD;
230  mutex_unlock(conn->flow_mutex);
231 
232  if (conndata->callbacks != NULL && conndata->callbacks->destroy != NULL)
233  conndata->callbacks->destroy(conn);
234  conn->data = NULL;
235  conndata_destroy(conndata);
237 }
238 
239 
240 /*
241  * Thread to send queued messages
242  */
243 static void httpsmsc_sender(void *arg)
244 {
245  SMSCConn *conn = arg;
246  ConnData *conndata = conn->data;
247  Msg *msg;
248  double delay = 0;
249 
250  /* Make sure we log into our own log-file if defined */
251  log_thread_to(conn->log_idx);
252 
253  if (conn->throughput) {
254  delay = 1.0 / conn->throughput;
255  }
256 
257  while (conndata->shutdown == 0) {
258  /* check if we can send ; otherwise block on semaphore */
259  if (conndata->max_pending_sends)
261 
262  if (conndata->shutdown) {
263  if (conndata->max_pending_sends)
264  semaphore_up(conndata->max_pending_sends);
265  break;
266  }
267 
268  msg = gwlist_consume(conndata->msg_to_send);
269  if (msg == NULL)
270  break;
271 
272  /* obey throughput speed limit, if any */
273  if (conn->throughput > 0) {
274  gwthread_sleep(delay);
275  }
276  counter_increase(conndata->open_sends);
277  if (conndata->callbacks->send_sms(conn, msg) == -1) {
278  counter_decrease(conndata->open_sends);
279  if (conndata->max_pending_sends)
280  semaphore_up(conndata->max_pending_sends);
281  }
282  }
283 
284  /* put outstanding sends back into global queue */
285  while((msg = gwlist_extract_first(conndata->msg_to_send)))
287 
288  /* if there no receiver shutdown */
289  if (conndata->port <= 0) {
290  /* unblock http_receive_result() if there are no open sends */
291  if (counter_value(conndata->open_sends) == 0)
293 
294  if (conndata->send_cb_thread != -1) {
295  gwthread_wakeup(conndata->send_cb_thread);
296  gwthread_join(conndata->send_cb_thread);
297  }
298  mutex_lock(conn->flow_mutex);
299  conn->status = SMSCCONN_DEAD;
300  mutex_unlock(conn->flow_mutex);
301 
302  if (conndata->callbacks != NULL && conndata->callbacks->destroy != NULL)
303  conndata->callbacks->destroy(conn);
304  conn->data = NULL;
305  conndata_destroy(conndata);
307  }
308 }
309 
310 /*
311  * Thread to handle finished sendings
312  */
313 static void httpsmsc_send_cb(void *arg)
314 {
315  SMSCConn *conn = arg;
316  ConnData *conndata = conn->data;
317  Msg *msg;
318  int status;
319  List *headers;
320  Octstr *final_url, *body;
321 
322  /* Make sure we log into our own log-file if defined */
323  log_thread_to(conn->log_idx);
324 
325  while(conndata->shutdown == 0 || counter_value(conndata->open_sends)) {
326 
327  msg = http_receive_result(conndata->http_ref, &status,
328  &final_url, &headers, &body);
329 
330  if (msg == NULL)
331  break; /* they told us to die, by unlocking */
332 
333  counter_decrease(conndata->open_sends);
334  if (conndata->max_pending_sends)
335  semaphore_up(conndata->max_pending_sends);
336 
337  /* Handle various states here. */
338 
339  /* request failed and we are not in shutdown mode */
340  if (status == -1 && conndata->shutdown == 0) {
341  error(0, "HTTP[%s]: Couldn't connect to SMS center."
342  "(retrying in %ld seconds) %ld.",
343  octstr_get_cstr(conn->id), conn->reconnect_delay, counter_value(conndata->open_sends));
344  mutex_lock(conn->flow_mutex);
346  mutex_unlock(conn->flow_mutex);
347  /* XXX how should we know whether it's temp. error ?? */
349  /*
350  * Just sleep reconnect delay and set conn to ACTIVE again;
351  * otherwise if no pending request are here, we leave conn in
352  * RECONNECTING state for ever and no routing (trials) take place.
353  */
354  if (counter_value(conndata->open_sends) == 0) {
356  /* and now enable routing again */
357  mutex_lock(conn->flow_mutex);
358  conn->status = SMSCCONN_ACTIVE;
359  time(&conn->connect_time);
360  mutex_unlock(conn->flow_mutex);
361  /* tell bearerbox core that we are connected again */
362  bb_smscconn_connected(conn);
363  }
364  continue;
365  }
366  /* request failed and we *are* in shutdown mode, drop the message */
367  else if (status == -1 && conndata->shutdown == 1) {
369  }
370  /* request succeeded */
371  else {
372  /* we received a response, so this link is considered online again */
373  if (conn->status != SMSCCONN_ACTIVE) {
374  mutex_lock(conn->flow_mutex);
375  conn->status = SMSCCONN_ACTIVE;
376  time(&conn->connect_time);
377  mutex_unlock(conn->flow_mutex);
378  /* tell bearerbox core that we are connected again */
379  bb_smscconn_connected(conn);
380  }
381  conndata->callbacks->parse_reply(conn, msg, status, headers, body);
382  }
383 
384  http_destroy_headers(headers);
385  octstr_destroy(final_url);
386  octstr_destroy(body);
387  }
388  debug("smsc.http", 0, "HTTP[%s]: httpsmsc_send_cb dying",
389  octstr_get_cstr(conn->id));
390  conndata->shutdown = 1;
391 
392  if (counter_value(conndata->open_sends)) {
393  warning(0, "HTTP[%s]: Shutdown while <%ld> requests are pending.",
394  octstr_get_cstr(conn->id), counter_value(conndata->open_sends));
395  }
396 }
397 
398 
399 /*-----------------------------------------------------------------
400  * functions to implement various smscconn operations
401  */
402 
403 static int httpsmsc_send(SMSCConn *conn, Msg *msg)
404 {
405  ConnData *conndata = conn->data;
406  Msg *sms;
407 
408 
409  /* don't crash if no send_sms handle defined */
410  if (!conndata || !conndata->callbacks->send_sms)
411  return -1;
412 
413  sms = msg_duplicate(msg);
414  /* convert character encoding if required */
415  if (conndata->alt_charset) {
416  /*
417  * Converted now to the target character set based on the
418  * one we got in the msg, which is either UTF-8 (our normal
419  * inter-box encoding), but may also be UCS-2, so beware.
420  * In addition, IF we convert to an "extra" encoding here
421  * we also revert the .coding vaue to DC_UNDEF, in order
422  * that all API specific code doesn't indicate an encoding
423  * which is no longer inside the payload here.
424  */
425  if (sms->sms.coding == DC_7BIT) {
426  if (charset_convert(sms->sms.msgdata, DEFAULT_CHARSET,
427  octstr_get_cstr(conndata->alt_charset)) == 0) {
428  sms->sms.coding = DC_UNDEF;
429  } else {
430  error(0, "Failed to convert msgdata from charset <%s> to <%s>, will send as is.",
432  }
433  }
434  else if (sms->sms.coding == DC_UCS2) {
435  if (charset_convert(sms->sms.msgdata, DEFAULT_UCS2_CHARSET,
436  octstr_get_cstr(conndata->alt_charset)) == 0) {
437  sms->sms.coding = DC_UNDEF;
438  } else {
439  error(0, "Failed to convert msgdata from charset <%s> to <%s>, will send as is.",
441  }
442  }
443  }
444 
445  gwlist_produce(conndata->msg_to_send, sms);
446 
447  return 0;
448 }
449 
450 
451 static long httpsmsc_queued(SMSCConn *conn)
452 {
453  ConnData *conndata = conn->data;
454 
455  conn->load = (conndata ? (conn->status != SMSCCONN_DEAD ?
456  gwlist_len(conndata->msg_to_send) : 0) : 0);
457 
458  return conn->load;
459 }
460 
461 
462 static int httpsmsc_shutdown(SMSCConn *conn, int finish_sending)
463 {
464  ConnData *conndata = conn->data;
465 
466  if (conndata == NULL)
467  return 0;
468 
469  debug("httpsmsc_shutdown", 0, "HTTP[%s]: Shutting down",
470  octstr_get_cstr(conn->id));
471 
472  mutex_lock(conn->flow_mutex);
474 
475  conndata->shutdown = 1;
476 
477  if (conndata->port > 0)
478  http_close_port(conndata->port);
480  if (conndata->receive_thread != -1)
481  gwthread_wakeup(conndata->receive_thread);
482  if (conndata->sender_thread != -1)
483  gwthread_wakeup(conndata->sender_thread);
484  mutex_unlock(conn->flow_mutex);
485 
486  return 0;
487 }
488 
489 
491 {
492  ConnData *conndata = NULL;
493  Octstr *type = NULL, *callbackname = NULL;
494  int ssl = 0; /* indicate if SSL-enabled server should be used */
495  long max_ps;
496 
497  if ((type = cfg_get(cfg, octstr_imm("system-type"))) == NULL) {
498  error(0, "HTTP[%s]: 'system-type' missing in smsc 'http' record.",
499  octstr_get_cstr(conn->id));
500  octstr_destroy(type);
501  return -1;
502  }
503 
504  conndata = gw_malloc(sizeof(ConnData));
505  /* reset conndata */
506  memset(conndata, 0, sizeof(ConnData));
507 
508  conn->data = conndata;
509  conndata->http_ref = NULL;
510  conndata->data = NULL;
511 
512  if (cfg_get_integer(&conndata->port, cfg, octstr_imm("port")) == -1) {
513  warning(0, "HTTP[%s]: 'port' not set in smsc 'http' group.",
514  octstr_get_cstr(conn->id));
515  conndata->port = -1;
516  }
517 
518  conndata->allow_ip = cfg_get(cfg, octstr_imm("connect-allow-ip"));
519  conndata->send_url = cfg_get(cfg, octstr_imm("send-url"));
520  conndata->username = cfg_get(cfg, octstr_imm("smsc-username"));
521  conndata->password = cfg_get(cfg, octstr_imm("smsc-password"));
522  conndata->system_id = cfg_get(cfg, octstr_imm("system-id"));
523  cfg_get_bool(&conndata->no_sender, cfg, octstr_imm("no-sender"));
524  cfg_get_bool(&conndata->no_coding, cfg, octstr_imm("no-coding"));
525  cfg_get_bool(&conndata->no_sep, cfg, octstr_imm("no-sep"));
526  conndata->proxy = cfg_get(cfg, octstr_imm("system-id"));
527  cfg_get_bool(&ssl, cfg, octstr_imm("use-ssl"));
528  conndata->dlr_url = cfg_get(cfg, octstr_imm("dlr-url"));
529  conndata->alt_charset = cfg_get(cfg, octstr_imm("alt-charset"));
530 
531  if (cfg_get_integer(&max_ps, cfg, octstr_imm("max-pending-submits")) == -1 || max_ps < 1)
532  max_ps = 10;
533 
534  conndata->max_pending_sends = semaphore_create(max_ps);
535 
536  if (conndata->port <= 0 && conndata->send_url == NULL) {
537  error(0, "Sender and receiver disabled. Dummy SMSC not allowed.");
538  goto error;
539  }
540  if (conndata->send_url == NULL)
541  panic(0, "HTTP[%s]: Sending not allowed. No 'send-url' specified.",
542  octstr_get_cstr(conn->id));
543 
544  /* callback struct is always in the format: smsc_http_XXX_callback where XXX is our type */
545  callbackname = octstr_format("smsc_http_%S_callback", type);
546  /* try to find the struct */
547  if (gw_dlopen_get_symbol(NULL, octstr_get_cstr(callbackname), (void**)&conndata->callbacks) == -1 || conndata->callbacks == NULL) {
548  error(0, "HTTP[%s]: system-type '%s' unknown smsc 'http' record.",
549  octstr_get_cstr(conn->id), octstr_get_cstr(type));
550  goto error;
551  }
552 
553  if (conndata->callbacks != NULL && conndata->callbacks->init != NULL && conndata->callbacks->init(conn, cfg)) {
554  error(0, "HTTP[%s]: submodule '%s' init failed.", octstr_get_cstr(conn->id), octstr_get_cstr(type));
555  goto error;
556  }
557 
558  conndata->open_sends = counter_create();
559  conndata->msg_to_send = gwlist_create();
560  gwlist_add_producer(conndata->msg_to_send);
561  conndata->http_ref = http_caller_create();
562 
563  conn->name = octstr_format("HTTP%s:%S:%d", (ssl?"S":""), type, conndata->port);
564 
565  if (conndata->send_url != NULL) {
566  conn->status = SMSCCONN_ACTIVE;
567  } else {
569  }
570 
571  conn->connect_time = time(NULL);
572 
573  conn->shutdown = httpsmsc_shutdown;
574  conn->queued = httpsmsc_queued;
575  conn->send_msg = httpsmsc_send;
576 
577  conndata->shutdown = 0;
578 
579  /* start receiver thread */
580  if (conndata->port > 0) {
581  if (http_open_port(conndata->port, ssl) == -1)
582  goto error;
583  if ((conndata->receive_thread = gwthread_create(httpsmsc_receiver, conn)) == -1)
584  goto error;
585  } else
586  conndata->receive_thread = -1;
587 
588  /* start sender threads */
589  if (conndata->send_url) {
590  if ((conndata->send_cb_thread =
591  gwthread_create(httpsmsc_send_cb, conn)) == -1)
592  goto error;
593  if ((conndata->sender_thread =
594  gwthread_create(httpsmsc_sender, conn)) == -1)
595  goto error;
596  }
597  else {
598  conndata->send_cb_thread = conndata->sender_thread = -1;
599  }
600 
601  info(0, "HTTP[%s]: Initiated and ready", octstr_get_cstr(conn->id));
602 
603  octstr_destroy(callbackname);
604  octstr_destroy(type);
605  return 0;
606 
607 error:
608  error(0, "HTTP[%s]: Failed to create HTTP SMSC connection",
609  octstr_get_cstr(conn->id));
610 
611  if (conndata->callbacks != NULL && conndata->callbacks->destroy != NULL)
612  conndata->callbacks->destroy(conn);
613  conn->data = NULL;
614  conndata_destroy(conndata);
616  conn->status = SMSCCONN_DEAD;
617  octstr_destroy(callbackname);
618  octstr_destroy(type);
619  return -1;
620 }
621 
Octstr * name
Definition: smscconn_p.h:173
void error(int err, const char *fmt,...)
Definition: log.c:648
void info(int err, const char *fmt,...)
Definition: log.c:672
Octstr * dlr_url
Definition: smsc_http_p.h:94
void * data
Definition: smsc_http_p.h:111
#define DEFAULT_CHARSET
Definition: smsc_http.c:133
Msg * msg_duplicate(Msg *msg)
Definition: msg.c:111
void bb_smscconn_connected(SMSCConn *conn)
Definition: bb_smscconn.c:192
static void httpsmsc_receiver(void *arg)
Definition: smsc_http.c:162
static void conndata_destroy(ConnData *conndata)
Definition: smsc_http.c:136
Octstr * alt_charset
Definition: smsc_http_p.h:104
long receive_thread
Definition: smsc_http_p.h:87
int gw_dlopen_get_symbol(const char *lib_path, const char *name, void **result)
Definition: gw-dlopen.c:70
int(* send_sms)(SMSCConn *conn, Msg *msg)
Definition: smsc_http_p.h:76
int ssl
void http_caller_signal_shutdown(HTTPCaller *caller)
Definition: http.c:913
void counter_destroy(Counter *counter)
Definition: counter.c:110
#define mutex_unlock(m)
Definition: thread.h:136
void http_close_client(HTTPClient *client)
Definition: http.c:2735
void bb_smscconn_killed(void)
Definition: bb_smscconn.c:199
int no_sep
Definition: smsc_http_p.h:102
void semaphore_destroy(Semaphore *semaphore)
Definition: gw-semaphore.c:104
void gwlist_produce(List *list, void *item)
Definition: list.c:411
Octstr * id
Definition: smscconn_p.h:174
void gwthread_join(long thread)
long gwlist_len(List *list)
Definition: list.c:166
void * data
Definition: smscconn_p.h:249
static void client(int port)
Definition: test_udp.c:77
HTTPCaller * http_ref
Definition: smsc_http_p.h:86
void octstr_append_char(Octstr *ostr, int ch)
Definition: octstr.c:1515
int log_idx
Definition: smscconn_p.h:197
int type
Definition: smsc_cimd2.c:215
Octstr * allow_ip
Definition: smsc_http_p.h:92
#define cfg_get(grp, varname)
Definition: cfg.h:86
void(* parse_reply)(SMSCConn *conn, Msg *msg, int status, List *headers, Octstr *body)
Definition: smsc_http_p.h:77
Octstr * proxy
Definition: smsc_http_p.h:103
Octstr * system_id
Definition: smsc_http_p.h:99
unsigned long counter_decrease(Counter *counter)
Definition: counter.c:155
static Cfg * cfg
Definition: opensmppbox.c:95
#define octstr_get_cstr(ostr)
Definition: octstr.h:233
int smsc_http_create(SMSCConn *conn, CfgGroup *cfg)
Definition: smsc_http.c:490
void(* destroy)(SMSCConn *conn)
Definition: smsc_http_p.h:75
unsigned long counter_increase(Counter *counter)
Definition: counter.c:123
int connect_denied(Octstr *allow_ip, Octstr *ip)
Definition: utils.c:833
long reconnect_delay
Definition: smscconn_p.h:199
void log_thread_to(int idx)
Definition: log.c:759
void semaphore_down(Semaphore *semaphore)
Definition: gw-semaphore.c:132
smscconn_killed_t why_killed
Definition: smscconn_p.h:153
void http_destroy_headers(List *headers)
Definition: http.c:2856
volatile int shutdown
Definition: smsc_http_p.h:90
void http_destroy_cgiargs(List *args)
Definition: http.c:2795
long port
Definition: smsc_http_p.h:91
Octstr * octstr_imm(const char *cstr)
Definition: octstr.c:281
Counter * open_sends
Definition: smsc_http_p.h:95
Definition: msg.h:79
int no_coding
Definition: smsc_http_p.h:101
List * msg_to_send
Definition: smsc_http_p.h:105
Counter * counter_create(void)
Definition: counter.c:94
void * gwlist_extract_first(List *list)
Definition: list.c:305
HTTPClient * http_accept_request(int port, Octstr **client_ip, Octstr **url, List **headers, Octstr **body, List **cgivars)
Definition: http.c:2575
void http_close_port(int port)
Definition: http.c:2505
void gwlist_remove_producer(List *list)
Definition: list.c:401
static void httpsmsc_send_cb(void *arg)
Definition: smsc_http.c:313
time_t connect_time
Definition: smscconn_p.h:155
double throughput
Definition: smscconn_p.h:203
Mutex * flow_mutex
Definition: smscconn_p.h:157
static double delay
Definition: mtbatch.c:99
long sender_thread
Definition: smsc_http_p.h:89
void warning(int err, const char *fmt,...)
Definition: log.c:660
void http_cgivar_dump_into(List *cgiargs, Octstr *os)
Definition: http.c:3436
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
unsigned long counter_value(Counter *counter)
Definition: counter.c:145
void gwthread_sleep(double seconds)
#define DEFAULT_UCS2_CHARSET
Definition: smsc_http.c:134
int no_sender
Definition: smsc_http_p.h:100
static int httpsmsc_shutdown(SMSCConn *conn, int finish_sending)
Definition: smsc_http.c:462
int http_open_port(int port, int ssl)
Definition: http.c:2499
Semaphore * max_pending_sends
Definition: smsc_http_p.h:96
#define http_receive_result(caller, status, final_url, headers, body)
Definition: http.h:383
void semaphore_up(Semaphore *semaphore)
Definition: gw-semaphore.c:118
int cfg_get_bool(int *n, CfgGroup *grp, Octstr *varname)
Definition: cfg.c:756
int(* init)(SMSCConn *conn, CfgGroup *cfg)
Definition: smsc_http_p.h:74
Definition: octstr.c:118
void * gwlist_consume(List *list)
Definition: list.c:427
static long httpsmsc_queued(SMSCConn *conn)
Definition: smsc_http.c:451
int(* shutdown)(SMSCConn *conn, int finish_sending)
Definition: smscconn_p.h:229
Octstr * password
Definition: smsc_http_p.h:98
void debug(const char *place, int err, const char *fmt,...)
Definition: log.c:726
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
smscconn_status_t status
Definition: smscconn_p.h:151
HTTPCaller * http_caller_create(void)
Definition: http.c:897
#define gwlist_create()
Definition: list.h:136
long(* queued)(SMSCConn *conn)
Definition: smscconn_p.h:240
int(* send_msg)(SMSCConn *conn, Msg *msg)
Definition: smscconn_p.h:235
Octstr * username
Definition: smsc_http_p.h:97
static int httpsmsc_send(SMSCConn *conn, Msg *msg)
Definition: smsc_http.c:403
void bb_smscconn_send_failed(SMSCConn *conn, Msg *sms, int reason, Octstr *reply)
Definition: bb_smscconn.c:328
void http_caller_destroy(HTTPCaller *caller)
Definition: http.c:907
#define DC_UNDEF
Definition: sms.h:109
Octstr * send_url
Definition: smsc_http_p.h:93
void gwlist_add_producer(List *list)
Definition: list.c:383
void(* receive_sms)(SMSCConn *conn, HTTPClient *client, List *headers, Octstr *body, List *cgivars)
Definition: smsc_http_p.h:78
static void httpsmsc_sender(void *arg)
Definition: smsc_http.c:243
static Octstr * url
Definition: test_xmlrpc.c:84
#define mutex_lock(m)
Definition: thread.h:130
struct smsc_http_fn_callbacks * callbacks
Definition: smsc_http_p.h:108
Semaphore * semaphore_create(long n)
Definition: gw-semaphore.c:81
Definition: list.c:102
static XMLRPCDocument * msg
Definition: test_xmlrpc.c:86
long send_cb_thread
Definition: smsc_http_p.h:88
#define DC_UCS2
Definition: sms.h:112
int charset_convert(Octstr *string, char *charset_from, char *charset_to)
Definition: charset.c:589
#define DC_7BIT
Definition: sms.h:110
int load
Definition: smscconn_p.h:152
void gwlist_destroy(List *list, gwlist_item_destructor_t *destructor)
Definition: list.c:145
See file LICENSE for details about the license agreement for using, modifying, copying or deriving work from this software.