[libpri-commits] rmudgett: branch rmudgett/link_struct r2000 - /team/rmudgett/link_struct/

SVN commits to the libpri project libpri-commits at lists.digium.com
Mon Sep 13 18:15:51 CDT 2010


Author: rmudgett
Date: Mon Sep 13 18:15:47 2010
New Revision: 2000

URL: http://svnview.digium.com/svn/libpri?view=rev&rev=2000
Log:
Merged revisions 1999 via svnmerge from 
https://origsvn.digium.com/svn/libpri/team/rmudgett/link_q931

................
  r1999 | rmudgett | 2010-09-13 17:57:33 -0500 (Mon, 13 Sep 2010) | 30 lines
  
  Merged revisions 1998 via svnmerge from 
  https://origsvn.digium.com/svn/libpri/team/rmudgett/link_q921
  
  ................
    r1998 | rmudgett | 2010-09-13 17:42:46 -0500 (Mon, 13 Sep 2010) | 23 lines
    
    Merged revisions 1994 via svnmerge from 
    https://origsvn.digium.com/svn/libpri/team/rmudgett/issue17865
    
    ................
      r1994 | root | 2010-09-13 17:25:53 -0500 (Mon, 13 Sep 2010) | 16 lines
      
      Merged revisions 1991 via svnmerge from 
      file:///srv/subversion/repos/libpri/branches/1.4
      
      ........
        r1991 | rmudgett | 2010-09-13 16:21:37 -0500 (Mon, 13 Sep 2010) | 9 lines
        
        PRI links do not retain active calls if the link comes back before T309 expires.
        
        The DL-ESTABLISH confirm event was not passed from Q.921 to Q.931 so Q.931
        never cancelled the T309 timer.
        
        Refactored q931_dl_tei_removal() and q931_dl_indication() into
        q931_dl_event() to allow the DL-ESTABLISH confirm/indication and
        DL-RELEASE confirm/indication events to be passed to Q.931.
      ........
    ................
  ................
................

Modified:
    team/rmudgett/link_struct/   (props changed)
    team/rmudgett/link_struct/pri_q931.h
    team/rmudgett/link_struct/q921.c
    team/rmudgett/link_struct/q931.c

Propchange: team/rmudgett/link_struct/
------------------------------------------------------------------------------
    automerge = *

Propchange: team/rmudgett/link_struct/
------------------------------------------------------------------------------
--- issue17865-integrated (original)
+++ issue17865-integrated Mon Sep 13 18:15:47 2010
@@ -1,1 +1,1 @@
-/branches/1.4:1-1983
+/branches/1.4:1-1993

Propchange: team/rmudgett/link_struct/
------------------------------------------------------------------------------
--- link_q921-integrated (original)
+++ link_q921-integrated Mon Sep 13 18:15:47 2010
@@ -1,1 +1,1 @@
-/team/rmudgett/issue17865:1-1984
+/team/rmudgett/issue17865:1-1997

Propchange: team/rmudgett/link_struct/
------------------------------------------------------------------------------
--- link_q931-integrated (original)
+++ link_q931-integrated Mon Sep 13 18:15:47 2010
@@ -1,1 +1,1 @@
-/team/rmudgett/link_q921:1-1995
+/team/rmudgett/link_q921:1-1998

Propchange: team/rmudgett/link_struct/
------------------------------------------------------------------------------
--- link_struct-integrated (original)
+++ link_struct-integrated Mon Sep 13 18:15:47 2010
@@ -1,1 +1,1 @@
-/team/rmudgett/link_q931:1-1996
+/team/rmudgett/link_q931:1-1999

Modified: team/rmudgett/link_struct/pri_q931.h
URL: http://svnview.digium.com/svn/libpri/team/rmudgett/link_struct/pri_q931.h?view=diff&rev=2000&r1=1999&r2=2000
==============================================================================
--- team/rmudgett/link_struct/pri_q931.h (original)
+++ team/rmudgett/link_struct/pri_q931.h Mon Sep 13 18:15:47 2010
@@ -502,8 +502,15 @@
 
 void q931_destroycall(struct pri *pri, q931_call *c);
 
-void q931_dl_tei_removal(struct pri *link);
-void q931_dl_indication(struct pri *link, int event);
+enum Q931_DL_EVENT {
+	Q931_DL_EVENT_NONE,
+	Q931_DL_EVENT_DL_ESTABLISH_IND,
+	Q931_DL_EVENT_DL_ESTABLISH_CONFIRM,
+	Q931_DL_EVENT_DL_RELEASE_IND,
+	Q931_DL_EVENT_DL_RELEASE_CONFIRM,
+	Q931_DL_EVENT_TEI_REMOVAL,
+};
+void q931_dl_event(struct pri *link, enum Q931_DL_EVENT event);
 
 int q931_send_hold(struct pri *ctrl, struct q931_call *call);
 int q931_send_hold_ack(struct pri *ctrl, struct q931_call *call);

Modified: team/rmudgett/link_struct/q921.c
URL: http://svnview.digium.com/svn/libpri/team/rmudgett/link_struct/q921.c?view=diff&rev=2000&r1=1999&r2=2000
==============================================================================
--- team/rmudgett/link_struct/q921.c (original)
+++ team/rmudgett/link_struct/q921.c Mon Sep 13 18:15:47 2010
@@ -221,7 +221,7 @@
 		case Q921_ESTABLISH_AWAITING_TEI:
 			q921_discard_iqueue(link);
 			/* DL-RELEASE indication */
-			q931_dl_indication(link, PRI_EVENT_DCHAN_DOWN);
+			q931_dl_event(link, Q931_DL_EVENT_DL_RELEASE_IND);
 			break;
 		default:
 			break;
@@ -721,7 +721,7 @@
 			q921_mdl_error(link, 'G');
 			q921_setstate(link, Q921_TEI_ASSIGNED);
 			/* DL-RELEASE indication */
-			q931_dl_indication(link, PRI_EVENT_DCHAN_DOWN);
+			q931_dl_event(link, Q931_DL_EVENT_DL_RELEASE_IND);
 		}
 		break;
 	case Q921_AWAITING_RELEASE:
@@ -732,6 +732,7 @@
 		} else {
 			q921_mdl_error(link, 'H');
 			/* DL-RELEASE confirm */
+			q931_dl_event(link, Q931_DL_EVENT_DL_RELEASE_CONFIRM);
 			q921_setstate(link, Q921_TEI_ASSIGNED);
 		}
 		break;
@@ -1348,7 +1349,7 @@
 {
 	pri_event *res = NULL;
 	struct pri *ctrl;
-	int delay_q931_dl_indication;
+	enum Q931_DL_EVENT delay_q931_dl_event;
 
 	ctrl = PRI_MASTER(link);
 
@@ -1363,17 +1364,17 @@
 		if (link->v_s != link->v_a) {
 			q921_discard_iqueue(link);
 			/* DL-ESTABLISH indication */
-			delay_q931_dl_indication = 1;
+			delay_q931_dl_event = Q931_DL_EVENT_DL_ESTABLISH_IND;
 		} else {
-			delay_q931_dl_indication = 0;
+			delay_q931_dl_event = Q931_DL_EVENT_NONE;
 		}
 		stop_t200(link);
 		start_t203(link);
 		link->v_s = link->v_a = link->v_r = 0;
 		q921_setstate(link, Q921_MULTI_FRAME_ESTABLISHED);
-		if (delay_q931_dl_indication) {
+		if (delay_q931_dl_event != Q931_DL_EVENT_NONE) {
 			/* Delayed because Q.931 could send STATUS messages. */
-			q931_dl_indication(link, PRI_EVENT_DCHAN_UP);
+			q931_dl_event(link, delay_q931_dl_event);
 		}
 		break;
 	case Q921_TEI_ASSIGNED:
@@ -1381,17 +1382,16 @@
 		q921_clear_exception_conditions(link);
 		link->v_s = link->v_a = link->v_r = 0;
 		/* DL-ESTABLISH indication */
-		//delay_q931_dl_indication = 1;
+		delay_q931_dl_event = Q931_DL_EVENT_DL_ESTABLISH_IND;
 		if (PTP_MODE(ctrl)) {
 			ctrl->ev.gen.e = PRI_EVENT_DCHAN_UP;
 			res = &ctrl->ev;
 		}
 		start_t203(link);
 		q921_setstate(link, Q921_MULTI_FRAME_ESTABLISHED);
-		//if (delay_q931_dl_indication)
-		{
+		if (delay_q931_dl_event != Q931_DL_EVENT_NONE) {
 			/* Delayed because Q.931 could send STATUS messages. */
-			q931_dl_indication(link, PRI_EVENT_DCHAN_UP);
+			q931_dl_event(link, delay_q931_dl_event);
 		}
 		break;
 	case Q921_AWAITING_ESTABLISHMENT:
@@ -1433,7 +1433,7 @@
 		q921_discard_iqueue(link);
 		q921_send_ua(link, h->u.p_f);
 		/* DL-RELEASE indication */
-		q931_dl_indication(link, PRI_EVENT_DCHAN_DOWN);
+		q931_dl_event(link, Q931_DL_EVENT_DL_RELEASE_IND);
 		stop_t200(link);
 		if (link->q921_state == Q921_MULTI_FRAME_ESTABLISHED)
 			stop_t203(link);
@@ -1478,20 +1478,21 @@
 	case Q921_AWAITING_ESTABLISHMENT:
 		q921_discard_iqueue(link);
 		/* DL-RELEASE indication */
-		q931_dl_indication(link, PRI_EVENT_DCHAN_DOWN);
+		q931_dl_event(link, Q931_DL_EVENT_DL_RELEASE_IND);
 		stop_t200(link);
 		q921_setstate(link, Q921_TEI_UNASSIGNED);
 		break;
 	case Q921_AWAITING_RELEASE:
 		q921_discard_iqueue(link);
 		/* DL-RELEASE confirm */
+		q931_dl_event(link, Q931_DL_EVENT_DL_RELEASE_CONFIRM);
 		stop_t200(link);
 		q921_setstate(link, Q921_TEI_UNASSIGNED);
 		break;
 	case Q921_MULTI_FRAME_ESTABLISHED:
 		q921_discard_iqueue(link);
 		/* DL-RELEASE indication */
-		q931_dl_indication(link, PRI_EVENT_DCHAN_DOWN);
+		q931_dl_event(link, Q931_DL_EVENT_DL_RELEASE_IND);
 		stop_t200(link);
 		stop_t203(link);
 		q921_setstate(link, Q921_TEI_UNASSIGNED);
@@ -1499,7 +1500,7 @@
 	case Q921_TIMER_RECOVERY:
 		q921_discard_iqueue(link);
 		/* DL-RELEASE indication */
-		q931_dl_indication(link, PRI_EVENT_DCHAN_DOWN);
+		q931_dl_event(link, Q931_DL_EVENT_DL_RELEASE_IND);
 		stop_t200(link);
 		q921_setstate(link, Q921_TEI_UNASSIGNED);
 		break;
@@ -1509,7 +1510,7 @@
 		return;
 	}
 
-	q931_dl_tei_removal(link);
+	q931_dl_event(link, Q931_DL_EVENT_TEI_REMOVAL);
 
 	/*
 	 * Negate the TEI value so debug messages will display a
@@ -1807,7 +1808,7 @@
 {
 	struct pri *ctrl;
 	pri_event *res = NULL;
-	int delay_q931_dl_indication;
+	enum Q931_DL_EVENT delay_q931_dl_event;
 
 	ctrl = PRI_MASTER(link);
 
@@ -1831,16 +1832,17 @@
 			break;
 		}
 
-		delay_q931_dl_indication = 0;
+		delay_q931_dl_event = Q931_DL_EVENT_NONE;
 		if (!link->l3initiated) {
 			if (link->v_s != link->v_a) {
 				q921_discard_iqueue(link);
 				/* DL-ESTABLISH indication */
-				delay_q931_dl_indication = 1;
+				delay_q931_dl_event = Q931_DL_EVENT_DL_ESTABLISH_IND;
 			}
 		} else {
 			link->l3initiated = 0;
 			/* DL-ESTABLISH confirm */
+			delay_q931_dl_event = Q931_DL_EVENT_DL_ESTABLISH_CONFIRM;
 		}
 
 		if (PTP_MODE(ctrl)) {
@@ -1854,9 +1856,9 @@
 		link->v_r = link->v_s = link->v_a = 0;
 
 		q921_setstate(link, Q921_MULTI_FRAME_ESTABLISHED);
-		if (delay_q931_dl_indication) {
+		if (delay_q931_dl_event != Q931_DL_EVENT_NONE) {
 			/* Delayed because Q.931 could send STATUS messages. */
-			q931_dl_indication(link, PRI_EVENT_DCHAN_UP);
+			q931_dl_event(link, delay_q931_dl_event);
 		}
 		break;
 	case Q921_AWAITING_RELEASE:
@@ -1864,6 +1866,7 @@
 			q921_mdl_error(link, 'D');
 		} else {
 			/* DL-RELEASE confirm */
+			q931_dl_event(link, Q931_DL_EVENT_DL_RELEASE_CONFIRM);
 			stop_t200(link);
 			q921_setstate(link, Q921_TEI_ASSIGNED);
 		}
@@ -2307,7 +2310,7 @@
 
 		q921_discard_iqueue(link);
 		/* DL-RELEASE indication */
-		q931_dl_indication(link, PRI_EVENT_DCHAN_DOWN);
+		q931_dl_event(link, Q931_DL_EVENT_DL_RELEASE_IND);
 		stop_t200(link);
 		q921_setstate(link, Q921_TEI_ASSIGNED);
 		q921_restart_ptp_link_if_needed(link);
@@ -2316,6 +2319,7 @@
 		if (!h->u.p_f)
 			break;
 		/* DL-RELEASE confirm */
+		q931_dl_event(link, Q931_DL_EVENT_DL_RELEASE_CONFIRM);
 		stop_t200(link);
 		q921_setstate(link, Q921_TEI_ASSIGNED);
 		break;

Modified: team/rmudgett/link_struct/q931.c
URL: http://svnview.digium.com/svn/libpri/team/rmudgett/link_struct/q931.c?view=diff&rev=2000&r1=1999&r2=2000
==============================================================================
--- team/rmudgett/link_struct/q931.c (original)
+++ team/rmudgett/link_struct/q931.c Mon Sep 13 18:15:47 2010
@@ -8374,99 +8374,125 @@
 }
 
 /*!
- * \brief Layer 2 is removing the link's TEI.
- *
- * \param link Q.921 link losing it's TEI.
- *
- * \note
- * For NT PTMP, this deviation from the specifications is needed
- * because we have no way to re-associate any T309 calls on the
- * removed TEI.
+ * \internal
+ * \brief Convert the DL event to a string.
+ *
+ * \param event Data-link event to convert to a string.
+ *
+ * \return DL event string
+ */
+static const char *q931_dl_event2str(enum Q931_DL_EVENT event)
+{
+	const char *str;
+
+	str = "Unknown";
+	switch (event) {
+	case Q931_DL_EVENT_NONE:
+		str = "Q931_DL_EVENT_NONE";
+		break;
+	case Q931_DL_EVENT_DL_ESTABLISH_IND:
+		str = "Q931_DL_EVENT_DL_ESTABLISH_IND";
+		break;
+	case Q931_DL_EVENT_DL_ESTABLISH_CONFIRM:
+		str = "Q931_DL_EVENT_DL_ESTABLISH_CONFIRM";
+		break;
+	case Q931_DL_EVENT_DL_RELEASE_IND:
+		str = "Q931_DL_EVENT_DL_RELEASE_IND";
+		break;
+	case Q931_DL_EVENT_DL_RELEASE_CONFIRM:
+		str = "Q931_DL_EVENT_DL_RELEASE_CONFIRM";
+		break;
+	case Q931_DL_EVENT_TEI_REMOVAL:
+		str = "Q931_DL_EVENT_TEI_REMOVAL";
+		break;
+	}
+	return str;
+}
+
+/*!
+ * \brief Receive a DL event from layer 2.
+ *
+ * \param link Q.921 link event occurred on.
+ * \param event Data-link event reporting.
  *
  * \return Nothing
  */
-void q931_dl_tei_removal(struct pri *link)
+void q931_dl_event(struct pri *link, enum Q931_DL_EVENT event)
 {
 	struct q931_call *cur;
 	struct q931_call *call;
 	struct pri *ctrl;
 	int idx;
 
+	if (!link) {
+		return;
+	}
+
 	/* Find the master - He has the call pool */
 	ctrl = PRI_MASTER(link);
 
 	if (ctrl->debug & PRI_DEBUG_Q931_STATE) {
-		pri_message(ctrl, "DL TEI removal\n");
-	}
-
-	if (!BRI_NT_PTMP(ctrl)) {
-		/* Only NT PTMP has anything to worry about when the TEI is removed. */
-		return;
-	}
-
-	for (cur = *ctrl->callpool; cur; cur = cur->next) {
-		if (!(cur->cr & ~Q931_CALL_REFERENCE_FLAG)) {
-			/* Don't do anything on the global call reference call record. */
-			continue;
-		}
-		if (cur->outboundbroadcast) {
-			/* Does this master call have a subcall on the link that went down? */
-			call = NULL;
-			for (idx = 0; idx < ARRAY_LEN(cur->subcalls); ++idx) {
-				if (cur->subcalls[idx] && cur->subcalls[idx]->link == link) {
-					/* This subcall is on the link that went down. */
-					call = cur->subcalls[idx];
-					break;
+		pri_message(ctrl, "TEI=%d DL event: %s(%d)\n", link->tei,
+			q931_dl_event2str(event), event);
+	}
+
+	switch (event) {
+	case Q931_DL_EVENT_TEI_REMOVAL:
+		if (!BRI_NT_PTMP(ctrl)) {
+			/* Only NT PTMP has anything to worry about when the TEI is removed. */
+			break;
+		}
+
+		/*
+		 * For NT PTMP, this deviation from the specifications is needed
+		 * because we have no way to re-associate any T309 calls on the
+		 * removed TEI.
+		 */
+		for (cur = *ctrl->callpool; cur; cur = cur->next) {
+			if (!(cur->cr & ~Q931_CALL_REFERENCE_FLAG)) {
+				/* Don't do anything on the global call reference call record. */
+				continue;
+			}
+			if (cur->outboundbroadcast) {
+				/* Does this master call have a subcall on the link that went down? */
+				call = NULL;
+				for (idx = 0; idx < ARRAY_LEN(cur->subcalls); ++idx) {
+					if (cur->subcalls[idx] && cur->subcalls[idx]->link == link) {
+						/* This subcall is on the link that went down. */
+						call = cur->subcalls[idx];
+						break;
+					}
 				}
-			}
-			if (!call) {
-				/* No subcall is on the link that went down. */
+				if (!call) {
+					/* No subcall is on the link that went down. */
+					continue;
+				}
+			} else if (cur->link != link) {
+				/* This call is not on the link that went down. */
 				continue;
-			}
-		} else if (cur->link != link) {
-			/* This call is not on the link that went down. */
-			continue;
-		} else {
-			call = cur;
-		}
-
-		/*
-		 * NOTE:  We are gambling that no T309 timer's have had a chance
-		 * to expire.  They should not expire since we are either called
-		 * immediately after the q931_dl_indication() or after a timeout
-		 * of 0.
-		 */
-		if (ctrl->debug & PRI_DEBUG_Q931_STATE) {
-			pri_message(ctrl, "Cancel call cref=%d on channel %d in state %d (%s)\n",
-				call->cr, call->channelno, call->ourcallstate,
-				q931_call_state_str(call->ourcallstate));
-		}
-		call->link = NULL;
-		pri_schedule_del(ctrl, call->retranstimer);
-		call->retranstimer = pri_schedule_event(ctrl, 0, pri_dl_down_cancelcall, call);
-	}
-}
-
-/* Receive an indication from Layer 2 */
-void q931_dl_indication(struct pri *link, int event)
-{
-	struct q931_call *cur;
-	struct q931_call *call;
-	struct pri *ctrl;
-	int idx;
-
-	if (!link) {
-		return;
-	}
-
-	/* Find the master - He has the call pool */
-	ctrl = PRI_MASTER(link);
-
-	switch (event) {
-	case PRI_EVENT_DCHAN_DOWN:
-		if (ctrl->debug & PRI_DEBUG_Q931_STATE) {
-			pri_message(ctrl, "DL-RELEASE indication (link is DOWN)\n");
-		}
+			} else {
+				call = cur;
+			}
+
+			/*
+			 * NOTE:  We are gambling that no T309 timer's have had a chance
+			 * to expire.  They should not expire since we are either called
+			 * immediately after the Q931_DL_EVENT_DL_RELEASE_xxx or after a
+			 * timeout of 0.
+			 */
+			if (ctrl->debug & PRI_DEBUG_Q931_STATE) {
+				pri_message(ctrl, "Cancel call cref=%d on channel %d in state %d (%s)\n",
+					call->cr, call->channelno, call->ourcallstate,
+					q931_call_state_str(call->ourcallstate));
+			}
+			call->link = NULL;
+			pri_schedule_del(ctrl, call->retranstimer);
+			call->retranstimer = pri_schedule_event(ctrl, 0, pri_dl_down_cancelcall,
+				call);
+		}
+		break;
+	case Q931_DL_EVENT_DL_RELEASE_IND:
+	case Q931_DL_EVENT_DL_RELEASE_CONFIRM:
 		for (cur = *ctrl->callpool; cur; cur = cur->next) {
 			if (!(cur->cr & ~Q931_CALL_REFERENCE_FLAG)) {
 				/* Don't do anything on the global call reference call record. */
@@ -8547,10 +8573,8 @@
 			}
 		}
 		break;
-	case PRI_EVENT_DCHAN_UP:
-		if (ctrl->debug & PRI_DEBUG_Q931_STATE) {
-			pri_message(ctrl, "DL-ESTABLISH indication (link is UP)\n");
-		}
+	case Q931_DL_EVENT_DL_ESTABLISH_IND:
+	case Q931_DL_EVENT_DL_ESTABLISH_CONFIRM:
 		for (cur = *ctrl->callpool; cur; cur = cur->next) {
 			if (!(cur->cr & ~Q931_CALL_REFERENCE_FLAG)) {
 				/* Don't do anything on the global call reference call record. */
@@ -8595,6 +8619,14 @@
 			case Q931_CALL_STATE_RELEASE_REQUEST:
 				break;
 			default:
+				if (event == Q931_DL_EVENT_DL_ESTABLISH_CONFIRM) {
+					/*
+					 * Lets not send a STATUS message for this call as we
+					 * requested the link to be established as a likely
+					 * result of this call.
+					 */
+					break;
+				}
 				/*
 				 * The STATUS message sent here is not required by Q.931,
 				 * but it may help anyway.




More information about the libpri-commits mailing list