[svn-commits] mattf: branch mattf/libpri-1.4-ntptmp r947 - /team/mattf/libpri-1.4-ntptmp/

SVN commits to the Digium repositories svn-commits at lists.digium.com
Tue Jul 21 17:11:51 CDT 2009


Author: mattf
Date: Tue Jul 21 17:11:48 2009
New Revision: 947

URL: http://svn.asterisk.org/svn-view/libpri?view=rev&rev=947
Log:
Fix bidirectional calling so that it works again... the pri for the call has to be set every time we receive a message, not just when we create a new call.

Modified:
    team/mattf/libpri-1.4-ntptmp/pri_internal.h
    team/mattf/libpri-1.4-ntptmp/q921.c
    team/mattf/libpri-1.4-ntptmp/q931.c

Modified: team/mattf/libpri-1.4-ntptmp/pri_internal.h
URL: http://svn.asterisk.org/svn-view/libpri/team/mattf/libpri-1.4-ntptmp/pri_internal.h?view=diff&rev=947&r1=946&r2=947
==============================================================================
--- team/mattf/libpri-1.4-ntptmp/pri_internal.h (original)
+++ team/mattf/libpri-1.4-ntptmp/pri_internal.h Tue Jul 21 17:11:48 2009
@@ -295,22 +295,29 @@
 
 void __pri_free_tei(struct pri *p);
 
-static inline struct pri * PRI_MASTER(struct pri *pri)
+static inline struct pri * PRI_MASTER(struct pri *mypri)
 {
+	struct pri *pri = mypri;
+
 	while (pri->master)
 		pri = pri->master;
 	return pri;
 }
 
-static inline int BRI_NT_PTMP(struct pri *pri)
+static inline int BRI_NT_PTMP(struct pri *mypri)
 {
+	struct pri *pri;
+
+	pri = PRI_MASTER(mypri);
+
 	return pri->bri && (((pri)->localtype == PRI_NETWORK) && ((pri)->tei == Q921_TEI_GROUP));
 }
 
-static inline int BRI_TE_PTMP(struct pri *pri)
+static inline int BRI_TE_PTMP(struct pri *mypri)
 {
-	while (pri->master)
-		pri = pri->master;
+	struct pri *pri;
+
+	pri = PRI_MASTER(mypri);
 
 	return pri->bri && (((pri)->localtype == PRI_CPE) && ((pri)->tei == Q921_TEI_GROUP));
 }

Modified: team/mattf/libpri-1.4-ntptmp/q921.c
URL: http://svn.asterisk.org/svn-view/libpri/team/mattf/libpri-1.4-ntptmp/q921.c?view=diff&rev=947&r1=946&r2=947
==============================================================================
--- team/mattf/libpri-1.4-ntptmp/q921.c (original)
+++ team/mattf/libpri-1.4-ntptmp/q921.c Tue Jul 21 17:11:48 2009
@@ -560,6 +560,7 @@
 			pri->txqueue = f;
 		/* Immediately transmit unless we're in a recovery state, or the window
 		   size is too big */
+		pri_message(pri, "TEI/SAPI: %d/%d state %d retran %d busy %d\n", pri->tei, pri->sapi, pri->q921_state, pri->retrans, pri->busy);
 		if ((pri->q921_state == Q921_LINK_CONNECTION_ESTABLISHED) && (!pri->retrans && !pri->busy)) {
 			if (pri->windowlen < pri->window) {
 				q921_send_queued_iframes(pri);

Modified: team/mattf/libpri-1.4-ntptmp/q931.c
URL: http://svn.asterisk.org/svn-view/libpri/team/mattf/libpri-1.4-ntptmp/q931.c?view=diff&rev=947&r1=946&r2=947
==============================================================================
--- team/mattf/libpri-1.4-ntptmp/q931.c (original)
+++ team/mattf/libpri-1.4-ntptmp/q931.c Tue Jul 21 17:11:48 2009
@@ -2377,17 +2377,13 @@
 	struct pri *master;
 
 	/* Find the master  - He has the call pool */
-	if (ctrl->master) {
-		master = ctrl->master;
-	} else {
-		master = ctrl;
-	}
+	master = PRI_MASTER(ctrl);
 
 	cur = *master->callpool;
 	prev = NULL;
 	while (cur) {
 		if (cur->cr == cr) {
-			return cur;
+			goto out;
 		}
 		prev = cur;
 		cur = cur->next;
@@ -2411,23 +2407,16 @@
 	cur->ourcallstate = Q931_CALL_STATE_NULL;
 	cur->peercallstate = Q931_CALL_STATE_NULL;
 
-	/* PRI is set to whoever called us */
-	if (ctrl->bri && (ctrl->localtype == PRI_CPE)) {
-		/*
-		 * Point to the master to avoid stale pointer problems if
-		 * the TEI is removed later.
-		 */
-		cur->pri = master;
-	} else {
-		cur->pri = ctrl;
-	}
-
 	/* Append to end of list */
 	if (prev) {
 		prev->next = cur;
 	} else {
 		*master->callpool = cur;
 	}
+
+out:
+	/* PRI is set to whoever called us */
+	cur->pri = ctrl;
 
 	return cur;
 }
@@ -2732,6 +2721,7 @@
 	len = sizeof(buf) - len;
 
 	ctrl = call->pri;
+
 	if (ctrl->bri && (ctrl->localtype == PRI_CPE)) {
 		/*
 		 * Must use the BRI subchannel structure to send with the correct TEI.
@@ -2741,7 +2731,8 @@
 		ctrl = ctrl->subchannel;
 	}
 	if (ctrl) {
-		q931_xmit(ctrl, h, len, 1, (msgtype == Q931_SETUP) ? 1 : 0);
+		pri_message(ctrl, "Sending message for call %p on %p TEI/SAPI %d/%d, call->pri is %p, TEI/SAPI %d/%d\n", call, ctrl, ctrl->tei, ctrl->sapi, call->pri, call->pri->tei, call->pri->sapi);
+		q931_xmit(call->pri, h, len, 1, (msgtype == Q931_SETUP) ? 1 : 0);
 	}
 	call->acked = 1;
 	return 0;
@@ -3317,6 +3308,9 @@
 			q931_release_complete(ctrl,c,cause);
 		break;
 	case Q931_CALL_STATE_CALL_INITIATED:
+		if (BRI_NT_PTMP(ctrl)) {
+
+		}
 		/* we sent SETUP */
 	case Q931_CALL_STATE_OVERLAP_SENDING:
 		/* received SETUP_ACKNOWLEDGE */
@@ -3592,6 +3586,7 @@
 		pri_error(ctrl, "Unable to locate call %d\n", cref);
 		return -1;
 	}
+	pri_message(ctrl, "Received message for call %p on %p TEI/SAPI %d/%d, call->pri is %p TEI/SAPI %d/%d\n", c, ctrl, ctrl->tei, ctrl->sapi, c->pri, c->pri->tei, c->pri->sapi);
 	/* Preliminary handling */
 	if ((h->pd == MAINTENANCE_PROTOCOL_DISCRIMINATOR_1) || (h->pd == MAINTENANCE_PROTOCOL_DISCRIMINATOR_2)) {
 		prepare_to_handle_maintenance_message(ctrl, mh, c);




More information about the svn-commits mailing list