Newer
Older
AST_NONSTANDARD_APP_ARGS(member, args.member, '-');
if (member.argc == 0 || ARRAY_LEN(member.subnames) <= member.argc) {
/* Too few or too many subnames */
return -1;
}
if (args.argc == 2) {
char name[80];
char num[80];
ast_callerid_split(args.cid, name, sizeof(name), num, sizeof(num));
if (member.argc == 1 && !strcasecmp("all", member.argv[0])) {
snprintf(buf, len, "\"%s\" <%s>", name, num);
} else if (member.argc == 1 && !strcasecmp("name", member.argv[0])) {
ast_copy_string(buf, name, len);
} else if (member.argc == 1 && !strncasecmp("num", member.argv[0], 3)) {
/* Accept num[ber] */
ast_copy_string(buf, num, len);
} else {
ast_log(LOG_ERROR, "Unknown callerid data type '%s'.\n", data);
Kevin P. Fleming
committed
}
} else {
enum ID_FIELD_STATUS status;
if (member.argc == 1 && !strcasecmp("rdnis", member.argv[0])) {
if (ast_channel_redirecting(chan)->from.number.valid
&& ast_channel_redirecting(chan)->from.number.str) {
ast_copy_string(buf, ast_channel_redirecting(chan)->from.number.str, len);
} else if (!strcasecmp("dnid", member.argv[0])) {
if (member.argc == 1) {
/* Setup as if user had given dnid-num instead. */
member.argc = 2;
member.argv[1] = "num";
if (!strncasecmp("num", member.argv[1], 3)) {
/*
* Accept num[ber]
* dnid-num...
*/
if (member.argc == 2) {
/* dnid-num */
if (ast_channel_dialed(chan)->number.str) {
ast_copy_string(buf, ast_channel_dialed(chan)->number.str, len);
Richard Mudgett
committed
}
} else if (member.argc == 3 && !strcasecmp("plan", member.argv[2])) {
/* dnid-num-plan */
snprintf(buf, len, "%d", ast_channel_dialed(chan)->number.plan);
} else {
ast_log(LOG_ERROR, "Unknown callerid data type '%s'.\n", data);
Richard Mudgett
committed
}
} else if (!strncasecmp("subaddr", member.argv[1], 7)) {
/*
* Accept subaddr[ess]
* dnid-subaddr...
*/
status = party_subaddress_read(buf, len, member.argc - 2, member.argv + 2,
&ast_channel_dialed(chan)->subaddress);
switch (status) {
case ID_FIELD_VALID:
case ID_FIELD_INVALID:
break;
default:
ast_log(LOG_ERROR, "Unknown callerid data type '%s'.\n", data);
break;
Richard Mudgett
committed
}
} else {
ast_log(LOG_ERROR, "Unknown callerid data type '%s'.\n", data);
Richard Mudgett
committed
}
} else if (member.argc == 1 && !strcasecmp("ani2", member.argv[0])) {
snprintf(buf, len, "%d", ast_channel_caller(chan)->ani2);
} else if (!strcasecmp("ani", member.argv[0])) {
if (member.argc == 1) {
/* Setup as if user had given ani-num instead. */
member.argc = 2;
member.argv[1] = "num";
}
status = party_id_read(buf, len, member.argc - 1, member.argv + 1,
switch (status) {
case ID_FIELD_VALID:
case ID_FIELD_INVALID:
break;
default:
ast_log(LOG_ERROR, "Unknown callerid data type '%s'.\n", data);
break;
Richard Mudgett
committed
} else if (!strcasecmp("priv", member.argv[0])) {
status = party_id_read(buf, len, member.argc - 1, member.argv + 1,
&ast_channel_caller(chan)->priv);
switch (status) {
case ID_FIELD_VALID:
case ID_FIELD_INVALID:
break;
default:
ast_log(LOG_ERROR, "Unknown callerid data type '%s'.\n", data);
break;
}
} else {
status = party_id_read(buf, len, member.argc, member.argv, &ast_channel_caller(chan)->id);
switch (status) {
case ID_FIELD_VALID:
case ID_FIELD_INVALID:
break;
default:
ast_log(LOG_ERROR, "Unknown callerid data type '%s'.\n", data);
break;
}
ast_channel_unlock(chan);
Kevin P. Fleming
committed
}
Richard Mudgett
committed
return 0;
Kevin P. Fleming
committed
}
/*!
* \internal
* \brief Write new values to the caller-id information struct.
*
* \param chan Asterisk channel to update
* \param cmd Not used
* \param data Caller-id function datatype string
* \param value Value to assign to the caller-id information struct.
*
* \retval 0 on success.
* \retval -1 on error.
*/
static int callerid_write(struct ast_channel *chan, const char *cmd, char *data, const char *value)
Kevin P. Fleming
committed
{
struct ast_party_caller caller;
struct ast_party_dialed dialed;
enum ID_FIELD_STATUS status;
char *val;
char *parms;
struct ast_party_func_args args;
struct ast_party_members member;
if (!value || !chan) {
parms = ast_strdupa(data);
AST_STANDARD_APP_ARGS(args, parms);
if (args.argc == 0) {
/* Must have at least one argument. */
return -1;
}
Richard Mudgett
committed
AST_NONSTANDARD_APP_ARGS(member, args.member, '-');
if (member.argc == 0 || ARRAY_LEN(member.subnames) <= member.argc) {
/* Too few or too many subnames */
return -1;
}
value = ast_skip_blanks(value);
ast_channel_lock(chan);
if (member.argc == 1 && !strcasecmp("rdnis", member.argv[0])) {
ast_channel_redirecting(chan)->from.number.valid = 1;
ast_free(ast_channel_redirecting(chan)->from.number.str);
ast_channel_redirecting(chan)->from.number.str = ast_strdup(value);
} else if (!strcasecmp("dnid", member.argv[0])) {
ast_party_dialed_set_init(&dialed, ast_channel_dialed(chan));
if (member.argc == 1) {
/* Setup as if user had given dnid-num instead. */
member.argc = 2;
member.argv[1] = "num";
if (!strncasecmp("num", member.argv[1], 3)) {
/*
* Accept num[ber]
* dnid-num...
*/
if (member.argc == 2) {
/* dnid-num */
dialed.number.str = ast_strdup(value);
ast_trim_blanks(dialed.number.str);
ast_party_dialed_set(ast_channel_dialed(chan), &dialed);
} else if (member.argc == 3 && !strcasecmp("plan", member.argv[2])) {
/* dnid-num-plan */
val = ast_strdupa(value);
ast_trim_blanks(val);
if (('0' <= val[0]) && (val[0] <= '9')) {
ast_channel_dialed(chan)->number.plan = atoi(val);
} else {
ast_log(LOG_ERROR,
"Unknown type-of-number/numbering-plan '%s', value unchanged\n", val);
}
} else {
ast_log(LOG_ERROR, "Unknown callerid data type '%s'.\n", data);
}
} else if (!strncasecmp("subaddr", member.argv[1], 7)) {
/*
* Accept subaddr[ess]
* dnid-subaddr...
*/
status = party_subaddress_write(&dialed.subaddress, member.argc - 2,
member.argv + 2, value);
switch (status) {
case ID_FIELD_VALID:
ast_party_dialed_set(ast_channel_dialed(chan), &dialed);
break;
case ID_FIELD_INVALID:
break;
default:
ast_log(LOG_ERROR, "Unknown callerid data type '%s'.\n", data);
break;
}
} else {
ast_log(LOG_ERROR, "Unknown callerid data type '%s'.\n", data);
ast_party_dialed_free(&dialed);
} else if (member.argc == 1 && !strcasecmp("ani2", member.argv[0])) {
val = ast_strdupa(value);
ast_trim_blanks(val);
if (('0' <= val[0]) && (val[0] <= '9')) {
ast_channel_caller(chan)->ani2 = atoi(val);
Richard Mudgett
committed
} else {
ast_log(LOG_ERROR, "Unknown callerid ani2 '%s', value unchanged\n", val);
Richard Mudgett
committed
}
} else if (!strcasecmp("ani", member.argv[0])) {
ast_party_caller_set_init(&caller, ast_channel_caller(chan));
if (member.argc == 1) {
/* Setup as if user had given ani-num instead. */
member.argc = 2;
member.argv[1] = "num";
}
status = party_id_write(&caller.ani, member.argc - 1, member.argv + 1, value);
switch (status) {
case ID_FIELD_VALID:
ast_party_caller_set(ast_channel_caller(chan), &caller, NULL);
break;
case ID_FIELD_INVALID:
break;
default:
ast_log(LOG_ERROR, "Unknown callerid data type '%s'.\n", data);
break;
Richard Mudgett
committed
} else if (!strcasecmp("priv", member.argv[0])) {
ast_party_caller_set_init(&caller, ast_channel_caller(chan));
status = party_id_write(&caller.priv, member.argc - 1, member.argv + 1, value);
switch (status) {
case ID_FIELD_VALID:
ast_party_caller_set(ast_channel_caller(chan), &caller, NULL);
break;
case ID_FIELD_INVALID:
break;
default:
ast_log(LOG_ERROR, "Unknown callerid data type '%s'.\n", data);
break;
}
ast_party_caller_free(&caller);
ast_party_caller_set_init(&caller, ast_channel_caller(chan));
status = party_id_write(&caller.id, member.argc, member.argv, value);
switch (status) {
case ID_FIELD_VALID:
ast_channel_set_caller_event(chan, &caller, NULL);
break;
case ID_FIELD_INVALID:
break;
default:
ast_log(LOG_ERROR, "Unknown callerid data type '%s'.\n", data);
break;
Richard Mudgett
committed
}
ast_party_caller_free(&caller);
}
ast_channel_unlock(chan);
Richard Mudgett
committed
return 0;
}
/*!
* \internal
* \brief Read values from the connected line information struct.
*
* \param chan Asterisk channel to read
* \param cmd Not used
* \param data Connected line function datatype string
* \param buf Buffer to fill with read value.
* \param len Length of the buffer
*
* \retval 0 on success.
* \retval -1 on error.
*/
static int connectedline_read(struct ast_channel *chan, const char *cmd, char *data, char *buf, size_t len)
{
struct ast_party_members member;
char *read_what;
Richard Mudgett
committed
enum ID_FIELD_STATUS status;
/* Ensure that the buffer is empty */
*buf = 0;
if (!chan) {
return -1;
}
read_what = ast_strdupa(data);
AST_NONSTANDARD_APP_ARGS(member, read_what, '-');
if (member.argc == 0 || ARRAY_LEN(member.subnames) <= member.argc) {
/* Too few or too many subnames */
return -1;
}
ast_channel_lock(chan);
if (member.argc == 1 && !strcasecmp("source", member.argv[0])) {
ast_copy_string(buf, ast_connected_line_source_name(ast_channel_connected(chan)->source), len);
Richard Mudgett
committed
} else if (!strcasecmp("priv", member.argv[0])) {
status = party_id_read(buf, len, member.argc - 1, member.argv + 1,
&ast_channel_connected(chan)->priv);
switch (status) {
case ID_FIELD_VALID:
case ID_FIELD_INVALID:
break;
default:
ast_log(LOG_ERROR, "Unknown connectedline data type '%s'.\n", data);
break;
}
status = party_id_read(buf, len, member.argc, member.argv, &ast_channel_connected(chan)->id);
switch (status) {
case ID_FIELD_VALID:
case ID_FIELD_INVALID:
break;
default:
ast_log(LOG_ERROR, "Unknown connectedline data type '%s'.\n", data);
break;
Richard Mudgett
committed
}
1337
1338
1339
1340
1341
1342
1343
1344
1345
1346
1347
1348
1349
1350
1351
1352
1353
1354
1355
1356
1357
1358
1359
1360
1361
1362
1363
1364
1365
}
ast_channel_unlock(chan);
return 0;
}
/*!
* \internal
* \brief Write new values to the connected line information struct.
*
* \param chan Asterisk channel to update
* \param cmd Not used
* \param data Connected line function datatype string
* \param value Value to assign to the connected line information struct.
*
* \retval 0 on success.
* \retval -1 on error.
*/
static int connectedline_write(struct ast_channel *chan, const char *cmd, char *data, const char *value)
{
struct ast_party_connected_line connected;
char *val;
char *parms;
void (*set_it)(struct ast_channel *chan, const struct ast_party_connected_line *connected, const struct ast_set_party_connected_line *update);
struct ast_party_func_args args;
struct ast_party_members member;
struct ast_flags opts;
char *opt_args[CONNECTED_LINE_OPT_ARG_ARRAY_SIZE];
Richard Mudgett
committed
enum ID_FIELD_STATUS status;
1367
1368
1369
1370
1371
1372
1373
1374
1375
1376
1377
1378
1379
1380
1381
1382
1383
1384
1385
1386
1387
1388
1389
1390
1391
1392
1393
1394
1395
1396
1397
if (!value || !chan) {
return -1;
}
parms = ast_strdupa(data);
AST_STANDARD_APP_ARGS(args, parms);
if (args.argc == 0) {
/* Must have at least one argument. */
return -1;
}
AST_NONSTANDARD_APP_ARGS(member, args.member, '-');
if (member.argc == 0 || ARRAY_LEN(member.subnames) <= member.argc) {
/* Too few or too many subnames */
return -1;
}
if (ast_app_parse_options(connectedline_opts, &opts, opt_args, args.opts)) {
/* General invalid option syntax. */
return -1;
}
/* Determine if the update indication inhibit option is present */
if (ast_test_flag(&opts, CONNECTED_LINE_OPT_INHIBIT)) {
set_it = ast_channel_set_connected_line;
} else {
set_it = ast_channel_update_connected_line;
}
ast_channel_lock(chan);
ast_party_connected_line_set_init(&connected, ast_channel_connected(chan));
ast_channel_unlock(chan);
value = ast_skip_blanks(value);
if (member.argc == 1 && !strcasecmp("source", member.argv[0])) {
int source;
val = ast_strdupa(value);
ast_trim_blanks(val);
if (('0' <= val[0]) && (val[0] <= '9')) {
source = atoi(val);
} else {
source = ast_connected_line_source_parse(val);
Richard Mudgett
committed
}
if (source < 0) {
ast_log(LOG_ERROR, "Unknown connectedline source '%s', value unchanged\n", val);
} else {
connected.source = source;
set_it(chan, &connected, NULL);
Richard Mudgett
committed
} else if (!strcasecmp("priv", member.argv[0])) {
status = party_id_write(&connected.priv, member.argc - 1, member.argv + 1, value);
switch (status) {
case ID_FIELD_VALID:
set_it(chan, &connected, NULL);
break;
case ID_FIELD_INVALID:
break;
default:
ast_log(LOG_ERROR, "Unknown connectedline data type '%s'.\n", data);
break;
}
ast_party_connected_line_free(&connected);
} else {
status = party_id_write(&connected.id, member.argc, member.argv, value);
switch (status) {
case ID_FIELD_VALID:
set_it(chan, &connected, NULL);
break;
case ID_FIELD_INVALID:
break;
default:
ast_log(LOG_ERROR, "Unknown connectedline data type '%s'.\n", data);
break;
1446
1447
1448
1449
1450
1451
1452
1453
1454
1455
1456
1457
1458
1459
1460
1461
1462
1463
1464
1465
1466
1467
1468
ast_party_connected_line_free(&connected);
}
return 0;
}
/*!
* \internal
* \brief Read values from the redirecting information struct.
*
* \param chan Asterisk channel to read
* \param cmd Not used
* \param data Redirecting function datatype string
* \param buf Buffer to fill with read value.
* \param len Length of the buffer
*
* \retval 0 on success.
* \retval -1 on error.
*/
static int redirecting_read(struct ast_channel *chan, const char *cmd, char *data, char *buf, size_t len)
{
struct ast_party_members member;
char *read_what;
const struct ast_party_redirecting *ast_redirecting;
enum ID_FIELD_STATUS status;
/* Ensure that the buffer is empty */
*buf = 0;
if (!chan) {
return -1;
}
read_what = ast_strdupa(data);
AST_NONSTANDARD_APP_ARGS(member, read_what, '-');
if (member.argc == 0 || ARRAY_LEN(member.subnames) <= member.argc) {
/* Too few or too many subnames */
return -1;
}
ast_channel_lock(chan);
ast_redirecting = ast_channel_redirecting(chan);
if (!strcasecmp("orig", member.argv[0])) {
if (member.argc == 2 && !strcasecmp("reason", member.argv[1])) {
ast_copy_string(buf,
ast_redirecting_reason_name(&ast_redirecting->orig_reason), len);
} else {
status = party_id_read(buf, len, member.argc - 1, member.argv + 1,
&ast_redirecting->orig);
switch (status) {
case ID_FIELD_VALID:
case ID_FIELD_INVALID:
break;
default:
ast_log(LOG_ERROR, "Unknown redirecting data type '%s'.\n", data);
break;
}
}
} else if (!strcasecmp("from", member.argv[0])) {
status = party_id_read(buf, len, member.argc - 1, member.argv + 1,
switch (status) {
case ID_FIELD_VALID:
case ID_FIELD_INVALID:
break;
default:
ast_log(LOG_ERROR, "Unknown redirecting data type '%s'.\n", data);
break;
}
} else if (!strcasecmp("to", member.argv[0])) {
status = party_id_read(buf, len, member.argc - 1, member.argv + 1,
switch (status) {
case ID_FIELD_VALID:
case ID_FIELD_INVALID:
break;
default:
ast_log(LOG_ERROR, "Unknown redirecting data type '%s'.\n", data);
break;
}
} else if (member.argc == 1 && !strncasecmp("pres", member.argv[0], 4)) {
/*
* Accept pres[entation]
* This is the combined from name/number presentation.
*/
ast_copy_string(buf,
ast_named_caller_presentation(
ast_party_id_presentation(&ast_redirecting->from)), len);
} else if (member.argc == 1 && !strcasecmp("reason", member.argv[0])) {
ast_copy_string(buf, ast_redirecting_reason_name(&ast_redirecting->reason), len);
} else if (member.argc == 1 && !strcasecmp("count", member.argv[0])) {
snprintf(buf, len, "%d", ast_redirecting->count);
Richard Mudgett
committed
1539
1540
1541
1542
1543
1544
1545
1546
1547
1548
1549
1550
1551
1552
1553
1554
1555
1556
1557
1558
1559
1560
1561
1562
1563
1564
1565
1566
1567
1568
1569
1570
1571
1572
1573
1574
1575
} else if (1 < member.argc && !strcasecmp("priv", member.argv[0])) {
if (!strcasecmp("orig", member.argv[1])) {
status = party_id_read(buf, len, member.argc - 2, member.argv + 2,
&ast_redirecting->priv_orig);
switch (status) {
case ID_FIELD_VALID:
case ID_FIELD_INVALID:
break;
default:
ast_log(LOG_ERROR, "Unknown redirecting data type '%s'.\n", data);
break;
}
} else if (!strcasecmp("from", member.argv[1])) {
status = party_id_read(buf, len, member.argc - 2, member.argv + 2,
&ast_redirecting->priv_from);
switch (status) {
case ID_FIELD_VALID:
case ID_FIELD_INVALID:
break;
default:
ast_log(LOG_ERROR, "Unknown redirecting data type '%s'.\n", data);
break;
}
} else if (!strcasecmp("to", member.argv[1])) {
status = party_id_read(buf, len, member.argc - 2, member.argv + 2,
&ast_redirecting->priv_to);
switch (status) {
case ID_FIELD_VALID:
case ID_FIELD_INVALID:
break;
default:
ast_log(LOG_ERROR, "Unknown redirecting data type '%s'.\n", data);
break;
}
} else {
ast_log(LOG_ERROR, "Unknown redirecting data type '%s'.\n", data);
}
1576
1577
1578
1579
1580
1581
1582
1583
1584
1585
1586
1587
1588
1589
1590
1591
1592
1593
1594
1595
1596
1597
1598
1599
1600
1601
1602
1603
1604
1605
1606
1607
1608
1609
1610
1611
1612
1613
1614
1615
1616
1617
1618
1619
1620
1621
1622
1623
1624
1625
1626
1627
1628
1629
1630
1631
1632
1633
1634
1635
1636
1637
1638
} else {
ast_log(LOG_ERROR, "Unknown redirecting data type '%s'.\n", data);
}
ast_channel_unlock(chan);
return 0;
}
/*!
* \internal
* \brief Write new values to the redirecting information struct.
*
* \param chan Asterisk channel to update
* \param cmd Not used
* \param data Redirecting function datatype string
* \param value Value to assign to the redirecting information struct.
*
* \retval 0 on success.
* \retval -1 on error.
*/
static int redirecting_write(struct ast_channel *chan, const char *cmd, char *data, const char *value)
{
struct ast_party_redirecting redirecting;
enum ID_FIELD_STATUS status;
char *val;
char *parms;
void (*set_it)(struct ast_channel *chan, const struct ast_party_redirecting *redirecting, const struct ast_set_party_redirecting *update);
struct ast_party_func_args args;
struct ast_party_members member;
struct ast_flags opts;
char *opt_args[REDIRECTING_OPT_ARG_ARRAY_SIZE];
if (!value || !chan) {
return -1;
}
parms = ast_strdupa(data);
AST_STANDARD_APP_ARGS(args, parms);
if (args.argc == 0) {
/* Must have at least one argument. */
return -1;
}
AST_NONSTANDARD_APP_ARGS(member, args.member, '-');
if (member.argc == 0 || ARRAY_LEN(member.subnames) <= member.argc) {
/* Too few or too many subnames */
return -1;
}
if (ast_app_parse_options(redirecting_opts, &opts, opt_args, args.opts)) {
/* General invalid option syntax. */
return -1;
}
/* Determine if the update indication inhibit option is present */
if (ast_test_flag(&opts, REDIRECTING_OPT_INHIBIT)) {
set_it = ast_channel_set_redirecting;
} else {
set_it = ast_channel_update_redirecting;
}
ast_channel_lock(chan);
ast_party_redirecting_set_init(&redirecting, ast_channel_redirecting(chan));
ast_channel_unlock(chan);
value = ast_skip_blanks(value);
if (!strcasecmp("orig", member.argv[0])) {
if (member.argc == 2 && !strcasecmp("reason", member.argv[1])) {
int reason;
val = ast_strdupa(value);
ast_trim_blanks(val);
if (('0' <= val[0]) && (val[0] <= '9')) {
reason = atoi(val);
} else {
reason = ast_redirecting_reason_parse(val);
}
if (reason < 0) {
/* The argument passed into the function does not correspond to a pre-defined
* reason, so we can just set the reason string to what was given and set the
* code to be unknown
*/
redirecting.orig_reason.code = AST_REDIRECTING_REASON_UNKNOWN;
redirecting.orig_reason.str = val;
set_it(chan, &redirecting, NULL);
redirecting.orig_reason.code = reason;
redirecting.orig_reason.str = "";
set_it(chan, &redirecting, NULL);
}
} else {
status = party_id_write(&redirecting.orig, member.argc - 1, member.argv + 1,
value);
switch (status) {
case ID_FIELD_VALID:
set_it(chan, &redirecting, NULL);
break;
case ID_FIELD_INVALID:
break;
default:
ast_log(LOG_ERROR, "Unknown redirecting data type '%s'.\n", data);
break;
}
ast_party_redirecting_free(&redirecting);
}
} else if (!strcasecmp("from", member.argv[0])) {
1686
1687
1688
1689
1690
1691
1692
1693
1694
1695
1696
1697
1698
1699
1700
1701
1702
1703
1704
1705
1706
1707
1708
1709
1710
1711
1712
1713
status = party_id_write(&redirecting.from, member.argc - 1, member.argv + 1,
value);
switch (status) {
case ID_FIELD_VALID:
set_it(chan, &redirecting, NULL);
break;
case ID_FIELD_INVALID:
break;
default:
ast_log(LOG_ERROR, "Unknown redirecting data type '%s'.\n", data);
break;
}
ast_party_redirecting_free(&redirecting);
} else if (!strcasecmp("to", member.argv[0])) {
status = party_id_write(&redirecting.to, member.argc - 1, member.argv + 1, value);
switch (status) {
case ID_FIELD_VALID:
set_it(chan, &redirecting, NULL);
break;
case ID_FIELD_INVALID:
break;
default:
ast_log(LOG_ERROR, "Unknown redirecting data type '%s'.\n", data);
break;
}
ast_party_redirecting_free(&redirecting);
} else if (member.argc == 1 && !strncasecmp("pres", member.argv[0], 4)) {
int pres;
val = ast_strdupa(value);
Richard Mudgett
committed
ast_trim_blanks(val);
1718
1719
1720
1721
1722
1723
1724
1725
1726
1727
1728
1729
1730
1731
1732
1733
1734
1735
1736
1737
1738
1739
1740
1741
1742
1743
1744
1745
1746
if (('0' <= val[0]) && (val[0] <= '9')) {
pres = atoi(val);
} else {
pres = ast_parse_caller_presentation(val);
}
if (pres < 0) {
ast_log(LOG_ERROR,
"Unknown redirecting combined presentation '%s', value unchanged\n", val);
} else {
redirecting.from.name.presentation = pres;
redirecting.from.number.presentation = pres;
redirecting.to.name.presentation = pres;
redirecting.to.number.presentation = pres;
set_it(chan, &redirecting, NULL);
}
} else if (member.argc == 1 && !strcasecmp("reason", member.argv[0])) {
int reason;
val = ast_strdupa(value);
ast_trim_blanks(val);
if (('0' <= val[0]) && (val[0] <= '9')) {
reason = atoi(val);
} else {
reason = ast_redirecting_reason_parse(val);
}
if (reason < 0) {
/* The argument passed into the function does not correspond to a pre-defined
* reason, so we can just set the reason string to what was given and set the
* code to be unknown
*/
redirecting.reason.code = AST_REDIRECTING_REASON_UNKNOWN;
redirecting.reason.str = val;
set_it(chan, &redirecting, NULL);
Richard Mudgett
committed
} else {
redirecting.reason.code = reason;
redirecting.reason.str = "";
Richard Mudgett
committed
}
} else if (member.argc == 1 && !strcasecmp("count", member.argv[0])) {
val = ast_strdupa(value);
ast_trim_blanks(val);
if (('0' <= val[0]) && (val[0] <= '9')) {
redirecting.count = atoi(val);
set_it(chan, &redirecting, NULL);
Richard Mudgett
committed
} else {
ast_log(LOG_ERROR, "Unknown redirecting count '%s', value unchanged\n", val);
Richard Mudgett
committed
}
Richard Mudgett
committed
1769
1770
1771
1772
1773
1774
1775
1776
1777
1778
1779
1780
1781
1782
1783
1784
1785
1786
1787
1788
1789
1790
1791
1792
1793
1794
1795
1796
1797
1798
1799
1800
1801
1802
1803
1804
1805
1806
1807
1808
1809
1810
1811
1812
1813
} else if (1 < member.argc && !strcasecmp("priv", member.argv[0])) {
if (!strcasecmp("orig", member.argv[1])) {
status = party_id_write(&redirecting.priv_orig, member.argc - 2, member.argv + 2,
value);
switch (status) {
case ID_FIELD_VALID:
set_it(chan, &redirecting, NULL);
break;
case ID_FIELD_INVALID:
break;
default:
ast_log(LOG_ERROR, "Unknown redirecting data type '%s'.\n", data);
break;
}
ast_party_redirecting_free(&redirecting);
} else if (!strcasecmp("from", member.argv[1])) {
status = party_id_write(&redirecting.priv_from, member.argc - 2, member.argv + 2,
value);
switch (status) {
case ID_FIELD_VALID:
set_it(chan, &redirecting, NULL);
break;
case ID_FIELD_INVALID:
break;
default:
ast_log(LOG_ERROR, "Unknown redirecting data type '%s'.\n", data);
break;
}
ast_party_redirecting_free(&redirecting);
} else if (!strcasecmp("to", member.argv[1])) {
status = party_id_write(&redirecting.priv_to, member.argc - 2, member.argv + 2, value);
switch (status) {
case ID_FIELD_VALID:
set_it(chan, &redirecting, NULL);
break;
case ID_FIELD_INVALID:
break;
default:
ast_log(LOG_ERROR, "Unknown redirecting data type '%s'.\n", data);
break;
}
ast_party_redirecting_free(&redirecting);
} else {
ast_log(LOG_ERROR, "Unknown redirecting data type '%s'.\n", data);
}
ast_log(LOG_ERROR, "Unknown redirecting data type '%s'.\n", data);
Kevin P. Fleming
committed
}
static struct ast_custom_function callerid_function = {
Kevin P. Fleming
committed
.name = "CALLERID",
.read = callerid_read,
Kevin P. Fleming
committed
.write = callerid_write,
};
static struct ast_custom_function callerpres_function = {
.name = "CALLERPRES",
.read = callerpres_read,
.write = callerpres_write,
};
static struct ast_custom_function connectedline_function = {
.name = "CONNECTEDLINE",
.read = connectedline_read,
.write = connectedline_write,
};
static struct ast_custom_function redirecting_function = {
.name = "REDIRECTING",
.read = redirecting_read,
.write = redirecting_write,
};
/*!
* \internal
* \brief Unload the function module
*
* \retval 0 on success.
* \retval -1 on error.
*/
static int unload_module(void)
Kevin P. Fleming
committed
{
int res;
res = ast_custom_function_unregister(&callerpres_function);
res |= ast_custom_function_unregister(&callerid_function);
res |= ast_custom_function_unregister(&connectedline_function);
res |= ast_custom_function_unregister(&redirecting_function);
return res;
Kevin P. Fleming
committed
}
/*!
* \internal
* \brief Load and initialize the function module.
*
* \retval AST_MODULE_LOAD_SUCCESS on success.
* \retval AST_MODULE_LOAD_DECLINE on error.
*/
static int load_module(void)
Kevin P. Fleming
committed
{
int res;
res = ast_custom_function_register(&callerpres_function);
res |= ast_custom_function_register(&callerid_function);
res |= ast_custom_function_register(&connectedline_function);
res |= ast_custom_function_register(&redirecting_function);
return res ? AST_MODULE_LOAD_DECLINE : AST_MODULE_LOAD_SUCCESS;
Kevin P. Fleming
committed
}
/* Do not wrap the following line. */
AST_MODULE_INFO_STANDARD(ASTERISK_GPL_KEY, "Party ID related dialplan functions (Caller-ID, Connected-line, Redirecting)");