Kannel: Open Source WAP and SMS gateway  svn-r5335
smscconn_p.h File Reference
#include <signal.h>
#include "gwlib/gwlib.h"
#include "gwlib/gw-regex.h"
#include "smscconn.h"
#include "load.h"

Go to the source code of this file.

Data Structures

struct  smscconn
 
struct  pattern_route
 

Typedefs

typedef struct pattern_route pattern_route
 

Functions

int smsc_wrapper_create (SMSCConn *conn, CfgGroup *cfg)
 
int smsc_fake_create (SMSCConn *conn, CfgGroup *cfg)
 
int smsc_cimd2_create (SMSCConn *conn, CfgGroup *cfg)
 
int smsc_emi2_create (SMSCConn *conn, CfgGroup *cfg)
 
int smsc_http_create (SMSCConn *conn, CfgGroup *cfg)
 
int smsc_smpp_create (SMSCConn *conn, CfgGroup *cfg)
 
int smsc_cgw_create (SMSCConn *conn, CfgGroup *cfg)
 
int smsc_at2_create (SMSCConn *conn, CfgGroup *cfg)
 
int smsc_smasi_create (SMSCConn *conn, CfgGroup *cfg)
 
int smsc_oisd_create (SMSCConn *conn, CfgGroup *cfg)
 
int smsc_loopback_create (SMSCConn *conn, CfgGroup *cfg)
 

Typedef Documentation

◆ pattern_route

typedef struct pattern_route pattern_route

Function Documentation

◆ smsc_at2_create()

int smsc_at2_create ( SMSCConn conn,
CfgGroup cfg 
)

Definition at line 1519 of file smsc_at.c.

References at2_add_msg_cb(), AT2_DEFAULT_SMS_POLL_INTERVAL, at2_device_thread(), at2_queued_cb(), at2_read_modems(), at2_shutdown_cb(), at2_start_cb(), cfg, cfg_get, cfg_get_bool(), cfg_get_configfile(), cfg_get_integer(), privdata::conn, smscconn::connect_time, smscconn::data, error(), gw_prioqueue_create(), gw_prioqueue_destroy(), gwlist_create, gwthread_create, info(), privdata::keepalive, load_add_interval(), load_create_real(), privdata::my_number, privdata::name, smscconn::name, O_DESTROY, octstr_compare(), octstr_create, octstr_duplicate, octstr_format(), octstr_get_cstr, octstr_imm(), octstr_len(), octstr_str_compare(), privdata::outgoing_queue, privdata::password, smscconn::queued, smscconn::send_msg, privdata::shutdown, smscconn::shutdown, sms_priority_compare(), SMSCCONN_CONNECTING, SMSCCONN_DEAD, SMSCCONN_KILLED_CANNOT_CONNECT, smscconn::start_conn, smscconn::status, privdata::username, privdata::validityperiod, and smscconn::why_killed.

Referenced by smscconn_create().

1520 {
1522  Octstr *modem_type_string;
1523  long portno; /* has to be long because of cfg_get_integer */
1524 
1525  privdata = gw_malloc(sizeof(PrivAT2data));
1526  memset(privdata, 0, sizeof(PrivAT2data));
1528  privdata->pending_incoming_messages = gwlist_create();
1529 
1530  privdata->configfile = cfg_get_configfile(cfg);
1531 
1532  privdata->device = cfg_get(cfg, octstr_imm("device"));
1533  if (privdata->device == NULL) {
1534  error(0, "AT2[-]: 'device' missing in at2 configuration.");
1535  goto error;
1536  }
1537 
1538  if (octstr_str_compare(privdata->device, "rawtcp") == 0) {
1539  privdata->rawtcp_host = cfg_get(cfg, octstr_imm("host"));
1540  if (privdata->rawtcp_host == NULL) {
1541  error(0, "AT2[-]: 'host' missing in at2 rawtcp configuration.");
1542  goto error;
1543  }
1544  if (cfg_get_integer(&portno, cfg, octstr_imm("port")) == -1) {
1545  error(0, "AT2[-]: 'port' missing in at2 rawtcp configuration.");
1546  goto error;
1547  }
1548  privdata->rawtcp_port = portno;
1549  privdata->is_serial = 0;
1550  privdata->use_telnet = 0;
1551  } else if (octstr_str_compare(privdata->device, "telnet") == 0) {
1552  privdata->rawtcp_host = cfg_get(cfg, octstr_imm("host"));
1553  if (privdata->rawtcp_host == NULL) {
1554  error(0, "AT2[-]: 'host' missing in at2 telnet configuration.");
1555  goto error;
1556  }
1557  if (cfg_get_integer(&portno, cfg, octstr_imm("port")) == -1) {
1558  error(0, "AT2[-]: 'port' missing in at2 telnet configuration.");
1559  goto error;
1560  }
1561  privdata->rawtcp_port = portno;
1562  privdata->is_serial = 0;
1563  privdata->use_telnet = 1;
1564  } else {
1565  privdata->is_serial = 1;
1566  privdata->use_telnet = 0;
1567  }
1568 
1569  privdata->name = cfg_get(cfg, octstr_imm("smsc-id"));
1570  if (privdata->name == NULL) {
1571  privdata->name = octstr_duplicate(privdata->device);
1572  }
1573 
1574  privdata->speed = 0;
1575  cfg_get_integer(&privdata->speed, cfg, octstr_imm("speed"));
1576 
1577  privdata->keepalive = 0;
1578  cfg_get_integer(&privdata->keepalive, cfg, octstr_imm("keepalive"));
1579 
1580  cfg_get_bool(&privdata->sms_memory_poll_interval, cfg, octstr_imm("sim-buffering"));
1581  if (privdata->sms_memory_poll_interval) {
1582  if (privdata->keepalive)
1583  privdata->sms_memory_poll_interval = privdata->keepalive;
1584  else
1585  privdata->sms_memory_poll_interval = AT2_DEFAULT_SMS_POLL_INTERVAL;
1586  }
1587 
1588  privdata->my_number = cfg_get(cfg, octstr_imm("my-number"));
1589  privdata->sms_center = cfg_get(cfg, octstr_imm("sms-center"));
1590  privdata->username = cfg_get(cfg, octstr_imm("smsc-username"));
1591  privdata->password = cfg_get(cfg, octstr_imm("smsc-password"));
1592  privdata->login_prompt = cfg_get(cfg, octstr_imm("login-prompt"));
1593  privdata->password_prompt = cfg_get(cfg, octstr_imm("password-prompt"));
1594  modem_type_string = cfg_get(cfg, octstr_imm("modemtype"));
1595 
1596  privdata->modem = NULL;
1597 
1598  if (modem_type_string != NULL) {
1599  if (octstr_compare(modem_type_string, octstr_imm("auto")) == 0 ||
1600  octstr_compare(modem_type_string, octstr_imm("autodetect")) == 0)
1601  O_DESTROY(modem_type_string);
1602  }
1603 
1604  if (octstr_len(modem_type_string) == 0) {
1605  info(0, "AT2[%s]: configuration doesn't show modemtype. will autodetect",
1607  } else {
1608  info(0, "AT2[%s]: configuration shows modemtype <%s>",
1610  octstr_get_cstr(modem_type_string));
1611  privdata->modem = at2_read_modems(privdata, privdata->configfile,
1612  modem_type_string, 0);
1613  if (privdata->modem == NULL) {
1614  info(0, "AT2[%s]: modemtype not found, revert to autodetect",
1616  } else {
1617  info(0, "AT2[%s]: read modem definition for <%s>",
1619  octstr_get_cstr(privdata->modem->name));
1620  }
1621  O_DESTROY(modem_type_string);
1622  }
1623 
1624  privdata->ilb = octstr_create("");
1625  privdata->fd = -1;
1626  privdata->lines = NULL;
1627  privdata->pin = cfg_get(cfg, octstr_imm("pin"));
1628  privdata->pin_ready = 0;
1629  privdata->conn = conn;
1630  privdata->phase2plus = 0;
1631  privdata->validityperiod = cfg_get(cfg, octstr_imm("validityperiod"));
1632  if (cfg_get_integer((long *) &privdata->max_error_count, cfg, octstr_imm("max-error-count")) == -1)
1633  privdata->max_error_count = -1;
1634 
1635  privdata->load = load_create_real(0);
1636  load_add_interval(privdata->load, 1);
1637 
1638  conn->data = privdata;
1639  conn->name = octstr_format("AT2[%s]", octstr_get_cstr(privdata->name));
1640  conn->status = SMSCCONN_CONNECTING;
1641  conn->connect_time = time(NULL);
1642 
1643  privdata->shutdown = 0;
1644 
1645  if ((privdata->device_thread = gwthread_create(at2_device_thread, conn)) == -1) {
1646  privdata->shutdown = 1;
1647  goto error;
1648  }
1649 
1650  conn->shutdown = at2_shutdown_cb;
1651  conn->queued = at2_queued_cb;
1652  conn->start_conn = at2_start_cb;
1653  conn->send_msg = at2_add_msg_cb;
1654  return 0;
1655 
1656 error:
1657  error(0, "AT2[%s]: Failed to create at2 smsc connection",
1659  if (privdata != NULL) {
1661  }
1662  gw_free(privdata);
1664  conn->status = SMSCCONN_DEAD;
1665  info(0, "AT2[%s]: exiting", octstr_get_cstr(privdata->name));
1666  return -1;
1667 }
Octstr * name
Definition: smscconn_p.h:173
void error(int err, const char *fmt,...)
Definition: log.c:648
static void at2_device_thread(void *arg)
Definition: smsc_at.c:1282
void info(int err, const char *fmt,...)
Definition: log.c:672
static long at2_queued_cb(SMSCConn *conn)
Definition: smsc_at.c:1484
#define AT2_DEFAULT_SMS_POLL_INTERVAL
Definition: smsc_at.h:94
long validityperiod
Definition: smsc_oisd.c:94
void * data
Definition: smscconn_p.h:250
Octstr * cfg_get_configfile(CfgGroup *grp)
Definition: cfg.c:716
List * outgoing_queue
Definition: smsc_cgw.c:153
int load_add_interval(Load *load, int interval)
Definition: load.c:111
Octstr * password
Definition: smsc_cimd2.c:100
#define cfg_get(grp, varname)
Definition: cfg.h:86
Load * load_create_real(int heuristic)
Definition: load.c:97
static Cfg * cfg
Definition: opensmppbox.c:95
#define octstr_get_cstr(ostr)
Definition: octstr.h:233
void(* start_conn)(SMSCConn *conn)
Definition: smscconn_p.h:246
smscconn_killed_t why_killed
Definition: smscconn_p.h:153
Octstr * octstr_imm(const char *cstr)
Definition: octstr.c:283
int sms_priority_compare(const void *a, const void *b)
Definition: sms.c:395
Octstr * my_number
Definition: smsc_cimd2.c:105
static int at2_shutdown_cb(SMSCConn *conn, int finish_sending)
Definition: smsc_at.c:1454
static ModemDef * at2_read_modems(PrivAT2data *privdata, Octstr *file, Octstr *id, int idnumber)
Definition: smsc_at.c:2758
time_t connect_time
Definition: smscconn_p.h:155
static int at2_add_msg_cb(SMSCConn *conn, Msg *sms)
Definition: smsc_at.c:1508
#define octstr_duplicate(ostr)
Definition: octstr.h:187
Octstr * username
Definition: smsc_cimd2.c:99
Octstr * octstr_format(const char *fmt,...)
Definition: octstr.c:2464
#define gwthread_create(func, arg)
Definition: gwthread.h:90
#define octstr_create(cstr)
Definition: octstr.h:125
#define O_DESTROY(a)
Definition: smsbox.c:97
Octstr * name
Definition: smsc_emi.c:96
gw_prioqueue_t * gw_prioqueue_create(int(*cmp)(const void *, const void *))
Definition: gw-prioqueue.c:174
int shutdown
Definition: smsc_cgw.c:156
long octstr_len(const Octstr *ostr)
Definition: octstr.c:342
int cfg_get_bool(int *n, CfgGroup *grp, Octstr *varname)
Definition: cfg.c:759
void gw_prioqueue_destroy(gw_prioqueue_t *queue, void(*item_destroy)(void *))
Definition: gw-prioqueue.c:201
Definition: octstr.c:118
int(* shutdown)(SMSCConn *conn, int finish_sending)
Definition: smscconn_p.h:230
int cfg_get_integer(long *n, CfgGroup *grp, Octstr *varname)
Definition: cfg.c:742
int octstr_str_compare(const Octstr *ostr, const char *str)
Definition: octstr.c:973
smscconn_status_t status
Definition: smscconn_p.h:151
#define gwlist_create()
Definition: list.h:136
long(* queued)(SMSCConn *conn)
Definition: smscconn_p.h:241
int(* send_msg)(SMSCConn *conn, Msg *msg)
Definition: smscconn_p.h:236
static void at2_start_cb(SMSCConn *conn)
Definition: smsc_at.c:1495
long keepalive
Definition: smsc_cimd2.c:104
SMSCConn * conn
Definition: smsc_cimd2.c:118
int octstr_compare(const Octstr *ostr1, const Octstr *ostr2)
Definition: octstr.c:871

◆ smsc_cgw_create()

int smsc_cgw_create ( SMSCConn conn,
CfgGroup cfg 
)

Definition at line 431 of file smsc_cgw.c.

References allow_ip, privdata::allow_ip, privdata::appname, cfg, cfg_get, cfg_get_integer(), cgw_add_msg_cb(), CGW_DEFPORT, cgw_listener(), cgw_open_listening_socket(), cgw_queued_cb(), cgw_sender(), cgw_shutdown_cb(), cgw_start_cb(), CGW_TRN_MAX, privdata::check_time, smscconn::connect_time, smscconn::data, deny_ip, privdata::deny_ip, privdata::dlr, error(), gwlist_create, gwlist_destroy(), gwthread_create, host, privdata::host, info(), privdata::listening_socket, smscconn::name, privdata::nexttrn, octstr_create, octstr_destroy(), octstr_format(), octstr_imm(), our_port, privdata::our_port, privdata::outgoing_queue, privdata::port, smscconn::queued, privdata::receiver_thread, privdata::rport, smscconn::send_msg, privdata::sender_thread, privdata::sendtime, privdata::shutdown, smscconn::shutdown, SMSCCONN_CONNECTING, SMSCCONN_DEAD, SMSCCONN_KILLED_CANNOT_CONNECT, smscconn::start_conn, smscconn::status, privdata::waitack, and smscconn::why_killed.

Referenced by smscconn_create().

432 {
434  Octstr *allow_ip, *deny_ip, *host, *appname;
435  long portno, our_port, waitack;
436  int i;
437 
438  privdata = gw_malloc(sizeof(PrivData));
441 
442  if (cfg_get_integer(&portno, cfg, octstr_imm("port")) == -1)
443  portno = 0;
444  privdata->port = portno;
445 
446  if (cfg_get_integer(&portno, cfg, octstr_imm("receive-port")) < 0)
447  portno = 0;
448  privdata->rport = portno;
449 
450  host = cfg_get(cfg, octstr_imm("host"));
451  appname = cfg_get(cfg, octstr_imm("appname"));
452 
453  if (cfg_get_integer(&our_port, cfg, octstr_imm("our-port")) == -1)
454  privdata->our_port = 0; /* 0 means use any port */
455  else
457 
458  allow_ip = cfg_get(cfg, octstr_imm("connect-allow-ip"));
459  if (allow_ip)
460  deny_ip = octstr_create("*.*.*.*");
461  else
462  deny_ip = NULL;
463 
464  if (cfg_get_integer(&waitack, cfg, octstr_imm("wait-ack")) < 0)
465  privdata->waitack = 60;
466  else
467  privdata->waitack = waitack;
468 
469  if (privdata->port <= 0 || privdata->port > 65535) {
470  info(1, "No port defined for cgw -> using default (%d)", CGW_DEFPORT);
472  }
473 
474 
475  if (host == NULL) {
476  error(0, "'host' missing in cgw configuration.");
477  goto error;
478  }
479 
480  if (appname == NULL)
481  appname = octstr_create("send");
482 
485  privdata->host = host;
486  privdata->appname = appname;
487  privdata->nexttrn = 0;
488  privdata->check_time = 0;
489 
490  for (i = 0; i < CGW_TRN_MAX; i++) {
491  privdata->sendtime[i] = 0;
492  privdata->dlr[i] = 0;
493  }
494 
495  if (privdata->rport > 0 && cgw_open_listening_socket(conn,privdata) < 0) {
496  gw_free(privdata);
497  privdata = NULL;
498  goto error;
499  }
500 
501 
502  conn->data = privdata;
503 
504  conn->name = octstr_format("CGW:%d", privdata->port);
505 
506  privdata->shutdown = 0;
507 
508  conn->status = SMSCCONN_CONNECTING;
509  conn->connect_time = time(NULL);
510 
511  if (privdata->rport > 0 && (privdata->receiver_thread = gwthread_create(cgw_listener, conn)) == -1)
512  goto error;
513 
514  if ((privdata->sender_thread = gwthread_create(cgw_sender, conn)) == -1) {
515  privdata->shutdown = 1;
516  goto error;
517  }
518 
519  conn->shutdown = cgw_shutdown_cb;
520  conn->queued = cgw_queued_cb;
521  conn->start_conn = cgw_start_cb;
522  conn->send_msg = cgw_add_msg_cb;
523 
524  return 0;
525 
526 error:
527  error(0, "Failed to create CGW smsc connection");
528  if (privdata != NULL)
530 
531  gw_free(privdata);
535  octstr_destroy(appname);
536 
538  conn->status = SMSCCONN_DEAD;
539  info(0, "exiting");
540  return -1;
541 }
#define CGW_DEFPORT
Definition: smsc_cgw.c:123
int port
Definition: smsc_cgw.c:159
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
static long our_port
Definition: radius_acct.c:87
static void cgw_start_cb(SMSCConn *conn)
Definition: smsc_cgw.c:588
void * data
Definition: smscconn_p.h:250
int waitack
Definition: smsc_cgw.c:171
List * outgoing_queue
Definition: smsc_cgw.c:153
static Octstr * host
Definition: fakesmsc.c:122
#define cfg_get(grp, varname)
Definition: cfg.h:86
static int cgw_add_msg_cb(SMSCConn *conn, Msg *sms)
Definition: smsc_cgw.c:549
static Cfg * cfg
Definition: opensmppbox.c:95
void(* start_conn)(SMSCConn *conn)
Definition: smscconn_p.h:246
smscconn_killed_t why_killed
Definition: smscconn_p.h:153
Octstr * octstr_imm(const char *cstr)
Definition: octstr.c:283
static int cgw_shutdown_cb(SMSCConn *conn, int finish_sending)
Definition: smsc_cgw.c:562
time_t connect_time
Definition: smscconn_p.h:155
static Octstr * deny_ip
Definition: bb_udp.c:112
Octstr * allow_ip
Definition: smsc_cgw.c:164
Octstr * host
Definition: smsc_cgw.c:163
Octstr * octstr_format(const char *fmt,...)
Definition: octstr.c:2464
void octstr_destroy(Octstr *ostr)
Definition: octstr.c:324
int rport
Definition: smsc_cgw.c:160
#define gwthread_create(func, arg)
Definition: gwthread.h:90
#define octstr_create(cstr)
Definition: octstr.h:125
long check_time
Definition: smsc_cgw.c:173
#define CGW_TRN_MAX
Definition: smsc_cgw.c:125
static void cgw_sender(void *arg)
Definition: smsc_cgw.c:616
static Octstr * allow_ip
Definition: bb_udp.c:111
int shutdown
Definition: smsc_cgw.c:156
long sender_thread
Definition: smsc_cgw.c:155
static long cgw_queued_cb(SMSCConn *conn)
Definition: smsc_cgw.c:599
Definition: octstr.c:118
int(* shutdown)(SMSCConn *conn, int finish_sending)
Definition: smscconn_p.h:230
int cfg_get_integer(long *n, CfgGroup *grp, Octstr *varname)
Definition: cfg.c:742
smscconn_status_t status
Definition: smscconn_p.h:151
#define gwlist_create()
Definition: list.h:136
long(* queued)(SMSCConn *conn)
Definition: smscconn_p.h:241
int(* send_msg)(SMSCConn *conn, Msg *msg)
Definition: smscconn_p.h:236
long receiver_thread
Definition: smsc_cgw.c:154
int listening_socket
Definition: smsc_cgw.c:157
Octstr * appname
Definition: smsc_cgw.c:165
time_t sendtime[CGW_TRN_MAX]
Definition: smsc_cgw.c:168
int our_port
Definition: smsc_cgw.c:161
static void cgw_listener(void *arg)
Definition: smsc_cgw.c:967
Octstr * deny_ip
Definition: smsc_cgw.c:164
static int cgw_open_listening_socket(SMSCConn *conn, PrivData *privdata)
Definition: smsc_cgw.c:945
int dlr[CGW_TRN_MAX]
Definition: smsc_cgw.c:169
int nexttrn
Definition: smsc_cgw.c:172
void gwlist_destroy(List *list, gwlist_item_destructor_t *destructor)
Definition: list.c:145

◆ smsc_cimd2_create()

int smsc_cimd2_create ( SMSCConn conn,
CfgGroup cfg 
)

Definition at line 2321 of file smsc_cimd2.c.

References cfg_get, cfg_get_bool(), cfg_get_integer(), cimd2_add_msg_cb(), cimd2_destroy(), cimd2_queued_cb(), cimd2_shutdown_cb(), cimd2_start_cb(), cimd2_stop_cb(), privdata::conn, smscconn::data, debug(), error(), gwlist_add_producer(), gwlist_create, gwthread_create, gwthread_join(), gwthread_wakeup(), privdata::host, smscconn::id, privdata::inbuffer, privdata::io_thread, io_thread(), smscconn::is_stopped, privdata::keepalive, maxlen, privdata::my_number, smscconn::name, privdata::next_ping, privdata::no_dlr, octstr_create, octstr_format(), octstr_get_cstr, octstr_imm(), octstr_len(), octstr_truncate(), ok, privdata::our_port, privdata::outgoing_queue, P_PASSWORD, P_USER_IDENTITY, parm_maxlen(), privdata::password, privdata::port, smscconn::queued, privdata::quitting, privdata::receive_seq, privdata::received, smscconn::send_msg, privdata::send_seq, smscconn::shutdown, privdata::socket, smscconn::start_conn, smscconn::stop_conn, privdata::stopped, privdata::username, and warning().

Referenced by smscconn_create().

2322 {
2323  PrivData *pdata;
2324  int ok;
2325  int maxlen;
2326 
2327  pdata = gw_malloc(sizeof(PrivData));
2328  conn->data = pdata;
2329  pdata->conn = conn;
2330 
2331  pdata->no_dlr = 0;
2332  pdata->quitting = 0;
2333  pdata->socket = -1;
2334  pdata->received = gwlist_create();
2335  pdata->inbuffer = octstr_create("");
2336  pdata->send_seq = 1;
2337  pdata->receive_seq = 0;
2338  pdata->outgoing_queue = gwlist_create();
2339  pdata->stopped = gwlist_create();
2341 
2342  if (conn->is_stopped)
2343  gwlist_add_producer(pdata->stopped);
2344 
2345  pdata->host = cfg_get(grp, octstr_imm("host"));
2346  if (cfg_get_integer(&(pdata->port), grp, octstr_imm("port")) == -1)
2347  pdata->port = 0;
2348  if (cfg_get_integer(&(pdata->our_port), grp, octstr_imm("our-port")) == -1)
2349  pdata->our_port = 0;
2350  pdata->username = cfg_get(grp, octstr_imm("smsc-username"));
2351  pdata->password = cfg_get(grp, octstr_imm("smsc-password"));
2352  pdata->my_number = cfg_get(grp, octstr_imm("my-number"));
2353  if (cfg_get_integer(&(pdata->keepalive), grp,octstr_imm("keepalive")) == -1)
2354  pdata->keepalive = 0;
2355 
2356  cfg_get_bool(&pdata->no_dlr, grp, octstr_imm("no-dlr"));
2357 
2358  /* Check that config is OK */
2359  ok = 1;
2360  if (pdata->host == NULL) {
2361  error(0,"CIMD2[%s]: Configuration file doesn't specify host",
2362  octstr_get_cstr(conn->id));
2363  ok = 0;
2364  }
2365  if (pdata->port == 0) {
2366  error(0,"CIMD2[%s]: Configuration file doesn't specify port",
2367  octstr_get_cstr(conn->id));
2368  ok = 0;
2369  }
2370  if (pdata->username == NULL) {
2371  error(0, "CIMD2[%s]: Configuration file doesn't specify username.",
2372  octstr_get_cstr(conn->id));
2373  ok = 0;
2374  }
2375  if (pdata->password == NULL) {
2376  error(0, "CIMD2[%s]: Configuration file doesn't specify password.",
2377  octstr_get_cstr(conn->id));
2378  ok = 0;
2379  }
2380 
2381  if (!ok) {
2382  cimd2_destroy(pdata);
2383  return -1;
2384  }
2385 
2386  conn->name = octstr_format("CIMD2:%s:%d:%s",
2387  octstr_get_cstr(pdata->host),
2388  pdata->port,
2389  octstr_get_cstr(pdata->username));
2390 
2391 
2392  if (pdata->keepalive > 0) {
2393  debug("bb.sms.cimd2", 0, "CIMD2[%s]: Keepalive set to %ld seconds",
2394  octstr_get_cstr(conn->id),
2395  pdata->keepalive);
2396  pdata->next_ping = time(NULL) + pdata->keepalive;
2397  }
2398 
2400  if (octstr_len(pdata->username) > maxlen) {
2401  octstr_truncate(pdata->username, maxlen);
2402  warning(0, "CIMD2[%s]: Truncating username to %d chars",
2403  octstr_get_cstr(conn->id),
2404  maxlen);
2405  }
2406 
2408  if (octstr_len(pdata->password) > maxlen) {
2409  octstr_truncate(pdata->password, maxlen);
2410  warning(0, "CIMD2[%s]: Truncating password to %d chars",
2411  octstr_get_cstr(conn->id),
2412  maxlen);
2413  }
2414 
2415  pdata->io_thread = gwthread_create(io_thread, conn);
2416 
2417  if (pdata->io_thread == -1) {
2418 
2419  error(0,"CIMD2[%s]: Couldn't start I/O thread.",
2420  octstr_get_cstr(conn->id));
2421  pdata->quitting = 1;
2422  gwthread_wakeup(pdata->io_thread);
2423  gwthread_join(pdata->io_thread);
2424  cimd2_destroy(pdata);
2425  return -1;
2426  }
2427 
2428  conn->send_msg = cimd2_add_msg_cb;
2429  conn->shutdown = cimd2_shutdown_cb;
2430  conn->queued = cimd2_queued_cb;
2431  conn->start_conn = cimd2_start_cb;
2432  conn->stop_conn = cimd2_stop_cb;
2433 
2434  return 0;
2435 }
int port
Definition: smsc_cgw.c:159
Octstr * name
Definition: smscconn_p.h:173
void error(int err, const char *fmt,...)
Definition: log.c:648
Octstr * inbuffer
Definition: smsc_cimd2.c:112
Octstr * id
Definition: smscconn_p.h:174
void gwthread_join(long thread)
void * data
Definition: smscconn_p.h:250
List * outgoing_queue
Definition: smsc_cgw.c:153
void(* stop_conn)(SMSCConn *conn)
Definition: smscconn_p.h:247
static int parm_maxlen(int parmno)
Definition: smsc_cimd2.c:287
int socket
Definition: smsc_cimd2.c:108
Octstr * password
Definition: smsc_cimd2.c:100
#define cfg_get(grp, varname)
Definition: cfg.h:86
int io_thread
Definition: smsc_cimd2.c:119
static int cimd2_shutdown_cb(SMSCConn *conn, int finish_sending)
Definition: smsc_cimd2.c:2252
#define octstr_get_cstr(ostr)
Definition: octstr.h:233
void(* start_conn)(SMSCConn *conn)
Definition: smscconn_p.h:246
List * stopped
Definition: smsc_cimd2.c:121
int receive_seq
Definition: smsc_cimd2.c:110
time_t next_ping
Definition: smsc_cimd2.c:115
static void io_thread(void *arg)
Definition: smsc_cimd2.c:2164
Octstr * octstr_imm(const char *cstr)
Definition: octstr.c:283
Octstr * my_number
Definition: smsc_cimd2.c:105
static void cimd2_start_cb(SMSCConn *conn)
Definition: smsc_cimd2.c:2294
Octstr * username
Definition: smsc_cimd2.c:99
void warning(int err, const char *fmt,...)
Definition: log.c:660
Octstr * host
Definition: smsc_cgw.c:163
int quitting
Definition: smsc_cimd2.c:120
Octstr * octstr_format(const char *fmt,...)
Definition: octstr.c:2464
#define gwthread_create(func, arg)
Definition: gwthread.h:90
#define octstr_create(cstr)
Definition: octstr.h:125
volatile sig_atomic_t is_stopped
Definition: smscconn_p.h:169
int send_seq
Definition: smsc_cimd2.c:109
int no_dlr
Definition: smsc_cimd2.c:106
int maxlen
Definition: smsc_cimd2.c:214
long octstr_len(const Octstr *ostr)
Definition: octstr.c:342
int cfg_get_bool(int *n, CfgGroup *grp, Octstr *varname)
Definition: cfg.c:759
static int cimd2_add_msg_cb(SMSCConn *conn, Msg *sms)
Definition: smsc_cimd2.c:2239
int(* shutdown)(SMSCConn *conn, int finish_sending)
Definition: smscconn_p.h:230
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:742
Definition: wtp_tid.h:82
void gwthread_wakeup(long thread)
static long cimd2_queued_cb(SMSCConn *conn)
Definition: smsc_cimd2.c:2313
List * received
Definition: smsc_cimd2.c:113
#define gwlist_create()
Definition: list.h:136
long(* queued)(SMSCConn *conn)
Definition: smscconn_p.h:241
void octstr_truncate(Octstr *ostr, int new_len)
Definition: octstr.c:1327
int(* send_msg)(SMSCConn *conn, Msg *msg)
Definition: smscconn_p.h:236
void gwlist_add_producer(List *list)
Definition: list.c:383
int our_port
Definition: smsc_cgw.c:161
long keepalive
Definition: smsc_cimd2.c:104
static void cimd2_destroy(PrivData *pdata)
Definition: smsc_cimd2.c:1929
static void cimd2_stop_cb(SMSCConn *conn)
Definition: smsc_cimd2.c:2305
SMSCConn * conn
Definition: smsc_cimd2.c:118

◆ smsc_emi2_create()

int smsc_emi2_create ( SMSCConn conn,
CfgGroup cfg 
)

Definition at line 1629 of file smsc_emi.c.

References add_msg_cb(), allow_ip, privdata::allow_ip, alt_charset, privdata::alt_charset, privdata::alt_host, privdata::alt_port, privdata::can_write, cfg, cfg_get, cfg_get_integer(), privdata::check_time, smscconn::connect_time, smscconn::data, deny_ip, privdata::deny_ip, emi2_listener(), EMI2_MAX_TRN, emi2_open_listening_socket(), emi2_sender(), error(), privdata::flowcontrol, gw_prioqueue_create(), gw_prioqueue_destroy(), gwthread_create, gwthread_join(), gwthread_wakeup(), host, privdata::host, privdata::idle_timeout, info(), privdata::keepalive, privdata::last_activity_time, privdata::listening_socket, privdata::my_number, privdata::nadc, privdata::name, smscconn::name, privdata::npid, octstr_append(), octstr_append_char(), octstr_append_decimal(), octstr_create, octstr_destroy(), octstr_format(), octstr_get_cstr, octstr_imm(), octstr_len(), smscconn::our_host, our_port, privdata::our_port, privdata::outgoing_queue, privdata::password, privdata::port, privdata::priv_nexttrn, smscconn::queued, queued_cb(), privdata::receiver_thread, privdata::rport, smscconn::send_msg, privdata::sender_thread, privdata::sendtime, privdata::shutdown, smscconn::shutdown, shutdown_cb(), privdata::slots, sms_priority_compare(), SMSCCONN_CONNECTING, SMSCCONN_DEAD, SMSCCONN_KILLED_CANNOT_CONNECT, start_cb(), smscconn::start_conn, smscconn::status, privdata::unacked, privdata::username, privdata::waitack, privdata::waitack_expire, warning(), smscconn::why_killed, and privdata::window.

Referenced by smscconn_create().

1630 {
1631  PrivData *privdata;
1632  Octstr *allow_ip, *deny_ip, *host, *alt_host;
1633  long portno, our_port, keepalive, flowcontrol, waitack,
1634  idle_timeout, alt_portno, alt_charset, waitack_expire;
1635  long window;
1636  /* has to be long because of cfg_get_integer */
1637  int i;
1638 
1639  allow_ip = deny_ip = host = alt_host = NULL;
1640 
1641  privdata = gw_malloc(sizeof(PrivData));
1643  privdata->listening_socket = -1;
1644  privdata->can_write = 1;
1645  privdata->priv_nexttrn = 0;
1647  privdata->check_time = 0;
1648 
1649  /* host may be empty if receive-port is used */
1650  host = cfg_get(cfg, octstr_imm("host"));
1651  privdata->host = host;
1652 
1653  if (cfg_get_integer(&portno, cfg, octstr_imm("port")) == -1)
1654  portno = 0;
1655  privdata->port = portno;
1656  if (host && (privdata->port <= 0 || privdata->port > 65535)) {
1657  error(0, "EMI2[%s]: 'port' missing/invalid in emi2 configuration.",
1659  goto error;
1660  }
1661 
1662  if (cfg_get_integer(&our_port, cfg, octstr_imm("our-port")) == -1)
1663  privdata->our_port = 0; /* 0 means use any port */
1664  else
1666 
1667  privdata->name = cfg_get(cfg, octstr_imm("smsc-id"));
1668  if (privdata->name == NULL) {
1669  privdata->name = octstr_create("");
1670 
1671  /* Add our_host */
1672  if (octstr_len(conn->our_host)) {
1674  }
1675 
1676  /* Add our_port */
1677  if (privdata->our_port != 0) {
1678  /* if we have our_port but not our_host, add kannel:our_port */
1679  if(octstr_len(privdata->name) == 0) {
1680  octstr_append(privdata->name, octstr_imm("kannel"));
1681  }
1684  } else {
1685  if(octstr_len(privdata->name) != 0) {
1687  }
1688  }
1689 
1690  /* if we have our_host neither our_port */
1691  if (octstr_len(privdata->name) != 0)
1693 
1694  if (privdata->host) {
1698  }
1699  }
1700 
1701  if (cfg_get_integer(&idle_timeout, cfg, octstr_imm("idle-timeout")) == -1)
1702  idle_timeout = 0;
1703 
1704  privdata->idle_timeout = idle_timeout;
1705 
1706  alt_host = cfg_get(cfg, octstr_imm("alt-host"));
1707  privdata->alt_host = alt_host;
1708 
1709  if (cfg_get_integer(&portno, cfg, octstr_imm("receive-port")) < 0)
1710  portno = 0;
1711  privdata->rport = portno;
1712 
1713  /* if neither host, nor receive-port is defined */
1714  if (privdata->host == NULL && privdata->rport == 0) {
1715  error(0, "EMI2[-]: 'receive-port' missing/invalid in emi2 configuration, "
1716  "while no 'host' and 'port' defined.");
1717  goto error;
1718  }
1719 
1720  if (cfg_get_integer(&alt_portno, cfg, octstr_imm("alt-port")) < 0)
1721  alt_portno = 0;
1722  privdata->alt_port = alt_portno;
1723 
1724  allow_ip = cfg_get(cfg, octstr_imm("connect-allow-ip"));
1725  if (allow_ip)
1726  deny_ip = octstr_create("*.*.*.*");
1727  else
1728  deny_ip = NULL;
1729  privdata->username = cfg_get(cfg, octstr_imm("smsc-username"));
1730  privdata->password = cfg_get(cfg, octstr_imm("smsc-password"));
1731 
1732  privdata->my_number = cfg_get(cfg, octstr_imm("my-number"));
1733 
1734  privdata->npid = cfg_get(cfg, octstr_imm("notification-pid"));
1735  privdata->nadc = cfg_get(cfg, octstr_imm("notification-addr"));
1736 
1737  if ( (privdata->username == NULL && privdata->my_number == NULL) ||
1738  cfg_get_integer(&keepalive, cfg, octstr_imm("keepalive")) < 0)
1739  privdata->keepalive = 0;
1740  else
1741  privdata->keepalive = keepalive;
1742 
1743  if (cfg_get_integer(&flowcontrol, cfg, octstr_imm("flow-control")) < 0)
1744  privdata->flowcontrol = 0;
1745  else
1746  privdata->flowcontrol = flowcontrol;
1747  if (privdata->flowcontrol < 0 || privdata->flowcontrol > 1) {
1748  error(0, "EMI2[%s]: 'flow-control' invalid in emi2 configuration.",
1750  goto error;
1751  }
1752 
1753  if (cfg_get_integer(&window, cfg, octstr_imm("window")) < 0)
1755  else
1756  privdata->window = window;
1757  if (privdata->window > EMI2_MAX_TRN) {
1758  warning(0, "EMI2[%s]: Value of 'window' should be lesser or equal to %d..",
1761  }
1762 
1763  if (cfg_get_integer(&waitack, cfg, octstr_imm("wait-ack")) < 0)
1764  privdata->waitack = 60;
1765  else
1766  privdata->waitack = waitack;
1767  if (privdata->waitack < 30 ) {
1768  error(0, "EMI2[%s]: 'wait-ack' invalid in emi2 configuration.",
1770  goto error;
1771  }
1772 
1773  if (cfg_get_integer(&waitack_expire, cfg, octstr_imm("wait-ack-expire")) < 0)
1774  privdata->waitack_expire = 0;
1775  else
1776  privdata->waitack_expire = waitack_expire;
1777  if (privdata->waitack_expire >3) {
1778  error(0, "EMI2[%s]: 'wait-ack-expire' invalid in emi2 configuration.",
1780  goto error;
1781  }
1782 
1783  if (privdata->rport < 0 || privdata->rport > 65535) {
1784  error(0, "EMI2[%s]: 'receive-port' missing/invalid in emi2 configuration.",
1786  goto error;
1787  }
1788 
1789  if (cfg_get_integer(&alt_charset, cfg, octstr_imm("alt-charset")) < 0)
1790  privdata->alt_charset = 0;
1791  else
1793 
1796 
1797  if (privdata->rport > 0 && emi2_open_listening_socket(conn,privdata) < 0) {
1798  gw_free(privdata);
1799  privdata = NULL;
1800  goto error;
1801  }
1802 
1803  conn->data = privdata;
1804 
1805  if (privdata->host) {
1806  conn->name = octstr_format("EMI2:%S:%d:%S", privdata->host, privdata->port,
1807  privdata->username ? privdata->username : octstr_imm("null"));
1808  } else {
1809  conn->name = octstr_format("EMI2:localhost:%d:%S", privdata->rport,
1810  privdata->username ? privdata->username : octstr_imm("null"));
1811  }
1812 
1813  privdata->shutdown = 0;
1814 
1815  for (i = 0; i < EMI2_MAX_TRN; i++)
1816  privdata->slots[i].sendtime = 0;
1817  privdata->unacked = 0;
1818 
1819  conn->status = SMSCCONN_CONNECTING;
1820  conn->connect_time = time(NULL);
1821 
1822  if (privdata->rport > 0 && (privdata->receiver_thread = gwthread_create(emi2_listener, conn)) == -1)
1823  goto error;
1824 
1825  if (privdata->host && (privdata->sender_thread = gwthread_create(emi2_sender, conn)) == -1) {
1826  privdata->shutdown = 1;
1827  if (privdata->rport > 0) {
1830  }
1831  goto error;
1832  }
1833 
1834  conn->shutdown = shutdown_cb;
1835  conn->queued = queued_cb;
1836  conn->start_conn = start_cb;
1837  conn->send_msg = add_msg_cb;
1838 
1839  return 0;
1840 
1841 error:
1842  error(0, "EMI2[%s]: Failed to create emi2 smsc connection",
1843  (privdata ? octstr_get_cstr(privdata->name) : "-"));
1844  if (privdata != NULL) {
1846  }
1847  gw_free(privdata);
1852  conn->status = SMSCCONN_DEAD;
1853  info(0, "EMI2[%s]: exiting", (privdata ? octstr_get_cstr(privdata->name) : "-"));
1854  return -1;
1855 }
int port
Definition: smsc_cgw.c:159
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
static long our_port
Definition: radius_acct.c:87
time_t last_activity_time
Definition: smsc_emi.c:126
int window
Definition: smsc_emi.c:121
void octstr_append(Octstr *ostr1, const Octstr *ostr2)
Definition: octstr.c:1504
void gwthread_join(long thread)
void * data
Definition: smscconn_p.h:250
int priv_nexttrn
Definition: smsc_emi.c:123
int waitack
Definition: smsc_cgw.c:171
List * outgoing_queue
Definition: smsc_cgw.c:153
void octstr_append_char(Octstr *ostr, int ch)
Definition: octstr.c:1517
Octstr * password
Definition: smsc_cimd2.c:100
static Octstr * host
Definition: fakesmsc.c:122
Octstr * npid
Definition: smsc_emi.c:132
#define cfg_get(grp, varname)
Definition: cfg.h:86
int can_write
Definition: smsc_emi.c:122
Octstr * our_host
Definition: smscconn_p.h:192
static Cfg * cfg
Definition: opensmppbox.c:95
#define octstr_get_cstr(ostr)
Definition: octstr.h:233
void(* start_conn)(SMSCConn *conn)
Definition: smscconn_p.h:246
int flowcontrol
Definition: smsc_emi.c:118
static int shutdown_cb(SMSCConn *conn, int finish_sending)
Definition: smsc_emi.c:1573
smscconn_killed_t why_killed
Definition: smscconn_p.h:153
static void emi2_sender(void *arg)
Definition: smsc_emi.c:1357
struct privdata::@23 slots[EMI2_MAX_TRN]
Octstr * octstr_imm(const char *cstr)
Definition: octstr.c:283
int sms_priority_compare(const void *a, const void *b)
Definition: sms.c:395
static int emi2_open_listening_socket(SMSCConn *conn, PrivData *privdata)
Definition: smsc_emi.c:1459
Octstr * my_number
Definition: smsc_cimd2.c:105
#define EMI2_MAX_TRN
Definition: smsc_emi.c:93
time_t connect_time
Definition: smscconn_p.h:155
static Octstr * deny_ip
Definition: bb_udp.c:112
Octstr * username
Definition: smsc_cimd2.c:99
Octstr * allow_ip
Definition: smsc_cgw.c:164
void warning(int err, const char *fmt,...)
Definition: log.c:660
Octstr * host
Definition: smsc_cgw.c:163
Octstr * octstr_format(const char *fmt,...)
Definition: octstr.c:2464
void octstr_destroy(Octstr *ostr)
Definition: octstr.c:324
int rport
Definition: smsc_cgw.c:160
#define gwthread_create(func, arg)
Definition: gwthread.h:90
#define octstr_create(cstr)
Definition: octstr.h:125
long check_time
Definition: smsc_cgw.c:173
Octstr * name
Definition: smsc_emi.c:96
gw_prioqueue_t * gw_prioqueue_create(int(*cmp)(const void *, const void *))
Definition: gw-prioqueue.c:174
static int add_msg_cb(SMSCConn *conn, Msg *sms)
Definition: smsc_emi.c:1560
static Octstr * allow_ip
Definition: bb_udp.c:111
int alt_port
Definition: smsc_emi.c:103
int shutdown
Definition: smsc_cgw.c:156
long sender_thread
Definition: smsc_cgw.c:155
long octstr_len(const Octstr *ostr)
Definition: octstr.c:342
void octstr_append_decimal(Octstr *ostr, long value)
Definition: octstr.c:1976
void gw_prioqueue_destroy(gw_prioqueue_t *queue, void(*item_destroy)(void *))
Definition: gw-prioqueue.c:201
int alt_charset
Definition: smsc_emi.c:134
int waitack_expire
Definition: smsc_emi.c:120
Definition: octstr.c:118
int(* shutdown)(SMSCConn *conn, int finish_sending)
Definition: smscconn_p.h:230
int cfg_get_integer(long *n, CfgGroup *grp, Octstr *varname)
Definition: cfg.c:742
static void emi2_listener(void *arg)
Definition: smsc_emi.c:1479
static void start_cb(SMSCConn *conn)
Definition: smsc_emi.c:1603
Octstr * nadc
Definition: smsc_emi.c:133
void gwthread_wakeup(long thread)
smscconn_status_t status
Definition: smscconn_p.h:151
Octstr * alt_host
Definition: smsc_emi.c:108
long(* queued)(SMSCConn *conn)
Definition: smscconn_p.h:241
int(* send_msg)(SMSCConn *conn, Msg *msg)
Definition: smscconn_p.h:236
long receiver_thread
Definition: smsc_cgw.c:154
int listening_socket
Definition: smsc_cgw.c:157
int unacked
Definition: smsc_cgw.c:170
int idle_timeout
Definition: smsc_emi.c:130
time_t sendtime[CGW_TRN_MAX]
Definition: smsc_cgw.c:168
int our_port
Definition: smsc_cgw.c:161
static long queued_cb(SMSCConn *conn)
Definition: smsc_emi.c:1615
Octstr * deny_ip
Definition: smsc_cgw.c:164
long keepalive
Definition: smsc_cimd2.c:104
static Octstr * alt_charset
Definition: opensmppbox.c:129

◆ smsc_fake_create()

int smsc_fake_create ( SMSCConn conn,
CfgGroup cfg 
)

Definition at line 540 of file smsc_fake.c.

References add_msg_cb(), allow_ip, privdata::allow_ip, cfg, cfg_get, cfg_get_integer(), smscconn::connect_time, privdata::connection_thread, smscconn::data, deny_ip, privdata::deny_ip, error(), fake_listener(), fake_open_connection(), gwlist_create, gwlist_destroy(), gwthread_create, privdata::listening_socket, smscconn::name, octstr_create, octstr_destroy(), octstr_format(), octstr_imm(), privdata::outgoing_queue, privdata::port, smscconn::queued, queued_cb(), smscconn::send_msg, privdata::shutdown, smscconn::shutdown, shutdown_cb(), SMSCCONN_CONNECTING, SMSCCONN_DEAD, SMSCCONN_KILLED_CANNOT_CONNECT, start_cb(), smscconn::start_conn, smscconn::status, and smscconn::why_killed.

Referenced by smscconn_create().

541 {
542  PrivData *privdata = NULL;
544  long portno; /* has to be long because of cfg_get_integer */
545 
546  if (cfg_get_integer(&portno, cfg, octstr_imm("port")) == -1)
547  portno = 0;
548  allow_ip = cfg_get(cfg, octstr_imm("connect-allow-ip"));
549  if (allow_ip)
550  deny_ip = octstr_create("*.*.*.*");
551  else
552  deny_ip = NULL;
553 
554  if (portno == 0) {
555  error(0, "'port' invalid in 'fake' record.");
556  goto error;
557  }
558  privdata = gw_malloc(sizeof(PrivData));
560 
561  privdata->port = portno;
564 
565  if (fake_open_connection(conn, privdata) < 0) {
566  gw_free(privdata);
567  privdata = NULL;
568  goto error;
569  }
570 
571  conn->data = privdata;
572 
573  conn->name = octstr_format("FAKE:%d", privdata->port);
574 
576  privdata->shutdown = 0;
577 
578  conn->status = SMSCCONN_CONNECTING;
579  conn->connect_time = time(NULL);
580 
582  goto error;
583 
584  conn->shutdown = shutdown_cb;
585  conn->queued = queued_cb;
586  conn->start_conn = start_cb;
587  conn->send_msg = add_msg_cb;
588 
589  return 0;
590 
591 error:
592  error(0, "Failed to create fake smsc connection");
593  if (privdata != NULL) {
595  if (close(privdata->listening_socket == -1)) {
596  error(errno, "smsc_fake: closing listening socket port %d failed",
598  }
599  }
600  gw_free(privdata);
604  conn->status = SMSCCONN_DEAD;
605  return -1;
606 }
int port
Definition: smsc_cgw.c:159
Octstr * name
Definition: smscconn_p.h:173
void error(int err, const char *fmt,...)
Definition: log.c:648
void * data
Definition: smscconn_p.h:250
List * outgoing_queue
Definition: smsc_cgw.c:153
static void start_cb(SMSCConn *conn)
Definition: smsc_fake.c:516
#define cfg_get(grp, varname)
Definition: cfg.h:86
static Cfg * cfg
Definition: opensmppbox.c:95
void(* start_conn)(SMSCConn *conn)
Definition: smscconn_p.h:246
smscconn_killed_t why_killed
Definition: smscconn_p.h:153
static void fake_listener(void *arg)
Definition: smsc_fake.c:364
Octstr * octstr_imm(const char *cstr)
Definition: octstr.c:283
static int shutdown_cb(SMSCConn *conn, int finish_sending)
Definition: smsc_fake.c:486
time_t connect_time
Definition: smscconn_p.h:155
static Octstr * deny_ip
Definition: bb_udp.c:112
Octstr * allow_ip
Definition: smsc_cgw.c:164
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
long connection_thread
Definition: smsc_fake.c:83
static Octstr * allow_ip
Definition: bb_udp.c:111
int shutdown
Definition: smsc_cgw.c:156
static int add_msg_cb(SMSCConn *conn, Msg *sms)
Definition: smsc_fake.c:457
Definition: octstr.c:118
int(* shutdown)(SMSCConn *conn, int finish_sending)
Definition: smscconn_p.h:230
int cfg_get_integer(long *n, CfgGroup *grp, Octstr *varname)
Definition: cfg.c:742
smscconn_status_t status
Definition: smscconn_p.h:151
#define gwlist_create()
Definition: list.h:136
long(* queued)(SMSCConn *conn)
Definition: smscconn_p.h:241
int(* send_msg)(SMSCConn *conn, Msg *msg)
Definition: smscconn_p.h:236
int listening_socket
Definition: smsc_cgw.c:157
static int fake_open_connection(SMSCConn *conn, PrivData *privdata)
Definition: smsc_fake.c:91
Octstr * deny_ip
Definition: smsc_cgw.c:164
static long queued_cb(SMSCConn *conn)
Definition: smsc_fake.c:526
void gwlist_destroy(List *list, gwlist_item_destructor_t *destructor)
Definition: list.c:145

◆ smsc_http_create()

int smsc_http_create ( SMSCConn conn,
CfgGroup cfg 
)

Definition at line 489 of file smsc_http.c.

References conndata::allow_ip, conndata::alt_charset, conndata::callbacks, cfg, cfg_get, cfg_get_bool(), cfg_get_integer(), conndata_destroy(), smscconn::connect_time, counter_create(), conndata::data, smscconn::data, smsc_http_fn_callbacks::destroy, conndata::dlr_url, error(), gw_dlopen_get_symbol(), gwlist_add_producer(), gwlist_create, gwthread_create, http_caller_create(), http_open_port(), conndata::http_ref, httpsmsc_queued(), httpsmsc_receiver(), httpsmsc_send(), httpsmsc_send_cb(), httpsmsc_sender(), httpsmsc_shutdown(), smscconn::id, info(), smsc_http_fn_callbacks::init, conndata::max_pending_sends, conndata::mobile_originated, conndata::msg_to_send, smscconn::name, conndata::no_coding, conndata::no_sender, conndata::no_sep, octstr_destroy(), octstr_format(), octstr_get_cstr, octstr_imm(), conndata::open_sends, conndata::password, conndata::port, smscconn::queued, conndata::receive_thread, semaphore_create(), conndata::send_cb_thread, smscconn::send_msg, conndata::send_url, conndata::sender_thread, conndata::shutdown, smscconn::shutdown, SMSCCONN_ACTIVE, SMSCCONN_ACTIVE_RECV, SMSCCONN_DEAD, SMSCCONN_KILLED_CANNOT_CONNECT, ssl, smscconn::status, conndata::system_id, type, conndata::use_post, conndata::username, warning(), and smscconn::why_killed.

Referenced by smscconn_create().

490 {
491  ConnData *conndata = NULL;
492  Octstr *type = NULL, *callbackname = NULL;
493  int ssl = 0; /* indicate if SSL-enabled server should be used */
494  long max_ps;
495 
496  if ((type = cfg_get(cfg, octstr_imm("system-type"))) == NULL) {
497  error(0, "HTTP[%s]: 'system-type' missing in smsc 'http' record.",
498  octstr_get_cstr(conn->id));
500  return -1;
501  }
502 
503  conndata = gw_malloc(sizeof(ConnData));
504  /* reset conndata */
505  memset(conndata, 0, sizeof(ConnData));
506 
507  conn->data = conndata;
508  conndata->http_ref = NULL;
509  conndata->data = NULL;
510 
511  if (cfg_get_integer(&conndata->port, cfg, octstr_imm("port")) == -1) {
512  warning(0, "HTTP[%s]: 'port' not set in smsc 'http' group.",
513  octstr_get_cstr(conn->id));
514  conndata->port = -1;
515  }
516 
517  conndata->allow_ip = cfg_get(cfg, octstr_imm("connect-allow-ip"));
518  conndata->send_url = cfg_get(cfg, octstr_imm("send-url"));
519  conndata->username = cfg_get(cfg, octstr_imm("smsc-username"));
520  conndata->password = cfg_get(cfg, octstr_imm("smsc-password"));
521  conndata->system_id = cfg_get(cfg, octstr_imm("system-id"));
522  cfg_get_bool(&conndata->no_sender, cfg, octstr_imm("no-sender"));
523  cfg_get_bool(&conndata->no_coding, cfg, octstr_imm("no-coding"));
524  cfg_get_bool(&conndata->no_sep, cfg, octstr_imm("no-sep"));
525  cfg_get_bool(&conndata->mobile_originated, cfg, octstr_imm("mobile-originated"));
526  cfg_get_bool(&ssl, cfg, octstr_imm("use-ssl"));
527  conndata->dlr_url = cfg_get(cfg, octstr_imm("dlr-url"));
528  conndata->alt_charset = cfg_get(cfg, octstr_imm("alt-charset"));
529  cfg_get_bool(&conndata->use_post, cfg, octstr_imm("use-post"));
530 
531  if (cfg_get_integer(&max_ps, cfg, octstr_imm("max-pending-submits")) == -1 || max_ps < 1)
532  max_ps = 10;
534 
535  if (conndata->port <= 0 && conndata->send_url == NULL) {
536  error(0, "HTTP[%s]: Sender and receiver disabled. Dummy SMSC not allowed.",
537  octstr_get_cstr(conn->id));
538  goto error;
539  }
540  if (conndata->send_url == NULL) {
541  error(0, "HTTP[%s]: Sending not allowed. No 'send-url' specified.",
542  octstr_get_cstr(conn->id));
543  goto error;
544  }
545 
546  /* callback struct is always in the format: smsc_http_XXX_callback where XXX is our type */
547  callbackname = octstr_format("smsc_http_%S_callback", type);
548  /* try to find the struct */
549  if (gw_dlopen_get_symbol(NULL, octstr_get_cstr(callbackname), (void**)&conndata->callbacks) == -1 || conndata->callbacks == NULL) {
550  error(0, "HTTP[%s]: system-type '%s' unknown smsc 'http' record.",
552  goto error;
553  }
554 
555  if (conndata->callbacks != NULL && conndata->callbacks->init != NULL && conndata->callbacks->init(conn, cfg)) {
556  error(0, "HTTP[%s]: submodule '%s' init failed.", octstr_get_cstr(conn->id), octstr_get_cstr(type));
557  goto error;
558  }
559 
564 
565  conn->name = octstr_format("HTTP%s:%S:%d", (ssl?"S":""), type, conndata->port);
566 
567  if (conndata->send_url != NULL) {
568  conn->status = SMSCCONN_ACTIVE;
569  } else {
571  }
572 
573  conn->connect_time = time(NULL);
574 
575  conn->shutdown = httpsmsc_shutdown;
576  conn->queued = httpsmsc_queued;
577  conn->send_msg = httpsmsc_send;
578 
579  conndata->shutdown = 0;
580 
581  /* start receiver thread */
582  if (conndata->port > 0) {
583  if (http_open_port(conndata->port, ssl) == -1)
584  goto error;
586  goto error;
587  } else
588  conndata->receive_thread = -1;
589 
590  /* start sender threads */
591  if (conndata->send_url) {
592  if ((conndata->send_cb_thread =
593  gwthread_create(httpsmsc_send_cb, conn)) == -1)
594  goto error;
595  if ((conndata->sender_thread =
596  gwthread_create(httpsmsc_sender, conn)) == -1)
597  goto error;
598  }
599  else {
601  }
602 
603  info(0, "HTTP[%s]: Initiated and ready", octstr_get_cstr(conn->id));
604 
605  octstr_destroy(callbackname);
607  return 0;
608 
609 error:
610  error(0, "HTTP[%s]: Failed to create HTTP SMSC connection",
611  octstr_get_cstr(conn->id));
612 
613  if (conndata->callbacks != NULL && conndata->callbacks->destroy != NULL)
614  conndata->callbacks->destroy(conn);
615  conn->data = NULL;
618  conn->status = SMSCCONN_DEAD;
619  octstr_destroy(callbackname);
621  return -1;
622 }
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:114
static void httpsmsc_receiver(void *arg)
Definition: smsc_http.c:161
static void conndata_destroy(ConnData *conndata)
Definition: smsc_http.c:136
Octstr * alt_charset
Definition: smsc_http_p.h:103
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 ssl
int no_sep
Definition: smsc_http_p.h:101
Octstr * id
Definition: smscconn_p.h:174
void * data
Definition: smscconn_p.h:250
HTTPCaller * http_ref
Definition: smsc_http_p.h:86
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
Octstr * system_id
Definition: smsc_http_p.h:107
static Cfg * cfg
Definition: opensmppbox.c:95
#define octstr_get_cstr(ostr)
Definition: octstr.h:233
void(* destroy)(SMSCConn *conn)
Definition: smsc_http_p.h:75
smscconn_killed_t why_killed
Definition: smscconn_p.h:153
volatile int shutdown
Definition: smsc_http_p.h:90
long port
Definition: smsc_http_p.h:91
Octstr * octstr_imm(const char *cstr)
Definition: octstr.c:283
Counter * open_sends
Definition: smsc_http_p.h:95
int no_coding
Definition: smsc_http_p.h:100
List * msg_to_send
Definition: smsc_http_p.h:104
Counter * counter_create(void)
Definition: counter.c:94
static void httpsmsc_send_cb(void *arg)
Definition: smsc_http.c:312
time_t connect_time
Definition: smscconn_p.h:155
long sender_thread
Definition: smsc_http_p.h:89
void warning(int err, const char *fmt,...)
Definition: log.c:660
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
int no_sender
Definition: smsc_http_p.h:99
static int httpsmsc_shutdown(SMSCConn *conn, int finish_sending)
Definition: smsc_http.c:461
int http_open_port(int port, int ssl)
Definition: http.c:2509
Semaphore * max_pending_sends
Definition: smsc_http_p.h:96
int cfg_get_bool(int *n, CfgGroup *grp, Octstr *varname)
Definition: cfg.c:759
int(* init)(SMSCConn *conn, CfgGroup *cfg)
Definition: smsc_http_p.h:74
Definition: octstr.c:118
static long httpsmsc_queued(SMSCConn *conn)
Definition: smsc_http.c:450
int(* shutdown)(SMSCConn *conn, int finish_sending)
Definition: smscconn_p.h:230
Octstr * password
Definition: smsc_http_p.h:98
int cfg_get_integer(long *n, CfgGroup *grp, Octstr *varname)
Definition: cfg.c:742
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:241
int(* send_msg)(SMSCConn *conn, Msg *msg)
Definition: smscconn_p.h:236
Octstr * username
Definition: smsc_http_p.h:97
static int httpsmsc_send(SMSCConn *conn, Msg *msg)
Definition: smsc_http.c:402
Octstr * send_url
Definition: smsc_http_p.h:93
void gwlist_add_producer(List *list)
Definition: list.c:383
static void httpsmsc_sender(void *arg)
Definition: smsc_http.c:242
struct smsc_http_fn_callbacks * callbacks
Definition: smsc_http_p.h:111
Semaphore * semaphore_create(long n)
Definition: gw-semaphore.c:81
long send_cb_thread
Definition: smsc_http_p.h:88
int use_post
Definition: smsc_http_p.h:102
int mobile_originated
Definition: smsc_http_p.h:108

◆ smsc_loopback_create()

int smsc_loopback_create ( SMSCConn conn,
CfgGroup cfg 
)

Definition at line 165 of file smsc_loopback.c.

References smscconn::connect_time, smscconn::data, smscconn::id, msg_cb(), smscconn::name, octstr_format(), smscconn::queued, queued_cb(), smscconn::send_msg, smscconn::shutdown, shutdown_cb(), SMSCCONN_CONNECTING, start_cb(), smscconn::start_conn, and smscconn::status.

Referenced by smscconn_create().

166 {
167  conn->data = NULL;
168  conn->name = octstr_format("LOOPBACK:%S", conn->id);
169 
170  conn->status = SMSCCONN_CONNECTING;
171  conn->connect_time = time(NULL);
172 
173  conn->shutdown = shutdown_cb;
174  conn->queued = queued_cb;
175  conn->start_conn = start_cb;
176  conn->send_msg = msg_cb;
177 
178  return 0;
179 }
Octstr * name
Definition: smscconn_p.h:173
static int msg_cb(SMSCConn *conn, Msg *msg)
Definition: smsc_loopback.c:76
static int shutdown_cb(SMSCConn *conn, int finish_sending)
Octstr * id
Definition: smscconn_p.h:174
void * data
Definition: smscconn_p.h:250
static void start_cb(SMSCConn *conn)
void(* start_conn)(SMSCConn *conn)
Definition: smscconn_p.h:246
time_t connect_time
Definition: smscconn_p.h:155
Octstr * octstr_format(const char *fmt,...)
Definition: octstr.c:2464
int(* shutdown)(SMSCConn *conn, int finish_sending)
Definition: smscconn_p.h:230
smscconn_status_t status
Definition: smscconn_p.h:151
long(* queued)(SMSCConn *conn)
Definition: smscconn_p.h:241
int(* send_msg)(SMSCConn *conn, Msg *msg)
Definition: smscconn_p.h:236
static long queued_cb(SMSCConn *conn)

◆ smsc_oisd_create()

int smsc_oisd_create ( SMSCConn conn,
CfgGroup cfg 
)

Definition at line 1498 of file smsc_oisd.c.

References cfg_get, cfg_get_bool(), cfg_get_integer(), privdata::conn, smscconn::data, debug(), error(), gwlist_add_producer(), gwlist_create, gwthread_create, gwthread_join(), gwthread_wakeup(), privdata::host, smscconn::id, privdata::inbuffer, privdata::io_thread, io_thread(), smscconn::is_stopped, privdata::keepalive, privdata::my_number, smscconn::name, privdata::next_ping, privdata::no_dlr, octstr_create, octstr_format(), octstr_get_cstr, octstr_imm(), oisd_add_msg_cb(), oisd_destroy(), oisd_queued_cb(), oisd_shutdown_cb(), oisd_start_cb(), oisd_stop_cb(), ok, privdata::outgoing_queue, privdata::port, smscconn::queued, privdata::quitting, privdata::received, smscconn::send_msg, privdata::send_seq, smscconn::shutdown, SMS_PARAM_UNDEFINED, privdata::socket, smscconn::start_conn, smscconn::stop_conn, privdata::stopped, and privdata::validityperiod.

Referenced by smscconn_create().

1499 {
1500  PrivData *pdata;
1501  int ok;
1502 
1503  pdata = gw_malloc(sizeof(PrivData));
1504  conn->data = pdata;
1505  pdata->conn = conn;
1506 
1507  pdata->no_dlr = 0;
1508  pdata->quitting = 0;
1509  pdata->socket = -1;
1510  pdata->received = gwlist_create();
1511  pdata->inbuffer = octstr_create("");
1512  pdata->send_seq = 1;
1513  pdata->outgoing_queue = gwlist_create();
1514  pdata->stopped = gwlist_create();
1516 
1517  if (conn->is_stopped)
1518  gwlist_add_producer(pdata->stopped);
1519 
1520  pdata->host = cfg_get(grp, octstr_imm("host"));
1521  if (cfg_get_integer(&(pdata->port), grp, octstr_imm("port")) == -1)
1522  pdata->port = 0;
1523  pdata->my_number = cfg_get(grp, octstr_imm("my-number"));
1524  if (cfg_get_integer(&(pdata->keepalive), grp, octstr_imm("keepalive")) == -1)
1525  pdata->keepalive = 0;
1526  if (cfg_get_integer(&(pdata->validityperiod), grp, octstr_imm("validityperiod")) == -1)
1528 
1529  cfg_get_bool(&pdata->no_dlr, grp, octstr_imm("no-dlr"));
1530 
1531  /* Check that config is OK */
1532  ok = 1;
1533  if (pdata->host == NULL) {
1534  error(0, "OISD[%s]: Configuration file doesn't specify host",
1535  octstr_get_cstr(conn->id));
1536  ok = 0;
1537  }
1538  if (pdata->port == 0) {
1539  error(0, "OISD[%s]: Configuration file doesn't specify port",
1540  octstr_get_cstr(conn->id));
1541  ok = 0;
1542  }
1543  if (pdata->my_number == NULL && pdata->keepalive > 0) {
1544  error(0, "OISD[%s]: Configuration file doesn't specify my-number.",
1545  octstr_get_cstr(conn->id));
1546  ok = 0;
1547  }
1548 
1549  if (!ok) {
1550  oisd_destroy(pdata);
1551  return -1;
1552  }
1553 
1554  conn->name = octstr_format("OISD:%s:%d",
1555  octstr_get_cstr(pdata->host),
1556  pdata->port);
1557 
1558 
1559  if (pdata->keepalive > 0) {
1560  debug("bb.sms.oisd", 0, "OISD[%s]: Keepalive set to %ld seconds",
1561  octstr_get_cstr(conn->id),
1562  pdata->keepalive);
1563  pdata->next_ping = time(NULL) + pdata->keepalive;
1564  }
1565 
1566  if (pdata->validityperiod > 0) {
1567  debug("bb.sms.oisd", 0, "OISD[%s]: Validity-Period set to %ld",
1568  octstr_get_cstr(conn->id),
1569  pdata->validityperiod);
1570  }
1571 
1572  pdata->io_thread = gwthread_create(io_thread, conn);
1573 
1574  if (pdata->io_thread == -1) {
1575 
1576  error(0, "OISD[%s]: Couldn't start I/O thread.",
1577  octstr_get_cstr(conn->id));
1578  pdata->quitting = 1;
1579  gwthread_wakeup(pdata->io_thread);
1580  gwthread_join(pdata->io_thread);
1581  oisd_destroy(pdata);
1582  return -1;
1583  }
1584 
1585  conn->send_msg = oisd_add_msg_cb;
1586  conn->shutdown = oisd_shutdown_cb;
1587  conn->queued = oisd_queued_cb;
1588  conn->start_conn = oisd_start_cb;
1589  conn->stop_conn = oisd_stop_cb;
1590 
1591  return 0;
1592 }
int port
Definition: smsc_cgw.c:159
Octstr * name
Definition: smscconn_p.h:173
void error(int err, const char *fmt,...)
Definition: log.c:648
Octstr * inbuffer
Definition: smsc_cimd2.c:112
static void io_thread(void *arg)
Definition: smsc_oisd.c:1344
static void oisd_stop_cb(SMSCConn *conn)
Definition: smsc_oisd.c:1482
Octstr * id
Definition: smscconn_p.h:174
void gwthread_join(long thread)
long validityperiod
Definition: smsc_oisd.c:94
void * data
Definition: smscconn_p.h:250
List * outgoing_queue
Definition: smsc_cgw.c:153
void(* stop_conn)(SMSCConn *conn)
Definition: smscconn_p.h:247
int socket
Definition: smsc_cimd2.c:108
#define cfg_get(grp, varname)
Definition: cfg.h:86
int io_thread
Definition: smsc_cimd2.c:119
#define octstr_get_cstr(ostr)
Definition: octstr.h:233
void(* start_conn)(SMSCConn *conn)
Definition: smscconn_p.h:246
List * stopped
Definition: smsc_cimd2.c:121
time_t next_ping
Definition: smsc_cimd2.c:115
static int oisd_add_msg_cb(SMSCConn *conn, Msg *sms)
Definition: smsc_oisd.c:1418
static void oisd_start_cb(SMSCConn *conn)
Definition: smsc_oisd.c:1471
Octstr * octstr_imm(const char *cstr)
Definition: octstr.c:283
Octstr * my_number
Definition: smsc_cimd2.c:105
static void oisd_destroy(PrivData *pdata)
Definition: smsc_oisd.c:1128
Octstr * host
Definition: smsc_cgw.c:163
int quitting
Definition: smsc_cimd2.c:120
Octstr * octstr_format(const char *fmt,...)
Definition: octstr.c:2464
#define gwthread_create(func, arg)
Definition: gwthread.h:90
#define octstr_create(cstr)
Definition: octstr.h:125
#define SMS_PARAM_UNDEFINED
Definition: sms.h:91
volatile sig_atomic_t is_stopped
Definition: smscconn_p.h:169
static long oisd_queued_cb(SMSCConn *conn)
Definition: smsc_oisd.c:1490
int send_seq
Definition: smsc_cimd2.c:109
int no_dlr
Definition: smsc_cimd2.c:106
int cfg_get_bool(int *n, CfgGroup *grp, Octstr *varname)
Definition: cfg.c:759
int(* shutdown)(SMSCConn *conn, int finish_sending)
Definition: smscconn_p.h:230
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:742
Definition: wtp_tid.h:82
void gwthread_wakeup(long thread)
List * received
Definition: smsc_cimd2.c:113
#define gwlist_create()
Definition: list.h:136
long(* queued)(SMSCConn *conn)
Definition: smscconn_p.h:241
int(* send_msg)(SMSCConn *conn, Msg *msg)
Definition: smscconn_p.h:236
void gwlist_add_producer(List *list)
Definition: list.c:383
long keepalive
Definition: smsc_cimd2.c:104
static int oisd_shutdown_cb(SMSCConn *conn, int finish_sending)
Definition: smsc_oisd.c:1430
SMSCConn * conn
Definition: smsc_cimd2.c:118

◆ smsc_smasi_create()

int smsc_smasi_create ( SMSCConn conn,
CfgGroup cfg 
)

Definition at line 1129 of file smsc_smasi.c.

References assign, colon, comma, SMASI::conn, cr, smscconn::data, error(), gwthread_create, smscconn::id, init_configuration(), lf, octstr_create, octstr_get_cstr, panic, smscconn::queued, queued_cb(), smscconn::send_msg, send_msg_cb(), smscconn::shutdown, shutdown_cb(), smasi_create(), smasi_destroy(), smasi_thread(), SMSCCONN_CONNECTING, smscconn::status, and SMASI::thread_handle.

Referenced by smscconn_create().

1130 {
1131  SMASI *smasi = NULL;
1132 
1133  /* Initialize data encoding subsystem. */
1134  colon = octstr_create(":3a");
1135  assign = octstr_create(":3d");
1136  comma = octstr_create(":2c");
1137  cr = octstr_create(":0a");
1138  lf = octstr_create(":0d");
1139 
1140  /* Create main SMASI structure and initialize it with configuration
1141  * settings.
1142  */
1143  smasi = smasi_create(conn);
1144 
1145  if (init_configuration(smasi, config) != 0)
1146  panic(0, "SMASI SMSC module configuration invalid.");
1147 
1148  conn->status = SMSCCONN_CONNECTING;
1149 
1150  /* Port is always set to a configured value or defaults to 21500.
1151  * Therefore, threads are always started.
1152  */
1153  smasi->thread_handle = gwthread_create(smasi_thread, smasi);
1154 
1155  if (smasi->thread_handle == -1) {
1156  error(0, "SMASI[%s]: Couldn't start SMASI thread.",
1157  octstr_get_cstr(smasi->conn->id));
1158  smasi_destroy(conn->data);
1159  return -1;
1160  }
1161 
1162  /* Setup control function pointers. */
1163  conn->shutdown = shutdown_cb;
1164  conn->queued = queued_cb;
1165  conn->send_msg = send_msg_cb;
1166 
1167  return 0;
1168 }
void error(int err, const char *fmt,...)
Definition: log.c:648
static Octstr * cr
Definition: smsc_smasi.c:221
SMSCConn * conn
Definition: smsc_smasi.c:136
Octstr * id
Definition: smscconn_p.h:174
void * data
Definition: smscconn_p.h:250
static int shutdown_cb(SMSCConn *conn, int finish_sending)
Definition: smsc_smasi.c:1034
static Octstr * comma
Definition: smsc_smasi.c:220
#define octstr_get_cstr(ostr)
Definition: octstr.h:233
static SMASI * smasi_create(SMSCConn *conn)
Definition: smsc_smasi.c:159
static void smasi_destroy(SMASI *smasi)
Definition: smsc_smasi.c:192
#define gwthread_create(func, arg)
Definition: gwthread.h:90
#define octstr_create(cstr)
Definition: octstr.h:125
static Octstr * colon
Definition: smsc_smasi.c:218
static int init_configuration(SMASI *smasi, CfgGroup *config)
Definition: smsc_smasi.c:1071
int(* shutdown)(SMSCConn *conn, int finish_sending)
Definition: smscconn_p.h:230
static int send_msg_cb(SMSCConn *conn, Msg *msg)
Definition: smsc_smasi.c:1023
#define panic
Definition: log.h:87
smscconn_status_t status
Definition: smscconn_p.h:151
int thread_handle
Definition: smsc_smasi.c:137
long(* queued)(SMSCConn *conn)
Definition: smscconn_p.h:241
int(* send_msg)(SMSCConn *conn, Msg *msg)
Definition: smscconn_p.h:236
static void smasi_thread(void *arg)
Definition: smsc_smasi.c:911
static Octstr * lf
Definition: smsc_smasi.c:222
static long queued_cb(SMSCConn *conn)
Definition: smsc_smasi.c:1012
static Octstr * assign
Definition: smsc_smasi.c:219

◆ smsc_smpp_create()

int smsc_smpp_create ( SMSCConn conn,
CfgGroup cfg 
)

Definition at line 2599 of file smsc_smpp.c.

References alt_charset, SMPP::bind_addr_npi, SMPP::bind_addr_ton, cfg_get, cfg_get_bool(), cfg_get_integer(), SMPP::conn, smscconn::data, error(), ESM_CLASS_SUBMIT_STORE_AND_FORWARD_MODE, gwthread_create, gwthread_join(), gwthread_wakeup(), host, smscconn::id, io_arg_create(), io_thread(), SMPP::log_format, smscconn::name, octstr_destroy(), octstr_duplicate, octstr_format(), octstr_get_cstr, octstr_imm(), octstr_len(), ok, our_port, panic, password, port, smscconn::queued, queued_cb(), SMPP::quitting, SMPP::receiver, SMPP::retry, smscconn::send_msg, send_msg_cb(), smscconn::shutdown, shutdown_cb(), smpp_create(), SMPP_DEFAULT_CONNECTION_TIMEOUT, SMPP_DEFAULT_PORT, SMPP_DEFAULT_PRIORITY, SMPP_DEFAULT_VERSION, SMPP_DEFAULT_WAITACK, smpp_destroy(), SMPP_ENQUIRE_LINK_INTERVAL, SMPP_MAX_PENDING_SUBMITS, SMPP_PDU_DUMP_MULTILINE, SMPP_WAITACK_REQUEUE, SMS_PARAM_UNDEFINED, smsc_id, SMSCCONN_CONNECTING, SMPP::ssl_client_certkey_file, smscconn::status, SMPP::transmitter, SMPP::use_ssl, username, and warning().

Referenced by smscconn_create().

2600 {
2601  Octstr *host;
2602  long port;
2603  long receive_port;
2604  Octstr *username;
2605  Octstr *password;
2606  Octstr *system_id;
2607  Octstr *system_type;
2608  Octstr *address_range;
2609  long source_addr_ton;
2610  long source_addr_npi;
2611  long dest_addr_ton;
2612  long dest_addr_npi;
2613  long our_port;
2614  long our_receiver_port;
2615  Octstr *my_number;
2616  Octstr *service_type;
2617  SMPP *smpp;
2618  int ok;
2619  int transceiver_mode;
2620  Octstr *smsc_id;
2621  long enquire_link_interval;
2622  long max_pending_submits;
2623  long version;
2624  long priority;
2625  long validity;
2626  long smpp_msg_id_type;
2627  int autodetect_addr;
2629  Octstr *alt_addr_charset;
2630  long connection_timeout, wait_ack, wait_ack_action;
2631  long esm_class;
2632 
2633  my_number = alt_addr_charset = alt_charset = NULL;
2634  transceiver_mode = 0;
2635  autodetect_addr = 1;
2636 
2637  host = cfg_get(grp, octstr_imm("host"));
2638  if (cfg_get_integer(&port, grp, octstr_imm("port")) == -1)
2639  port = 0;
2640  if (cfg_get_integer(&receive_port, grp, octstr_imm("receive-port")) == -1)
2641  receive_port = 0;
2642 
2643  if (cfg_get_integer(&our_port, grp, octstr_imm("our-port")) == -1)
2644  our_port = 0;
2645  if (cfg_get_integer(&our_receiver_port, grp, octstr_imm("our-receiver-port")) == -1)
2646  our_receiver_port = 0;
2647 
2648  cfg_get_bool(&transceiver_mode, grp, octstr_imm("transceiver-mode"));
2649  username = cfg_get(grp, octstr_imm("smsc-username"));
2650  password = cfg_get(grp, octstr_imm("smsc-password"));
2651  system_type = cfg_get(grp, octstr_imm("system-type"));
2652  address_range = cfg_get(grp, octstr_imm("address-range"));
2653  my_number = cfg_get(grp, octstr_imm("my-number"));
2654  service_type = cfg_get(grp, octstr_imm("service-type"));
2655 
2656  system_id = cfg_get(grp, octstr_imm("system-id"));
2657  if (system_id != NULL) {
2658  warning(0, "SMPP: obsolete system-id variable is set, "
2659  "use smsc-username instead.");
2660  if (username == NULL) {
2661  warning(0, "SMPP: smsc-username not set, using system-id instead");
2662  username = system_id;
2663  } else
2664  octstr_destroy(system_id);
2665  }
2666 
2667  /*
2668  * check if timing values have been configured, otherwise
2669  * use the predefined default values.
2670  */
2671  if (cfg_get_integer(&enquire_link_interval, grp,
2672  octstr_imm("enquire-link-interval")) == -1)
2673  enquire_link_interval = SMPP_ENQUIRE_LINK_INTERVAL;
2674  if (cfg_get_integer(&max_pending_submits, grp,
2675  octstr_imm("max-pending-submits")) == -1)
2676  max_pending_submits = SMPP_MAX_PENDING_SUBMITS;
2677 
2678  /* Check that config is OK */
2679  ok = 1;
2680  if (host == NULL) {
2681  error(0, "SMPP: Configuration file doesn't specify host");
2682  ok = 0;
2683  }
2684  if (port == 0 && receive_port == 0) {
2686  warning(0, "SMPP: Configuration file doesn't specify port or receive-port. "
2687  "Using 'port = %ld' as default.", port);
2688  }
2689  if (port != 0 && receive_port != 0) {
2690  error(0, "SMPP: Configuration file can only have port or receive-port. "
2691  "Usage of both in one group is deprecated!");
2692  ok = 0;
2693  }
2694  if (username == NULL) {
2695  error(0, "SMPP: Configuration file doesn't specify username.");
2696  ok = 0;
2697  }
2698  if (password == NULL) {
2699  error(0, "SMPP: Configuration file doesn't specify password.");
2700  ok = 0;
2701  }
2702  if (system_type == NULL) {
2703  error(0, "SMPP: Configuration file doesn't specify system-type.");
2704  ok = 0;
2705  }
2706  if (octstr_len(service_type) > 6) {
2707  error(0, "SMPP: Service type must be 6 characters or less.");
2708  ok = 0;
2709  }
2710  if (transceiver_mode && receive_port != 0) {
2711  warning(0, "SMPP: receive-port for transceiver mode defined, ignoring.");
2712  receive_port = 0;
2713  }
2714 
2715  if (!ok)
2716  return -1;
2717 
2718  /* if the ton and npi values are forced, set them, else set them to -1 */
2719  if (cfg_get_integer(&source_addr_ton, grp,
2720  octstr_imm("source-addr-ton")) == -1)
2721  source_addr_ton = -1;
2722  if (cfg_get_integer(&source_addr_npi, grp,
2723  octstr_imm("source-addr-npi")) == -1)
2724  source_addr_npi = -1;
2725  if (cfg_get_integer(&dest_addr_ton, grp,
2726  octstr_imm("dest-addr-ton")) == -1)
2727  dest_addr_ton = -1;
2728  if (cfg_get_integer(&dest_addr_npi, grp,
2729  octstr_imm("dest-addr-npi")) == -1)
2730  dest_addr_npi = -1;
2731 
2732  /* if source addr autodetection should be used set this to 1 */
2733  if (cfg_get_bool(&autodetect_addr, grp, octstr_imm("source-addr-autodetect")) == -1)
2734  autodetect_addr = 1; /* default is autodetect if no option defined */
2735 
2736  /* check for any specified interface version */
2737  if (cfg_get_integer(&version, grp, octstr_imm("interface-version")) == -1)
2738  version = SMPP_DEFAULT_VERSION;
2739  else
2740  /* convert decimal to BCD */
2741  version = ((version / 10) << 4) + (version % 10);
2742 
2743  /* check for any specified priority value in range [0-5] */
2744  if (cfg_get_integer(&priority, grp, octstr_imm("priority")) == -1)
2745  priority = SMPP_DEFAULT_PRIORITY;
2746  else if (priority < 0 || priority > 3)
2747  panic(0, "SMPP: Invalid value for priority directive in configuraton (allowed range 0-3).");
2748 
2749  /* check for message validity period */
2750  if (cfg_get_integer(&validity, grp, octstr_imm("validityperiod")) == -1)
2751  validity = SMS_PARAM_UNDEFINED;
2752  else if (validity < 0)
2753  panic(0, "SMPP: Invalid value for validity period (allowed value >= 0).");
2754 
2755  /* set the msg_id type variable for this SMSC */
2756  if (cfg_get_integer(&smpp_msg_id_type, grp, octstr_imm("msg-id-type")) == -1) {
2757  /*
2758  * defaults to C string "as-is" style
2759  */
2760  smpp_msg_id_type = -1;
2761  } else {
2762  if (smpp_msg_id_type < 0 || smpp_msg_id_type > 3)
2763  panic(0,"SMPP: Invalid value for msg-id-type directive in configuraton");
2764  }
2765 
2766  /* check for an alternative charset */
2767  alt_charset = cfg_get(grp, octstr_imm("alt-charset"));
2768  alt_addr_charset = cfg_get(grp, octstr_imm("alt-addr-charset"));
2769 
2770  /* check for connection timeout */
2771  if (cfg_get_integer(&connection_timeout, grp, octstr_imm("connection-timeout")) == -1)
2772  connection_timeout = SMPP_DEFAULT_CONNECTION_TIMEOUT;
2773 
2774  /* check if wait-ack timeout set */
2775  if (cfg_get_integer(&wait_ack, grp, octstr_imm("wait-ack")) == -1)
2776  wait_ack = SMPP_DEFAULT_WAITACK;
2777 
2778  if (cfg_get_integer(&wait_ack_action, grp, octstr_imm("wait-ack-expire")) == -1)
2779  wait_ack_action = SMPP_WAITACK_REQUEUE;
2780  else if (wait_ack_action > 0x03 || wait_ack_action < 0)
2781  panic(0, "SMPP: Invalid wait-ack-expire directive in configuration.");
2782 
2783  if (cfg_get_integer(&esm_class, grp, octstr_imm("esm-class")) == -1) {
2785  }
2786 
2787  smpp = smpp_create(conn, host, port, receive_port, our_port, our_receiver_port, system_type,
2788  username, password, address_range,
2789  source_addr_ton, source_addr_npi, dest_addr_ton,
2790  dest_addr_npi, enquire_link_interval,
2791  max_pending_submits, version, priority, validity, my_number,
2792  smpp_msg_id_type, autodetect_addr, alt_charset, alt_addr_charset,
2793  service_type, connection_timeout, wait_ack, wait_ack_action, esm_class);
2794 
2795  cfg_get_integer(&smpp->bind_addr_ton, grp, octstr_imm("bind-addr-ton"));
2796  cfg_get_integer(&smpp->bind_addr_npi, grp, octstr_imm("bind-addr-npi"));
2797 
2798  /* set connect retry, default false */
2799  if (cfg_get_bool(&smpp->retry, grp, octstr_imm("retry")) == -1)
2800  smpp->retry = 0;
2801 
2802  cfg_get_bool(&smpp->use_ssl, grp, octstr_imm("use-ssl"));
2803  if (smpp->use_ssl)
2804 #ifndef HAVE_LIBSSL
2805  panic(0, "SMPP: Can not use 'use-ssl' without SSL support compiled in.");
2806 #else
2807  smpp->ssl_client_certkey_file = cfg_get(grp, octstr_imm("ssl-client-certkey-file"));
2808 #endif
2809 
2810  conn->data = smpp;
2811  conn->name = octstr_format("%sSMPP:%S:%d/%d:%S:%S",
2812  (smpp->use_ssl ? "S" : ""), host, port,
2813  (!receive_port && transceiver_mode ? port : receive_port),
2814  username, system_type);
2815 
2816  smsc_id = cfg_get(grp, octstr_imm("smsc-id"));
2817  if (smsc_id == NULL) {
2818  conn->id = octstr_duplicate(conn->name);
2819  }
2820 
2821  if (cfg_get_integer(&smpp->log_format, grp, octstr_imm("log-format")) == -1)
2823 
2827  octstr_destroy(system_type);
2828  octstr_destroy(address_range);
2829  octstr_destroy(my_number);
2832  octstr_destroy(alt_addr_charset);
2833  octstr_destroy(service_type);
2834 
2835  conn->status = SMSCCONN_CONNECTING;
2836 
2837  /*
2838  * I/O threads are only started if the corresponding ports
2839  * have been configured with positive numbers. Use 0 to
2840  * disable the creation of the corresponding thread.
2841  */
2842  if (port != 0)
2844  (transceiver_mode ? 2 : 1)));
2845  if (receive_port != 0)
2846  smpp->receiver = gwthread_create(io_thread, io_arg_create(smpp, 0));
2847 
2848  if ((port != 0 && smpp->transmitter == -1) ||
2849  (receive_port != 0 && smpp->receiver == -1)) {
2850  error(0, "SMPP[%s]: Couldn't start I/O threads.",
2851  octstr_get_cstr(smpp->conn->id));
2852  smpp->quitting = 1;
2853  if (smpp->transmitter != -1) {
2855  gwthread_join(smpp->transmitter);
2856  }
2857  if (smpp->receiver != -1) {
2858  gwthread_wakeup(smpp->receiver);
2859  gwthread_join(smpp->receiver);
2860  }
2861  smpp_destroy(conn->data);
2862  conn->data = NULL;
2863  return -1;
2864  }
2865 
2866  conn->shutdown = shutdown_cb;
2867  conn->queued = queued_cb;
2868  conn->send_msg = send_msg_cb;
2869 
2870  return 0;
2871 }
Octstr * name
Definition: smscconn_p.h:173
void error(int err, const char *fmt,...)
Definition: log.c:648
static long our_port
Definition: radius_acct.c:87
static long queued_cb(SMSCConn *conn)
Definition: smsc_smpp.c:2537
Definition: http.c:2014
long bind_addr_npi
Definition: smsc_smpp.c:165
Octstr * id
Definition: smscconn_p.h:174
void gwthread_join(long thread)
void * data
Definition: smscconn_p.h:250
static struct io_arg * io_arg_create(SMPP *smpp, int transmitter)
Definition: smsc_smpp.c:2231
#define SMPP_ENQUIRE_LINK_INTERVAL
Definition: smsc_smpp.c:120
SMSCConn * conn
Definition: smsc_smpp.c:188
#define SMPP_DEFAULT_CONNECTION_TIMEOUT
Definition: smsc_smpp.c:125
static Octstr * host
Definition: fakesmsc.c:122
#define cfg_get(grp, varname)
Definition: cfg.h:86
long bind_addr_ton
Definition: smsc_smpp.c:164
#define octstr_get_cstr(ostr)
Definition: octstr.h:233
static void io_thread(void *arg)
Definition: smsc_smpp.c:2311
unsigned char * username
Definition: test_cimd2.c:99
int use_ssl
Definition: smsc_smpp.c:168
static int port
Definition: fakesmsc.c:121
static int shutdown_cb(SMSCConn *conn, int finish_sending)
Definition: smsc_smpp.c:2559
unsigned char * password
Definition: test_cimd2.c:100
Octstr * octstr_imm(const char *cstr)
Definition: octstr.c:283
long receiver
Definition: smsc_smpp.c:146
#define SMPP_DEFAULT_VERSION
Definition: smsc_smpp.c:122
static void smpp_destroy(SMPP *smpp)
Definition: smsc_smpp.c:295
static int send_msg_cb(SMSCConn *conn, Msg *msg)
Definition: smsc_smpp.c:2548
static SMPP * smpp_create(SMSCConn *conn, Octstr *host, int transmit_port, int receive_port, int our_port, int our_receiver_port, Octstr *system_type, Octstr *username, Octstr *password, Octstr *address_range, int source_addr_ton, int source_addr_npi, int dest_addr_ton, int dest_addr_npi, int enquire_link_interval, int max_pending_submits, int version, int priority, int validity, Octstr *my_number, int smpp_msg_id_type, int autodetect_addr, Octstr *alt_charset, Octstr *alt_addr_charset, Octstr *service_type, long connection_timeout, long wait_ack, int wait_ack_action, int esm_class)
Definition: smsc_smpp.c:229
#define ESM_CLASS_SUBMIT_STORE_AND_FORWARD_MODE
Definition: smpp_pdu.h:139
#define octstr_duplicate(ostr)
Definition: octstr.h:187
static Octstr * smsc_id
Definition: mtbatch.c:98
#define SMPP_DEFAULT_PORT
Definition: smsc_smpp.c:128
void warning(int err, const char *fmt,...)
Definition: log.c:660
#define SMPP_MAX_PENDING_SUBMITS
Definition: smsc_smpp.c:121
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 SMS_PARAM_UNDEFINED
Definition: sms.h:91
int retry
Definition: smsc_smpp.c:182
long log_format
Definition: smsc_smpp.c:186
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(* shutdown)(SMSCConn *conn, int finish_sending)
Definition: smscconn_p.h:230
int cfg_get_integer(long *n, CfgGroup *grp, Octstr *varname)
Definition: cfg.c:742
Definition: wtp_tid.h:82
#define SMPP_DEFAULT_WAITACK
Definition: smsc_smpp.c:126
#define panic
Definition: log.h:87
void gwthread_wakeup(long thread)
smscconn_status_t status
Definition: smscconn_p.h:151
long(* queued)(SMSCConn *conn)
Definition: smscconn_p.h:241
int(* send_msg)(SMSCConn *conn, Msg *msg)
Definition: smscconn_p.h:236
#define SMPP_DEFAULT_PRIORITY
Definition: smsc_smpp.c:123
#define SMPP_WAITACK_REQUEUE
Definition: smsc_smpp.c:135
static Octstr * alt_charset
Definition: opensmppbox.c:129
long transmitter
Definition: smsc_smpp.c:145
volatile int quitting
Definition: smsc_smpp.c:170
Octstr * ssl_client_certkey_file
Definition: smsc_smpp.c:169

◆ smsc_wrapper_create()

int smsc_wrapper_create ( SMSCConn conn,
CfgGroup cfg 
)

Definition at line 397 of file smsc_wrapper.c.

References cfg, smscconn::connect_time, smscconn::data, error(), gwlist_add_producer(), gwlist_create, gwthread_create, smscconn::is_stopped, mutex_create, smscconn::name, octstr_create, smsc_wrapper::outgoing_queue, smscconn::queued, smsc_wrapper::receiver_thread, smsc_wrapper::reconnect_mutex, smscconn::send_msg, smsc_wrapper::sender_thread, smscconn::shutdown, smsc_wrapper::smsc, smsc_name(), smsc_open(), SMSCCONN_ACTIVE, SMSCCONN_DEAD, SMSCCONN_KILLED_CANNOT_CONNECT, smscwrapper_destroy(), smscconn::start_conn, smscconn::status, smscconn::stop_conn, smsc_wrapper::stopped, smscconn::why_killed, wrapper_add_msg(), wrapper_queued(), wrapper_receiver(), wrapper_sender(), wrapper_shutdown(), wrapper_start(), and wrapper_stop().

Referenced by smscconn_create().

398 {
399  /* 1. Call smsc_open()
400  * 2. create sender/receiver threads
401  * 3. fill up the conn
402  *
403  * XXX open() SHOULD be done in distinct thread, not here!
404  */
405 
406  SmscWrapper *wrap;
407 
408  wrap = gw_malloc(sizeof(SmscWrapper));
409  wrap->smsc = NULL;
410  conn->data = wrap;
411  conn->send_msg = wrapper_add_msg;
412 
413 
414  wrap->outgoing_queue = gwlist_create();
415  wrap->stopped = gwlist_create();
416  wrap->reconnect_mutex = mutex_create();
418 
419  if ((wrap->smsc = smsc_open(cfg)) == NULL)
420  goto error;
421 
422  conn->name = octstr_create(smsc_name(wrap->smsc));
423  conn->status = SMSCCONN_ACTIVE;
424  conn->connect_time = time(NULL);
425 
426  if (conn->is_stopped)
428 
429 
430  /* XXX here we could fail things... specially if the second one
431  * fails.. so fix this ASAP
432  *
433  * moreover, open should be in sender/receiver, so that we can continue
434  * while trying to open... maybe move this, or just wait for new
435  * implementations of various SMSC protocols
436  */
437 
438  if ((wrap->receiver_thread = gwthread_create(wrapper_receiver, conn))==-1)
439  goto error;
440 
441  if ((wrap->sender_thread = gwthread_create(wrapper_sender, conn))==-1)
442  goto error;
443 
444  conn->shutdown = wrapper_shutdown;
445  conn->queued = wrapper_queued;
446  conn->stop_conn = wrapper_stop;
447  conn->start_conn = wrapper_start;
448 
449  return 0;
450 
451 error:
452  error(0, "Failed to create Smsc wrapper");
453  conn->data = NULL;
454  smscwrapper_destroy(wrap);
456  conn->status = SMSCCONN_DEAD;
457  return -1;
458 }
Octstr * name
Definition: smscconn_p.h:173
void error(int err, const char *fmt,...)
Definition: log.c:648
List * outgoing_queue
Definition: smsc_wrapper.c:76
List * stopped
Definition: smsc_wrapper.c:77
void * data
Definition: smscconn_p.h:250
#define mutex_create()
Definition: thread.h:96
char * smsc_name(SMSCenter *smsc)
Definition: smsc.c:643
void(* stop_conn)(SMSCConn *conn)
Definition: smscconn_p.h:247
static void wrapper_sender(void *arg)
Definition: smsc_wrapper.c:258
long receiver_thread
Definition: smsc_wrapper.c:78
static Cfg * cfg
Definition: opensmppbox.c:95
void(* start_conn)(SMSCConn *conn)
Definition: smscconn_p.h:246
static void wrapper_stop(SMSCConn *conn)
Definition: smsc_wrapper.c:368
Mutex * reconnect_mutex
Definition: smsc_wrapper.c:80
static int wrapper_add_msg(SMSCConn *conn, Msg *sms)
Definition: smsc_wrapper.c:337
SMSCenter * smsc
Definition: smsc_wrapper.c:75
smscconn_killed_t why_killed
Definition: smscconn_p.h:153
SMSCenter * smsc_open(CfgGroup *grp)
Definition: smsc.c:444
static void smscwrapper_destroy(SmscWrapper *wrap)
Definition: smsc_wrapper.c:84
time_t connect_time
Definition: smscconn_p.h:155
static void wrapper_start(SMSCConn *conn)
Definition: smsc_wrapper.c:377
#define gwthread_create(func, arg)
Definition: gwthread.h:90
#define octstr_create(cstr)
Definition: octstr.h:125
static int wrapper_shutdown(SMSCConn *conn, int finish_sending)
Definition: smsc_wrapper.c:349
volatile sig_atomic_t is_stopped
Definition: smscconn_p.h:169
static void wrapper_receiver(void *arg)
Definition: smsc_wrapper.c:191
int(* shutdown)(SMSCConn *conn, int finish_sending)
Definition: smscconn_p.h:230
smscconn_status_t status
Definition: smscconn_p.h:151
#define gwlist_create()
Definition: list.h:136
long(* queued)(SMSCConn *conn)
Definition: smscconn_p.h:241
int(* send_msg)(SMSCConn *conn, Msg *msg)
Definition: smscconn_p.h:236
long sender_thread
Definition: smsc_wrapper.c:79
void gwlist_add_producer(List *list)
Definition: list.c:383
static long wrapper_queued(SMSCConn *conn)
Definition: smsc_wrapper.c:386
See file LICENSE for details about the license agreement for using, modifying, copying or deriving work from this software.