[svn-commits] murf: branch group/newcdr r115534 - in /team/group/newcdr: include/asterisk/ ...

SVN commits to the Digium repositories svn-commits at lists.digium.com
Wed May 7 15:12:45 CDT 2008


Author: murf
Date: Wed May  7 15:12:45 2008
New Revision: 115534

URL: http://svn.digium.com/view/asterisk?view=rev&rev=115534
Log:
First pass at converting the CDRfix5 linkedid field into newcdr; 
the linkedid is propagated at masquerade, and also at 3-way in zap.
There could be several other places to put this, we shall see.


Modified:
    team/group/newcdr/include/asterisk/channel.h
    team/group/newcdr/main/channel.c
    team/group/newcdr/main/features.c

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=115534&r1=115533&r2=115534
==============================================================================
--- team/group/newcdr/include/asterisk/channel.h (original)
+++ team/group/newcdr/include/asterisk/channel.h Wed May  7 15:12:45 2008
@@ -1647,6 +1647,11 @@
         AST_LIST_ENTRY(ast_group_info) list;   
 };
 
+/*!
+  \brief propagate the linked id between chan and peer
+ */
+void ast_channel_set_linkgroup(struct ast_channel *chan, struct ast_channel *peer);
+
 
 #if defined(__cplusplus) || defined(c_plusplus)
 }

Modified: team/group/newcdr/main/channel.c
URL: http://svn.digium.com/view/asterisk/team/group/newcdr/main/channel.c?view=diff&rev=115534&r1=115533&r2=115534
==============================================================================
--- team/group/newcdr/main/channel.c (original)
+++ team/group/newcdr/main/channel.c Wed May  7 15:12:45 2008
@@ -3756,6 +3756,30 @@
 }
 
 /*!
+  \brief Propagate the linked id from one channel to the other
+
+*/
+void ast_channel_set_linkgroup(struct ast_channel *chan, struct ast_channel *peer)
+{
+	if (ast_strlen_zero(chan->linkedid) && ast_strlen_zero(peer->linkedid)) {
+		ast_string_field_set(chan, linkedid, chan->uniqueid);
+		ast_string_field_set(peer, linkedid, chan->uniqueid);
+	} else if (!ast_strlen_zero(chan->linkedid) && ast_strlen_zero(peer->linkedid)) {
+		ast_string_field_set(peer, linkedid, chan->linkedid);
+	} else if (ast_strlen_zero(chan->linkedid) && !ast_strlen_zero(peer->linkedid)) {
+		ast_string_field_set(chan, linkedid, peer->linkedid);
+	} else {
+		int x = strcmp(chan->linkedid,peer->linkedid);
+		ast_log(LOG_WARNING,"linkid clash between (chan)%s and (peer) %s.\n",
+				chan->linkedid, peer->linkedid); /* smallest wins! */
+		if (x < 0)
+			ast_string_field_set(peer, linkedid, chan->linkedid); /* let the chan take precedence, then */
+		else if (x > 0)
+			ast_string_field_set(chan, linkedid, peer->linkedid); /* let the peer take precedence, then */
+	}
+}
+
+/*!
   \brief Masquerade a channel
 
   \note Assumes channel will be locked when called
@@ -3817,6 +3841,9 @@
 	/* Mangle the name of the clone channel */
 	ast_string_field_set(clone, name, masqn);
 	
+	/* share linked id's */
+	ast_channel_set_linkgroup(original, clone);
+
 	/* Notify any managers of the change, first the masq then the other */
 	manager_event(EVENT_FLAG_CALL, "Rename", "Channel: %s\r\nNewname: %s\r\nUniqueid: %s\r\n", newn, masqn, clone->uniqueid);
 	manager_event(EVENT_FLAG_CALL, "Rename", "Channel: %s\r\nNewname: %s\r\nUniqueid: %s\r\n", orig, newn, original->uniqueid);

Modified: team/group/newcdr/main/features.c
URL: http://svn.digium.com/view/asterisk/team/group/newcdr/main/features.c?view=diff&rev=115534&r1=115533&r2=115534
==============================================================================
--- team/group/newcdr/main/features.c (original)
+++ team/group/newcdr/main/features.c Wed May  7 15:12:45 2008
@@ -2006,6 +2006,27 @@
 	return chan;
 }
 
+void ast_channel_log(char *title, struct ast_channel *chan);
+
+void ast_channel_log(char *title, struct ast_channel *chan)
+{
+       ast_log(LOG_NOTICE, "______ %s (%lx)______\n", title, (unsigned long)chan);
+       ast_log(LOG_NOTICE, "CHAN: name: %s;  appl: %s; data: %s; contxt: %s;  exten: %s; pri: %d;\n",
+                       chan->name, chan->appl, chan->data, chan->context, chan->exten, chan->priority);
+       ast_log(LOG_NOTICE, "CHAN: acctcode: %s;  dialcontext: %s; amaflags: %x; maccontxt: %s;  macexten: %s; macpri: %d;\n",
+                       chan->accountcode, chan->dialcontext, chan->amaflags, chan->macrocontext, chan->macroexten, chan->macropriority);
+       ast_log(LOG_NOTICE, "CHAN: masq: %x;  masqr: %x; _bridge: %x; uniqueID: %s; linkedID:%s\n",
+                       (unsigned int)chan->masq, (unsigned int)chan->masqr,
+                       (unsigned int)chan->_bridge, chan->uniqueid, chan->linkedid);
+       if (chan->masqr)
+               ast_log(LOG_NOTICE, "CHAN: masquerading as: %s;  cdr: %x;\n",
+                               chan->masqr->name, (unsigned int)chan->masqr->cdr);
+       if (chan->_bridge)
+               ast_log(LOG_NOTICE, "CHAN: Bridged to %s\n", chan->_bridge->name);
+
+	ast_log(LOG_NOTICE, "===== done ====\n");
+}
+
 /*!
  * \brief bridge the call and set CDR
  * \param chan,peer,config
@@ -2066,6 +2087,13 @@
 		return -1;
 	peer->appl = "Bridged Call";
 	peer->data = chan->name;
+
+        /* show the two channels and cdrs involved in the bridge for debug & devel purposes */
+        ast_channel_log("Pre-bridge CHAN Channel info", chan);
+        ast_channel_log("Pre-bridge PEER Channel info", peer);
+
+        /* two channels are being marked as linked here */
+        ast_channel_set_linkgroup(chan,peer);
 
 	/* copy the userfield from the B-leg to A-leg if applicable */
 	if (chan->cdr && peer->cdr && !ast_strlen_zero(peer->cdr->userfield)) {




More information about the svn-commits mailing list