Kannel: Open Source WAP and SMS gateway  svn-r5335
dlr.h File Reference

Go to the source code of this file.

Macros

#define DLR_UNDEFINED   -1
 
#define DLR_NOTHING   0x00
 
#define DLR_SUCCESS   0x01
 
#define DLR_FAIL   0x02
 
#define DLR_BUFFERED   0x04
 
#define DLR_SMSC_SUCCESS   0x08
 
#define DLR_SMSC_FAIL   0x10
 
#define DLR_EXPIRED   0x20|DLR_FAIL
 
#define DLR_UNKNOWN   0x40|DLR_FAIL
 
#define DLR_IS_DEFINED(dlr)   (dlr != DLR_UNDEFINED)
 
#define DLR_IS_ENABLED(dlr)   (DLR_IS_DEFINED(dlr) && (dlr & (DLR_SUCCESS | DLR_FAIL | DLR_BUFFERED | DLR_SMSC_SUCCESS | DLR_SMSC_FAIL | DLR_EXPIRED | DLR_UNKNOWN)))
 
#define DLR_IS_ENABLED_DEVICE(dlr)   (DLR_IS_DEFINED(dlr) && (dlr & (DLR_SUCCESS | DLR_FAIL | DLR_BUFFERED | DLR_EXPIRED | DLR_UNKNOWN)))
 
#define DLR_IS_ENABLED_SMSC(dlr)   (DLR_IS_DEFINED(dlr) && (dlr & (DLR_SMSC_SUCCESS | DLR_SMSC_FAIL)))
 
#define DLR_IS_NOT_FINAL(dlr)   (DLR_IS_DEFINED(dlr) && (dlr & (DLR_BUFFERED | DLR_SMSC_SUCCESS)))
 
#define DLR_IS_SUCCESS_OR_FAIL(dlr)   (DLR_IS_DEFINED(dlr) && (dlr & (DLR_SUCCESS | DLR_FAIL | DLR_EXPIRED | DLR_UNKNOWN)))
 
#define DLR_IS_SUCCESS(dlr)   (DLR_IS_DEFINED(dlr) && (dlr & DLR_SUCCESS))
 
#define DLR_IS_FAIL(dlr)   (DLR_IS_DEFINED(dlr) && (dlr & (DLR_FAIL|DLR_EXPIRED|DLR_UNKNOWN)))
 
#define DLR_IS_BUFFERED(dlr)   (DLR_IS_DEFINED(dlr) && (dlr & DLR_BUFFERED))
 
#define DLR_IS_SMSC_SUCCESS(dlr)   (DLR_IS_DEFINED(dlr) && (dlr & DLR_SMSC_SUCCESS))
 
#define DLR_IS_SMSC_FAIL(dlr)   (DLR_IS_DEFINED(dlr) && (dlr & DLR_SMSC_FAIL))
 

Functions

void dlr_init (Cfg *cfg)
 
void dlr_shutdown (void)
 
void dlr_add (const Octstr *smsc, const Octstr *ts, Msg *msg, int use_dst)
 
Msgdlr_find (const Octstr *smsc, const Octstr *ts, const Octstr *dst, int type, int use_dst)
 
long dlr_messages (void)
 
void dlr_flush (void)
 
const char * dlr_type (void)
 
Msgcreate_dlr_from_msg (const Octstr *smsc, const Msg *msg, const Octstr *reply, long stat)
 
void dlr_save (const char *filename)
 
void dlr_load (const char *filename)
 

Macro Definition Documentation

◆ DLR_BUFFERED

◆ DLR_EXPIRED

#define DLR_EXPIRED   0x20|DLR_FAIL

◆ DLR_FAIL

◆ DLR_IS_BUFFERED

#define DLR_IS_BUFFERED (   dlr)    (DLR_IS_DEFINED(dlr) && (dlr & DLR_BUFFERED))

Definition at line 88 of file dlr.h.

Referenced by msg_to_emimsg(), and msg_to_pdu().

◆ DLR_IS_DEFINED

#define DLR_IS_DEFINED (   dlr)    (dlr != DLR_UNDEFINED)

Definition at line 80 of file dlr.h.

◆ DLR_IS_ENABLED

#define DLR_IS_ENABLED (   dlr)    (DLR_IS_DEFINED(dlr) && (dlr & (DLR_SUCCESS | DLR_FAIL | DLR_BUFFERED | DLR_SMSC_SUCCESS | DLR_SMSC_FAIL | DLR_EXPIRED | DLR_UNKNOWN)))

Definition at line 81 of file dlr.h.

Referenced by create_dlr_from_msg(), dlr_add(), handle_pdu(), main(), send_message(), and sms_split().

◆ DLR_IS_ENABLED_DEVICE

◆ DLR_IS_ENABLED_SMSC

#define DLR_IS_ENABLED_SMSC (   dlr)    (DLR_IS_DEFINED(dlr) && (dlr & (DLR_SMSC_SUCCESS | DLR_SMSC_FAIL)))

Definition at line 83 of file dlr.h.

Referenced by soap_o2o_dlrmask_smsc_yn_attribute().

◆ DLR_IS_FAIL

#define DLR_IS_FAIL (   dlr)    (DLR_IS_DEFINED(dlr) && (dlr & (DLR_FAIL|DLR_EXPIRED|DLR_UNKNOWN)))

Definition at line 87 of file dlr.h.

Referenced by bb_smscconn_send_failed(), and msg_to_pdu().

◆ DLR_IS_NOT_FINAL

#define DLR_IS_NOT_FINAL (   dlr)    (DLR_IS_DEFINED(dlr) && (dlr & (DLR_BUFFERED | DLR_SMSC_SUCCESS)))

Definition at line 84 of file dlr.h.

Referenced by dlr_find().

◆ DLR_IS_SMSC_FAIL

#define DLR_IS_SMSC_FAIL (   dlr)    (DLR_IS_DEFINED(dlr) && (dlr & DLR_SMSC_FAIL))

Definition at line 90 of file dlr.h.

Referenced by bb_smscconn_send_failed().

◆ DLR_IS_SMSC_SUCCESS

#define DLR_IS_SMSC_SUCCESS (   dlr)    (DLR_IS_DEFINED(dlr) && (dlr & DLR_SMSC_SUCCESS))

Definition at line 89 of file dlr.h.

Referenced by bb_smscconn_sent().

◆ DLR_IS_SUCCESS

#define DLR_IS_SUCCESS (   dlr)    (DLR_IS_DEFINED(dlr) && (dlr & DLR_SUCCESS))

Definition at line 86 of file dlr.h.

Referenced by msg_to_pdu(), and soap_o2o_dlrmask_success_01_attribute().

◆ DLR_IS_SUCCESS_OR_FAIL

#define DLR_IS_SUCCESS_OR_FAIL (   dlr)    (DLR_IS_DEFINED(dlr) && (dlr & (DLR_SUCCESS | DLR_FAIL | DLR_EXPIRED | DLR_UNKNOWN)))

◆ DLR_NOTHING

#define DLR_NOTHING   0x00

Definition at line 71 of file dlr.h.

Referenced by kannel_send_sms(), and msg_to_pdu().

◆ DLR_SMSC_FAIL

#define DLR_SMSC_FAIL   0x10

Definition at line 76 of file dlr.h.

Referenced by bb_smscconn_send_failed(), msg_to_pdu(), and pdu_to_msg().

◆ DLR_SMSC_SUCCESS

#define DLR_SMSC_SUCCESS   0x08

Definition at line 75 of file dlr.h.

Referenced by bb_smscconn_sent(), and msg_to_pdu().

◆ DLR_SUCCESS

◆ DLR_UNDEFINED

#define DLR_UNDEFINED   -1

Definition at line 70 of file dlr.h.

Referenced by create_onetrans(), generic_receive_sms(), kannel_send_sms(), and msg_to_pdu().

◆ DLR_UNKNOWN

#define DLR_UNKNOWN   0x40|DLR_FAIL

Definition at line 78 of file dlr.h.

Referenced by clickatell_receive_sms().

Function Documentation

◆ create_dlr_from_msg()

Msg* create_dlr_from_msg ( const Octstr smsc,
const Msg msg,
const Octstr reply,
long  stat 
)

Definition at line 501 of file dlr.c.

References debug(), DLR_IS_ENABLED, dlr_mask, gw_assert(), meta_data_set_value(), METADATA_ORIG_MSG_GROUP, METADATA_ORIG_MSG_GROUP_DLR_MASK, msg, msg_create, octstr_create, octstr_destroy(), octstr_duplicate, octstr_format(), octstr_get_cstr, octstr_imm(), reply(), report_mo, and dlr_entry::smsc.

Referenced by bb_smscconn_send_failed(), and bb_smscconn_sent().

502 {
503  Msg *dlrmsg;
504 
505  if (msg == NULL)
506  return NULL;
507 
508  /* generate DLR */
509  debug("dlr.dlr", 0,"SMSC[%s]: creating DLR message",
510  (smsc ? octstr_get_cstr(smsc) : "UNKNOWN"));
511 
512  dlrmsg = msg_create(sms);
513  gw_assert(dlrmsg != NULL);
514 
515  dlrmsg->sms.service = octstr_duplicate(msg->sms.service);
516  dlrmsg->sms.dlr_mask = stat;
517  dlrmsg->sms.sms_type = report_mo;
518  dlrmsg->sms.smsc_id = octstr_duplicate(smsc ? smsc : msg->sms.smsc_id);
519  dlrmsg->sms.sender = octstr_duplicate(msg->sms.sender);
520  dlrmsg->sms.receiver = octstr_duplicate(msg->sms.receiver);
521  dlrmsg->sms.dlr_url = octstr_duplicate(msg->sms.dlr_url);
522  dlrmsg->sms.msgdata = octstr_duplicate(reply);
523  dlrmsg->sms.boxc_id = octstr_duplicate(msg->sms.boxc_id);
524  dlrmsg->sms.foreign_id = octstr_duplicate(msg->sms.foreign_id);
525  time(&dlrmsg->sms.time);
526  dlrmsg->sms.meta_data = octstr_duplicate(msg->sms.meta_data);
527 
528  /* add original DLR bit-mask, as we do in dlr_find() */
529  if (DLR_IS_ENABLED(msg->sms.dlr_mask)) {
530  Octstr *dlr_mask = octstr_format("%ld", msg->sms.dlr_mask);
531  if (dlrmsg->sms.meta_data == NULL)
532  dlrmsg->sms.meta_data = octstr_create("");
533  meta_data_set_value(dlrmsg->sms.meta_data, METADATA_ORIG_MSG_GROUP,
536  }
537 
538  debug("dlr.dlr", 0,"SMSC[%s]: DLR = %s",
539  (smsc ? octstr_get_cstr(smsc) : "UNKNOWN"),
540  (dlrmsg->sms.dlr_url ? octstr_get_cstr(dlrmsg->sms.dlr_url) : ""));
541 
542  return dlrmsg;
543 }
static Octstr * dlr_mask
Definition: test_ppg.c:106
#define METADATA_ORIG_MSG_GROUP_DLR_MASK
Definition: meta_data.h:74
gw_assert(wtls_machine->packet_to_send !=NULL)
Definition: msg.h:109
int meta_data_set_value(Octstr *data, const char *group, const Octstr *key, const Octstr *value, int replace)
Definition: meta_data.c:324
#define msg_create(type)
Definition: msg.h:136
#define octstr_get_cstr(ostr)
Definition: octstr.h:233
Octstr * octstr_imm(const char *cstr)
Definition: octstr.c:283
Definition: msg.h:79
#define octstr_duplicate(ostr)
Definition: octstr.h:187
#define METADATA_ORIG_MSG_GROUP
Definition: meta_data.h:73
Octstr * octstr_format(const char *fmt,...)
Definition: octstr.c:2464
void octstr_destroy(Octstr *ostr)
Definition: octstr.c:324
#define octstr_create(cstr)
Definition: octstr.h:125
Definition: octstr.c:118
void debug(const char *place, int err, const char *fmt,...)
Definition: log.c:726
Octstr * smsc
Definition: dlr_p.h:79
#define DLR_IS_ENABLED(dlr)
Definition: dlr.h:81
static XMLRPCDocument * msg
Definition: test_xmlrpc.c:86
static void reply(HTTPClient *c, List *push_headers)

◆ dlr_add()

void dlr_add ( const Octstr smsc,
const Octstr ts,
Msg msg,
int  use_dst 
)

Definition at line 330 of file dlr.c.

References dlr_entry::boxc_id, debug(), dlr_entry::destination, dlr_storage::dlr_add, dlr_entry_create(), DLR_IS_ENABLED, dlr_type(), gw_assert(), handles, dlr_entry::mask, msg, octstr_create, octstr_destroy(), octstr_duplicate, octstr_get_cstr, octstr_len(), dlr_entry::service, dlr_entry::smsc, dlr_entry::source, split, dlr_entry::timestamp, dlr_entry::url, dlr_entry::use_dst, and warning().

Referenced by add_msg_cb(), at2_send_one_message(), cgw_handle_op(), cimd2_submit_msg(), clickatell_parse_reply(), emi2_handle_smscreq(), generic_parse_reply(), handle_pdu(), kannel_parse_reply(), msg_cb(), oisd_submit_msg(), soap_read_response(), and xidris_parse_reply().

331 {
332  struct dlr_entry *dlr = NULL;
333 
334  /* Add the foreign_id so all SMSC modules can use it.
335  * Obey also the original message in the split_parts list. */
336  if (msg->sms.foreign_id != NULL)
337  octstr_destroy(msg->sms.foreign_id);
338  msg->sms.foreign_id = octstr_duplicate(ts);
339  if (msg->sms.split_parts != NULL) {
340  struct split_parts *split = msg->sms.split_parts;
341  if (split->orig->sms.foreign_id != NULL)
342  octstr_destroy(split->orig->sms.foreign_id);
343  split->orig->sms.foreign_id = octstr_duplicate(ts);
344  }
345 
346  if (octstr_len(smsc) == 0) {
347  warning(0, "DLR[%s]: Can't add a dlr without smsc-id", dlr_type());
348  return;
349  }
350 
351  /* sanity check */
352  if (handles == NULL || handles->dlr_add == NULL || msg == NULL)
353  return;
354 
355  /* check if delivery receipt requested */
356  if (!DLR_IS_ENABLED(msg->sms.dlr_mask))
357  return;
358 
359  /* allocate new struct dlr_entry struct */
360  dlr = dlr_entry_create();
361  gw_assert(dlr != NULL);
362 
363  /* now copy all values, we are interested in */
364  dlr->smsc = (smsc ? octstr_duplicate(smsc) : octstr_create(""));
365  dlr->timestamp = (ts ? octstr_duplicate(ts) : octstr_create(""));
366  dlr->source = (msg->sms.sender ? octstr_duplicate(msg->sms.sender) : octstr_create(""));
367  dlr->destination = (msg->sms.receiver ? octstr_duplicate(msg->sms.receiver) : octstr_create(""));
368  dlr->service = (msg->sms.service ? octstr_duplicate(msg->sms.service) : octstr_create(""));
369  dlr->url = (msg->sms.dlr_url ? octstr_duplicate(msg->sms.dlr_url) : octstr_create(""));
370  dlr->boxc_id = (msg->sms.boxc_id ? octstr_duplicate(msg->sms.boxc_id) : octstr_create(""));
371  dlr->mask = msg->sms.dlr_mask;
372  dlr->use_dst = use_dst;
373 
374  debug("dlr.dlr", 0, "DLR[%s]: Adding DLR smsc=%s, ts=%s, src=%s, dst=%s, mask=%d, boxc=%s",
377 
378  /* call registered function */
379  handles->dlr_add(dlr);
380 }
Octstr * url
Definition: dlr_p.h:84
gw_assert(wtls_machine->packet_to_send !=NULL)
Octstr * service
Definition: dlr_p.h:83
struct dlr_entry * dlr_entry_create(void)
Definition: dlr.c:103
Octstr * boxc_id
Definition: dlr_p.h:85
void(* dlr_add)(struct dlr_entry *entry)
Definition: dlr_p.h:117
#define octstr_get_cstr(ostr)
Definition: octstr.h:233
static struct dlr_storage * handles
Definition: dlr.c:97
Octstr * source
Definition: dlr_p.h:81
const char * dlr_type(void)
Definition: dlr.c:319
#define octstr_duplicate(ostr)
Definition: octstr.h:187
void warning(int err, const char *fmt,...)
Definition: log.c:660
Octstr * timestamp
Definition: dlr_p.h:80
void octstr_destroy(Octstr *ostr)
Definition: octstr.c:324
#define octstr_create(cstr)
Definition: octstr.h:125
long octstr_len(const Octstr *ostr)
Definition: octstr.c:342
Octstr * destination
Definition: dlr_p.h:82
void debug(const char *place, int err, const char *fmt,...)
Definition: log.c:726
static List * split
Definition: test_http.c:88
Definition: dlr_p.h:78
Octstr * smsc
Definition: dlr_p.h:79
int mask
Definition: dlr_p.h:86
#define DLR_IS_ENABLED(dlr)
Definition: dlr.h:81
static XMLRPCDocument * msg
Definition: test_xmlrpc.c:86
int use_dst
Definition: dlr_p.h:87

◆ dlr_find()

Msg* dlr_find ( const Octstr smsc,
const Octstr ts,
const Octstr dst,
int  type,
int  use_dst 
)

Definition at line 387 of file dlr.c.

References dlr_entry::boxc_id, debug(), dlr_entry::destination, dlr_entry_destroy(), dlr_storage::dlr_get, DLR_IS_NOT_FINAL, DLR_IS_SUCCESS_OR_FAIL, dlr_mask, dlr_storage::dlr_remove, dlr_type(), dlr_storage::dlr_update, handles, dlr_entry::mask, meta_data_set_value(), METADATA_ORIG_MSG_GROUP, METADATA_ORIG_MSG_GROUP_DLR_MASK, MIN_DST_LEN, msg, msg_create, O_SET, octstr_create, octstr_delete(), octstr_destroy(), octstr_duplicate, octstr_format(), octstr_get_cstr, octstr_imm(), octstr_len(), report_mo, dlr_entry::service, dlr_entry::smsc, dlr_entry::source, dlr_entry::url, dlr_entry::use_dst, and warning().

Referenced by at2_pdu_decode_report_sm(), cgw_handle_op(), cimd2_accept_delivery_report_message(), clickatell_receive_sms(), generic_receive_sms(), handle_dlr(), handle_operation(), kannel_receive_sms(), main_connection_loop(), msg_to_pdu(), oisd_accept_delivery_report_message(), soap_parse_dlr(), and xidris_receive_sms().

388 {
389  Msg *msg = NULL;
390  struct dlr_entry *dlr = NULL;
391  Octstr *dst_min = NULL;
392  Octstr *dlr_mask;
393 
394  if(octstr_len(smsc) == 0) {
395  warning(0, "DLR[%s]: Can't find a dlr without smsc-id", dlr_type());
396  return NULL;
397  }
398 
399  /* check if we have handler registered */
400  if (handles == NULL || handles->dlr_get == NULL)
401  return NULL;
402 
403  if (use_dst && dst) {
404  dst_min = octstr_duplicate(dst);
405  int len = octstr_len(dst);
406 
407  if (len > MIN_DST_LEN)
408  octstr_delete(dst_min, 0, len - MIN_DST_LEN);
409  }
410  debug("dlr.dlr", 0, "DLR[%s]: Looking for DLR smsc=%s, ts=%s, dst=%s, type=%d",
412 
413  dlr = handles->dlr_get(smsc, ts, dst_min);
414  if (dlr == NULL) {
415  warning(0, "DLR[%s]: DLR from SMSC<%s> for DST<%s> not found.",
417  return NULL;
418  }
419 
420 #define O_SET(x, val) if (octstr_len(val) > 0) { x = val; val = NULL; }
421 
422  if ((typ & dlr->mask) > 0) {
423  /* its an entry we are interested in */
424  msg = msg_create(sms);
425  msg->sms.sms_type = report_mo;
426  msg->sms.dlr_mask = typ;
427  O_SET(msg->sms.service, dlr->service);
428  O_SET(msg->sms.smsc_id, dlr->smsc);
429  O_SET(msg->sms.receiver, dlr->destination);
430  O_SET(msg->sms.sender, dlr->source);
431  /* if dlr_url was present, recode it here again */
432  O_SET(msg->sms.dlr_url, dlr->url);
433  /* add the foreign_id */
434  msg->sms.foreign_id = octstr_duplicate(ts);
435  /*
436  * insert original message to the data segment
437  * later in the smsc module
438  */
439  msg->sms.msgdata = NULL;
440  /*
441  * If a boxc_id is available, then instruct bearerbox to
442  * route this msg back to originating smsbox
443  */
444  O_SET(msg->sms.boxc_id, dlr->boxc_id);
445  /*
446  * We will provide the DLR request bitmask in the DLR going back
447  * to the smsbox connection for processing. This allows smsbox
448  * connection type applications to avoid temporary storing and
449  * resolving data to pull up this information.
450  */
451  dlr_mask = octstr_format("%ld", dlr->mask);
452  msg->sms.meta_data = octstr_create("");
456 
457  time(&msg->sms.time);
458  debug("dlr.dlr", 0, "DLR[%s]: created DLR message for URL <%s>",
459  dlr_type(), (msg->sms.dlr_url?octstr_get_cstr(msg->sms.dlr_url):""));
460  } else {
461  debug("dlr.dlr", 0, "DLR[%s]: Ignoring DLR message because of mask type=%d dlr->mask=%d", dlr_type(), typ, dlr->mask);
462  /* ok that was a status report but we where not interested in having it */
463  msg = NULL;
464  }
465 
466 #undef O_SET
467 
468  /* check for end status and if so remove from storage */
469  if (DLR_IS_NOT_FINAL(typ) && DLR_IS_SUCCESS_OR_FAIL(dlr->mask)) {
470  debug("dlr.dlr", 0, "DLR[%s]: DLR not destroyed, still waiting for other delivery report", dlr_type());
471  /* update dlr entry status if function defined */
472  if (handles != NULL && handles->dlr_update != NULL){
473  handles->dlr_update(smsc, ts, dst_min, typ);
474  }
475  } else {
476  if (handles != NULL && handles->dlr_remove != NULL){
477  /* it's not good for internal storage, but better for all others */
478  handles->dlr_remove(smsc, ts, dst_min);
479  } else {
480  warning(0, "DLR[%s]: Storage don't have remove operation defined", dlr_type());
481  }
482  }
483 
484  /* destroy struct dlr_entry */
485  dlr_entry_destroy(dlr);
486  octstr_destroy(dst_min);
487 
488  return msg;
489 }
static Octstr * dlr_mask
Definition: test_ppg.c:106
#define METADATA_ORIG_MSG_GROUP_DLR_MASK
Definition: meta_data.h:74
Octstr * url
Definition: dlr_p.h:84
void(* dlr_update)(const Octstr *smsc, const Octstr *ts, const Octstr *dst, int status)
Definition: dlr_p.h:130
Octstr * service
Definition: dlr_p.h:83
Definition: msg.h:109
Octstr * boxc_id
Definition: dlr_p.h:85
int meta_data_set_value(Octstr *data, const char *group, const Octstr *key, const Octstr *value, int replace)
Definition: meta_data.c:324
#define MIN_DST_LEN
Definition: dlr_p.h:74
#define msg_create(type)
Definition: msg.h:136
#define octstr_get_cstr(ostr)
Definition: octstr.h:233
#define DLR_IS_NOT_FINAL(dlr)
Definition: dlr.h:84
static struct dlr_storage * handles
Definition: dlr.c:97
Octstr * octstr_imm(const char *cstr)
Definition: octstr.c:283
Definition: msg.h:79
void octstr_delete(Octstr *ostr1, long pos, long len)
Definition: octstr.c:1527
Octstr * source
Definition: dlr_p.h:81
struct dlr_entry *(* dlr_get)(const Octstr *smsc, const Octstr *ts, const Octstr *dst)
Definition: dlr_p.h:122
const char * dlr_type(void)
Definition: dlr.c:319
#define octstr_duplicate(ostr)
Definition: octstr.h:187
#define METADATA_ORIG_MSG_GROUP
Definition: meta_data.h:73
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 octstr_create(cstr)
Definition: octstr.h:125
long octstr_len(const Octstr *ostr)
Definition: octstr.c:342
Octstr * destination
Definition: dlr_p.h:82
Definition: octstr.c:118
void dlr_entry_destroy(struct dlr_entry *dlr)
Definition: dlr.c:142
void debug(const char *place, int err, const char *fmt,...)
Definition: log.c:726
#define O_SET(x, val)
Definition: dlr_p.h:78
Octstr * smsc
Definition: dlr_p.h:79
int mask
Definition: dlr_p.h:86
void(* dlr_remove)(const Octstr *smsc, const Octstr *ts, const Octstr *dst)
Definition: dlr_p.h:126
#define DLR_IS_SUCCESS_OR_FAIL(dlr)
Definition: dlr.h:85
static XMLRPCDocument * msg
Definition: test_xmlrpc.c:86
int use_dst
Definition: dlr_p.h:87

◆ dlr_flush()

void dlr_flush ( void  )

Definition at line 491 of file dlr.c.

References dlr_storage::dlr_flush, dlr_messages(), dlr_type(), handles, and info().

Referenced by bb_flush_dlr().

492 {
493  info(0, "Flushing all %ld queued DLR messages in %s storage", dlr_messages(),
494  dlr_type());
495 
496  if (handles != NULL && handles->dlr_flush != NULL)
497  handles->dlr_flush();
498 }
void info(int err, const char *fmt,...)
Definition: log.c:672
static struct dlr_storage * handles
Definition: dlr.c:97
void(* dlr_flush)(void)
Definition: dlr_p.h:138
const char * dlr_type(void)
Definition: dlr.c:319
long dlr_messages(void)
Definition: dlr.c:308

◆ dlr_init()

void dlr_init ( Cfg cfg)

Definition at line 233 of file dlr.c.

References cfg, cfg_get, cfg_get_single_group(), dlr_storage::dlr_add, dlr_storage::dlr_get, dlr_init_cass(), dlr_init_mem(), dlr_init_mssql(), dlr_init_mysql(), dlr_init_oracle(), dlr_init_pgsql(), dlr_init_redis(), dlr_init_sdb(), dlr_init_spool(), dlr_init_sqlite3(), dlr_storage::dlr_remove, dlr_type(), handles, info(), octstr_compare(), octstr_destroy(), octstr_get_cstr, octstr_imm(), panic, dlr_storage::type, and warning().

Referenced by init_smppbox(), and main().

234 {
235  CfgGroup *grp;
236  Octstr *dlr_type;
237 
238  /* check which DLR storage type we are using */
239  grp = cfg_get_single_group(cfg, octstr_imm("core"));
240  if(grp == NULL)
241  panic(0, "DLR: can't find group core");
242 
243  dlr_type = cfg_get(grp, octstr_imm("dlr-storage"));
244 
245  /*
246  * assume we are using internal memory in case no directive
247  * has been specified, warn the user anyway
248  */
249  if (dlr_type == NULL) {
250  dlr_type = octstr_imm("internal");
251  warning(0, "DLR: using default 'internal' for storage type.");
252  }
253 
254  /* call the sub-init routine */
255  if (octstr_compare(dlr_type, octstr_imm("spool")) == 0) {
257  } else if (octstr_compare(dlr_type, octstr_imm("mysql")) == 0) {
259  } else if (octstr_compare(dlr_type, octstr_imm("sdb")) == 0) {
261  } else if (octstr_compare(dlr_type, octstr_imm("oracle")) == 0) {
263  } else if (octstr_compare(dlr_type, octstr_imm("internal")) == 0) {
265  } else if (octstr_compare(dlr_type, octstr_imm("pgsql")) == 0) {
267  } else if (octstr_compare(dlr_type, octstr_imm("mssql")) == 0) {
269  } else if (octstr_compare(dlr_type, octstr_imm("sqlite3")) == 0) {
271  } else if (octstr_compare(dlr_type, octstr_imm("redis")) == 0) {
273  } else if (octstr_compare(dlr_type, octstr_imm("cassandra")) == 0) {
275  }
276 
277  /*
278  * add aditional types here
279  */
280 
281  if (handles == NULL) {
282  panic(0, "DLR: storage type '%s' is not supported!", octstr_get_cstr(dlr_type));
283  }
284 
285  /* check needed function pointers */
286  if (handles->dlr_add == NULL || handles->dlr_get == NULL || handles->dlr_remove == NULL)
287  panic(0, "DLR: storage type '%s' don't implement needed functions", octstr_get_cstr(dlr_type));
288 
289  /* get info from storage */
290  info(0, "DLR using storage type: %s", handles->type);
291 
292  /* cleanup */
294 }
const char * type
Definition: dlr_p.h:112
void info(int err, const char *fmt,...)
Definition: log.c:672
struct dlr_storage * dlr_init_sdb(Cfg *cfg)
Definition: dlr_sdb.c:477
#define cfg_get(grp, varname)
Definition: cfg.h:86
struct dlr_storage * dlr_init_mem(Cfg *cfg)
Definition: dlr_mem.c:206
static Cfg * cfg
Definition: opensmppbox.c:95
void(* dlr_add)(struct dlr_entry *entry)
Definition: dlr_p.h:117
#define octstr_get_cstr(ostr)
Definition: octstr.h:233
struct dlr_storage * dlr_init_oracle(Cfg *cfg)
Definition: dlr_oracle.c:428
struct dlr_storage * dlr_init_pgsql(Cfg *cfg)
Definition: dlr_pgsql.c:420
static struct dlr_storage * handles
Definition: dlr.c:97
Octstr * octstr_imm(const char *cstr)
Definition: octstr.c:283
struct dlr_entry *(* dlr_get)(const Octstr *smsc, const Octstr *ts, const Octstr *dst)
Definition: dlr_p.h:122
const char * dlr_type(void)
Definition: dlr.c:319
struct dlr_storage * dlr_init_sqlite3(Cfg *cfg)
Definition: dlr_sqlite3.c:421
void warning(int err, const char *fmt,...)
Definition: log.c:660
void octstr_destroy(Octstr *ostr)
Definition: octstr.c:324
struct dlr_storage * dlr_init_spool(Cfg *cfg)
Definition: dlr_spool.c:602
struct dlr_storage * dlr_init_redis(Cfg *cfg)
Definition: dlr_redis.c:576
struct dlr_storage * dlr_init_mysql(Cfg *cfg)
Definition: dlr_mysql.c:470
struct dlr_storage * dlr_init_mssql(Cfg *cfg)
Definition: dlr_mssql.c:394
Definition: octstr.c:118
struct dlr_storage * dlr_init_cass(Cfg *cfg)
Definition: dlr_cass.c:427
#define panic
Definition: log.h:87
Definition: cfg.c:73
CfgGroup * cfg_get_single_group(Cfg *cfg, Octstr *name)
Definition: cfg.c:639
void(* dlr_remove)(const Octstr *smsc, const Octstr *ts, const Octstr *dst)
Definition: dlr_p.h:126
int octstr_compare(const Octstr *ostr1, const Octstr *ostr2)
Definition: octstr.c:871

◆ dlr_load()

void dlr_load ( const char *  filename)

◆ dlr_messages()

long dlr_messages ( void  )

Definition at line 308 of file dlr.c.

References dlr_storage::dlr_messages, and handles.

Referenced by bb_print_status(), and dlr_flush().

309 {
310  if (handles != NULL && handles->dlr_messages != NULL)
311  return handles->dlr_messages();
312 
313  return -1;
314 }
long(* dlr_messages)(void)
Definition: dlr_p.h:134
static struct dlr_storage * handles
Definition: dlr.c:97

◆ dlr_save()

void dlr_save ( const char *  filename)

◆ dlr_shutdown()

void dlr_shutdown ( void  )

Definition at line 299 of file dlr.c.

References dlr_storage::dlr_shutdown, and handles.

Referenced by main().

300 {
301  if (handles != NULL && handles->dlr_shutdown != NULL)
303 }
static struct dlr_storage * handles
Definition: dlr.c:97
void(* dlr_shutdown)(void)
Definition: dlr_p.h:142

◆ dlr_type()

const char* dlr_type ( void  )

Definition at line 319 of file dlr.c.

References handles, and dlr_storage::type.

Referenced by bb_print_status(), dlr_add(), dlr_find(), dlr_flush(), and dlr_init().

320 {
321  if (handles != NULL && handles->type != NULL)
322  return handles->type;
323 
324  return "unknown";
325 }
const char * type
Definition: dlr_p.h:112
static struct dlr_storage * handles
Definition: dlr.c:97
See file LICENSE for details about the license agreement for using, modifying, copying or deriving work from this software.