[svn-commits] rmudgett: mISDNuser/trunk r113 - /mISDNuser/trunk/i4lnet/tei.c

SVN commits to the Digium repositories svn-commits at lists.digium.com
Wed May 13 11:21:21 CDT 2009


Author: rmudgett
Date: Wed May 13 11:21:18 2009
New Revision: 113

URL: http://svn.asterisk.org/svn-view/thirdparty?view=rev&rev=113
Log:
Improve TEI recovery as described in Q.921 section 5.3 when all TEI's are exhausted.

tei-check2.patch
This patch will only send an identity check request for the group-TEI (127)
instead of 63 separate messages, which is more efficient.

How it works: all L2 entity TEI state machines change to ST_TEI_IDVERIFY
without sending a check request msg, so they can react to the id check
responses.  Then the id check request is started for the L2 entity with
TEI 127.

TE's may answer with more than one Ai in the id check response, so take
care of this too.

tei-check3.patch
It is not necessary to actually send an ID remove for the TEI's that
get no check response.  Sending this is left out when the check request
is done for TEI 127.

Patches:
    tei-check2.patch file uploaded by customer (with minor cosmetic changes).
    tei-check3.patch file uploaded by customer (with minor cosmetic changes).

JIRA ABE-1865

Modified:
    mISDNuser/trunk/i4lnet/tei.c

Modified: mISDNuser/trunk/i4lnet/tei.c
URL: http://svn.asterisk.org/svn-view/thirdparty/mISDNuser/trunk/i4lnet/tei.c?view=diff&rev=113&r1=112&r2=113
==============================================================================
--- mISDNuser/trunk/i4lnet/tei.c (original)
+++ mISDNuser/trunk/i4lnet/tei.c Wed May 13 11:21:18 2009
@@ -89,16 +89,17 @@
 }
 
 static void
-check_all_tei(net_stack_t *nst)
+check_all_tei(net_stack_t *nst, layer2_t *l2_127)
 {
 	layer2_t *l2;
 
 	l2 = nst->layer2;
 	while (l2) {
 		if (l2->tei >= 64 && l2->tei < 127)
-			FsmEvent(&l2->tm->tei_m, EV_VERIFY, &l2->tei);
+			FsmEvent(&l2->tm->tei_m, EV_VERIFY, &l2_127->tei);
 		l2 = l2->next;
 	}
+	FsmEvent(&l2_127->tm->tei_m, EV_VERIFY, &l2_127->tei);
 }
 
 unsigned int
@@ -208,15 +209,18 @@
 tei_id_verify(struct FsmInst *fi, int event, void *arg)
 {
 	teimgr_t *tm = fi->userdata;
+	int tei = *(int *) arg;
 
 	if (tm->debug)
 		tm->tei_m.printdebug(fi, "id verify request for tei %d",
 			tm->l2->tei);
 	tm->ri = -1;
-	put_tei_msg(tm, ID_CHK_REQ, 0, tm->l2->tei);
+	/* (don't send specific tei check msg if check is requested for 127) */
+	if (tei == tm->l2->tei)
+		put_tei_msg(tm, ID_CHK_REQ, 0, tm->l2->tei);
 	FsmChangeState(&tm->tei_m, ST_TEI_IDVERIFY);
 	test_and_set_bit(FLG_TEI_T201_1, &tm->l2->flag);
-	FsmAddTimer(&tm->t201, tm->T201, EV_T201, NULL, 2);
+	FsmAddTimer(&tm->t201, tm->T201, EV_T201, (void *) tei, 2);
 }
 
 static void
@@ -238,21 +242,31 @@
 tei_id_ver_tout(struct FsmInst *fi, int event, void *arg)
 {
 	teimgr_t *tm = fi->userdata;
+	int tei = (int) arg;
 
 	if (tm->debug)
 		tm->tei_m.printdebug(fi, "verify tout tei %d",
 			tm->l2->tei);
 	if (test_and_clear_bit(FLG_TEI_T201_1, &tm->l2->flag)) {
-		put_tei_msg(tm, ID_CHK_REQ, 0, tm->l2->tei);
+		/* (don't send specific tei check msg if check is requested for 127) */
+		if (tei == tm->l2->tei)
+			put_tei_msg(tm, ID_CHK_REQ, 0, tm->l2->tei);
 		tm->ri = -1;
-		FsmAddTimer(&tm->t201, tm->T201, EV_T201, NULL, 3);
+		FsmAddTimer(&tm->t201, tm->T201, EV_T201, (void *) tei, 3);
 	} else {
 		FsmChangeState(fi, ST_TEI_NOP);
+		if (tm->l2->tei == 127)
+			return;
 		if (tm->ri == -1) {
 			tm->tei_m.printdebug(fi, "tei %d check no response",
 				tm->l2->tei);
 			/* remove tei and release l2 to recover this TEI */
-			FsmEvent(&tm->tei_m, EV_REMOVE, &tm->l2->tei);
+			if (tei == tm->l2->tei)
+				/* specific TEI check */
+				FsmEvent(&tm->tei_m, EV_REMOVE, &tm->l2->tei);
+			else
+				/* recovery, TEI is not assigned, no need to remove it */
+				release_l2(tm->l2);
 		} else
 			tm->tei_m.printdebug(fi, "tei %d check ok",
 				tm->l2->tei);
@@ -384,7 +398,7 @@
 		ri = ((unsigned int) *dp++ << 8);
 		ri += *dp++;
 		mt = *dp++;
-		ai = (unsigned int) *dp++;
+		ai = (unsigned int) *dp;
 		ai >>= 1;
 		dprint(DBGM_TEI, -1, "tei handler mt %x ri(%x) ai(%d)\n",
 			mt, ri, ai);
@@ -407,7 +421,7 @@
 				 * Start a TEI check for all l2's that have one.  This will
 				 * eventually remove a TEI and the next request will succeed.
 				 */
-				check_all_tei(nst);
+				check_all_tei(nst, l2);
 				free_msg(msg);
 				return(0);
 			}
@@ -416,8 +430,8 @@
 			free_msg(msg);
 			return(0);
 		}
-		l2 = find_tei(nst, ai);
 		if (mt == ID_VERIFY) {
+			l2 = find_tei(nst, ai);
 			if (l2) {
 				FsmEvent(&l2->tm->tei_m, EV_VERIFY, &ai);
 			} else {
@@ -429,15 +443,23 @@
 				FsmEvent(&l2->tm->tei_m, EV_REMOVE, &ai);
 			}
 		} else if (mt == ID_CHK_RES) {
-			if (l2) {
-				FsmEvent(&l2->tm->tei_m, EV_CHECK_RES, &ri);
-			} else {
-				l2 = find_tei(nst, 127);
-				if (!l2) {
-					wprint("%s: no 127 manager\n", __FUNCTION__);
-					return(-EINVAL);
+			for (;;) {
+				l2 = find_tei(nst, ai);
+				if (l2) {
+					FsmEvent(&l2->tm->tei_m, EV_CHECK_RES, &ri);
+				} else {
+					l2 = find_tei(nst, 127);
+					if (!l2) {
+						wprint("%s: no 127 manager\n", __FUNCTION__);
+						return(-EINVAL);
+					}
+					FsmEvent(&l2->tm->tei_m, EV_REMOVE, &ai);
 				}
-				FsmEvent(&l2->tm->tei_m, EV_REMOVE, &ai);
+				if (*dp++ & 0x01)
+					/* final Ai */
+					break;
+				ai = (unsigned int) *dp;
+				ai >>= 1;
 			}
 		} else {
 			wprint("%s: wrong mt %x", __FUNCTION__, mt);




More information about the svn-commits mailing list