[asterisk-commits] murf: branch murf/newcdr r63792 - in
/team/murf/newcdr: cel/ channels/ funcs/...
asterisk-commits at lists.digium.com
asterisk-commits at lists.digium.com
Thu May 10 14:49:59 MST 2007
Author: murf
Date: Thu May 10 16:49:58 2007
New Revision: 63792
URL: http://svn.digium.com/view/asterisk?view=rev&rev=63792
Log:
OK, here's a good checkpoint. I'm hitting the transfer stuff hard; that's where the CDR stuff is really weak. Matter of fact, the Manager interface is pretty weak on transfers, too. I added HOOKFLASH and ATTENDEDTRANSFER and BLINDTRANSFER and TRANSFER events, and am sprinkling them in the res_feature and chan drivers. Slow work and lots of trial and error. Everything seems to work right now, using CSV, custom drivers. Transfer scenarios involving double transfers and parks will easily generate 40 CEL events, and 80 Manager events. (and 2 CDR's)
Modified:
team/murf/newcdr/cel/cel_csv.c
team/murf/newcdr/cel/cel_custom.c
team/murf/newcdr/cel/cel_manager.c
team/murf/newcdr/cel/cel_odbc.c
team/murf/newcdr/cel/cel_pgsql.c
team/murf/newcdr/cel/cel_sqlite.c
team/murf/newcdr/cel/cel_sqlite3_custom.c
team/murf/newcdr/cel/cel_tds.c
team/murf/newcdr/channels/chan_sip.c
team/murf/newcdr/channels/chan_zap.c
team/murf/newcdr/funcs/func_cel.c
team/murf/newcdr/include/asterisk/cel.h
team/murf/newcdr/include/asterisk/channel.h
team/murf/newcdr/include/asterisk/event_defs.h
team/murf/newcdr/main/cel.c
team/murf/newcdr/main/channel.c
team/murf/newcdr/main/pbx.c
team/murf/newcdr/res/res_features.c
Modified: team/murf/newcdr/cel/cel_csv.c
URL: http://svn.digium.com/view/asterisk/team/murf/newcdr/cel/cel_csv.c?view=diff&rev=63792&r1=63791&r2=63792
==============================================================================
--- team/murf/newcdr/cel/cel_csv.c (original)
+++ team/murf/newcdr/cel/cel_csv.c Thu May 10 16:49:58 2007
@@ -74,14 +74,15 @@
"exten",
"calleridname",
"calleridnum",
- "channel",
- "application", Last application run on the channel
- "app arguments", argument to the last channel
+ "channame",
+ "appname", Last application run on the channel
+ "appdata", argument to the last channel
"event name",
"event time",
"amaflags", DOCUMENTATION, BILL, IGNORE etc, specified on a per channel basis like accountcode.
"uniqueid", unique call identifier
- "userfield" user field set via SetCDRUserField
+ "userfield" user field set via Set(${CEL(userfield)}=<some value>)
+ "peer" the peer for bridges
----------------------------------------------------------*/
static FILE *mf = NULL;
@@ -203,7 +204,8 @@
const char *cid_num, const char *cid_ani, const char *cid_rdnis,
const char *cid_dnid, const char *exten, const char *context,
const char *channame, const char *appname, const char *appdata,
- const char *accountcode, const char *uniqueid, unsigned int amaflag)
+ const char *accountcode, const char *uniqueid, unsigned int amaflag,
+ const char *userfield, const char *peer)
{
buf[0] = '\0';
@@ -235,6 +237,11 @@
/* Unique ID */
if (loguniqueid)
append_string(buf, uniqueid, bufsize);
+ /* Userfield */
+ append_string(buf, userfield, bufsize);
+ /* Peer (for bridges) */
+ append_string(buf, peer, bufsize);
+
/* If we hit the end of our buffer, log an error */
if (strlen(buf) < bufsize - 5) {
/* Trim off trailing comma */
@@ -273,7 +280,7 @@
const char *userdefname = 0;
time_t eventtime = 0;
const char *cid_ani, *cid_rdnis, *cid_name, *cid_num, *cid_dnid;
- const char *exten, *context, *channame, *appname, *appdata, *accountcode, *uniqueid;
+ const char *exten, *context, *channame, *appname, *appdata, *accountcode, *uniqueid, *userfield, *peer;
unsigned int amaflag;
eventtype = (enum ast_cel_eventtype)ast_event_get_ie_uint(event, AST_EVENT_IE_CEL_EVENT_TYPE);
@@ -293,11 +300,13 @@
accountcode = ast_event_get_ie_str(event, AST_EVENT_IE_CEL_ACCTCODE);
uniqueid = ast_event_get_ie_str(event, AST_EVENT_IE_CEL_UNIQUEID);
amaflag = ast_event_get_ie_uint(event, AST_EVENT_IE_CEL_AMAFLAGS);
+ userfield = ast_event_get_ie_str(event, AST_EVENT_IE_CEL_USERFIELD);
+ peer = ast_event_get_ie_str(event, AST_EVENT_IE_CEL_PEER);
snprintf(csvmaster, sizeof(csvmaster),"%s/%s/%s", ast_config_AST_LOG_DIR, CSV_LOG_DIR, CSV_MASTER);
if (build_csv_record(buf, sizeof(buf), eventtype, eventtime,userdefname,
cid_name, cid_num, cid_ani, cid_rdnis, cid_dnid, exten, context,
- channame, appname, appdata, accountcode, uniqueid, amaflag)) {
+ channame, appname, appdata, accountcode, uniqueid, amaflag, userfield, peer)) {
ast_log(LOG_WARNING, "Unable to create CSV record in %d bytes. CDR not recorded!\n", (int)sizeof(buf));
} else {
/* because of the absolutely unconditional need for the
Modified: team/murf/newcdr/cel/cel_custom.c
URL: http://svn.digium.com/view/asterisk/team/murf/newcdr/cel/cel_custom.c?view=diff&rev=63792&r1=63791&r2=63792
==============================================================================
--- team/murf/newcdr/cel/cel_custom.c (original)
+++ team/murf/newcdr/cel/cel_custom.c Thu May 10 16:49:58 2007
@@ -113,7 +113,7 @@
time_t eventtime = 0;
struct ast_channel tchan = {0}; /* just so we store the data in vars and do var subst on the mapping line from the config file */
const char *cid_ani, *cid_rdnis, *cid_name, *cid_num, *cid_dnid;
- const char *exten, *context, *channame, *appname, *appdata, *accountcode, *uniqueid;
+ const char *exten, *context, *channame, *appname, *appdata, *accountcode, *uniqueid, *peer, *userfield;
unsigned int amaflag;
struct ast_var_t *vardata;
@@ -142,10 +142,12 @@
accountcode = ast_event_get_ie_str(event, AST_EVENT_IE_CEL_ACCTCODE);
uniqueid = ast_event_get_ie_str(event, AST_EVENT_IE_CEL_UNIQUEID);
amaflag = ast_event_get_ie_uint(event, AST_EVENT_IE_CEL_AMAFLAGS);
+ userfield = ast_event_get_ie_str(event, AST_EVENT_IE_CEL_USERFIELD);
+ peer = ast_event_get_ie_str(event, AST_EVENT_IE_CEL_PEER);
cel_set_backend_channel_vars(&tchan, eventtype, userdefname, eventtime, cid_name, cid_num,
cid_ani, cid_rdnis, cid_dnid, exten, context, channame,
- appname, appdata, accountcode, uniqueid, amaflag);
+ appname, appdata, accountcode, uniqueid, amaflag, userfield, peer);
memset(buf, 0 , sizeof(buf));
/* Quite possibly the first use of a static struct ast_channel, we need it so the var funcs will work */
Modified: team/murf/newcdr/cel/cel_manager.c
URL: http://svn.digium.com/view/asterisk/team/murf/newcdr/cel/cel_manager.c?view=diff&rev=63792&r1=63791&r2=63792
==============================================================================
--- team/murf/newcdr/cel/cel_manager.c (original)
+++ team/murf/newcdr/cel/cel_manager.c Thu May 10 16:49:58 2007
@@ -94,7 +94,7 @@
const char *userdefname = 0;
time_t eventtime = 0;
const char *cid_ani, *cid_rdnis, *cid_name, *cid_num, *cid_dnid;
- const char *exten, *context, *channame, *appname, *appdata, *accountcode, *uniqueid;
+ const char *exten, *context, *channame, *appname, *appdata, *accountcode, *uniqueid, *userfield, *peer;
unsigned int amaflag;
if (!enablecel)
@@ -122,6 +122,8 @@
accountcode = ast_event_get_ie_str(event, AST_EVENT_IE_CEL_ACCTCODE);
uniqueid = ast_event_get_ie_str(event, AST_EVENT_IE_CEL_UNIQUEID);
amaflag = ast_event_get_ie_uint(event, AST_EVENT_IE_CEL_AMAFLAGS);
+ userfield = ast_event_get_ie_str(event, AST_EVENT_IE_CEL_USERFIELD);
+ peer = ast_event_get_ie_str(event, AST_EVENT_IE_CEL_PEER);
t = eventtime;
localtime_r(&t, &timeresult);
@@ -142,12 +144,14 @@
"AppData: %s\r\n"
"EventTime: %s\r\n"
"AMAFlags: %s\r\n"
- "UniqueID: %s\r\n",
- (eventtype==CEL_USER_DEFINED?userdefname:ast_cel_eventtype2str(eventtype)),
+ "UniqueID: %s\r\n"
+ "Userfield: %s\r\n"
+ "Peer: %s\r\n",
+ (eventtype==CEL_USER_DEFINED?userdefname:ast_cel_eventtype2str(eventtype)),
accountcode, cid_num, cid_name, cid_ani, cid_rdnis, cid_dnid,
exten, context, channame,
appname, appdata, strStartTime,
- ast_cel_flags2str(amaflag), uniqueid);
+ ast_cel_flags2str(amaflag), uniqueid, userfield, peer);
}
static int unload_module(void)
Modified: team/murf/newcdr/cel/cel_odbc.c
URL: http://svn.digium.com/view/asterisk/team/murf/newcdr/cel/cel_odbc.c?view=diff&rev=63792&r1=63791&r2=63792
==============================================================================
--- team/murf/newcdr/cel/cel_odbc.c (original)
+++ team/murf/newcdr/cel/cel_odbc.c Thu May 10 16:49:58 2007
@@ -100,7 +100,7 @@
const char *userdefname = 0;
time_t eventtime = 0;
const char *cid_ani, *cid_rdnis, *cid_name, *cid_num, *cid_dnid;
- const char *exten, *context, *channame, *appname, *appdata, *accountcode, *uniqueid;
+ const char *exten, *context, *channame, *appname, *appdata, *accountcode, *uniqueid, *userfield, *peer;
unsigned int amaflag;
eventtype = (enum ast_cel_eventtype)ast_event_get_ie_uint(event, AST_EVENT_IE_CEL_EVENT_TYPE);
@@ -123,6 +123,8 @@
accountcode = ast_event_get_ie_str(event, AST_EVENT_IE_CEL_ACCTCODE);
uniqueid = ast_event_get_ie_str(event, AST_EVENT_IE_CEL_UNIQUEID);
amaflag = ast_event_get_ie_uint(event, AST_EVENT_IE_CEL_AMAFLAGS);
+ userfield = ast_event_get_ie_str(event, AST_EVENT_IE_CEL_USERFIELD);
+ peer = ast_event_get_ie_str(event, AST_EVENT_IE_CEL_PEER);
if (usegmtime)
gmtime_r(&eventtime,&tm);
@@ -135,13 +137,13 @@
if (loguniqueid) {
snprintf(sqlcmd,sizeof(sqlcmd),"INSERT INTO %s "
"(eventtime,eventtype,cidname,cidnum,cidani,cidrdnis,ciddnid,exten,context,channel,app,"
- "appdata,amaflags,accountcode,uniqueid) "
- "VALUES (?,?,?,?,?,?,?,?,?,?,?,?,?,?,?)", table);
+ "appdata,amaflags,accountcode,userfield,peer,uniqueid) "
+ "VALUES (?,?,?,?,?,?,?,?,?,?,?,?,?,?,?,?,?)", table);
} else {
snprintf(sqlcmd,sizeof(sqlcmd),"INSERT INTO %s "
"(eventtime,eventtype,cidname,cidnum,cidani,cidrdnis,ciddnid,exten,context,channel,app,appdata,"
- "amaflags,accountcode) "
- "VALUES (?,?,?,?,?,?,?,?,?,?,?,?,?,?)", table);
+ "amaflags,accountcode,userfield,peer) "
+ "VALUES (?,?,?,?,?,?,?,?,?,?,?,?,?,?,?,?)", table);
}
if (!connected) {
@@ -193,9 +195,11 @@
SQLBindParameter(ODBC_stmt, 12, SQL_PARAM_INPUT, SQL_C_CHAR, SQL_CHAR, sizeof(appdata), 0, (char*)appdata, 0, NULL);
SQLBindParameter(ODBC_stmt, 13, SQL_PARAM_INPUT, SQL_C_SLONG, SQL_INTEGER, 0, 0, (int*)&amaflag, 0, NULL);
SQLBindParameter(ODBC_stmt, 14, SQL_PARAM_INPUT, SQL_C_CHAR, SQL_CHAR, sizeof(accountcode), 0, (char*)accountcode, 0, NULL);
+ SQLBindParameter(ODBC_stmt, 15, SQL_PARAM_INPUT, SQL_C_CHAR, SQL_CHAR, sizeof(userfield), 0, (char*)userfield, 0, NULL);
+ SQLBindParameter(ODBC_stmt, 16, SQL_PARAM_INPUT, SQL_C_CHAR, SQL_CHAR, sizeof(peer), 0, (char*)peer, 0, NULL);
if (loguniqueid) {
- SQLBindParameter(ODBC_stmt, 15, SQL_PARAM_INPUT, SQL_C_CHAR, SQL_CHAR, sizeof(uniqueid), 0, (char*)uniqueid, 0, NULL);
+ SQLBindParameter(ODBC_stmt, 17, SQL_PARAM_INPUT, SQL_C_CHAR, SQL_CHAR, sizeof(uniqueid), 0, (char*)uniqueid, 0, NULL);
}
if (connected) {
Modified: team/murf/newcdr/cel/cel_pgsql.c
URL: http://svn.digium.com/view/asterisk/team/murf/newcdr/cel/cel_pgsql.c?view=diff&rev=63792&r1=63791&r2=63792
==============================================================================
--- team/murf/newcdr/cel/cel_pgsql.c (original)
+++ team/murf/newcdr/cel/cel_pgsql.c Thu May 10 16:49:58 2007
@@ -84,7 +84,7 @@
time_t eventtime = 0;
struct ast_channel tchan = {0}; /* just so we store the data in vars and do var subst on the mapping line from the config file */
const char *cid_ani, *cid_rdnis, *cid_name, *cid_num, *cid_dnid;
- const char *exten, *context, *channame, *appname, *appdata, *accountcode, *uniqueid;
+ const char *exten, *context, *channame, *appname, *appdata, *accountcode, *uniqueid, *userfield, *peer;
unsigned int amaflag;
eventtype = (enum ast_cel_eventtype)ast_event_get_ie_uint(event, AST_EVENT_IE_CEL_EVENT_TYPE);
@@ -104,10 +104,12 @@
accountcode = ast_event_get_ie_str(event, AST_EVENT_IE_CEL_ACCTCODE);
uniqueid = ast_event_get_ie_str(event, AST_EVENT_IE_CEL_UNIQUEID);
amaflag = ast_event_get_ie_uint(event, AST_EVENT_IE_CEL_AMAFLAGS);
+ userfield = ast_event_get_ie_str(event, AST_EVENT_IE_CEL_USERFIELD);
+ peer = ast_event_get_ie_str(event, AST_EVENT_IE_CEL_PEER);
cel_set_backend_channel_vars(&tchan, eventtype, userdefname, eventtime, cid_name, cid_num,
cid_ani, cid_rdnis, cid_dnid, exten, context, channame,
- appname, appdata, accountcode, uniqueid, amaflag);
+ appname, appdata, accountcode, uniqueid, amaflag, userfield, peer);
ast_mutex_lock(&pgsql_lock);
@@ -127,7 +129,7 @@
if (connected) {
char *cidname_esc=NULL, *exten_esc, *context_esc=NULL, *channel_esc=NULL, *app_esc=NULL, *appdata_esc=NULL;
- char *uniqueid_esc=NULL, *cidnum_esc=NULL, *cidani_esc=NULL, *cidrdnis_esc=NULL, *ciddnid_esc=NULL, *accountcode_esc;
+ char *uniqueid_esc=NULL, *cidnum_esc=NULL, *cidani_esc=NULL, *cidrdnis_esc=NULL, *ciddnid_esc=NULL, *accountcode_esc, *userfield_esc, *peer_esc;
/* Maximum space needed would be if all characters needed to be escaped, plus a trailing NULL */
if ((cidname_esc = alloca(strlen(cid_name) * 2 + 1)) != NULL)
@@ -152,6 +154,10 @@
PQescapeString(uniqueid_esc, uniqueid, strlen(uniqueid));
if ((accountcode_esc = alloca(strlen(accountcode) * 2 + 1)) != NULL)
PQescapeString(accountcode_esc, accountcode, strlen(accountcode));
+ if ((userfield_esc = alloca(strlen(userfield) * 2 + 1)) != NULL)
+ PQescapeString(userfield_esc, userfield, strlen(userfield));
+ if ((peer_esc = alloca(strlen(peer) * 2 + 1)) != NULL)
+ PQescapeString(peer_esc, peer, strlen(peer));
/* Check for all alloca failures above at once */
if ((!cidname_esc) || (!context_esc) || (!channel_esc) || (!app_esc) || (!appdata_esc) || (!uniqueid_esc)
@@ -165,11 +171,11 @@
ast_log(LOG_DEBUG, "cel_pgsql: inserting a CEL record.\n");
snprintf(sqlcmd,sizeof(sqlcmd),"INSERT INTO %s (eventtime,cidname,cidnum,cidani,cidrdnis,ciddnid,exten,context,channel,"
- "app,appdata,amaflags,accountcode,uniqueid) VALUES"
- " ('%s','%s','%s','%s','%s','%s','%s','%s','%s','%s','%s','%d,'%s','%s')",
+ "app,appdata,amaflags,accountcode,uniqueid,userfield,peer) VALUES"
+ " ('%s','%s','%s','%s','%s','%s','%s','%s','%s','%s','%s','%d,'%s','%s','%s','%s')",
table,timestr,cidname_esc,cidnum_esc, cidani_esc, cidrdnis_esc, ciddnid_esc,
exten_esc, context_esc,channel_esc, app_esc, appdata_esc,
- amaflag, accountcode_esc, uniqueid_esc);
+ amaflag, accountcode_esc, uniqueid_esc, userfield_esc, peer_esc);
if (option_debug > 2)
ast_log(LOG_DEBUG, "cel_pgsql: SQL command executed: %s\n",sqlcmd);
Modified: team/murf/newcdr/cel/cel_sqlite.c
URL: http://svn.digium.com/view/asterisk/team/murf/newcdr/cel/cel_sqlite.c?view=diff&rev=63792&r1=63791&r2=63792
==============================================================================
--- team/murf/newcdr/cel/cel_sqlite.c (original)
+++ team/murf/newcdr/cel/cel_sqlite.c Thu May 10 16:49:58 2007
@@ -72,16 +72,22 @@
/*! \brief SQL table format */
static char sql_create_table[] = "CREATE TABLE cel ("
" AcctId INTEGER PRIMARY KEY,"
-" clid VARCHAR(80),"
-" clidnum VARCHAR(80),"
+" cidname VARCHAR(80),"
+" cidnum VARCHAR(80),"
+" cidani VARCHAR(80),"
+" cidrdnis VARCHAR(80),"
+" ciddnid VARCHAR(80),"
" exten VARCHAR(80),"
" context VARCHAR(80),"
-" channel VARCHAR(80),"
-" app VARCHAR(80),"
-" data VARCHAR(80),"
+" channame VARCHAR(80),"
+" appname VARCHAR(80),"
+" appdata VARCHAR(80),"
" eventtime CHAR(19),"
+" eventtype VARCHAR(32),"
" amaflags INTEGER,"
" accountcode VARCHAR(20)"
+" userfield VARCHAR(80),"
+" peer VARCHAR(80),"
#if LOG_UNIQUEID
" ,uniqueid VARCHAR(32)"
#endif
@@ -99,7 +105,7 @@
const char *userdefname = 0;
time_t eventtime = 0;
const char *cid_ani, *cid_rdnis, *cid_name, *cid_num, *cid_dnid;
- const char *exten, *context, *channame, *appname, *appdata, *accountcode, *uniqueid;
+ const char *exten, *context, *channame, *appname, *appdata, *accountcode, *uniqueid, *userfield, *peer;
unsigned int amaflag;
eventtype = (enum ast_cel_eventtype)ast_event_get_ie_uint(event, AST_EVENT_IE_CEL_EVENT_TYPE);
@@ -119,6 +125,8 @@
accountcode = ast_event_get_ie_str(event, AST_EVENT_IE_CEL_ACCTCODE);
uniqueid = ast_event_get_ie_str(event, AST_EVENT_IE_CEL_UNIQUEID);
amaflag = ast_event_get_ie_uint(event, AST_EVENT_IE_CEL_AMAFLAGS);
+ userfield = ast_event_get_ie_str(event, AST_EVENT_IE_CEL_USERFIELD);
+ peer = ast_event_get_ie_str(event, AST_EVENT_IE_CEL_PEER);
ast_mutex_lock(&sqlite_lock);
@@ -134,6 +142,8 @@
"eventtime,"
"amaflags,"
"accountcode"
+ "userfield"
+ "peer"
# if LOG_UNIQUEID
",uniqueid"
# endif
@@ -149,7 +159,9 @@
channame, appname, appdata,
startstr,
amaflag,
- accountcode
+ accountcode,
+ userfield,
+ peer
# if LOG_UNIQUEID
,uniqueid
# endif
Modified: team/murf/newcdr/cel/cel_sqlite3_custom.c
URL: http://svn.digium.com/view/asterisk/team/murf/newcdr/cel/cel_sqlite3_custom.c?view=diff&rev=63792&r1=63791&r2=63792
==============================================================================
--- team/murf/newcdr/cel/cel_sqlite3_custom.c (original)
+++ team/murf/newcdr/cel/cel_sqlite3_custom.c Thu May 10 16:49:58 2007
@@ -163,7 +163,7 @@
char *userdefname = 0;
time_t eventtime = 0;
const char *cid_ani, *cid_rdnis, *cid_name, *cid_num, *cid_dnid;
- const char *exten, *context, *channame, *appname, *appdata, *accountcode, *uniqueid;
+ const char *exten, *context, *channame, *appname, *appdata, *accountcode, *uniqueid, *userfield, *peer;
unsigned int amaflag;
struct ast_var_t *vardata;
@@ -188,10 +188,12 @@
accountcode = ast_event_get_ie_str(event, AST_EVENT_IE_CEL_ACCTCODE);
uniqueid = ast_event_get_ie_str(event, AST_EVENT_IE_CEL_UNIQUEID);
amaflag = ast_event_get_ie_uint(event, AST_EVENT_IE_CEL_AMAFLAGS);
+ userfield = ast_event_get_ie_str(event, AST_EVENT_IE_CEL_USERFIELD);
+ peer = ast_event_get_ie_str(event, AST_EVENT_IE_CEL_PEER);
cel_set_backend_channel_vars(&dummy, eventtype, userdefname, eventtime, cid_name, cid_num,
cid_ani, cid_rdnis, cid_dnid, exten, context, channame,
- appname, appdata, accountcode, uniqueid, amaflag);
+ appname, appdata, accountcode, uniqueid, amaflag, userfield, peer);
{ /* Make it obvious that only sql_cmd should be used outside of this block */
char *sql_tmp_cmd;
Modified: team/murf/newcdr/cel/cel_tds.c
URL: http://svn.digium.com/view/asterisk/team/murf/newcdr/cel/cel_tds.c?view=diff&rev=63792&r1=63791&r2=63792
==============================================================================
--- team/murf/newcdr/cel/cel_tds.c (original)
+++ team/murf/newcdr/cel/cel_tds.c Thu May 10 16:49:58 2007
@@ -33,16 +33,22 @@
CREATE TABLE [dbo].[cel] (
[accountcode] [varchar] (20) NULL ,
- [clidnum] [varchar] (80) NULL ,
+ [cidname] [varchar] (80) NULL ,
+ [cidnum] [varchar] (80) NULL ,
+ [cidani] [varchar] (80) NULL ,
+ [cidrdnis] [varchar] (80) NULL ,
+ [ciddnid] [varchar] (80) NULL ,
[exten] [varchar] (80) NULL ,
[context] [varchar] (80) NULL ,
- [clid] [varchar] (80) NULL ,
- [channel] [varchar] (80) NULL ,
- [app] [varchar] (80) NULL ,
+ [channame] [varchar] (80) NULL ,
+ [appname] [varchar] (80) NULL ,
[appdata] [varchar] (80) NULL ,
[eventtime] [datetime] NULL ,
- [amaflags] [varchar] (16) NULL ,
+ [eventtype] [varchar] (32) NULL ,
[uniqueid] [varchar] (32) NULL
+ [amaflags] [varchar] (16) NULL
+ [userfield] [varchar] (32) NULL
+ [peer] [varchar] (32) NULL
) ON [PRIMARY]
\endverbatim
@@ -105,7 +111,7 @@
static void tds_log(const struct ast_event *event, void *userdata)
{
char sqlcmd[2048], start[80];
- char *accountcode_ai, *clidnum_ai, *exten_ai, *context_ai, *clid_ai, *channel_ai, *app_ai, *appdata_ai, *uniqueid_ai, *cidani_ai, *cidrdnis_ai, *ciddnid_ai;
+ char *accountcode_ai, *clidnum_ai, *exten_ai, *context_ai, *clid_ai, *channel_ai, *app_ai, *appdata_ai, *uniqueid_ai, *cidani_ai, *cidrdnis_ai, *ciddnid_ai, *peer_ai, *userfield_ai;
int retried = 0;
#ifdef FREETDS_PRE_0_62
TDS_INT result_type;
@@ -114,7 +120,7 @@
const char *userdefname = 0;
time_t eventtime = 0;
const char *cid_ani, *cid_rdnis, *cid_name, *cid_num, *cid_dnid;
- const char *exten, *context, *channame, *appname, *appdata, *accountcode, *uniqueid;
+ const char *exten, *context, *channame, *appname, *appdata, *accountcode, *uniqueid, *userfield, *peer;
const char *eventname;
unsigned int amaflag;
@@ -135,6 +141,8 @@
accountcode = ast_event_get_ie_str(event, AST_EVENT_IE_CEL_ACCTCODE);
uniqueid = ast_event_get_ie_str(event, AST_EVENT_IE_CEL_UNIQUEID);
amaflag = ast_event_get_ie_uint(event, AST_EVENT_IE_CEL_AMAFLAGS);
+ userfield = ast_event_get_ie_str(event, AST_EVENT_IE_CEL_USERFIELD);
+ peer = ast_event_get_ie_str(event, AST_EVENT_IE_CEL_PEER);
ast_mutex_lock(&tds_lock);
@@ -157,6 +165,8 @@
app_ai = anti_injection(appname, 80);
appdata_ai = anti_injection(appdata, 80);
uniqueid_ai = anti_injection(uniqueid, 32);
+ userfield_ai = anti_injection(userfield, 32);
+ peer_ai = anti_injection(peer, 32);
get_date(start, eventtime);
@@ -179,6 +189,8 @@
"eventtype, "
"amaflags, "
"uniqueid"
+ "userfield"
+ "peer"
") "
"VALUES "
"("
@@ -197,6 +209,8 @@
"'%s', " /* eventtype */
"'%s', " /* amaflags */
"'%s'" /* uniqueid */
+ "'%s'" /* userfield */
+ "'%s'" /* peer */
")",
table,
accountcode_ai,
@@ -213,7 +227,9 @@
start,
eventname,
ast_cel_flags2str(amaflag),
- uniqueid_ai
+ uniqueid_ai,
+ userfield_ai,
+ peer_ai
);
do {
@@ -250,6 +266,8 @@
free(app_ai);
free(appdata_ai);
free(uniqueid_ai);
+ free(userfield_ai);
+ free(peer_ai);
ast_mutex_unlock(&tds_lock);
Modified: team/murf/newcdr/channels/chan_sip.c
URL: http://svn.digium.com/view/asterisk/team/murf/newcdr/channels/chan_sip.c?view=diff&rev=63792&r1=63791&r2=63792
==============================================================================
--- team/murf/newcdr/channels/chan_sip.c (original)
+++ team/murf/newcdr/channels/chan_sip.c Thu May 10 16:49:58 2007
@@ -14943,6 +14943,8 @@
/* Success - we have a new channel */
if (option_debug > 2)
ast_log(LOG_DEBUG, "%s transfer succeeded. Telling transferer.\n", p->refer->attendedtransfer? "Attended" : "Blind");
+ ast_cel_report_event(current.chan1, CEL_TRANSFER, NULL, current.chan2);
+
transmit_notify_with_sipfrag(p, seqno, "200 Ok", TRUE);
if (p->refer->localtransfer)
p->refer->status = REFER_200OK;
Modified: team/murf/newcdr/channels/chan_zap.c
URL: http://svn.digium.com/view/asterisk/team/murf/newcdr/channels/chan_zap.c?view=diff&rev=63792&r1=63791&r2=63792
==============================================================================
--- team/murf/newcdr/channels/chan_zap.c (original)
+++ team/murf/newcdr/channels/chan_zap.c Thu May 10 16:49:58 2007
@@ -90,6 +90,7 @@
#include "asterisk/adsi.h"
#include "asterisk/cli.h"
#include "asterisk/cdr.h"
+#include "asterisk/cel.h"
#include "asterisk/features.h"
#include "asterisk/musiconhold.h"
#include "asterisk/say.h"
@@ -4560,6 +4561,8 @@
} else {
if (option_verbose > 2)
ast_verbose(VERBOSE_PREFIX_3 "Started three way call on channel %d\n", p->channel);
+ ast_cel_report_event(p->subs[SUB_THREEWAY].owner, CEL_HOOKFLASH, NULL, chan);
+
/* Start music on hold if appropriate */
if (ast_bridged_channel(p->subs[SUB_THREEWAY].owner)) {
ast_queue_control_data(p->subs[SUB_THREEWAY].owner, AST_CONTROL_HOLD,
@@ -4583,6 +4586,7 @@
p->owner = p->subs[SUB_REAL].owner;
}
/* Drop the last call and stop the conference */
+ ast_cel_report_event(p->subs[SUB_REAL].owner, CEL_3WAY_END, NULL, p->subs[SUB_THREEWAY].owner);
if (option_verbose > 2)
ast_verbose(VERBOSE_PREFIX_3 "Dropping three-way call on %s\n", p->subs[SUB_THREEWAY].owner->name);
p->subs[SUB_THREEWAY].owner->_softhangup |= AST_SOFTHANGUP_DEV;
@@ -4607,6 +4611,7 @@
ast_queue_control(p->subs[otherindex].owner, AST_CONTROL_UNHOLD);
p->subs[otherindex].needunhold = 1;
p->owner = p->subs[SUB_REAL].owner;
+ ast_cel_report_event(p->subs[SUB_REAL].owner, CEL_3WAY_START, NULL, p->subs[SUB_THREEWAY].owner);
if (ast->_state == AST_STATE_RINGING) {
if (option_debug)
ast_log(LOG_DEBUG, "Enabling ringtone on real and threeway\n");
Modified: team/murf/newcdr/funcs/func_cel.c
URL: http://svn.digium.com/view/asterisk/team/murf/newcdr/funcs/func_cel.c?view=diff&rev=63792&r1=63791&r2=63792
==============================================================================
--- team/murf/newcdr/funcs/func_cel.c (original)
+++ team/murf/newcdr/funcs/func_cel.c Thu May 10 16:49:58 2007
@@ -101,10 +101,15 @@
ast_cel_setaccount(chan, value);
else if (!strcasecmp(args.variable, "amaflags"))
ast_cel_setamaflags(chan, value);
- else
- ast_cel_setvar(chan, args.variable, value);
- /* No need to worry about the u flag, as all fields for which setting
- * 'u' would do anything are marked as readonly. */
+ else if (!strcasecmp(args.variable, "userfield"))
+ ast_cel_setamaflags(chan, value);
+ /* sorry, but CEL can't manipulate or use channel vars at the moment..*/
+ else {
+ ast_log(LOG_ERROR,"Sorry, but CEL doesn't use channel vars, and can only set accountcode, amaflags, and userfield\n");
+ }
+
+ /* No need to worry about the u flag, as all fields for which setting
+ * 'u' would do anything are marked as readonly. */
return 0;
}
Modified: team/murf/newcdr/include/asterisk/cel.h
URL: http://svn.digium.com/view/asterisk/team/murf/newcdr/include/asterisk/cel.h?view=diff&rev=63792&r1=63791&r2=63792
==============================================================================
--- team/murf/newcdr/include/asterisk/cel.h (original)
+++ team/murf/newcdr/include/asterisk/cel.h Thu May 10 16:49:58 2007
@@ -65,9 +65,23 @@
/*! channel out of the park */
CEL_PARK_END = 12,
/*! a transfer occurs */
- CEL_TRANSFER = 13,
+ CEL_BLINDTRANSFER = 13,
+ /*! a transfer occurs */
+ CEL_ATTENDEDTRANSFER = 14,
+ /*! a transfer occurs */
+ CEL_TRANSFER = 15,
+ /*! a 3-way conference, usually part of a transfer */
+ CEL_HOOKFLASH = 16,
+ /*! a 3-way conference, usually part of a transfer */
+ CEL_3WAY_START = 17,
+ /*! a 3-way conference, usually part of a transfer */
+ CEL_3WAY_END = 18,
+ /*! channel enters a conference */
+ CEL_CONF_ENTER = 19,
+ /*! channel exits a conference */
+ CEL_CONF_EXIT = 20,
/*! a user-defined event, the event name field should be set */
- CEL_USER_DEFINED = 14,
+ CEL_USER_DEFINED = 21,
};
/* there was in the early stages of design, a concept of struct ast_cel,
@@ -111,12 +125,13 @@
const char *cid_rdnis, const char *cid_dnid, const char *exten,
const char *context, const char *channame, const char *appname,
const char *appdata, const char *accountcode,
- const char *uniqueid, unsigned int amaflag);
+ const char *uniqueid, unsigned int amaflag, const char *userfield,
+ const char *peer);
/*! Frees the cel struct */
void ast_cel_destroy(struct ast_cel *cel);
-void ast_cel_report_event(const struct ast_channel *chan, enum ast_cel_eventtype, char *userdefevname);
+void ast_cel_report_event(const struct ast_channel *chan, enum ast_cel_eventtype, char *userdefevname, const struct ast_channel *peer2);
extern int cel_default_amaflags;
Modified: team/murf/newcdr/include/asterisk/channel.h
URL: http://svn.digium.com/view/asterisk/team/murf/newcdr/include/asterisk/channel.h?view=diff&rev=63792&r1=63791&r2=63792
==============================================================================
--- team/murf/newcdr/include/asterisk/channel.h (original)
+++ team/murf/newcdr/include/asterisk/channel.h Thu May 10 16:49:58 2007
@@ -149,6 +149,7 @@
#include "asterisk/config.h"
#include "asterisk/lock.h"
#include "asterisk/cdr.h"
+#include "asterisk/cel.h"
#include "asterisk/utils.h"
#include "asterisk/linkedlists.h"
#include "asterisk/stringfields.h"
@@ -390,6 +391,7 @@
AST_STRING_FIELD(language); /*!< Language requested for voice prompts */
AST_STRING_FIELD(musicclass); /*!< Default music class */
AST_STRING_FIELD(accountcode); /*!< Account code for billing */
+ AST_STRING_FIELD(userfield); /*!< Userfield for CEL billing */
AST_STRING_FIELD(call_forward); /*!< Where to forward to if asked to dial on this interface */
AST_STRING_FIELD(uniqueid); /*!< Unique Channel Identifier */
);
Modified: team/murf/newcdr/include/asterisk/event_defs.h
URL: http://svn.digium.com/view/asterisk/team/murf/newcdr/include/asterisk/event_defs.h?view=diff&rev=63792&r1=63791&r2=63792
==============================================================================
--- team/murf/newcdr/include/asterisk/event_defs.h (original)
+++ team/murf/newcdr/include/asterisk/event_defs.h Thu May 10 16:49:58 2007
@@ -185,12 +185,18 @@
* Payload type: STR
*/
AST_EVENT_IE_CEL_CIDDNID = 0x16,
+ /*!
+ * \brief Channel Event Peer -- for Things involving multiple channels, like BRIDGE
+ * Used by: AST_EVENT_CEL
+ * Payload type: STR
+ */
+ AST_EVENT_IE_CEL_PEER = 0x17,
/*!
* \brief Hint that someone cares that an IE exists
* Used by: AST_EVENT_SUB
* Payload type: UINT (ast_event_ie_type)
*/
- AST_EVENT_IE_EXISTS = 0x17,
+ AST_EVENT_IE_EXISTS = 0x18,
};
/*!
Modified: team/murf/newcdr/main/cel.c
URL: http://svn.digium.com/view/asterisk/team/murf/newcdr/main/cel.c?view=diff&rev=63792&r1=63791&r2=63792
==============================================================================
--- team/murf/newcdr/main/cel.c (original)
+++ team/murf/newcdr/main/cel.c Thu May 10 16:49:58 2007
@@ -55,7 +55,7 @@
char cel_default_accountcode[AST_MAX_ACCOUNT_CODE];
static int cel_enabled; /*! Is the CEL subsystem enabled ? */
-static long long eventset = 0; /*! which events we want to track */
+static long long eventset = 0; /*! which events we want to track; up to 64 events */
static struct ast_hashtab *appset = 0;
int check_cel_enabled()
@@ -123,6 +123,20 @@
return CEL_TRANSFER;
else if (strcasecmp(eventname,"USER_DEFINED")==0)
return CEL_USER_DEFINED;
+ else if (strcasecmp(eventname,"CONF_ENTER")==0)
+ return CEL_CONF_ENTER;
+ else if (strcasecmp(eventname,"CONF_EXIT")==0)
+ return CEL_CONF_EXIT;
+ else if (strcasecmp(eventname,"BLINDTRANSFER")==0)
+ return CEL_BLINDTRANSFER;
+ else if (strcasecmp(eventname,"ATTENDEDTRANSFER")==0)
+ return CEL_ATTENDEDTRANSFER;
+ else if (strcasecmp(eventname,"3WAY_START")==0)
+ return CEL_3WAY_START;
+ else if (strcasecmp(eventname,"3WAY_END")==0)
+ return CEL_3WAY_END;
+ else if (strcasecmp(eventname,"HOOKFLASH")==0)
+ return CEL_HOOKFLASH;
else
return -1;
}
@@ -326,8 +340,22 @@
return "EV_PARK_END";
case CEL_TRANSFER:
return "EV_TRANSFER";
+ case CEL_CONF_ENTER:
+ return "EV_CONF_ENTER";
+ case CEL_CONF_EXIT:
+ return "EV_CONF_EXIT";
case CEL_USER_DEFINED:
return "EV_USER_DEF";
+ case CEL_BLINDTRANSFER:
+ return "EV_BLINDTRANSFER";
+ case CEL_ATTENDEDTRANSFER:
+ return "EV_ATTENDEDTRANSFER";
+ case CEL_3WAY_START:
+ return "EV_3WAY_START";
+ case CEL_3WAY_END:
+ return "EV_3WAY_END";
+ case CEL_HOOKFLASH:
+ return "EV_HOOKFLASH";
}
return "";
}
@@ -361,8 +389,8 @@
}
/* readonly channel variables */
-static const char *cel_readonly_vars[] = { "clid", "clidnum", "clidani", "clidrdnis", "exten", "context", "channel",
- "app", "appdata", "eventtype", "eventname",
+static const char *cel_readonly_vars[] = { "cidname", "cidnum", "cidani", "cidrdnis", "ciddnid", "exten", "context", "channame",
+ "appname", "appdata", "eventtype", "eventname","peer",
"uniqueid",
NULL };
@@ -372,8 +400,6 @@
*/
int ast_cel_setvar(struct ast_channel *chan, const char *name, const char *value)
{
- struct ast_var_t *newvariable;
- struct varshead *headp;
int x;
for (x = 0; cel_readonly_vars[x]; x++) {
@@ -386,22 +412,6 @@
if (!chan) {
ast_log(LOG_ERROR, "Attempt to set a variable on a NULL Channel.\n");
return -1;
- }
-
- headp = &chan->varshead;
- AST_LIST_TRAVERSE_SAFE_BEGIN(headp, newvariable, entries) {
- if (!strcasecmp(ast_var_name(newvariable), name)) {
- /* there is already such a variable, delete it */
- AST_LIST_REMOVE_CURRENT(headp, entries);
- ast_var_delete(newvariable);
- break;
- }
- }
- AST_LIST_TRAVERSE_SAFE_END;
-
- if (value) {
- newvariable = ast_var_assign(name, value);
- AST_LIST_INSERT_HEAD(headp, newvariable, entries);
}
return 0;
@@ -434,27 +444,10 @@
}
}
-static const char *ast_cel_getvar_internal(struct ast_channel *chan, const char *name)
-{
- struct ast_var_t *variables;
- struct varshead *headp = &chan->varshead;
-
- if (ast_strlen_zero(name))
- return NULL;
-
- AST_LIST_TRAVERSE(headp, variables, entries) {
- if (!strcasecmp(name, ast_var_name(variables)))
- return ast_var_value(variables);
- }
-
- return NULL;
-}
-
/*! CEL channel variable retrieval */
void ast_cel_getvar(struct ast_channel *chan, const char *name, char **ret, char *workspace, int workspacelen, int raw)
{
const char *fmt = "%Y-%m-%d %T";
- const char *varbuf;
if (!chan) /* don't die if the chan is null */
return;
@@ -479,9 +472,29 @@
ast_copy_string(workspace, chan->name, workspacelen);
else if (!strcasecmp(name, "appname"))
ast_copy_string(workspace, chan->appl, workspacelen);
- else if (!strcasecmp(name, "appdata"))
+ else if (!strcasecmp(name, "userfield"))
+ ast_copy_string(workspace, chan->userfield, workspacelen);
+ else if (!strcasecmp(name, "peer")) {
+ struct ast_channel *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(workspace, (p ? p->name : ""), workspacelen);
+ else
+ ast_copy_string(workspace, chan->language, workspacelen); /* a horrible kludge, but... how else? */
+ } else if (!strcasecmp(name, "appdata"))
ast_copy_string(workspace, chan->data, workspacelen);
- else if (!strcasecmp(name, "eventtime")) { /* only available to the backends, and needs special handling via raw */
+ else if (!strcasecmp(name, "eventtype")) { /* only available to the backends, and needs special handling via raw */
+ struct ast_var_t *variables;
+ struct varshead *headp = &chan->varshead;
+ const char *t2=0;
+
+ AST_LIST_TRAVERSE(headp, variables, entries) {
+ if (!strcasecmp(name, ast_var_name(variables))) {
+ t2 = ast_var_value(variables);
+ break;
+ }
+ }
+ ast_copy_string(workspace, t2 ? t2 : "<none>", workspacelen);
+ } else if (!strcasecmp(name, "eventtime")) { /* only available to the backends, and needs special handling via raw */
struct ast_var_t *variables;
struct varshead *headp = &chan->varshead;
const char *t2=0;
@@ -511,8 +524,6 @@
ast_copy_string(workspace, chan->accountcode, workspacelen);
else if (!strcasecmp(name, "uniqueid"))
ast_copy_string(workspace, chan->uniqueid, workspacelen);
- else if ((varbuf = ast_cel_getvar_internal(chan, name)))
- ast_copy_string(workspace, varbuf, workspacelen);
else
workspace[0] = '\0';
@@ -525,9 +536,12 @@
const char *cid_name, const char *cid_num, const char *cid_ani,
const char *cid_rdnis, const char *cid_dnid, const char *exten,
const char *context, const char *channame, const char *appname,
- const char *appdata, const char *accountcode,
- const char *uniqueid, unsigned int amaflag)
-{
+ const char *appdata, const char *accountcode, const char *uniqueid,
+ unsigned int amaflag, const char *userfield, const char *peer)
+{
+ /* this routine is only called to populate a dummy channel struct with the data,
+ so the CEL func can grab the correct datum and have it substituted, the same as if
+ a real channel were being used with the CEL func. What we do for re-use!! */
/* set the eventtime, eventtype fields */
struct ast_var_t *newvariable;
@@ -556,24 +570,20 @@
ast_string_field_set(chan,name,channame);
ast_string_field_set(chan,uniqueid,uniqueid);
ast_string_field_set(chan,accountcode,accountcode);
+ ast_string_field_set(chan,userfield,userfield);
+ ast_string_field_set(chan,language,peer); /* we'll hide the peer name in the language field -- CEL had best be able to tell a dummy channel from a real one!*/
chan->appl = ast_strdup(appname);
chan->data = ast_strdup(appdata);
chan->amaflags = amaflag;
}
-void ast_cel_report_event(const struct ast_channel *chan, enum ast_cel_eventtype eventtype, char *userdefevname)
+void ast_cel_report_event(const struct ast_channel *chan, enum ast_cel_eventtype eventtype, char *userdefevname, const struct ast_channel *peer2)
{
if (track_event(eventtype))
{
- time_t eventtime;
- struct ast_event *ev;
int trackit = 1;
- char *udef = userdefevname;
-
- if (!udef)
- udef = "";
ast_log(LOG_DEBUG,"CEL event tracked: %s\n", ast_cel_eventtype2str(eventtype));
@@ -584,6 +594,21 @@
}
if (trackit) {
+ time_t eventtime;
+ struct ast_event *ev;
+ char *udef = userdefevname;
+ const char *peername = "";
+ struct ast_channel *peer = ast_bridged_channel((struct ast_channel*)chan);
+
+ if (peer)
+ peername = peer->name;
+
+ if (peer2)
+ peername = peer2->name;
+
+ if (!udef)
+ udef = "";
+
eventtime = time(0);
/* now, report this event */
ev = ast_event_new(AST_EVENT_CEL,
@@ -603,6 +628,8 @@
AST_EVENT_IE_CEL_AMAFLAGS, AST_EVENT_IE_PLTYPE_UINT, chan->amaflags,
AST_EVENT_IE_CEL_ACCTCODE, AST_EVENT_IE_PLTYPE_STR, chan->accountcode,
AST_EVENT_IE_CEL_UNIQUEID, AST_EVENT_IE_PLTYPE_STR, chan->uniqueid,
+ AST_EVENT_IE_CEL_USERFIELD, AST_EVENT_IE_PLTYPE_STR, chan->userfield,
+ AST_EVENT_IE_CEL_PEER, AST_EVENT_IE_PLTYPE_STR, peername,
AST_EVENT_IE_END);
if (!ev) {
return;
Modified: team/murf/newcdr/main/channel.c
URL: http://svn.digium.com/view/asterisk/team/murf/newcdr/main/channel.c?view=diff&rev=63792&r1=63791&r2=63792
==============================================================================
--- team/murf/newcdr/main/channel.c (original)
+++ team/murf/newcdr/main/channel.c Thu May 10 16:49:58 2007
@@ -774,7 +774,7 @@
ast_cdr_init(tmp->cdr, tmp);
ast_cdr_start(tmp->cdr);
- ast_cel_report_event(tmp, CEL_CHANNEL_START, NULL);
+ ast_cel_report_event(tmp, CEL_CHANNEL_START, NULL, NULL);
headp = &tmp->varshead;
AST_LIST_HEAD_INIT_NOLOCK(headp);
@@ -1080,7 +1080,7 @@
headp=&chan->varshead;
- ast_cel_report_event(chan, CEL_CHANNEL_END, NULL);
+ ast_cel_report_event(chan, CEL_CHANNEL_END, NULL, NULL);
AST_LIST_LOCK(&channels);
AST_LIST_REMOVE(&channels, chan, chan_list);
@@ -1648,7 +1648,7 @@
chan->generator->release(chan, chan->generatordata);
chan->generatordata = NULL;
chan->generator = NULL;
- ast_cel_report_event(chan, CEL_HANGUP, NULL);
+ ast_cel_report_event(chan, CEL_HANGUP, NULL, NULL);
if (chan->cdr) { /* End the CDR if it hasn't already */
ast_cdr_end(chan->cdr);
@@ -1711,7 +1711,7 @@
res = chan->tech->answer(chan);
ast_setstate(chan, AST_STATE_UP);
ast_cdr_answer(chan->cdr);
- ast_cel_report_event(chan, CEL_ANSWER, NULL);
+ ast_cel_report_event(chan, CEL_ANSWER, NULL, NULL);
ast_channel_unlock(chan);
if (delay)
ast_safe_sleep(chan, delay);
@@ -1719,7 +1719,7 @@
break;
case AST_STATE_UP:
ast_cdr_answer(chan->cdr);
- ast_cel_report_event(chan, CEL_ANSWER, NULL);
+ ast_cel_report_event(chan, CEL_ANSWER, NULL, NULL);
break;
default:
break;
@@ -2229,7 +2229,7 @@
}
ast_cdr_answer(chan->cdr);
[... 154 lines stripped ...]
More information about the asterisk-commits
mailing list