[Pkg-voip-commits] r1147 - in libpri/trunk/debian: . patches

Tzafrir Cohen tzafrir-guest at costa.debian.org
Sat Jan 7 22:51:01 UTC 2006


Author: tzafrir-guest
Date: 2006-01-07 22:50:56 +0000 (Sat, 07 Jan 2006)
New Revision: 1147

Modified:
   libpri/trunk/debian/changelog
   libpri/trunk/debian/patches/bristuff.dpatch
Log:
bristuff 0.3.0-PRE-1f

Modified: libpri/trunk/debian/changelog
===================================================================
--- libpri/trunk/debian/changelog	2006-01-07 22:49:39 UTC (rev 1146)
+++ libpri/trunk/debian/changelog	2006-01-07 22:50:56 UTC (rev 1147)
@@ -1,3 +1,9 @@
+libpri (1.2.1-3) UNRELEASED; urgency=low
+
+  * bristuff 0.3.0-PRE-1f
+
+ -- Tzafrir Cohen <tzafrir.cohens at xorcom.com>  Sat,  7 Jan 2006 20:12:41 +0200
+
 libpri (1.2.1-2) unstable; urgency=low
 
   * bristuff 0.3.0-PRE-1d

Modified: libpri/trunk/debian/patches/bristuff.dpatch
===================================================================
--- libpri/trunk/debian/patches/bristuff.dpatch	2006-01-07 22:49:39 UTC (rev 1146)
+++ libpri/trunk/debian/patches/bristuff.dpatch	2006-01-07 22:50:56 UTC (rev 1147)
@@ -2,10 +2,9 @@
 ## bristuff.dpatch by Tzafrir Cohen <tzafrir.cohen at xorcom.com>
 ##
 ## All lines beginning with `## DP:' are a description of the patch.
-## DP: The libpri part of bristuff, version 0.3.0-PRE-1d
+## DP: The libpri part of bristuff, version 0.3.0-PRE-1f
 
 @DPATCH@
-diff -urN libpri-1.2.1.orig/README libpri-1.2.1/README
 --- libpri-1.2.1.orig/README	2005-11-29 19:39:18.000000000 +0100
 +++ libpri-1.2.1/README	2005-06-13 09:02:39.000000000 +0200
 @@ -1,6 +1,7 @@
@@ -329,14 +328,6 @@
  /* Set CRV reference for GR-303 calls */
  
  
-@@ -525,7 +644,6 @@
- #define PRI_USER_USER_TX
- /* Set the user user field.  Warning!  don't send binary data accross this field */
- extern void pri_sr_set_useruser(struct pri_sr *sr, char *userchars);
--
- extern void pri_call_set_useruser(q931_call *sr, char *userchars);
- 
- extern int pri_setup(struct pri *pri, q931_call *call, struct pri_sr *req);
 @@ -546,8 +664,8 @@
  
  /* Override message and error stuff */
@@ -695,6 +686,43 @@
 diff -urN libpri-1.2.1.orig/pri_facility.c libpri-1.2.1/pri_facility.c
 --- libpri-1.2.1.orig/pri_facility.c	2005-11-29 19:39:18.000000000 +0100
 +++ libpri-1.2.1/pri_facility.c	2005-11-20 15:58:10.000000000 +0100
+@@ -1,26 +1,13 @@
+-/*
+- * libpri: An implementation of Primary Rate ISDN
+- *
+- * Written by Matthew Fredrickson <creslin at digium.com>
+- *
+- * Copyright (C) 2004-2005, Digium
+- * All Rights Reserved.
+- *
+- * This program is free software; you can redistribute it and/or modify
+- * it under the terms of the GNU General Public License as published by
+- * the Free Software Foundation; either version 2 of the License, or
+- * (at your option) any later version.
+- * 
+- * This program is distributed in the hope that it will be useful,
+- * but WITHOUT ANY WARRANTY; without even the implied warranty of
+- * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
+- * GNU General Public License for more details.
+- * 
+- * You should have received a copy of the GNU General Public License
+- * along with this program; if not, write to the Free Software
+- * Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA. 
+- *
+- */
++/* 
++   This file and it's contents are licensed under the terms and conditions
++   of the GNU Public License.  See http://www.gnu.org for details.
++   
++   Routines for dealing with facility messages and their respective
++   components (ROSE)
++
++   by Matthew Fredrickson <creslin at digium.com>
++   Copyright (C) 2004-2005 Digium, Inc
++*/
+ 
+ #include "compat.h"
+ #include "libpri.h"
 @@ -208,9 +195,9 @@
  	if (datalen > buflen) {
  		/* Truncate */
@@ -1090,7 +1118,7 @@
  #endif /* _PRI_FACILITY_H */
 diff -urN libpri-1.2.1.orig/pri_internal.h libpri-1.2.1/pri_internal.h
 --- libpri-1.2.1.orig/pri_internal.h	2005-11-29 19:39:18.000000000 +0100
-+++ libpri-1.2.1/pri_internal.h	2005-11-20 15:38:47.000000000 +0100
++++ libpri-1.2.1/pri_internal.h	2006-01-04 13:13:12.000000000 +0100
 @@ -30,7 +30,10 @@
  struct pri_sched {
  	struct timeval when;
@@ -1126,7 +1154,7 @@
  	int state;			/* State of D-channel */
  	int switchtype;		/* Switch type */
  	int nsf;		/* Network-Specific Facility (if any) */
-@@ -62,25 +73,39 @@
+@@ -62,25 +73,42 @@
  	int protodisc;
  	
  	/* Q.921 State */
@@ -1146,6 +1174,9 @@
 +  	
 +  	/* TEI registry */
 +      	char q921_teis[Q921_MAX_TEIS];
++
++      	char q921_tei_check[Q921_MAX_TEIS];
++      	unsigned short q921_tei_check_ri[Q921_MAX_TEIS];
 +   	
 +  	unsigned int ri; 
 +  
@@ -1183,7 +1214,7 @@
  	/* All ISDN Timer values */
  	int timers[MAX_TIMERS];
  
-@@ -89,8 +114,8 @@
+@@ -89,8 +117,8 @@
  	int schedev;
  	pri_event ev;		/* Static event thingy */
  	
@@ -1194,7 +1225,7 @@
  	
  	/* Q.931 calls */
  	q931_call **callpool;
-@@ -109,6 +134,9 @@
+@@ -109,6 +137,9 @@
  
  	unsigned char last_invoke;	/* Last ROSE invoke ID */
  	unsigned char sendfacility;
@@ -1204,7 +1235,7 @@
  };
  
  struct pri_sr {
-@@ -118,6 +146,7 @@
+@@ -118,6 +149,7 @@
  	int nonisdn;
  	char *caller;
  	int callerplan;
@@ -1212,7 +1243,7 @@
  	char *callername;
  	int callerpres;
  	char *called;
-@@ -169,6 +198,10 @@
+@@ -169,6 +201,10 @@
  	int acked;			/* Whether setup has been acked or not */
  	int sendhangupack;	/* Whether or not to send a hangup ack */
  	int proc;			/* Whether we've sent a call proceeding / alerting */
@@ -1223,7 +1254,7 @@
  	
  	int ri;				/* Restart Indicator (Restart Indicator IE) */
  
-@@ -202,15 +235,18 @@
+@@ -202,15 +238,18 @@
  	int callerplan;
  	int callerplanani;
  	int callerpres;			/* Caller presentation */
@@ -1246,7 +1277,7 @@
  	int nonisdn;
  	char callednum[256];	/* Called Number */
  	int complete;			/* no more digits coming */
-@@ -225,16 +261,27 @@
+@@ -225,16 +264,27 @@
  	char redirectingnum[256];	/* Number of redirecting party */
  	char redirectingname[256];	/* Name of redirecting party */
  
@@ -1277,7 +1308,7 @@
  	
  	long aoc_units;				/* Advice of Charge Units */
  
-@@ -242,6 +289,7 @@
+@@ -242,6 +292,7 @@
  };
  
  extern int pri_schedule_event(struct pri *pri, int ms, void (*function)(void *data), void *data);
@@ -1285,7 +1316,7 @@
  
  extern pri_event *pri_schedule_run(struct pri *pri);
  
-@@ -250,7 +298,7 @@
+@@ -250,7 +301,7 @@
  extern pri_event *pri_mkerror(struct pri *pri, char *errstr);
  
  extern void pri_message(struct pri *pri, char *fmt, ...);
@@ -1409,7 +1440,7 @@
  #endif
 diff -urN libpri-1.2.1.orig/pri_timers.h libpri-1.2.1/pri_timers.h
 --- libpri-1.2.1.orig/pri_timers.h	2005-11-29 19:39:18.000000000 +0100
-+++ libpri-1.2.1/pri_timers.h	2005-06-13 09:02:39.000000000 +0200
++++ libpri-1.2.1/pri_timers.h	2006-01-04 12:57:32.000000000 +0100
 @@ -27,17 +27,17 @@
  
  /* -1 means we dont currently support the timer/counter */
@@ -1433,21 +1464,6 @@
  				-1,	/* T304 */ \
  				30000,	/* T305 */ \
  				-1,	/* T306 */ \
-diff -urN libpri-1.2.1.orig/pridump.c libpri-1.2.1/pridump.c
---- libpri-1.2.1.orig/pridump.c	2005-11-29 19:39:18.000000000 +0100
-+++ libpri-1.2.1/pridump.c	2005-11-20 15:10:20.000000000 +0100
-@@ -1,9 +1,9 @@
- /*
-  * libpri: An implementation of Primary Rate ISDN
-  *
-- * Written by Mark Spencer <markster at digium.com>
-+ * Written by Mark Spencer <markster at linux-support.net>
-  *
-- * Copyright (C) 2001-2005, Digium
-+ * Copyright (C) 2001, Linux Support Services, Inc.
-  * All Rights Reserved.
-  *
-  * This program is free software; you can redistribute it and/or modify
 diff -urN libpri-1.2.1.orig/prisched.c libpri-1.2.1/prisched.c
 --- libpri-1.2.1.orig/prisched.c	2005-11-29 19:39:18.000000000 +0100
 +++ libpri-1.2.1/prisched.c	2005-06-13 09:02:39.000000000 +0200
@@ -1623,7 +1639,7 @@
  	}
 diff -urN libpri-1.2.1.orig/q921.c libpri-1.2.1/q921.c
 --- libpri-1.2.1.orig/q921.c	2005-12-06 22:35:50.000000000 +0100
-+++ libpri-1.2.1/q921.c	2005-07-25 16:53:22.000000000 +0200
++++ libpri-1.2.1/q921.c	2006-01-04 15:50:03.000000000 +0100
 @@ -1,10 +1,12 @@
  /*
   * libpri: An implementation of Primary Rate ISDN
@@ -1726,7 +1742,7 @@
  	default:
  		pri_error(pri, "Don't know how to U/A on a type %d node\n", pri->localtype);
  		return;
-@@ -116,18 +140,326 @@
+@@ -116,18 +140,359 @@
  	q921_transmit(pri, &h, 3);
  }
  
@@ -1925,6 +1941,39 @@
 +  	free(f);
 +    }
 +}
++
++static void q921_send_teichkreq(struct pri *pri,int tei) {
++    q921_u *f;
++    unsigned short ri=0x6464;
++    ri = rand();
++  
++    if (pri->localtype != BRI_NETWORK_PTMP) {
++	pri_error(pri, "TEI check response for non-ptmp???\n"); 
++  	return;
++    }
++  
++    f = malloc(sizeof(q921_u) + 5 + 2);
++    memset(f,0x0,sizeof(q921_u) + 5 + 2);
++    if (f) {
++	f->h.sapi = Q921_SAPI_LAYER2_MANAGEMENT;
++  	f->h.tei = Q921_TEI_GROUP;
++  	f->h.c_r = 1; // command u->n	
++  	f->h.ea1 = 0;	
++  	f->h.ea2 = 1;	
++  	f->m2 = 0;
++  	f->m3 = 0;
++  	f->ft = Q921_FRAMETYPE_U;
++  	f->data[0] = 0xf;
++  	f->data[1] = 0;
++  	f->data[2] = 0;
++  	f->data[3] = Q921_TEI_ID_CHK_REQ;
++  	f->data[4] = (tei << 1) | 0x1;
++  	if (pri->debug & PRI_DEBUG_Q921_STATE)
++      	    pri_message(pri, "Sending TEI check request ri=%d tei=%d\n",ri,tei);
++  	q921_transmit(pri,(q921_h *)&(f->h),8);
++  	free(f);
++    }
++}
 + 
 +static void q921_send_teiverify(struct pri *pri,int tei) {
 +    q921_u *f;
@@ -2058,7 +2107,7 @@
  	h.u.m3 = 3;	/* M3 = 3 */
  	h.u.m2 = 3;	/* M2 = 3 */
  	h.u.p_f = 1;	/* Poll bit set */
-@@ -139,25 +471,42 @@
+@@ -139,25 +504,42 @@
  	case PRI_CPE:
  		h.h.c_r = 0;
  		break;
@@ -2107,7 +2156,7 @@
  	while(f) {
  		if (f->h.n_s == num) {
  			/* Cancel each packet as necessary */
-@@ -165,26 +514,26 @@
+@@ -165,26 +547,26 @@
  			if (prev)
  				prev->next = f->next;
  			else
@@ -2142,7 +2191,7 @@
  					q921_transmit(pri, (q921_h *)(&f->h), f->len);
  					break;
  				}
-@@ -198,77 +547,136 @@
+@@ -198,77 +580,136 @@
  	return 0;
  }
  
@@ -2252,37 +2301,38 @@
 +	for (x=pri->v_a[teio]; x != ack; Q921_INC(x)) 
 +		cnt += q921_ack_packet(pri, x, tei);	
 +	if (!pri->txqueue[teio]) {
++		/* Something was ACK'd.  Stop T200 counter */
++		if (pri->t200_timer[teio]) {
++		    pri_schedule_del(pri, pri->t200_timer[teio]);
++		    pri->t200_timer[teio] = 0;
++		}
  		if (pri->debug &  PRI_DEBUG_Q921_STATE)
  			pri_message(pri, "-- Since there was nothing left, stopping T200 counter\n");
- 		/* Something was ACK'd.  Stop T200 counter */
+-		/* Something was ACK'd.  Stop T200 counter */
 -		pri_schedule_del(pri, pri->t200_timer);
 -		pri->t200_timer = 0;
-+		if (pri->t200_timer[teio]) {
-+		    pri_schedule_del(pri, pri->t200_timer[teio]);
-+		    pri->t200_timer[teio] = 0;
-+		}
  	}
 -	if (pri->t203_timer) {
 +	if (pri->t203_timer[teio]) {
++		pri_schedule_del(pri, pri->t203_timer[teio]);
++		pri->t203_timer[teio] = 0;
  		if (pri->debug &  PRI_DEBUG_Q921_STATE)
  			pri_message(pri, "-- Stopping T203 counter since we got an ACK\n");
 -		pri_schedule_del(pri, pri->t203_timer);
 -		pri->t203_timer = 0;
-+		pri_schedule_del(pri, pri->t203_timer[teio]);
-+		pri->t203_timer[teio] = 0;
  	}
 -	if (pri->txqueue) {
 +	if (pri->txqueue[teio]) {
  		/* Something left to transmit, Start the T200 counter again if we stopped it */
++		if (pri->t200_timer[teio]) {
++		    pri_schedule_del(pri, pri->t200_timer[teio]);
++		    pri->t200_timer[teio] = 0;
++		}
  		if (pri->debug &  PRI_DEBUG_Q921_STATE)
 -			pri_message(pri, "-- Something left to transmit (%d), restarting T200 counter\n", pri->txqueue->h.n_s);
 -		if (!pri->t200_timer)
 -			pri->t200_timer = pri_schedule_event(pri, pri->timers[PRI_TIMER_T200], t200_expire, pri);
 +			pri_message(pri, "-- Something left to transmit (%d), restarting T200 counter\n", pri->txqueue[teio]->h.n_s);
-+		if (pri->t200_timer[teio]) {
-+		    pri_schedule_del(pri, pri->t200_timer[teio]);
-+		    pri->t200_timer[teio] = 0;
-+		}
 +		pri->t200_timer[teio] = pri_schedule_event2(pri, pri->timers[PRI_TIMER_T200], t200_expire, pri, tei);
 +
  	} else {
@@ -2310,7 +2360,7 @@
  	h.s.p_f = pf;	
  	switch(pri->localtype) {
  	case PRI_NETWORK:
-@@ -277,23 +685,38 @@
+@@ -277,23 +718,38 @@
  	case PRI_CPE:
  		h.h.c_r = 1;
  		break;
@@ -2354,7 +2404,7 @@
  	h.s.p_f = pbit;		/* Poll/Final set appropriately */
  	switch(pri->localtype) {
  	case PRI_NETWORK:
-@@ -308,81 +731,192 @@
+@@ -308,81 +764,192 @@
  		else
  			h.h.c_r = 1;
  		break;
@@ -2585,7 +2635,7 @@
  	f = malloc(sizeof(q921_frame) + len + 2);
  	if (f) {
  		memset(f,0,sizeof(q921_frame) + len + 2);
-@@ -400,47 +934,80 @@
+@@ -400,47 +967,80 @@
  			else
  				f->h.h.c_r = 1;
  		break;
@@ -2663,14 +2713,14 @@
 -		if (pri->t203_timer) {
 +		    }
 +		    if (pri->t203_timer[teio]) {
++			pri_schedule_del(pri, pri->t203_timer[teio]);
++			pri->t203_timer[teio] = 0;
  			if (pri->debug & PRI_DEBUG_Q921_STATE)
  				pri_message(pri, "Stopping T_203 timer\n");
 -			pri_schedule_del(pri, pri->t203_timer);
 -			pri->t203_timer = 0;
 -		}
 -		if (!pri->t200_timer) {
-+			pri_schedule_del(pri, pri->t203_timer[teio]);
-+			pri->t203_timer[teio] = 0;
 +		    }
 +		    if (!pri->t200_timer[teio]) {
  			if (pri->debug & PRI_DEBUG_Q921_STATE)
@@ -2686,7 +2736,7 @@
  		
  	} else {
  		pri_error(pri, "!! Out of memory for Q.921 transmit\n");
-@@ -449,49 +1016,61 @@
+@@ -449,49 +1049,86 @@
  	return 0;
  }
  
@@ -2709,11 +2759,6 @@
 -		q921_rr(pri, 1, 1);
 -		/* Start timer T200 to resend our RR if we don't get it */
 -		pri->t203_timer = pri_schedule_event(pri, pri->timers[PRI_TIMER_T200], t200_expire, pri);
--	} else {
--		if (pri->debug &  PRI_DEBUG_Q921_STATE)
--			pri_message(pri, "T203 counter expired in weird state %d\n", pri->q921_state);
--		pri->t203_timer = 0;
--	}
 +  		/* Solicit an F-bit in the other's RR */
 +		pri->solicitfbit[teio] = 1;
 +		pri->retrans[teio] = 0;
@@ -2725,6 +2770,34 @@
 +			pri_message(pri, "T203 counter expired in weird state %d\n", pri->q921_state[teio]);
 +		pri->t203_timer[teio] = 0;
 +  	}
++}
++
++static void q921_start_tei(struct pri *pri, int tei);
++
++
++static void t201_expire(void *vpri, int tei)
++{
++  	struct pri *pri = vpri;
++ 	int teio=tei - Q921_TEI_BASE;
++	int i = 0;
++ 	if (((teio < 0) || (teio > Q921_MAX_TEIS)) || (pri->localtype != BRI_NETWORK_PTMP)) { teio=0; }
++ 	if (tei == Q921_TEI_GROUP) {
++	    for (i=0;i<Q921_MAX_TEIS;i++) {
++		if (pri->q921_tei_check[i] == 1) {
++		    pri->q921_tei_check[i] = 0;
++		    q921_start_tei(pri, Q921_TEI_BASE + i);
++		}
++	    }
+ 	} else {
+-		if (pri->debug &  PRI_DEBUG_Q921_STATE)
+-			pri_message(pri, "T203 counter expired in weird state %d\n", pri->q921_state);
+-		pri->t203_timer = 0;
++	    if (pri->q921_tei_check[teio] == 1) {
++		pri->q921_tei_check[teio] = 0;
++		q921_start_tei(pri, tei);
++	    }
+ 	}
++	pri->t201_timer[teio] = 0;
  }
  
  static pri_event *q921_handle_iframe(struct pri *pri, q921_i *i, int len)
@@ -2773,7 +2846,7 @@
  		if (res == -1) {
  			return NULL;
  		}
-@@ -500,10 +1079,10 @@
+@@ -500,10 +1137,10 @@
  	} else {
  		/* If we haven't already sent a reject, send it now, otherwise
  		   we are obliged to RR */
@@ -2787,11 +2860,32 @@
  	}
  	return NULL;
  }
-@@ -641,62 +1220,113 @@
+@@ -641,75 +1278,152 @@
  	};
  }
  
 -static pri_event *q921_dchannel_up(struct pri *pri)
++static void q921_tei_recovery(struct pri *pri, int tei) {
++    int i = 0;
++    int teio=tei - Q921_TEI_BASE;
++    if (((teio < 0) || (teio > Q921_MAX_TEIS)) || (pri->localtype != BRI_NETWORK_PTMP)) { teio=0; }
++    for (i=0;i<Q921_MAX_TEIS;i++) {
++	if ((i + Q921_TEI_BASE == tei) || (tei == Q921_TEI_GROUP)) {
++	    pri->q921_tei_check[i] = 1;
++	}
++    }
++    q921_send_teichkreq(pri, tei);
++    if (!pri->t201_timer[teio]) {
++	pri->t201_timer[teio] = pri_schedule_event2(pri, pri->timers[PRI_TIMER_T201], t201_expire, pri, tei);
++    }
++}
++/*
++static void q921_invoke_tei_recovery(void *vpri, int tei) {
++  	struct pri *pri = vpri;
++	q921_tei_recovery(pri, tei);
++}
++*/
++
 +static pri_event *q921_dchannel_up(struct pri *pri, int tei)
  {
 -	/* Reset counters, etc */
@@ -2863,11 +2957,11 @@
 -	q921_reset(pri);
 + 	if (pri->localtype == BRI_NETWORK_PTMP) {
 + 	    if (pri->t203_timer[teio]) {
++ 		pri_schedule_del(pri, pri->t203_timer[teio]);
++ 		pri->t203_timer[teio] = 0;
 + 		if (pri->debug & PRI_DEBUG_Q921_STATE) {
 + 			pri_message(pri, "Stopping T_203 timer for TEI %d\n", tei);
 + 		}
-+ 		pri_schedule_del(pri, pri->t203_timer[teio]);
-+ 		pri->t203_timer[teio] = 0;
 + 	    }
 + 	}
 +
@@ -2936,8 +3030,9 @@
 +	}
  }
  
++
  static pri_event *__q921_receive_qualified(struct pri *pri, q921_h *h, int len)
-@@ -704,12 +1334,16 @@
+ {
  	q921_frame *f;
  	pri_event *ev;
  	int sendnow;
@@ -2956,7 +3051,7 @@
  			return NULL;
  		}
  		/* Informational frame */
-@@ -720,8 +1354,10 @@
+@@ -720,8 +1434,10 @@
  		return q921_handle_iframe(pri, &h->i, len);	
  		break;
  	case 1:
@@ -2968,7 +3063,7 @@
  			return NULL;
  		}
  		if (len < 4) {
-@@ -731,80 +1367,122 @@
+@@ -731,80 +1447,122 @@
  		switch(h->s.ss) {
  		case 0:
  			/* Receiver Ready */
@@ -3125,7 +3220,7 @@
  		}
  		break;
  	case 3:
-@@ -821,8 +1499,16 @@
+@@ -821,8 +1579,16 @@
  					if (pri->debug & PRI_DEBUG_Q921_STATE)
  						pri_message(pri, "-- Got DM Mode from peer.\n");
  					/* Disconnected mode, try again after T200 */
@@ -3144,7 +3239,7 @@
  					return ev;
  						
  				} else {
-@@ -830,21 +1516,139 @@
+@@ -830,21 +1596,144 @@
  						pri_message(pri, "-- Ignoring unsolicited DM with p/f set to 0\n");
  #if 0
  					/* Requesting that we start */
@@ -3221,19 +3316,9 @@
 + 						if (tei < Q921_MAX_TEIS) {
 + 						    q921_send_teiassign(pri,((unsigned int)(h->u.data[1] << 8) + h->u.data[2]),tei + Q921_TEI_BASE);
 + 						} else {
-+ 						    // if you plug too many TEs into my bus it's your fault!!!
-+ 
-+ 						    pri_error(pri, "Whooopsie...general protection fault in module TEI manager.\n");
-+ 
-+ 						    // XXX IMPLEMENT TEI RECOVERY!!!
-+ 						    for (tei=0;tei<Q921_MAX_TEIS;tei++) {
-+ 							    // XXX ri should be 0?
-+ 						//	    q921_reset(pri, tei + Q921_TEI_BASE);
-+ 						//	    q921_send_teiremove(pri,((unsigned int)(h->u.data[1] << 8) + h->u.data[2]),tei + Q921_TEI_BASE);
-+ 						//    	    pri->q921_teis[tei] = 0;
-+ 							    // XXX dont forget schedulers, etc...
-+ 						    }
-+ 						    q921_send_teidenied(pri,((unsigned int)(h->u.data[1] << 8) + h->u.data[2]),h->u.data[4] >> 1);
++ 						    pri_error(pri, "no TEI available. starting TEI recovery procedure. dont worry!\n");
++						    q921_tei_recovery(pri, 127);
++						    
 + 						}
 + 					    break;
 + 					    case Q921_TEI_ID_CHK_REQ:
@@ -3244,6 +3329,21 @@
 + 							q921_send_teichkresp(pri, pri->tei);
 + 						    }
 + 					    break;
++ 					    case Q921_TEI_ID_CHK_RES:
++ 						if (pri->localtype != BRI_NETWORK_PTMP)
++ 						    break;
++						    teio = (h->u.data[4] >> 1) - Q921_TEI_BASE;
++						    if ((teio < 0) || (teio >= Q921_MAX_TEIS)) break;
++ 						    if (pri->q921_tei_check[teio] == 1) {
++ 						        pri->q921_tei_check_ri[teio] = (h->u.data[1] << 8) + h->u.data[2];
++ 						        pri->q921_tei_check[teio] = 0;
++ 						    } else {
++							// d a t
++							pri_error(pri, "double assgined tei for tei %d teio %d\n", h->u.data[4] >> 1, teio);
++ 						        pri->q921_tei_check[teio] = 0;
++     							q921_start_tei(pri, h->u.data[4] >> 1);
++						    }
++ 					    break;
 + 					    default:
 + 						pri_message(pri, "Ri = %d TEI msg = %x TEI = %x\n", (h->u.data[1] << 8) + h->u.data[2], h->u.data[3], h->u.data[4] >> 1);
 + 					} 
@@ -3290,7 +3390,7 @@
  			return ev;
  		case 3:
  			if (h->u.m2 == 3) {
-@@ -866,17 +1670,26 @@
+@@ -866,17 +1755,26 @@
  					}
  				}
  				/* Send Unnumbered Acknowledgement */
@@ -3323,7 +3423,7 @@
  			} else 
  				pri_error(pri, "!! Weird frame received (m3=3, m2 = %d)\n", h->u.m2);
  			break;
-@@ -901,19 +1714,42 @@
+@@ -901,19 +1799,42 @@
  	/* Discard FCS */
  	len -= 2;
  	
@@ -3373,7 +3473,7 @@
  #ifdef PROCESS_SUBCHANNELS
  		/* If it's not us, try any subchannels we have */
  		if (pri->subchannel)
-@@ -921,10 +1757,16 @@
+@@ -921,10 +1842,16 @@
  		else 
  #endif
  			return NULL;
@@ -3392,7 +3492,7 @@
  	return ev;
  }
  
-@@ -938,14 +1780,54 @@
+@@ -938,14 +1865,58 @@
  	return e;
  }
  
@@ -3435,6 +3535,8 @@
 +		for (i=0;i<Q921_MAX_TEIS;i++) {
 +		    q921_start_tei(pri,Q921_TEI_BASE+i);
 +		}
++		/* clean up those TEIs */
++//		pri_schedule_event2(pri, 10000, q921_invoke_tei_recovery, pri, 127 );
 +	    } else if ((tei >= Q921_TEI_BASE) && (tei < Q921_TEI_BASE + Q921_MAX_TEIS)){
 +		// restart of a single p2p datalink
 +		q921_start_tei(pri,tei);
@@ -3442,8 +3544,10 @@
 +	} 
 +	if (pri->localtype == BRI_CPE_PTMP){ 
 +	    if (tei == 0) {
++#ifdef RELAX_TRB
 +		/* let's get a TEI */
-+	//	q921_send_teireq(pri);
++		q921_send_teireq(pri);
++#endif
 +	    } else {
 +		/* save the planet by recycling */
 +		pri->sabme_retrans[0] = 0;
@@ -3473,15 +3577,6 @@
   *
   * This program is free software; you can redistribute it and/or modify
   * it under the terms of the GNU General Public License as published by
-@@ -21,7 +23,7 @@
-  * Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA. 
-  *
-  */
--
-+ 
- #include "compat.h"
- #include "libpri.h"
- #include "pri_internal.h"
 @@ -31,6 +33,7 @@
  
  #include <unistd.h>




More information about the Pkg-voip-commits mailing list