[asterisk-commits] dvossel: branch dvossel/iax2transfer_1.6.1 r173207 - in /team/dvossel/iax2tra...

SVN commits to the Asterisk project asterisk-commits at lists.digium.com
Tue Feb 3 14:44:01 CST 2009


Author: dvossel
Date: Tue Feb  3 14:44:01 2009
New Revision: 173207

URL: http://svn.digium.com/svn-view/asterisk?view=rev&rev=173207
Log:
automerge stuff

Modified:
    team/dvossel/iax2transfer_1.6.1/   (props changed)
    team/dvossel/iax2transfer_1.6.1/channels/chan_iax2.c

Propchange: team/dvossel/iax2transfer_1.6.1/
------------------------------------------------------------------------------
    automerge = *

Modified: team/dvossel/iax2transfer_1.6.1/channels/chan_iax2.c
URL: http://svn.digium.com/svn-view/asterisk/team/dvossel/iax2transfer_1.6.1/channels/chan_iax2.c?view=diff&rev=173207&r1=173206&r2=173207
==============================================================================
--- team/dvossel/iax2transfer_1.6.1/channels/chan_iax2.c (original)
+++ team/dvossel/iax2transfer_1.6.1/channels/chan_iax2.c Tue Feb  3 14:44:01 2009
@@ -863,6 +863,13 @@
  */
 static struct timeval lastused[ARRAY_LEN(iaxs)];
 
+/*!
+ *  * \brief Another container of iax2_pvt structures
+ *  
+ *  Active IAX2 pvt stucts used during transfering a call are stored here.  
+ */
+static struct ao2_container *iax_transfercallno_pvts;
+
 /* Flag to use with trunk calls, keeping these calls high up.  It halves our effective use
    but keeps the division between trunked and non-trunked better. */
 #define TRUNK_CALL_START	ARRAY_LEN(iaxs) / 2
@@ -1670,6 +1677,25 @@
 	return res;
 }
 
+static void store_by_transfercallno(struct chan_iax2_pvt *pvt)
+{
+	if (!pvt->transfercallno) {
+		ast_log(LOG_ERROR, "This should not be called without a transfer call number.\n");
+		return;
+	}
+
+	ao2_link(iax_transfercallno_pvts, pvt);
+}
+
+static void remove_by_transfercallno(struct chan_iax2_pvt *pvt)
+{
+	if (!pvt->transfercallno) {
+		ast_log(LOG_ERROR, "This should not be called without a transfer call number.\n");
+		return;
+	}
+
+	ao2_unlink(iax_transfercallno_pvts, pvt);
+}
 static void store_by_peercallno(struct chan_iax2_pvt *pvt)
 {
 	if (!pvt->peercallno) {
@@ -1706,12 +1732,13 @@
 			struct chan_iax2_pvt tmp_pvt = {
 				.callno = dcallno,
 				.peercallno = callno,
+				.transfercallno = callno,
 				/* hack!! */
 				.frames_received = check_dcallno,
 			};
 
 			memcpy(&tmp_pvt.addr, sin, sizeof(tmp_pvt.addr));
-
+			/* this works for finding normal call numbers not involving transfering */ 
 			if ((pvt = ao2_find(iax_peercallno_pvts, &tmp_pvt, OBJ_POINTER))) {
 				if (return_locked) {
 					ast_mutex_lock(&iaxsl[pvt->callno]);
@@ -1721,9 +1748,20 @@
 				pvt = NULL;
 				return res;
 			}
-		}
-
-		/* This will occur on the first response to a message that we initiated,
+			/* this searches for transfer call numbers that might not get caught otherwise */
+			memset(&tmp_pvt.addr, 0, sizeof(tmp_pvt.addr));
+			memcpy(&tmp_pvt.transfer, sin, sizeof(tmp_pvt.addr));
+			if ((pvt = ao2_find(iax_transfercallno_pvts, &tmp_pvt, OBJ_POINTER))) {
+				if (return_locked) {
+					ast_mutex_lock(&iaxsl[pvt->callno]);
+				}
+				res = pvt->callno;
+				ao2_ref(pvt, -1);
+				pvt = NULL;
+				return res;
+			}
+		}
+			/* This will occur on the first response to a message that we initiated,
 		 * such as a PING. */
 		if (dcallno) {
 			ast_mutex_lock(&iaxsl[dcallno]);
@@ -1740,7 +1778,6 @@
 		if (dcallno) {
 			ast_mutex_unlock(&iaxsl[dcallno]);
 		}
-
 #ifdef IAX_OLD_FIND
 		/* If we get here, we SHOULD NOT find a call structure for this
 		   callno; if we do, it means that there is a call structure that
@@ -2375,6 +2412,10 @@
 
 		if (pvt->peercallno) {
 			remove_by_peercallno(pvt);
+		}
+
+		if(pvt->transfercallno) {
+			remove_by_transfercallno(pvt);
 		}
 
 		if (!owner) {
@@ -6677,10 +6718,11 @@
 	pvt->transfer.sin_family = AF_INET;
 	pvt->transferring = TRANSFER_BEGIN;
 	pvt->transferid = ies->transferid;
+	store_by_transfercallno(pvt);
 	if (ies->transferid)
 		iax_ie_append_int(&ied, IAX_IE_TRANSFERID, ies->transferid);
 	send_command_transfer(pvt, AST_FRAME_IAX, IAX_COMMAND_TXCNT, 0, ied.buf, ied.pos);
-	return 0; 
+	return 0;
 }
 
 static int complete_dpreply(struct chan_iax2_pvt *pvt, struct iax_ies *ies)
@@ -6744,6 +6786,7 @@
 		ast_log(LOG_WARNING, "Invalid transfer request\n");
 		return -1;
 	}
+	remove_by_transfercallno(pvt);
 	memcpy(&pvt->addr, &pvt->transfer, sizeof(pvt->addr));
 	memset(&pvt->transfer, 0, sizeof(pvt->transfer));
 	pvt->mediareleased = 0;
@@ -6758,8 +6801,8 @@
 		remove_by_peercallno(pvt);
 	}
 	pvt->peercallno = peercallno;
+	/*this is where the transfering call swiches hash tables */
 	store_by_peercallno(pvt);
-
 	pvt->transferring = TRANSFER_NONE;
 	pvt->svoiceformat = -1;
 	pvt->voiceformat = 0;
@@ -12337,7 +12380,7 @@
 	ao2_ref(peers, -1);
 	ao2_ref(users, -1);
 	ao2_ref(iax_peercallno_pvts, -1);
-
+	ao2_ref(iax_transfercallno_pvts, -1);
 	if (timingfd > -1) {
 		ast_timer_close(timingfd);
 	}
@@ -12384,6 +12427,23 @@
 		pvt2->frames_received) ? CMP_MATCH | CMP_STOP : 0;
 }
 
+static int transfercallno_pvt_hash_cb(const void *obj, const int flags)
+{
+	const struct chan_iax2_pvt *pvt = obj;
+
+	return pvt->transfercallno;
+}
+
+static int transfercallno_pvt_cmp_cb(void *obj, void *arg, int flags)
+{
+	struct chan_iax2_pvt *pvt = obj, *pvt2 = arg;
+
+	/* The frames_received field is used to hold whether we're matching
+	 * against a full frame or not ... */
+
+	return match(&pvt2->transfer, pvt2->transfercallno, pvt2->callno, pvt,
+		pvt2->frames_received) ? CMP_MATCH | CMP_STOP : 0;
+}
 /*! \brief Load IAX2 module, load configuraiton ---*/
 static int load_module(void)
 {
@@ -12400,6 +12460,7 @@
 		return AST_MODULE_LOAD_FAILURE;
 	}
 	iax_peercallno_pvts = ao2_container_alloc(IAX_MAX_CALLS, pvt_hash_cb, pvt_cmp_cb);
+	iax_transfercallno_pvts = ao2_container_alloc(IAX_MAX_CALLS, transfercallno_pvt_hash_cb, transfercallno_pvt_cmp_cb);
 	if (!iax_peercallno_pvts) {
 		ao2_ref(peers, -1);
 		ao2_ref(users, -1);




More information about the asterisk-commits mailing list