[asterisk-commits] murf: branch murf/newcdr r62263 - in
/team/murf/newcdr: ./ cel/ include/aster...
asterisk-commits at lists.digium.com
asterisk-commits at lists.digium.com
Fri Apr 27 18:57:29 MST 2007
Author: murf
Date: Fri Apr 27 20:57:28 2007
New Revision: 62263
URL: http://svn.digium.com/view/asterisk?view=rev&rev=62263
Log:
Got rid of the ast_cel structure entirely-- it would be a mem mngmnt nightmare. Got some more of the backends to compile. Got a chunk of the routine to generate events written
Modified:
team/murf/newcdr/Makefile
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_radius.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/include/asterisk/cel.h
team/murf/newcdr/include/asterisk/event_defs.h
team/murf/newcdr/main/cel.c
Modified: team/murf/newcdr/Makefile
URL: http://svn.digium.com/view/asterisk/team/murf/newcdr/Makefile?view=diff&rev=62263&r1=62262&r2=62263
==============================================================================
--- team/murf/newcdr/Makefile (original)
+++ team/murf/newcdr/Makefile Fri Apr 27 20:57:28 2007
@@ -242,7 +242,7 @@
ASTCFLAGS+=$(MALLOC_DEBUG)$(BUSYDETECT)$(OPTIONS)
-MOD_SUBDIRS:=res channels pbx apps codecs formats cdr funcs main
+MOD_SUBDIRS:=res channels pbx apps codecs formats cdr cel funcs main
OTHER_SUBDIRS:=utils agi
SUBDIRS:=$(OTHER_SUBDIRS) $(MOD_SUBDIRS)
SUBDIRS_INSTALL:=$(SUBDIRS:%=%-install)
@@ -437,6 +437,8 @@
fi
mkdir -p $(DESTDIR)$(ASTLOGDIR)/cdr-csv
mkdir -p $(DESTDIR)$(ASTLOGDIR)/cdr-custom
+ mkdir -p $(DESTDIR)$(ASTLOGDIR)/cel-csv
+ mkdir -p $(DESTDIR)$(ASTLOGDIR)/cel-custom
mkdir -p $(DESTDIR)$(ASTDATADIR)/keys
mkdir -p $(DESTDIR)$(ASTDATADIR)/firmware
mkdir -p $(DESTDIR)$(ASTDATADIR)/firmware/iax
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=62263&r1=62262&r2=62263
==============================================================================
--- team/murf/newcdr/cel/cel_csv.c (original)
+++ team/murf/newcdr/cel/cel_csv.c Fri Apr 27 20:57:28 2007
@@ -58,7 +58,7 @@
static int loguniqueid = 0;
static int loguserfield = 0;
static char *config = "cel.conf";
-static struct ast_event_sub event_sub = 0;
+static struct ast_event_sub *event_sub = 0;
/* #define CSV_LOGUNIQUEID 1 */
/* #define CSV_LOGUSERFIELD 1 */
@@ -84,8 +84,6 @@
"userfield" user field set via SetCDRUserField
----------------------------------------------------------*/
-static char *name = "csv";
-
static FILE *mf = NULL;
@@ -167,7 +165,7 @@
return error;
}
-static int append_int(char *buf, int s, size_t bufsize)
+/* static int append_int(char *buf, int s, size_t bufsize)
{
char tmp[32];
int pos = strlen(buf);
@@ -179,17 +177,15 @@
buf[pos++] = ',';
buf[pos++] = '\0';
return 0;
-}
-
-static int append_date(char *buf, struct timeval tv, size_t bufsize)
+ } */
+
+static int append_date(char *buf, time_t t, size_t bufsize)
{
char tmp[80] = "";
struct tm tm;
- time_t t;
- t = tv.tv_sec;
if (strlen(buf) > bufsize - 3)
return -1;
- if (ast_tvzero(tv)) {
+ if (t == 0) {
strncat(buf, ",", bufsize - strlen(buf) - 1);
return 0;
}
@@ -202,40 +198,38 @@
return append_string(buf, tmp, bufsize);
}
-static int build_csv_record(char *buf, size_t bufsize, struct ast_cel *cel)
+static int build_csv_record(char *buf, size_t bufsize, const struct ast_channel *chan, enum ast_cel_eventtype eventtype, time_t eventtime, const char *userdefname)
{
buf[0] = '\0';
/* Start Time */
- append_date(buf, cel->eventtime, bufsize);
+ append_date(buf, eventtime, bufsize);
/* EventType */
- append_string(buf, ast_cel_eventtype2str(cel->eventtype), bufsize);
- /* UserEventName */
- append_string(buf, cel->usereventname, bufsize);
+ if (eventtype==CEL_USER_DEFINED)
+ append_string(buf, (char*)userdefname, bufsize);
+ else
+ append_string(buf, ast_cel_eventtype2str(eventtype), bufsize);
/* Account code */
- append_string(buf, cel->accountcode, bufsize);
+ append_string(buf, (char*)chan->accountcode, bufsize);
/* CID number */
- append_string(buf, cel->clidnum, bufsize);
+ append_string(buf, (char*)chan->cid.cid_num, bufsize);
/* Exten */
- append_string(buf, cel->exten, bufsize);
+ append_string(buf, (char*)chan->exten, bufsize);
/* Context */
- append_string(buf, cel->context, bufsize);
+ append_string(buf, (char*)chan->context, bufsize);
/* Caller*ID */
- append_string(buf, cel->clid, bufsize);
+ append_string(buf, chan->cid.cid_name, bufsize);
/* Channel Name */
- append_string(buf, cel->channel, bufsize);
+ append_string(buf, (char*)chan->name, bufsize);
/* Application */
- append_string(buf, cel->app, bufsize);
+ append_string(buf, (char*)chan->appl, bufsize);
/* App Data/Args, whatever */
- append_string(buf, cel->appdata, bufsize);
+ append_string(buf, (char*)chan->data, bufsize);
/* AMA Flags */
- append_string(buf, ast_cel_flags2str(cel->amaflags), bufsize);
+ append_string(buf, ast_cel_flags2str(chan->amaflags), bufsize);
/* Unique ID */
if (loguniqueid)
- append_string(buf, cel->uniqueid, bufsize);
- /* append the user field */
- if(loguserfield)
- append_string(buf, cel->userfield,bufsize);
+ append_string(buf, (char*)chan->uniqueid, bufsize);
/* If we hit the end of our buffer, log an error */
if (strlen(buf) < bufsize - 5) {
/* Trim off trailing comma */
@@ -270,15 +264,23 @@
/* Make sure we have a big enough buf */
char buf[1024];
char csvmaster[PATH_MAX];
- struct ast_cel *cel;
-
- cel = ast_event_get_ie_raw(event, AST_EVENT_IE_CELPTR);
- cel_set_backend_channel_vars(cel);
+ const struct ast_channel *chan;
+ enum ast_cel_eventtype eventtype;
+ const char *userdefname = 0;
+ time_t eventtime = 0;
+
+ chan = ast_event_get_ie_raw(event, AST_EVENT_IE_CHANPTR);
+ eventtype = (enum ast_cel_eventtype)ast_event_get_ie_uint(event, AST_EVENT_IE_CEL_EVENT_TYPE);
+ eventtime = (time_t)ast_event_get_ie_uint(event, AST_EVENT_IE_CEL_EVENT_TIME);
+ if (eventtype == CEL_USER_DEFINED)
+ userdefname = ast_event_get_ie_str(event, AST_EVENT_IE_CEL_USEREVENT_NAME);
+
+ cel_set_backend_channel_vars(chan, eventtype, userdefname, eventtime);
snprintf(csvmaster, sizeof(csvmaster),"%s/%s/%s", ast_config_AST_LOG_DIR, CSV_LOG_DIR, CSV_MASTER);
#if 0
printf("[CDR] %s ('%s' -> '%s') Dur: %ds Bill: %ds Disp: %s Flags: %s Account: [%s]\n", cel->channel, cel->src, cel->dst, cel->duration, cel->billsec, ast_cel_disp2str(cel->disposition), ast_cel_flags2str(cel->amaflags), cel->accountcode);
#endif
- if (build_csv_record(buf, sizeof(buf), cel)) {
+ if (build_csv_record(buf, sizeof(buf), chan, eventtype, eventtime,userdefname)) {
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
@@ -294,9 +296,9 @@
fclose(mf);
mf = NULL;
}
- if (!ast_strlen_zero(cel->accountcode)) {
- if (writefile(buf, cel->accountcode))
- ast_log(LOG_WARNING, "Unable to write CSV record to account file '%s' : %s\n", cel->accountcode, strerror(errno));
+ if (!ast_strlen_zero(chan->accountcode)) {
+ if (writefile(buf, (char*)chan->accountcode))
+ ast_log(LOG_WARNING, "Unable to write CSV record to account file '%s' : %s\n", chan->accountcode, strerror(errno));
}
}
return;
@@ -315,12 +317,10 @@
static int load_module(void)
{
- int res;
-
if(!load_config())
return AST_MODULE_LOAD_DECLINE;
- event_sub = ast_event_subscribe(AST_EVENT_CEL, csv_log, NULL, AST_EVENT_IE_END);
+ event_sub = ast_event_subscribe(AST_EVENT_CEL, csv_log, "CSV Event Logging", NULL, AST_EVENT_IE_END);
if (!event_sub) {
ast_log(LOG_ERROR, "Unable to register CSV CEL handling\n");
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=62263&r1=62262&r2=62263
==============================================================================
--- team/murf/newcdr/cel/cel_custom.c (original)
+++ team/murf/newcdr/cel/cel_custom.c Fri Apr 27 20:57:28 2007
@@ -62,7 +62,7 @@
static char master[PATH_MAX];
static char format[1024]="";
-static struct ast_event_sub event_sub = 0;
+static struct ast_event_sub *event_sub = 0;
static int load_config(int reload)
{
@@ -107,19 +107,25 @@
{
/* Make sure we have a big enough buf */
char buf[2048];
- struct ast_channel dummy;
- struct ast_cel *cel;
+ const struct ast_channel *chan;
+ enum ast_cel_eventtype eventtype;
+ const char *userdefname = 0;
+ time_t eventtime = 0;
/* Abort if no master file is specified */
if (ast_strlen_zero(master))
- return 0;
+ return;
- cel = ast_event_get_ie_raw(event, AST_EVENT_IE_CELPTR);
- cel_set_backend_channel_vars(cel);
+ chan = ast_event_get_ie_raw(event, AST_EVENT_IE_CHANPTR);
+ eventtype = (enum ast_cel_eventtype)ast_event_get_ie_uint(event, AST_EVENT_IE_CEL_EVENT_TYPE);
+ eventtime = (time_t)ast_event_get_ie_uint(event, AST_EVENT_IE_CEL_EVENT_TIME);
+ if (eventtype == CEL_USER_DEFINED)
+ userdefname = ast_event_get_ie_str(event, AST_EVENT_IE_CEL_USEREVENT_NAME);
+ cel_set_backend_channel_vars(chan, eventtype, userdefname, eventtime);
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 */
/* fix this code */
- pbx_substitute_variables_helper(cel->chan, format, buf, sizeof(buf) - 1);
+ pbx_substitute_variables_helper((struct ast_channel*)chan, format, buf, sizeof(buf) - 1);
/* because of the absolutely unconditional need for the
highest reliability possible in writing billing records,
@@ -134,7 +140,7 @@
fclose(mf);
mf = NULL;
}
- return 0;
+ return;
}
static int unload_module(void)
@@ -151,7 +157,7 @@
{
if (!load_config(0)) {
- event_sub = ast_event_subscribe(AST_EVENT_CEL, custom_log, NULL, AST_EVENT_IE_END);
+ event_sub = ast_event_subscribe(AST_EVENT_CEL, custom_log, NULL, "Custom CSV logging", AST_EVENT_IE_END);
if (!event_sub)
ast_log(LOG_ERROR, "Unable to register custom CEL handling\n");
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=62263&r1=62262&r2=62263
==============================================================================
--- team/murf/newcdr/cel/cel_manager.c (original)
+++ team/murf/newcdr/cel/cel_manager.c Fri Apr 27 20:57:28 2007
@@ -48,10 +48,8 @@
#define DATE_FORMAT "%Y-%m-%d %T"
#define CONF_FILE "cel_manager.conf"
-static char *name = "cel_manager";
-
static int enablecel = 0;
-static struct ast_event_sub event_sub = 0;
+static struct ast_event_sub *event_sub = 0;
static int loadconfigurationfile(void)
{
@@ -92,54 +90,41 @@
time_t t;
struct tm timeresult;
char strStartTime[80] = "";
- char strAnswerTime[80] = "";
- char strEndTime[80] = "";
- struct ast_cel *cel = 0;
+ const struct ast_channel *chan;
+ enum ast_cel_eventtype eventtype;
+ const char *userdefname = 0;
+ time_t eventtime = 0;
if (!enablecel)
- return 0;
+ return;
- cel = ast_event_get_ie_raw(event, AST_EVENT_IE_CELPTR);
- cel_set_backend_channel_vars(cel);
- t = cel->start.tv_sec;
+ chan = ast_event_get_ie_raw(event, AST_EVENT_IE_CHANPTR);
+ eventtype = (enum ast_cel_eventtype)ast_event_get_ie_uint(event, AST_EVENT_IE_CEL_EVENT_TYPE);
+ eventtime = (time_t)ast_event_get_ie_uint(event, AST_EVENT_IE_CEL_EVENT_TIME);
+ if (eventtype == CEL_USER_DEFINED)
+ userdefname = ast_event_get_ie_str(event, AST_EVENT_IE_CEL_USEREVENT_NAME);
+ cel_set_backend_channel_vars(chan, eventtype, userdefname, eventtime);
+ t = eventtime;
localtime_r(&t, &timeresult);
strftime(strStartTime, sizeof(strStartTime), DATE_FORMAT, &timeresult);
- if (cel->answer.tv_sec) {
- t = cel->answer.tv_sec;
- localtime_r(&t, &timeresult);
- strftime(strAnswerTime, sizeof(strAnswerTime), DATE_FORMAT, &timeresult);
- }
-
- t = cel->end.tv_sec;
- localtime_r(&t, &timeresult);
- strftime(strEndTime, sizeof(strEndTime), DATE_FORMAT, &timeresult);
-
- manager_event(EVENT_FLAG_CALL, "Cdr",
+ manager_event(EVENT_FLAG_CALL, "CEL",
+ "EventName: %s\r\n"
"AccountCode: %s\r\n"
- "Source: %s\r\n"
- "Destination: %s\r\n"
- "DestinationContext: %s\r\n"
- "CallerID: %s\r\n"
+ "CallerIDnum: %s\r\n"
+ "Exten: %s\r\n"
+ "Context: %s\r\n"
+ "CallerIDname: %s\r\n"
"Channel: %s\r\n"
- "DestinationChannel: %s\r\n"
- "LastApplication: %s\r\n"
- "LastData: %s\r\n"
- "StartTime: %s\r\n"
- "AnswerTime: %s\r\n"
- "EndTime: %s\r\n"
- "Duration: %ld\r\n"
- "BillableSeconds: %ld\r\n"
- "Disposition: %s\r\n"
+ "Application: %s\r\n"
+ "AppData: %s\r\n"
+ "EventTime: %s\r\n"
"AMAFlags: %s\r\n"
- "UniqueID: %s\r\n"
- "UserField: %s\r\n",
- cel->accountcode, cel->src, cel->dst, cel->dcontext, cel->clid, cel->channel,
- cel->dstchannel, cel->lastapp, cel->lastdata, strStartTime, strAnswerTime, strEndTime,
- cel->duration, cel->billsec, ast_cel_disp2str(cel->disposition),
- ast_cel_flags2str(cel->amaflags), cel->uniqueid, cel->userfield);
-
- return 0;
+ "UniqueID: %s\r\n",
+ (eventtype==CEL_USER_DEFINED?userdefname:ast_cel_eventtype2str(eventtype)),
+ chan->accountcode, chan->cid.cid_num, chan->exten, chan->context, chan->cid.cid_name, chan->name,
+ chan->appl, chan->data, strStartTime,
+ ast_cel_flags2str(chan->amaflags), chan->uniqueid);
}
static int unload_module(void)
@@ -152,13 +137,11 @@
static int load_module(void)
{
- int res;
-
/* Configuration file */
if (!loadconfigurationfile())
return AST_MODULE_LOAD_DECLINE;
- event_sub = ast_event_subscribe(AST_EVENT_CEL, manager_log, NULL, AST_EVENT_IE_END);
+ event_sub = ast_event_subscribe(AST_EVENT_CEL, manager_log, NULL, "Manager Event Logging", AST_EVENT_IE_END);
if (!event_sub) {
ast_log(LOG_ERROR, "Unable to register Asterisk Call Manager CEL handling\n");
}
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=62263&r1=62262&r2=62263
==============================================================================
--- team/murf/newcdr/cel/cel_odbc.c (original)
+++ team/murf/newcdr/cel/cel_odbc.c Fri Apr 27 20:57:28 2007
@@ -81,7 +81,7 @@
static SQLHENV ODBC_env = SQL_NULL_HANDLE; /* global ODBC Environment */
static SQLHDBC ODBC_con; /* global ODBC Connection Handle */
static SQLHSTMT ODBC_stmt; /* global ODBC Statement Handle */
-static struct ast_event_sub event_sub = 0;
+static struct ast_event_sub *event_sub = 0;
static void odbc_disconnect(void)
{
@@ -97,27 +97,35 @@
char sqlcmd[2048] = "", timestr[128];
int res = 0;
struct tm tm;
- struct ast_cel *cel = 0;
-
- cel = ast_event_get_ie_raw(event, AST_EVENT_IE_CELPTR);
- cel_set_backend_channel_vars(cel);
+ const struct ast_channel *chan;
+ enum ast_cel_eventtype eventtype;
+ char *userdefname = 0;
+ time_t eventtime = 0;
+
+ chan = ast_event_get_ie_raw(event, AST_EVENT_IE_CHANPTR);
+ eventtype = (enum ast_cel_eventtype)ast_event_get_ie_uint(event, AST_EVENT_IE_CEL_EVENT_TYPE);
+ eventtime = (time_t)ast_event_get_ie_uint(event, AST_EVENT_IE_CEL_EVENT_TIME);
+ if (eventtype == CEL_USER_DEFINED)
+ userdefname = ast_event_get_ie_str(event, AST_EVENT_IE_CEL_USEREVENT_NAME);
+
+ cel_set_backend_channel_vars(chan, eventtype, userdefname, eventtime);
if (usegmtime)
- gmtime_r(&cel->start.tv_sec,&tm);
+ gmtime_r(&eventtime,&tm);
else
- localtime_r(&cel->start.tv_sec,&tm);
+ localtime_r(&eventtime,&tm);
ast_mutex_lock(&odbc_lock);
strftime(timestr, sizeof(timestr), DATE_FORMAT, &tm);
memset(sqlcmd,0,2048);
if (loguniqueid) {
snprintf(sqlcmd,sizeof(sqlcmd),"INSERT INTO %s "
- "(calldate,clid,src,dst,dcontext,channel,dstchannel,lastapp,"
- "lastdata,duration,billsec,disposition,amaflags,accountcode,uniqueid,userfield) "
+ "(eventtime,clid,clidnum,exten,context,channel,app,"
+ "appdata,amaflags,accountcode,uniqueid) "
"VALUES (?,?,?,?,?,?,?,?,?,?,?,?,?,?,?,?)", table);
} else {
snprintf(sqlcmd,sizeof(sqlcmd),"INSERT INTO %s "
- "(calldate,clid,src,dst,dcontext,channel,dstchannel,lastapp,lastdata,"
- "duration,billsec,disposition,amaflags,accountcode) "
+ "(eventtime,clid,clidnum,exten,context,channel,app,appdata,"
+ "amaflags,accountcode) "
"VALUES (?,?,?,?,?,?,?,?,?,?,?,?,?,?)", table);
}
@@ -157,26 +165,18 @@
}
SQLBindParameter(ODBC_stmt, 1, SQL_PARAM_INPUT, SQL_C_CHAR, SQL_CHAR, sizeof(timestr), 0, ×tr, 0, NULL);
- SQLBindParameter(ODBC_stmt, 2, SQL_PARAM_INPUT, SQL_C_CHAR, SQL_CHAR, sizeof(cel->clid), 0, cel->clid, 0, NULL);
- SQLBindParameter(ODBC_stmt, 3, SQL_PARAM_INPUT, SQL_C_CHAR, SQL_CHAR, sizeof(cel->src), 0, cel->src, 0, NULL);
- SQLBindParameter(ODBC_stmt, 4, SQL_PARAM_INPUT, SQL_C_CHAR, SQL_CHAR, sizeof(cel->dst), 0, cel->dst, 0, NULL);
- SQLBindParameter(ODBC_stmt, 5, SQL_PARAM_INPUT, SQL_C_CHAR, SQL_CHAR, sizeof(cel->dcontext), 0, cel->dcontext, 0, NULL);
- SQLBindParameter(ODBC_stmt, 6, SQL_PARAM_INPUT, SQL_C_CHAR, SQL_CHAR, sizeof(cel->channel), 0, cel->channel, 0, NULL);
- SQLBindParameter(ODBC_stmt, 7, SQL_PARAM_INPUT, SQL_C_CHAR, SQL_CHAR, sizeof(cel->dstchannel), 0, cel->dstchannel, 0, NULL);
- SQLBindParameter(ODBC_stmt, 8, SQL_PARAM_INPUT, SQL_C_CHAR, SQL_CHAR, sizeof(cel->lastapp), 0, cel->lastapp, 0, NULL);
- SQLBindParameter(ODBC_stmt, 9, SQL_PARAM_INPUT, SQL_C_CHAR, SQL_CHAR, sizeof(cel->lastdata), 0, cel->lastdata, 0, NULL);
- SQLBindParameter(ODBC_stmt, 10, SQL_PARAM_INPUT, SQL_C_SLONG, SQL_INTEGER, 0, 0, &cel->duration, 0, NULL);
- SQLBindParameter(ODBC_stmt, 11, SQL_PARAM_INPUT, SQL_C_SLONG, SQL_INTEGER, 0, 0, &cel->billsec, 0, NULL);
- if (dispositionstring)
- SQLBindParameter(ODBC_stmt, 12, SQL_PARAM_INPUT, SQL_C_CHAR, SQL_CHAR, strlen(ast_cel_disp2str(cel->disposition)) + 1, 0, ast_cel_disp2str(cel->disposition), 0, NULL);
- else
- SQLBindParameter(ODBC_stmt, 12, SQL_PARAM_INPUT, SQL_C_SLONG, SQL_INTEGER, 0, 0, &cel->disposition, 0, NULL);
- SQLBindParameter(ODBC_stmt, 13, SQL_PARAM_INPUT, SQL_C_SLONG, SQL_INTEGER, 0, 0, &cel->amaflags, 0, NULL);
- SQLBindParameter(ODBC_stmt, 14, SQL_PARAM_INPUT, SQL_C_CHAR, SQL_CHAR, sizeof(cel->accountcode), 0, cel->accountcode, 0, NULL);
+ SQLBindParameter(ODBC_stmt, 2, SQL_PARAM_INPUT, SQL_C_CHAR, SQL_CHAR, sizeof(chan->cid.name), 0, cel->clid, 0, NULL);
+ SQLBindParameter(ODBC_stmt, 3, SQL_PARAM_INPUT, SQL_C_CHAR, SQL_CHAR, sizeof(chan->cid.num), 0, cel->src, 0, NULL);
+ SQLBindParameter(ODBC_stmt, 4, SQL_PARAM_INPUT, SQL_C_CHAR, SQL_CHAR, sizeof(chan->exten), 0, cel->dst, 0, NULL);
+ SQLBindParameter(ODBC_stmt, 5, SQL_PARAM_INPUT, SQL_C_CHAR, SQL_CHAR, sizeof(chan->context), 0, cel->dcontext, 0, NULL);
+ SQLBindParameter(ODBC_stmt, 6, SQL_PARAM_INPUT, SQL_C_CHAR, SQL_CHAR, sizeof(chan->name), 0, cel->channel, 0, NULL);
+ SQLBindParameter(ODBC_stmt, 8, SQL_PARAM_INPUT, SQL_C_CHAR, SQL_CHAR, sizeof(chan->app), 0, cel->lastapp, 0, NULL);
+ SQLBindParameter(ODBC_stmt, 9, SQL_PARAM_INPUT, SQL_C_CHAR, SQL_CHAR, sizeof(chan->data), 0, cel->lastdata, 0, NULL);
+ SQLBindParameter(ODBC_stmt, 13, SQL_PARAM_INPUT, SQL_C_SLONG, SQL_INTEGER, 0, 0, &chan->amaflags, 0, NULL);
+ SQLBindParameter(ODBC_stmt, 14, SQL_PARAM_INPUT, SQL_C_CHAR, SQL_CHAR, sizeof(chan->accountcode), 0, cel->accountcode, 0, NULL);
if (loguniqueid) {
SQLBindParameter(ODBC_stmt, 15, SQL_PARAM_INPUT, SQL_C_CHAR, SQL_CHAR, sizeof(cel->uniqueid), 0, cel->uniqueid, 0, NULL);
- SQLBindParameter(ODBC_stmt, 16, SQL_PARAM_INPUT, SQL_C_CHAR, SQL_CHAR, sizeof(cel->userfield), 0, cel->userfield, 0, NULL);
}
if (connected) {
@@ -372,7 +372,7 @@
ast_verbose( VERBOSE_PREFIX_3 "cel_odbc: Unable to connect to datasource: %s\n", dsn);
}
}
- event_sub = ast_event_subscribe(AST_EVENT_CEL, odbc_log, NULL, AST_EVENT_IE_END);
+ event_sub = ast_event_subscribe(AST_EVENT_CEL, odbc_log, NULL, "CEL ODBC backend", AST_EVENT_IE_END);
if (!event_sub) {
ast_log(LOG_ERROR, "cel_odbc: Unable to register ODBC CEL handling\n");
}
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=62263&r1=62262&r2=62263
==============================================================================
--- team/murf/newcdr/cel/cel_pgsql.c (original)
+++ team/murf/newcdr/cel/cel_pgsql.c Fri Apr 27 20:57:28 2007
@@ -73,20 +73,29 @@
static PGconn *conn = NULL;
static PGresult *result = NULL;
-static struct ast_event_sub event_sub = 0;
+static struct ast_event_sub *event_sub = 0;
static int pgsql_log(const struct ast_event *event, void *userdata)
{
struct tm tm;
char sqlcmd[2048] = "", timestr[128];
char *pgerror;
- struct ast_cel *cel = 0;
+ const struct ast_channel *chan;
+ enum ast_cel_eventtype eventtype;
+ const char *userdefname = 0;
+ time_t eventtime = 0;
- cel = ast_event_get_ie_raw(event, AST_EVENT_IE_CELPTR);
- cel_set_backend_channel_vars(cel);
+ chan = ast_event_get_ie_raw(event, AST_EVENT_IE_CHANPTR);
+ eventtype = (enum ast_cel_eventtype)ast_event_get_ie_uint(event, AST_EVENT_IE_CEL_EVENT_TYPE);
+ eventtime = (time_t)ast_event_get_ie_uint(event, AST_EVENT_IE_CEL_EVENT_TIME);
+ if (eventtype == CEL_USER_DEFINED)
+ userdefname = ast_event_get_ie_str(event, AST_EVENT_IE_CEL_USEREVENT_NAME);
+
+
+ cel_set_backend_channel_vars(chan, eventtype, userdefname, eventtime);
ast_mutex_lock(&pgsql_lock);
- localtime_r(&cel->start.tv_sec,&tm);
+ localtime_r(&eventtime,&tm);
strftime(timestr, sizeof(timestr), DATE_FORMAT, &tm);
if ((!connected) && pghostname && pgdbuser && pgpassword && pgdbname) {
@@ -101,29 +110,25 @@
}
if (connected) {
- char *clid=NULL, *dcontext=NULL, *channel=NULL, *dstchannel=NULL, *lastapp=NULL, *lastdata=NULL;
- char *uniqueid=NULL, *userfield=NULL;
+ char *clid=NULL, *context=NULL, *channel=NULL, *app=NULL, *appdata=NULL;
+ char *uniqueid=NULL;
/* Maximum space needed would be if all characters needed to be escaped, plus a trailing NULL */
- if ((clid = alloca(strlen(cel->clid) * 2 + 1)) != NULL)
- PQescapeString(clid, cel->clid, strlen(cel->clid));
- if ((dcontext = alloca(strlen(cel->dcontext) * 2 + 1)) != NULL)
- PQescapeString(dcontext, cel->dcontext, strlen(cel->dcontext));
- if ((channel = alloca(strlen(cel->channel) * 2 + 1)) != NULL)
- PQescapeString(channel, cel->channel, strlen(cel->channel));
- if ((dstchannel = alloca(strlen(cel->dstchannel) * 2 + 1)) != NULL)
- PQescapeString(dstchannel, cel->dstchannel, strlen(cel->dstchannel));
- if ((lastapp = alloca(strlen(cel->lastapp) * 2 + 1)) != NULL)
- PQescapeString(lastapp, cel->lastapp, strlen(cel->lastapp));
- if ((lastdata = alloca(strlen(cel->lastdata) * 2 + 1)) != NULL)
- PQescapeString(lastdata, cel->lastdata, strlen(cel->lastdata));
- if ((uniqueid = alloca(strlen(cel->uniqueid) * 2 + 1)) != NULL)
- PQescapeString(uniqueid, cel->uniqueid, strlen(cel->uniqueid));
- if ((userfield = alloca(strlen(cel->userfield) * 2 + 1)) != NULL)
- PQescapeString(userfield, cel->userfield, strlen(cel->userfield));
+ if ((clid = alloca(strlen(chan->cid.name) * 2 + 1)) != NULL)
+ PQescapeString(clid, chan->cid.name, strlen(chan->cid.name));
+ if ((context = alloca(strlen(chan->context) * 2 + 1)) != NULL)
+ PQescapeString(context, chan->context, strlen(chan->context));
+ if ((channel = alloca(strlen(chan->name) * 2 + 1)) != NULL)
+ PQescapeString(channel, chan->name, strlen(chan->name));
+ if ((app = alloca(strlen(chan->app) * 2 + 1)) != NULL)
+ PQescapeString(app, chan->app, strlen(chan->app));
+ if ((appdata = alloca(strlen(chan->data) * 2 + 1)) != NULL)
+ PQescapeString(appdata, chan->data, strlen(chan->data));
+ if ((uniqueid = alloca(strlen(chan->uniqueid) * 2 + 1)) != NULL)
+ PQescapeString(uniqueid, chan->uniqueid, strlen(chan->uniqueid));
/* Check for all alloca failures above at once */
- if ((!clid) || (!dcontext) || (!channel) || (!dstchannel) || (!lastapp) || (!lastdata) || (!uniqueid) || (!userfield)) {
+ if ((!clid) || (!context) || (!channel) || (!app) || (!appdata) || (!uniqueid)) {
ast_log(LOG_ERROR, "cel_pgsql: Out of memory error (insert fails)\n");
ast_mutex_unlock(&pgsql_lock);
return -1;
@@ -132,11 +137,11 @@
if (option_debug > 1)
ast_log(LOG_DEBUG, "cel_pgsql: inserting a CEL record.\n");
- snprintf(sqlcmd,sizeof(sqlcmd),"INSERT INTO %s (calldate,clid,src,dst,dcontext,channel,dstchannel,"
- "lastapp,lastdata,duration,billsec,disposition,amaflags,accountcode,uniqueid,userfield) VALUES"
+ snprintf(sqlcmd,sizeof(sqlcmd),"INSERT INTO %s (eventtime,clid,clidnum,exten,context,channel,"
+ "app,appdata,amaflags,accountcode,uniqueid) VALUES"
" ('%s','%s','%s','%s','%s', '%s','%s','%s','%s',%ld,%ld,'%s',%ld,'%s','%s','%s')",
- table,timestr,clid,cel->src, cel->dst, dcontext,channel, dstchannel, lastapp, lastdata,
- cel->duration,cel->billsec,ast_cel_disp2str(cel->disposition),cel->amaflags, cel->accountcode, uniqueid, userfield);
+ table,timestr,clid,chan->cid.num, chan->exten, context,channel, lastapp, lastdata,
+ chan->amaflags, chan->accountcode, uniqueid);
if (option_debug > 2)
ast_log(LOG_DEBUG, "cel_pgsql: SQL command executed: %s\n",sqlcmd);
@@ -290,7 +295,7 @@
connected = 0;
}
- event_sub = ast_event_subscribe(AST_EVENT_CEL, csv_log, NULL, AST_EVENT_IE_END);
+ event_sub = ast_event_subscribe(AST_EVENT_CEL, csv_log, NULL, "CEL PGSQL backend", AST_EVENT_IE_END);
if (!event_sub)
return AST_MODULE_LOAD_DECLINE;
Modified: team/murf/newcdr/cel/cel_radius.c
URL: http://svn.digium.com/view/asterisk/team/murf/newcdr/cel/cel_radius.c?view=diff&rev=62263&r1=62262&r2=62263
==============================================================================
--- team/murf/newcdr/cel/cel_radius.c (original)
+++ team/murf/newcdr/cel/cel_radius.c Fri Apr 27 20:57:28 2007
@@ -94,11 +94,11 @@
static struct ast_flags global_flags = { RADIUS_FLAG_USEGMTIME | RADIUS_FLAG_LOGUNIQUEID | RADIUS_FLAG_LOGUSERFIELD };
static rc_handle *rh = NULL;
-static struct ast_event_sub event_sub = 0;
-
-static int build_radius_record(VALUE_PAIR **send, struct ast_cel *cel)
-{
-int recordtype = PW_STATUS_STOP;
+static struct ast_event_sub *event_sub = 0;
+
+static int build_radius_record(VALUE_PAIR **send, struct ast_channel *chan, enum ast_cel_eventtype eventtype, time_t eventtime, char *userdefname)
+{
+ int recordtype = PW_STATUS_STOP;
struct tm tm;
char timestr[128];
char *tmp;
@@ -107,107 +107,66 @@
return -1;
/* Account code */
- if (!rc_avpair_add(rh, send, PW_AST_ACCT_CODE, &cel->accountcode, strlen(cel->accountcode), VENDOR_CODE))
+ if (!rc_avpair_add(rh, send, PW_AST_ACCT_CODE, &chan->accountcode, strlen(chan->accountcode), VENDOR_CODE))
return -1;
/* Source */
- if (!rc_avpair_add(rh, send, PW_AST_SRC, &cel->src, strlen(cel->src), VENDOR_CODE))
+ if (!rc_avpair_add(rh, send, PW_AST_SRC, &chan->cid.num, strlen(chan->cid.num), VENDOR_CODE))
return -1;
/* Destination */
- if (!rc_avpair_add(rh, send, PW_AST_DST, &cel->dst, strlen(cel->dst), VENDOR_CODE))
+ if (!rc_avpair_add(rh, send, PW_AST_DST, &chan->exten, strlen(chan->exten), VENDOR_CODE))
return -1;
/* Destination context */
- if (!rc_avpair_add(rh, send, PW_AST_DST_CTX, &cel->dcontext, strlen(cel->dcontext), VENDOR_CODE))
+ if (!rc_avpair_add(rh, send, PW_AST_DST_CTX, &chan->context, strlen(chan->context), VENDOR_CODE))
return -1;
/* Caller ID */
- if (!rc_avpair_add(rh, send, PW_AST_CLID, &cel->clid, strlen(cel->clid), VENDOR_CODE))
+ if (!rc_avpair_add(rh, send, PW_AST_CLID, &chan->cid.name, strlen(chan->cid.name), VENDOR_CODE))
return -1;
/* Channel */
- if (!rc_avpair_add(rh, send, PW_AST_CHAN, &cel->channel, strlen(cel->channel), VENDOR_CODE))
- return -1;
-
- /* Destination Channel */
- if (!rc_avpair_add(rh, send, PW_AST_DST_CHAN, &cel->dstchannel, strlen(cel->dstchannel), VENDOR_CODE))
+ if (!rc_avpair_add(rh, send, PW_AST_CHAN, &chan->name, strlen(chan->name), VENDOR_CODE))
return -1;
/* Last Application */
- if (!rc_avpair_add(rh, send, PW_AST_LAST_APP, &cel->lastapp, strlen(cel->lastapp), VENDOR_CODE))
+ if (!rc_avpair_add(rh, send, PW_AST_LAST_APP, &chan->app, strlen(chan->app), VENDOR_CODE))
return -1;
/* Last Data */
- if (!rc_avpair_add(rh, send, PW_AST_LAST_DATA, &cel->lastdata, strlen(cel->lastdata), VENDOR_CODE))
+ if (!rc_avpair_add(rh, send, PW_AST_LAST_DATA, &chan->data, strlen(chan->data), VENDOR_CODE))
return -1;
/* Start Time */
if (ast_test_flag(&global_flags, RADIUS_FLAG_USEGMTIME))
- gmtime_r(&(cel->start.tv_sec), &tm);
+ gmtime_r(&(eventtime), &tm);
else
- localtime_r(&(cel->start.tv_sec), &tm);
+ localtime_r(&(eventtime), &tm);
strftime(timestr, sizeof(timestr), DATE_FORMAT, &tm);
if (!rc_avpair_add(rh, send, PW_AST_START_TIME, timestr, strlen(timestr), VENDOR_CODE))
return -1;
- /* Answer Time */
- if (ast_test_flag(&global_flags, RADIUS_FLAG_USEGMTIME))
- gmtime_r(&(cel->answer.tv_sec), &tm);
- else
- localtime_r(&(cel->answer.tv_sec), &tm);
- strftime(timestr, sizeof(timestr), DATE_FORMAT, &tm);
- if (!rc_avpair_add(rh, send, PW_AST_ANSWER_TIME, timestr, strlen(timestr), VENDOR_CODE))
- return -1;
-
- /* End Time */
- if (ast_test_flag(&global_flags, RADIUS_FLAG_USEGMTIME))
- gmtime_r(&(cel->end.tv_sec), &tm);
- else
- localtime_r(&(cel->end.tv_sec), &tm);
- strftime(timestr, sizeof(timestr), DATE_FORMAT, &tm);
- if (!rc_avpair_add(rh, send, PW_AST_END_TIME, timestr, strlen(timestr), VENDOR_CODE))
- return -1;
-
- /* Duration */
- if (!rc_avpair_add(rh, send, PW_AST_DURATION, &cel->duration, 0, VENDOR_CODE))
- return -1;
-
- /* Billable seconds */
- if (!rc_avpair_add(rh, send, PW_AST_BILL_SEC, &cel->billsec, 0, VENDOR_CODE))
- return -1;
-
- /* Disposition */
- tmp = ast_cel_disp2str(cel->disposition);
- if (!rc_avpair_add(rh, send, PW_AST_DISPOSITION, tmp, strlen(tmp), VENDOR_CODE))
- return -1;
-
/* AMA Flags */
- tmp = ast_cel_flags2str(cel->amaflags);
+ tmp = ast_cel_flags2str(chan->amaflags);
if (!rc_avpair_add(rh, send, PW_AST_AMA_FLAGS, tmp, strlen(tmp), VENDOR_CODE))
return -1;
if (ast_test_flag(&global_flags, RADIUS_FLAG_LOGUNIQUEID)) {
/* Unique ID */
- if (!rc_avpair_add(rh, send, PW_AST_UNIQUE_ID, &cel->uniqueid, strlen(cel->uniqueid), VENDOR_CODE))
- return -1;
- }
-
- if (ast_test_flag(&global_flags, RADIUS_FLAG_LOGUSERFIELD)) {
- /* append the user field */
- if (!rc_avpair_add(rh, send, PW_AST_USER_FIELD, &cel->userfield, strlen(cel->userfield), VENDOR_CODE))
+ if (!rc_avpair_add(rh, send, PW_AST_UNIQUE_ID, &chan->uniqueid, strlen(chan->uniqueid), VENDOR_CODE))
return -1;
}
/* Setting Acct-Session-Id & User-Name attributes for proper generation
of Acct-Unique-Session-Id on server side */
/* Channel */
- if (!rc_avpair_add(rh, send, PW_USER_NAME, &cel->channel, strlen(cel->channel), 0))
+ if (!rc_avpair_add(rh, send, PW_USER_NAME, &chan->channel, strlen(chan->channel), 0))
return -1;
/* Unique ID */
- if (!rc_avpair_add(rh, send, PW_ACCT_SESSION_ID, &cel->uniqueid, strlen(cel->uniqueid), 0))
+ if (!rc_avpair_add(rh, send, PW_ACCT_SESSION_ID, &chan->uniqueid, strlen(chan->uniqueid), 0))
return -1;
return 0;
@@ -217,12 +176,20 @@
{
int result = ERROR_RC;
VALUE_PAIR *send = NULL;
- struct ast_cel *cel = 0;
-
- cel = ast_event_get_ie_raw(event, AST_EVENT_IE_CELPTR);
- cel_set_backend_channel_vars(cel);
-
- if (build_radius_record(&send, cel)) {
+ const struct ast_channel *chan;
+ enum ast_cel_eventtype eventtype;
+ const char *userdefname = 0;
+ time_t eventtime = 0;
+
+ chan = ast_event_get_ie_raw(event, AST_EVENT_IE_CHANPTR);
+ eventtype = (enum ast_cel_eventtype)ast_event_get_ie_uint(event, AST_EVENT_IE_CEL_EVENT_TYPE);
+ eventtime = (time_t)ast_event_get_ie_uint(event, AST_EVENT_IE_CEL_EVENT_TIME);
+ if (eventtype == CEL_USER_DEFINED)
+ userdefname = ast_event_get_ie_str(event, AST_EVENT_IE_CEL_USEREVENT_NAME);
+
+ cel_set_backend_channel_vars(chan, eventtype, userdefname, eventtime);
+
+ if (build_radius_record(&send, chan, eventtype, eventtime, userdefname)) {
if (option_debug)
ast_log(LOG_DEBUG, "Unable to create RADIUS record. CEL not recorded!\n");
return result;
@@ -273,7 +240,7 @@
return -1;
}
- event_sub = ast_event_subscribe(AST_EVENT_CEL, csv_log, NULL, AST_EVENT_IE_END);
+ event_sub = ast_event_subscribe(AST_EVENT_CEL, csv_log, NULL, "CEL Radius Logging", AST_EVENT_IE_END);
if (!event_sub)
return AST_MODULE_LOAD_DECLINE;
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=62263&r1=62262&r2=62263
==============================================================================
--- team/murf/newcdr/cel/cel_sqlite.c (original)
+++ team/murf/newcdr/cel/cel_sqlite.c Fri Apr 27 20:57:28 2007
@@ -65,7 +65,7 @@
static char *name = "sqlite";
static sqlite* db = NULL;
-static struct ast_event_sub event_sub = 0;
+static struct ast_event_sub *event_sub = 0;
AST_MUTEX_DEFINE_STATIC(sqlite_lock);
@@ -73,26 +73,17 @@
static char sql_create_table[] = "CREATE TABLE cel ("
" AcctId INTEGER PRIMARY KEY,"
" clid VARCHAR(80),"
-" src VARCHAR(80),"
-" dst VARCHAR(80),"
-" dcontext VARCHAR(80),"
+" clidnum VARCHAR(80),"
+" exten VARCHAR(80),"
+" context VARCHAR(80),"
" channel VARCHAR(80),"
-" dstchannel VARCHAR(80),"
-" lastapp VARCHAR(80),"
-" lastdata VARCHAR(80),"
-" start CHAR(19),"
-" answer CHAR(19),"
-" end CHAR(19),"
-" duration INTEGER,"
-" billsec INTEGER,"
-" disposition INTEGER,"
+" app VARCHAR(80),"
+" data VARCHAR(80),"
+" eventtime CHAR(19),"
" amaflags INTEGER,"
" accountcode VARCHAR(20)"
#if LOG_UNIQUEID
" ,uniqueid VARCHAR(32)"
-#endif
-#if LOG_USERFIELD
-" ,userfield VARCHAR(255)"
#endif
");";
@@ -102,62 +93,53 @@
char *zErr = 0;
struct tm tm;
time_t t;
- char startstr[80], answerstr[80], endstr[80];
+ char startstr[80];
int count;
- struct ast_cel *cel = ast_event_get_ie_raw(event, AST_EVENT_IE_CELPTR);
-
- cel_set_backend_channel_vars(cel);
+ const struct ast_channel *chan;
+ enum ast_cel_eventtype eventtype;
+ const char *userdefname = 0;
+ time_t eventtime = 0;
+
+ chan = ast_event_get_ie_raw(event, AST_EVENT_IE_CHANPTR);
+ eventtype = (enum ast_cel_eventtype)ast_event_get_ie_uint(event, AST_EVENT_IE_CEL_EVENT_TYPE);
+ eventtime = (time_t)ast_event_get_ie_uint(event, AST_EVENT_IE_CEL_EVENT_TIME);
+ if (eventtype == CEL_USER_DEFINED)
+ userdefname = ast_event_get_ie_str(event, AST_EVENT_IE_CEL_USEREVENT_NAME);
+
+ cel_set_backend_channel_vars(chan, eventtype, userdefname, eventtime);
+
ast_mutex_lock(&sqlite_lock);
- t = cel->start.tv_sec;
+ t = eventtime;
localtime_r(&t, &tm);
strftime(startstr, sizeof(startstr), DATE_FORMAT, &tm);
-
- t = cel->answer.tv_sec;
- localtime_r(&t, &tm);
- strftime(answerstr, sizeof(answerstr), DATE_FORMAT, &tm);
-
- t = cel->end.tv_sec;
- localtime_r(&t, &tm);
- strftime(endstr, sizeof(endstr), DATE_FORMAT, &tm);
for(count=0; count<5; count++) {
res = sqlite_exec_printf(db,
"INSERT INTO cel ("
- "clid,src,dst,dcontext,"
- "channel,dstchannel,lastapp,lastdata, "
- "start,answer,end,"
- "duration,billsec,disposition,amaflags, "
+ "clid,clidnum,exten,context,"
+ "channel,app,appdata, "
+ "eventtime,"
+ "amaflags, "
"accountcode"
# if LOG_UNIQUEID
",uniqueid"
# endif
-# if LOG_USERFIELD
- ",userfield"
-# endif
") VALUES ("
"'%q', '%q', '%q', '%q', "
- "'%q', '%q', '%q', '%q', "
"'%q', '%q', '%q', "
- "%d, %d, %d, %d, "
- "'%q'"
+ "'%q', %d, '%q', "
# if LOG_UNIQUEID
",'%q'"
# endif
-# if LOG_USERFIELD
- ",'%q'"
-# endif
")", NULL, NULL, &zErr,
- cel->clid, cel->src, cel->dst, cel->dcontext,
- cel->channel, cel->dstchannel, cel->lastapp, cel->lastdata,
- startstr, answerstr, endstr,
- cel->duration, cel->billsec, cel->disposition, cel->amaflags,
- cel->accountcode
+ chan->cid.name, chan->cid.num, chan->exten, chan->context,
+ chan->name, chan->app, chan->data,
+ startstr,
+ chan->amaflags,
+ chan->accountcode
# if LOG_UNIQUEID
- ,cel->uniqueid
-# endif
-# if LOG_USERFIELD
- ,cel->userfield
+ ,chan->uniqueid
# endif
);
if (res != SQLITE_BUSY && res != SQLITE_LOCKED)
@@ -215,7 +197,7 @@
/* TODO: here we should probably create an index */
}
- event_sub = ast_event_subscribe(AST_EVENT_CEL, sqlite_log, NULL, AST_EVENT_IE_END);
+ event_sub = ast_event_subscribe(AST_EVENT_CEL, sqlite_log, NULL, "CEL sqlite logging backend", AST_EVENT_IE_END);
if (!event_sub) {
ast_log(LOG_ERROR, "Unable to register SQLite CEL handling\n");
return AST_MODULE_LOAD_DECLINE;
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=62263&r1=62262&r2=62263
==============================================================================
--- team/murf/newcdr/cel/cel_sqlite3_custom.c (original)
+++ team/murf/newcdr/cel/cel_sqlite3_custom.c Fri Apr 27 20:57:28 2007
@@ -72,7 +72,7 @@
static char table[80];
static char columns[1024];
static char values[1024];
-static struct ast_event_sub event_sub = 0;
+static struct ast_event_sub *event_sub = 0;
static int load_config(int reload)
{
@@ -158,14 +158,23 @@
char *sql_cmd;
struct ast_channel dummy = { 0, };
int count;
- struct ast_cel *cel = ast_event_get_ie_raw(event, AST_EVENT_IE_CELPTR);
+ struct ast_channel *chan;
+ enum ast_cel_eventtype eventtype;
+ char *userdefname = 0;
+ time_t eventtime = 0;
+
+ chan = ast_event_get_ie_raw(event, AST_EVENT_IE_CHANPTR);
+ eventtype = (enum ast_cel_eventtype)ast_event_get_ie_uint(event, AST_EVENT_IE_CEL_EVENT_TYPE);
+ eventtime = (time_t)ast_event_get_ie_uint(event, AST_EVENT_IE_CEL_EVENT_TIME);
+ if (eventtype == CEL_USER_DEFINED)
+ userdefname = ast_event_get_ie_str(event, AST_EVENT_IE_CEL_USEREVENT_NAME);
+
+ cel_set_backend_channel_vars(chan, eventtype, userdefname, eventtime);
{ /* Make it obvious that only sql_cmd should be used outside of this block */
char *sql_tmp_cmd;
char sql_insert_cmd[2048] = "";
- cel_set_backend_channel_vars(cel);
sql_tmp_cmd = sqlite3_mprintf("INSERT INTO %q (%q) VALUES (%q)", table, columns, values);
- dummy.cel = cel;
pbx_substitute_variables_helper(&dummy, sql_tmp_cmd, sql_insert_cmd, sizeof(sql_insert_cmd) - 1);
sqlite3_free(sql_tmp_cmd);
sql_cmd = alloca(strlen(sql_insert_cmd) * 2 + 1);
@@ -211,7 +220,7 @@
char *sql_cmd;
if (!load_config(0)) {
- event_sub = ast_event_subscribe(AST_EVENT_CEL, sqlite3_log, NULL, AST_EVENT_IE_END);
+ event_sub = ast_event_subscribe(AST_EVENT_CEL, sqlite3_log, NULL, "CEL sqlist3_custom backend", AST_EVENT_IE_END);
if (!event_sub) {
ast_log(LOG_ERROR, "%s: Unable to register custom SQLite3 CEL handling\n", name);
return AST_MODULE_LOAD_DECLINE;
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=62263&r1=62262&r2=62263
==============================================================================
--- team/murf/newcdr/cel/cel_tds.c (original)
+++ team/murf/newcdr/cel/cel_tds.c Fri Apr 27 20:57:28 2007
@@ -33,20 +33,14 @@
CREATE TABLE [dbo].[cel] (
[accountcode] [varchar] (20) NULL ,
- [src] [varchar] (80) NULL ,
- [dst] [varchar] (80) NULL ,
- [dcontext] [varchar] (80) NULL ,
+ [clidnum] [varchar] (80) NULL ,
+ [exten] [varchar] (80) NULL ,
+ [context] [varchar] (80) NULL ,
[clid] [varchar] (80) NULL ,
[channel] [varchar] (80) NULL ,
- [dstchannel] [varchar] (80) NULL ,
- [lastapp] [varchar] (80) NULL ,
- [lastdata] [varchar] (80) NULL ,
- [start] [datetime] NULL ,
- [answer] [datetime] NULL ,
[... 402 lines stripped ...]
More information about the asterisk-commits
mailing list