aboutsummaryrefslogtreecommitdiffstats
path: root/funcs
diff options
context:
space:
mode:
authorrussell <russell@f38db490-d61c-443f-a65b-d21fe96a405b>2009-06-26 15:28:53 +0000
committerrussell <russell@f38db490-d61c-443f-a65b-d21fe96a405b>2009-06-26 15:28:53 +0000
commitac3b35dcc792329046ec2532ff204962c895ee98 (patch)
treea28e9113cf1daf97e45a8fc6d41a52c76ac69836 /funcs
parentd13a40e1cfe5f54bfb4d1aacd2c63e7859e010bc (diff)
Merge the new Channel Event Logging (CEL) subsystem.
CEL is the new system for logging channel events. This was inspired after facing many problems trying to represent what is possible to happen to a call in Asterisk using CDR records. For more information on CEL, see the built in HTML or PDF documentation generated from the files in doc/tex/. Many thanks to Steve Murphy (murf) and Brian Degenhardt (bmd) for their hard work developing this code. Also, thanks to Matt Nicholson (mnicholson) and Sean Bright (seanbright) for their assistance in the final push to get this code ready for Asterisk trunk. Review: https://reviewboard.asterisk.org/r/239/ git-svn-id: http://svn.digium.com/svn/asterisk/trunk@203638 f38db490-d61c-443f-a65b-d21fe96a405b
Diffstat (limited to 'funcs')
-rw-r--r--funcs/func_cdr.c2
-rw-r--r--funcs/func_channel.c79
-rw-r--r--funcs/func_odbc.c8
3 files changed, 81 insertions, 8 deletions
diff --git a/funcs/func_cdr.c b/funcs/func_cdr.c
index 2e55d7a0b..e7f14af2a 100644
--- a/funcs/func_cdr.c
+++ b/funcs/func_cdr.c
@@ -241,6 +241,8 @@ static int cdr_write(struct ast_channel *chan, const char *cmd, char *parse,
if (!strcasecmp(args.variable, "accountcode")) /* the 'l' flag doesn't apply to setting the accountcode, userfield, or amaflags */
ast_cdr_setaccount(chan, value);
+ else if (!strcasecmp(args.variable, "peeraccount"))
+ ast_cdr_setpeeraccount(chan, value);
else if (!strcasecmp(args.variable, "userfield"))
ast_cdr_setuserfield(chan, value);
else if (!strcasecmp(args.variable, "amaflags"))
diff --git a/funcs/func_channel.c b/funcs/func_channel.c
index 5d81ad980..ec97df9d6 100644
--- a/funcs/func_channel.c
+++ b/funcs/func_channel.c
@@ -29,6 +29,7 @@
ASTERISK_FILE_VERSION(__FILE__, "$Revision$")
#include <regex.h>
+#include <ctype.h>
#include "asterisk/module.h"
#include "asterisk/channel.h"
@@ -271,13 +272,62 @@ static int func_channel_read(struct ast_channel *chan, const char *function,
locked_copy_string(chan, buf, ast_state2str(chan->_state), len);
else if (!strcasecmp(data, "channeltype"))
locked_copy_string(chan, buf, chan->tech->type, len);
- else if (!strcasecmp(data, "transfercapability"))
+ else if (!strcasecmp(data, "accountcode"))
+ locked_copy_string(chan, buf, chan->accountcode, len);
+ else if (!strcasecmp(data, "peeraccount"))
+ locked_copy_string(chan, buf, chan->peeraccount, len);
+ else if (!strcasecmp(data, "hangupsource"))
+ locked_copy_string(chan, buf, chan->hangupsource, len);
+ else if (!strcasecmp(data, "appname") && chan->appl)
+ locked_copy_string(chan, buf, chan->appl, len);
+ else if (!strcasecmp(data, "appdata") && chan->data)
+ locked_copy_string(chan, buf, chan->data, len);
+ else if (!strcasecmp(data, "exten") && chan->data)
+ locked_copy_string(chan, buf, chan->exten, len);
+ else if (!strcasecmp(data, "context") && chan->data)
+ locked_copy_string(chan, buf, chan->context, len);
+ else if (!strcasecmp(data, "userfield") && chan->data)
+ locked_copy_string(chan, buf, chan->userfield, len);
+ else if (!strcasecmp(data, "channame") && chan->data)
+ locked_copy_string(chan, buf, chan->name, len);
+ else if (!strcasecmp(data, "linkedid")) {
+ ast_channel_lock(chan);
+ if (ast_strlen_zero(chan->linkedid)) {
+ /* fall back on the channel's uniqueid if linkedid is unset */
+ ast_copy_string(buf, chan->uniqueid, len);
+ }
+ else {
+ ast_copy_string(buf, chan->linkedid, len);
+ }
+ ast_channel_unlock(chan);
+ } else if (!strcasecmp(data, "peer")) {
+ struct ast_channel *p;
+ ast_channel_lock(chan);
+ p = ast_bridged_channel(chan);
+ if (p || chan->tech || chan->cdr) /* dummy channel? if so, we hid the peer name in the language */
+ ast_copy_string(buf, (p ? p->name : ""), len);
+ else {
+ /* a dummy channel can still pass along bridged peer info via
+ the BRIDGEPEER variable */
+ const char *pname = pbx_builtin_getvar_helper(chan, "BRIDGEPEER");
+ if (!ast_strlen_zero(pname))
+ ast_copy_string(buf, pname, len); /* a horrible kludge, but... how else? */
+ else
+ buf[0] = 0;
+ }
+ ast_channel_unlock(chan);
+ } else if (!strcasecmp(data, "uniqueid")) {
+ locked_copy_string(chan, buf, chan->uniqueid, len);
+ } else if (!strcasecmp(data, "transfercapability"))
locked_copy_string(chan, buf, transfercapability_table[chan->transfercapability & 0x1f], len);
else if (!strcasecmp(data, "callgroup")) {
char groupbuf[256];
locked_copy_string(chan, buf, ast_print_group(groupbuf, sizeof(groupbuf), chan->callgroup), len);
- } else if (!chan->tech->func_channel_read
- || chan->tech->func_channel_read(chan, function, data, buf, len)) {
+ } else if (!strcasecmp(data, "amaflags")) {
+ char amabuf[256];
+ snprintf(amabuf,sizeof(amabuf), "%d", chan->amaflags);
+ locked_copy_string(chan, buf, amabuf, len);
+ } else if (!chan->tech || !chan->tech->func_channel_read || chan->tech->func_channel_read(chan, function, data, buf, len)) {
ast_log(LOG_WARNING, "Unknown or unavailable item requested: '%s'\n", data);
ret = -1;
}
@@ -297,12 +347,33 @@ static int func_channel_write(struct ast_channel *chan, const char *function,
locked_string_field_set(chan, parkinglot, value);
else if (!strcasecmp(data, "musicclass"))
locked_string_field_set(chan, musicclass, value);
+ else if (!strcasecmp(data, "accountcode"))
+ locked_string_field_set(chan, accountcode, value);
+ else if (!strcasecmp(data, "userfield"))
+ locked_string_field_set(chan, userfield, value);
+ else if (!strcasecmp(data, "amaflags")) {
+ ast_channel_lock(chan);
+ if(isdigit(*value)) {
+ sscanf(value, "%d", &chan->amaflags);
+ } else if (!strcasecmp(value,"OMIT")){
+ chan->amaflags = 1;
+ } else if (!strcasecmp(value,"BILLING")){
+ chan->amaflags = 2;
+ } else if (!strcasecmp(value,"DOCUMENTATION")){
+ chan->amaflags = 3;
+ }
+ ast_channel_unlock(chan);
+ } else if (!strcasecmp(data, "peeraccount"))
+ locked_string_field_set(chan, peeraccount, value);
+ else if (!strcasecmp(data, "hangupsource"))
+ /* XXX - should we be forcing this here? */
+ ast_set_hangupsource(chan, value, 0);
#ifdef CHANNEL_TRACE
else if (!strcasecmp(data, "trace")) {
ast_channel_lock(chan);
if (ast_true(value))
ret = ast_channel_trace_enable(chan);
- else if (ast_false(value))
+ else if (ast_false(value))
ret = ast_channel_trace_disable(chan);
else {
ret = -1;
diff --git a/funcs/func_odbc.c b/funcs/func_odbc.c
index 8bb744f62..c8b65eb22 100644
--- a/funcs/func_odbc.c
+++ b/funcs/func_odbc.c
@@ -238,7 +238,7 @@ static int acf_odbc_write(struct ast_channel *chan, const char *cmd, char *s, co
}
if (!chan) {
- if ((chan = ast_channel_alloc(0, 0, "", "", "", "", "", 0, "Bogus/func_odbc")))
+ if ((chan = ast_channel_alloc(0, AST_STATE_DOWN, "", "", "", "", "", "", 0, "Bogus/func_odbc")))
bogus_chan = 1;
}
@@ -414,7 +414,7 @@ static int acf_odbc_read(struct ast_channel *chan, const char *cmd, char *s, cha
}
if (!chan) {
- if ((chan = ast_channel_alloc(0, 0, "", "", "", "", "", 0, "Bogus/func_odbc"))) {
+ if ((chan = ast_channel_alloc(0, AST_STATE_DOWN, "", "", "", "", "", "", 0, "Bogus/func_odbc"))) {
bogus_chan = 1;
}
}
@@ -1051,7 +1051,7 @@ static char *cli_odbc_read(struct ast_cli_entry *e, int cmd, struct ast_cli_args
/* Evaluate function */
char_args = ast_strdupa(a->argv[3]);
- chan = ast_channel_alloc(0, 0, "", "", "", "", "", 0, "Bogus/func_odbc");
+ chan = ast_dummy_channel_alloc();
AST_STANDARD_APP_ARGS(args, char_args);
for (i = 0; i < args.argc; i++) {
@@ -1254,7 +1254,7 @@ static char *cli_odbc_write(struct ast_cli_entry *e, int cmd, struct ast_cli_arg
char_args = ast_strdupa(a->argv[3]);
char_values = ast_strdupa(a->argv[4]);
- chan = ast_channel_alloc(0, 0, "", "", "", "", "", 0, "Bogus/func_odbc");
+ chan = ast_dummy_channel_alloc();
AST_STANDARD_APP_ARGS(args, char_args);
for (i = 0; i < args.argc; i++) {