[asterisk-commits] murf: branch murf/newcdr r63564 - in
/team/murf/newcdr: cdr/ cel/ channels/ c...
asterisk-commits at lists.digium.com
asterisk-commits at lists.digium.com
Wed May 9 07:26:16 MST 2007
Author: murf
Date: Wed May 9 09:26:15 2007
New Revision: 63564
URL: http://svn.digium.com/view/asterisk?view=rev&rev=63564
Log:
A sane moment to commit changes. I've refactored the backends again, unified the field names for getvar's sake. Got rid of passing channel ptr thru the event mech, which was pretty stupid. Passing all the involved fields is more expensive, but there's no choice. fixed sqlite to not load if no db file is there. Config file entries for apps and event filtering are operational, the event stuff is operational, events so far operational are CHAN_{START,END}, APP_{START,END}, ANSWER, HANGUP. I'm thinking of bringing back the USERFIELD, as channel vars are not practical in CEL.
Modified:
team/murf/newcdr/cdr/cdr_radius.c
team/murf/newcdr/cdr/cdr_sqlite.c
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/channels/chan_local.c
team/murf/newcdr/configs/cel.conf.sample
team/murf/newcdr/configs/cel_custom.conf.sample
team/murf/newcdr/configs/cel_sqlite3_custom.conf.sample
team/murf/newcdr/funcs/func_cel.c
team/murf/newcdr/include/asterisk/cel.h
team/murf/newcdr/include/asterisk/event_defs.h
team/murf/newcdr/main/asterisk.c
team/murf/newcdr/main/cel.c
team/murf/newcdr/main/event.c
team/murf/newcdr/main/pbx.c
Modified: team/murf/newcdr/cdr/cdr_radius.c
URL: http://svn.digium.com/view/asterisk/team/murf/newcdr/cdr/cdr_radius.c?view=diff&rev=63564&r1=63563&r2=63564
==============================================================================
--- team/murf/newcdr/cdr/cdr_radius.c (original)
+++ team/murf/newcdr/cdr/cdr_radius.c Wed May 9 09:26:15 2007
@@ -205,9 +205,11 @@
if (!rc_avpair_add(rh, send, PW_USER_NAME, &cdr->channel, strlen(cdr->channel), 0))
return -1;
+#ifdef WHY_CANT_SESSION_ID_BE_FOUND
/* Unique ID */
if (!rc_avpair_add(rh, send, PW_ACCT_SESSION_ID, &cdr->uniqueid, strlen(cdr->uniqueid), 0))
return -1;
+#endif
return 0;
}
Modified: team/murf/newcdr/cdr/cdr_sqlite.c
URL: http://svn.digium.com/view/asterisk/team/murf/newcdr/cdr/cdr_sqlite.c?view=diff&rev=63564&r1=63563&r2=63564
==============================================================================
--- team/murf/newcdr/cdr/cdr_sqlite.c (original)
+++ team/murf/newcdr/cdr/cdr_sqlite.c Wed May 9 09:26:15 2007
@@ -187,11 +187,17 @@
/* is the database there? */
snprintf(fn, sizeof(fn), "%s/cdr.db", ast_config_AST_LOG_DIR);
+
+ if (access(fn, W_OK) != 0) {
+ ast_log(LOG_ERROR, "cdr_sqlite: Unable to create table 'cdr': %s\n", fn);
+ return AST_MODULE_LOAD_DECLINE;
+ }
+
db = sqlite_open(fn, AST_FILE_MODE, &zErr);
if (!db) {
ast_log(LOG_ERROR, "cdr_sqlite: %s\n", zErr);
free(zErr);
- return -1;
+ return AST_MODULE_LOAD_DECLINE;
}
/* is the table there? */
@@ -210,14 +216,14 @@
res = ast_cdr_register(name, ast_module_info->description, sqlite_log);
if (res) {
ast_log(LOG_ERROR, "Unable to register SQLite CDR handling\n");
- return -1;
- }
- return 0;
+ return AST_MODULE_LOAD_DECLINE;
+ }
+ return AST_MODULE_LOAD_SUCCESS;
err:
if (db)
sqlite_close(db);
- return -1;
+ return AST_MODULE_LOAD_DECLINE;
}
AST_MODULE_INFO_STANDARD(ASTERISK_GPL_KEY, "SQLite CDR Backend");
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=63564&r1=63563&r2=63564
==============================================================================
--- team/murf/newcdr/cel/cel_csv.c (original)
+++ team/murf/newcdr/cel/cel_csv.c Wed May 9 09:26:15 2007
@@ -140,7 +140,7 @@
return 1;
}
-static int append_string(char *buf, char *s, size_t bufsize)
+static int append_string(char *buf, const char *s, size_t bufsize)
{
int pos = strlen(buf);
int spos = 0;
@@ -198,7 +198,12 @@
return append_string(buf, tmp, bufsize);
}
-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)
+static int build_csv_record(char *buf, size_t bufsize, enum ast_cel_eventtype eventtype,
+ time_t eventtime, const char *userdefname, 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)
{
buf[0] = '\0';
@@ -210,26 +215,26 @@
else
append_string(buf, ast_cel_eventtype2str(eventtype), bufsize);
/* Account code */
- append_string(buf, (char*)chan->accountcode, bufsize);
+ append_string(buf, accountcode, bufsize);
/* CID number */
- append_string(buf, (char*)chan->cid.cid_num, bufsize);
+ append_string(buf, cid_num, bufsize);
/* Exten */
- append_string(buf, (char*)chan->exten, bufsize);
+ append_string(buf, exten, bufsize);
/* Context */
- append_string(buf, (char*)chan->context, bufsize);
+ append_string(buf, context, bufsize);
/* Caller*ID */
- append_string(buf, chan->cid.cid_name, bufsize);
+ append_string(buf, cid_name, bufsize);
/* Channel Name */
- append_string(buf, (char*)chan->name, bufsize);
+ append_string(buf, channame, bufsize);
/* Application */
- append_string(buf, (char*)chan->appl, bufsize);
+ append_string(buf, appname, bufsize);
/* App Data/Args, whatever */
- append_string(buf, (char*)chan->data, bufsize);
+ append_string(buf, appdata, bufsize);
/* AMA Flags */
- append_string(buf, ast_cel_flags2str(chan->amaflags), bufsize);
+ append_string(buf, ast_cel_flags2str(amaflag), bufsize);
/* Unique ID */
if (loguniqueid)
- append_string(buf, (char*)chan->uniqueid, bufsize);
+ append_string(buf, uniqueid, bufsize);
/* If we hit the end of our buffer, log an error */
if (strlen(buf) < bufsize - 5) {
/* Trim off trailing comma */
@@ -264,23 +269,35 @@
/* Make sure we have a big enough buf */
char buf[1024];
char csvmaster[PATH_MAX];
- struct ast_channel *chan;
enum ast_cel_eventtype eventtype;
const char *userdefname = 0;
time_t eventtime = 0;
-
- chan = (struct ast_channel *)ast_event_get_ie_raw(event, AST_EVENT_IE_CHANPTR);
+ const char *cid_ani, *cid_rdnis, *cid_name, *cid_num, *cid_dnid;
+ const char *exten, *context, *channame, *appname, *appdata, *accountcode, *uniqueid;
+ unsigned int amaflag;
+
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);
+ cid_name = ast_event_get_ie_str(event, AST_EVENT_IE_CEL_CIDNAME);
+ cid_num = ast_event_get_ie_str(event, AST_EVENT_IE_CEL_CIDNUM);
+ cid_ani = ast_event_get_ie_str(event, AST_EVENT_IE_CEL_CIDANI);
+ cid_rdnis = ast_event_get_ie_str(event, AST_EVENT_IE_CEL_CIDRDNIS);
+ cid_dnid = ast_event_get_ie_str(event, AST_EVENT_IE_CEL_CIDDNID);
+ exten = ast_event_get_ie_str(event, AST_EVENT_IE_CEL_EXTEN);
+ context = ast_event_get_ie_str(event, AST_EVENT_IE_CEL_CONTEXT);
+ channame = ast_event_get_ie_str(event, AST_EVENT_IE_CEL_CHANNAME);
+ appname = ast_event_get_ie_str(event, AST_EVENT_IE_CEL_APPNAME);
+ appdata = ast_event_get_ie_str(event, AST_EVENT_IE_CEL_APPDATA);
+ 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);
+
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), chan, eventtype, eventtime,userdefname)) {
+ 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)) {
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
@@ -296,9 +313,9 @@
fclose(mf);
mf = NULL;
}
- 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));
+ if (!ast_strlen_zero(accountcode)) {
+ if (writefile(buf, (char*)accountcode))
+ ast_log(LOG_WARNING, "Unable to write CSV record to account file '%s' : %s\n", accountcode, strerror(errno));
}
}
return;
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=63564&r1=63563&r2=63564
==============================================================================
--- team/murf/newcdr/cel/cel_custom.c (original)
+++ team/murf/newcdr/cel/cel_custom.c Wed May 9 09:26:15 2007
@@ -107,26 +107,70 @@
{
/* Make sure we have a big enough buf */
char buf[2048];
- struct ast_channel *chan;
+ struct varshead *headp;
enum ast_cel_eventtype eventtype;
const char *userdefname = 0;
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;
+ unsigned int amaflag;
+ struct ast_var_t *vardata;
+
+ ast_string_field_init(&tchan, 128);
+ headp = &tchan.varshead;
+ AST_LIST_HEAD_INIT_NOLOCK(headp);
/* Abort if no master file is specified */
if (ast_strlen_zero(master))
return;
- chan = (struct ast_channel *)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);
+ cid_name = ast_event_get_ie_str(event, AST_EVENT_IE_CEL_CIDNAME);
+ cid_num = ast_event_get_ie_str(event, AST_EVENT_IE_CEL_CIDNUM);
+ cid_ani = ast_event_get_ie_str(event, AST_EVENT_IE_CEL_CIDANI);
+ cid_rdnis = ast_event_get_ie_str(event, AST_EVENT_IE_CEL_CIDRDNIS);
+ cid_dnid = ast_event_get_ie_str(event, AST_EVENT_IE_CEL_CIDDNID);
+ exten = ast_event_get_ie_str(event, AST_EVENT_IE_CEL_EXTEN);
+ context = ast_event_get_ie_str(event, AST_EVENT_IE_CEL_CONTEXT);
+ channame = ast_event_get_ie_str(event, AST_EVENT_IE_CEL_CHANNAME);
+ appname = ast_event_get_ie_str(event, AST_EVENT_IE_CEL_APPNAME);
+ appdata = ast_event_get_ie_str(event, AST_EVENT_IE_CEL_APPDATA);
+ 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);
+
+ 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);
+
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((struct ast_channel*)chan, format, buf, sizeof(buf) - 1);
-
+ pbx_substitute_variables_helper(&tchan, format, buf, sizeof(buf) - 1);
+
+ /* get rid of the headp list, it's function is done */
+ while ((vardata = AST_LIST_REMOVE_HEAD(headp, entries)))
+ ast_var_delete(vardata);
+ ast_string_field_free_all(&tchan);
+ if (tchan.cid.cid_name)
+ free(tchan.cid.cid_name);
+ if (tchan.cid.cid_num)
+ free(tchan.cid.cid_num);
+ if (tchan.cid.cid_ani)
+ free(tchan.cid.cid_ani);
+ if (tchan.cid.cid_rdnis)
+ free(tchan.cid.cid_rdnis);
+ if (tchan.cid.cid_dnid)
+ free(tchan.cid.cid_dnid);
+ if (tchan.appl)
+ free((char*)tchan.appl);
+ if (tchan.data)
+ free((char*)tchan.data);
+
/* because of the absolutely unconditional need for the
highest reliability possible in writing billing records,
we open write and close the log file each time */
@@ -157,7 +201,7 @@
{
if (!load_config(0)) {
- event_sub = ast_event_subscribe(AST_EVENT_CEL, custom_log, NULL, "Custom CSV logging", AST_EVENT_IE_END);
+ event_sub = ast_event_subscribe(AST_EVENT_CEL, custom_log, "Custom CSV logging", NULL, 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=63564&r1=63563&r2=63564
==============================================================================
--- team/murf/newcdr/cel/cel_manager.c (original)
+++ team/murf/newcdr/cel/cel_manager.c Wed May 9 09:26:15 2007
@@ -90,20 +90,39 @@
time_t t;
struct tm timeresult;
char strStartTime[80] = "";
- struct ast_channel *chan;
enum ast_cel_eventtype eventtype;
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;
+ unsigned int amaflag;
+
if (!enablecel)
return;
- chan = (struct ast_channel *)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);
+
+ 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);
+ cid_name = ast_event_get_ie_str(event, AST_EVENT_IE_CEL_CIDNAME);
+ cid_num = ast_event_get_ie_str(event, AST_EVENT_IE_CEL_CIDNUM);
+ cid_ani = ast_event_get_ie_str(event, AST_EVENT_IE_CEL_CIDANI);
+ cid_rdnis = ast_event_get_ie_str(event, AST_EVENT_IE_CEL_CIDRDNIS);
+ cid_dnid = ast_event_get_ie_str(event, AST_EVENT_IE_CEL_CIDDNID);
+ exten = ast_event_get_ie_str(event, AST_EVENT_IE_CEL_EXTEN);
+ context = ast_event_get_ie_str(event, AST_EVENT_IE_CEL_CONTEXT);
+ channame = ast_event_get_ie_str(event, AST_EVENT_IE_CEL_CHANNAME);
+ appname = ast_event_get_ie_str(event, AST_EVENT_IE_CEL_APPNAME);
+ appdata = ast_event_get_ie_str(event, AST_EVENT_IE_CEL_APPDATA);
+ 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);
+
t = eventtime;
localtime_r(&t, &timeresult);
strftime(strStartTime, sizeof(strStartTime), DATE_FORMAT, &timeresult);
@@ -112,9 +131,12 @@
"EventName: %s\r\n"
"AccountCode: %s\r\n"
"CallerIDnum: %s\r\n"
+ "CallerIDname: %s\r\n"
+ "CallerIDani: %s\r\n"
+ "CallerIDrdnis: %s\r\n"
+ "CallerIDdnid: %s\r\n"
"Exten: %s\r\n"
"Context: %s\r\n"
- "CallerIDname: %s\r\n"
"Channel: %s\r\n"
"Application: %s\r\n"
"AppData: %s\r\n"
@@ -122,9 +144,10 @@
"AMAFlags: %s\r\n"
"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);
+ accountcode, cid_num, cid_name, cid_ani, cid_rdnis, cid_dnid,
+ exten, context, channame,
+ appname, appdata, strStartTime,
+ ast_cel_flags2str(amaflag), uniqueid);
}
static int unload_module(void)
@@ -141,7 +164,7 @@
if (!loadconfigurationfile())
return AST_MODULE_LOAD_DECLINE;
- event_sub = ast_event_subscribe(AST_EVENT_CEL, manager_log, NULL, "Manager Event Logging", AST_EVENT_IE_END);
+ event_sub = ast_event_subscribe(AST_EVENT_CEL, manager_log, "Manager Event Logging", NULL, 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=63564&r1=63563&r2=63564
==============================================================================
--- team/murf/newcdr/cel/cel_odbc.c (original)
+++ team/murf/newcdr/cel/cel_odbc.c Wed May 9 09:26:15 2007
@@ -96,18 +96,34 @@
char sqlcmd[2048] = "", timestr[128];
int res = 0;
struct tm tm;
- 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);
+ const char *cid_ani, *cid_rdnis, *cid_name, *cid_num, *cid_dnid;
+ const char *exten, *context, *channame, *appname, *appdata, *accountcode, *uniqueid;
+ unsigned int amaflag;
+
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((struct ast_channel *)chan, eventtype, userdefname, eventtime);
+ else
+ userdefname = ast_cel_eventtype2str(eventtype);
+
+ cid_name = ast_event_get_ie_str(event, AST_EVENT_IE_CEL_CIDNAME);
+ cid_num = ast_event_get_ie_str(event, AST_EVENT_IE_CEL_CIDNUM);
+ cid_ani = ast_event_get_ie_str(event, AST_EVENT_IE_CEL_CIDANI);
+ cid_rdnis = ast_event_get_ie_str(event, AST_EVENT_IE_CEL_CIDRDNIS);
+ cid_dnid = ast_event_get_ie_str(event, AST_EVENT_IE_CEL_CIDDNID);
+ exten = ast_event_get_ie_str(event, AST_EVENT_IE_CEL_EXTEN);
+ context = ast_event_get_ie_str(event, AST_EVENT_IE_CEL_CONTEXT);
+ channame = ast_event_get_ie_str(event, AST_EVENT_IE_CEL_CHANNAME);
+ appname = ast_event_get_ie_str(event, AST_EVENT_IE_CEL_APPNAME);
+ appdata = ast_event_get_ie_str(event, AST_EVENT_IE_CEL_APPDATA);
+ 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);
+
if (usegmtime)
gmtime_r(&eventtime,&tm);
else
@@ -118,12 +134,12 @@
memset(sqlcmd,0,2048);
if (loguniqueid) {
snprintf(sqlcmd,sizeof(sqlcmd),"INSERT INTO %s "
- "(eventtime,clid,clidnum,exten,context,channel,app,"
+ "(eventtime,eventtype,cidname,cidnum,cidani,cidrdnis,ciddnid,exten,context,channel,app,"
"appdata,amaflags,accountcode,uniqueid) "
- "VALUES (?,?,?,?,?,?,?,?,?,?,?,?,?,?,?,?)", table);
+ "VALUES (?,?,?,?,?,?,?,?,?,?,?,?,?,?,?)", table);
} else {
snprintf(sqlcmd,sizeof(sqlcmd),"INSERT INTO %s "
- "(eventtime,clid,clidnum,exten,context,channel,app,appdata,"
+ "(eventtime,eventtype,cidname,cidnum,cidani,cidrdnis,ciddnid,exten,context,channel,app,appdata,"
"amaflags,accountcode) "
"VALUES (?,?,?,?,?,?,?,?,?,?,?,?,?,?)", table);
}
@@ -164,18 +180,22 @@
}
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(chan->cid.cid_name), 0, chan->cid.cid_name, 0, NULL);
- SQLBindParameter(ODBC_stmt, 3, SQL_PARAM_INPUT, SQL_C_CHAR, SQL_CHAR, sizeof(chan->cid.cid_num), 0, chan->cid.cid_num, 0, NULL);
- SQLBindParameter(ODBC_stmt, 4, SQL_PARAM_INPUT, SQL_C_CHAR, SQL_CHAR, sizeof(chan->exten), 0, (char*)chan->exten, 0, NULL);
- SQLBindParameter(ODBC_stmt, 5, SQL_PARAM_INPUT, SQL_C_CHAR, SQL_CHAR, sizeof(chan->context), 0, (char*)chan->context, 0, NULL);
- SQLBindParameter(ODBC_stmt, 6, SQL_PARAM_INPUT, SQL_C_CHAR, SQL_CHAR, sizeof(chan->name), 0, (char*)chan->name, 0, NULL);
- SQLBindParameter(ODBC_stmt, 8, SQL_PARAM_INPUT, SQL_C_CHAR, SQL_CHAR, sizeof(chan->appl), 0, (char*)chan->appl, 0, NULL);
- SQLBindParameter(ODBC_stmt, 9, SQL_PARAM_INPUT, SQL_C_CHAR, SQL_CHAR, sizeof(chan->data), 0, (char*)chan->data, 0, NULL);
- SQLBindParameter(ODBC_stmt, 13, SQL_PARAM_INPUT, SQL_C_SLONG, SQL_INTEGER, 0, 0, (int*)&chan->amaflags, 0, NULL);
- SQLBindParameter(ODBC_stmt, 14, SQL_PARAM_INPUT, SQL_C_CHAR, SQL_CHAR, sizeof(chan->accountcode), 0, (char*)chan->accountcode, 0, NULL);
+ SQLBindParameter(ODBC_stmt, 2, SQL_PARAM_INPUT, SQL_C_CHAR, SQL_CHAR, sizeof(userdefname), 0, (char*)userdefname, 0, NULL);
+ SQLBindParameter(ODBC_stmt, 3, SQL_PARAM_INPUT, SQL_C_CHAR, SQL_CHAR, sizeof(cid_name), 0, (char*)cid_name, 0, NULL);
+ SQLBindParameter(ODBC_stmt, 4, SQL_PARAM_INPUT, SQL_C_CHAR, SQL_CHAR, sizeof(cid_num), 0, (char*)cid_num, 0, NULL);
+ SQLBindParameter(ODBC_stmt, 5, SQL_PARAM_INPUT, SQL_C_CHAR, SQL_CHAR, sizeof(cid_ani), 0, (char*)cid_ani, 0, NULL);
+ SQLBindParameter(ODBC_stmt, 6, SQL_PARAM_INPUT, SQL_C_CHAR, SQL_CHAR, sizeof(cid_rdnis), 0, (char*)cid_rdnis, 0, NULL);
+ SQLBindParameter(ODBC_stmt, 7, SQL_PARAM_INPUT, SQL_C_CHAR, SQL_CHAR, sizeof(cid_dnid), 0, (char*)cid_dnid, 0, NULL);
+ SQLBindParameter(ODBC_stmt, 8, SQL_PARAM_INPUT, SQL_C_CHAR, SQL_CHAR, sizeof(exten), 0, (char*)exten, 0, NULL);
+ SQLBindParameter(ODBC_stmt, 9, SQL_PARAM_INPUT, SQL_C_CHAR, SQL_CHAR, sizeof(context), 0, (char*)context, 0, NULL);
+ SQLBindParameter(ODBC_stmt, 10, SQL_PARAM_INPUT, SQL_C_CHAR, SQL_CHAR, sizeof(channame), 0, (char*)channame, 0, NULL);
+ SQLBindParameter(ODBC_stmt, 11, SQL_PARAM_INPUT, SQL_C_CHAR, SQL_CHAR, sizeof(appname), 0, (char*)appname, 0, NULL);
+ 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);
if (loguniqueid) {
- SQLBindParameter(ODBC_stmt, 15, SQL_PARAM_INPUT, SQL_C_CHAR, SQL_CHAR, sizeof(chan->uniqueid), 0, (char*)chan->uniqueid, 0, NULL);
+ SQLBindParameter(ODBC_stmt, 15, SQL_PARAM_INPUT, SQL_C_CHAR, SQL_CHAR, sizeof(uniqueid), 0, (char*)uniqueid, 0, NULL);
}
if (connected) {
@@ -371,7 +391,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, "CEL ODBC backend", AST_EVENT_IE_END);
+ event_sub = ast_event_subscribe(AST_EVENT_CEL, odbc_log, "CEL ODBC backend", NULL, 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=63564&r1=63563&r2=63564
==============================================================================
--- team/murf/newcdr/cel/cel_pgsql.c (original)
+++ team/murf/newcdr/cel/cel_pgsql.c Wed May 9 09:26:15 2007
@@ -79,19 +79,36 @@
struct tm tm;
char sqlcmd[2048] = "", timestr[128];
char *pgerror;
- 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);
+ 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;
+ unsigned int amaflag;
+
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((struct ast_channel *)chan, eventtype, userdefname, eventtime);
+ cid_name = ast_event_get_ie_str(event, AST_EVENT_IE_CEL_CIDNAME);
+ cid_num = ast_event_get_ie_str(event, AST_EVENT_IE_CEL_CIDNUM);
+ cid_ani = ast_event_get_ie_str(event, AST_EVENT_IE_CEL_CIDANI);
+ cid_rdnis = ast_event_get_ie_str(event, AST_EVENT_IE_CEL_CIDRDNIS);
+ cid_dnid = ast_event_get_ie_str(event, AST_EVENT_IE_CEL_CIDDNID);
+ exten = ast_event_get_ie_str(event, AST_EVENT_IE_CEL_EXTEN);
+ context = ast_event_get_ie_str(event, AST_EVENT_IE_CEL_CONTEXT);
+ channame = ast_event_get_ie_str(event, AST_EVENT_IE_CEL_CHANNAME);
+ appname = ast_event_get_ie_str(event, AST_EVENT_IE_CEL_APPNAME);
+ appdata = ast_event_get_ie_str(event, AST_EVENT_IE_CEL_APPDATA);
+ 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);
+
+ 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);
+
ast_mutex_lock(&pgsql_lock);
localtime_r(&eventtime,&tm);
@@ -109,25 +126,36 @@
}
if (connected) {
- char *clid=NULL, *context=NULL, *channel=NULL, *app=NULL, *appdata=NULL;
- char *uniqueid=NULL;
+ 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;
/* Maximum space needed would be if all characters needed to be escaped, plus a trailing NULL */
- if ((clid = alloca(strlen(chan->cid.cid_name) * 2 + 1)) != NULL)
- PQescapeString(clid, chan->cid.cid_name, strlen(chan->cid.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->appl) * 2 + 1)) != NULL)
- PQescapeString(app, chan->appl, strlen(chan->appl));
- 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));
+ if ((cidname_esc = alloca(strlen(cid_name) * 2 + 1)) != NULL)
+ PQescapeString(cidname_esc, cid_name, strlen(cid_name));
+ if ((cidnum_esc = alloca(strlen(cid_num) * 2 + 1)) != NULL)
+ PQescapeString(cidnum_esc, cid_num, strlen(cid_num));
+ if ((cidani_esc = alloca(strlen(cid_ani) * 2 + 1)) != NULL)
+ PQescapeString(cidani_esc, cid_ani, strlen(cid_ani));
+ if ((cidrdnis_esc = alloca(strlen(cid_rdnis) * 2 + 1)) != NULL)
+ PQescapeString(cidrdnis_esc, cid_rdnis, strlen(cid_rdnis));
+ if ((ciddnid_esc = alloca(strlen(cid_dnid) * 2 + 1)) != NULL)
+ PQescapeString(ciddnid_esc, cid_dnid, strlen(cid_dnid));
+ if ((context_esc = alloca(strlen(context) * 2 + 1)) != NULL)
+ PQescapeString(context_esc, context, strlen(context));
+ if ((channel_esc = alloca(strlen(channame) * 2 + 1)) != NULL)
+ PQescapeString(channel_esc, channame, strlen(channame));
+ if ((app_esc = alloca(strlen(appname) * 2 + 1)) != NULL)
+ PQescapeString(app_esc, appname, strlen(appname));
+ if ((appdata_esc = alloca(strlen(appdata) * 2 + 1)) != NULL)
+ PQescapeString(appdata_esc, appdata, strlen(appdata));
+ if ((uniqueid_esc = alloca(strlen(uniqueid) * 2 + 1)) != NULL)
+ PQescapeString(uniqueid_esc, uniqueid, strlen(uniqueid));
+ if ((accountcode_esc = alloca(strlen(accountcode) * 2 + 1)) != NULL)
+ PQescapeString(accountcode_esc, accountcode, strlen(accountcode));
/* Check for all alloca failures above at once */
- if ((!clid) || (!context) || (!channel) || (!app) || (!appdata) || (!uniqueid)) {
+ if ((!cidname_esc) || (!context_esc) || (!channel_esc) || (!app_esc) || (!appdata_esc) || (!uniqueid_esc)
+ || (!ciddnid_esc) || (!cidrdnis_esc) || (!cidani_esc) || (!cidnum_esc)) {
ast_log(LOG_ERROR, "cel_pgsql: Out of memory error (insert fails)\n");
ast_mutex_unlock(&pgsql_lock);
return;
@@ -136,11 +164,12 @@
if (option_debug > 1)
ast_log(LOG_DEBUG, "cel_pgsql: inserting a CEL record.\n");
- snprintf(sqlcmd,sizeof(sqlcmd),"INSERT INTO %s (eventtime,clid,clidnum,exten,context,channel,"
+ 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',%d,'%s','%s')",
- table,timestr,clid,chan->cid.cid_num, chan->exten, context,channel, app, appdata,
- chan->amaflags, chan->accountcode, uniqueid);
+ " ('%s','%s','%s','%s','%s','%s','%s','%s','%s','%s','%s','%d,'%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);
if (option_debug > 2)
ast_log(LOG_DEBUG, "cel_pgsql: SQL command executed: %s\n",sqlcmd);
@@ -294,7 +323,7 @@
connected = 0;
}
- event_sub = ast_event_subscribe(AST_EVENT_CEL, pgsql_log, NULL, "CEL PGSQL backend", AST_EVENT_IE_END);
+ event_sub = ast_event_subscribe(AST_EVENT_CEL, pgsql_log, "CEL PGSQL backend", NULL, 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=63564&r1=63563&r2=63564
==============================================================================
--- team/murf/newcdr/cel/cel_radius.c (original)
+++ team/murf/newcdr/cel/cel_radius.c Wed May 9 09:26:15 2007
@@ -57,23 +57,20 @@
enum {
PW_AST_ACCT_CODE = 101,
- PW_AST_SRC = 102,
- PW_AST_DST = 103,
- PW_AST_DST_CTX = 104,
- PW_AST_CLID = 105,
- PW_AST_CHAN = 106,
- PW_AST_DST_CHAN = 107,
- PW_AST_LAST_APP = 108,
- PW_AST_LAST_DATA = 109,
- PW_AST_START_TIME = 110,
- PW_AST_ANSWER_TIME = 111,
- PW_AST_END_TIME = 112,
- PW_AST_DURATION = 113,
- PW_AST_BILL_SEC = 114,
- PW_AST_DISPOSITION = 115,
- PW_AST_AMA_FLAGS = 116,
- PW_AST_UNIQUE_ID = 117,
- PW_AST_USER_FIELD = 118
+ PW_AST_CIDNUM = 102,
+ PW_AST_CIDNAME = 103,
+ PW_AST_CIDANI = 104,
+ PW_AST_CIDRDNIS = 105,
+ PW_AST_CIDDNID = 106,
+ PW_AST_EXTEN = 107,
+ PW_AST_CONTEXT = 108,
+ PW_AST_CHANNAME = 109,
+ PW_AST_APPNAME = 110,
+ PW_AST_APPDATA = 111,
+ PW_AST_EVENT_TIME = 112,
+ PW_AST_AMA_FLAGS = 113,
+ PW_AST_UNIQUE_ID = 114,
+ PW_AST_USER_NAME = 115,
};
enum {
@@ -94,7 +91,13 @@
static rc_handle *rh = NULL;
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)
+static int build_radius_record(VALUE_PAIR **send, enum ast_cel_eventtype eventtype,
+ time_t eventtime, char *userdefname, 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)
{
int recordtype = PW_STATUS_STOP;
struct tm tm;
@@ -105,67 +108,81 @@
return -1;
/* Account code */
- if (!rc_avpair_add(rh, send, PW_AST_ACCT_CODE, (char**)&chan->accountcode, strlen(chan->accountcode), VENDOR_CODE))
+ if (!rc_avpair_add(rh, send, PW_AST_ACCT_CODE, (char**)&accountcode, strlen(accountcode), VENDOR_CODE))
return -1;
/* Source */
- if (!rc_avpair_add(rh, send, PW_AST_SRC, &chan->cid.cid_num, strlen(chan->cid.cid_num), VENDOR_CODE))
+ if (!rc_avpair_add(rh, send, PW_AST_CIDNUM, &cid_num, strlen(cid_num), VENDOR_CODE))
return -1;
/* Destination */
- if (!rc_avpair_add(rh, send, PW_AST_DST, &chan->exten, strlen(chan->exten), VENDOR_CODE))
+ if (!rc_avpair_add(rh, send, PW_AST_EXTEN, &exten, strlen(exten), VENDOR_CODE))
return -1;
/* Destination context */
- if (!rc_avpair_add(rh, send, PW_AST_DST_CTX, &chan->context, strlen(chan->context), VENDOR_CODE))
+ if (!rc_avpair_add(rh, send, PW_AST_CONTEXT, &context, strlen(context), VENDOR_CODE))
return -1;
/* Caller ID */
- if (!rc_avpair_add(rh, send, PW_AST_CLID, &chan->cid.cid_name, strlen(chan->cid.cid_name), VENDOR_CODE))
+ if (!rc_avpair_add(rh, send, PW_AST_CIDNAME, &cid_name, strlen(cid_name), VENDOR_CODE))
+ return -1;
+
+ /* Caller ID ani */
+ if (!rc_avpair_add(rh, send, PW_AST_CIDANI, &cid_ani, strlen(cid_ani), VENDOR_CODE))
+ return -1;
+
+ /* Caller ID rdnis */
+ if (!rc_avpair_add(rh, send, PW_AST_CIDRDNIS, &cid_rdnis, strlen(cid_rdnis), VENDOR_CODE))
+ return -1;
+
+ /* Caller ID dnid */
+ if (!rc_avpair_add(rh, send, PW_AST_CIDDNID, &cid_dnid, strlen(cid_dnid), VENDOR_CODE))
return -1;
/* Channel */
- if (!rc_avpair_add(rh, send, PW_AST_CHAN, (char**)&chan->name, strlen(chan->name), VENDOR_CODE))
+ if (!rc_avpair_add(rh, send, PW_AST_CHANNAME, (char**)&channame, strlen(channame), VENDOR_CODE))
return -1;
/* Last Application */
- if (!rc_avpair_add(rh, send, PW_AST_LAST_APP, &chan->appl, strlen(chan->appl), VENDOR_CODE))
+ if (!rc_avpair_add(rh, send, PW_AST_APPNAME, &appname, strlen(appname), VENDOR_CODE))
return -1;
/* Last Data */
- if (!rc_avpair_add(rh, send, PW_AST_LAST_DATA, &chan->data, strlen(chan->data), VENDOR_CODE))
- return -1;
-
-
- /* Start Time */
+ if (!rc_avpair_add(rh, send, PW_AST_APPDATA, &appdata, strlen(appdata), VENDOR_CODE))
+ return -1;
+
+
+ /* Event Time */
if (ast_test_flag(&global_flags, RADIUS_FLAG_USEGMTIME))
gmtime_r(&(eventtime), &tm);
else
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))
+ if (!rc_avpair_add(rh, send, PW_AST_EVENT_TIME, timestr, strlen(timestr), VENDOR_CODE))
return -1;
/* AMA Flags */
- tmp = ast_cel_flags2str(chan->amaflags);
+ tmp = ast_cel_flags2str(amaflag);
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, (char**)&chan->uniqueid, strlen(chan->uniqueid), VENDOR_CODE))
+ if (!rc_avpair_add(rh, send, PW_AST_UNIQUE_ID, (char**)&uniqueid, strlen(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, (char**)&chan->name, strlen(chan->name), 0))
- return -1;
-
+ if (!rc_avpair_add(rh, send, PW_USER_NAME, (char**)&channame, strlen(channame), 0))
+ return -1;
+
+#ifdef WHY_CANT_SESSIONID_BE_FOUND
/* Unique ID */
- if (!rc_avpair_add(rh, send, PW_ACCT_SESSION_ID, (char**)&chan->uniqueid, strlen(chan->uniqueid), 0))
- return -1;
+ if (!rc_avpair_add(rh, send, PW_ACCT_SESSIONID, (char**)&uniqueid, strlen(uniqueid), 0))
+ return -1;
+#endif
return 0;
}
@@ -174,20 +191,34 @@
{
int result = ERROR_RC;
VALUE_PAIR *send = NULL;
- 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);
+ const char *cid_ani, *cid_rdnis, *cid_name, *cid_num, *cid_dnid;
+ const char *exten, *context, *channame, *appname, *appdata, *accountcode, *uniqueid;
+ unsigned int amaflag;
+
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((struct ast_channel*)chan, eventtype, userdefname, eventtime);
-
- if (build_radius_record(&send, (struct ast_channel*)chan, eventtype, eventtime, (char*)userdefname)) {
+ cid_name = ast_event_get_ie_str(event, AST_EVENT_IE_CEL_CIDNAME);
+ cid_num = ast_event_get_ie_str(event, AST_EVENT_IE_CEL_CIDNUM);
+ cid_ani = ast_event_get_ie_str(event, AST_EVENT_IE_CEL_CIDANI);
+ cid_rdnis = ast_event_get_ie_str(event, AST_EVENT_IE_CEL_CIDRDNIS);
+ cid_dnid = ast_event_get_ie_str(event, AST_EVENT_IE_CEL_CIDDNID);
+ exten = ast_event_get_ie_str(event, AST_EVENT_IE_CEL_EXTEN);
+ context = ast_event_get_ie_str(event, AST_EVENT_IE_CEL_CONTEXT);
+ channame = ast_event_get_ie_str(event, AST_EVENT_IE_CEL_CHANNAME);
+ appname = ast_event_get_ie_str(event, AST_EVENT_IE_CEL_APPNAME);
+ appdata = ast_event_get_ie_str(event, AST_EVENT_IE_CEL_APPDATA);
+ 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);
+
+ if (build_radius_record(&send, eventtype, eventtime, (char*)userdefname, cid_name, cid_num,
+ cid_ani, cid_rdnis, cid_dnid, exten, context, channame,
+ appname, appdata, accountcode, uniqueid, amaflag)) {
if (option_debug)
ast_log(LOG_DEBUG, "Unable to create RADIUS record. CEL not recorded!\n");
return;
@@ -229,21 +260,21 @@
/* read radiusclient-ng config file */
if (!(rh = rc_read_config(radiuscfg))) {
ast_log(LOG_NOTICE, "Cannot load radiusclient-ng configuration file %s.\n", radiuscfg);
- return -1;
+ return AST_MODULE_LOAD_DECLINE;
}
/* read radiusclient-ng dictionaries */
if (rc_read_dictionary(rh, rc_conf_str(rh, "dictionary"))) {
ast_log(LOG_NOTICE, "Cannot load radiusclient-ng dictionary file.\n");
- return -1;
- }
-
- event_sub = ast_event_subscribe(AST_EVENT_CEL, radius_log, NULL, "CEL Radius Logging", AST_EVENT_IE_END);
+ return AST_MODULE_LOAD_DECLINE;
+ }
+
+ event_sub = ast_event_subscribe(AST_EVENT_CEL, radius_log, "CEL Radius Logging", NULL, AST_EVENT_IE_END);
if (!event_sub)
return AST_MODULE_LOAD_DECLINE;
else
- return 0;
+ return AST_MODULE_LOAD_SUCCESS;
}
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=63564&r1=63563&r2=63564
==============================================================================
--- team/murf/newcdr/cel/cel_sqlite.c (original)
+++ team/murf/newcdr/cel/cel_sqlite.c Wed May 9 09:26:15 2007
@@ -95,18 +95,30 @@
time_t t;
char startstr[80];
int count;
[... 1147 lines stripped ...]
More information about the asterisk-commits
mailing list