[svn-commits] mmichelson: branch group/CCSS r227495 - in /team/group/CCSS: ./ apps/ channel...

SVN commits to the Digium repositories svn-commits at lists.digium.com
Tue Nov 3 17:13:05 CST 2009


Author: mmichelson
Date: Tue Nov  3 17:13:01 2009
New Revision: 227495

URL: http://svnview.digium.com/svn/asterisk?view=rev&rev=227495
Log:
Resolve conflict and reset automerge.


Modified:
    team/group/CCSS/   (props changed)
    team/group/CCSS/CHANGES
    team/group/CCSS/apps/app_forkcdr.c
    team/group/CCSS/channels/chan_mgcp.c
    team/group/CCSS/configs/cdr_custom.conf.sample
    team/group/CCSS/funcs/func_cdr.c
    team/group/CCSS/include/asterisk/cdr.h
    team/group/CCSS/include/asterisk/manager.h
    team/group/CCSS/main/cdr.c
    team/group/CCSS/main/features.c
    team/group/CCSS/main/manager.c
    team/group/CCSS/pbx/pbx_config.c
    team/group/CCSS/res/res_pktccops.c

Propchange: team/group/CCSS/
------------------------------------------------------------------------------
    automerge = *

Propchange: team/group/CCSS/
------------------------------------------------------------------------------
--- svnmerge-integrated (original)
+++ svnmerge-integrated Tue Nov  3 17:13:01 2009
@@ -1,1 +1,1 @@
-/trunk:1-227430
+/trunk:1-227494

Modified: team/group/CCSS/CHANGES
URL: http://svnview.digium.com/svn/asterisk/team/group/CCSS/CHANGES?view=diff&rev=227495&r1=227494&r2=227495
==============================================================================
--- team/group/CCSS/CHANGES (original)
+++ team/group/CCSS/CHANGES Tue Nov  3 17:13:01 2009
@@ -277,6 +277,8 @@
  * Multiple files and formats can now be specified in cdr_custom.conf.
  * cdr_syslog has been added which allows CDRs to be written directly to syslog.
    See configs/cdr_syslog.conf.sample for more information.
+ * A 'sequence' field has been added to CDRs which can be combined with
+   linkedid or uniqueid to uniquely identify a CDR.
 
 Calendaring for Asterisk
 ------------------------

Modified: team/group/CCSS/apps/app_forkcdr.c
URL: http://svnview.digium.com/svn/asterisk/team/group/CCSS/apps/app_forkcdr.c?view=diff&rev=227495&r1=227494&r2=227495
==============================================================================
--- team/group/CCSS/apps/app_forkcdr.c (original)
+++ team/group/CCSS/apps/app_forkcdr.c Tue Nov  3 17:13:01 2009
@@ -184,7 +184,7 @@
 	while (cdr->next)
 		cdr = cdr->next;
 	
-	if (!(newcdr = ast_cdr_dup(cdr)))
+	if (!(newcdr = ast_cdr_dup_unique(cdr)))
 		return;
 	
 	ast_cdr_append(cdr, newcdr);

Modified: team/group/CCSS/channels/chan_mgcp.c
URL: http://svnview.digium.com/svn/asterisk/team/group/CCSS/channels/chan_mgcp.c?view=diff&rev=227495&r1=227494&r2=227495
==============================================================================
--- team/group/CCSS/channels/chan_mgcp.c (original)
+++ team/group/CCSS/channels/chan_mgcp.c Tue Nov  3 17:13:01 2009
@@ -1818,7 +1818,7 @@
 		if (*c == '\n') {
 			/* We've got a new header */
 			*c = 0;
-			ast_debug(3, "Header: %s (%d)\n", req->header[f], strlen(req->header[f]));
+			ast_debug(3, "Header: %s (%d)\n", req->header[f], (int) strlen(req->header[f]));
 			if (ast_strlen_zero(req->header[f])) {
 				/* Line by itself means we're now in content */
 				c++;
@@ -1847,7 +1847,7 @@
 		if (*c == '\n') {
 			/* We've got a new line */
 			*c = 0;
-			ast_debug(3, "Line: %s (%d)\n", req->line[f], strlen(req->line[f]));
+			ast_debug(3, "Line: %s (%d)\n", req->line[f], (int) strlen(req->line[f]));
 			if (f >= MGCP_MAX_LINES - 1) {
 				ast_log(LOG_WARNING, "Too many SDP lines...\n");
 			} else {

Modified: team/group/CCSS/configs/cdr_custom.conf.sample
URL: http://svnview.digium.com/svn/asterisk/team/group/CCSS/configs/cdr_custom.conf.sample?view=diff&rev=227495&r1=227494&r2=227495
==============================================================================
--- team/group/CCSS/configs/cdr_custom.conf.sample (original)
+++ team/group/CCSS/configs/cdr_custom.conf.sample Tue Nov  3 17:13:01 2009
@@ -7,6 +7,6 @@
 ; Master.csv, Simple.csv, or both.
 ;
 ;[mappings]
-;Master.csv => ${CSV_QUOTE(${CDR(clid)})},${CSV_QUOTE(${CDR(src)})},${CSV_QUOTE(${CDR(dst)})},${CSV_QUOTE(${CDR(dcontext)})},${CSV_QUOTE(${CDR(channel)})},${CSV_QUOTE(${CDR(dstchannel)})},${CSV_QUOTE(${CDR(lastapp)})},${CSV_QUOTE(${CDR(lastdata)})},${CSV_QUOTE(${CDR(start)})},${CSV_QUOTE(${CDR(answer)})},${CSV_QUOTE(${CDR(end)})},${CSV_QUOTE(${CDR(duration)})},${CSV_QUOTE(${CDR(billsec)})},${CSV_QUOTE(${CDR(disposition)})},${CSV_QUOTE(${CDR(amaflags)})},${CSV_QUOTE(${CDR(accountcode)})},${CSV_QUOTE(${CDR(uniqueid)})},${CSV_QUOTE(${CDR(userfield)})}
+;Master.csv => ${CSV_QUOTE(${CDR(clid)})},${CSV_QUOTE(${CDR(src)})},${CSV_QUOTE(${CDR(dst)})},${CSV_QUOTE(${CDR(dcontext)})},${CSV_QUOTE(${CDR(channel)})},${CSV_QUOTE(${CDR(dstchannel)})},${CSV_QUOTE(${CDR(lastapp)})},${CSV_QUOTE(${CDR(lastdata)})},${CSV_QUOTE(${CDR(start)})},${CSV_QUOTE(${CDR(answer)})},${CSV_QUOTE(${CDR(end)})},${CSV_QUOTE(${CDR(duration)})},${CSV_QUOTE(${CDR(billsec)})},${CSV_QUOTE(${CDR(disposition)})},${CSV_QUOTE(${CDR(amaflags)})},${CSV_QUOTE(${CDR(accountcode)})},${CSV_QUOTE(${CDR(uniqueid)})},${CSV_QUOTE(${CDR(userfield)})},${CDR(sequence)}
 ;Simple.csv => ${CSV_QUOTE(${EPOCH})},${CSV_QUOTE(${CDR(src)})},${CSV_QUOTE(${CDR(dst)})}
 

Modified: team/group/CCSS/funcs/func_cdr.c
URL: http://svnview.digium.com/svn/asterisk/team/group/CCSS/funcs/func_cdr.c?view=diff&rev=227495&r1=227494&r2=227495
==============================================================================
--- team/group/CCSS/funcs/func_cdr.c (original)
+++ team/group/CCSS/funcs/func_cdr.c Tue Nov  3 17:13:01 2009
@@ -98,6 +98,9 @@
 					</enum>
 					<enum name="channel">
 						<para>Channel name.</para>
+					</enum>
+					<enum name="sequence">
+						<para>CDR sequence number.</param>
 					</enum>
 				</enumlist>
 			</parameter>

Modified: team/group/CCSS/include/asterisk/cdr.h
URL: http://svnview.digium.com/svn/asterisk/team/group/CCSS/include/asterisk/cdr.h?view=diff&rev=227495&r1=227494&r2=227495
==============================================================================
--- team/group/CCSS/include/asterisk/cdr.h (original)
+++ team/group/CCSS/include/asterisk/cdr.h Tue Nov  3 17:13:01 2009
@@ -110,6 +110,8 @@
 	char linkedid[32];
 	/*! User field */
 	char userfield[AST_MAX_USER_FIELD];
+	/*! Sequence field */
+	int sequence;
 
 	/*! A linked list for variables */
 	struct varshead varshead;
@@ -143,9 +145,37 @@
 struct ast_cdr *ast_cdr_alloc(void);
 
 /*! 
- * \brief Duplicate a record 
+ * \brief Duplicate a record and increment the sequence number.
+ * \param cdr the record to duplicate
  * \retval a malloc'd ast_cdr structure, 
  * \retval NULL on error (malloc failure)
+ * \see ast_cdr_dup()
+ * \see ast_cdr_dup_unique_swap()
+ */
+struct ast_cdr *ast_cdr_dup_unique(struct ast_cdr *cdr);
+
+/*! 
+ * \brief Duplicate a record and increment the sequence number of the old
+ * record.
+ * \param cdr the record to duplicate
+ * \retval a malloc'd ast_cdr structure, 
+ * \retval NULL on error (malloc failure)
+ * \note This version increments the original CDR's sequence number rather than
+ * the duplicate's sequence number. The effect is as if the original CDR's
+ * sequence number was swapped with the duplicate's sequence number.
+ *
+ * \see ast_cdr_dup()
+ * \see ast_cdr_dup_unique()
+ */
+struct ast_cdr *ast_cdr_dup_unique_swap(struct ast_cdr *cdr);
+
+/*! 
+ * \brief Duplicate a record 
+ * \param cdr the record to duplicate
+ * \retval a malloc'd ast_cdr structure, 
+ * \retval NULL on error (malloc failure)
+ * \see ast_cdr_dup_unique()
+ * \see ast_cdr_dup_unique_swap()
  */
 struct ast_cdr *ast_cdr_dup(struct ast_cdr *cdr);
 

Modified: team/group/CCSS/include/asterisk/manager.h
URL: http://svnview.digium.com/svn/asterisk/team/group/CCSS/include/asterisk/manager.h?view=diff&rev=227495&r1=227494&r2=227495
==============================================================================
--- team/group/CCSS/include/asterisk/manager.h (original)
+++ team/group/CCSS/include/asterisk/manager.h Tue Nov  3 17:13:01 2009
@@ -73,7 +73,8 @@
 #define EVENT_FLAG_DIALPLAN		(1 << 11) /* Dialplan events (VarSet, NewExten) */
 #define EVENT_FLAG_ORIGINATE	(1 << 12) /* Originate a call to an extension */
 #define EVENT_FLAG_AGI			(1 << 13) /* AGI events */
-#define EVENT_FLAG_CC			(1 << 14) /* Call Completion events */
+#define EVENT_FLAG_HOOKRESPONSE		(1 << 14) /* Hook Response */
+#define EVENT_FLAG_CC			(1 << 15) /* Call Completion events */
 /*@} */
 
 /*! \brief Export manager structures */
@@ -107,6 +108,15 @@
     \param hook struct manager_custom_hook object to delete
 */
 void ast_manager_unregister_hook(struct manager_custom_hook *hook);
+
+/*! \brief Registered hooks can call this function to invoke actions and they will receive responses through registered callback
+ * \param hookid the file identifier specified in manager_custom_hook struct when registering a hook
+ * \param msg ami action mesage string e.g. "Action: SipPeers\r\n"
+
+ * \retval 0 on Success
+ * \retval non-zero on Failure
+*/
+int ast_hook_send_action(struct manager_custom_hook *hook, const char *msg);
 
 struct mansession;
 

Modified: team/group/CCSS/main/cdr.c
URL: http://svnview.digium.com/svn/asterisk/team/group/CCSS/main/cdr.c?view=diff&rev=227495&r1=227494&r2=227495
==============================================================================
--- team/group/CCSS/main/cdr.c (original)
+++ team/group/CCSS/main/cdr.c Tue Nov  3 17:13:01 2009
@@ -74,6 +74,11 @@
 	struct ast_cdr_batch_item *tail;
 } *batch = NULL;
 
+
+static int cdr_sequence =  0;
+
+static int cdr_seq_inc(struct ast_cdr *cdr);
+
 static struct sched_context *sched;
 static int cdr_sched = -1;
 static pthread_t cdr_thread = AST_PTHREADT_NULL;
@@ -163,6 +168,26 @@
 int ast_cdr_isset_unanswered(void)
 {
 	return unanswered;
+}
+
+struct ast_cdr *ast_cdr_dup_unique(struct ast_cdr *cdr) 
+{
+	struct ast_cdr *newcdr = ast_cdr_dup(cdr);
+	if (!newcdr)
+		return NULL;
+
+	cdr_seq_inc(newcdr);
+	return newcdr;
+}
+
+struct ast_cdr *ast_cdr_dup_unique_swap(struct ast_cdr *cdr) 
+{
+	struct ast_cdr *newcdr = ast_cdr_dup(cdr);
+	if (!newcdr)
+		return NULL;
+
+	cdr_seq_inc(cdr);
+	return newcdr;
 }
 
 /*! Duplicate a CDR record 
@@ -279,6 +304,8 @@
 		ast_copy_string(workspace, cdr->linkedid, workspacelen);
 	else if (!strcasecmp(name, "userfield"))
 		ast_copy_string(workspace, cdr->userfield, workspacelen);
+	else if (!strcasecmp(name, "sequence"))
+		snprintf(workspace, workspacelen, "%d", cdr->sequence);
 	else if ((varbuf = ast_cdr_getvar_internal(cdr, name, recur)))
 		ast_copy_string(workspace, varbuf, workspacelen);
 	else
@@ -292,7 +319,7 @@
 static const char * const cdr_readonly_vars[] = { "clid", "src", "dst", "dcontext", "channel", "dstchannel",
 						  "lastapp", "lastdata", "start", "answer", "end", "duration",
 						  "billsec", "disposition", "amaflags", "accountcode", "uniqueid", "linkedid",
-						  "userfield", NULL };
+						  "userfield", "sequence", NULL };
 /*! Set a CDR channel variable 
 	\note You can't set the CDR variables that belong to the actual CDR record, like "billsec".
 */
@@ -847,6 +874,11 @@
 	return 0;
 }
 
+static int cdr_seq_inc(struct ast_cdr *cdr)
+{
+	return (cdr->sequence = ast_atomic_fetchadd_int(&cdr_sequence, +1));
+}
+
 int ast_cdr_init(struct ast_cdr *cdr, struct ast_channel *c)
 {
 	char *chan;
@@ -856,6 +888,7 @@
 			chan = S_OR(cdr->channel, "<unknown>");
 			ast_copy_string(cdr->channel, c->name, sizeof(cdr->channel));
 			set_one_cid(cdr, c);
+			cdr_seq_inc(cdr);
 
 			cdr->disposition = (c->_state == AST_STATE_UP) ?  AST_CDR_ANSWERED : AST_CDR_NOANSWER;
 			cdr->amaflags = c->amaflags ? c->amaflags :  ast_default_amaflags;
@@ -1116,7 +1149,7 @@
 		if (ast_test_flag(&flags, AST_CDR_FLAG_LOCKED) || !ast_test_flag(cdr, AST_CDR_FLAG_LOCKED)) {
 			if (ast_test_flag(&flags, AST_CDR_FLAG_POSTED)) {
 				ast_cdr_end(cdr);
-				if ((duplicate = ast_cdr_dup(cdr))) {
+				if ((duplicate = ast_cdr_dup_unique_swap(cdr))) {
 					ast_cdr_detach(duplicate);
 				}
 				ast_set_flag(cdr, AST_CDR_FLAG_POSTED);

Modified: team/group/CCSS/main/features.c
URL: http://svnview.digium.com/svn/asterisk/team/group/CCSS/main/features.c?view=diff&rev=227495&r1=227494&r2=227495
==============================================================================
--- team/group/CCSS/main/features.c (original)
+++ team/group/CCSS/main/features.c Tue Nov  3 17:13:01 2009
@@ -2804,7 +2804,7 @@
 		if (chan_cdr) {
 			ast_set_flag(chan_cdr, AST_CDR_FLAG_MAIN);
 			ast_cdr_update(chan);
-			bridge_cdr = ast_cdr_dup(chan_cdr);
+			bridge_cdr = ast_cdr_dup_unique_swap(chan_cdr);
 			ast_copy_string(bridge_cdr->lastapp, S_OR(chan->appl, ""), sizeof(bridge_cdr->lastapp));
 			ast_copy_string(bridge_cdr->lastdata, S_OR(chan->data, ""), sizeof(bridge_cdr->lastdata));
 		} else {

Modified: team/group/CCSS/main/manager.c
URL: http://svnview.digium.com/svn/asterisk/team/group/CCSS/main/manager.c?view=diff&rev=227495&r1=227494&r2=227495
==============================================================================
--- team/group/CCSS/main/manager.c (original)
+++ team/group/CCSS/main/manager.c Tue Nov  3 17:13:01 2009
@@ -838,6 +838,7 @@
 	struct ast_tcptls_session_instance *tcptls_session;
 	FILE *f;
 	int fd;
+	struct manager_custom_hook *hook;
 	ast_mutex_t lock;
 };
 
@@ -1142,10 +1143,12 @@
 {
 	struct ast_manager_user *user = NULL;
 
-	AST_RWLIST_TRAVERSE(&users, user, list)
+	AST_RWLIST_TRAVERSE(&users, user, list) {
 		if (!strcasecmp(user->username, name)) {
 			break;
 		}
+	}
+
 	return user;
 }
 
@@ -1597,13 +1600,84 @@
 	return head;
 }
 
+/* access for hooks to send action messages to ami */
+
+int ast_hook_send_action(struct manager_custom_hook *hook, const char *msg)
+{
+	const char *action;
+	int ret = 0;
+	struct manager_action *tmp;
+	struct mansession s = {.session = NULL, };
+	struct message m = { 0 };
+	char header_buf[1025] = { '\0' };
+	const char *src = msg;
+	int x = 0;
+	int curlen;
+
+	if (hook == NULL) {
+		return -1;
+	}
+
+	/* convert msg string to message struct */
+	curlen = strlen(msg);
+	for (x = 0; x < curlen; x++) {
+		int cr;	/* set if we have \r */
+		if (src[x] == '\r' && x+1 < curlen && src[x+1] == '\n')
+			cr = 2;	/* Found. Update length to include \r\n */
+		else if (src[x] == '\n')
+			cr = 1;	/* also accept \n only */
+		else
+			continue;
+		/* don't copy empty lines */
+		if (x) {
+			memmove(header_buf, src, x);	/*... but trim \r\n */
+			header_buf[x] = '\0';		/* terminate the string */
+			m.headers[m.hdrcount++] = ast_strdupa(header_buf);
+		}
+		x += cr;
+		curlen -= x;		/* remaining size */
+		src += x;		/* update pointer */
+		x = -1;			/* reset loop */
+	}
+
+	action = astman_get_header(&m,"Action");
+	if (action && strcasecmp(action,"login")) {
+
+		AST_RWLIST_RDLOCK(&actions);
+		AST_RWLIST_TRAVERSE(&actions, tmp, list) {
+			if (strcasecmp(action, tmp->action))
+				continue;
+			/*
+			* we have to simulate a session for this action request
+			* to be able to pass it down for processing
+			* This is necessary to meet the previous design of manager.c
+			*/
+			s.hook = hook;
+			s.f = (void*)1; /* set this to something so our request will make it through all functions that test it*/
+			ret = tmp->func(&s, &m);
+			break;
+		}
+		AST_RWLIST_UNLOCK(&actions);
+	}
+	return ret;
+}
+
+
 /*!
  * helper function to send a string to the socket.
  * Return -1 on error (e.g. buffer full).
  */
 static int send_string(struct mansession *s, char *string)
 {
-	if (s->f) {
+	/* It's a result from one of the hook's action invocation */
+	if (s->hook) {
+		/*
+		 * to send responses, we're using the same function
+		 * as for receiving events. We call the event "HookResponse"
+		 */
+		s->hook->helper(EVENT_FLAG_HOOKRESPONSE, "HookResponse", string);
+		return 0;
+	} else if (s->f) {
 		return ast_careful_fwrite(s->f, s->fd, string, strlen(string), s->session->writetimeout);
 	} else {
 		return ast_careful_fwrite(s->session->f, s->session->fd, string, strlen(string), s->session->writetimeout);

Modified: team/group/CCSS/pbx/pbx_config.c
URL: http://svnview.digium.com/svn/asterisk/team/group/CCSS/pbx/pbx_config.c?view=diff&rev=227495&r1=227494&r2=227495
==============================================================================
--- team/group/CCSS/pbx/pbx_config.c (original)
+++ team/group/CCSS/pbx/pbx_config.c Tue Nov  3 17:13:01 2009
@@ -38,8 +38,8 @@
 #include "asterisk/channel.h"	/* AST_MAX_EXTENSION */
 #include "asterisk/callerid.h"
 
-static char *config = "extensions.conf";
-static char *registrar = "pbx_config";
+static const char config[] = "extensions.conf";
+static const char registrar[] = "pbx_config";
 static char userscontext[AST_MAX_EXTENSION] = "default";
 
 static int static_config = 0;

Modified: team/group/CCSS/res/res_pktccops.c
URL: http://svnview.digium.com/svn/asterisk/team/group/CCSS/res/res_pktccops.c?view=diff&rev=227495&r1=227494&r2=227495
==============================================================================
--- team/group/CCSS/res/res_pktccops.c (original)
+++ team/group/CCSS/res/res_pktccops.c Tue Nov  3 17:13:01 2009
@@ -315,6 +315,7 @@
 	int len, lent;
 	char buf[COPS_HEADER_SIZE];
 	struct pktcobj *pobject = NULL;
+	uint16_t *ubuf = (uint16_t *) buf;
 	recmsg->msg = NULL;
 	recmsg->object = NULL;
 	len = recv(sfd, buf, COPS_HEADER_SIZE, MSG_DONTWAIT);
@@ -357,7 +358,7 @@
 				return lent;
 			}
 			len += lent;
-			pobject->length = ntohs(*((uint16_t *) buf));
+			pobject->length = ntohs(*ubuf);
 			pobject->cnum = *(buf + 2);
 			pobject->ctype = *(buf + 3);
 			if (!(pobject->contents = malloc(pobject->length - COPS_OBJECT_HEADER_SIZE))) {




More information about the svn-commits mailing list