Asterisk - The Open Source Telephony Project  18.5.0
Data Structures | Enumerations | Functions | Variables
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"
Include dependency graph for func_callerid.c:

Go to the source code of this file.

Data Structures

struct  __subtype_ast_party_func_args
 
struct  __subtype_ast_party_members
 
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)
 
struct ast_moduleAST_MODULE_SELF_SYM (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 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 = "30ef0c93b36035ec78c9cfd712d36d9b" , .load = load_module, .unload = unload_module, .load_pri = AST_MODPRI_DEFAULT, .support_level = AST_MODULE_SUPPORT_CORE, }
 
static const struct ast_module_infoast_module_info = &__mod_info
 
static struct ast_custom_function callerid_function
 
static struct ast_custom_function connectedline_function
 
static const struct ast_app_option connectedline_opts [128] = { [ 'i' ] = { .flag = CONNECTED_LINE_OPT_INHIBIT }, }
 
static struct ast_custom_function redirecting_function
 
static const 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

◆ CONNECTED_LINE_OPT_ARGS

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 454 of file func_callerid.c.

454  {
455  CONNECTED_LINE_OPT_DUMMY, /*!< Delete this if CONNECTED_LINE ever gets an option with parameters. */
456 
457  /*! \note This entry _MUST_ be the last one in the enum */
459 };

◆ CONNECTED_LINE_OPT_FLAGS

Enumerator
CONNECTED_LINE_OPT_INHIBIT 

Definition at line 451 of file func_callerid.c.

451  {
452  CONNECTED_LINE_OPT_INHIBIT = (1 << 0),
453 };

◆ ID_FIELD_STATUS

Enumerator
ID_FIELD_VALID 
ID_FIELD_INVALID 
ID_FIELD_UNKNOWN 

Definition at line 435 of file func_callerid.c.

◆ REDIRECTING_OPT_ARGS

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 468 of file func_callerid.c.

468  {
469  REDIRECTING_OPT_DUMMY, /*!< Delete this if REDIRECTING ever gets an option with parameters. */
470 
471  /*! \note This entry _MUST_ be the last one in the enum */
473 };

◆ REDIRECTING_OPT_FLAGS

Enumerator
REDIRECTING_OPT_INHIBIT 

Definition at line 465 of file func_callerid.c.

465  {
466  REDIRECTING_OPT_INHIBIT = (1 << 0),
467 };

Function Documentation

◆ __reg_module()

static void __reg_module ( void  )
static

Definition at line 1831 of file func_callerid.c.

◆ __unreg_module()

static void __unreg_module ( void  )
static

Definition at line 1831 of file func_callerid.c.

◆ AST_MODULE_SELF_SYM()

struct ast_module* AST_MODULE_SELF_SYM ( void  )

Definition at line 1831 of file func_callerid.c.

◆ callerid_read()

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.

< Member name

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

Definition at line 930 of file func_callerid.c.

References ast_party_members::argc, args, ARRAY_LEN, AST_APP_ARG, ast_callerid_split(), ast_channel_caller(), ast_channel_dialed(), ast_channel_lock, ast_channel_redirecting(), ast_channel_unlock, ast_copy_string(), AST_DECLARE_APP_ARGS, ast_log, AST_NONSTANDARD_APP_ARGS, AST_STANDARD_APP_ARGS, ast_strdupa, ID_FIELD_INVALID, ID_FIELD_VALID, LOG_ERROR, name, party_id_read(), party_subaddress_read(), status, and ast_party_members::subnames.

931 {
932  char *parms;
933  struct ast_party_members member = { 0, };
935  AST_APP_ARG(member); /*!< Member name */
936  AST_APP_ARG(cid); /*!< Optional caller id to parse instead of from the channel. */
937  );
938 
939  /* Ensure that the buffer is empty */
940  *buf = 0;
941 
942  if (!chan) {
943  return -1;
944  }
945 
946  parms = ast_strdupa(data);
947  AST_STANDARD_APP_ARGS(args, parms);
948  if (args.argc == 0) {
949  /* Must have at least one argument. */
950  return -1;
951  }
952 
953  AST_NONSTANDARD_APP_ARGS(member, args.member, '-');
954  if (member.argc == 0 || ARRAY_LEN(member.subnames) <= member.argc) {
955  /* Too few or too many subnames */
956  return -1;
957  }
958 
959  if (args.argc == 2) {
960  char name[80];
961  char num[80];
962 
963  ast_callerid_split(args.cid, name, sizeof(name), num, sizeof(num));
964 
965  if (member.argc == 1 && !strcasecmp("all", member.subnames[0])) {
966  snprintf(buf, len, "\"%s\" <%s>", name, num);
967  } else if (member.argc == 1 && !strcasecmp("name", member.subnames[0])) {
968  ast_copy_string(buf, name, len);
969  } else if (member.argc == 1 && !strncasecmp("num", member.subnames[0], 3)) {
970  /* Accept num[ber] */
971  ast_copy_string(buf, num, len);
972  } else {
973  ast_log(LOG_ERROR, "Unknown callerid data type '%s'.\n", data);
974  }
975  } else {
976  enum ID_FIELD_STATUS status;
977  ast_channel_lock(chan);
978 
979  if (member.argc == 1 && !strcasecmp("rdnis", member.subnames[0])) {
980  if (ast_channel_redirecting(chan)->from.number.valid
981  && ast_channel_redirecting(chan)->from.number.str) {
982  ast_copy_string(buf, ast_channel_redirecting(chan)->from.number.str, len);
983  }
984  } else if (!strcasecmp("dnid", member.subnames[0])) {
985  if (member.argc == 1) {
986  /* Setup as if user had given dnid-num instead. */
987  member.argc = 2;
988  member.subnames[1] = "num";
989  }
990  if (!strncasecmp("num", member.subnames[1], 3)) {
991  /*
992  * Accept num[ber]
993  * dnid-num...
994  */
995  if (member.argc == 2) {
996  /* dnid-num */
997  if (ast_channel_dialed(chan)->number.str) {
998  ast_copy_string(buf, ast_channel_dialed(chan)->number.str, len);
999  }
1000  } else if (member.argc == 3 && !strcasecmp("plan", member.subnames[2])) {
1001  /* dnid-num-plan */
1002  snprintf(buf, len, "%d", ast_channel_dialed(chan)->number.plan);
1003  } else {
1004  ast_log(LOG_ERROR, "Unknown callerid data type '%s'.\n", data);
1005  }
1006  } else if (!strncasecmp("subaddr", member.subnames[1], 7)) {
1007  /*
1008  * Accept subaddr[ess]
1009  * dnid-subaddr...
1010  */
1011  status = party_subaddress_read(buf, len, member.argc - 2, member.subnames + 2,
1012  &ast_channel_dialed(chan)->subaddress);
1013  switch (status) {
1014  case ID_FIELD_VALID:
1015  case ID_FIELD_INVALID:
1016  break;
1017  default:
1018  ast_log(LOG_ERROR, "Unknown callerid data type '%s'.\n", data);
1019  break;
1020  }
1021  } else {
1022  ast_log(LOG_ERROR, "Unknown callerid data type '%s'.\n", data);
1023  }
1024  } else if (member.argc == 1 && !strcasecmp("ani2", member.subnames[0])) {
1025  snprintf(buf, len, "%d", ast_channel_caller(chan)->ani2);
1026  } else if (!strcasecmp("ani", member.subnames[0])) {
1027  if (member.argc == 1) {
1028  /* Setup as if user had given ani-num instead. */
1029  member.argc = 2;
1030  member.subnames[1] = "num";
1031  }
1032  status = party_id_read(buf, len, member.argc - 1, member.subnames + 1,
1033  &ast_channel_caller(chan)->ani);
1034  switch (status) {
1035  case ID_FIELD_VALID:
1036  case ID_FIELD_INVALID:
1037  break;
1038  default:
1039  ast_log(LOG_ERROR, "Unknown callerid data type '%s'.\n", data);
1040  break;
1041  }
1042  } else if (!strcasecmp("priv", member.subnames[0])) {
1043  status = party_id_read(buf, len, member.argc - 1, member.subnames + 1,
1044  &ast_channel_caller(chan)->priv);
1045  switch (status) {
1046  case ID_FIELD_VALID:
1047  case ID_FIELD_INVALID:
1048  break;
1049  default:
1050  ast_log(LOG_ERROR, "Unknown callerid data type '%s'.\n", data);
1051  break;
1052  }
1053  } else {
1054  status = party_id_read(buf, len, member.argc, member.subnames, &ast_channel_caller(chan)->id);
1055  switch (status) {
1056  case ID_FIELD_VALID:
1057  case ID_FIELD_INVALID:
1058  break;
1059  default:
1060  ast_log(LOG_ERROR, "Unknown callerid data type '%s'.\n", data);
1061  break;
1062  }
1063  }
1064 
1065  ast_channel_unlock(chan);
1066  }
1067 
1068  return 0;
1069 }
struct ast_party_caller * ast_channel_caller(struct ast_channel *chan)
#define ast_channel_lock(chan)
Definition: channel.h:2945
#define ARRAY_LEN(a)
Definition: isdn_lib.c:42
int ast_callerid_split(const char *src, char *name, int namelen, char *num, int numlen)
Definition: callerid.c:1092
char buf[BUFSIZE]
Definition: eagi_proxy.c:66
#define AST_STANDARD_APP_ARGS(args, parse)
Performs the &#39;standard&#39; argument separation process for an application.
const char * args
char * subnames[10]
Number structure.
Definition: app_followme.c:154
#define ast_log
Definition: astobj2.c:42
static enum ID_FIELD_STATUS party_subaddress_read(char *buf, size_t len, int argc, char *argv[], const struct ast_party_subaddress *subaddress)
#define ast_strdupa(s)
duplicate a string in memory from the stack
Definition: astmm.h:300
static enum ID_FIELD_STATUS party_id_read(char *buf, size_t len, int argc, char *argv[], const struct ast_party_id *id)
#define LOG_ERROR
Definition: logger.h:285
#define AST_NONSTANDARD_APP_ARGS(args, parse, sep)
Performs the &#39;nonstandard&#39; argument separation process for an application.
static int len(struct ast_channel *chan, const char *cmd, char *data, char *buf, size_t buflen)
struct ast_party_dialed * ast_channel_dialed(struct ast_channel *chan)
#define ast_channel_unlock(chan)
Definition: channel.h:2946
unsigned int argc
static const char name[]
Definition: cdr_mysql.c:74
ID_FIELD_STATUS
struct ast_party_redirecting * ast_channel_redirecting(struct ast_channel *chan)
void ast_copy_string(char *dst, const char *src, size_t size)
Size-limited null-terminating string copy.
Definition: strings.h:401
#define AST_DECLARE_APP_ARGS(name, arglist)
Declare a structure to hold an application&#39;s arguments.
jack_status_t status
Definition: app_jack.c:146
#define AST_APP_ARG(name)
Define an application argument.

◆ callerid_write()

static int callerid_write ( struct ast_channel chan,
const char *  cmd,
char *  data,
const char *  value 
)
static

Definition at line 1083 of file func_callerid.c.

References ast_party_caller::ani, ast_party_caller::ani2, ast_party_func_args::argc, ast_party_members::argc, ARRAY_LEN, ast_channel_caller(), ast_channel_dialed(), ast_channel_lock, ast_channel_redirecting(), 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_party_redirecting::from, ast_party_caller::id, ID_FIELD_INVALID, ID_FIELD_VALID, LOG_ERROR, ast_party_func_args::member, NULL, ast_party_id::number, ast_party_dialed::number, party_id_write(), party_subaddress_write(), ast_party_dialed::plan, ast_party_caller::priv, status, ast_party_number::str, ast_party_dialed::str, ast_party_dialed::subaddress, ast_party_members::subnames, and ast_party_number::valid.

1084 {
1085  struct ast_party_caller caller;
1086  struct ast_party_dialed dialed;
1087  enum ID_FIELD_STATUS status;
1088  char *val;
1089  char *parms;
1090  struct ast_party_func_args args = { 0, };
1091  struct ast_party_members member = { 0, };
1092 
1093  if (!value || !chan) {
1094  return -1;
1095  }
1096 
1097  parms = ast_strdupa(data);
1098  AST_STANDARD_APP_ARGS(args, parms);
1099  if (args.argc == 0) {
1100  /* Must have at least one argument. */
1101  return -1;
1102  }
1103 
1104  AST_NONSTANDARD_APP_ARGS(member, args.member, '-');
1105  if (member.argc == 0 || ARRAY_LEN(member.subnames) <= member.argc) {
1106  /* Too few or too many subnames */
1107  return -1;
1108  }
1109 
1111 
1112  ast_channel_lock(chan);
1113  if (member.argc == 1 && !strcasecmp("rdnis", member.subnames[0])) {
1115  ast_free(ast_channel_redirecting(chan)->from.number.str);
1117  } else if (!strcasecmp("dnid", member.subnames[0])) {
1119  if (member.argc == 1) {
1120  /* Setup as if user had given dnid-num instead. */
1121  member.argc = 2;
1122  member.subnames[1] = "num";
1123  }
1124  if (!strncasecmp("num", member.subnames[1], 3)) {
1125  /*
1126  * Accept num[ber]
1127  * dnid-num...
1128  */
1129  if (member.argc == 2) {
1130  /* dnid-num */
1131  dialed.number.str = ast_strdup(value);
1132  ast_trim_blanks(dialed.number.str);
1133  ast_party_dialed_set(ast_channel_dialed(chan), &dialed);
1134  } else if (member.argc == 3 && !strcasecmp("plan", member.subnames[2])) {
1135  /* dnid-num-plan */
1136  val = ast_strdupa(value);
1137  ast_trim_blanks(val);
1138 
1139  if (('0' <= val[0]) && (val[0] <= '9')) {
1140  ast_channel_dialed(chan)->number.plan = atoi(val);
1141  } else {
1143  "Unknown type-of-number/numbering-plan '%s', value unchanged\n", val);
1144  }
1145  } else {
1146  ast_log(LOG_ERROR, "Unknown callerid data type '%s'.\n", data);
1147  }
1148  } else if (!strncasecmp("subaddr", member.subnames[1], 7)) {
1149  /*
1150  * Accept subaddr[ess]
1151  * dnid-subaddr...
1152  */
1153  status = party_subaddress_write(&dialed.subaddress, member.argc - 2,
1154  member.subnames + 2, value);
1155  switch (status) {
1156  case ID_FIELD_VALID:
1157  ast_party_dialed_set(ast_channel_dialed(chan), &dialed);
1158  break;
1159  case ID_FIELD_INVALID:
1160  break;
1161  default:
1162  ast_log(LOG_ERROR, "Unknown callerid data type '%s'.\n", data);
1163  break;
1164  }
1165  } else {
1166  ast_log(LOG_ERROR, "Unknown callerid data type '%s'.\n", data);
1167  }
1168  ast_party_dialed_free(&dialed);
1169  } else if (member.argc == 1 && !strcasecmp("ani2", member.subnames[0])) {
1170  val = ast_strdupa(value);
1171  ast_trim_blanks(val);
1172 
1173  if (('0' <= val[0]) && (val[0] <= '9')) {
1174  ast_channel_caller(chan)->ani2 = atoi(val);
1175  } else {
1176  ast_log(LOG_ERROR, "Unknown callerid ani2 '%s', value unchanged\n", val);
1177  }
1178  } else if (!strcasecmp("ani", member.subnames[0])) {
1180  if (member.argc == 1) {
1181  /* Setup as if user had given ani-num instead. */
1182  member.argc = 2;
1183  member.subnames[1] = "num";
1184  }
1185  status = party_id_write(&caller.ani, member.argc - 1, member.subnames + 1, value);
1186  switch (status) {
1187  case ID_FIELD_VALID:
1188  ast_party_caller_set(ast_channel_caller(chan), &caller, NULL);
1189  break;
1190  case ID_FIELD_INVALID:
1191  break;
1192  default:
1193  ast_log(LOG_ERROR, "Unknown callerid data type '%s'.\n", data);
1194  break;
1195  }
1196  ast_party_caller_free(&caller);
1197  } else if (!strcasecmp("priv", member.subnames[0])) {
1199  status = party_id_write(&caller.priv, member.argc - 1, member.subnames + 1, value);
1200  switch (status) {
1201  case ID_FIELD_VALID:
1202  ast_party_caller_set(ast_channel_caller(chan), &caller, NULL);
1203  break;
1204  case ID_FIELD_INVALID:
1205  break;
1206  default:
1207  ast_log(LOG_ERROR, "Unknown callerid data type '%s'.\n", data);
1208  break;
1209  }
1210  ast_party_caller_free(&caller);
1211  } else {
1213  status = party_id_write(&caller.id, member.argc, member.subnames, value);
1214  switch (status) {
1215  case ID_FIELD_VALID:
1216  ast_channel_set_caller_event(chan, &caller, NULL);
1217  break;
1218  case ID_FIELD_INVALID:
1219  break;
1220  default:
1221  ast_log(LOG_ERROR, "Unknown callerid data type '%s'.\n", data);
1222  break;
1223  }
1224  ast_party_caller_free(&caller);
1225  }
1226  ast_channel_unlock(chan);
1227 
1228  return 0;
1229 }
struct ast_party_caller * ast_channel_caller(struct ast_channel *chan)
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:2945
struct ast_party_dialed::@246 number
Dialed/Called number.
int plan
Q.931 Type-Of-Number and Numbering-Plan encoded fields.
Definition: channel.h:389
char * str
Subscriber phone number (Malloced)
Definition: channel.h:292
#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:7472
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:528
#define AST_STANDARD_APP_ARGS(args, parse)
Performs the &#39;standard&#39; argument separation process for an application.
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:2007
void ast_party_caller_free(struct ast_party_caller *doomed)
Destroy the caller party contents.
Definition: channel.c:2015
#define ast_strdup(str)
A wrapper for strdup()
Definition: astmm.h:243
const char * args
#define NULL
Definition: resample.c:96
int value
Definition: syslog.c:37
char * subnames[10]
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:1958
#define ast_log
Definition: astobj2.c:42
Caller Party information.
Definition: channel.h:419
#define ast_strdupa(s)
duplicate a string in memory from the stack
Definition: astmm.h:300
Dialed/Called Party information.
Definition: channel.h:379
#define LOG_ERROR
Definition: logger.h:285
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:1999
#define AST_NONSTANDARD_APP_ARGS(args, parse, sep)
Performs the &#39;nonstandard&#39; argument separation process for an application.
int ani2
Automatic Number Identification 2 (Info Digits)
Definition: channel.h:434
struct ast_party_dialed * ast_channel_dialed(struct ast_channel *chan)
char * ast_skip_blanks(const char *str)
Gets a pointer to the first non-whitespace character in a string.
Definition: strings.h:157
char * ast_trim_blanks(char *str)
Trims trailing whitespace characters from a string.
Definition: strings.h:182
#define ast_channel_unlock(chan)
Definition: channel.h:2946
unsigned int argc
#define ast_free(a)
Definition: astmm.h:182
ID_FIELD_STATUS
struct ast_party_redirecting * ast_channel_redirecting(struct ast_channel *chan)
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:1971
unsigned char valid
TRUE if the number information is valid/present.
Definition: channel.h:298
jack_status_t status
Definition: app_jack.c:146
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:1950
struct ast_party_number number
Subscriber phone number.
Definition: channel.h:343

◆ connectedline_read()

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

Definition at line 1244 of file func_callerid.c.

References ast_party_members::argc, ARRAY_LEN, ast_channel_connected(), ast_channel_lock, ast_channel_unlock, ast_connected_line_source_name(), ast_copy_string(), ast_log, AST_NONSTANDARD_APP_ARGS, ast_strdupa, ID_FIELD_INVALID, ID_FIELD_VALID, LOG_ERROR, party_id_read(), status, and ast_party_members::subnames.

1245 {
1246  struct ast_party_members member = { 0, };
1247  char *read_what;
1248  enum ID_FIELD_STATUS status;
1249 
1250  /* Ensure that the buffer is empty */
1251  *buf = 0;
1252 
1253  if (!chan) {
1254  return -1;
1255  }
1256 
1257  read_what = ast_strdupa(data);
1258  AST_NONSTANDARD_APP_ARGS(member, read_what, '-');
1259  if (member.argc == 0 || ARRAY_LEN(member.subnames) <= member.argc) {
1260  /* Too few or too many subnames */
1261  return -1;
1262  }
1263 
1264  ast_channel_lock(chan);
1265 
1266  if (member.argc == 1 && !strcasecmp("source", member.subnames[0])) {
1268  } else if (!strcasecmp("priv", member.subnames[0])) {
1269  status = party_id_read(buf, len, member.argc - 1, member.subnames + 1,
1270  &ast_channel_connected(chan)->priv);
1271  switch (status) {
1272  case ID_FIELD_VALID:
1273  case ID_FIELD_INVALID:
1274  break;
1275  default:
1276  ast_log(LOG_ERROR, "Unknown connectedline data type '%s'.\n", data);
1277  break;
1278  }
1279  } else {
1280  status = party_id_read(buf, len, member.argc, member.subnames, &ast_channel_connected(chan)->id);
1281  switch (status) {
1282  case ID_FIELD_VALID:
1283  case ID_FIELD_INVALID:
1284  break;
1285  default:
1286  ast_log(LOG_ERROR, "Unknown connectedline data type '%s'.\n", data);
1287  break;
1288  }
1289  }
1290 
1291  ast_channel_unlock(chan);
1292 
1293  return 0;
1294 }
#define ast_channel_lock(chan)
Definition: channel.h:2945
#define ARRAY_LEN(a)
Definition: isdn_lib.c:42
char buf[BUFSIZE]
Definition: eagi_proxy.c:66
const char * ast_connected_line_source_name(int data)
Convert connected line update source value to text code.
Definition: callerid.c:1305
char * subnames[10]
#define ast_log
Definition: astobj2.c:42
struct ast_party_connected_line * ast_channel_connected(struct ast_channel *chan)
#define ast_strdupa(s)
duplicate a string in memory from the stack
Definition: astmm.h:300
static enum ID_FIELD_STATUS party_id_read(char *buf, size_t len, int argc, char *argv[], const struct ast_party_id *id)
#define LOG_ERROR
Definition: logger.h:285
#define AST_NONSTANDARD_APP_ARGS(args, parse, sep)
Performs the &#39;nonstandard&#39; argument separation process for an application.
static int len(struct ast_channel *chan, const char *cmd, char *data, char *buf, size_t buflen)
#define ast_channel_unlock(chan)
Definition: channel.h:2946
unsigned int argc
ID_FIELD_STATUS
void ast_copy_string(char *dst, const char *src, size_t size)
Size-limited null-terminating string copy.
Definition: strings.h:401
jack_status_t status
Definition: app_jack.c:146

◆ connectedline_write()

static int connectedline_write ( struct ast_channel chan,
const char *  cmd,
char *  data,
const char *  value 
)
static

Definition at line 1308 of file func_callerid.c.

References ast_party_func_args::argc, ast_party_members::argc, ARRAY_LEN, ast_app_parse_options(), ast_channel_connected(), 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, 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, NULL, ast_party_func_args::opts, party_id_write(), ast_party_connected_line::priv, ast_party_connected_line::source, status, ast_party_members::subnames, and update().

1309 {
1311  char *val;
1312  char *parms;
1313  void (*set_it)(struct ast_channel *chan, const struct ast_party_connected_line *connected, const struct ast_set_party_connected_line *update);
1314  struct ast_party_func_args args = { 0, };
1315  struct ast_party_members member = { 0, };
1316  struct ast_flags opts;
1317  char *opt_args[CONNECTED_LINE_OPT_ARG_ARRAY_SIZE];
1318  enum ID_FIELD_STATUS status;
1319 
1320  if (!value || !chan) {
1321  return -1;
1322  }
1323 
1324  parms = ast_strdupa(data);
1325  AST_STANDARD_APP_ARGS(args, parms);
1326  if (args.argc == 0) {
1327  /* Must have at least one argument. */
1328  return -1;
1329  }
1330 
1331  AST_NONSTANDARD_APP_ARGS(member, args.member, '-');
1332  if (member.argc == 0 || ARRAY_LEN(member.subnames) <= member.argc) {
1333  /* Too few or too many subnames */
1334  return -1;
1335  }
1336 
1337  if (ast_app_parse_options(connectedline_opts, &opts, opt_args, args.opts)) {
1338  /* General invalid option syntax. */
1339  return -1;
1340  }
1341 
1342  /* Determine if the update indication inhibit option is present */
1345  } else {
1347  }
1348 
1349  ast_channel_lock(chan);
1351  ast_channel_unlock(chan);
1352 
1354 
1355  if (member.argc == 1 && !strcasecmp("source", member.subnames[0])) {
1356  int source;
1357 
1358  val = ast_strdupa(value);
1359  ast_trim_blanks(val);
1360 
1361  if (('0' <= val[0]) && (val[0] <= '9')) {
1362  source = atoi(val);
1363  } else {
1364  source = ast_connected_line_source_parse(val);
1365  }
1366 
1367  if (source < 0) {
1368  ast_log(LOG_ERROR, "Unknown connectedline source '%s', value unchanged\n", val);
1369  } else {
1370  connected.source = source;
1371  set_it(chan, &connected, NULL);
1372  }
1373  } else if (!strcasecmp("priv", member.subnames[0])) {
1374  status = party_id_write(&connected.priv, member.argc - 1, member.subnames + 1, value);
1375  switch (status) {
1376  case ID_FIELD_VALID:
1377  set_it(chan, &connected, NULL);
1378  break;
1379  case ID_FIELD_INVALID:
1380  break;
1381  default:
1382  ast_log(LOG_ERROR, "Unknown connectedline data type '%s'.\n", data);
1383  break;
1384  }
1385  ast_party_connected_line_free(&connected);
1386  } else {
1387  status = party_id_write(&connected.id, member.argc, member.subnames, value);
1388  switch (status) {
1389  case ID_FIELD_VALID:
1390  set_it(chan, &connected, NULL);
1391  break;
1392  case ID_FIELD_INVALID:
1393  break;
1394  default:
1395  ast_log(LOG_ERROR, "Unknown connectedline data type '%s'.\n", data);
1396  break;
1397  }
1398  ast_party_connected_line_free(&connected);
1399  }
1400 
1401  return 0;
1402 }
#define ast_channel_lock(chan)
Definition: channel.h:2945
Main Channel structure associated with a channel.
#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:1279
Definition: ast_expr2.c:325
struct ast_party_id id
Connected party ID.
Definition: channel.h:459
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:2045
#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
#define AST_STANDARD_APP_ARGS(args, parse)
Performs the &#39;standard&#39; argument separation process for an application.
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:9189
void ast_party_connected_line_free(struct ast_party_connected_line *doomed)
Destroy the connected line information contents.
Definition: channel.c:2072
const char * args
#define NULL
Definition: resample.c:96
int value
Definition: syslog.c:37
char * subnames[10]
#define ast_log
Definition: astobj2.c:42
struct ast_party_connected_line * ast_channel_connected(struct ast_channel *chan)
#define ast_strdupa(s)
duplicate a string in memory from the stack
Definition: astmm.h:300
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: main/app.c:2906
static const struct ast_app_option connectedline_opts[128]
#define LOG_ERROR
Definition: logger.h:285
#define AST_NONSTANDARD_APP_ARGS(args, parse, sep)
Performs the &#39;nonstandard&#39; argument separation process for an application.
Connected Line/Party information.
Definition: channel.h:457
char * ast_skip_blanks(const char *str)
Gets a pointer to the first non-whitespace character in a string.
Definition: strings.h:157
char * ast_trim_blanks(char *str)
Trims trailing whitespace characters from a string.
Definition: strings.h:182
#define ast_channel_unlock(chan)
Definition: channel.h:2946
unsigned int argc
int source
Information about the source of an update.
Definition: channel.h:483
ID_FIELD_STATUS
Structure used to handle boolean flags.
Definition: utils.h:199
Indicate what information in ast_party_connected_line should be set.
Definition: channel.h:490
static enum ID_FIELD_STATUS party_id_write(struct ast_party_id *id, int argc, char *argv[], const char *value)
char connected
Definition: eagi_proxy.c:82
struct ast_party_id priv
Private connected party ID.
Definition: channel.h:469
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:8404
jack_status_t status
Definition: app_jack.c:146

◆ load_module()

static int load_module ( void  )
static

Definition at line 1814 of file func_callerid.c.

References ast_custom_function_register, AST_MODULE_LOAD_DECLINE, AST_MODULE_LOAD_SUCCESS, and unload_module().

1815 {
1816  int res;
1817 
1821 
1822  if (res) {
1823  unload_module();
1824  return AST_MODULE_LOAD_DECLINE;
1825  }
1826 
1827  return AST_MODULE_LOAD_SUCCESS;
1828 }
static int unload_module(void)
static struct ast_custom_function redirecting_function
static struct ast_custom_function callerid_function
Module has failed to load, may be in an inconsistent state.
Definition: module.h:78
#define ast_custom_function_register(acf)
Register a custom function.
Definition: pbx.h:1508
static struct ast_custom_function connectedline_function

◆ party_id_read()

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 609 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().

610 {
611  enum ID_FIELD_STATUS status;
612 
613  if (argc == 0) {
614  /* Must have at least one subname. */
615  return ID_FIELD_UNKNOWN;
616  }
617 
618  status = ID_FIELD_VALID;
619 
620  if (argc == 1 && !strcasecmp("all", argv[0])) {
621  snprintf(buf, len, "\"%s\" <%s>",
622  S_COR(id->name.valid, id->name.str, ""),
623  S_COR(id->number.valid, id->number.str, ""));
624  } else if (!strcasecmp("name", argv[0])) {
625  status = party_name_read(buf, len, argc - 1, argv + 1, &id->name);
626  } else if (!strncasecmp("num", argv[0], 3)) {
627  /* Accept num[ber] */
628  status = party_number_read(buf, len, argc - 1, argv + 1, &id->number);
629  } else if (!strncasecmp("subaddr", argv[0], 7)) {
630  /* Accept subaddr[ess] */
631  status = party_subaddress_read(buf, len, argc - 1, argv + 1, &id->subaddress);
632  } else if (argc == 1 && !strcasecmp("tag", argv[0])) {
633  if (id->tag) {
634  ast_copy_string(buf, id->tag, len);
635  }
636  } else if (argc == 1 && !strcasecmp("ton", argv[0])) {
637  /* ton is an alias for num-plan */
638  snprintf(buf, len, "%d", id->number.plan);
639  } else if (argc == 1 && !strncasecmp("pres", argv[0], 4)) {
640  /*
641  * Accept pres[entation]
642  * This is the combined name/number presentation.
643  */
646  } else {
647  status = ID_FIELD_UNKNOWN;
648  }
649 
650  return status;
651 }
char * str
Subscriber phone number (Malloced)
Definition: channel.h:292
const char * ast_named_caller_presentation(int data)
Convert caller ID pres value to text code.
Definition: callerid.c:1182
struct ast_party_name name
Subscriber name.
Definition: channel.h:341
char buf[BUFSIZE]
Definition: eagi_proxy.c:66
int ast_party_id_presentation(const struct ast_party_id *id)
Determine the overall presentation value for the given party.
Definition: channel.c:1821
char * str
Subscriber name (Malloced)
Definition: channel.h:265
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:85
struct ast_party_subaddress subaddress
Subscriber subaddress.
Definition: channel.h:345
int plan
Q.931 Type-Of-Number and Numbering-Plan encoded fields.
Definition: channel.h:294
static int len(struct ast_channel *chan, const char *cmd, char *data, char *buf, size_t buflen)
ID_FIELD_STATUS
char * tag
User-set "tag".
Definition: channel.h:355
void ast_copy_string(char *dst, const char *src, size_t size)
Size-limited null-terminating string copy.
Definition: strings.h:401
unsigned char valid
TRUE if the name information is valid/present.
Definition: channel.h:280
unsigned char valid
TRUE if the number information is valid/present.
Definition: channel.h:298
jack_status_t status
Definition: app_jack.c:146
struct ast_party_number number
Subscriber phone number.
Definition: channel.h:343

◆ party_id_write()

static enum ID_FIELD_STATUS party_id_write ( struct ast_party_id id,
int  argc,
char *  argv[],
const char *  value 
)
static

Definition at line 844 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().

845 {
846  char *val;
847  enum ID_FIELD_STATUS status;
848 
849  if (argc == 0) {
850  /* Must have at least one subname. */
851  return ID_FIELD_UNKNOWN;
852  }
853 
854  status = ID_FIELD_VALID;
855 
856  if (argc == 1 && !strcasecmp("all", argv[0])) {
857  char name[256];
858  char num[256];
859 
860  ast_callerid_split(value, name, sizeof(name), num, sizeof(num));
861  id->name.valid = 1;
862  id->name.str = ast_strdup(name);
863  if (!id->name.str) {
864  return ID_FIELD_INVALID;
865  }
866  id->number.valid = 1;
867  id->number.str = ast_strdup(num);
868  if (!id->number.str) {
869  return ID_FIELD_INVALID;
870  }
871  } else if (!strcasecmp("name", argv[0])) {
872  status = party_name_write(&id->name, argc - 1, argv + 1, value);
873  } else if (!strncasecmp("num", argv[0], 3)) {
874  /* Accept num[ber] */
875  status = party_number_write(&id->number, argc - 1, argv + 1, value);
876  } else if (!strncasecmp("subaddr", argv[0], 7)) {
877  /* Accept subaddr[ess] */
878  status = party_subaddress_write(&id->subaddress, argc - 1, argv + 1, value);
879  } else if (argc == 1 && !strcasecmp("tag", argv[0])) {
880  id->tag = ast_strdup(value);
881  ast_trim_blanks(id->tag);
882  } else if (argc == 1 && !strcasecmp("ton", argv[0])) {
883  /* ton is an alias for num-plan */
884  argv[0] = "plan";
885  status = party_number_write(&id->number, argc, argv, value);
886  } else if (argc == 1 && !strncasecmp("pres", argv[0], 4)) {
887  int pres;
888 
889  /*
890  * Accept pres[entation]
891  * This is the combined name/number presentation.
892  */
893  val = ast_strdupa(value);
894  ast_trim_blanks(val);
895 
896  if (('0' <= val[0]) && (val[0] <= '9')) {
897  pres = atoi(val);
898  } else {
899  pres = ast_parse_caller_presentation(val);
900  }
901 
902  if (pres < 0) {
904  "Unknown combined presentation '%s', value unchanged\n", val);
905  status = ID_FIELD_INVALID;
906  } else {
907  id->name.presentation = pres;
908  id->number.presentation = pres;
909  }
910  } else {
911  status = ID_FIELD_UNKNOWN;
912  }
913 
914  return status;
915 }
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:292
int ast_callerid_split(const char *src, char *name, int namelen, char *num, int numlen)
Definition: callerid.c:1092
Definition: ast_expr2.c:325
struct ast_party_name name
Subscriber name.
Definition: channel.h:341
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:265
#define ast_strdup(str)
A wrapper for strdup()
Definition: astmm.h:243
int value
Definition: syslog.c:37
static enum ID_FIELD_STATUS party_number_write(struct ast_party_number *number, int argc, char *argv[], const char *value)
#define ast_log
Definition: astobj2.c:42
#define ast_strdupa(s)
duplicate a string in memory from the stack
Definition: astmm.h:300
int ast_parse_caller_presentation(const char *data)
Convert caller ID text code to value (used in config file parsing)
Definition: callerid.c:1143
struct ast_party_subaddress subaddress
Subscriber subaddress.
Definition: channel.h:345
#define LOG_ERROR
Definition: logger.h:285
char * ast_trim_blanks(char *str)
Trims trailing whitespace characters from a string.
Definition: strings.h:182
static const char name[]
Definition: cdr_mysql.c:74
ID_FIELD_STATUS
char * tag
User-set "tag".
Definition: channel.h:355
jack_status_t status
Definition: app_jack.c:146
struct ast_party_number number
Subscriber phone number.
Definition: channel.h:343

◆ party_name_read()

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 493 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().

494 {
495  enum ID_FIELD_STATUS status;
496 
497  status = ID_FIELD_VALID;
498 
499  if (argc == 0) {
500  /* We want the name string */
501  if (name->valid && name->str) {
502  ast_copy_string(buf, name->str, len);
503  }
504  } else if (argc == 1 && !strcasecmp("valid", argv[0])) {
505  snprintf(buf, len, "%d", name->valid);
506  } else if (argc == 1 && !strcasecmp("charset", argv[0])) {
508  } else if (argc == 1 && !strncasecmp("pres", argv[0], 4)) {
509  /* Accept pres[entation] */
511  } else {
512  status = ID_FIELD_UNKNOWN;
513  }
514 
515  return status;
516 }
int presentation
Q.931 encoded presentation-indicator encoded field.
Definition: channel.h:278
const char * ast_named_caller_presentation(int data)
Convert caller ID pres value to text code.
Definition: callerid.c:1182
char buf[BUFSIZE]
Definition: eagi_proxy.c:66
int char_set
Character set the name is using.
Definition: channel.h:273
char * str
Subscriber name (Malloced)
Definition: channel.h:265
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:1360
void ast_copy_string(char *dst, const char *src, size_t size)
Size-limited null-terminating string copy.
Definition: strings.h:401
unsigned char valid
TRUE if the name information is valid/present.
Definition: channel.h:280
jack_status_t status
Definition: app_jack.c:146

◆ party_name_write()

static enum ID_FIELD_STATUS party_name_write ( struct ast_party_name name,
int  argc,
char *  argv[],
const char *  value 
)
static

Definition at line 667 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().

668 {
669  char *val;
670  enum ID_FIELD_STATUS status;
671 
672  status = ID_FIELD_VALID;
673 
674  if (argc == 0) {
675  /* We are setting the name string */
676  name->valid = 1;
677  name->str = ast_strdup(value);
678  ast_trim_blanks(name->str);
679  } else if (argc == 1 && !strcasecmp("valid", argv[0])) {
680  name->valid = atoi(value) ? 1 : 0;
681  } else if (argc == 1 && !strcasecmp("charset", argv[0])) {
682  int char_set;
683 
684  val = ast_strdupa(value);
685  ast_trim_blanks(val);
686 
687  if (('0' <= val[0]) && (val[0] <= '9')) {
688  char_set = atoi(val);
689  } else {
690  char_set = ast_party_name_charset_parse(val);
691  }
692 
693  if (char_set < 0) {
695  "Unknown name char-set '%s', value unchanged\n", val);
696  status = ID_FIELD_INVALID;
697  } else {
698  name->char_set = char_set;
699  }
700  } else if (argc == 1 && !strncasecmp("pres", argv[0], 4)) {
701  int pres;
702 
703  /* Accept pres[entation] */
704  val = ast_strdupa(value);
705  ast_trim_blanks(val);
706 
707  if (('0' <= val[0]) && (val[0] <= '9')) {
708  pres = atoi(val);
709  } else {
710  pres = ast_parse_caller_presentation(val);
711  }
712 
713  if (pres < 0) {
715  "Unknown name presentation '%s', value unchanged\n", val);
716  status = ID_FIELD_INVALID;
717  } else {
718  name->presentation = pres;
719  }
720  } else {
721  status = ID_FIELD_UNKNOWN;
722  }
723 
724  return status;
725 }
int presentation
Q.931 encoded presentation-indicator encoded field.
Definition: channel.h:278
Definition: ast_expr2.c:325
int char_set
Character set the name is using.
Definition: channel.h:273
char * str
Subscriber name (Malloced)
Definition: channel.h:265
#define ast_strdup(str)
A wrapper for strdup()
Definition: astmm.h:243
int value
Definition: syslog.c:37
#define ast_log
Definition: astobj2.c:42
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:1334
#define ast_strdupa(s)
duplicate a string in memory from the stack
Definition: astmm.h:300
int ast_parse_caller_presentation(const char *data)
Convert caller ID text code to value (used in config file parsing)
Definition: callerid.c:1143
#define LOG_ERROR
Definition: logger.h:285
char * ast_trim_blanks(char *str)
Trims trailing whitespace characters from a string.
Definition: strings.h:182
ID_FIELD_STATUS
unsigned char valid
TRUE if the name information is valid/present.
Definition: channel.h:280
jack_status_t status
Definition: app_jack.c:146

◆ party_number_read()

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 532 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().

533 {
534  enum ID_FIELD_STATUS status;
535 
536  status = ID_FIELD_VALID;
537 
538  if (argc == 0) {
539  /* We want the number string */
540  if (number->valid && number->str) {
541  ast_copy_string(buf, number->str, len);
542  }
543  } else if (argc == 1 && !strcasecmp("valid", argv[0])) {
544  snprintf(buf, len, "%d", number->valid);
545  } else if (argc == 1 && !strcasecmp("plan", argv[0])) {
546  snprintf(buf, len, "%d", number->plan);
547  } else if (argc == 1 && !strncasecmp("pres", argv[0], 4)) {
548  /* Accept pres[entation] */
550  } else {
551  status = ID_FIELD_UNKNOWN;
552  }
553 
554  return status;
555 }
char * str
Subscriber phone number (Malloced)
Definition: channel.h:292
const char * ast_named_caller_presentation(int data)
Convert caller ID pres value to text code.
Definition: callerid.c:1182
int presentation
Q.931 presentation-indicator and screening-indicator encoded fields.
Definition: channel.h:296
char buf[BUFSIZE]
Definition: eagi_proxy.c:66
int plan
Q.931 Type-Of-Number and Numbering-Plan encoded fields.
Definition: channel.h:294
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:401
unsigned char valid
TRUE if the number information is valid/present.
Definition: channel.h:298
jack_status_t status
Definition: app_jack.c:146

◆ party_number_write()

static enum ID_FIELD_STATUS party_number_write ( struct ast_party_number number,
int  argc,
char *  argv[],
const char *  value 
)
static

Definition at line 741 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().

742 {
743  char *val;
744  enum ID_FIELD_STATUS status;
745 
746  status = ID_FIELD_VALID;
747 
748  if (argc == 0) {
749  /* We are setting the number string */
750  number->valid = 1;
751  number->str = ast_strdup(value);
752  ast_trim_blanks(number->str);
753  } else if (argc == 1 && !strcasecmp("valid", argv[0])) {
754  number->valid = atoi(value) ? 1 : 0;
755  } else if (argc == 1 && !strcasecmp("plan", argv[0])) {
756  val = ast_strdupa(value);
757  ast_trim_blanks(val);
758 
759  if (('0' <= val[0]) && (val[0] <= '9')) {
760  number->plan = atoi(val);
761  } else {
763  "Unknown type-of-number/numbering-plan '%s', value unchanged\n", val);
764  status = ID_FIELD_INVALID;
765  }
766  } else if (argc == 1 && !strncasecmp("pres", argv[0], 4)) {
767  int pres;
768 
769  /* Accept pres[entation] */
770  val = ast_strdupa(value);
771  ast_trim_blanks(val);
772 
773  if (('0' <= val[0]) && (val[0] <= '9')) {
774  pres = atoi(val);
775  } else {
776  pres = ast_parse_caller_presentation(val);
777  }
778 
779  if (pres < 0) {
781  "Unknown number presentation '%s', value unchanged\n", val);
782  status = ID_FIELD_INVALID;
783  } else {
784  number->presentation = pres;
785  }
786  } else {
787  status = ID_FIELD_UNKNOWN;
788  }
789 
790  return status;
791 }
char * str
Subscriber phone number (Malloced)
Definition: channel.h:292
int presentation
Q.931 presentation-indicator and screening-indicator encoded fields.
Definition: channel.h:296
Definition: ast_expr2.c:325
#define ast_strdup(str)
A wrapper for strdup()
Definition: astmm.h:243
int value
Definition: syslog.c:37
#define ast_log
Definition: astobj2.c:42
#define ast_strdupa(s)
duplicate a string in memory from the stack
Definition: astmm.h:300
int ast_parse_caller_presentation(const char *data)
Convert caller ID text code to value (used in config file parsing)
Definition: callerid.c:1143
#define LOG_ERROR
Definition: logger.h:285
int plan
Q.931 Type-Of-Number and Numbering-Plan encoded fields.
Definition: channel.h:294
char * ast_trim_blanks(char *str)
Trims trailing whitespace characters from a string.
Definition: strings.h:182
ID_FIELD_STATUS
unsigned char valid
TRUE if the number information is valid/present.
Definition: channel.h:298
jack_status_t status
Definition: app_jack.c:146

◆ party_subaddress_read()

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 571 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().

572 {
573  enum ID_FIELD_STATUS status;
574 
575  status = ID_FIELD_VALID;
576 
577  if (argc == 0) {
578  /* We want the subaddress string */
579  if (subaddress->str) {
580  ast_copy_string(buf, subaddress->str, len);
581  }
582  } else if (argc == 1 && !strcasecmp("valid", argv[0])) {
583  snprintf(buf, len, "%d", subaddress->valid);
584  } else if (argc == 1 && !strcasecmp("type", argv[0])) {
585  snprintf(buf, len, "%d", subaddress->type);
586  } else if (argc == 1 && !strcasecmp("odd", argv[0])) {
587  snprintf(buf, len, "%d", subaddress->odd_even_indicator);
588  } else {
589  status = ID_FIELD_UNKNOWN;
590  }
591 
592  return status;
593 }
char buf[BUFSIZE]
Definition: eagi_proxy.c:66
unsigned char valid
TRUE if the subaddress information is valid/present.
Definition: channel.h:329
char * str
Malloced subaddress string.
Definition: channel.h:314
unsigned char odd_even_indicator
TRUE if odd number of address signals.
Definition: channel.h:327
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:321
void ast_copy_string(char *dst, const char *src, size_t size)
Size-limited null-terminating string copy.
Definition: strings.h:401
jack_status_t status
Definition: app_jack.c:146

◆ party_subaddress_write()

static enum ID_FIELD_STATUS party_subaddress_write ( struct ast_party_subaddress subaddress,
int  argc,
char *  argv[],
const char *  value 
)
static

Definition at line 807 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().

808 {
809  enum ID_FIELD_STATUS status;
810 
811  status = ID_FIELD_VALID;
812 
813  if (argc == 0) {
814  /* We are setting the subaddress string */
815  subaddress->str = ast_strdup(value);
816  ast_trim_blanks(subaddress->str);
817  } else if (argc == 1 && !strcasecmp("valid", argv[0])) {
818  subaddress->valid = atoi(value) ? 1 : 0;
819  } else if (argc == 1 && !strcasecmp("type", argv[0])) {
820  subaddress->type = atoi(value) ? 2 : 0;
821  } else if (argc == 1 && !strcasecmp("odd", argv[0])) {
822  subaddress->odd_even_indicator = atoi(value) ? 1 : 0;
823  } else {
824  status = ID_FIELD_UNKNOWN;
825  }
826 
827  return status;
828 }
unsigned char valid
TRUE if the subaddress information is valid/present.
Definition: channel.h:329
#define ast_strdup(str)
A wrapper for strdup()
Definition: astmm.h:243
char * str
Malloced subaddress string.
Definition: channel.h:314
int value
Definition: syslog.c:37
unsigned char odd_even_indicator
TRUE if odd number of address signals.
Definition: channel.h:327
char * ast_trim_blanks(char *str)
Trims trailing whitespace characters from a string.
Definition: strings.h:182
ID_FIELD_STATUS
int type
Q.931 subaddress type.
Definition: channel.h:321
jack_status_t status
Definition: app_jack.c:146

◆ redirecting_read()

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

Definition at line 1417 of file func_callerid.c.

References ast_party_members::argc, ARRAY_LEN, ast_channel_lock, ast_channel_redirecting(), 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, ast_party_redirecting::orig, ast_party_redirecting::orig_reason, party_id_read(), ast_party_redirecting::priv_from, ast_party_redirecting::priv_orig, ast_party_redirecting::priv_to, ast_party_redirecting::reason, status, ast_party_members::subnames, and ast_party_redirecting::to.

1418 {
1419  struct ast_party_members member = { 0, };
1420  char *read_what;
1421  const struct ast_party_redirecting *ast_redirecting;
1422  enum ID_FIELD_STATUS status;
1423 
1424  /* Ensure that the buffer is empty */
1425  *buf = 0;
1426 
1427  if (!chan) {
1428  return -1;
1429  }
1430 
1431  read_what = ast_strdupa(data);
1432  AST_NONSTANDARD_APP_ARGS(member, read_what, '-');
1433  if (member.argc == 0 || ARRAY_LEN(member.subnames) <= member.argc) {
1434  /* Too few or too many subnames */
1435  return -1;
1436  }
1437 
1438  ast_channel_lock(chan);
1439 
1440  ast_redirecting = ast_channel_redirecting(chan);
1441  if (!strcasecmp("orig", member.subnames[0])) {
1442  if (member.argc == 2 && !strcasecmp("reason", member.subnames[1])) {
1444  ast_redirecting_reason_name(&ast_redirecting->orig_reason), len);
1445  } else {
1446  status = party_id_read(buf, len, member.argc - 1, member.subnames + 1,
1447  &ast_redirecting->orig);
1448  switch (status) {
1449  case ID_FIELD_VALID:
1450  case ID_FIELD_INVALID:
1451  break;
1452  default:
1453  ast_log(LOG_ERROR, "Unknown redirecting data type '%s'.\n", data);
1454  break;
1455  }
1456  }
1457  } else if (!strcasecmp("from", member.subnames[0])) {
1458  status = party_id_read(buf, len, member.argc - 1, member.subnames + 1,
1459  &ast_redirecting->from);
1460  switch (status) {
1461  case ID_FIELD_VALID:
1462  case ID_FIELD_INVALID:
1463  break;
1464  default:
1465  ast_log(LOG_ERROR, "Unknown redirecting data type '%s'.\n", data);
1466  break;
1467  }
1468  } else if (!strcasecmp("to", member.subnames[0])) {
1469  status = party_id_read(buf, len, member.argc - 1, member.subnames + 1,
1470  &ast_redirecting->to);
1471  switch (status) {
1472  case ID_FIELD_VALID:
1473  case ID_FIELD_INVALID:
1474  break;
1475  default:
1476  ast_log(LOG_ERROR, "Unknown redirecting data type '%s'.\n", data);
1477  break;
1478  }
1479  } else if (member.argc == 1 && !strncasecmp("pres", member.subnames[0], 4)) {
1480  /*
1481  * Accept pres[entation]
1482  * This is the combined from name/number presentation.
1483  */
1486  ast_party_id_presentation(&ast_redirecting->from)), len);
1487  } else if (member.argc == 1 && !strcasecmp("reason", member.subnames[0])) {
1489  } else if (member.argc == 1 && !strcasecmp("count", member.subnames[0])) {
1490  snprintf(buf, len, "%d", ast_redirecting->count);
1491  } else if (1 < member.argc && !strcasecmp("priv", member.subnames[0])) {
1492  if (!strcasecmp("orig", member.subnames[1])) {
1493  status = party_id_read(buf, len, member.argc - 2, member.subnames + 2,
1494  &ast_redirecting->priv_orig);
1495  switch (status) {
1496  case ID_FIELD_VALID:
1497  case ID_FIELD_INVALID:
1498  break;
1499  default:
1500  ast_log(LOG_ERROR, "Unknown redirecting data type '%s'.\n", data);
1501  break;
1502  }
1503  } else if (!strcasecmp("from", member.subnames[1])) {
1504  status = party_id_read(buf, len, member.argc - 2, member.subnames + 2,
1505  &ast_redirecting->priv_from);
1506  switch (status) {
1507  case ID_FIELD_VALID:
1508  case ID_FIELD_INVALID:
1509  break;
1510  default:
1511  ast_log(LOG_ERROR, "Unknown redirecting data type '%s'.\n", data);
1512  break;
1513  }
1514  } else if (!strcasecmp("to", member.subnames[1])) {
1515  status = party_id_read(buf, len, member.argc - 2, member.subnames + 2,
1516  &ast_redirecting->priv_to);
1517  switch (status) {
1518  case ID_FIELD_VALID:
1519  case ID_FIELD_INVALID:
1520  break;
1521  default:
1522  ast_log(LOG_ERROR, "Unknown redirecting data type '%s'.\n", data);
1523  break;
1524  }
1525  } else {
1526  ast_log(LOG_ERROR, "Unknown redirecting data type '%s'.\n", data);
1527  }
1528  } else {
1529  ast_log(LOG_ERROR, "Unknown redirecting data type '%s'.\n", data);
1530  }
1531 
1532  ast_channel_unlock(chan);
1533 
1534  return 0;
1535 }
#define ast_channel_lock(chan)
Definition: channel.h:2945
const char * ast_named_caller_presentation(int data)
Convert caller ID pres value to text code.
Definition: callerid.c:1182
struct ast_party_id priv_to
Call is redirecting to a new party (Sent to the caller) - private representation. ...
Definition: channel.h:540
#define ARRAY_LEN(a)
Definition: isdn_lib.c:42
struct ast_party_id priv_orig
Who originally redirected the call (Sent to the party the call is redirected toward) - private repres...
Definition: channel.h:534
struct ast_party_id from
Who is redirecting the call (Sent to the party the call is redirected toward)
Definition: channel.h:528
char buf[BUFSIZE]
Definition: eagi_proxy.c:66
int ast_party_id_presentation(const struct ast_party_id *id)
Determine the overall presentation value for the given party.
Definition: channel.c:1821
struct ast_party_id priv_from
Who is redirecting the call (Sent to the party the call is redirected toward) - private representatio...
Definition: channel.h:537
const char * ast_redirecting_reason_name(const struct ast_party_redirecting_reason *data)
Convert redirecting reason value to text code.
Definition: callerid.c:1249
char * subnames[10]
struct ast_party_id orig
Who originally redirected the call (Sent to the party the call is redirected toward) ...
Definition: channel.h:525
#define ast_log
Definition: astobj2.c:42
struct ast_party_redirecting_reason orig_reason
Reason for the redirection by the original party.
Definition: channel.h:546
#define ast_strdupa(s)
duplicate a string in memory from the stack
Definition: astmm.h:300
static enum ID_FIELD_STATUS party_id_read(char *buf, size_t len, int argc, char *argv[], const struct ast_party_id *id)
#define LOG_ERROR
Definition: logger.h:285
#define AST_NONSTANDARD_APP_ARGS(args, parse, sep)
Performs the &#39;nonstandard&#39; argument separation process for an application.
static int len(struct ast_channel *chan, const char *cmd, char *data, char *buf, size_t buflen)
Redirecting Line information. RDNIS (Redirecting Directory Number Information Service) Where a call d...
Definition: channel.h:523
#define ast_channel_unlock(chan)
Definition: channel.h:2946
unsigned int argc
ID_FIELD_STATUS
struct ast_party_redirecting_reason reason
Reason for the redirection.
Definition: channel.h:543
struct ast_party_redirecting * ast_channel_redirecting(struct ast_channel *chan)
int count
Number of times the call was redirected.
Definition: channel.h:549
struct ast_party_id to
Call is redirecting to a new party (Sent to the caller)
Definition: channel.h:531
void ast_copy_string(char *dst, const char *src, size_t size)
Size-limited null-terminating string copy.
Definition: strings.h:401
jack_status_t status
Definition: app_jack.c:146

◆ redirecting_write()

static int redirecting_write ( struct ast_channel chan,
const char *  cmd,
char *  data,
const char *  value 
)
static

Definition at line 1549 of file func_callerid.c.

References ast_party_func_args::argc, ast_party_members::argc, ARRAY_LEN, ast_app_parse_options(), ast_channel_lock, ast_channel_redirecting(), 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_REDIRECTING_REASON_UNKNOWN, ast_skip_blanks(), AST_STANDARD_APP_ARGS, ast_strdupa, ast_test_flag, ast_trim_blanks(), ast_party_redirecting_reason::code, 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, NULL, ast_party_id::number, ast_party_func_args::opts, ast_party_redirecting::orig, ast_party_redirecting::orig_reason, party_id_write(), ast_party_name::presentation, ast_party_number::presentation, ast_party_redirecting::priv_from, ast_party_redirecting::priv_orig, ast_party_redirecting::priv_to, ast_party_redirecting::reason, REDIRECTING_OPT_ARG_ARRAY_SIZE, REDIRECTING_OPT_INHIBIT, redirecting_opts, status, ast_party_redirecting_reason::str, ast_party_members::subnames, ast_party_redirecting::to, and update().

1550 {
1551  struct ast_party_redirecting redirecting;
1552  enum ID_FIELD_STATUS status;
1553  char *val;
1554  char *parms;
1555  void (*set_it)(struct ast_channel *chan, const struct ast_party_redirecting *redirecting, const struct ast_set_party_redirecting *update);
1556  struct ast_party_func_args args = { 0, };
1557  struct ast_party_members member = { 0, };
1558  struct ast_flags opts;
1559  char *opt_args[REDIRECTING_OPT_ARG_ARRAY_SIZE];
1560 
1561  if (!value || !chan) {
1562  return -1;
1563  }
1564 
1565  parms = ast_strdupa(data);
1566  AST_STANDARD_APP_ARGS(args, parms);
1567  if (args.argc == 0) {
1568  /* Must have at least one argument. */
1569  return -1;
1570  }
1571 
1572  AST_NONSTANDARD_APP_ARGS(member, args.member, '-');
1573  if (member.argc == 0 || ARRAY_LEN(member.subnames) <= member.argc) {
1574  /* Too few or too many subnames */
1575  return -1;
1576  }
1577 
1578  if (ast_app_parse_options(redirecting_opts, &opts, opt_args, args.opts)) {
1579  /* General invalid option syntax. */
1580  return -1;
1581  }
1582 
1583  /* Determine if the update indication inhibit option is present */
1584  if (ast_test_flag(&opts, REDIRECTING_OPT_INHIBIT)) {
1585  set_it = ast_channel_set_redirecting;
1586  } else {
1588  }
1589 
1590  ast_channel_lock(chan);
1592  ast_channel_unlock(chan);
1593 
1595 
1596  if (!strcasecmp("orig", member.subnames[0])) {
1597  if (member.argc == 2 && !strcasecmp("reason", member.subnames[1])) {
1598  int reason;
1599 
1600  val = ast_strdupa(value);
1601  ast_trim_blanks(val);
1602 
1603  if (('0' <= val[0]) && (val[0] <= '9')) {
1604  reason = atoi(val);
1605  } else {
1606  reason = ast_redirecting_reason_parse(val);
1607  }
1608 
1609  if (reason < 0) {
1610  /* The argument passed into the function does not correspond to a pre-defined
1611  * reason, so we can just set the reason string to what was given and set the
1612  * code to be unknown
1613  */
1615  redirecting.orig_reason.str = val;
1616  set_it(chan, &redirecting, NULL);
1617  } else {
1618  redirecting.orig_reason.code = reason;
1619  redirecting.orig_reason.str = "";
1620  set_it(chan, &redirecting, NULL);
1621  }
1622  } else {
1623  status = party_id_write(&redirecting.orig, member.argc - 1, member.subnames + 1,
1624  value);
1625  switch (status) {
1626  case ID_FIELD_VALID:
1627  set_it(chan, &redirecting, NULL);
1628  break;
1629  case ID_FIELD_INVALID:
1630  break;
1631  default:
1632  ast_log(LOG_ERROR, "Unknown redirecting data type '%s'.\n", data);
1633  break;
1634  }
1635  ast_party_redirecting_free(&redirecting);
1636  }
1637  } else if (!strcasecmp("from", member.subnames[0])) {
1638  status = party_id_write(&redirecting.from, member.argc - 1, member.subnames + 1,
1639  value);
1640  switch (status) {
1641  case ID_FIELD_VALID:
1642  set_it(chan, &redirecting, NULL);
1643  break;
1644  case ID_FIELD_INVALID:
1645  break;
1646  default:
1647  ast_log(LOG_ERROR, "Unknown redirecting data type '%s'.\n", data);
1648  break;
1649  }
1650  ast_party_redirecting_free(&redirecting);
1651  } else if (!strcasecmp("to", member.subnames[0])) {
1652  status = party_id_write(&redirecting.to, member.argc - 1, member.subnames + 1, value);
1653  switch (status) {
1654  case ID_FIELD_VALID:
1655  set_it(chan, &redirecting, NULL);
1656  break;
1657  case ID_FIELD_INVALID:
1658  break;
1659  default:
1660  ast_log(LOG_ERROR, "Unknown redirecting data type '%s'.\n", data);
1661  break;
1662  }
1663  ast_party_redirecting_free(&redirecting);
1664  } else if (member.argc == 1 && !strncasecmp("pres", member.subnames[0], 4)) {
1665  int pres;
1666 
1667  val = ast_strdupa(value);
1668  ast_trim_blanks(val);
1669 
1670  if (('0' <= val[0]) && (val[0] <= '9')) {
1671  pres = atoi(val);
1672  } else {
1673  pres = ast_parse_caller_presentation(val);
1674  }
1675 
1676  if (pres < 0) {
1678  "Unknown redirecting combined presentation '%s', value unchanged\n", val);
1679  } else {
1680  redirecting.from.name.presentation = pres;
1681  redirecting.from.number.presentation = pres;
1682  redirecting.to.name.presentation = pres;
1683  redirecting.to.number.presentation = pres;
1684  set_it(chan, &redirecting, NULL);
1685  }
1686  } else if (member.argc == 1 && !strcasecmp("reason", member.subnames[0])) {
1687  int reason;
1688 
1689  val = ast_strdupa(value);
1690  ast_trim_blanks(val);
1691 
1692  if (('0' <= val[0]) && (val[0] <= '9')) {
1693  reason = atoi(val);
1694  } else {
1695  reason = ast_redirecting_reason_parse(val);
1696  }
1697 
1698  if (reason < 0) {
1699  /* The argument passed into the function does not correspond to a pre-defined
1700  * reason, so we can just set the reason string to what was given and set the
1701  * code to be unknown
1702  */
1704  redirecting.reason.str = val;
1705  set_it(chan, &redirecting, NULL);
1706  } else {
1707  redirecting.reason.code = reason;
1708  redirecting.reason.str = "";
1709  set_it(chan, &redirecting, NULL);
1710  }
1711  } else if (member.argc == 1 && !strcasecmp("count", member.subnames[0])) {
1712  val = ast_strdupa(value);
1713  ast_trim_blanks(val);
1714 
1715  if (('0' <= val[0]) && (val[0] <= '9')) {
1716  redirecting.count = atoi(val);
1717  set_it(chan, &redirecting, NULL);
1718  } else {
1719  ast_log(LOG_ERROR, "Unknown redirecting count '%s', value unchanged\n", val);
1720  }
1721  } else if (1 < member.argc && !strcasecmp("priv", member.subnames[0])) {
1722  if (!strcasecmp("orig", member.subnames[1])) {
1723  status = party_id_write(&redirecting.priv_orig, member.argc - 2, member.subnames + 2,
1724  value);
1725  switch (status) {
1726  case ID_FIELD_VALID:
1727  set_it(chan, &redirecting, NULL);
1728  break;
1729  case ID_FIELD_INVALID:
1730  break;
1731  default:
1732  ast_log(LOG_ERROR, "Unknown redirecting data type '%s'.\n", data);
1733  break;
1734  }
1735  ast_party_redirecting_free(&redirecting);
1736  } else if (!strcasecmp("from", member.subnames[1])) {
1737  status = party_id_write(&redirecting.priv_from, member.argc - 2, member.subnames + 2,
1738  value);
1739  switch (status) {
1740  case ID_FIELD_VALID:
1741  set_it(chan, &redirecting, NULL);
1742  break;
1743  case ID_FIELD_INVALID:
1744  break;
1745  default:
1746  ast_log(LOG_ERROR, "Unknown redirecting data type '%s'.\n", data);
1747  break;
1748  }
1749  ast_party_redirecting_free(&redirecting);
1750  } else if (!strcasecmp("to", member.subnames[1])) {
1751  status = party_id_write(&redirecting.priv_to, member.argc - 2, member.subnames + 2, value);
1752  switch (status) {
1753  case ID_FIELD_VALID:
1754  set_it(chan, &redirecting, NULL);
1755  break;
1756  case ID_FIELD_INVALID:
1757  break;
1758  default:
1759  ast_log(LOG_ERROR, "Unknown redirecting data type '%s'.\n", data);
1760  break;
1761  }
1762  ast_party_redirecting_free(&redirecting);
1763  } else {
1764  ast_log(LOG_ERROR, "Unknown redirecting data type '%s'.\n", data);
1765  }
1766  } else {
1767  ast_log(LOG_ERROR, "Unknown redirecting data type '%s'.\n", data);
1768  }
1769 
1770  return 0;
1771 }
int presentation
Q.931 encoded presentation-indicator encoded field.
Definition: channel.h:278
#define ast_channel_lock(chan)
Definition: channel.h:2945
Main Channel structure associated with a channel.
struct ast_party_id priv_to
Call is redirecting to a new party (Sent to the caller) - private representation. ...
Definition: channel.h:540
#define ARRAY_LEN(a)
Definition: isdn_lib.c:42
int presentation
Q.931 presentation-indicator and screening-indicator encoded fields.
Definition: channel.h:296
Definition: ast_expr2.c:325
#define ast_test_flag(p, flag)
Definition: utils.h:63
struct ast_party_id priv_orig
Who originally redirected the call (Sent to the party the call is redirected toward) - private repres...
Definition: channel.h:534
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:341
struct ast_party_id from
Who is redirecting the call (Sent to the party the call is redirected toward)
Definition: channel.h:528
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:10379
#define AST_STANDARD_APP_ARGS(args, parse)
Performs the &#39;standard&#39; argument separation process for an application.
int ast_redirecting_reason_parse(const char *data)
Convert redirecting reason text code to value (used in config file parsing)
Definition: callerid.c:1223
struct ast_party_id priv_from
Who is redirecting the call (Sent to the party the call is redirected toward) - private representatio...
Definition: channel.h:537
const char * args
#define NULL
Definition: resample.c:96
int value
Definition: syslog.c:37
int code
enum AST_REDIRECTING_REASON value for redirection
Definition: channel.h:511
char * subnames[10]
struct ast_party_id orig
Who originally redirected the call (Sent to the party the call is redirected toward) ...
Definition: channel.h:525
#define ast_log
Definition: astobj2.c:42
struct ast_party_redirecting_reason orig_reason
Reason for the redirection by the original party.
Definition: channel.h:546
#define ast_strdupa(s)
duplicate a string in memory from the stack
Definition: astmm.h:300
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:9215
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: main/app.c:2906
int ast_parse_caller_presentation(const char *data)
Convert caller ID text code to value (used in config file parsing)
Definition: callerid.c:1143
#define LOG_ERROR
Definition: logger.h:285
#define AST_NONSTANDARD_APP_ARGS(args, parse, sep)
Performs the &#39;nonstandard&#39; argument separation process for an application.
char * ast_skip_blanks(const char *str)
Gets a pointer to the first non-whitespace character in a string.
Definition: strings.h:157
Redirecting Line information. RDNIS (Redirecting Directory Number Information Service) Where a call d...
Definition: channel.h:523
char * ast_trim_blanks(char *str)
Trims trailing whitespace characters from a string.
Definition: strings.h:182
char * str
a string value for the redirecting reason
Definition: channel.h:508
#define ast_channel_unlock(chan)
Definition: channel.h:2946
static const struct ast_app_option redirecting_opts[128]
unsigned int argc
ID_FIELD_STATUS
struct ast_party_redirecting_reason reason
Reason for the redirection.
Definition: channel.h:543
Structure used to handle boolean flags.
Definition: utils.h:199
struct ast_party_redirecting * ast_channel_redirecting(struct ast_channel *chan)
void ast_party_redirecting_free(struct ast_party_redirecting *doomed)
Destroy the redirecting information contents.
Definition: channel.c:2179
Indicate what information in ast_party_redirecting should be set.
Definition: channel.h:556
int count
Number of times the call was redirected.
Definition: channel.h:549
struct ast_party_id to
Call is redirecting to a new party (Sent to the caller)
Definition: channel.h:531
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:2153
jack_status_t status
Definition: app_jack.c:146
struct ast_party_number number
Subscriber phone number.
Definition: channel.h:343

◆ unload_module()

static int unload_module ( void  )
static

Definition at line 1799 of file func_callerid.c.

References ast_custom_function_unregister().

Referenced by load_module().

1800 {
1804  return 0;
1805 }
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.
static struct ast_custom_function connectedline_function

Variable Documentation

◆ __mod_info

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 = "30ef0c93b36035ec78c9cfd712d36d9b" , .load = load_module, .unload = unload_module, .load_pri = AST_MODPRI_DEFAULT, .support_level = AST_MODULE_SUPPORT_CORE, }
static

Definition at line 1831 of file func_callerid.c.

◆ ast_module_info

const struct ast_module_info* ast_module_info = &__mod_info
static

Definition at line 1831 of file func_callerid.c.

◆ callerid_function

struct ast_custom_function callerid_function
static

Definition at line 1773 of file func_callerid.c.

◆ connectedline_function

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 1780 of file func_callerid.c.

◆ connectedline_opts

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

Definition at line 463 of file func_callerid.c.

Referenced by connectedline_write().

◆ redirecting_function

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 1786 of file func_callerid.c.

◆ redirecting_opts

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

Definition at line 477 of file func_callerid.c.

Referenced by redirecting_write().