Asterisk - The Open Source Telephony Project GIT-master-f36a736
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 = AST_BUILDOPT_SUM, .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 471 of file func_callerid.c.

471 {
472 CONNECTED_LINE_OPT_DUMMY, /*!< Delete this if CONNECTED_LINE ever gets an option with parameters. */
473
474 /*! \note This entry _MUST_ be the last one in the enum */
476};
@ CONNECTED_LINE_OPT_ARG_ARRAY_SIZE
@ CONNECTED_LINE_OPT_DUMMY

◆ CONNECTED_LINE_OPT_FLAGS

Enumerator
CONNECTED_LINE_OPT_INHIBIT 

Definition at line 468 of file func_callerid.c.

468 {
470};
@ CONNECTED_LINE_OPT_INHIBIT

◆ ID_FIELD_STATUS

Enumerator
ID_FIELD_VALID 
ID_FIELD_INVALID 
ID_FIELD_UNKNOWN 

Definition at line 452 of file func_callerid.c.

452 {
456};
@ ID_FIELD_INVALID
@ ID_FIELD_VALID
@ ID_FIELD_UNKNOWN

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

485 {
486 REDIRECTING_OPT_DUMMY, /*!< Delete this if REDIRECTING ever gets an option with parameters. */
487
488 /*! \note This entry _MUST_ be the last one in the enum */
490};
@ REDIRECTING_OPT_ARG_ARRAY_SIZE
@ REDIRECTING_OPT_DUMMY

◆ REDIRECTING_OPT_FLAGS

Enumerator
REDIRECTING_OPT_INHIBIT 

Definition at line 482 of file func_callerid.c.

482 {
483 REDIRECTING_OPT_INHIBIT = (1 << 0),
484};
@ REDIRECTING_OPT_INHIBIT

Function Documentation

◆ __reg_module()

static void __reg_module ( void  )
static

Definition at line 1850 of file func_callerid.c.

◆ __unreg_module()

static void __unreg_module ( void  )
static

Definition at line 1850 of file func_callerid.c.

◆ AST_MODULE_SELF_SYM()

struct ast_module * AST_MODULE_SELF_SYM ( void  )

Definition at line 1850 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.

Definition at line 947 of file func_callerid.c.

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

References 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, buf, ID_FIELD_INVALID, ID_FIELD_VALID, len(), LOG_ERROR, name, party_id_read(), party_subaddress_read(), and status.

◆ callerid_write()

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

Definition at line 1100 of file func_callerid.c.

1101{
1102 struct ast_party_caller caller;
1103 struct ast_party_dialed dialed;
1105 char *val;
1106 char *parms;
1107 struct ast_party_func_args args = { 0, };
1108 struct ast_party_members member = { 0, };
1109
1110 if (!value || !chan) {
1111 return -1;
1112 }
1113
1114 parms = ast_strdupa(data);
1116 if (args.argc == 0) {
1117 /* Must have at least one argument. */
1118 return -1;
1119 }
1120
1121 AST_NONSTANDARD_APP_ARGS(member, args.member, '-');
1122 if (member.argc == 0 || ARRAY_LEN(member.subnames) <= member.argc) {
1123 /* Too few or too many subnames */
1124 return -1;
1125 }
1126
1128
1129 ast_channel_lock(chan);
1130 if (member.argc == 1 && !strcasecmp("rdnis", member.subnames[0])) {
1132 ast_free(ast_channel_redirecting(chan)->from.number.str);
1134 } else if (!strcasecmp("dnid", member.subnames[0])) {
1136 if (member.argc == 1) {
1137 /* Setup as if user had given dnid-num instead. */
1138 member.argc = 2;
1139 member.subnames[1] = "num";
1140 }
1141 if (!strncasecmp("num", member.subnames[1], 3)) {
1142 /*
1143 * Accept num[ber]
1144 * dnid-num...
1145 */
1146 if (member.argc == 2) {
1147 /* dnid-num */
1148 dialed.number.str = ast_strdup(value);
1149 ast_trim_blanks(dialed.number.str);
1151 } else if (member.argc == 3 && !strcasecmp("plan", member.subnames[2])) {
1152 /* dnid-num-plan */
1155
1156 if (('0' <= val[0]) && (val[0] <= '9')) {
1157 ast_channel_dialed(chan)->number.plan = atoi(val);
1158 } else {
1160 "Unknown type-of-number/numbering-plan '%s', value unchanged\n", val);
1161 }
1162 } else {
1163 ast_log(LOG_ERROR, "Unknown callerid data type '%s'.\n", data);
1164 }
1165 } else if (!strncasecmp("subaddr", member.subnames[1], 7)) {
1166 /*
1167 * Accept subaddr[ess]
1168 * dnid-subaddr...
1169 */
1170 status = party_subaddress_write(&dialed.subaddress, member.argc - 2,
1171 member.subnames + 2, value);
1172 switch (status) {
1173 case ID_FIELD_VALID:
1175 break;
1176 case ID_FIELD_INVALID:
1177 break;
1178 default:
1179 ast_log(LOG_ERROR, "Unknown callerid data type '%s'.\n", data);
1180 break;
1181 }
1182 } else {
1183 ast_log(LOG_ERROR, "Unknown callerid data type '%s'.\n", data);
1184 }
1185 ast_party_dialed_free(&dialed);
1186 } else if (member.argc == 1 && !strcasecmp("ani2", member.subnames[0])) {
1189
1190 if (('0' <= val[0]) && (val[0] <= '9')) {
1191 ast_channel_caller(chan)->ani2 = atoi(val);
1192 } else {
1193 ast_log(LOG_ERROR, "Unknown callerid ani2 '%s', value unchanged\n", val);
1194 }
1195 } else if (!strcasecmp("ani", member.subnames[0])) {
1197 if (member.argc == 1) {
1198 /* Setup as if user had given ani-num instead. */
1199 member.argc = 2;
1200 member.subnames[1] = "num";
1201 }
1202 status = party_id_write(&caller.ani, member.argc - 1, member.subnames + 1, value);
1203 switch (status) {
1204 case ID_FIELD_VALID:
1206 break;
1207 case ID_FIELD_INVALID:
1208 break;
1209 default:
1210 ast_log(LOG_ERROR, "Unknown callerid data type '%s'.\n", data);
1211 break;
1212 }
1213 ast_party_caller_free(&caller);
1214 } else if (!strcasecmp("priv", member.subnames[0])) {
1216 status = party_id_write(&caller.priv, member.argc - 1, member.subnames + 1, value);
1217 switch (status) {
1218 case ID_FIELD_VALID:
1220 break;
1221 case ID_FIELD_INVALID:
1222 break;
1223 default:
1224 ast_log(LOG_ERROR, "Unknown callerid data type '%s'.\n", data);
1225 break;
1226 }
1227 ast_party_caller_free(&caller);
1228 } else {
1230 status = party_id_write(&caller.id, member.argc, member.subnames, value);
1231 switch (status) {
1232 case ID_FIELD_VALID:
1233 ast_channel_set_caller_event(chan, &caller, NULL);
1234 break;
1235 case ID_FIELD_INVALID:
1236 break;
1237 default:
1238 ast_log(LOG_ERROR, "Unknown callerid data type '%s'.\n", data);
1239 break;
1240 }
1241 ast_party_caller_free(&caller);
1242 }
1243 ast_channel_unlock(chan);
1244
1245 return 0;
1246}
#define ast_free(a)
Definition: astmm.h:180
#define ast_strdup(str)
A wrapper for strdup()
Definition: astmm.h:241
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:1969
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:7394
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:2026
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:2018
void ast_party_dialed_free(struct ast_party_dialed *doomed)
Destroy the dialed party contents.
Definition: channel.c:1990
void ast_party_caller_free(struct ast_party_caller *doomed)
Destroy the caller party contents.
Definition: channel.c:2034
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:1977
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_subaddress_write(struct ast_party_subaddress *subaddress, int argc, char *argv[], const char *value)
#define NULL
Definition: resample.c:96
char * ast_trim_blanks(char *str)
Trims trailing whitespace characters from a string.
Definition: strings.h:186
char * ast_skip_blanks(const char *str)
Gets a pointer to the first non-whitespace character in a string.
Definition: strings.h:161
Caller Party information.
Definition: channel.h:420
int ani2
Automatic Number Identification 2 (Info Digits)
Definition: channel.h:435
Dialed/Called Party information.
Definition: channel.h:380
struct ast_party_dialed::@208 number
Dialed/Called number.
int plan
Q.931 Type-Of-Number and Numbering-Plan encoded fields.
Definition: channel.h:390
struct ast_party_number number
Subscriber phone number.
Definition: channel.h:344
unsigned char valid
TRUE if the number information is valid/present.
Definition: channel.h:299
char * str
Subscriber phone number (Malloced)
Definition: channel.h:293
struct ast_party_id from
Who is redirecting the call (Sent to the party the call is redirected toward)
Definition: channel.h:529
Definition: ast_expr2.c:325
int value
Definition: syslog.c:37

References ast_party_caller::ani, ast_party_caller::ani2, args, 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, 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_number::valid, and value.

◆ connectedline_read()

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

Definition at line 1261 of file func_callerid.c.

1262{
1263 struct ast_party_members member = { 0, };
1264 char *read_what;
1266
1267 /* Ensure that the buffer is empty */
1268 *buf = 0;
1269
1270 if (!chan) {
1271 return -1;
1272 }
1273
1274 read_what = ast_strdupa(data);
1275 AST_NONSTANDARD_APP_ARGS(member, read_what, '-');
1276 if (member.argc == 0 || ARRAY_LEN(member.subnames) <= member.argc) {
1277 /* Too few or too many subnames */
1278 return -1;
1279 }
1280
1281 ast_channel_lock(chan);
1282
1283 if (member.argc == 1 && !strcasecmp("source", member.subnames[0])) {
1285 } else if (!strcasecmp("priv", member.subnames[0])) {
1286 status = party_id_read(buf, len, member.argc - 1, member.subnames + 1,
1287 &ast_channel_connected(chan)->priv);
1288 switch (status) {
1289 case ID_FIELD_VALID:
1290 case ID_FIELD_INVALID:
1291 break;
1292 default:
1293 ast_log(LOG_ERROR, "Unknown connectedline data type '%s'.\n", data);
1294 break;
1295 }
1296 } else {
1297 status = party_id_read(buf, len, member.argc, member.subnames, &ast_channel_connected(chan)->id);
1298 switch (status) {
1299 case ID_FIELD_VALID:
1300 case ID_FIELD_INVALID:
1301 break;
1302 default:
1303 ast_log(LOG_ERROR, "Unknown connectedline data type '%s'.\n", data);
1304 break;
1305 }
1306 }
1307
1308 ast_channel_unlock(chan);
1309
1310 return 0;
1311}
const char * ast_connected_line_source_name(int data)
Convert connected line update source value to text code.
Definition: callerid.c:1505
struct ast_party_connected_line * ast_channel_connected(struct ast_channel *chan)

References 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, buf, ID_FIELD_INVALID, ID_FIELD_VALID, len(), LOG_ERROR, party_id_read(), and status.

◆ connectedline_write()

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

Definition at line 1325 of file func_callerid.c.

1326{
1328 char *val;
1329 char *parms;
1330 void (*set_it)(struct ast_channel *chan, const struct ast_party_connected_line *connected, const struct ast_set_party_connected_line *update);
1331 struct ast_party_func_args args = { 0, };
1332 struct ast_party_members member = { 0, };
1333 struct ast_flags opts;
1334 char *opt_args[CONNECTED_LINE_OPT_ARG_ARRAY_SIZE];
1336
1337 if (!value || !chan) {
1338 return -1;
1339 }
1340
1341 parms = ast_strdupa(data);
1343 if (args.argc == 0) {
1344 /* Must have at least one argument. */
1345 return -1;
1346 }
1347
1348 AST_NONSTANDARD_APP_ARGS(member, args.member, '-');
1349 if (member.argc == 0 || ARRAY_LEN(member.subnames) <= member.argc) {
1350 /* Too few or too many subnames */
1351 return -1;
1352 }
1353
1354 if (ast_app_parse_options(connectedline_opts, &opts, opt_args, args.opts)) {
1355 /* General invalid option syntax. */
1356 return -1;
1357 }
1358
1359 /* Determine if the update indication inhibit option is present */
1362 } else {
1364 }
1365
1366 ast_channel_lock(chan);
1368 ast_channel_unlock(chan);
1369
1371
1372 if (member.argc == 1 && !strcasecmp("source", member.subnames[0])) {
1373 int source;
1374
1377
1378 if (('0' <= val[0]) && (val[0] <= '9')) {
1379 source = atoi(val);
1380 } else {
1382 }
1383
1384 if (source < 0) {
1385 ast_log(LOG_ERROR, "Unknown connectedline source '%s', value unchanged\n", val);
1386 } else {
1387 connected.source = source;
1388 set_it(chan, &connected, NULL);
1389 }
1390 } else if (!strcasecmp("priv", member.subnames[0])) {
1391 status = party_id_write(&connected.priv, member.argc - 1, member.subnames + 1, value);
1392 switch (status) {
1393 case ID_FIELD_VALID:
1394 set_it(chan, &connected, NULL);
1395 break;
1396 case ID_FIELD_INVALID:
1397 break;
1398 default:
1399 ast_log(LOG_ERROR, "Unknown connectedline data type '%s'.\n", data);
1400 break;
1401 }
1403 } else {
1404 status = party_id_write(&connected.id, member.argc, member.subnames, value);
1405 switch (status) {
1406 case ID_FIELD_VALID:
1407 set_it(chan, &connected, NULL);
1408 break;
1409 case ID_FIELD_INVALID:
1410 break;
1411 default:
1412 ast_log(LOG_ERROR, "Unknown connectedline data type '%s'.\n", data);
1413 break;
1414 }
1416 }
1417
1418 return 0;
1419}
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:1479
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:8330
void ast_party_connected_line_free(struct ast_party_connected_line *doomed)
Destroy the connected line information contents.
Definition: channel.c:2091
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:9115
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:2064
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
char connected
Definition: eagi_proxy.c:82
static const struct ast_app_option connectedline_opts[128]
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:3066
Main Channel structure associated with a channel.
Structure used to handle boolean flags.
Definition: utils.h:199
Connected Line/Party information.
Definition: channel.h:458
Indicate what information in ast_party_connected_line should be set.
Definition: channel.h:491
#define ast_test_flag(p, flag)
Definition: utils.h:63

References args, 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, ID_FIELD_INVALID, ID_FIELD_VALID, LOG_ERROR, NULL, party_id_write(), status, update(), and value.

◆ load_module()

static int load_module ( void  )
static

Definition at line 1833 of file func_callerid.c.

1834{
1835 int res;
1836
1840
1841 if (res) {
1842 unload_module();
1844 }
1845
1847}
static struct ast_custom_function callerid_function
static struct ast_custom_function connectedline_function
static int unload_module(void)
static struct ast_custom_function redirecting_function
@ AST_MODULE_LOAD_SUCCESS
Definition: module.h:70
@ AST_MODULE_LOAD_DECLINE
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:1558

References ast_custom_function_register, AST_MODULE_LOAD_DECLINE, AST_MODULE_LOAD_SUCCESS, callerid_function, connectedline_function, redirecting_function, and unload_module().

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

627{
629
630 if (argc == 0) {
631 /* Must have at least one subname. */
632 return ID_FIELD_UNKNOWN;
633 }
634
636
637 if (argc == 1 && !strcasecmp("all", argv[0])) {
638 snprintf(buf, len, "\"%s\" <%s>",
639 S_COR(id->name.valid, id->name.str, ""),
640 S_COR(id->number.valid, id->number.str, ""));
641 } else if (!strcasecmp("name", argv[0])) {
642 status = party_name_read(buf, len, argc - 1, argv + 1, &id->name);
643 } else if (!strncasecmp("num", argv[0], 3)) {
644 /* Accept num[ber] */
645 status = party_number_read(buf, len, argc - 1, argv + 1, &id->number);
646 } else if (!strncasecmp("subaddr", argv[0], 7)) {
647 /* Accept subaddr[ess] */
648 status = party_subaddress_read(buf, len, argc - 1, argv + 1, &id->subaddress);
649 } else if (argc == 1 && !strcasecmp("tag", argv[0])) {
650 if (id->tag) {
651 ast_copy_string(buf, id->tag, len);
652 }
653 } else if (argc == 1 && !strcasecmp("ton", argv[0])) {
654 /* ton is an alias for num-plan */
655 snprintf(buf, len, "%d", id->number.plan);
656 } else if (argc == 1 && !strncasecmp("pres", argv[0], 4)) {
657 /*
658 * Accept pres[entation]
659 * This is the combined name/number presentation.
660 */
663 } else {
665 }
666
667 return status;
668}
enum queue_result id
Definition: app_queue.c:1667
const char * ast_named_caller_presentation(int data)
Convert caller ID pres value to text code.
Definition: callerid.c:1382
int ast_party_id_presentation(const struct ast_party_id *id)
Determine the overall presentation value for the given party.
Definition: channel.c:1840
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_number_read(char *buf, size_t len, int argc, char *argv[], const struct ast_party_number *number)
#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:87

References ast_copy_string(), ast_named_caller_presentation(), ast_party_id_presentation(), buf, id, ID_FIELD_UNKNOWN, ID_FIELD_VALID, len(), party_name_read(), party_number_read(), party_subaddress_read(), S_COR, and status.

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

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

862{
863 char *val;
865
866 if (argc == 0) {
867 /* Must have at least one subname. */
868 return ID_FIELD_UNKNOWN;
869 }
870
872
873 if (argc == 1 && !strcasecmp("all", argv[0])) {
874 char name[256];
875 char num[256];
876
877 ast_callerid_split(value, name, sizeof(name), num, sizeof(num));
878 id->name.valid = 1;
879 id->name.str = ast_strdup(name);
880 if (!id->name.str) {
881 return ID_FIELD_INVALID;
882 }
883 id->number.valid = 1;
884 id->number.str = ast_strdup(num);
885 if (!id->number.str) {
886 return ID_FIELD_INVALID;
887 }
888 } else if (!strcasecmp("name", argv[0])) {
889 status = party_name_write(&id->name, argc - 1, argv + 1, value);
890 } else if (!strncasecmp("num", argv[0], 3)) {
891 /* Accept num[ber] */
892 status = party_number_write(&id->number, argc - 1, argv + 1, value);
893 } else if (!strncasecmp("subaddr", argv[0], 7)) {
894 /* Accept subaddr[ess] */
895 status = party_subaddress_write(&id->subaddress, argc - 1, argv + 1, value);
896 } else if (argc == 1 && !strcasecmp("tag", argv[0])) {
897 id->tag = ast_strdup(value);
898 ast_trim_blanks(id->tag);
899 } else if (argc == 1 && !strcasecmp("ton", argv[0])) {
900 /* ton is an alias for num-plan */
901 argv[0] = "plan";
902 status = party_number_write(&id->number, argc, argv, value);
903 } else if (argc == 1 && !strncasecmp("pres", argv[0], 4)) {
904 int pres;
905
906 /*
907 * Accept pres[entation]
908 * This is the combined name/number presentation.
909 */
912
913 if (('0' <= val[0]) && (val[0] <= '9')) {
914 pres = atoi(val);
915 } else {
917 }
918
919 if (pres < 0) {
921 "Unknown combined presentation '%s', value unchanged\n", val);
923 } else {
924 id->name.presentation = pres;
925 id->number.presentation = pres;
926 }
927 } else {
929 }
930
931 return status;
932}
int ast_parse_caller_presentation(const char *data)
Convert caller ID text code to value (used in config file parsing)
Definition: callerid.c:1343
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_write(struct ast_party_number *number, int argc, char *argv[], const char *value)

References ast_callerid_split(), ast_log, ast_parse_caller_presentation(), ast_strdup, ast_strdupa, ast_trim_blanks(), id, ID_FIELD_INVALID, ID_FIELD_UNKNOWN, ID_FIELD_VALID, LOG_ERROR, name, party_name_write(), party_number_write(), party_subaddress_write(), status, and value.

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

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

511{
513
515
516 if (argc == 0) {
517 /* We want the name string */
518 if (name->valid && name->str) {
519 ast_copy_string(buf, name->str, len);
520 }
521 } else if (argc == 1 && !strcasecmp("valid", argv[0])) {
522 snprintf(buf, len, "%d", name->valid);
523 } else if (argc == 1 && !strcasecmp("charset", argv[0])) {
525 } else if (argc == 1 && !strncasecmp("pres", argv[0], 4)) {
526 /* Accept pres[entation] */
528 } else {
530 }
531
532 return status;
533}
const char * ast_party_name_charset_str(int data)
Convert ast_party_name.char_set value to text code.
Definition: callerid.c:1560

References ast_copy_string(), ast_named_caller_presentation(), ast_party_name_charset_str(), buf, ID_FIELD_UNKNOWN, ID_FIELD_VALID, len(), name, and status.

Referenced by party_id_read().

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

685{
686 char *val;
688
690
691 if (argc == 0) {
692 /* We are setting the name string */
693 name->valid = 1;
694 name->str = ast_strdup(value);
695 ast_trim_blanks(name->str);
696 } else if (argc == 1 && !strcasecmp("valid", argv[0])) {
697 name->valid = atoi(value) ? 1 : 0;
698 } else if (argc == 1 && !strcasecmp("charset", argv[0])) {
699 int char_set;
700
703
704 if (('0' <= val[0]) && (val[0] <= '9')) {
705 char_set = atoi(val);
706 } else {
708 }
709
710 if (char_set < 0) {
712 "Unknown name char-set '%s', value unchanged\n", val);
714 } else {
715 name->char_set = char_set;
716 }
717 } else if (argc == 1 && !strncasecmp("pres", argv[0], 4)) {
718 int pres;
719
720 /* Accept pres[entation] */
723
724 if (('0' <= val[0]) && (val[0] <= '9')) {
725 pres = atoi(val);
726 } else {
728 }
729
730 if (pres < 0) {
732 "Unknown name presentation '%s', value unchanged\n", val);
734 } else {
735 name->presentation = pres;
736 }
737 } else {
739 }
740
741 return status;
742}
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:1534

References ast_log, ast_parse_caller_presentation(), ast_party_name_charset_parse(), ast_strdup, ast_strdupa, ast_trim_blanks(), ID_FIELD_INVALID, ID_FIELD_UNKNOWN, ID_FIELD_VALID, LOG_ERROR, name, status, and value.

Referenced by party_id_write().

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

550{
552
554
555 if (argc == 0) {
556 /* We want the number string */
557 if (number->valid && number->str) {
559 }
560 } else if (argc == 1 && !strcasecmp("valid", argv[0])) {
561 snprintf(buf, len, "%d", number->valid);
562 } else if (argc == 1 && !strcasecmp("plan", argv[0])) {
563 snprintf(buf, len, "%d", number->plan);
564 } else if (argc == 1 && !strncasecmp("pres", argv[0], 4)) {
565 /* Accept pres[entation] */
567 } else {
569 }
570
571 return status;
572}

References ast_copy_string(), ast_named_caller_presentation(), buf, ID_FIELD_UNKNOWN, ID_FIELD_VALID, len(), and status.

Referenced by party_id_read().

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

759{
760 char *val;
762
764
765 if (argc == 0) {
766 /* We are setting the number string */
767 number->valid = 1;
768 number->str = ast_strdup(value);
770 } else if (argc == 1 && !strcasecmp("valid", argv[0])) {
771 number->valid = atoi(value) ? 1 : 0;
772 } else if (argc == 1 && !strcasecmp("plan", argv[0])) {
775
776 if (('0' <= val[0]) && (val[0] <= '9')) {
777 number->plan = atoi(val);
778 } else {
780 "Unknown type-of-number/numbering-plan '%s', value unchanged\n", val);
782 }
783 } else if (argc == 1 && !strncasecmp("pres", argv[0], 4)) {
784 int pres;
785
786 /* Accept pres[entation] */
789
790 if (('0' <= val[0]) && (val[0] <= '9')) {
791 pres = atoi(val);
792 } else {
794 }
795
796 if (pres < 0) {
798 "Unknown number presentation '%s', value unchanged\n", val);
800 } else {
801 number->presentation = pres;
802 }
803 } else {
805 }
806
807 return status;
808}

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, status, and value.

Referenced by party_id_write().

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

589{
591
593
594 if (argc == 0) {
595 /* We want the subaddress string */
596 if (subaddress->str) {
597 ast_copy_string(buf, subaddress->str, len);
598 }
599 } else if (argc == 1 && !strcasecmp("valid", argv[0])) {
600 snprintf(buf, len, "%d", subaddress->valid);
601 } else if (argc == 1 && !strcasecmp("type", argv[0])) {
602 snprintf(buf, len, "%d", subaddress->type);
603 } else if (argc == 1 && !strcasecmp("odd", argv[0])) {
604 snprintf(buf, len, "%d", subaddress->odd_even_indicator);
605 } else {
607 }
608
609 return status;
610}
unsigned char odd_even_indicator
TRUE if odd number of address signals.
Definition: channel.h:328
unsigned char valid
TRUE if the subaddress information is valid/present.
Definition: channel.h:330
char * str
Malloced subaddress string.
Definition: channel.h:315
int type
Q.931 subaddress type.
Definition: channel.h:322

References ast_copy_string(), buf, ID_FIELD_UNKNOWN, ID_FIELD_VALID, len(), 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().

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

825{
827
829
830 if (argc == 0) {
831 /* We are setting the subaddress string */
832 subaddress->str = ast_strdup(value);
833 ast_trim_blanks(subaddress->str);
834 } else if (argc == 1 && !strcasecmp("valid", argv[0])) {
835 subaddress->valid = atoi(value) ? 1 : 0;
836 } else if (argc == 1 && !strcasecmp("type", argv[0])) {
837 subaddress->type = atoi(value) ? 2 : 0;
838 } else if (argc == 1 && !strcasecmp("odd", argv[0])) {
839 subaddress->odd_even_indicator = atoi(value) ? 1 : 0;
840 } else {
842 }
843
844 return status;
845}

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, ast_party_subaddress::valid, and value.

Referenced by callerid_write(), and party_id_write().

◆ redirecting_read()

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

Definition at line 1434 of file func_callerid.c.

1435{
1436 struct ast_party_members member = { 0, };
1437 char *read_what;
1438 const struct ast_party_redirecting *ast_redirecting;
1440
1441 /* Ensure that the buffer is empty */
1442 *buf = 0;
1443
1444 if (!chan) {
1445 return -1;
1446 }
1447
1448 read_what = ast_strdupa(data);
1449 AST_NONSTANDARD_APP_ARGS(member, read_what, '-');
1450 if (member.argc == 0 || ARRAY_LEN(member.subnames) <= member.argc) {
1451 /* Too few or too many subnames */
1452 return -1;
1453 }
1454
1455 ast_channel_lock(chan);
1456
1457 ast_redirecting = ast_channel_redirecting(chan);
1458 if (!strcasecmp("orig", member.subnames[0])) {
1459 if (member.argc == 2 && !strcasecmp("reason", member.subnames[1])) {
1461 ast_redirecting_reason_name(&ast_redirecting->orig_reason), len);
1462 } else {
1463 status = party_id_read(buf, len, member.argc - 1, member.subnames + 1,
1464 &ast_redirecting->orig);
1465 switch (status) {
1466 case ID_FIELD_VALID:
1467 case ID_FIELD_INVALID:
1468 break;
1469 default:
1470 ast_log(LOG_ERROR, "Unknown redirecting data type '%s'.\n", data);
1471 break;
1472 }
1473 }
1474 } else if (!strcasecmp("from", member.subnames[0])) {
1475 status = party_id_read(buf, len, member.argc - 1, member.subnames + 1,
1476 &ast_redirecting->from);
1477 switch (status) {
1478 case ID_FIELD_VALID:
1479 case ID_FIELD_INVALID:
1480 break;
1481 default:
1482 ast_log(LOG_ERROR, "Unknown redirecting data type '%s'.\n", data);
1483 break;
1484 }
1485 } else if (!strcasecmp("to", member.subnames[0])) {
1486 status = party_id_read(buf, len, member.argc - 1, member.subnames + 1,
1487 &ast_redirecting->to);
1488 switch (status) {
1489 case ID_FIELD_VALID:
1490 case ID_FIELD_INVALID:
1491 break;
1492 default:
1493 ast_log(LOG_ERROR, "Unknown redirecting data type '%s'.\n", data);
1494 break;
1495 }
1496 } else if (member.argc == 1 && !strncasecmp("pres", member.subnames[0], 4)) {
1497 /*
1498 * Accept pres[entation]
1499 * This is the combined from name/number presentation.
1500 */
1503 ast_party_id_presentation(&ast_redirecting->from)), len);
1504 } else if (member.argc == 1 && !strcasecmp("reason", member.subnames[0])) {
1506 } else if (member.argc == 1 && !strcasecmp("count", member.subnames[0])) {
1507 snprintf(buf, len, "%d", ast_redirecting->count);
1508 } else if (1 < member.argc && !strcasecmp("priv", member.subnames[0])) {
1509 if (!strcasecmp("orig", member.subnames[1])) {
1510 status = party_id_read(buf, len, member.argc - 2, member.subnames + 2,
1511 &ast_redirecting->priv_orig);
1512 switch (status) {
1513 case ID_FIELD_VALID:
1514 case ID_FIELD_INVALID:
1515 break;
1516 default:
1517 ast_log(LOG_ERROR, "Unknown redirecting data type '%s'.\n", data);
1518 break;
1519 }
1520 } else if (!strcasecmp("from", member.subnames[1])) {
1521 status = party_id_read(buf, len, member.argc - 2, member.subnames + 2,
1522 &ast_redirecting->priv_from);
1523 switch (status) {
1524 case ID_FIELD_VALID:
1525 case ID_FIELD_INVALID:
1526 break;
1527 default:
1528 ast_log(LOG_ERROR, "Unknown redirecting data type '%s'.\n", data);
1529 break;
1530 }
1531 } else if (!strcasecmp("to", member.subnames[1])) {
1532 status = party_id_read(buf, len, member.argc - 2, member.subnames + 2,
1533 &ast_redirecting->priv_to);
1534 switch (status) {
1535 case ID_FIELD_VALID:
1536 case ID_FIELD_INVALID:
1537 break;
1538 default:
1539 ast_log(LOG_ERROR, "Unknown redirecting data type '%s'.\n", data);
1540 break;
1541 }
1542 } else {
1543 ast_log(LOG_ERROR, "Unknown redirecting data type '%s'.\n", data);
1544 }
1545 } else {
1546 ast_log(LOG_ERROR, "Unknown redirecting data type '%s'.\n", data);
1547 }
1548
1549 ast_channel_unlock(chan);
1550
1551 return 0;
1552}
const char * ast_redirecting_reason_name(const struct ast_party_redirecting_reason *data)
Convert redirecting reason value to text code.
Definition: callerid.c:1449
Redirecting Line information. RDNIS (Redirecting Directory Number Information Service) Where a call d...
Definition: channel.h:524
struct ast_party_id priv_to
Call is redirecting to a new party (Sent to the caller) - private representation.
Definition: channel.h:541
struct ast_party_redirecting_reason orig_reason
Reason for the redirection by the original party.
Definition: channel.h:547
struct ast_party_redirecting_reason reason
Reason for the redirection.
Definition: channel.h:544
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:538
int count
Number of times the call was redirected.
Definition: channel.h:550
struct ast_party_id to
Call is redirecting to a new party (Sent to the caller)
Definition: channel.h:532
struct ast_party_id orig
Who originally redirected the call (Sent to the party the call is redirected toward)
Definition: channel.h:526
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:535

References 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, buf, ast_party_redirecting::count, ast_party_redirecting::from, ID_FIELD_INVALID, ID_FIELD_VALID, len(), 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, and ast_party_redirecting::to.

◆ redirecting_write()

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

Definition at line 1566 of file func_callerid.c.

1567{
1568 struct ast_party_redirecting redirecting;
1570 char *val;
1571 char *parms;
1572 void (*set_it)(struct ast_channel *chan, const struct ast_party_redirecting *redirecting, const struct ast_set_party_redirecting *update);
1573 struct ast_party_func_args args = { 0, };
1574 struct ast_party_members member = { 0, };
1575 struct ast_flags opts;
1576 char *opt_args[REDIRECTING_OPT_ARG_ARRAY_SIZE];
1577
1578 if (!value || !chan) {
1579 return -1;
1580 }
1581
1582 parms = ast_strdupa(data);
1584 if (args.argc == 0) {
1585 /* Must have at least one argument. */
1586 return -1;
1587 }
1588
1589 AST_NONSTANDARD_APP_ARGS(member, args.member, '-');
1590 if (member.argc == 0 || ARRAY_LEN(member.subnames) <= member.argc) {
1591 /* Too few or too many subnames */
1592 return -1;
1593 }
1594
1595 if (ast_app_parse_options(redirecting_opts, &opts, opt_args, args.opts)) {
1596 /* General invalid option syntax. */
1597 return -1;
1598 }
1599
1600 /* Determine if the update indication inhibit option is present */
1603 } else {
1605 }
1606
1607 ast_channel_lock(chan);
1609 ast_channel_unlock(chan);
1610
1612
1613 if (!strcasecmp("orig", member.subnames[0])) {
1614 if (member.argc == 2 && !strcasecmp("reason", member.subnames[1])) {
1615 int reason;
1616
1619
1620 if (('0' <= val[0]) && (val[0] <= '9')) {
1621 reason = atoi(val);
1622 } else {
1624 }
1625
1626 if (reason < 0) {
1627 /* The argument passed into the function does not correspond to a pre-defined
1628 * reason, so we can just set the reason string to what was given and set the
1629 * code to be unknown
1630 */
1631 ast_log(LOG_WARNING, "Unknown redirecting reason '%s', defaulting to unknown\n", val);
1633 redirecting.orig_reason.str = val;
1634 set_it(chan, &redirecting, NULL);
1635 } else {
1636 redirecting.orig_reason.code = reason;
1637 redirecting.orig_reason.str = "";
1638 set_it(chan, &redirecting, NULL);
1639 }
1640 } else {
1641 status = party_id_write(&redirecting.orig, member.argc - 1, member.subnames + 1,
1642 value);
1643 switch (status) {
1644 case ID_FIELD_VALID:
1645 set_it(chan, &redirecting, NULL);
1646 break;
1647 case ID_FIELD_INVALID:
1648 break;
1649 default:
1650 ast_log(LOG_ERROR, "Unknown redirecting data type '%s'.\n", data);
1651 break;
1652 }
1653 ast_party_redirecting_free(&redirecting);
1654 }
1655 } else if (!strcasecmp("from", member.subnames[0])) {
1656 status = party_id_write(&redirecting.from, member.argc - 1, member.subnames + 1,
1657 value);
1658 switch (status) {
1659 case ID_FIELD_VALID:
1660 set_it(chan, &redirecting, NULL);
1661 break;
1662 case ID_FIELD_INVALID:
1663 break;
1664 default:
1665 ast_log(LOG_ERROR, "Unknown redirecting data type '%s'.\n", data);
1666 break;
1667 }
1668 ast_party_redirecting_free(&redirecting);
1669 } else if (!strcasecmp("to", member.subnames[0])) {
1670 status = party_id_write(&redirecting.to, member.argc - 1, member.subnames + 1, value);
1671 switch (status) {
1672 case ID_FIELD_VALID:
1673 set_it(chan, &redirecting, NULL);
1674 break;
1675 case ID_FIELD_INVALID:
1676 break;
1677 default:
1678 ast_log(LOG_ERROR, "Unknown redirecting data type '%s'.\n", data);
1679 break;
1680 }
1681 ast_party_redirecting_free(&redirecting);
1682 } else if (member.argc == 1 && !strncasecmp("pres", member.subnames[0], 4)) {
1683 int pres;
1684
1687
1688 if (('0' <= val[0]) && (val[0] <= '9')) {
1689 pres = atoi(val);
1690 } else {
1692 }
1693
1694 if (pres < 0) {
1696 "Unknown redirecting combined presentation '%s', value unchanged\n", val);
1697 } else {
1698 redirecting.from.name.presentation = pres;
1699 redirecting.from.number.presentation = pres;
1700 redirecting.to.name.presentation = pres;
1701 redirecting.to.number.presentation = pres;
1702 set_it(chan, &redirecting, NULL);
1703 }
1704 } else if (member.argc == 1 && !strcasecmp("reason", member.subnames[0])) {
1705 int reason;
1706
1709
1710 if (('0' <= val[0]) && (val[0] <= '9')) {
1711 reason = atoi(val);
1712 } else {
1714 }
1715
1716 if (reason < 0) {
1717 /* The argument passed into the function does not correspond to a pre-defined
1718 * reason, so we can just set the reason string to what was given and set the
1719 * code to be unknown
1720 */
1721 ast_log(LOG_WARNING, "Unknown redirecting reason '%s', defaulting to unknown\n", val);
1723 redirecting.reason.str = val;
1724 set_it(chan, &redirecting, NULL);
1725 } else {
1726 redirecting.reason.code = reason;
1727 redirecting.reason.str = "";
1728 set_it(chan, &redirecting, NULL);
1729 }
1730 } else if (member.argc == 1 && !strcasecmp("count", member.subnames[0])) {
1733
1734 if (('0' <= val[0]) && (val[0] <= '9')) {
1735 redirecting.count = atoi(val);
1736 set_it(chan, &redirecting, NULL);
1737 } else {
1738 ast_log(LOG_ERROR, "Unknown redirecting count '%s', value unchanged\n", val);
1739 }
1740 } else if (1 < member.argc && !strcasecmp("priv", member.subnames[0])) {
1741 if (!strcasecmp("orig", member.subnames[1])) {
1742 status = party_id_write(&redirecting.priv_orig, member.argc - 2, member.subnames + 2,
1743 value);
1744 switch (status) {
1745 case ID_FIELD_VALID:
1746 set_it(chan, &redirecting, NULL);
1747 break;
1748 case ID_FIELD_INVALID:
1749 break;
1750 default:
1751 ast_log(LOG_ERROR, "Unknown redirecting data type '%s'.\n", data);
1752 break;
1753 }
1754 ast_party_redirecting_free(&redirecting);
1755 } else if (!strcasecmp("from", member.subnames[1])) {
1756 status = party_id_write(&redirecting.priv_from, member.argc - 2, member.subnames + 2,
1757 value);
1758 switch (status) {
1759 case ID_FIELD_VALID:
1760 set_it(chan, &redirecting, NULL);
1761 break;
1762 case ID_FIELD_INVALID:
1763 break;
1764 default:
1765 ast_log(LOG_ERROR, "Unknown redirecting data type '%s'.\n", data);
1766 break;
1767 }
1768 ast_party_redirecting_free(&redirecting);
1769 } else if (!strcasecmp("to", member.subnames[1])) {
1770 status = party_id_write(&redirecting.priv_to, member.argc - 2, member.subnames + 2, value);
1771 switch (status) {
1772 case ID_FIELD_VALID:
1773 set_it(chan, &redirecting, NULL);
1774 break;
1775 case ID_FIELD_INVALID:
1776 break;
1777 default:
1778 ast_log(LOG_ERROR, "Unknown redirecting data type '%s'.\n", data);
1779 break;
1780 }
1781 ast_party_redirecting_free(&redirecting);
1782 } else {
1783 ast_log(LOG_ERROR, "Unknown redirecting data type '%s'.\n", data);
1784 }
1785 } else {
1786 ast_log(LOG_ERROR, "Unknown redirecting data type '%s'.\n", data);
1787 }
1788
1789 return 0;
1790}
@ AST_REDIRECTING_REASON_UNKNOWN
Definition: callerid.h:499
int ast_redirecting_reason_parse(const char *data)
Convert redirecting reason text code to value (used in config file parsing)
Definition: callerid.c:1423
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:9141
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:2172
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:10306
void ast_party_redirecting_free(struct ast_party_redirecting *doomed)
Destroy the redirecting information contents.
Definition: channel.c:2198
static const struct ast_app_option redirecting_opts[128]
#define LOG_WARNING
struct ast_party_name name
Subscriber name.
Definition: channel.h:342
int presentation
Q.931 encoded presentation-indicator encoded field.
Definition: channel.h:279
int presentation
Q.931 presentation-indicator and screening-indicator encoded fields.
Definition: channel.h:297
int code
enum AST_REDIRECTING_REASON value for redirection
Definition: channel.h:512
char * str
a string value for the redirecting reason
Definition: channel.h:509
Indicate what information in ast_party_redirecting should be set.
Definition: channel.h:557

References args, 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, LOG_WARNING, ast_party_id::name, NULL, ast_party_id::number, 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_redirecting::to, update(), and value.

◆ unload_module()

static int unload_module ( void  )
static

Definition at line 1818 of file func_callerid.c.

1819{
1823 return 0;
1824}
int ast_custom_function_unregister(struct ast_custom_function *acf)
Unregister a custom function.

References ast_custom_function_unregister(), callerid_function, connectedline_function, and redirecting_function.

Referenced by load_module().

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

Definition at line 1850 of file func_callerid.c.

◆ ast_module_info

const struct ast_module_info* ast_module_info = &__mod_info
static

Definition at line 1850 of file func_callerid.c.

◆ callerid_function

struct ast_custom_function callerid_function
static

Definition at line 1792 of file func_callerid.c.

Referenced by load_module(), and unload_module().

◆ connectedline_function

struct ast_custom_function connectedline_function
static
Initial value:
= {
.name = "CONNECTEDLINE",
}
static int connectedline_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)

Definition at line 1799 of file func_callerid.c.

Referenced by load_module(), and unload_module().

◆ connectedline_opts

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

Definition at line 480 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 1805 of file func_callerid.c.

Referenced by load_module(), and unload_module().

◆ redirecting_opts

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

Definition at line 494 of file func_callerid.c.

Referenced by redirecting_write().