Wed Jan 8 2020 09:50:12

Asterisk developer's documentation


func_callerid.c File Reference

Party ID related dialplan functions (Caller-ID, Connected-line, Redirecting) More...

#include "asterisk.h"
#include "asterisk/module.h"
#include "asterisk/channel.h"
#include "asterisk/pbx.h"
#include "asterisk/utils.h"
#include "asterisk/app.h"
#include "asterisk/callerid.h"

Go to the source code of this file.

Data Structures

struct  ast_party_func_args
 
struct  ast_party_members
 

Enumerations

enum  CONNECTED_LINE_OPT_ARGS { CONNECTED_LINE_OPT_DUMMY, CONNECTED_LINE_OPT_ARG_ARRAY_SIZE }
 
enum  CONNECTED_LINE_OPT_FLAGS { CONNECTED_LINE_OPT_INHIBIT = (1 << 0) }
 
enum  ID_FIELD_STATUS { ID_FIELD_VALID, ID_FIELD_INVALID, ID_FIELD_UNKNOWN }
 
enum  REDIRECTING_OPT_ARGS { REDIRECTING_OPT_DUMMY, REDIRECTING_OPT_ARG_ARRAY_SIZE }
 
enum  REDIRECTING_OPT_FLAGS { REDIRECTING_OPT_INHIBIT = (1 << 0) }
 

Functions

static void __reg_module (void)
 
static void __unreg_module (void)
 
static int callerid_read (struct ast_channel *chan, const char *cmd, char *data, char *buf, size_t len)
 
static int callerid_write (struct ast_channel *chan, const char *cmd, char *data, const char *value)
 
static int callerpres_read (struct ast_channel *chan, const char *cmd, char *data, char *buf, size_t len)
 
static int callerpres_write (struct ast_channel *chan, const char *cmd, char *data, const char *value)
 
static int connectedline_read (struct ast_channel *chan, const char *cmd, char *data, char *buf, size_t len)
 
static int connectedline_write (struct ast_channel *chan, const char *cmd, char *data, const char *value)
 
static int load_module (void)
 
static enum ID_FIELD_STATUS party_id_read (char *buf, size_t len, int argc, char *argv[], const struct ast_party_id *id)
 
static enum ID_FIELD_STATUS party_id_write (struct ast_party_id *id, int argc, char *argv[], const char *value)
 
static enum ID_FIELD_STATUS party_name_read (char *buf, size_t len, int argc, char *argv[], const struct ast_party_name *name)
 
static enum ID_FIELD_STATUS party_name_write (struct ast_party_name *name, int argc, char *argv[], const char *value)
 
static enum ID_FIELD_STATUS party_number_read (char *buf, size_t len, int argc, char *argv[], const struct ast_party_number *number)
 
static enum ID_FIELD_STATUS party_number_write (struct ast_party_number *number, int argc, char *argv[], const char *value)
 
static enum ID_FIELD_STATUS party_subaddress_read (char *buf, size_t len, int argc, char *argv[], const struct ast_party_subaddress *subaddress)
 
static enum ID_FIELD_STATUS party_subaddress_write (struct ast_party_subaddress *subaddress, int argc, char *argv[], const char *value)
 
static int redirecting_read (struct ast_channel *chan, const char *cmd, char *data, char *buf, size_t len)
 
static int redirecting_write (struct ast_channel *chan, const char *cmd, char *data, const char *value)
 
static int unload_module (void)
 

Variables

static struct ast_module_info __mod_info = { .name = AST_MODULE, .flags = AST_MODFLAG_LOAD_ORDER , .description = "Party ID related dialplan functions (Caller-ID, Connected-line, Redirecting)" , .key = "This paragraph is copyright (c) 2006 by Digium, Inc. \In order for your module to load, it must return this \key via a function called \"key\". Any code which \includes this paragraph must be licensed under the GNU \General Public License version 2 or later (at your \option). In addition to Digium's general reservations \of rights, Digium expressly reserves the right to \allow other parties to license this paragraph under \different terms. Any use of Digium, Inc. trademarks or \logos (including \"Asterisk\" or \"Digium\") without \express written permission of Digium, Inc. is prohibited.\n" , .buildopt_sum = "ac1f6a56484a8820659555499174e588" , .load = load_module, .unload = unload_module, .load_pri = AST_MODPRI_DEFAULT, }
 
static struct ast_module_infoast_module_info = &__mod_info
 
static struct ast_custom_function callerid_function
 
static int callerpres_deprecate_notify
 
static struct ast_custom_function callerpres_function
 
static struct ast_custom_function connectedline_function
 
static struct ast_app_option connectedline_opts [128] = { [ 'i' ] = { .flag = CONNECTED_LINE_OPT_INHIBIT }, }
 
static struct ast_custom_function redirecting_function
 
static struct ast_app_option redirecting_opts [128] = { [ 'i' ] = { .flag = REDIRECTING_OPT_INHIBIT }, }
 

Detailed Description

Party ID related dialplan functions (Caller-ID, Connected-line, Redirecting)

See Also:

Definition in file func_callerid.c.

Enumeration Type Documentation

Enumerator
CONNECTED_LINE_OPT_DUMMY 

Delete this if CONNECTED_LINE ever gets an option with parameters.

CONNECTED_LINE_OPT_ARG_ARRAY_SIZE 
Note
This entry MUST be the last one in the enum

Definition at line 334 of file func_callerid.c.

334  {
335  CONNECTED_LINE_OPT_DUMMY, /*!< Delete this if CONNECTED_LINE ever gets an option with parameters. */
336 
337  /*! \note This entry _MUST_ be the last one in the enum */
339 };
Enumerator
CONNECTED_LINE_OPT_INHIBIT 

Definition at line 331 of file func_callerid.c.

331  {
332  CONNECTED_LINE_OPT_INHIBIT = (1 << 0),
333 };
Enumerator
ID_FIELD_VALID 
ID_FIELD_INVALID 
ID_FIELD_UNKNOWN 

Definition at line 315 of file func_callerid.c.

Enumerator
REDIRECTING_OPT_DUMMY 

Delete this if REDIRECTING ever gets an option with parameters.

REDIRECTING_OPT_ARG_ARRAY_SIZE 
Note
This entry MUST be the last one in the enum

Definition at line 348 of file func_callerid.c.

348  {
349  REDIRECTING_OPT_DUMMY, /*!< Delete this if REDIRECTING ever gets an option with parameters. */
350 
351  /*! \note This entry _MUST_ be the last one in the enum */
353 };
Enumerator
REDIRECTING_OPT_INHIBIT 

Definition at line 345 of file func_callerid.c.

345  {
346  REDIRECTING_OPT_INHIBIT = (1 << 0),
347 };

Function Documentation

static void __reg_module ( void  )
static

Definition at line 1610 of file func_callerid.c.

static void __unreg_module ( void  )
static

Definition at line 1610 of file func_callerid.c.

static int callerid_read ( struct ast_channel chan,
const char *  cmd,
char *  data,
char *  buf,
size_t  len 
)
static

< Member name

< Optional caller id to parse instead of from the channel.

Definition at line 880 of file func_callerid.c.

References ast_party_caller::ani, ast_party_caller::ani2, ast_party_members::argc, args, ast_party_members::argv, ARRAY_LEN, AST_APP_ARG, ast_callerid_split(), ast_channel_lock, ast_channel_unlock, ast_copy_string(), AST_DECLARE_APP_ARGS, ast_log(), AST_NONSTANDARD_APP_ARGS, AST_STANDARD_APP_ARGS, ast_strdupa, ast_channel::caller, ast_channel::dialed, ast_party_redirecting::from, ast_party_caller::id, ID_FIELD_INVALID, ID_FIELD_VALID, LOG_ERROR, name, ast_party_id::number, ast_party_dialed::number, party_id_read(), party_subaddress_read(), ast_party_dialed::plan, ast_channel::redirecting, status, ast_party_number::str, ast_party_dialed::str, ast_party_dialed::subaddress, ast_party_members::subnames, and ast_party_number::valid.

881 {
882  enum ID_FIELD_STATUS status;
883  char *parms;
884  struct ast_party_members member;
886  AST_APP_ARG(member); /*!< Member name */
887  AST_APP_ARG(cid); /*!< Optional caller id to parse instead of from the channel. */
888  );
889 
890  /* Ensure that the buffer is empty */
891  *buf = 0;
892 
893  if (!chan) {
894  return -1;
895  }
896 
897  parms = ast_strdupa(data);
898  AST_STANDARD_APP_ARGS(args, parms);
899  if (args.argc == 0) {
900  /* Must have at least one argument. */
901  return -1;
902  }
903 
904  AST_NONSTANDARD_APP_ARGS(member, args.member, '-');
905  if (member.argc == 0 || ARRAY_LEN(member.subnames) <= member.argc) {
906  /* Too few or too many subnames */
907  return -1;
908  }
909 
910  if (args.argc == 2) {
911  char name[80];
912  char num[80];
913 
914  ast_callerid_split(args.cid, name, sizeof(name), num, sizeof(num));
915 
916  if (member.argc == 1 && !strcasecmp("all", member.argv[0])) {
917  snprintf(buf, len, "\"%s\" <%s>", name, num);
918  } else if (member.argc == 1 && !strcasecmp("name", member.argv[0])) {
919  ast_copy_string(buf, name, len);
920  } else if (member.argc == 1 && !strncasecmp("num", member.argv[0], 3)) {
921  /* Accept num[ber] */
922  ast_copy_string(buf, num, len);
923  } else {
924  ast_log(LOG_ERROR, "Unknown callerid data type '%s'.\n", data);
925  }
926  } else {
927  ast_channel_lock(chan);
928 
929  if (member.argc == 1 && !strcasecmp("rdnis", member.argv[0])) {
930  if (chan->redirecting.from.number.valid
931  && chan->redirecting.from.number.str) {
933  }
934  } else if (!strcasecmp("dnid", member.argv[0])) {
935  if (member.argc == 1) {
936  /* Setup as if user had given dnid-num instead. */
937  member.argc = 2;
938  member.argv[1] = "num";
939  }
940  if (!strncasecmp("num", member.argv[1], 3)) {
941  /*
942  * Accept num[ber]
943  * dnid-num...
944  */
945  if (member.argc == 2) {
946  /* dnid-num */
947  if (chan->dialed.number.str) {
948  ast_copy_string(buf, chan->dialed.number.str, len);
949  }
950  } else if (member.argc == 3 && !strcasecmp("plan", member.argv[2])) {
951  /* dnid-num-plan */
952  snprintf(buf, len, "%d", chan->dialed.number.plan);
953  } else {
954  ast_log(LOG_ERROR, "Unknown callerid data type '%s'.\n", data);
955  }
956  } else if (!strncasecmp("subaddr", member.argv[1], 7)) {
957  /*
958  * Accept subaddr[ess]
959  * dnid-subaddr...
960  */
961  status = party_subaddress_read(buf, len, member.argc - 2, member.argv + 2,
962  &chan->dialed.subaddress);
963  switch (status) {
964  case ID_FIELD_VALID:
965  case ID_FIELD_INVALID:
966  break;
967  default:
968  ast_log(LOG_ERROR, "Unknown callerid data type '%s'.\n", data);
969  break;
970  }
971  } else {
972  ast_log(LOG_ERROR, "Unknown callerid data type '%s'.\n", data);
973  }
974  } else if (member.argc == 1 && !strcasecmp("ani2", member.argv[0])) {
975  snprintf(buf, len, "%d", chan->caller.ani2);
976  } else if (!strcasecmp("ani", member.argv[0])) {
977  if (member.argc == 1) {
978  /* Setup as if user had given ani-num instead. */
979  member.argc = 2;
980  member.argv[1] = "num";
981  }
982  status = party_id_read(buf, len, member.argc - 1, member.argv + 1,
983  &chan->caller.ani);
984  switch (status) {
985  case ID_FIELD_VALID:
986  case ID_FIELD_INVALID:
987  break;
988  default:
989  ast_log(LOG_ERROR, "Unknown callerid data type '%s'.\n", data);
990  break;
991  }
992  } else {
993  status = party_id_read(buf, len, member.argc, member.argv, &chan->caller.id);
994  switch (status) {
995  case ID_FIELD_VALID:
996  case ID_FIELD_INVALID:
997  break;
998  default:
999  ast_log(LOG_ERROR, "Unknown callerid data type '%s'.\n", data);
1000  break;
1001  }
1002  }
1003 
1004  ast_channel_unlock(chan);
1005  }
1006 
1007  return 0;
1008 }
#define ast_channel_lock(chan)
Definition: channel.h:2466
int plan
Q.931 Type-Of-Number and Numbering-Plan encoded fields.
Definition: channel.h:338
char * str
Subscriber phone number (Malloced)
Definition: channel.h:241
#define ARRAY_LEN(a)
Definition: isdn_lib.c:42
char * str
Subscriber phone number (Malloced)
Definition: channel.h:336
struct ast_party_caller caller
Channel Caller ID information.
Definition: channel.h:804
int ast_callerid_split(const char *src, char *name, int namelen, char *num, int numlen)
Definition: callerid.c:1093
struct ast_party_id from
Who is redirecting the call (Sent to the party the call is redirected toward)
Definition: channel.h:449
#define AST_DECLARE_APP_ARGS(name, arglist)
Declare a structure to hold an application&#39;s arguments.
Definition: app.h:572
struct ast_party_redirecting redirecting
Redirecting/Diversion information.
Definition: channel.h:814
struct ast_party_id id
Caller party ID.
Definition: channel.h:370
struct ast_party_id ani
Automatic Number Identification (ANI)
Definition: channel.h:377
static enum ID_FIELD_STATUS party_subaddress_read(char *buf, size_t len, int argc, char *argv[], const struct ast_party_subaddress *subaddress)
struct ast_party_dialed::@155 number
Dialed/Called number.
static enum ID_FIELD_STATUS party_id_read(char *buf, size_t len, int argc, char *argv[], const struct ast_party_id *id)
struct ast_party_dialed dialed
Dialed/Called information.
Definition: channel.h:797
#define ast_strdupa(s)
duplicate a string in memory from the stack
Definition: utils.h:663
#define LOG_ERROR
Definition: logger.h:155
static struct @350 args
static int len(struct ast_channel *chan, const char *cmd, char *data, char *buf, size_t buflen)
int ani2
Automatic Number Identification 2 (Info Digits)
Definition: channel.h:380
void ast_log(int level, const char *file, int line, const char *function, const char *fmt,...)
Used for sending a log message This is the standard logger function. Probably the only way you will i...
Definition: logger.c:1207
#define ast_channel_unlock(chan)
Definition: channel.h:2467
static const char name[]
ID_FIELD_STATUS
struct ast_party_subaddress subaddress
Dialed/Called subaddress.
Definition: channel.h:341
void ast_copy_string(char *dst, const char *src, size_t size)
Size-limited null-terminating string copy.
Definition: strings.h:223
#define AST_APP_ARG(name)
Define an application argument.
Definition: app.h:555
#define AST_STANDARD_APP_ARGS(args, parse)
Performs the &#39;standard&#39; argument separation process for an application.
Definition: app.h:604
#define AST_NONSTANDARD_APP_ARGS(args, parse, sep)
Performs the &#39;nonstandard&#39; argument separation process for an application.
Definition: app.h:619
unsigned char valid
TRUE if the number information is valid/present.
Definition: channel.h:247
jack_status_t status
Definition: app_jack.c:143
struct ast_party_number number
Subscriber phone number.
Definition: channel.h:292
static int callerid_write ( struct ast_channel chan,
const char *  cmd,
char *  data,
const char *  value 
)
static

Definition at line 1022 of file func_callerid.c.

References ast_party_caller::ani, ast_party_caller::ani2, ast_party_func_args::argc, ast_party_members::argc, ast_party_members::argv, ARRAY_LEN, ast_cdr_setcid(), ast_channel_lock, ast_channel_set_caller_event(), ast_channel_unlock, ast_free, ast_log(), AST_NONSTANDARD_APP_ARGS, ast_party_caller_free(), ast_party_caller_set(), ast_party_caller_set_init(), ast_party_dialed_free(), ast_party_dialed_set(), ast_party_dialed_set_init(), ast_skip_blanks(), AST_STANDARD_APP_ARGS, ast_strdup, ast_strdupa, ast_trim_blanks(), ast_channel::caller, ast_channel::cdr, ast_channel::dialed, ast_party_redirecting::from, ast_party_caller::id, ID_FIELD_INVALID, ID_FIELD_VALID, LOG_ERROR, ast_party_func_args::member, ast_party_id::number, ast_party_dialed::number, party_id_write(), party_subaddress_write(), ast_party_dialed::plan, ast_channel::redirecting, status, ast_party_number::str, ast_party_dialed::str, ast_party_dialed::subaddress, ast_party_members::subnames, and ast_party_number::valid.

1023 {
1024  struct ast_party_caller caller;
1025  struct ast_party_dialed dialed;
1026  enum ID_FIELD_STATUS status;
1027  char *val;
1028  char *parms;
1029  struct ast_party_func_args args;
1030  struct ast_party_members member;
1031 
1032  if (!value || !chan) {
1033  return -1;
1034  }
1035 
1036  parms = ast_strdupa(data);
1037  AST_STANDARD_APP_ARGS(args, parms);
1038  if (args.argc == 0) {
1039  /* Must have at least one argument. */
1040  return -1;
1041  }
1042 
1043  AST_NONSTANDARD_APP_ARGS(member, args.member, '-');
1044  if (member.argc == 0 || ARRAY_LEN(member.subnames) <= member.argc) {
1045  /* Too few or too many subnames */
1046  return -1;
1047  }
1048 
1050 
1051  ast_channel_lock(chan);
1052  if (member.argc == 1 && !strcasecmp("rdnis", member.argv[0])) {
1053  chan->redirecting.from.number.valid = 1;
1056  if (chan->cdr) {
1057  ast_cdr_setcid(chan->cdr, chan);
1058  }
1059  } else if (!strcasecmp("dnid", member.argv[0])) {
1060  ast_party_dialed_set_init(&dialed, &chan->dialed);
1061  if (member.argc == 1) {
1062  /* Setup as if user had given dnid-num instead. */
1063  member.argc = 2;
1064  member.argv[1] = "num";
1065  }
1066  if (!strncasecmp("num", member.argv[1], 3)) {
1067  /*
1068  * Accept num[ber]
1069  * dnid-num...
1070  */
1071  if (member.argc == 2) {
1072  /* dnid-num */
1073  dialed.number.str = ast_strdup(value);
1074  ast_trim_blanks(dialed.number.str);
1075  ast_party_dialed_set(&chan->dialed, &dialed);
1076  if (chan->cdr) {
1077  ast_cdr_setcid(chan->cdr, chan);
1078  }
1079  } else if (member.argc == 3 && !strcasecmp("plan", member.argv[2])) {
1080  /* dnid-num-plan */
1081  val = ast_strdupa(value);
1082  ast_trim_blanks(val);
1083 
1084  if (('0' <= val[0]) && (val[0] <= '9')) {
1085  chan->dialed.number.plan = atoi(val);
1086  if (chan->cdr) {
1087  ast_cdr_setcid(chan->cdr, chan);
1088  }
1089  } else {
1091  "Unknown type-of-number/numbering-plan '%s', value unchanged\n", val);
1092  }
1093  } else {
1094  ast_log(LOG_ERROR, "Unknown callerid data type '%s'.\n", data);
1095  }
1096  } else if (!strncasecmp("subaddr", member.argv[1], 7)) {
1097  /*
1098  * Accept subaddr[ess]
1099  * dnid-subaddr...
1100  */
1101  status = party_subaddress_write(&dialed.subaddress, member.argc - 2,
1102  member.argv + 2, value);
1103  switch (status) {
1104  case ID_FIELD_VALID:
1105  ast_party_dialed_set(&chan->dialed, &dialed);
1106  if (chan->cdr) {
1107  ast_cdr_setcid(chan->cdr, chan);
1108  }
1109  break;
1110  case ID_FIELD_INVALID:
1111  break;
1112  default:
1113  ast_log(LOG_ERROR, "Unknown callerid data type '%s'.\n", data);
1114  break;
1115  }
1116  } else {
1117  ast_log(LOG_ERROR, "Unknown callerid data type '%s'.\n", data);
1118  }
1119  ast_party_dialed_free(&dialed);
1120  } else if (member.argc == 1 && !strcasecmp("ani2", member.argv[0])) {
1121  val = ast_strdupa(value);
1122  ast_trim_blanks(val);
1123 
1124  if (('0' <= val[0]) && (val[0] <= '9')) {
1125  chan->caller.ani2 = atoi(val);
1126  if (chan->cdr) {
1127  ast_cdr_setcid(chan->cdr, chan);
1128  }
1129  } else {
1130  ast_log(LOG_ERROR, "Unknown callerid ani2 '%s', value unchanged\n", val);
1131  }
1132  } else if (!strcasecmp("ani", member.argv[0])) {
1133  ast_party_caller_set_init(&caller, &chan->caller);
1134  if (member.argc == 1) {
1135  /* Setup as if user had given ani-num instead. */
1136  member.argc = 2;
1137  member.argv[1] = "num";
1138  }
1139  status = party_id_write(&caller.ani, member.argc - 1, member.argv + 1, value);
1140  switch (status) {
1141  case ID_FIELD_VALID:
1142  ast_party_caller_set(&chan->caller, &caller, NULL);
1143  if (chan->cdr) {
1144  ast_cdr_setcid(chan->cdr, chan);
1145  }
1146  break;
1147  case ID_FIELD_INVALID:
1148  break;
1149  default:
1150  ast_log(LOG_ERROR, "Unknown callerid data type '%s'.\n", data);
1151  break;
1152  }
1153  ast_party_caller_free(&caller);
1154  } else {
1155  ast_party_caller_set_init(&caller, &chan->caller);
1156  status = party_id_write(&caller.id, member.argc, member.argv, value);
1157  switch (status) {
1158  case ID_FIELD_VALID:
1159  ast_channel_set_caller_event(chan, &caller, NULL);
1160  if (chan->cdr) {
1161  ast_cdr_setcid(chan->cdr, chan);
1162  }
1163  break;
1164  case ID_FIELD_INVALID:
1165  break;
1166  default:
1167  ast_log(LOG_ERROR, "Unknown callerid data type '%s'.\n", data);
1168  break;
1169  }
1170  ast_party_caller_free(&caller);
1171  }
1172  ast_channel_unlock(chan);
1173 
1174  return 0;
1175 }
static enum ID_FIELD_STATUS party_subaddress_write(struct ast_party_subaddress *subaddress, int argc, char *argv[], const char *value)
#define ast_channel_lock(chan)
Definition: channel.h:2466
int plan
Q.931 Type-Of-Number and Numbering-Plan encoded fields.
Definition: channel.h:338
char * str
Subscriber phone number (Malloced)
Definition: channel.h:241
#define ARRAY_LEN(a)
Definition: isdn_lib.c:42
void ast_channel_set_caller_event(struct ast_channel *chan, const struct ast_party_caller *caller, const struct ast_set_party_caller *update)
Set the caller id information in the Asterisk channel and generate an AMI event if the caller id name...
Definition: channel.c:7091
struct ast_party_caller caller
Channel Caller ID information.
Definition: channel.h:804
#define ast_strdup(a)
Definition: astmm.h:109
Definition: ast_expr2.c:325
struct ast_party_id from
Who is redirecting the call (Sent to the party the call is redirected toward)
Definition: channel.h:449
void ast_party_caller_set(struct ast_party_caller *dest, const struct ast_party_caller *src, const struct ast_set_party_caller *update)
Set the caller information based on another caller source.
Definition: channel.c:2295
struct ast_party_redirecting redirecting
Redirecting/Diversion information.
Definition: channel.h:814
void ast_party_caller_free(struct ast_party_caller *doomed)
Destroy the caller party contents.
Definition: channel.c:2302
struct ast_cdr * cdr
Definition: channel.h:766
int value
Definition: syslog.c:39
void ast_party_dialed_set(struct ast_party_dialed *dest, const struct ast_party_dialed *src)
Set the dialed information based on another dialed source.
Definition: channel.c:2249
int ast_cdr_setcid(struct ast_cdr *cdr, struct ast_channel *chan)
Initialize based on a channel.
Definition: cdr.c:883
struct ast_party_dialed::@155 number
Dialed/Called number.
Caller Party information.
Definition: channel.h:368
struct ast_party_dialed dialed
Dialed/Called information.
Definition: channel.h:797
#define ast_strdupa(s)
duplicate a string in memory from the stack
Definition: utils.h:663
Dialed/Called Party information.
Definition: channel.h:328
#define LOG_ERROR
Definition: logger.h:155
void ast_party_caller_set_init(struct ast_party_caller *init, const struct ast_party_caller *guide)
Initialize the given caller structure using the given guide for a set update operation.
Definition: channel.c:2288
static struct @350 args
int ani2
Automatic Number Identification 2 (Info Digits)
Definition: channel.h:380
char * ast_skip_blanks(const char *str)
Gets a pointer to the first non-whitespace character in a string.
Definition: strings.h:97
void ast_log(int level, const char *file, int line, const char *function, const char *fmt,...)
Used for sending a log message This is the standard logger function. Probably the only way you will i...
Definition: logger.c:1207
char * ast_trim_blanks(char *str)
Trims trailing whitespace characters from a string.
Definition: strings.h:122
#define ast_channel_unlock(chan)
Definition: channel.h:2467
#define ast_free(a)
Definition: astmm.h:97
ID_FIELD_STATUS
static enum ID_FIELD_STATUS party_id_write(struct ast_party_id *id, int argc, char *argv[], const char *value)
void ast_party_dialed_free(struct ast_party_dialed *doomed)
Destroy the dialed party contents.
Definition: channel.c:2262
#define AST_STANDARD_APP_ARGS(args, parse)
Performs the &#39;standard&#39; argument separation process for an application.
Definition: app.h:604
#define AST_NONSTANDARD_APP_ARGS(args, parse, sep)
Performs the &#39;nonstandard&#39; argument separation process for an application.
Definition: app.h:619
unsigned char valid
TRUE if the number information is valid/present.
Definition: channel.h:247
jack_status_t status
Definition: app_jack.c:143
void ast_party_dialed_set_init(struct ast_party_dialed *init, const struct ast_party_dialed *guide)
Initialize the given dialed structure using the given guide for a set update operation.
Definition: channel.c:2241
struct ast_party_number number
Subscriber phone number.
Definition: channel.h:292
static int callerpres_read ( struct ast_channel chan,
const char *  cmd,
char *  data,
char *  buf,
size_t  len 
)
static

Definition at line 813 of file func_callerid.c.

References ast_copy_string(), ast_log(), ast_named_caller_presentation(), ast_party_id_presentation(), ast_channel::caller, ast_party_caller::id, and LOG_WARNING.

814 {
815  if (!chan) {
816  ast_log(LOG_WARNING, "No channel was provided to %s function.\n", cmd);
817  return -1;
818  }
819 
822  ast_log(LOG_WARNING, "CALLERPRES is deprecated."
823  " Use CALLERID(name-pres) or CALLERID(num-pres) instead.\n");
824  }
825  ast_copy_string(buf,
827  return 0;
828 }
const char * ast_named_caller_presentation(int data)
Convert caller ID pres value to text code.
Definition: callerid.c:1183
struct ast_party_caller caller
Channel Caller ID information.
Definition: channel.h:804
#define LOG_WARNING
Definition: logger.h:144
int ast_party_id_presentation(const struct ast_party_id *id)
Determine the overall presentation value for the given party.
Definition: channel.c:2151
static int callerpres_deprecate_notify
struct ast_party_id id
Caller party ID.
Definition: channel.h:370
static int len(struct ast_channel *chan, const char *cmd, char *data, char *buf, size_t buflen)
void ast_log(int level, const char *file, int line, const char *function, const char *fmt,...)
Used for sending a log message This is the standard logger function. Probably the only way you will i...
Definition: logger.c:1207
void ast_copy_string(char *dst, const char *src, size_t size)
Size-limited null-terminating string copy.
Definition: strings.h:223
static int callerpres_write ( struct ast_channel chan,
const char *  cmd,
char *  data,
const char *  value 
)
static

Definition at line 842 of file func_callerid.c.

References ast_log(), ast_parse_caller_presentation(), ast_channel::caller, ast_party_caller::id, LOG_WARNING, ast_party_id::name, ast_party_id::number, ast_party_name::presentation, and ast_party_number::presentation.

843 {
844  int pres;
845 
846  if (!chan) {
847  ast_log(LOG_WARNING, "No channel was provided to %s function.\n", cmd);
848  return -1;
849  }
850 
853  ast_log(LOG_WARNING, "CALLERPRES is deprecated."
854  " Use CALLERID(name-pres) or CALLERID(num-pres) instead.\n");
855  }
856 
858  if (pres < 0) {
859  ast_log(LOG_WARNING, "'%s' is not a valid presentation (see 'show function CALLERPRES')\n", value);
860  } else {
861  chan->caller.id.name.presentation = pres;
862  chan->caller.id.number.presentation = pres;
863  }
864  return 0;
865 }
int presentation
Q.931 encoded presentation-indicator encoded field.
Definition: channel.h:227
struct ast_party_caller caller
Channel Caller ID information.
Definition: channel.h:804
int presentation
Q.931 presentation-indicator and screening-indicator encoded fields.
Definition: channel.h:245
struct ast_party_name name
Subscriber name.
Definition: channel.h:290
#define LOG_WARNING
Definition: logger.h:144
static int callerpres_deprecate_notify
int value
Definition: syslog.c:39
struct ast_party_id id
Caller party ID.
Definition: channel.h:370
int ast_parse_caller_presentation(const char *data)
Convert caller ID text code to value (used in config file parsing)
Definition: callerid.c:1144
void ast_log(int level, const char *file, int line, const char *function, const char *fmt,...)
Used for sending a log message This is the standard logger function. Probably the only way you will i...
Definition: logger.c:1207
struct ast_party_number number
Subscriber phone number.
Definition: channel.h:292
static int connectedline_read ( struct ast_channel chan,
const char *  cmd,
char *  data,
char *  buf,
size_t  len 
)
static

Definition at line 1190 of file func_callerid.c.

References ast_party_members::argc, ast_party_members::argv, ARRAY_LEN, ast_channel_lock, ast_channel_unlock, ast_connected_line_source_name(), ast_copy_string(), ast_log(), AST_NONSTANDARD_APP_ARGS, ast_strdupa, ast_channel::connected, ast_party_connected_line::id, ID_FIELD_INVALID, ID_FIELD_VALID, LOG_ERROR, party_id_read(), ast_party_connected_line::source, status, and ast_party_members::subnames.

1191 {
1192  struct ast_party_members member;
1193  char *read_what;
1194  enum ID_FIELD_STATUS status;
1195 
1196  /* Ensure that the buffer is empty */
1197  *buf = 0;
1198 
1199  if (!chan) {
1200  return -1;
1201  }
1202 
1203  read_what = ast_strdupa(data);
1204  AST_NONSTANDARD_APP_ARGS(member, read_what, '-');
1205  if (member.argc == 0 || ARRAY_LEN(member.subnames) <= member.argc) {
1206  /* Too few or too many subnames */
1207  return -1;
1208  }
1209 
1210  ast_channel_lock(chan);
1211 
1212  if (member.argc == 1 && !strcasecmp("source", member.argv[0])) {
1214  } else {
1215  status = party_id_read(buf, len, member.argc, member.argv, &chan->connected.id);
1216  switch (status) {
1217  case ID_FIELD_VALID:
1218  case ID_FIELD_INVALID:
1219  break;
1220  default:
1221  ast_log(LOG_ERROR, "Unknown connectedline data type '%s'.\n", data);
1222  break;
1223  }
1224  }
1225 
1226  ast_channel_unlock(chan);
1227 
1228  return 0;
1229 }
#define ast_channel_lock(chan)
Definition: channel.h:2466
struct ast_party_connected_line connected
Channel Connected Line ID information.
Definition: channel.h:811
#define ARRAY_LEN(a)
Definition: isdn_lib.c:42
struct ast_party_id id
Connected party ID.
Definition: channel.h:403
const char * ast_connected_line_source_name(int data)
Convert connected line update source value to text code.
Definition: callerid.c:1291
static enum ID_FIELD_STATUS party_id_read(char *buf, size_t len, int argc, char *argv[], const struct ast_party_id *id)
#define ast_strdupa(s)
duplicate a string in memory from the stack
Definition: utils.h:663
#define LOG_ERROR
Definition: logger.h:155
static int len(struct ast_channel *chan, const char *cmd, char *data, char *buf, size_t buflen)
void ast_log(int level, const char *file, int line, const char *function, const char *fmt,...)
Used for sending a log message This is the standard logger function. Probably the only way you will i...
Definition: logger.c:1207
#define ast_channel_unlock(chan)
Definition: channel.h:2467
int source
Information about the source of an update.
Definition: channel.h:424
ID_FIELD_STATUS
void ast_copy_string(char *dst, const char *src, size_t size)
Size-limited null-terminating string copy.
Definition: strings.h:223
#define AST_NONSTANDARD_APP_ARGS(args, parse, sep)
Performs the &#39;nonstandard&#39; argument separation process for an application.
Definition: app.h:619
jack_status_t status
Definition: app_jack.c:143
static int connectedline_write ( struct ast_channel chan,
const char *  cmd,
char *  data,
const char *  value 
)
static

Definition at line 1243 of file func_callerid.c.

References ast_party_func_args::argc, ast_party_members::argc, ast_party_members::argv, ARRAY_LEN, ast_app_parse_options(), ast_channel_lock, ast_channel_set_connected_line(), ast_channel_unlock, ast_channel_update_connected_line(), ast_connected_line_source_parse(), ast_log(), AST_NONSTANDARD_APP_ARGS, ast_party_connected_line_free(), ast_party_connected_line_set_init(), ast_skip_blanks(), AST_STANDARD_APP_ARGS, ast_strdupa, ast_test_flag, ast_trim_blanks(), connected, ast_channel::connected, CONNECTED_LINE_OPT_ARG_ARRAY_SIZE, CONNECTED_LINE_OPT_INHIBIT, connectedline_opts, ast_party_connected_line::id, ID_FIELD_INVALID, ID_FIELD_VALID, LOG_ERROR, ast_party_func_args::member, ast_party_func_args::opts, party_id_write(), ast_party_connected_line::source, status, ast_party_members::subnames, and update().

1244 {
1246  enum ID_FIELD_STATUS status;
1247  char *val;
1248  char *parms;
1249  void (*set_it)(struct ast_channel *chan, const struct ast_party_connected_line *connected, const struct ast_set_party_connected_line *update);
1250  struct ast_party_func_args args;
1251  struct ast_party_members member;
1252  struct ast_flags opts;
1253  char *opt_args[CONNECTED_LINE_OPT_ARG_ARRAY_SIZE];
1254 
1255  if (!value || !chan) {
1256  return -1;
1257  }
1258 
1259  parms = ast_strdupa(data);
1260  AST_STANDARD_APP_ARGS(args, parms);
1261  if (args.argc == 0) {
1262  /* Must have at least one argument. */
1263  return -1;
1264  }
1265 
1266  AST_NONSTANDARD_APP_ARGS(member, args.member, '-');
1267  if (member.argc == 0 || ARRAY_LEN(member.subnames) <= member.argc) {
1268  /* Too few or too many subnames */
1269  return -1;
1270  }
1271 
1272  if (ast_app_parse_options(connectedline_opts, &opts, opt_args, args.opts)) {
1273  /* General invalid option syntax. */
1274  return -1;
1275  }
1276 
1277  /* Determine if the update indication inhibit option is present */
1280  } else {
1282  }
1283 
1284  ast_channel_lock(chan);
1285  ast_party_connected_line_set_init(&connected, &chan->connected);
1286  ast_channel_unlock(chan);
1287 
1289 
1290  if (member.argc == 1 && !strcasecmp("source", member.argv[0])) {
1291  int source;
1292 
1293  val = ast_strdupa(value);
1294  ast_trim_blanks(val);
1295 
1296  if (('0' <= val[0]) && (val[0] <= '9')) {
1297  source = atoi(val);
1298  } else {
1299  source = ast_connected_line_source_parse(val);
1300  }
1301 
1302  if (source < 0) {
1303  ast_log(LOG_ERROR, "Unknown connectedline source '%s', value unchanged\n", val);
1304  } else {
1305  connected.source = source;
1306  set_it(chan, &connected, NULL);
1307  }
1308  } else {
1309  status = party_id_write(&connected.id, member.argc, member.argv, value);
1310  switch (status) {
1311  case ID_FIELD_VALID:
1312  set_it(chan, &connected, NULL);
1313  break;
1314  case ID_FIELD_INVALID:
1315  break;
1316  default:
1317  ast_log(LOG_ERROR, "Unknown connectedline data type '%s'.\n", data);
1318  break;
1319  }
1320  ast_party_connected_line_free(&connected);
1321  }
1322 
1323  return 0;
1324 }
#define ast_channel_lock(chan)
Definition: channel.h:2466
Main Channel structure associated with a channel.
Definition: channel.h:742
static struct ast_app_option connectedline_opts[128]
struct ast_party_connected_line connected
Channel Connected Line ID information.
Definition: channel.h:811
#define ARRAY_LEN(a)
Definition: isdn_lib.c:42
int ast_connected_line_source_parse(const char *data)
Convert connected line update source text code to value (used in config file parsing) ...
Definition: callerid.c:1265
Definition: ast_expr2.c:325
struct ast_party_id id
Connected party ID.
Definition: channel.h:403
void ast_party_connected_line_set_init(struct ast_party_connected_line *init, const struct ast_party_connected_line *guide)
Initialize the given connected line structure using the given guide for a set update operation...
Definition: channel.c:2329
#define ast_test_flag(p, flag)
Definition: utils.h:63
static void update(int code_size, int y, int wi, int fi, int dq, int sr, int dqsez, struct g726_state *state_ptr)
Definition: codec_g726.c:367
void ast_channel_update_connected_line(struct ast_channel *chan, const struct ast_party_connected_line *connected, const struct ast_set_party_connected_line *update)
Indicate that the connected line information has changed.
Definition: channel.c:9085
int ast_app_parse_options(const struct ast_app_option *options, struct ast_flags *flags, char **args, char *optstr)
Parses a string containing application options and sets flags/arguments.
Definition: app.c:2101
void ast_party_connected_line_free(struct ast_party_connected_line *doomed)
Destroy the connected line information contents.
Definition: channel.c:2353
int value
Definition: syslog.c:39
#define ast_strdupa(s)
duplicate a string in memory from the stack
Definition: utils.h:663
#define LOG_ERROR
Definition: logger.h:155
static struct @350 args
Connected Line/Party information.
Definition: channel.h:401
char * ast_skip_blanks(const char *str)
Gets a pointer to the first non-whitespace character in a string.
Definition: strings.h:97
void ast_log(int level, const char *file, int line, const char *function, const char *fmt,...)
Used for sending a log message This is the standard logger function. Probably the only way you will i...
Definition: logger.c:1207
char * ast_trim_blanks(char *str)
Trims trailing whitespace characters from a string.
Definition: strings.h:122
#define ast_channel_unlock(chan)
Definition: channel.h:2467
int source
Information about the source of an update.
Definition: channel.h:424
ID_FIELD_STATUS
Structure used to handle boolean flags.
Definition: utils.h:200
Indicate what information in ast_party_connected_line should be set.
Definition: channel.h:431
static enum ID_FIELD_STATUS party_id_write(struct ast_party_id *id, int argc, char *argv[], const char *value)
static int connected
Definition: cdr_pgsql.c:57
#define AST_STANDARD_APP_ARGS(args, parse)
Performs the &#39;standard&#39; argument separation process for an application.
Definition: app.h:604
#define AST_NONSTANDARD_APP_ARGS(args, parse, sep)
Performs the &#39;nonstandard&#39; argument separation process for an application.
Definition: app.h:619
void ast_channel_set_connected_line(struct ast_channel *chan, const struct ast_party_connected_line *connected, const struct ast_set_party_connected_line *update)
Set the connected line information in the Asterisk channel.
Definition: channel.c:8458
jack_status_t status
Definition: app_jack.c:143
static int load_module ( void  )
static

Definition at line 1598 of file func_callerid.c.

References ast_custom_function_register, AST_MODULE_LOAD_DECLINE, and AST_MODULE_LOAD_SUCCESS.

1599 {
1600  int res;
1601 
1607 }
static struct ast_custom_function redirecting_function
static struct ast_custom_function callerid_function
static struct ast_custom_function callerpres_function
#define ast_custom_function_register(acf)
Register a custom function.
Definition: pbx.h:1164
static struct ast_custom_function connectedline_function
static enum ID_FIELD_STATUS party_id_read ( char *  buf,
size_t  len,
int  argc,
char *  argv[],
const struct ast_party_id id 
)
static

Definition at line 489 of file func_callerid.c.

References ast_copy_string(), ast_named_caller_presentation(), ast_party_id_presentation(), ID_FIELD_UNKNOWN, ID_FIELD_VALID, ast_party_id::name, ast_party_id::number, party_name_read(), party_number_read(), party_subaddress_read(), ast_party_number::plan, S_COR, status, ast_party_name::str, ast_party_number::str, ast_party_id::subaddress, ast_party_id::tag, ast_party_name::valid, and ast_party_number::valid.

Referenced by callerid_read(), connectedline_read(), and redirecting_read().

490 {
491  enum ID_FIELD_STATUS status;
492 
493  if (argc == 0) {
494  /* Must have at least one subname. */
495  return ID_FIELD_UNKNOWN;
496  }
497 
498  status = ID_FIELD_VALID;
499 
500  if (argc == 1 && !strcasecmp("all", argv[0])) {
501  snprintf(buf, len, "\"%s\" <%s>",
502  S_COR(id->name.valid, id->name.str, ""),
503  S_COR(id->number.valid, id->number.str, ""));
504  } else if (!strcasecmp("name", argv[0])) {
505  status = party_name_read(buf, len, argc - 1, argv + 1, &id->name);
506  } else if (!strncasecmp("num", argv[0], 3)) {
507  /* Accept num[ber] */
508  status = party_number_read(buf, len, argc - 1, argv + 1, &id->number);
509  } else if (!strncasecmp("subaddr", argv[0], 7)) {
510  /* Accept subaddr[ess] */
511  status = party_subaddress_read(buf, len, argc - 1, argv + 1, &id->subaddress);
512  } else if (argc == 1 && !strcasecmp("tag", argv[0])) {
513  if (id->tag) {
514  ast_copy_string(buf, id->tag, len);
515  }
516  } else if (argc == 1 && !strcasecmp("ton", argv[0])) {
517  /* ton is an alias for num-plan */
518  snprintf(buf, len, "%d", id->number.plan);
519  } else if (argc == 1 && !strncasecmp("pres", argv[0], 4)) {
520  /*
521  * Accept pres[entation]
522  * This is the combined name/number presentation.
523  */
524  ast_copy_string(buf,
526  } else {
527  status = ID_FIELD_UNKNOWN;
528  }
529 
530  return status;
531 }
char * str
Subscriber phone number (Malloced)
Definition: channel.h:241
const char * ast_named_caller_presentation(int data)
Convert caller ID pres value to text code.
Definition: callerid.c:1183
struct ast_party_name name
Subscriber name.
Definition: channel.h:290
int ast_party_id_presentation(const struct ast_party_id *id)
Determine the overall presentation value for the given party.
Definition: channel.c:2151
char * str
Subscriber name (Malloced)
Definition: channel.h:214
static enum ID_FIELD_STATUS party_number_read(char *buf, size_t len, int argc, char *argv[], const struct ast_party_number *number)
static enum ID_FIELD_STATUS party_name_read(char *buf, size_t len, int argc, char *argv[], const struct ast_party_name *name)
static enum ID_FIELD_STATUS party_subaddress_read(char *buf, size_t len, int argc, char *argv[], const struct ast_party_subaddress *subaddress)
#define S_COR(a, b, c)
returns the equivalent of logic or for strings, with an additional boolean check: second one if not e...
Definition: strings.h:83
struct ast_party_subaddress subaddress
Subscriber subaddress.
Definition: channel.h:294
int plan
Q.931 Type-Of-Number and Numbering-Plan encoded fields.
Definition: channel.h:243
static int len(struct ast_channel *chan, const char *cmd, char *data, char *buf, size_t buflen)
ID_FIELD_STATUS
char * tag
User-set &quot;tag&quot;.
Definition: channel.h:304
void ast_copy_string(char *dst, const char *src, size_t size)
Size-limited null-terminating string copy.
Definition: strings.h:223
unsigned char valid
TRUE if the name information is valid/present.
Definition: channel.h:229
unsigned char valid
TRUE if the number information is valid/present.
Definition: channel.h:247
jack_status_t status
Definition: app_jack.c:143
struct ast_party_number number
Subscriber phone number.
Definition: channel.h:292
static enum ID_FIELD_STATUS party_id_write ( struct ast_party_id id,
int  argc,
char *  argv[],
const char *  value 
)
static

Definition at line 724 of file func_callerid.c.

References ast_callerid_split(), ast_log(), ast_parse_caller_presentation(), ast_strdup, ast_strdupa, ast_trim_blanks(), ID_FIELD_INVALID, ID_FIELD_UNKNOWN, ID_FIELD_VALID, LOG_ERROR, name, ast_party_id::name, ast_party_id::number, party_name_write(), party_number_write(), party_subaddress_write(), status, ast_party_name::str, ast_party_number::str, ast_party_id::subaddress, and ast_party_id::tag.

Referenced by callerid_write(), connectedline_write(), and redirecting_write().

725 {
726  char *val;
727  enum ID_FIELD_STATUS status;
728 
729  if (argc == 0) {
730  /* Must have at least one subname. */
731  return ID_FIELD_UNKNOWN;
732  }
733 
734  status = ID_FIELD_VALID;
735 
736  if (argc == 1 && !strcasecmp("all", argv[0])) {
737  char name[256];
738  char num[256];
739 
740  ast_callerid_split(value, name, sizeof(name), num, sizeof(num));
741  id->name.valid = 1;
742  id->name.str = ast_strdup(name);
743  if (!id->name.str) {
744  return ID_FIELD_INVALID;
745  }
746  id->number.valid = 1;
747  id->number.str = ast_strdup(num);
748  if (!id->number.str) {
749  return ID_FIELD_INVALID;
750  }
751  } else if (!strcasecmp("name", argv[0])) {
752  status = party_name_write(&id->name, argc - 1, argv + 1, value);
753  } else if (!strncasecmp("num", argv[0], 3)) {
754  /* Accept num[ber] */
755  status = party_number_write(&id->number, argc - 1, argv + 1, value);
756  } else if (!strncasecmp("subaddr", argv[0], 7)) {
757  /* Accept subaddr[ess] */
758  status = party_subaddress_write(&id->subaddress, argc - 1, argv + 1, value);
759  } else if (argc == 1 && !strcasecmp("tag", argv[0])) {
760  id->tag = ast_strdup(value);
761  ast_trim_blanks(id->tag);
762  } else if (argc == 1 && !strcasecmp("ton", argv[0])) {
763  /* ton is an alias for num-plan */
764  argv[0] = "plan";
765  status = party_number_write(&id->number, argc, argv, value);
766  } else if (argc == 1 && !strncasecmp("pres", argv[0], 4)) {
767  int pres;
768 
769  /*
770  * Accept pres[entation]
771  * This is the combined name/number presentation.
772  */
773  val = ast_strdupa(value);
774  ast_trim_blanks(val);
775 
776  if (('0' <= val[0]) && (val[0] <= '9')) {
777  pres = atoi(val);
778  } else {
779  pres = ast_parse_caller_presentation(val);
780  }
781 
782  if (pres < 0) {
784  "Unknown combined presentation '%s', value unchanged\n", val);
785  status = ID_FIELD_INVALID;
786  } else {
787  id->name.presentation = pres;
788  id->number.presentation = pres;
789  }
790  } else {
791  status = ID_FIELD_UNKNOWN;
792  }
793 
794  return status;
795 }
static enum ID_FIELD_STATUS party_subaddress_write(struct ast_party_subaddress *subaddress, int argc, char *argv[], const char *value)
char * str
Subscriber phone number (Malloced)
Definition: channel.h:241
int ast_callerid_split(const char *src, char *name, int namelen, char *num, int numlen)
Definition: callerid.c:1093
#define ast_strdup(a)
Definition: astmm.h:109
Definition: ast_expr2.c:325
struct ast_party_name name
Subscriber name.
Definition: channel.h:290
static enum ID_FIELD_STATUS party_name_write(struct ast_party_name *name, int argc, char *argv[], const char *value)
char * str
Subscriber name (Malloced)
Definition: channel.h:214
int value
Definition: syslog.c:39
static enum ID_FIELD_STATUS party_number_write(struct ast_party_number *number, int argc, char *argv[], const char *value)
int ast_parse_caller_presentation(const char *data)
Convert caller ID text code to value (used in config file parsing)
Definition: callerid.c:1144
#define ast_strdupa(s)
duplicate a string in memory from the stack
Definition: utils.h:663
struct ast_party_subaddress subaddress
Subscriber subaddress.
Definition: channel.h:294
#define LOG_ERROR
Definition: logger.h:155
void ast_log(int level, const char *file, int line, const char *function, const char *fmt,...)
Used for sending a log message This is the standard logger function. Probably the only way you will i...
Definition: logger.c:1207
char * ast_trim_blanks(char *str)
Trims trailing whitespace characters from a string.
Definition: strings.h:122
static const char name[]
ID_FIELD_STATUS
char * tag
User-set &quot;tag&quot;.
Definition: channel.h:304
jack_status_t status
Definition: app_jack.c:143
struct ast_party_number number
Subscriber phone number.
Definition: channel.h:292
static enum ID_FIELD_STATUS party_name_read ( char *  buf,
size_t  len,
int  argc,
char *  argv[],
const struct ast_party_name name 
)
static

Definition at line 373 of file func_callerid.c.

References ast_copy_string(), ast_named_caller_presentation(), ast_party_name_charset_str(), ast_party_name::char_set, ID_FIELD_UNKNOWN, ID_FIELD_VALID, ast_party_name::presentation, status, ast_party_name::str, and ast_party_name::valid.

Referenced by party_id_read().

374 {
375  enum ID_FIELD_STATUS status;
376 
377  status = ID_FIELD_VALID;
378 
379  if (argc == 0) {
380  /* We want the name string */
381  if (name->valid && name->str) {
382  ast_copy_string(buf, name->str, len);
383  }
384  } else if (argc == 1 && !strcasecmp("valid", argv[0])) {
385  snprintf(buf, len, "%d", name->valid);
386  } else if (argc == 1 && !strcasecmp("charset", argv[0])) {
388  } else if (argc == 1 && !strncasecmp("pres", argv[0], 4)) {
389  /* Accept pres[entation] */
391  } else {
392  status = ID_FIELD_UNKNOWN;
393  }
394 
395  return status;
396 }
int presentation
Q.931 encoded presentation-indicator encoded field.
Definition: channel.h:227
const char * ast_named_caller_presentation(int data)
Convert caller ID pres value to text code.
Definition: callerid.c:1183
int char_set
Character set the name is using.
Definition: channel.h:222
char * str
Subscriber name (Malloced)
Definition: channel.h:214
static int len(struct ast_channel *chan, const char *cmd, char *data, char *buf, size_t buflen)
ID_FIELD_STATUS
const char * ast_party_name_charset_str(int data)
Convert ast_party_name.char_set value to text code.
Definition: callerid.c:1346
void ast_copy_string(char *dst, const char *src, size_t size)
Size-limited null-terminating string copy.
Definition: strings.h:223
unsigned char valid
TRUE if the name information is valid/present.
Definition: channel.h:229
jack_status_t status
Definition: app_jack.c:143
static enum ID_FIELD_STATUS party_name_write ( struct ast_party_name name,
int  argc,
char *  argv[],
const char *  value 
)
static

Definition at line 547 of file func_callerid.c.

References ast_log(), ast_parse_caller_presentation(), ast_party_name_charset_parse(), ast_strdup, ast_strdupa, ast_trim_blanks(), ast_party_name::char_set, ID_FIELD_INVALID, ID_FIELD_UNKNOWN, ID_FIELD_VALID, LOG_ERROR, ast_party_name::presentation, status, ast_party_name::str, and ast_party_name::valid.

Referenced by party_id_write().

548 {
549  char *val;
550  enum ID_FIELD_STATUS status;
551 
552  status = ID_FIELD_VALID;
553 
554  if (argc == 0) {
555  /* We are setting the name string */
556  name->valid = 1;
557  name->str = ast_strdup(value);
558  ast_trim_blanks(name->str);
559  } else if (argc == 1 && !strcasecmp("valid", argv[0])) {
560  name->valid = atoi(value) ? 1 : 0;
561  } else if (argc == 1 && !strcasecmp("charset", argv[0])) {
562  int char_set;
563 
564  val = ast_strdupa(value);
565  ast_trim_blanks(val);
566 
567  if (('0' <= val[0]) && (val[0] <= '9')) {
568  char_set = atoi(val);
569  } else {
570  char_set = ast_party_name_charset_parse(val);
571  }
572 
573  if (char_set < 0) {
575  "Unknown name char-set '%s', value unchanged\n", val);
576  status = ID_FIELD_INVALID;
577  } else {
578  name->char_set = char_set;
579  }
580  } else if (argc == 1 && !strncasecmp("pres", argv[0], 4)) {
581  int pres;
582 
583  /* Accept pres[entation] */
584  val = ast_strdupa(value);
585  ast_trim_blanks(val);
586 
587  if (('0' <= val[0]) && (val[0] <= '9')) {
588  pres = atoi(val);
589  } else {
590  pres = ast_parse_caller_presentation(val);
591  }
592 
593  if (pres < 0) {
595  "Unknown name presentation '%s', value unchanged\n", val);
596  status = ID_FIELD_INVALID;
597  } else {
598  name->presentation = pres;
599  }
600  } else {
601  status = ID_FIELD_UNKNOWN;
602  }
603 
604  return status;
605 }
int presentation
Q.931 encoded presentation-indicator encoded field.
Definition: channel.h:227
#define ast_strdup(a)
Definition: astmm.h:109
Definition: ast_expr2.c:325
int char_set
Character set the name is using.
Definition: channel.h:222
char * str
Subscriber name (Malloced)
Definition: channel.h:214
int value
Definition: syslog.c:39
int ast_party_name_charset_parse(const char *data)
Convert ast_party_name.char_set text code to value (used in config file parsing)
Definition: callerid.c:1320
int ast_parse_caller_presentation(const char *data)
Convert caller ID text code to value (used in config file parsing)
Definition: callerid.c:1144
#define ast_strdupa(s)
duplicate a string in memory from the stack
Definition: utils.h:663
#define LOG_ERROR
Definition: logger.h:155
void ast_log(int level, const char *file, int line, const char *function, const char *fmt,...)
Used for sending a log message This is the standard logger function. Probably the only way you will i...
Definition: logger.c:1207
char * ast_trim_blanks(char *str)
Trims trailing whitespace characters from a string.
Definition: strings.h:122
ID_FIELD_STATUS
unsigned char valid
TRUE if the name information is valid/present.
Definition: channel.h:229
jack_status_t status
Definition: app_jack.c:143
static enum ID_FIELD_STATUS party_number_read ( char *  buf,
size_t  len,
int  argc,
char *  argv[],
const struct ast_party_number number 
)
static

Definition at line 412 of file func_callerid.c.

References ast_copy_string(), ast_named_caller_presentation(), ID_FIELD_UNKNOWN, ID_FIELD_VALID, ast_party_number::plan, ast_party_number::presentation, status, ast_party_number::str, and ast_party_number::valid.

Referenced by party_id_read().

413 {
414  enum ID_FIELD_STATUS status;
415 
416  status = ID_FIELD_VALID;
417 
418  if (argc == 0) {
419  /* We want the number string */
420  if (number->valid && number->str) {
421  ast_copy_string(buf, number->str, len);
422  }
423  } else if (argc == 1 && !strcasecmp("valid", argv[0])) {
424  snprintf(buf, len, "%d", number->valid);
425  } else if (argc == 1 && !strcasecmp("plan", argv[0])) {
426  snprintf(buf, len, "%d", number->plan);
427  } else if (argc == 1 && !strncasecmp("pres", argv[0], 4)) {
428  /* Accept pres[entation] */
430  } else {
431  status = ID_FIELD_UNKNOWN;
432  }
433 
434  return status;
435 }
char * str
Subscriber phone number (Malloced)
Definition: channel.h:241
const char * ast_named_caller_presentation(int data)
Convert caller ID pres value to text code.
Definition: callerid.c:1183
int presentation
Q.931 presentation-indicator and screening-indicator encoded fields.
Definition: channel.h:245
int plan
Q.931 Type-Of-Number and Numbering-Plan encoded fields.
Definition: channel.h:243
static int len(struct ast_channel *chan, const char *cmd, char *data, char *buf, size_t buflen)
ID_FIELD_STATUS
void ast_copy_string(char *dst, const char *src, size_t size)
Size-limited null-terminating string copy.
Definition: strings.h:223
unsigned char valid
TRUE if the number information is valid/present.
Definition: channel.h:247
jack_status_t status
Definition: app_jack.c:143
static enum ID_FIELD_STATUS party_number_write ( struct ast_party_number number,
int  argc,
char *  argv[],
const char *  value 
)
static

Definition at line 621 of file func_callerid.c.

References ast_log(), ast_parse_caller_presentation(), ast_strdup, ast_strdupa, ast_trim_blanks(), ID_FIELD_INVALID, ID_FIELD_UNKNOWN, ID_FIELD_VALID, LOG_ERROR, ast_party_number::plan, ast_party_number::presentation, status, ast_party_number::str, and ast_party_number::valid.

Referenced by party_id_write().

622 {
623  char *val;
624  enum ID_FIELD_STATUS status;
625 
626  status = ID_FIELD_VALID;
627 
628  if (argc == 0) {
629  /* We are setting the number string */
630  number->valid = 1;
631  number->str = ast_strdup(value);
632  ast_trim_blanks(number->str);
633  } else if (argc == 1 && !strcasecmp("valid", argv[0])) {
634  number->valid = atoi(value) ? 1 : 0;
635  } else if (argc == 1 && !strcasecmp("plan", argv[0])) {
636  val = ast_strdupa(value);
637  ast_trim_blanks(val);
638 
639  if (('0' <= val[0]) && (val[0] <= '9')) {
640  number->plan = atoi(val);
641  } else {
643  "Unknown type-of-number/numbering-plan '%s', value unchanged\n", val);
644  status = ID_FIELD_INVALID;
645  }
646  } else if (argc == 1 && !strncasecmp("pres", argv[0], 4)) {
647  int pres;
648 
649  /* Accept pres[entation] */
650  val = ast_strdupa(value);
651  ast_trim_blanks(val);
652 
653  if (('0' <= val[0]) && (val[0] <= '9')) {
654  pres = atoi(val);
655  } else {
656  pres = ast_parse_caller_presentation(val);
657  }
658 
659  if (pres < 0) {
661  "Unknown number presentation '%s', value unchanged\n", val);
662  status = ID_FIELD_INVALID;
663  } else {
664  number->presentation = pres;
665  }
666  } else {
667  status = ID_FIELD_UNKNOWN;
668  }
669 
670  return status;
671 }
char * str
Subscriber phone number (Malloced)
Definition: channel.h:241
int presentation
Q.931 presentation-indicator and screening-indicator encoded fields.
Definition: channel.h:245
#define ast_strdup(a)
Definition: astmm.h:109
Definition: ast_expr2.c:325
int value
Definition: syslog.c:39
int ast_parse_caller_presentation(const char *data)
Convert caller ID text code to value (used in config file parsing)
Definition: callerid.c:1144
#define ast_strdupa(s)
duplicate a string in memory from the stack
Definition: utils.h:663
#define LOG_ERROR
Definition: logger.h:155
int plan
Q.931 Type-Of-Number and Numbering-Plan encoded fields.
Definition: channel.h:243
void ast_log(int level, const char *file, int line, const char *function, const char *fmt,...)
Used for sending a log message This is the standard logger function. Probably the only way you will i...
Definition: logger.c:1207
char * ast_trim_blanks(char *str)
Trims trailing whitespace characters from a string.
Definition: strings.h:122
ID_FIELD_STATUS
unsigned char valid
TRUE if the number information is valid/present.
Definition: channel.h:247
jack_status_t status
Definition: app_jack.c:143
static enum ID_FIELD_STATUS party_subaddress_read ( char *  buf,
size_t  len,
int  argc,
char *  argv[],
const struct ast_party_subaddress subaddress 
)
static

Definition at line 451 of file func_callerid.c.

References ast_copy_string(), ID_FIELD_UNKNOWN, ID_FIELD_VALID, ast_party_subaddress::odd_even_indicator, status, ast_party_subaddress::str, ast_party_subaddress::type, and ast_party_subaddress::valid.

Referenced by callerid_read(), and party_id_read().

452 {
453  enum ID_FIELD_STATUS status;
454 
455  status = ID_FIELD_VALID;
456 
457  if (argc == 0) {
458  /* We want the subaddress string */
459  if (subaddress->str) {
460  ast_copy_string(buf, subaddress->str, len);
461  }
462  } else if (argc == 1 && !strcasecmp("valid", argv[0])) {
463  snprintf(buf, len, "%d", subaddress->valid);
464  } else if (argc == 1 && !strcasecmp("type", argv[0])) {
465  snprintf(buf, len, "%d", subaddress->type);
466  } else if (argc == 1 && !strcasecmp("odd", argv[0])) {
467  snprintf(buf, len, "%d", subaddress->odd_even_indicator);
468  } else {
469  status = ID_FIELD_UNKNOWN;
470  }
471 
472  return status;
473 }
unsigned char valid
TRUE if the subaddress information is valid/present.
Definition: channel.h:278
char * str
Malloced subaddress string.
Definition: channel.h:263
unsigned char odd_even_indicator
TRUE if odd number of address signals.
Definition: channel.h:276
static int len(struct ast_channel *chan, const char *cmd, char *data, char *buf, size_t buflen)
ID_FIELD_STATUS
int type
Q.931 subaddress type.
Definition: channel.h:270
void ast_copy_string(char *dst, const char *src, size_t size)
Size-limited null-terminating string copy.
Definition: strings.h:223
jack_status_t status
Definition: app_jack.c:143
static enum ID_FIELD_STATUS party_subaddress_write ( struct ast_party_subaddress subaddress,
int  argc,
char *  argv[],
const char *  value 
)
static

Definition at line 687 of file func_callerid.c.

References ast_strdup, ast_trim_blanks(), ID_FIELD_UNKNOWN, ID_FIELD_VALID, ast_party_subaddress::odd_even_indicator, status, ast_party_subaddress::str, ast_party_subaddress::type, and ast_party_subaddress::valid.

Referenced by callerid_write(), and party_id_write().

688 {
689  enum ID_FIELD_STATUS status;
690 
691  status = ID_FIELD_VALID;
692 
693  if (argc == 0) {
694  /* We are setting the subaddress string */
695  subaddress->str = ast_strdup(value);
696  ast_trim_blanks(subaddress->str);
697  } else if (argc == 1 && !strcasecmp("valid", argv[0])) {
698  subaddress->valid = atoi(value) ? 1 : 0;
699  } else if (argc == 1 && !strcasecmp("type", argv[0])) {
700  subaddress->type = atoi(value) ? 2 : 0;
701  } else if (argc == 1 && !strcasecmp("odd", argv[0])) {
702  subaddress->odd_even_indicator = atoi(value) ? 1 : 0;
703  } else {
704  status = ID_FIELD_UNKNOWN;
705  }
706 
707  return status;
708 }
#define ast_strdup(a)
Definition: astmm.h:109
unsigned char valid
TRUE if the subaddress information is valid/present.
Definition: channel.h:278
char * str
Malloced subaddress string.
Definition: channel.h:263
int value
Definition: syslog.c:39
unsigned char odd_even_indicator
TRUE if odd number of address signals.
Definition: channel.h:276
char * ast_trim_blanks(char *str)
Trims trailing whitespace characters from a string.
Definition: strings.h:122
ID_FIELD_STATUS
int type
Q.931 subaddress type.
Definition: channel.h:270
jack_status_t status
Definition: app_jack.c:143
static int redirecting_read ( struct ast_channel chan,
const char *  cmd,
char *  data,
char *  buf,
size_t  len 
)
static

Definition at line 1339 of file func_callerid.c.

References ast_party_members::argc, ast_party_members::argv, ARRAY_LEN, ast_channel_lock, ast_channel_unlock, ast_copy_string(), ast_log(), ast_named_caller_presentation(), AST_NONSTANDARD_APP_ARGS, ast_party_id_presentation(), ast_redirecting_reason_name(), ast_strdupa, ast_party_redirecting::count, ast_party_redirecting::from, ID_FIELD_INVALID, ID_FIELD_VALID, LOG_ERROR, party_id_read(), ast_party_redirecting::reason, ast_channel::redirecting, status, ast_party_members::subnames, and ast_party_redirecting::to.

1340 {
1341  struct ast_party_members member;
1342  char *read_what;
1343  enum ID_FIELD_STATUS status;
1344 
1345  /* Ensure that the buffer is empty */
1346  *buf = 0;
1347 
1348  if (!chan) {
1349  return -1;
1350  }
1351 
1352  read_what = ast_strdupa(data);
1353  AST_NONSTANDARD_APP_ARGS(member, read_what, '-');
1354  if (member.argc == 0 || ARRAY_LEN(member.subnames) <= member.argc) {
1355  /* Too few or too many subnames */
1356  return -1;
1357  }
1358 
1359  ast_channel_lock(chan);
1360 
1361  if (!strcasecmp("from", member.argv[0])) {
1362  status = party_id_read(buf, len, member.argc - 1, member.argv + 1,
1363  &chan->redirecting.from);
1364  switch (status) {
1365  case ID_FIELD_VALID:
1366  case ID_FIELD_INVALID:
1367  break;
1368  default:
1369  ast_log(LOG_ERROR, "Unknown redirecting data type '%s'.\n", data);
1370  break;
1371  }
1372  } else if (!strcasecmp("to", member.argv[0])) {
1373  status = party_id_read(buf, len, member.argc - 1, member.argv + 1,
1374  &chan->redirecting.to);
1375  switch (status) {
1376  case ID_FIELD_VALID:
1377  case ID_FIELD_INVALID:
1378  break;
1379  default:
1380  ast_log(LOG_ERROR, "Unknown redirecting data type '%s'.\n", data);
1381  break;
1382  }
1383  } else if (member.argc == 1 && !strncasecmp("pres", member.argv[0], 4)) {
1384  /*
1385  * Accept pres[entation]
1386  * This is the combined from name/number presentation.
1387  */
1388  ast_copy_string(buf,
1391  } else if (member.argc == 1 && !strcasecmp("reason", member.argv[0])) {
1393  } else if (member.argc == 1 && !strcasecmp("count", member.argv[0])) {
1394  snprintf(buf, len, "%d", chan->redirecting.count);
1395  } else {
1396  ast_log(LOG_ERROR, "Unknown redirecting data type '%s'.\n", data);
1397  }
1398 
1399  ast_channel_unlock(chan);
1400 
1401  return 0;
1402 }
#define ast_channel_lock(chan)
Definition: channel.h:2466
const char * ast_named_caller_presentation(int data)
Convert caller ID pres value to text code.
Definition: callerid.c:1183
#define ARRAY_LEN(a)
Definition: isdn_lib.c:42
struct ast_party_id from
Who is redirecting the call (Sent to the party the call is redirected toward)
Definition: channel.h:449
int ast_party_id_presentation(const struct ast_party_id *id)
Determine the overall presentation value for the given party.
Definition: channel.c:2151
struct ast_party_redirecting redirecting
Redirecting/Diversion information.
Definition: channel.h:814
const char * ast_redirecting_reason_name(int data)
Convert redirecting reason value to text code.
Definition: callerid.c:1240
static enum ID_FIELD_STATUS party_id_read(char *buf, size_t len, int argc, char *argv[], const struct ast_party_id *id)
#define ast_strdupa(s)
duplicate a string in memory from the stack
Definition: utils.h:663
#define LOG_ERROR
Definition: logger.h:155
static int len(struct ast_channel *chan, const char *cmd, char *data, char *buf, size_t buflen)
void ast_log(int level, const char *file, int line, const char *function, const char *fmt,...)
Used for sending a log message This is the standard logger function. Probably the only way you will i...
Definition: logger.c:1207
#define ast_channel_unlock(chan)
Definition: channel.h:2467
ID_FIELD_STATUS
int count
Number of times the call was redirected.
Definition: channel.h:455
struct ast_party_id to
Call is redirecting to a new party (Sent to the caller)
Definition: channel.h:452
void ast_copy_string(char *dst, const char *src, size_t size)
Size-limited null-terminating string copy.
Definition: strings.h:223
#define AST_NONSTANDARD_APP_ARGS(args, parse, sep)
Performs the &#39;nonstandard&#39; argument separation process for an application.
Definition: app.h:619
int reason
enum AST_REDIRECTING_REASON value for redirection
Definition: channel.h:458
jack_status_t status
Definition: app_jack.c:143
static int redirecting_write ( struct ast_channel chan,
const char *  cmd,
char *  data,
const char *  value 
)
static

Definition at line 1416 of file func_callerid.c.

References ast_party_func_args::argc, ast_party_members::argc, ast_party_members::argv, ARRAY_LEN, ast_app_parse_options(), ast_channel_lock, ast_channel_set_redirecting(), ast_channel_unlock, ast_channel_update_redirecting(), ast_log(), AST_NONSTANDARD_APP_ARGS, ast_parse_caller_presentation(), ast_party_redirecting_free(), ast_party_redirecting_set_init(), ast_redirecting_reason_parse(), ast_skip_blanks(), AST_STANDARD_APP_ARGS, ast_strdupa, ast_test_flag, ast_trim_blanks(), ast_party_redirecting::count, ast_party_redirecting::from, ID_FIELD_INVALID, ID_FIELD_VALID, LOG_ERROR, ast_party_func_args::member, ast_party_id::name, ast_party_id::number, ast_party_func_args::opts, party_id_write(), ast_party_name::presentation, ast_party_number::presentation, ast_party_redirecting::reason, ast_channel::redirecting, REDIRECTING_OPT_ARG_ARRAY_SIZE, REDIRECTING_OPT_INHIBIT, redirecting_opts, status, ast_party_members::subnames, ast_party_redirecting::to, and update().

1417 {
1418  struct ast_party_redirecting redirecting;
1419  enum ID_FIELD_STATUS status;
1420  char *val;
1421  char *parms;
1422  void (*set_it)(struct ast_channel *chan, const struct ast_party_redirecting *redirecting, const struct ast_set_party_redirecting *update);
1423  struct ast_party_func_args args;
1424  struct ast_party_members member;
1425  struct ast_flags opts;
1426  char *opt_args[REDIRECTING_OPT_ARG_ARRAY_SIZE];
1427 
1428  if (!value || !chan) {
1429  return -1;
1430  }
1431 
1432  parms = ast_strdupa(data);
1433  AST_STANDARD_APP_ARGS(args, parms);
1434  if (args.argc == 0) {
1435  /* Must have at least one argument. */
1436  return -1;
1437  }
1438 
1439  AST_NONSTANDARD_APP_ARGS(member, args.member, '-');
1440  if (member.argc == 0 || ARRAY_LEN(member.subnames) <= member.argc) {
1441  /* Too few or too many subnames */
1442  return -1;
1443  }
1444 
1445  if (ast_app_parse_options(redirecting_opts, &opts, opt_args, args.opts)) {
1446  /* General invalid option syntax. */
1447  return -1;
1448  }
1449 
1450  /* Determine if the update indication inhibit option is present */
1451  if (ast_test_flag(&opts, REDIRECTING_OPT_INHIBIT)) {
1452  set_it = ast_channel_set_redirecting;
1453  } else {
1455  }
1456 
1457  ast_channel_lock(chan);
1458  ast_party_redirecting_set_init(&redirecting, &chan->redirecting);
1459  ast_channel_unlock(chan);
1460 
1462 
1463  if (!strcasecmp("from", member.argv[0])) {
1464  status = party_id_write(&redirecting.from, member.argc - 1, member.argv + 1,
1465  value);
1466  switch (status) {
1467  case ID_FIELD_VALID:
1468  set_it(chan, &redirecting, NULL);
1469  break;
1470  case ID_FIELD_INVALID:
1471  break;
1472  default:
1473  ast_log(LOG_ERROR, "Unknown redirecting data type '%s'.\n", data);
1474  break;
1475  }
1476  ast_party_redirecting_free(&redirecting);
1477  } else if (!strcasecmp("to", member.argv[0])) {
1478  status = party_id_write(&redirecting.to, member.argc - 1, member.argv + 1, value);
1479  switch (status) {
1480  case ID_FIELD_VALID:
1481  set_it(chan, &redirecting, NULL);
1482  break;
1483  case ID_FIELD_INVALID:
1484  break;
1485  default:
1486  ast_log(LOG_ERROR, "Unknown redirecting data type '%s'.\n", data);
1487  break;
1488  }
1489  ast_party_redirecting_free(&redirecting);
1490  } else if (member.argc == 1 && !strncasecmp("pres", member.argv[0], 4)) {
1491  int pres;
1492 
1493  val = ast_strdupa(value);
1494  ast_trim_blanks(val);
1495 
1496  if (('0' <= val[0]) && (val[0] <= '9')) {
1497  pres = atoi(val);
1498  } else {
1499  pres = ast_parse_caller_presentation(val);
1500  }
1501 
1502  if (pres < 0) {
1504  "Unknown redirecting combined presentation '%s', value unchanged\n", val);
1505  } else {
1506  redirecting.from.name.presentation = pres;
1507  redirecting.from.number.presentation = pres;
1508  redirecting.to.name.presentation = pres;
1509  redirecting.to.number.presentation = pres;
1510  set_it(chan, &redirecting, NULL);
1511  }
1512  } else if (member.argc == 1 && !strcasecmp("reason", member.argv[0])) {
1513  int reason;
1514 
1515  val = ast_strdupa(value);
1516  ast_trim_blanks(val);
1517 
1518  if (('0' <= val[0]) && (val[0] <= '9')) {
1519  reason = atoi(val);
1520  } else {
1521  reason = ast_redirecting_reason_parse(val);
1522  }
1523 
1524  if (reason < 0) {
1525  ast_log(LOG_ERROR, "Unknown redirecting reason '%s', value unchanged\n", val);
1526  } else {
1527  redirecting.reason = reason;
1528  set_it(chan, &redirecting, NULL);
1529  }
1530  } else if (member.argc == 1 && !strcasecmp("count", member.argv[0])) {
1531  val = ast_strdupa(value);
1532  ast_trim_blanks(val);
1533 
1534  if (('0' <= val[0]) && (val[0] <= '9')) {
1535  redirecting.count = atoi(val);
1536  set_it(chan, &redirecting, NULL);
1537  } else {
1538  ast_log(LOG_ERROR, "Unknown redirecting count '%s', value unchanged\n", val);
1539  }
1540  } else {
1541  ast_log(LOG_ERROR, "Unknown redirecting data type '%s'.\n", data);
1542  }
1543 
1544  return 0;
1545 }
int presentation
Q.931 encoded presentation-indicator encoded field.
Definition: channel.h:227
#define ast_channel_lock(chan)
Definition: channel.h:2466
Main Channel structure associated with a channel.
Definition: channel.h:742
#define ARRAY_LEN(a)
Definition: isdn_lib.c:42
int presentation
Q.931 presentation-indicator and screening-indicator encoded fields.
Definition: channel.h:245
Definition: ast_expr2.c:325
#define ast_test_flag(p, flag)
Definition: utils.h:63
static void update(int code_size, int y, int wi, int fi, int dq, int sr, int dqsez, struct g726_state *state_ptr)
Definition: codec_g726.c:367
struct ast_party_name name
Subscriber name.
Definition: channel.h:290
struct ast_party_id from
Who is redirecting the call (Sent to the party the call is redirected toward)
Definition: channel.h:449
void ast_channel_update_redirecting(struct ast_channel *chan, const struct ast_party_redirecting *redirecting, const struct ast_set_party_redirecting *update)
Indicate that the redirecting id has changed.
Definition: channel.c:9592
int ast_app_parse_options(const struct ast_app_option *options, struct ast_flags *flags, char **args, char *optstr)
Parses a string containing application options and sets flags/arguments.
Definition: app.c:2101
int ast_redirecting_reason_parse(const char *data)
Convert redirecting reason text code to value (used in config file parsing)
Definition: callerid.c:1214
struct ast_party_redirecting redirecting
Redirecting/Diversion information.
Definition: channel.h:814
int value
Definition: syslog.c:39
void ast_channel_set_redirecting(struct ast_channel *chan, const struct ast_party_redirecting *redirecting, const struct ast_set_party_redirecting *update)
Set the redirecting id information in the Asterisk channel.
Definition: channel.c:9111
int ast_parse_caller_presentation(const char *data)
Convert caller ID text code to value (used in config file parsing)
Definition: callerid.c:1144
static struct ast_app_option redirecting_opts[128]
#define ast_strdupa(s)
duplicate a string in memory from the stack
Definition: utils.h:663
#define LOG_ERROR
Definition: logger.h:155
static struct @350 args
char * ast_skip_blanks(const char *str)
Gets a pointer to the first non-whitespace character in a string.
Definition: strings.h:97
void ast_log(int level, const char *file, int line, const char *function, const char *fmt,...)
Used for sending a log message This is the standard logger function. Probably the only way you will i...
Definition: logger.c:1207
Redirecting Line information. RDNIS (Redirecting Directory Number Information Service) Where a call d...
Definition: channel.h:447
char * ast_trim_blanks(char *str)
Trims trailing whitespace characters from a string.
Definition: strings.h:122
#define ast_channel_unlock(chan)
Definition: channel.h:2467
ID_FIELD_STATUS
Structure used to handle boolean flags.
Definition: utils.h:200
void ast_party_redirecting_free(struct ast_party_redirecting *doomed)
Destroy the redirecting information contents.
Definition: channel.c:2396
Indicate what information in ast_party_redirecting should be set.
Definition: channel.h:465
int count
Number of times the call was redirected.
Definition: channel.h:455
struct ast_party_id to
Call is redirecting to a new party (Sent to the caller)
Definition: channel.h:452
static enum ID_FIELD_STATUS party_id_write(struct ast_party_id *id, int argc, char *argv[], const char *value)
void ast_party_redirecting_set_init(struct ast_party_redirecting *init, const struct ast_party_redirecting *guide)
Initialize the given redirecting id structure using the given guide for a set update operation...
Definition: channel.c:2380
#define AST_STANDARD_APP_ARGS(args, parse)
Performs the &#39;standard&#39; argument separation process for an application.
Definition: app.h:604
#define AST_NONSTANDARD_APP_ARGS(args, parse, sep)
Performs the &#39;nonstandard&#39; argument separation process for an application.
Definition: app.h:619
int reason
enum AST_REDIRECTING_REASON value for redirection
Definition: channel.h:458
jack_status_t status
Definition: app_jack.c:143
struct ast_party_number number
Subscriber phone number.
Definition: channel.h:292
static int unload_module ( void  )
static

Definition at line 1580 of file func_callerid.c.

References ast_custom_function_unregister().

1581 {
1582  int res;
1583 
1588  return res;
1589 }
static struct ast_custom_function redirecting_function
static struct ast_custom_function callerid_function
int ast_custom_function_unregister(struct ast_custom_function *acf)
Unregister a custom function.
Definition: pbx.c:3814
static struct ast_custom_function callerpres_function
static struct ast_custom_function connectedline_function

Variable Documentation

struct ast_module_info __mod_info = { .name = AST_MODULE, .flags = AST_MODFLAG_LOAD_ORDER , .description = "Party ID related dialplan functions (Caller-ID, Connected-line, Redirecting)" , .key = "This paragraph is copyright (c) 2006 by Digium, Inc. \In order for your module to load, it must return this \key via a function called \"key\". Any code which \includes this paragraph must be licensed under the GNU \General Public License version 2 or later (at your \option). In addition to Digium's general reservations \of rights, Digium expressly reserves the right to \allow other parties to license this paragraph under \different terms. Any use of Digium, Inc. trademarks or \logos (including \"Asterisk\" or \"Digium\") without \express written permission of Digium, Inc. is prohibited.\n" , .buildopt_sum = "ac1f6a56484a8820659555499174e588" , .load = load_module, .unload = unload_module, .load_pri = AST_MODPRI_DEFAULT, }
static

Definition at line 1610 of file func_callerid.c.

Definition at line 1610 of file func_callerid.c.

struct ast_custom_function callerid_function
static

Definition at line 1547 of file func_callerid.c.

int callerpres_deprecate_notify
static

TRUE if we have already notified about CALLERPRES being deprecated.

Definition at line 798 of file func_callerid.c.

struct ast_custom_function callerpres_function
static

Definition at line 1554 of file func_callerid.c.

struct ast_custom_function connectedline_function
static
Initial value:
= {
.name = "CONNECTEDLINE",
}
static int connectedline_read(struct ast_channel *chan, const char *cmd, char *data, char *buf, size_t len)
static int connectedline_write(struct ast_channel *chan, const char *cmd, char *data, const char *value)

Definition at line 1561 of file func_callerid.c.

struct ast_app_option connectedline_opts[128] = { [ 'i' ] = { .flag = CONNECTED_LINE_OPT_INHIBIT }, }
static

Definition at line 343 of file func_callerid.c.

Referenced by connectedline_write().

struct ast_custom_function redirecting_function
static
Initial value:
= {
.name = "REDIRECTING",
}
static int redirecting_write(struct ast_channel *chan, const char *cmd, char *data, const char *value)
static int redirecting_read(struct ast_channel *chan, const char *cmd, char *data, char *buf, size_t len)

Definition at line 1567 of file func_callerid.c.

struct ast_app_option redirecting_opts[128] = { [ 'i' ] = { .flag = REDIRECTING_OPT_INHIBIT }, }
static

Definition at line 357 of file func_callerid.c.

Referenced by redirecting_write().