Kannel: Open Source WAP and SMS gateway  $Revision: 5037 $
urltrans.h File Reference
#include "gwlib/gwlib.h"
#include "msg.h"
#include "numhash.h"
#include "gwlib/regex.h"

Go to the source code of this file.

Typedefs

typedef struct URLTranslationList URLTranslationList
 
typedef struct URLTranslation URLTranslation
 

Enumerations

enum  {
  TRANSTYPE_GET_URL = 0, TRANSTYPE_POST_URL, TRANSTYPE_POST_XML, TRANSTYPE_TEXT,
  TRANSTYPE_FILE, TRANSTYPE_EXECUTE, TRANSTYPE_SENDSMS
}
 

Functions

URLTranslationListurltrans_create (void)
 
void urltrans_destroy (URLTranslationList *list)
 
int urltrans_add_one (URLTranslationList *trans, CfgGroup *grp)
 
int urltrans_add_cfg (URLTranslationList *trans, Cfg *cfg)
 
URLTranslationurltrans_find (URLTranslationList *trans, Msg *msg)
 
URLTranslationurltrans_find_service (URLTranslationList *trans, Msg *msg)
 
URLTranslationurltrans_find_username (URLTranslationList *trans, Octstr *name)
 
Octstrurltrans_fill_escape_codes (Octstr *pattern, Msg *request)
 
Octstrurltrans_get_pattern (URLTranslation *t, Msg *sms)
 
int urltrans_type (URLTranslation *t)
 
Octstrurltrans_prefix (URLTranslation *t)
 
Octstrurltrans_suffix (URLTranslation *t)
 
Octstrurltrans_default_sender (URLTranslation *t)
 
Octstrurltrans_faked_sender (URLTranslation *t)
 
int urltrans_max_messages (URLTranslation *t)
 
int urltrans_concatenation (URLTranslation *t)
 
Octstrurltrans_split_chars (URLTranslation *t)
 
Octstrurltrans_split_suffix (URLTranslation *t)
 
int urltrans_omit_empty (URLTranslation *t)
 
Octstrurltrans_header (URLTranslation *t)
 
Octstrurltrans_footer (URLTranslation *t)
 
Octstrurltrans_alt_charset (URLTranslation *t)
 
Octstrurltrans_name (URLTranslation *t)
 
Octstrurltrans_username (URLTranslation *t)
 
Octstrurltrans_password (URLTranslation *t)
 
Octstrurltrans_forced_smsc (URLTranslation *t)
 
Octstrurltrans_default_smsc (URLTranslation *t)
 
Octstrurltrans_allow_ip (URLTranslation *t)
 
Octstrurltrans_deny_ip (URLTranslation *t)
 
Octstrurltrans_allowed_prefix (URLTranslation *t)
 
Octstrurltrans_denied_prefix (URLTranslation *t)
 
Octstrurltrans_allowed_recv_prefix (URLTranslation *t)
 
Octstrurltrans_denied_recv_prefix (URLTranslation *t)
 
Numhashurltrans_white_list (URLTranslation *t)
 
Numhashurltrans_black_list (URLTranslation *t)
 
regex_t * urltrans_white_list_regex (URLTranslation *t)
 
regex_t * urltrans_black_list_regex (URLTranslation *t)
 
int urltrans_assume_plain_text (URLTranslation *t)
 
int urltrans_accept_x_kannel_headers (URLTranslation *t)
 
int urltrans_strip_keyword (URLTranslation *t)
 
int urltrans_send_sender (URLTranslation *t)
 
Octstrurltrans_dlr_url (URLTranslation *t)
 
int urltrans_dlr_mask (URLTranslation *t)
 

Typedef Documentation

Definition at line 100 of file urltrans.h.

Definition at line 93 of file urltrans.h.

Enumeration Type Documentation

anonymous enum
Enumerator
TRANSTYPE_GET_URL 
TRANSTYPE_POST_URL 
TRANSTYPE_POST_XML 
TRANSTYPE_TEXT 
TRANSTYPE_FILE 
TRANSTYPE_EXECUTE 
TRANSTYPE_SENDSMS 

Definition at line 102 of file urltrans.h.

Function Documentation

int urltrans_accept_x_kannel_headers ( URLTranslation t)

Definition at line 912 of file urltrans.c.

References URLTranslation::accept_x_kannel_headers.

Referenced by fill_message().

913 {
914  return t->accept_x_kannel_headers;
915 }
int accept_x_kannel_headers
Definition: urltrans.c:124
int urltrans_add_cfg ( URLTranslationList trans,
Cfg cfg 
)

Definition at line 228 of file urltrans.c.

References cfg_get_multi_group(), gwlist_destroy(), gwlist_extract_first(), octstr_imm(), and urltrans_add_one().

Referenced by main().

229 {
230  CfgGroup *grp;
231  List *list;
232 
233  list = cfg_get_multi_group(cfg, octstr_imm("sms-service"));
234  while (list && (grp = gwlist_extract_first(list)) != NULL) {
235  if (urltrans_add_one(trans, grp) == -1) {
236  gwlist_destroy(list, NULL);
237  return -1;
238  }
239  }
240  gwlist_destroy(list, NULL);
241 
242  list = cfg_get_multi_group(cfg, octstr_imm("sendsms-user"));
243  while (list && (grp = gwlist_extract_first(list)) != NULL) {
244  if (urltrans_add_one(trans, grp) == -1) {
245  gwlist_destroy(list, NULL);
246  return -1;
247  }
248  }
249  gwlist_destroy(list, NULL);
250 
251  return 0;
252 }
Octstr * octstr_imm(const char *cstr)
Definition: octstr.c:281
void * gwlist_extract_first(List *list)
Definition: list.c:305
List * cfg_get_multi_group(Cfg *cfg, Octstr *name)
Definition: cfg.c:642
int urltrans_add_one(URLTranslationList *trans, CfgGroup *grp)
Definition: urltrans.c:203
Definition: cfg.c:73
Definition: list.c:102
void gwlist_destroy(List *list, gwlist_item_destructor_t *destructor)
Definition: list.c:145
int urltrans_add_one ( URLTranslationList trans,
CfgGroup grp 
)

Definition at line 203 of file urltrans.c.

References create_onetrans(), URLTranslationList::defaults, dict_get(), dict_put(), gwlist_append(), gwlist_create, URLTranslation::keyword_regex, URLTranslationList::list, URLTranslation::name, URLTranslationList::names, TRANSTYPE_SENDSMS, and URLTranslation::type.

Referenced by urltrans_add_cfg().

204 {
205  URLTranslation *ot;
206  List *list2;
207 
208  ot = create_onetrans(grp);
209  if (ot == NULL)
210  return -1;
211 
212  if (ot->type != TRANSTYPE_SENDSMS && ot->keyword_regex == NULL)
213  gwlist_append(trans->defaults, ot);
214  else
215  gwlist_append(trans->list, ot);
216 
217  list2 = dict_get(trans->names, ot->name);
218  if (list2 == NULL) {
219  list2 = gwlist_create();
220  dict_put(trans->names, ot->name, list2);
221  }
222  gwlist_append(list2, ot);
223 
224  return 0;
225 }
void dict_put(Dict *dict, Octstr *key, void *value)
Definition: dict.c:240
void gwlist_append(List *list, void *item)
Definition: list.c:179
void * dict_get(Dict *dict, Octstr *key)
Definition: dict.c:286
static URLTranslation * create_onetrans(CfgGroup *grp)
Definition: urltrans.c:946
#define gwlist_create()
Definition: list.h:136
regex_t * keyword_regex
Definition: urltrans.c:134
Definition: list.c:102
Octstr * name
Definition: urltrans.c:108
Octstr* urltrans_allow_ip ( URLTranslation t)

Definition at line 857 of file urltrans.c.

References URLTranslation::allow_ip.

Referenced by authorise_username().

858 {
859  return t->allow_ip;
860 }
Octstr * allow_ip
Definition: urltrans.c:113
Octstr* urltrans_allowed_prefix ( URLTranslation t)

Definition at line 867 of file urltrans.c.

References URLTranslation::allowed_prefix.

868 {
869  return t->allowed_prefix;
870 }
Octstr * allowed_prefix
Definition: urltrans.c:116
Octstr* urltrans_allowed_recv_prefix ( URLTranslation t)

Definition at line 877 of file urltrans.c.

References URLTranslation::allowed_recv_prefix.

878 {
879  return t->allowed_recv_prefix;
880 }
Octstr * allowed_recv_prefix
Definition: urltrans.c:118
Octstr* urltrans_alt_charset ( URLTranslation t)

Definition at line 827 of file urltrans.c.

References URLTranslation::alt_charset.

Referenced by obey_request_thread(), and url_result_thread().

828 {
829  return t->alt_charset;
830 }
Octstr * alt_charset
Definition: urltrans.c:102
int urltrans_assume_plain_text ( URLTranslation t)

Definition at line 907 of file urltrans.c.

References URLTranslation::assume_plain_text.

908 {
909  return t->assume_plain_text;
910 }
int assume_plain_text
Definition: urltrans.c:123
Numhash* urltrans_black_list ( URLTranslation t)

Definition at line 897 of file urltrans.c.

References URLTranslation::black_list.

Referenced by smsbox_req_handle().

898 {
899  return t->black_list;
900 }
Numhash * black_list
Definition: urltrans.c:121
regex_t* urltrans_black_list_regex ( URLTranslation t)

Definition at line 902 of file urltrans.c.

References URLTranslation::black_list_regex.

Referenced by smsbox_req_handle().

903 {
904  return t->black_list_regex;
905 }
regex_t * black_list_regex
Definition: urltrans.c:142
int urltrans_concatenation ( URLTranslation t)

Definition at line 797 of file urltrans.c.

References URLTranslation::concatenation.

Referenced by send_message().

798 {
799  return t->concatenation;
800 }
int concatenation
Definition: urltrans.c:96
URLTranslationList* urltrans_create ( void  )

Definition at line 182 of file urltrans.c.

References URLTranslationList::defaults, destroy_keyword_list(), dict_create(), gwlist_create, URLTranslationList::list, and URLTranslationList::names.

Referenced by main().

183 {
184  URLTranslationList *trans;
185 
186  trans = gw_malloc(sizeof(URLTranslationList));
187  trans->list = gwlist_create();
188  trans->defaults = gwlist_create();
189  trans->names = dict_create(1024, destroy_keyword_list);
190  return trans;
191 }
Dict * dict_create(long size_hint, void(*destroy_value)(void *))
Definition: dict.c:192
#define gwlist_create()
Definition: list.h:136
static void destroy_keyword_list(void *list)
Definition: urltrans.c:176
Octstr* urltrans_default_sender ( URLTranslation t)

Definition at line 782 of file urltrans.c.

References URLTranslation::default_sender.

Referenced by smsbox_req_handle(), smsbox_req_sendota(), and smsbox_sendota_post().

783 {
784  return t->default_sender;
785 }
Octstr * default_sender
Definition: urltrans.c:94
Octstr* urltrans_default_smsc ( URLTranslation t)

Definition at line 852 of file urltrans.c.

References URLTranslation::default_smsc.

Referenced by smsbox_req_handle(), smsbox_req_sendota(), and smsbox_sendota_post().

853 {
854  return t->default_smsc;
855 }
Octstr * default_smsc
Definition: urltrans.c:112
Octstr* urltrans_denied_prefix ( URLTranslation t)

Definition at line 872 of file urltrans.c.

References URLTranslation::denied_prefix.

873 {
874  return t->denied_prefix;
875 }
Octstr * denied_prefix
Definition: urltrans.c:117
Octstr* urltrans_denied_recv_prefix ( URLTranslation t)

Definition at line 882 of file urltrans.c.

References URLTranslation::denied_recv_prefix.

883 {
884  return t->denied_recv_prefix;
885 }
Octstr * denied_recv_prefix
Definition: urltrans.c:119
Octstr* urltrans_deny_ip ( URLTranslation t)

Definition at line 862 of file urltrans.c.

References URLTranslation::deny_ip.

Referenced by authorise_username().

863 {
864  return t->deny_ip;
865 }
Octstr * deny_ip
Definition: urltrans.c:115
void urltrans_destroy ( URLTranslationList list)

Definition at line 194 of file urltrans.c.

References URLTranslationList::defaults, destroy_onetrans(), dict_destroy(), gwlist_destroy(), URLTranslationList::list, and URLTranslationList::names.

Referenced by main().

195 {
196  gwlist_destroy(trans->list, destroy_onetrans);
197  gwlist_destroy(trans->defaults, destroy_onetrans);
198  dict_destroy(trans->names);
199  gw_free(trans);
200 }
void dict_destroy(Dict *dict)
Definition: dict.c:215
static void destroy_onetrans(void *ot)
Definition: urltrans.c:1253
void gwlist_destroy(List *list, gwlist_item_destructor_t *destructor)
Definition: list.c:145
int urltrans_dlr_mask ( URLTranslation t)

Definition at line 932 of file urltrans.c.

References URLTranslation::dlr_mask.

Referenced by send_message().

933 {
934  return t->dlr_mask;
935 }
Octstr* urltrans_dlr_url ( URLTranslation t)

Definition at line 927 of file urltrans.c.

References URLTranslation::dlr_url.

Referenced by send_message().

928 {
929  return t->dlr_url;
930 }
Octstr * dlr_url
Definition: urltrans.c:131
Octstr* urltrans_faked_sender ( URLTranslation t)

Definition at line 787 of file urltrans.c.

References URLTranslation::faked_sender.

Referenced by obey_request_thread(), smsbox_req_handle(), smsbox_req_sendota(), and smsbox_sendota_post().

788 {
789  return t->faked_sender;
790 }
Octstr * faked_sender
Definition: urltrans.c:93
Octstr* urltrans_fill_escape_codes ( Octstr pattern,
Msg request 
)

Definition at line 323 of file urltrans.c.

References DC_7BIT, DC_8BIT, DC_UCS2, DC_UNDEF, fields_to_dcs(), gw_gmtime(), gwlist_create, gwlist_destroy(), gwlist_get(), gwlist_len(), meta_data_get_value(), MSG_PARAM_UNDEFINED, octstr_append(), octstr_append_char(), octstr_append_cstr(), octstr_append_decimal(), octstr_binary_to_hex(), octstr_copy, octstr_create, octstr_destroy(), octstr_destroy_item(), octstr_duplicate, octstr_format_append(), octstr_get_char(), octstr_get_cstr, octstr_imm(), octstr_len(), octstr_search_char(), octstr_split_words(), octstr_url_encode(), uuid_is_null(), UUID_STR_LEN, and uuid_unparse().

Referenced by generic_receive_sms(), generic_send_sms(), and urltrans_get_pattern().

324 {
325  Octstr *enc;
326  Octstr *meta_group, *meta_param;
327  int nextarg, j;
328  struct tm tm;
329  int num_words;
330  List *word_list;
331  Octstr *result;
332  long pattern_len;
333  long pos;
334  int c;
335  long i, k;
336  Octstr *temp;
337 
338  result = octstr_create("");
339 
340  if (request->sms.msgdata) {
341  word_list = octstr_split_words(request->sms.msgdata);
342  num_words = gwlist_len(word_list);
343  } else {
344  word_list = gwlist_create();
345  num_words = 0;
346  }
347 
348  pattern_len = octstr_len(pattern);
349  nextarg = 1;
350  pos = 0;
351  for (;;) {
352  while (pos < pattern_len) {
353  c = octstr_get_char(pattern, pos);
354  if (c == '%' && pos + 1 < pattern_len)
355  break;
356  octstr_append_char(result, c);
357  ++pos;
358  }
359 
360  if (pos == pattern_len)
361  break;
362 
363  switch (octstr_get_char(pattern, pos + 1)) {
364  case 'a':
365  for (j = 0; j < num_words; ++j) {
366  enc = octstr_duplicate(gwlist_get(word_list, j));
367  octstr_url_encode(enc);
368  if (j > 0)
369  octstr_append_char(result, '+');
370  octstr_append(result, enc);
371  octstr_destroy(enc);
372  }
373  break;
374 
375  case 'A':
376  if (request->sms.msgdata) {
377  enc = octstr_duplicate(request->sms.msgdata);
378  octstr_url_encode(enc);
379  octstr_append(result, enc);
380  octstr_destroy(enc);
381  }
382  break;
383 
384  case 'b': /* message payload, URL-encoded */
385  enc = octstr_duplicate(request->sms.msgdata);
386  octstr_url_encode(enc);
387  octstr_append(result, enc);
388  octstr_destroy(enc);
389  break;
390 
391  case 'B': /* billing identifier/information */
392  if (octstr_len(request->sms.binfo)) {
393  enc = octstr_duplicate(request->sms.binfo);
394  octstr_url_encode(enc);
395  octstr_append(result, enc);
396  octstr_destroy(enc);
397  }
398  break;
399 
400  case 'c':
401  octstr_append_decimal(result, request->sms.coding);
402  break;
403 
404  case 'C':
405  if (octstr_len(request->sms.charset)) {
406  octstr_append(result, request->sms.charset);
407  } else {
408  switch (request->sms.coding) {
409  case DC_UNDEF:
410  case DC_7BIT:
411  octstr_append(result, octstr_imm("UTF-8"));
412  break;
413  case DC_8BIT:
414  octstr_append(result, octstr_imm("8-BIT"));
415  break;
416  case DC_UCS2:
417  octstr_append(result, octstr_imm("UTF-16BE"));
418  break;
419  }
420  }
421  break;
422 
423  case 'd':
424  enc = octstr_create("");
425  octstr_append_decimal(enc, request->sms.dlr_mask);
426  octstr_url_encode(enc);
427  octstr_append(result, enc);
428  octstr_destroy(enc);
429  break;
430 
431  case 'D': /* meta_data */
432  if (octstr_len(request->sms.meta_data)) {
433  enc = octstr_duplicate(request->sms.meta_data);
434  octstr_url_encode(enc);
435  octstr_append(result, enc);
436  octstr_destroy(enc);
437  }
438  break;
439 
440  case 'e': /* message payload, printable hexadecimal byte codes */
441  if (octstr_len(request->sms.msgdata)) {
442  enc = octstr_duplicate(request->sms.msgdata);
443  octstr_binary_to_hex(enc, 1);
444  octstr_append(result, enc);
445  octstr_destroy(enc);
446  }
447  break;
448 
449  case 'f': /* smsc number*/
450  if (octstr_len(request->sms.smsc_number)) {
451  enc = octstr_duplicate(request->sms.smsc_number);
452  octstr_url_encode(enc);
453  octstr_append(result, enc);
454  octstr_destroy(enc);
455  }
456  break;
457 
458  case 'F':
459  if (request->sms.foreign_id == NULL)
460  break;
461  enc = octstr_duplicate(request->sms.foreign_id);
462  octstr_url_encode(enc);
463  octstr_append(result, enc);
464  octstr_destroy(enc);
465  break;
466 
467  case 'i':
468  if (request->sms.smsc_id == NULL)
469  break;
470  enc = octstr_duplicate(request->sms.smsc_id);
471  octstr_url_encode(enc);
472  octstr_append(result, enc);
473  octstr_destroy(enc);
474  break;
475 
476  case 'I':
477  if (!uuid_is_null(request->sms.id)) {
478  char id[UUID_STR_LEN + 1];
479  uuid_unparse(request->sms.id, id);
480  octstr_append_cstr(result, id);
481  }
482  break;
483 
484  case 'k':
485  if (num_words <= 0)
486  break;
487  enc = octstr_duplicate(gwlist_get(word_list, 0));
488  octstr_url_encode(enc);
489  octstr_append(result, enc);
490  octstr_destroy(enc);
491  break;
492 
493  case 'm': /* mclass - message class */
494  enc = octstr_create("");
495  octstr_append_decimal(enc, request->sms.mclass);
496  octstr_url_encode(enc);
497  octstr_append(result, enc);
498  octstr_destroy(enc);
499  break;
500 
501  case 'M': /* mwi - message waiting indicator */
502  enc = octstr_create("");
503  octstr_append_decimal(enc, request->sms.mwi);
504  octstr_url_encode(enc);
505  octstr_append(result, enc);
506  octstr_destroy(enc);
507  break;
508 
509  case 'n':
510  if (request->sms.service == NULL)
511  break;
512  enc = octstr_duplicate(request->sms.service);
513  octstr_url_encode(enc);
514  octstr_append(result, enc);
515  octstr_destroy(enc);
516  break;
517 
518  case 'o': /* account information (may be operator id for aggregators */
519  if (octstr_len(request->sms.account)) {
520  enc = octstr_duplicate(request->sms.account);
521  octstr_url_encode(enc);
522  octstr_append(result, enc);
523  octstr_destroy(enc);
524  }
525  break;
526 
527  case 'O': /* DCS */
528  {
529  int dcs;
530  dcs = fields_to_dcs(request, request->sms.alt_dcs);
531  octstr_format_append(result, "%02d", dcs);
532  break;
533  }
534 
535  /* NOTE: the sender and receiver is already switched in
536  * message, so that's why we must use 'sender' when
537  * we want original receiver and vice versa
538  */
539  case 'P':
540  enc = octstr_duplicate(request->sms.sender);
541  octstr_url_encode(enc);
542  octstr_append(result, enc);
543  octstr_destroy(enc);
544  break;
545 
546  case 'p':
547  enc = octstr_duplicate(request->sms.receiver);
548  octstr_url_encode(enc);
549  octstr_append(result, enc);
550  octstr_destroy(enc);
551  break;
552 
553  case 'q':
554  if (strncmp(octstr_get_cstr(request->sms.receiver),"00",2)==0) {
555  enc = octstr_copy(request->sms.receiver, 2,
556  octstr_len(request->sms.receiver));
557  octstr_url_encode(enc);
558  octstr_format_append(result, "%%2B%S", enc);
559  octstr_destroy(enc);
560  } else {
561  enc = octstr_duplicate(request->sms.receiver);
562  octstr_url_encode(enc);
563  octstr_append(result, enc);
564  octstr_destroy(enc);
565  }
566  break;
567 
568  case 'Q':
569  if (strncmp(octstr_get_cstr(request->sms.sender), "00", 2) == 0) {
570  enc = octstr_copy(request->sms.sender, 2,
571  octstr_len(request->sms.sender));
572  octstr_url_encode(enc);
573  octstr_format_append(result, "%%2B%S", enc);
574  octstr_destroy(enc);
575  } else {
576  enc = octstr_duplicate(request->sms.sender);
577  octstr_url_encode(enc);
578  octstr_append(result, enc);
579  octstr_destroy(enc);
580  }
581  break;
582 
583  case 'r':
584  for (j = nextarg; j < num_words; ++j) {
585  enc = octstr_duplicate(gwlist_get(word_list, j));
586  octstr_url_encode(enc);
587  if (j != nextarg)
588  octstr_append_char(result, '+');
589  octstr_append(result, enc);
590  octstr_destroy(enc);
591  }
592  break;
593 
594  case 'R': /* dlr_url */
595  if (octstr_len(request->sms.dlr_url)) {
596  enc = octstr_duplicate(request->sms.dlr_url);
597  octstr_url_encode(enc);
598  octstr_append(result, enc);
599  octstr_destroy(enc);
600  }
601  break;
602 
603  case 's':
604  if (nextarg >= num_words)
605  break;
606  enc = octstr_duplicate(gwlist_get(word_list, nextarg));
607  octstr_url_encode(enc);
608  octstr_append(result, enc);
609  octstr_destroy(enc);
610  ++nextarg;
611  break;
612 
613  case 'S':
614  if (nextarg >= num_words)
615  break;
616  temp = gwlist_get(word_list, nextarg);
617  for (i = 0; i < octstr_len(temp); ++i) {
618  if (octstr_get_char(temp, i) == '*')
619  octstr_append_char(result, '~');
620  else
621  octstr_append_char(result, octstr_get_char(temp, i));
622  }
623  ++nextarg;
624  break;
625 
626  case 't':
627  tm = gw_gmtime(request->sms.time);
628  octstr_format_append(result, "%04d-%02d-%02d+%02d:%02d:%02d",
629  tm.tm_year + 1900,
630  tm.tm_mon + 1,
631  tm.tm_mday,
632  tm.tm_hour,
633  tm.tm_min,
634  tm.tm_sec);
635  break;
636 
637  case 'T':
638  if (request->sms.time == MSG_PARAM_UNDEFINED)
639  break;
640  octstr_format_append(result, "%ld", request->sms.time);
641  break;
642 
643  case 'u':
644  if(octstr_len(request->sms.udhdata)) {
645  enc = octstr_duplicate(request->sms.udhdata);
646  octstr_url_encode(enc);
647  octstr_append(result, enc);
648  octstr_destroy(enc);
649  }
650  break;
651 
652  case 'v':
653  if (request->sms.validity != MSG_PARAM_UNDEFINED) {
654  octstr_format_append(result, "%ld", (request->sms.validity - time(NULL)) / 60);
655  }
656  break;
657 
658  case 'V':
659  if (request->sms.deferred != MSG_PARAM_UNDEFINED) {
660  octstr_format_append(result, "%ld", (request->sms.deferred - time(NULL)) / 60);
661  }
662  break;
663 
664  /*
665  * This allows to pass meta-data individual parameters into urls.
666  * The syntax is as follows: %#group#parameter#
667  * For example: %#smpp#my_param# would be replaced with the value
668  * 'my_param' from the group 'smpp' coming inside the meta_data field.
669  */
670  case '#':
671  /* ASCII 0x23 == '#' */
672  k = octstr_search_char(pattern, 0x23, pos + 2);
673  if (k >= 0) {
674  pos += 2;
675  meta_group = octstr_copy(pattern, pos, (k-pos));
676  pos = k + 1;
677  k = octstr_search_char(pattern, 0x23, pos);
678  if (k >= 0) {
679  meta_param = octstr_copy(pattern, pos, (k-pos));
680  pos = k - 1;
681  if (request->sms.meta_data != NULL) {
682  enc = meta_data_get_value(request->sms.meta_data,
683  octstr_get_cstr(meta_group), meta_param);
684  octstr_url_encode(enc);
685  octstr_append(result, enc);
686  octstr_destroy(enc);
687  }
688  octstr_destroy(meta_param);
689  } else {
690  pos++;
691  }
692  octstr_destroy(meta_group);
693  }
694  break;
695 
696  /* XXX sms.parameters not present in here:
697  * * pid - will we receive this ?
698  * * alt-dcs - shouldn't be required unless we want to inform
699  * which alt-dcs external server should use back
700  * * compress - if we use compression, probably kannel would
701  * decompress and reset this to 0. not required
702  * * rpi - we don't receive these from smsc
703  * * username, password, dlr-url, account - nonsense to send
704  */
705  case '%':
706  octstr_format_append(result, "%%");
707  break;
708 
709  default:
710  octstr_format_append(result, "%%%c",
711  octstr_get_char(pattern, pos + 1));
712  break;
713  }
714 
715  pos += 2;
716  }
717 
718  gwlist_destroy(word_list, octstr_destroy_item);
719 
720  return result;
721 }
void octstr_append(Octstr *ostr1, const Octstr *ostr2)
Definition: octstr.c:1502
struct tm gw_gmtime(time_t t)
Definition: protected.c:137
long gwlist_len(List *list)
Definition: list.c:166
void * gwlist_get(List *list, long pos)
Definition: list.c:292
void octstr_append_char(Octstr *ostr, int ch)
Definition: octstr.c:1515
#define DC_8BIT
Definition: sms.h:111
void uuid_unparse(const uuid_t uu, char *out)
Definition: gw_uuid.c:561
Octstr * meta_data_get_value(Octstr *data, const char *group, const Octstr *key)
Definition: meta_data.c:368
void octstr_append_cstr(Octstr *ostr, const char *cstr)
Definition: octstr.c:1509
#define octstr_get_cstr(ostr)
Definition: octstr.h:233
#define octstr_copy(ostr, from, len)
Definition: octstr.h:178
void octstr_binary_to_hex(Octstr *ostr, int uppercase)
Definition: octstr.c:463
long octstr_search_char(const Octstr *ostr, int ch, long pos)
Definition: octstr.c:1010
Octstr * octstr_imm(const char *cstr)
Definition: octstr.c:281
int uuid_is_null(const uuid_t uu)
Definition: gw_uuid.c:412
#define octstr_duplicate(ostr)
Definition: octstr.h:187
List * octstr_split_words(const Octstr *ostr)
Definition: octstr.c:1600
void octstr_destroy(Octstr *ostr)
Definition: octstr.c:322
#define octstr_create(cstr)
Definition: octstr.h:125
void octstr_destroy_item(void *os)
Definition: octstr.c:334
int fields_to_dcs(Msg *msg, int mode)
Definition: sms.c:73
#define UUID_STR_LEN
Definition: gw_uuid.h:19
long octstr_len(const Octstr *ostr)
Definition: octstr.c:340
void octstr_append_decimal(Octstr *ostr, long value)
Definition: octstr.c:1974
Definition: octstr.c:118
#define MSG_PARAM_UNDEFINED
Definition: msg.h:71
void octstr_format_append(Octstr *os, const char *fmt,...)
Definition: octstr.c:2505
#define gwlist_create()
Definition: list.h:136
#define DC_UNDEF
Definition: sms.h:109
int octstr_get_char(const Octstr *ostr, long pos)
Definition: octstr.c:404
Definition: list.c:102
void octstr_url_encode(Octstr *ostr)
Definition: octstr.c:1671
#define DC_UCS2
Definition: sms.h:112
#define DC_7BIT
Definition: sms.h:110
void gwlist_destroy(List *list, gwlist_item_destructor_t *destructor)
Definition: list.c:145
URLTranslation* urltrans_find ( URLTranslationList trans,
Msg msg 
)

Definition at line 255 of file urltrans.c.

References find_default_translation(), and find_translation().

Referenced by main(), and obey_request_thread().

256 {
257  URLTranslation *t = NULL;
258 
259  t = find_translation(trans, msg);
260  if (t == NULL) {
261  t = find_default_translation(trans, msg->sms.smsc_id, msg->sms.sender, msg->sms.receiver, msg->sms.account);
262  }
263 
264  return t;
265 }
static URLTranslation * find_default_translation(URLTranslationList *trans, Octstr *smsc, Octstr *sender, Octstr *receiver, Octstr *account)
Definition: urltrans.c:1491
static URLTranslation * find_translation(URLTranslationList *trans, Msg *msg)
Definition: urltrans.c:1451
URLTranslation* urltrans_find_service ( URLTranslationList trans,
Msg msg 
)

Definition at line 268 of file urltrans.c.

References dict_get(), gwlist_get(), and URLTranslationList::names.

Referenced by obey_request_thread().

269 {
270  URLTranslation *t;
271  List *list;
272 
273  list = dict_get(trans->names, msg->sms.service);
274  if (list != NULL) {
275  t = gwlist_get(list, 0);
276  } else {
277  t = NULL;
278  }
279  return t;
280 }
void * gwlist_get(List *list, long pos)
Definition: list.c:292
void * dict_get(Dict *dict, Octstr *key)
Definition: dict.c:286
Definition: list.c:102
URLTranslation* urltrans_find_username ( URLTranslationList trans,
Octstr name 
)

Definition at line 284 of file urltrans.c.

References gw_assert(), gwlist_get(), gwlist_len(), URLTranslationList::list, octstr_compare(), TRANSTYPE_SENDSMS, URLTranslation::type, and URLTranslation::username.

Referenced by authorise_user(), and authorise_username().

285 {
286  URLTranslation *t;
287  int i;
288 
289  gw_assert(name != NULL);
290  for (i = 0; i < gwlist_len(trans->list); ++i) {
291  t = gwlist_get(trans->list, i);
292  if (t->type == TRANSTYPE_SENDSMS) {
293  if (octstr_compare(name, t->username) == 0)
294  return t;
295  }
296  }
297  return NULL;
298 }
long gwlist_len(List *list)
Definition: list.c:166
void * gwlist_get(List *list, long pos)
Definition: list.c:292
Octstr * username
Definition: urltrans.c:109
gw_assert(wtls_machine->packet_to_send!=NULL)
int octstr_compare(const Octstr *ostr1, const Octstr *ostr2)
Definition: octstr.c:869
Octstr* urltrans_footer ( URLTranslation t)

Definition at line 822 of file urltrans.c.

References URLTranslation::footer.

Referenced by send_message().

823 {
824  return t->footer;
825 }
Octstr * footer
Definition: urltrans.c:101
Octstr* urltrans_forced_smsc ( URLTranslation t)

Definition at line 847 of file urltrans.c.

References URLTranslation::forced_smsc.

Referenced by smsbox_req_handle(), smsbox_req_sendota(), and smsbox_sendota_post().

848 {
849  return t->forced_smsc;
850 }
Octstr * forced_smsc
Definition: urltrans.c:111
Octstr* urltrans_get_pattern ( URLTranslation t,
Msg sms 
)

Definition at line 728 of file urltrans.c.

References URLTranslation::dlr_url, octstr_create, octstr_len(), URLTranslation::pattern, report_mo, URLTranslation::strip_keyword, strip_keyword(), TRANSTYPE_POST_URL, TRANSTYPE_POST_XML, TRANSTYPE_SENDSMS, URLTranslation::type, and urltrans_fill_escape_codes().

Referenced by obey_request().

729 {
730  Octstr *result, *pattern;
731 
732  if (request->sms.sms_type != report_mo && t->type == TRANSTYPE_SENDSMS)
733  return octstr_create("");
734 
735  /* check if this is a delivery report message or not */
736  if (request->sms.sms_type != report_mo) {
737  pattern = t->pattern;
738  } else {
739  /* this is a DLR message */
740  pattern = request->sms.dlr_url;
741  if (octstr_len(pattern) == 0) {
742  if (t && octstr_len(t->dlr_url)) {
743  pattern = t->dlr_url;
744  } else {
745  return octstr_create("");
746  }
747  }
748  }
749 
750  /* We have pulled this out into an own exported function. This
751  * gives other modules the chance to use the same escape code
752  * semantics for Msgs. */
753  result = urltrans_fill_escape_codes(pattern, request);
754 
755  /*
756  * this SHOULD be done in smsbox, not here, but well,
757  * much easier to do here
758  */
759  if (t && (t->type == TRANSTYPE_POST_URL || t->type == TRANSTYPE_POST_XML)
760  && t->strip_keyword)
761  strip_keyword(request);
762 
763  return result;
764 }
Definition: msg.h:109
static void strip_keyword(Msg *request)
Definition: urltrans.c:304
Octstr * dlr_url
Definition: urltrans.c:131
Octstr * urltrans_fill_escape_codes(Octstr *pattern, Msg *request)
Definition: urltrans.c:323
#define octstr_create(cstr)
Definition: octstr.h:125
int strip_keyword
Definition: urltrans.c:125
Octstr * pattern
Definition: urltrans.c:90
long octstr_len(const Octstr *ostr)
Definition: octstr.c:340
Definition: octstr.c:118
Octstr* urltrans_header ( URLTranslation t)

Definition at line 817 of file urltrans.c.

References URLTranslation::header.

Referenced by send_message().

818 {
819  return t->header;
820 }
Octstr * header
Definition: urltrans.c:100
int urltrans_max_messages ( URLTranslation t)

Definition at line 792 of file urltrans.c.

References URLTranslation::max_messages.

Referenced by send_message().

793 {
794  return t->max_messages;
795 }
long max_messages
Definition: urltrans.c:95
Octstr* urltrans_name ( URLTranslation t)

Definition at line 832 of file urltrans.c.

References URLTranslation::name.

Referenced by obey_request_thread(), remember_receiver(), and smsbox_req_handle().

833 {
834  return t->name;
835 }
Octstr * name
Definition: urltrans.c:108
int urltrans_omit_empty ( URLTranslation t)

Definition at line 812 of file urltrans.c.

References URLTranslation::omit_empty.

Referenced by send_message().

813 {
814  return t->omit_empty;
815 }
int omit_empty
Definition: urltrans.c:99
Octstr* urltrans_password ( URLTranslation t)

Definition at line 842 of file urltrans.c.

References URLTranslation::password.

Referenced by authorise_username().

843 {
844  return t->password;
845 }
Octstr * password
Definition: urltrans.c:110
Octstr* urltrans_prefix ( URLTranslation t)

Definition at line 772 of file urltrans.c.

References URLTranslation::prefix.

Referenced by url_result_thread().

773 {
774  return t->prefix;
775 }
Octstr * prefix
Definition: urltrans.c:91
int urltrans_send_sender ( URLTranslation t)

Definition at line 922 of file urltrans.c.

References URLTranslation::send_sender.

Referenced by obey_request().

923 {
924  return t->send_sender;
925 }
Octstr* urltrans_split_chars ( URLTranslation t)

Definition at line 802 of file urltrans.c.

References URLTranslation::split_chars.

Referenced by send_message().

803 {
804  return t->split_chars;
805 }
Octstr * split_chars
Definition: urltrans.c:97
Octstr* urltrans_split_suffix ( URLTranslation t)

Definition at line 807 of file urltrans.c.

References URLTranslation::split_suffix.

Referenced by send_message().

808 {
809  return t->split_suffix;
810 }
Octstr * split_suffix
Definition: urltrans.c:98
int urltrans_strip_keyword ( URLTranslation t)

Definition at line 917 of file urltrans.c.

References URLTranslation::strip_keyword.

918 {
919  return t->strip_keyword;
920 }
int strip_keyword
Definition: urltrans.c:125
Octstr* urltrans_suffix ( URLTranslation t)

Definition at line 777 of file urltrans.c.

References URLTranslation::suffix.

Referenced by url_result_thread().

778 {
779  return t->suffix;
780 }
Octstr * suffix
Definition: urltrans.c:92
int urltrans_type ( URLTranslation t)

Definition at line 767 of file urltrans.c.

References URLTranslation::type.

Referenced by main(), and obey_request().

768 {
769  return t->type;
770 }
Octstr* urltrans_username ( URLTranslation t)

Definition at line 837 of file urltrans.c.

References URLTranslation::username.

Referenced by smsbox_req_handle().

838 {
839  return t->username;
840 }
Octstr * username
Definition: urltrans.c:109
Numhash* urltrans_white_list ( URLTranslation t)

Definition at line 887 of file urltrans.c.

References URLTranslation::white_list.

Referenced by smsbox_req_handle().

888 {
889  return t->white_list;
890 }
Numhash * white_list
Definition: urltrans.c:120
regex_t* urltrans_white_list_regex ( URLTranslation t)

Definition at line 892 of file urltrans.c.

References URLTranslation::white_list_regex.

Referenced by smsbox_req_handle().

893 {
894  return t->white_list_regex;
895 }
regex_t * white_list_regex
Definition: urltrans.c:141
See file LICENSE for details about the license agreement for using, modifying, copying or deriving work from this software.