[svn-commits] murf: branch group/newcdr r115357 - in /team/group/newcdr: cel/ include/aster...

SVN commits to the Digium repositories svn-commits at lists.digium.com
Tue May 6 13:09:24 CDT 2008


Author: murf
Date: Tue May  6 13:09:24 2008
New Revision: 115357

URL: http://svn.digium.com/view/asterisk?view=rev&rev=115357
Log:
OK, got the linkedid into the backends. Now to get them in the driver(s). Zap first.

Modified:
    team/group/newcdr/cel/cel_csv.c
    team/group/newcdr/cel/cel_custom.c
    team/group/newcdr/cel/cel_manager.c
    team/group/newcdr/cel/cel_odbc.c
    team/group/newcdr/cel/cel_pgsql.c
    team/group/newcdr/cel/cel_radius.c
    team/group/newcdr/cel/cel_sqlite.c
    team/group/newcdr/cel/cel_sqlite3_custom.c
    team/group/newcdr/cel/cel_tds.c
    team/group/newcdr/include/asterisk/cdr.h
    team/group/newcdr/include/asterisk/cel.h
    team/group/newcdr/include/asterisk/channel.h
    team/group/newcdr/include/asterisk/event_defs.h
    team/group/newcdr/include/asterisk/res_odbc.h
    team/group/newcdr/main/cdr.c
    team/group/newcdr/main/cel.c

Modified: team/group/newcdr/cel/cel_csv.c
URL: http://svn.digium.com/view/asterisk/team/group/newcdr/cel/cel_csv.c?view=diff&rev=115357&r1=115356&r2=115357
==============================================================================
--- team/group/newcdr/cel/cel_csv.c (original)
+++ team/group/newcdr/cel/cel_csv.c Tue May  6 13:09:24 2008
@@ -218,7 +218,7 @@
 							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 *userfield, const char *peer)
+							const char *userfield, const char *peer, const char *linkedid)
 {
 
 	buf[0] = '\0';
@@ -250,6 +250,7 @@
 	/* Unique ID */
 	if (loguniqueid)
 		append_string(buf, uniqueid, bufsize);
+	append_string(buf, linkedid, bufsize);
 	/* Userfield */
 	append_string(buf, userfield, bufsize);
 	/* Peer (for bridges) */
@@ -304,7 +305,7 @@
 	const char *userdefname = 0;
 	struct timeval eventtime = {0};
 	const char *cid_ani, *cid_rdnis, *cid_name, *cid_num, *cid_dnid;
-	const char *exten, *context, *channame, *appname, *appdata, *accountcode, *uniqueid, *userfield, *peer;
+	const char *exten, *context, *channame, *appname, *appdata, *accountcode, *uniqueid, *userfield, *peer, *linkedid;
 	unsigned int amaflag;
 	
 	eventtype = (enum ast_cel_eventtype)ast_event_get_ie_uint(event, AST_EVENT_IE_CEL_EVENT_TYPE);
@@ -324,6 +325,7 @@
 	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);
+	linkedid = ast_event_get_ie_str(event, AST_EVENT_IE_CEL_LINKEDID);
 	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);
@@ -331,7 +333,7 @@
 	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, userfield, peer)) {
+						 channame, appname, appdata, accountcode, uniqueid, amaflag, userfield, peer, linkedid)) {
 		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/group/newcdr/cel/cel_custom.c
URL: http://svn.digium.com/view/asterisk/team/group/newcdr/cel/cel_custom.c?view=diff&rev=115357&r1=115356&r2=115357
==============================================================================
--- team/group/newcdr/cel/cel_custom.c (original)
+++ team/group/newcdr/cel/cel_custom.c Tue May  6 13:09:24 2008
@@ -120,7 +120,7 @@
 	struct timeval 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, *peer, *userfield;
+	const char *exten, *context, *channame, *appname, *appdata, *accountcode, *uniqueid, *linkedid, *peer, *userfield;
 	unsigned int amaflag;
 	struct ast_var_t *vardata;
 
@@ -149,13 +149,14 @@
 	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);
+	linkedid = ast_event_get_ie_str(event, AST_EVENT_IE_CEL_LINKEDID);
 	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, userfield, peer);
+								 appname, appdata, accountcode, uniqueid, amaflag, userfield, peer, linkedid);
 
 	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/group/newcdr/cel/cel_manager.c
URL: http://svn.digium.com/view/asterisk/team/group/newcdr/cel/cel_manager.c?view=diff&rev=115357&r1=115356&r2=115357
==============================================================================
--- team/group/newcdr/cel/cel_manager.c (original)
+++ team/group/newcdr/cel/cel_manager.c Tue May  6 13:09:24 2008
@@ -138,7 +138,7 @@
 	const char *userdefname = 0;
 	struct timeval eventtime = {0};
 	const char *cid_ani, *cid_rdnis, *cid_name, *cid_num, *cid_dnid;
-	const char *exten, *context, *channame, *appname, *appdata, *accountcode, *uniqueid, *userfield, *peer;
+	const char *exten, *context, *channame, *appname, *appdata, *accountcode, *uniqueid, *linkedid, *userfield, *peer;
 	unsigned int amaflag;
 
 	if (!enablecel)
@@ -162,6 +162,7 @@
 	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);
+	linkedid = ast_event_get_ie_str(event, AST_EVENT_IE_CEL_LINKEDID);
 	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);
@@ -186,13 +187,14 @@
 	    "EventTime: %s\r\n"
 	    "AMAFlags: %s\r\n"
 	    "UniqueID: %s\r\n"
+	    "LinkedID: %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, userfield, peer);
+				  ast_cel_flags2str(amaflag), uniqueid, linkedid, userfield, peer);
 }
 
 static int unload_module(void)

Modified: team/group/newcdr/cel/cel_odbc.c
URL: http://svn.digium.com/view/asterisk/team/group/newcdr/cel/cel_odbc.c?view=diff&rev=115357&r1=115356&r2=115357
==============================================================================
--- team/group/newcdr/cel/cel_odbc.c (original)
+++ team/group/newcdr/cel/cel_odbc.c Tue May  6 13:09:24 2008
@@ -73,31 +73,12 @@
 #define DATE_FORMAT "%Y-%m-%d %T"
 
 static char *config_file = "cel_odbc.conf";
-static char *dsn = NULL, *username = NULL, *password = NULL, *table = NULL;
-static int loguniqueid = 0;
+static char *dsn = NULL, *table = NULL;
 static int usegmtime = 0;
-static int dispositionstring = 0;
-static int connected = 0;
-
-AST_MUTEX_DEFINE_STATIC(odbc_lock);
-
-static int odbc_do_query(void);
-static int odbc_init(void);
-
-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_flags config = { 0 };
-
-static void odbc_disconnect(void)
-{
-	SQLDisconnect(ODBC_con);
-	SQLFreeHandle(SQL_HANDLE_DBC, ODBC_con);
-	SQLFreeHandle(SQL_HANDLE_ENV, ODBC_env);
-	connected = 0;
-}
 
 static SQLHSTMT execute_cb(struct odbc_obj *obj, void *data)
 {
@@ -110,7 +91,7 @@
 	const char *userdefname = 0;
 	struct timeval eventtime = {0};
 	const char *cid_ani, *cid_rdnis, *cid_name, *cid_num, *cid_dnid;
-	const char *exten, *context, *channame, *appname, *appdata, *accountcode, *uniqueid, *userfield, *peer;
+	const char *exten, *context, *channame, *appname, *appdata, *accountcode, *uniqueid, *linkedid, *userfield, *peer;
 	unsigned int amaflag;
 
 	eventtype = (enum ast_cel_eventtype)ast_event_get_ie_uint(event, AST_EVENT_IE_CEL_EVENT_TYPE);
@@ -133,6 +114,7 @@
 	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);
+	linkedid = ast_event_get_ie_str(event, AST_EVENT_IE_CEL_LINKEDID);
 	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);
@@ -143,13 +125,13 @@
 	if (ast_test_flag(&config, CONFIG_LOGUNIQUEID)) {
 		snprintf(sqlcmd,sizeof(sqlcmd),"INSERT INTO %s "
 		"(eventtime,eventtype,cidname,cidnum,cidani,cidrdnis,ciddnid,exten,context,channel,app,"
-		"appdata,amaflags,accountcode,userfield,peer,uniqueid) "
-		"VALUES (?,?,?,?,?,?,?,?,?,?,?,?,?,?,?,?,?)", table);
+		"appdata,amaflags,accountcode,userfield,peer,uniqueid,linkedid) "
+		"VALUES (?,?,?,?,?,?,?,?,?,?,?,?,?,?,?,?,?,?)", table);
 	} else {
 		snprintf(sqlcmd,sizeof(sqlcmd),"INSERT INTO %s "
 		"(eventtime,eventtype,cidname,cidnum,cidani,cidrdnis,ciddnid,exten,context,channel,app,appdata,"
-		"amaflags,accountcode,userfield,peer) "
-		"VALUES (?,?,?,?,?,?,?,?,?,?,?,?,?,?,?,?)", table);
+		"amaflags,accountcode,userfield,peer,linkedid) "
+		"VALUES (?,?,?,?,?,?,?,?,?,?,?,?,?,?,?,?,?)", table);
 	}
 	
 	ODBC_res = SQLAllocHandle(SQL_HANDLE_STMT, obj->con, &stmt);
@@ -176,9 +158,10 @@
 	SQLBindParameter(stmt, 14, SQL_PARAM_INPUT, SQL_C_CHAR, SQL_CHAR, sizeof(accountcode), 0, (char*)accountcode, 0, NULL);
 	SQLBindParameter(stmt, 15, SQL_PARAM_INPUT, SQL_C_CHAR, SQL_CHAR, sizeof(userfield), 0, (char*)userfield, 0, NULL);
 	SQLBindParameter(stmt, 16, SQL_PARAM_INPUT, SQL_C_CHAR, SQL_CHAR, sizeof(peer), 0, (char*)peer, 0, NULL);
+	SQLBindParameter(stmt, 17, SQL_PARAM_INPUT, SQL_C_CHAR, SQL_CHAR, sizeof(uniqueid), 0, (char*)linkedid, 0, NULL);
 
 	if (ast_test_flag(&config, CONFIG_LOGUNIQUEID)) {
-		SQLBindParameter(stmt, 17, SQL_PARAM_INPUT, SQL_C_CHAR, SQL_CHAR, sizeof(uniqueid), 0, (char*)uniqueid, 0, NULL);
+		SQLBindParameter(stmt, 18, SQL_PARAM_INPUT, SQL_C_CHAR, SQL_CHAR, sizeof(uniqueid), 0, (char*)uniqueid, 0, NULL);
 	}
 
 	ODBC_res = SQLExecDirect(stmt, (unsigned char *)sqlcmd, SQL_NTS);
@@ -200,7 +183,7 @@
 		ast_log(LOG_ERROR, "Unable to retrieve database handle.  CDR failed.\n");
 		return;
 	}
-	stmt = ast_odbc_direct_execute(obj, execute_cb, event);
+	stmt = ast_odbc_direct_execute(obj, execute_cb, (void *)event);
 	if (stmt) {
 		SQLLEN rows = 0;
 		

Modified: team/group/newcdr/cel/cel_pgsql.c
URL: http://svn.digium.com/view/asterisk/team/group/newcdr/cel/cel_pgsql.c?view=diff&rev=115357&r1=115356&r2=115357
==============================================================================
--- team/group/newcdr/cel/cel_pgsql.c (original)
+++ team/group/newcdr/cel/cel_pgsql.c Tue May  6 13:09:24 2008
@@ -84,7 +84,7 @@
 	struct timeval 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, *userfield, *peer;
+	const char *exten, *context, *channame, *appname, *appdata, *accountcode, *uniqueid, *linkedid, *userfield, *peer;
 	unsigned int amaflag;
 
 	eventtype = (enum ast_cel_eventtype)ast_event_get_ie_uint(event, AST_EVENT_IE_CEL_EVENT_TYPE);
@@ -104,13 +104,14 @@
 	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);
+	linkedid = ast_event_get_ie_str(event, AST_EVENT_IE_CEL_LINKEDID);
 	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, userfield, peer);
+								 appname, appdata, accountcode, uniqueid, amaflag, userfield, peer, linkedid);
 
 	ast_mutex_lock(&pgsql_lock);
 
@@ -129,7 +130,7 @@
 	}
 
 	if (connected) {
-		char *cidname_esc=NULL, *exten_esc, *context_esc=NULL, *channel_esc=NULL, *app_esc=NULL, *appdata_esc=NULL;
+		char *cidname_esc=NULL, *exten_esc, *context_esc=NULL, *channel_esc=NULL, *app_esc=NULL, *appdata_esc=NULL, *linkedid_esc=NULL;
 		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 */
@@ -153,6 +154,8 @@
 			PQescapeString(appdata_esc, appdata, strlen(appdata));
 		if ((uniqueid_esc = alloca(strlen(uniqueid) * 2 + 1)) != NULL)
 			PQescapeString(uniqueid_esc, uniqueid, strlen(uniqueid));
+		if ((linkedid_esc = alloca(strlen(linkedid) * 2 + 1)) != NULL)
+			PQescapeString(linkedid_esc, linkedid, strlen(linkedid));
 		if ((accountcode_esc = alloca(strlen(accountcode) * 2 + 1)) != NULL)
 			PQescapeString(accountcode_esc, accountcode, strlen(accountcode));
 		if ((userfield_esc = alloca(strlen(userfield) * 2 + 1)) != NULL)
@@ -161,7 +164,7 @@
 			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)
+		if ((!cidname_esc) || (!context_esc) || (!channel_esc) || (!app_esc) || (!appdata_esc) || (!uniqueid_esc) || (!linkedid_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);
@@ -172,11 +175,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,userfield,peer) VALUES"
-				 " ('%s','%s','%s','%s','%s','%s','%s','%s','%s','%s','%s','%d,'%s','%s','%s','%s')",
+				 "app,appdata,amaflags,accountcode,uniqueid,userfield,peer,linkedid) VALUES"
+				 " ('%s','%s','%s','%s','%s','%s','%s','%s','%s','%s','%s','%d,'%s','%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, userfield_esc, peer_esc);
+				 amaflag, accountcode_esc, uniqueid_esc, userfield_esc, peer_esc,linkedid_esc);
 		
 		if (option_debug > 2)
 			ast_log(LOG_DEBUG, "cel_pgsql: SQL command executed:  %s\n",sqlcmd);

Modified: team/group/newcdr/cel/cel_radius.c
URL: http://svn.digium.com/view/asterisk/team/group/newcdr/cel/cel_radius.c?view=diff&rev=115357&r1=115356&r2=115357
==============================================================================
--- team/group/newcdr/cel/cel_radius.c (original)
+++ team/group/newcdr/cel/cel_radius.c Tue May  6 13:09:24 2008
@@ -70,7 +70,8 @@
 	PW_AST_EVENT_TIME =   112,
 	PW_AST_AMA_FLAGS =    113,
 	PW_AST_UNIQUE_ID =    114,
-	PW_AST_USER_NAME =     115,
+	PW_AST_USER_NAME =    115,
+	PW_AST_LINKED_ID =    116,
 };
 
 enum {
@@ -97,7 +98,7 @@
 							   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 *linkedid)
 {
 	int recordtype = PW_STATUS_STOP;
 	struct ast_tm tm;
@@ -168,6 +169,11 @@
 		if (!rc_avpair_add(rh, send, PW_AST_UNIQUE_ID, (char**)&uniqueid, strlen(uniqueid), VENDOR_CODE))
 			return -1;
 	}
+	
+	/* LinkedID */
+	if (!rc_avpair_add(rh, send, PW_AST_LINKED_ID, &linkedid, strlen(linkedid), VENDOR_CODE))
+		return -1;
+
 
 	/* Setting Acct-Session-Id & User-Name attributes for proper generation
 	   of Acct-Unique-Session-Id on server side */ 
@@ -192,7 +198,7 @@
 	const char *userdefname = 0;
 	struct timeval 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, *linkedid;
 	unsigned int amaflag;
 	
 	eventtype = (enum ast_cel_eventtype)ast_event_get_ie_uint(event, AST_EVENT_IE_CEL_EVENT_TYPE);
@@ -212,11 +218,12 @@
 	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);
+	linkedid = ast_event_get_ie_str(event, AST_EVENT_IE_CEL_LINKEDID);
 	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)) {
+							appname, appdata, accountcode, uniqueid, amaflag, linkedid)) {
 		if (option_debug)
 			ast_log(LOG_DEBUG, "Unable to create RADIUS record. CEL not recorded!\n");
 		return;

Modified: team/group/newcdr/cel/cel_sqlite.c
URL: http://svn.digium.com/view/asterisk/team/group/newcdr/cel/cel_sqlite.c?view=diff&rev=115357&r1=115356&r2=115357
==============================================================================
--- team/group/newcdr/cel/cel_sqlite.c (original)
+++ team/group/newcdr/cel/cel_sqlite.c Tue May  6 13:09:24 2008
@@ -88,6 +88,7 @@
 "	accountcode	VARCHAR(20)"
 "	userfield	VARCHAR(80),"
 "	peer		VARCHAR(80),"
+"	linkedid	VARCHAR(32),"
 #if LOG_UNIQUEID
 "	,uniqueid	VARCHAR(32)"
 #endif
@@ -105,7 +106,7 @@
 	const char *userdefname = 0;
 	struct timeval eventtime = {0};
 	const char *cid_ani, *cid_rdnis, *cid_name, *cid_num, *cid_dnid;
-	const char *exten, *context, *channame, *appname, *appdata, *accountcode, *uniqueid, *userfield, *peer;
+	const char *exten, *context, *channame, *appname, *appdata, *accountcode, *uniqueid, *userfield, *peer, *linkedid;
 	unsigned int amaflag;
 	
 	eventtype = (enum ast_cel_eventtype)ast_event_get_ie_uint(event, AST_EVENT_IE_CEL_EVENT_TYPE);
@@ -125,6 +126,7 @@
 	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);
+	linkedid = ast_event_get_ie_str(event, AST_EVENT_IE_CEL_LINKEDID);
 	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);
@@ -142,18 +144,19 @@
 				"channelname,appname,appdata, "
 				"eventtime,"
 				"amaflags,"
-				"accountcode"
-				"userfield"
-				"peer"
+				"accountcode,"
+				"userfield,"
+				"peer,"
+				"linkedid"
 #				if LOG_UNIQUEID
 				",uniqueid"
 #				endif
 			") VALUES ("
 				"'%q', '%q', '%q', '%q', '%q', '%q', '%q', "
 				"'%q', '%q', '%q', "
-				"'%q', %d, '%q', "
+				"'%q', %d, '%q', '%q'"
 #				if LOG_UNIQUEID
-				",'%q'"
+				", '%q'"
 #				endif
             ")", NULL, NULL, &zErr,
                 cid_name, cid_num, cid_ani, cid_rdnis, cid_dnid, exten, context,
@@ -162,7 +165,7 @@
 				amaflag,
 				accountcode,
 				userfield,
-				peer
+				peer, linkedid
 #				if LOG_UNIQUEID
 				,uniqueid
 #				endif

Modified: team/group/newcdr/cel/cel_sqlite3_custom.c
URL: http://svn.digium.com/view/asterisk/team/group/newcdr/cel/cel_sqlite3_custom.c?view=diff&rev=115357&r1=115356&r2=115357
==============================================================================
--- team/group/newcdr/cel/cel_sqlite3_custom.c (original)
+++ team/group/newcdr/cel/cel_sqlite3_custom.c Tue May  6 13:09:24 2008
@@ -164,7 +164,7 @@
 	char *userdefname = 0;
 	struct timeval eventtime = {0};
 	const char *cid_ani, *cid_rdnis, *cid_name, *cid_num, *cid_dnid;
-	const char *exten, *context, *channame, *appname, *appdata, *accountcode, *uniqueid, *userfield, *peer;
+	const char *exten, *context, *channame, *appname, *appdata, *accountcode, *uniqueid, *userfield, *peer, *linkedid;
 	unsigned int amaflag;
 	struct ast_var_t *vardata;
 	
@@ -189,13 +189,14 @@
 	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);
+	linkedid = ast_event_get_ie_str(event, AST_EVENT_IE_CEL_LINKEDID);
 	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, userfield, peer);
+								 appname, appdata, accountcode, uniqueid, amaflag, userfield, peer, linkedid);
 
 	{ /* Make it obvious that only sql_cmd should be used outside of this block */
 		char *sql_tmp_cmd;

Modified: team/group/newcdr/cel/cel_tds.c
URL: http://svn.digium.com/view/asterisk/team/group/newcdr/cel/cel_tds.c?view=diff&rev=115357&r1=115356&r2=115357
==============================================================================
--- team/group/newcdr/cel/cel_tds.c (original)
+++ team/group/newcdr/cel/cel_tds.c Tue May  6 13:09:24 2008
@@ -45,9 +45,10 @@
 	[appdata] [varchar] (80) NULL ,
 	[eventtime] [datetime] NULL ,
 	[eventtype] [varchar] (32) NULL ,
-	[uniqueid] [varchar] (32) NULL
-	[amaflags] [varchar] (16) NULL
-	[userfield] [varchar] (32) NULL
+	[uniqueid] [varchar] (32) NULL ,
+	[linkedid] [varchar] (32) NULL ,
+	[amaflags] [varchar] (16) NULL ,
+	[userfield] [varchar] (32) NULL ,
 	[peer] [varchar] (32) NULL
 ) ON [PRIMARY]
 
@@ -111,7 +112,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, *peer_ai, *userfield_ai;
+	char *accountcode_ai, *clidnum_ai, *exten_ai, *context_ai, *clid_ai, *channel_ai, *app_ai, *appdata_ai, *uniqueid_ai, *linkedid_ai, *cidani_ai, *cidrdnis_ai, *ciddnid_ai, *peer_ai, *userfield_ai;
 	int retried = 0;
 #ifdef FREETDS_PRE_0_62
 	TDS_INT result_type;
@@ -120,7 +121,7 @@
 	const char *userdefname = 0;
 	struct timeval eventtime = {0};
 	const char *cid_ani, *cid_rdnis, *cid_name, *cid_num, *cid_dnid;
-	const char *exten, *context, *channame, *appname, *appdata, *accountcode, *uniqueid, *userfield, *peer;
+	const char *exten, *context, *channame, *appname, *appdata, *accountcode, *uniqueid, *linkedid, *userfield, *peer;
 	const char *eventname;
 	unsigned int amaflag;
 	
@@ -141,6 +142,7 @@
 	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);
+	linkedid = ast_event_get_ie_str(event, AST_EVENT_IE_CEL_LINKEDID);
 	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);
@@ -166,6 +168,7 @@
 	app_ai = anti_injection(appname, 80);
 	appdata_ai = anti_injection(appdata, 80);
 	uniqueid_ai = anti_injection(uniqueid, 32);
+	linkedid_ai = anti_injection(linkedid, 32);
 	userfield_ai = anti_injection(userfield, 32);
 	peer_ai = anti_injection(peer, 32);
 
@@ -190,6 +193,7 @@
 			"eventtype, "
 			"amaflags, "
 			"uniqueid"
+			"linkedid"
 			"userfield"
 			"peer"
 		") "
@@ -207,10 +211,11 @@
 			"'%s', "	/* app */
 			"'%s', "	/* appdata */
 			"%s, "		/* eventtime */
-			"'%s', "		/* eventtype */
+			"'%s', "	/* eventtype */
 			"'%s', "	/* amaflags */
-			"'%s'"		/* uniqueid */
-			"'%s'"		/* userfield */
+			"'%s', "	/* uniqueid */
+			"'%s', "	/* linkedid */
+			"'%s', "	/* userfield */
 			"'%s'"		/* peer */
 		")",
 		table,
@@ -229,6 +234,7 @@
 		eventname,
 		ast_cel_flags2str(amaflag),
 		uniqueid_ai,
+		linkedid_ai,
 		userfield_ai,
 		peer_ai
 	);
@@ -267,6 +273,7 @@
 	free(app_ai);
 	free(appdata_ai);
 	free(uniqueid_ai);
+	free(linkedid_ai);
 	free(userfield_ai);
 	free(peer_ai);
 

Modified: team/group/newcdr/include/asterisk/cdr.h
URL: http://svn.digium.com/view/asterisk/team/group/newcdr/include/asterisk/cdr.h?view=diff&rev=115357&r1=115356&r2=115357
==============================================================================
--- team/group/newcdr/include/asterisk/cdr.h (original)
+++ team/group/newcdr/include/asterisk/cdr.h Tue May  6 13:09:24 2008
@@ -86,6 +86,8 @@
 	unsigned int flags;				
 	/*! Unique Channel Identifier */
 	char uniqueid[32];
+	/* Linked group Identifier */
+	char linkedid[32];
 	/*! User field */
 	char userfield[AST_MAX_USER_FIELD];
 

Modified: team/group/newcdr/include/asterisk/cel.h
URL: http://svn.digium.com/view/asterisk/team/group/newcdr/include/asterisk/cel.h?view=diff&rev=115357&r1=115356&r2=115357
==============================================================================
--- team/group/newcdr/include/asterisk/cel.h (original)
+++ team/group/newcdr/include/asterisk/cel.h Tue May  6 13:09:24 2008
@@ -126,7 +126,7 @@
 								  const char *context, const char *channame, const char *appname, 
 								  const char *appdata, const char *accountcode, 
 								  const char *uniqueid, unsigned int amaflag, const char *userfield,
-								  const char *peer);
+								  const char *peer, const char *linkedid);
 
 /*! Frees the cel struct */
 void ast_cel_destroy(struct ast_cel *cel);

Modified: team/group/newcdr/include/asterisk/channel.h
URL: http://svn.digium.com/view/asterisk/team/group/newcdr/include/asterisk/channel.h?view=diff&rev=115357&r1=115356&r2=115357
==============================================================================
--- team/group/newcdr/include/asterisk/channel.h (original)
+++ team/group/newcdr/include/asterisk/channel.h Tue May  6 13:09:24 2008
@@ -395,6 +395,7 @@
 		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 */
+		AST_STRING_FIELD(linkedid);		/*!< Linked Channel Identifier -- gets propagated by linkage */
 	);
 	
 	/*! \brief File descriptor for channel -- Drivers will poll on these file descriptors, so at least one must be non -1.  See \arg \ref AstFileDesc */

Modified: team/group/newcdr/include/asterisk/event_defs.h
URL: http://svn.digium.com/view/asterisk/team/group/newcdr/include/asterisk/event_defs.h?view=diff&rev=115357&r1=115356&r2=115357
==============================================================================
--- team/group/newcdr/include/asterisk/event_defs.h (original)
+++ team/group/newcdr/include/asterisk/event_defs.h Tue May  6 13:09:24 2008
@@ -205,6 +205,12 @@
 	 * Payload type: UINT (ast_event_ie_type)
 	 */
 	AST_EVENT_IE_EXISTS    = 0x18,
+	/*! 
+	 * \brief Channel Event LinkedID
+	 * Used by: AST_EVENT_CEL
+	 * Payload type: STR
+	 */
+	AST_EVENT_IE_CEL_LINKEDID = 0x19,
 	/*!
 	 * \brief Device Name
 	 * Used by AST_EVENT_DEVICE_STATE

Modified: team/group/newcdr/include/asterisk/res_odbc.h
URL: http://svn.digium.com/view/asterisk/team/group/newcdr/include/asterisk/res_odbc.h?view=diff&rev=115357&r1=115356&r2=115357
==============================================================================
--- team/group/newcdr/include/asterisk/res_odbc.h (original)
+++ team/group/newcdr/include/asterisk/res_odbc.h Tue May  6 13:09:24 2008
@@ -38,6 +38,7 @@
 	ast_mutex_t lock;
 	SQLHDBC  con;                   /* ODBC Connection Handle */
 	struct odbc_class *parent;      /* Information about the connection is protected */
+	struct timeval last_used;
 	unsigned int used:1;
 	unsigned int up:1;
 	AST_LIST_ENTRY(odbc_obj) list;
@@ -93,6 +94,22 @@
  */
 int ast_odbc_sanity_check(struct odbc_obj *obj);
 
+/*! \brief Checks if the database natively supports backslash as an escape character.
+ * \param obj The ODBC object
+ * \return Returns 1 if an ESCAPE clause is needed to support '\', 0 otherwise
+ */
+int ast_odbc_backslash_is_escape(struct odbc_obj *obj);
+
+/*! \brief Executes an non prepared statement and returns the resulting
+ * statement handle.
+ * \param obj The ODBC object
+ * \param exec_cb A function callback, which, when called, should return a statement handle with result columns bound.
+ * \param data A parameter to be passed to the exec_cb parameter function, indicating which statement handle is to be prepared.
+ * \retval a statement handle
+ * \retval NULL on error
+ */
+SQLHSTMT ast_odbc_direct_execute(struct odbc_obj *obj, SQLHSTMT (*exec_cb)(struct odbc_obj *obj, void *data), void *data);
+
 /*! 
  * \brief Prepares, executes, and returns the resulting statement handle.
  * \param obj The ODBC object

Modified: team/group/newcdr/main/cdr.c
URL: http://svn.digium.com/view/asterisk/team/group/newcdr/main/cdr.c?view=diff&rev=115357&r1=115356&r2=115357
==============================================================================
--- team/group/newcdr/main/cdr.c (original)
+++ team/group/newcdr/main/cdr.c Tue May  6 13:09:24 2008
@@ -267,6 +267,8 @@
 		ast_copy_string(workspace, cdr->accountcode, workspacelen);
 	else if (!strcasecmp(name, "uniqueid"))
 		ast_copy_string(workspace, cdr->uniqueid, workspacelen);
+	else if (!strcasecmp(name, "linkedid"))
+		ast_copy_string(workspace, cdr->linkedid, workspacelen);
 	else if (!strcasecmp(name, "userfield"))
 		ast_copy_string(workspace, cdr->userfield, workspacelen);
 	else if ((varbuf = ast_cdr_getvar_internal(cdr, name, recur)))
@@ -281,7 +283,7 @@
 /* readonly cdr variables */
 static	const char *cdr_readonly_vars[] = { "clid", "src", "dst", "dcontext", "channel", "dstchannel",
 				    "lastapp", "lastdata", "start", "answer", "end", "duration",
-				    "billsec", "disposition", "amaflags", "accountcode", "uniqueid",
+				    "billsec", "disposition", "amaflags", "accountcode", "uniqueid", "linkedid",
 				    "userfield", NULL };
 /*! Set a CDR channel variable 
 	\note You can't set the CDR variables that belong to the actual CDR record, like "billsec".
@@ -835,6 +837,8 @@
 			ast_copy_string(cdr->dcontext, S_OR(c->macrocontext,c->context), sizeof(cdr->dcontext));
 			/* Unique call identifier */
 			ast_copy_string(cdr->uniqueid, c->uniqueid, sizeof(cdr->uniqueid));
+			/* Linked call identifier */
+			ast_copy_string(cdr->linkedid, c->linkedid, sizeof(cdr->linkedid));
 		}
 	}
 	return 0;
@@ -950,7 +954,8 @@
 
 			/* Copy account code et-al */	
 			ast_copy_string(cdr->accountcode, c->accountcode, sizeof(cdr->accountcode));
-			
+			ast_copy_string(cdr->linkedid, c->linkedid, sizeof(cdr->linkedid));
+
 			/* Destination information */ /* XXX privilege macro* ? */
 			ast_copy_string(cdr->dst, S_OR(c->macroexten, c->exten), sizeof(cdr->dst));
 			ast_copy_string(cdr->dcontext, S_OR(c->macrocontext, c->context), sizeof(cdr->dcontext));

Modified: team/group/newcdr/main/cel.c
URL: http://svn.digium.com/view/asterisk/team/group/newcdr/main/cel.c?view=diff&rev=115357&r1=115356&r2=115357
==============================================================================
--- team/group/newcdr/main/cel.c (original)
+++ team/group/newcdr/main/cel.c Tue May  6 13:09:24 2008
@@ -537,7 +537,7 @@
 								  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 *userfield, const char *peer)
+								  unsigned int amaflag, const char *userfield, const char *peer, const char *linkedid)
 {
 	/* 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
@@ -569,6 +569,7 @@
 	ast_copy_string(chan->context, context, sizeof(chan->context));
 	ast_string_field_set(chan,name,channame);
 	ast_string_field_set(chan,uniqueid,uniqueid);
+	ast_string_field_set(chan,linkedid,linkedid);
 	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!*/




More information about the svn-commits mailing list