[Pkg-voip-commits] r5755 - in /libpri/trunk/debian: changelog copyright patches/bristuff.dpatch

paravoid at alioth.debian.org paravoid at alioth.debian.org
Wed May 21 00:40:05 UTC 2008


Author: paravoid
Date: Wed May 21 00:40:04 2008
New Revision: 5755

URL: http://svn.debian.org/wsvn/pkg-voip/?sc=1&rev=5755
Log:
* Update to bristuff 0.4.0-RC1
  - fixed "call reference exceeds 127 on BRI spans" bug in libpri
    which caused a deadlock in chan_zap.
  - fixed "t303 not stopped" bug in libpri.
* Add Junghanns.NET GmbH to the copyright holders in debian/copyright.
* Refer to /usr/share/common-licenses/GPL-2 to avoid ambiguity vs. GPLv3.

Modified:
    libpri/trunk/debian/changelog
    libpri/trunk/debian/copyright
    libpri/trunk/debian/patches/bristuff.dpatch

Modified: libpri/trunk/debian/changelog
URL: http://svn.debian.org/wsvn/pkg-voip/libpri/trunk/debian/changelog?rev=5755&op=diff
==============================================================================
--- libpri/trunk/debian/changelog (original)
+++ libpri/trunk/debian/changelog Wed May 21 00:40:04 2008
@@ -1,8 +1,13 @@
-libpri (1.4.3-2) UNRELEASED; urgency=low
-
-  * NOT RELEASED YET
-
- -- Mark Purcell <msp at debian.org>  Tue, 22 Apr 2008 23:03:27 +1000
+libpri (1.4.3-2) unstable; urgency=low
+
+  * Update to bristuff 0.4.0-RC1
+    - fixed "call reference exceeds 127 on BRI spans" bug in libpri
+      which caused a deadlock in chan_zap.
+    - fixed "t303 not stopped" bug in libpri.
+  * Add Junghanns.NET GmbH to the copyright holders in debian/copyright.
+  * Refer to /usr/share/common-licenses/GPL-2 to avoid ambiguity vs. GPLv3.
+
+ -- Faidon Liambotis <paravoid at debian.org>  Wed, 21 May 2008 03:33:52 +0300
 
 libpri (1.4.3-1) unstable; urgency=low
 

Modified: libpri/trunk/debian/copyright
URL: http://svn.debian.org/wsvn/pkg-voip/libpri/trunk/debian/copyright?rev=5755&op=diff
==============================================================================
--- libpri/trunk/debian/copyright (original)
+++ libpri/trunk/debian/copyright Wed May 21 00:40:04 2008
@@ -7,6 +7,10 @@
 
  * Copyright (C) 2001, Linux Support Services, Inc.
  * Copyright (C) 2001-2005, Digium
+
+Additionaly, this package contains changes ("bristuff patch")
+in debian/patches/bristuff.dpatch which are
+ * Copyright (C) 2003-2006 Junghanns.NET GmbH
 
 License:
 
@@ -25,5 +29,5 @@
    Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA  02110-1301 USA
 
 On Debian systems, the complete text of the GNU General
-Public License can be found in `/usr/share/common-licenses/GPL'.
+Public License can be found in `/usr/share/common-licenses/GPL-2'.
 

Modified: libpri/trunk/debian/patches/bristuff.dpatch
URL: http://svn.debian.org/wsvn/pkg-voip/libpri/trunk/debian/patches/bristuff.dpatch?rev=5755&op=diff
==============================================================================
--- libpri/trunk/debian/patches/bristuff.dpatch (original)
+++ libpri/trunk/debian/patches/bristuff.dpatch Wed May 21 00:40:04 2008
@@ -2,17 +2,17 @@
 ## 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 bristuff-0.4.0-test4
+## DP: The libpri part of bristuff, version bristuff-0.4.0-RC1
 ## DP: http://www.junghanns.net/en/download.html
 ## DP:
 ## DP: newer versions: replace the contets of the patch file literally.
-## DP: The remove Makefile and the strange changes this libpri.patch makes to 
-## DP: copyright statements.
+## DP: Watch out for Makefile changes!
 
 @DPATCH@
-diff -urN libpri-1.4.1.orig/libpri.h libpri-1.4.1/libpri.h
---- libpri-1.4.1.orig/libpri.h	2006-04-27 18:09:11.000000000 +0200
-+++ libpri-1.4.1/libpri.h	2007-07-11 14:25:15.000000000 +0200
+Index: libpri-1.4.3/libpri.h
+===================================================================
+--- libpri-1.4.3.orig/libpri.h
++++ libpri-1.4.3/libpri.h
 @@ -5,6 +5,8 @@
   *
   * Copyright (C) 2001, Linux Support Services, Inc.
@@ -30,9 +30,9 @@
 +#define PRI_NETWORK		1	/* PTP modes, default for PRI */
  #define PRI_CPE			2
 +#define BRI_NETWORK_PTMP	3	/* PTMP modes, default for BRI */
-+#define BRI_CPE_PTMP		4	
++#define BRI_CPE_PTMP		4
 +#define BRI_NETWORK		5	/* PTP modes */
-+#define BRI_CPE			6	
++#define BRI_CPE			6
  
  /* Debugging */
  #define PRI_DEBUG_Q921_RAW		(1 << 0)	/* Show raw HDLC frames */
@@ -67,7 +67,7 @@
  } pri_event_generic;
  
  typedef struct pri_event_error {
-@@ -275,18 +293,19 @@
+@@ -275,18 +293,19 @@ typedef struct pri_event_ringing {
  	int cref;
  	int progress;
  	int progressmask;
@@ -89,7 +89,7 @@
  } pri_event_answer;
  
  typedef struct pri_event_facname {
-@@ -304,32 +323,37 @@
+@@ -304,32 +323,37 @@ typedef struct pri_event_ring {
  	int e;
  	int channel;				/* Channel requested */
  	int callingpres;			/* Presentation of Calling CallerID */
@@ -136,7 +136,7 @@
  } pri_event_ring;
  
  typedef struct pri_event_hangup {
-@@ -337,6 +361,8 @@
+@@ -337,6 +361,8 @@ typedef struct pri_event_hangup {
  	int channel;				/* Channel requested */
  	int cause;
  	int cref;
@@ -145,7 +145,7 @@
  	q931_call *call;			/* Opaque call pointer */
  	long aoc_units;				/* Advise of Charge number of charged units */
  	char useruserinfo[260];		/* User->User info */
-@@ -377,20 +403,80 @@
+@@ -377,12 +403,67 @@ typedef struct pri_event_keypad_digit {
  	char digits[64];
  } pri_event_keypad_digit;
  
@@ -196,8 +196,8 @@
 +
 +typedef struct pri_event_display {
 +	int e;
-+	int channel;		
-+	int cref;			
++	int channel;
++	int cref;
 +	q931_call *call;
 +	char text[256];
 +} pri_event_display;
@@ -213,8 +213,7 @@
  	pri_event_ring	  ring;		/* Ring */
  	pri_event_hangup  hangup;	/* Hang up */
  	pri_event_ringing ringing;	/* Ringing */
- 	pri_event_answer  answer;	/* Answer */
- 	pri_event_restart_ack restartack;	/* Restart Acknowledge */
+@@ -391,6 +472,11 @@ typedef union {
  	pri_event_proceeding  proceeding;	/* Call proceeding & Progress */
  	pri_event_setup_ack   setup_ack;	/* SETUP_ACKNOWLEDGE structure */
  	pri_event_notify notify;		/* Notification */
@@ -226,7 +225,7 @@
  	pri_event_keypad_digit digit;			/* Digits that come during a call */
  } pri_event;
  
-@@ -405,7 +491,9 @@
+@@ -405,7 +491,9 @@ typedef int (*pri_io_cb)(struct pri *pri
     channel operating in HDLC mode with FCS computed by the fd's driver.  Also it
     must be NON-BLOCKING! Frames received on the fd should include FCS.  Nodetype 
     must be one of PRI_NETWORK or PRI_CPE.  switchtype should be PRI_SWITCH_* */
@@ -237,7 +236,7 @@
  
  /* Create D-channel just as above with user defined I/O callbacks and data */
  extern struct pri *pri_new_cb(int fd, int nodetype, int switchtype, pri_io_cb io_read, pri_io_cb io_write, void *userdata);
-@@ -429,6 +517,9 @@
+@@ -429,6 +517,9 @@ extern int pri_get_debug(struct pri *pri
  /* Enable transmission support of Facility IEs on the pri */
  extern void pri_facility_enable(struct pri *pri);
  
@@ -247,7 +246,7 @@
  /* Run PRI on the given D-channel, taking care of any events that
     need to be handled.  If block is set, it will block until an event
     occurs which needs to be handled */
-@@ -469,6 +560,12 @@
+@@ -469,6 +560,12 @@ extern int pri_information(struct pri *p
  /* Send a keypad facility string of digits */
  extern int pri_keypad_facility(struct pri *pri, q931_call *call, char *digits);
  
@@ -260,7 +259,7 @@
  /* Answer the incomplete(call without called number) call on the given channel.
     Set non-isdn to non-zero if you are not connecting to ISDN equipment */
  extern int pri_need_more_info(struct pri *pri, q931_call *call, int channel, int nonisdn);
-@@ -477,6 +574,35 @@
+@@ -477,6 +574,35 @@ extern int pri_need_more_info(struct pri
     Set non-isdn to non-zero if you are not connecting to ISDN equipment */
  extern int pri_answer(struct pri *pri, q931_call *call, int channel, int nonisdn);
  
@@ -296,7 +295,7 @@
  /* Set CRV reference for GR-303 calls */
  
  
-@@ -485,14 +611,14 @@
+@@ -485,14 +611,14 @@ extern int pri_answer(struct pri *pri, q
  
  /* backwards compatibility for those who don't use asterisk with libpri */
  #define pri_release(a,b,c) \
@@ -314,7 +313,7 @@
  
  #define PRI_DESTROYCALL
  extern void pri_destroycall(struct pri *pri, q931_call *call);
-@@ -525,7 +651,7 @@
+@@ -525,7 +651,7 @@ extern struct pri_sr *pri_sr_new(void);
  extern void pri_sr_free(struct pri_sr *sr);
  
  extern int pri_sr_set_channel(struct pri_sr *sr, int channel, int exclusive, int nonisdn);
@@ -323,7 +322,7 @@
  extern int pri_sr_set_called(struct pri_sr *sr, char *called, int calledplan, int complete);
  extern int pri_sr_set_caller(struct pri_sr *sr, char *caller, char *callername, int callerplan, int callerpres);
  extern int pri_sr_set_redirecting(struct pri_sr *sr, char *num, int plan, int pres, int reason);
-@@ -553,8 +679,8 @@
+@@ -553,8 +679,8 @@ int pri_channel_bridge(q931_call *call1,
  
  /* Override message and error stuff */
  #define PRI_NEW_SET_API
@@ -334,9 +333,10 @@
  
  /* Set overlap mode */
  #define PRI_SET_OVERLAPDIAL
-diff -urN libpri-1.4.1.orig/Makefile libpri-1.4.1/Makefile
---- libpri-1.4.1.orig/Makefile	2006-12-30 20:17:34.000000000 +0100
-+++ libpri-1.4.1/Makefile	2007-07-11 14:25:15.000000000 +0200
+Index: libpri-1.4.3/Makefile
+===================================================================
+--- libpri-1.4.3.orig/Makefile
++++ libpri-1.4.3/Makefile
 @@ -27,6 +27,16 @@
  # Uncomment if you want libpri to count number of Q921/Q931 sent/received
  #LIBPRI_COUNTERS=-DLIBPRI_COUNTERS
@@ -354,7 +354,7 @@
  CC=gcc
  
  OSARCH=$(shell uname -s)
-@@ -36,7 +46,7 @@
+@@ -36,7 +46,7 @@ STATIC_LIBRARY=libpri.a
  DYNAMIC_LIBRARY=libpri.so.1.0
  STATIC_OBJS=copy_string.o pri.o q921.o prisched.o q931.o pri_facility.o
  DYNAMIC_OBJS=copy_string.lo pri.lo q921.lo prisched.lo q931.lo pri_facility.lo
@@ -363,9 +363,10 @@
  INSTALL_PREFIX=$(DESTDIR)
  INSTALL_BASE=/usr
  SOFLAGS = -Wl,-hlibpri.so.1.0
-diff -urN libpri-1.4.1.orig/pri.c libpri-1.4.1/pri.c
---- libpri-1.4.1.orig/pri.c	2006-07-06 23:11:37.000000000 +0200
-+++ libpri-1.4.1/pri.c	2007-07-11 14:25:15.000000000 +0200
+Index: libpri-1.4.3/pri.c
+===================================================================
+--- libpri-1.4.3.orig/pri.c
++++ libpri-1.4.3/pri.c
 @@ -1,24 +1,14 @@
  /*
   * libpri: An implementation of Primary Rate ISDN
@@ -397,7 +398,7 @@
   *
   */
  
-@@ -48,6 +38,14 @@
+@@ -48,6 +38,14 @@ char *pri_node2str(int node)
  		return "Network";
  	case PRI_CPE:
  		return "CPE";
@@ -412,7 +413,7 @@
  	default:
  		return "Invalid value";
  	}
-@@ -187,7 +185,7 @@
+@@ -187,7 +185,7 @@ static int __pri_write(struct pri *pri, 
  	return res;
  }
  
@@ -421,7 +422,7 @@
  {
  	struct pri *p;
  	p = malloc(sizeof(struct pri));
-@@ -207,6 +205,8 @@
+@@ -207,6 +205,8 @@ static struct pri *__pri_new(int fd, int
  		p->master = master;
  		p->callpool = &p->localpool;
  		pri_default_timers(p, switchtype);
@@ -430,7 +431,7 @@
  #ifdef LIBPRI_COUNTERS
  		p->q921_rxcount = 0;
  		p->q921_txcount = 0;
-@@ -217,7 +217,7 @@
+@@ -217,7 +217,7 @@ static struct pri *__pri_new(int fd, int
  			p->protodisc = GR303_PROTOCOL_DISCRIMINATOR;
  			p->sapi = Q921_SAPI_GR303_EOC;
  			p->tei = Q921_TEI_GR303_EOC_OPS;
@@ -439,7 +440,7 @@
  			if (!p->subchannel) {
  				free(p);
  				p = NULL;
-@@ -226,7 +226,7 @@
+@@ -226,7 +226,7 @@ static struct pri *__pri_new(int fd, int
  			p->protodisc = GR303_PROTOCOL_DISCRIMINATOR;
  			p->sapi = Q921_SAPI_GR303_TMC_CALLPROC;
  			p->tei = Q921_TEI_GR303_TMC_CALLPROC;
@@ -448,7 +449,7 @@
  			if (!p->subchannel) {
  				free(p);
  				p = NULL;
-@@ -242,7 +242,7 @@
+@@ -242,7 +242,7 @@ static struct pri *__pri_new(int fd, int
  		}
  		/* Start Q.921 layer, Wait if we're the network */
  		if (p)
@@ -457,14 +458,14 @@
  	}
  	return p;
  }
-@@ -262,15 +262,16 @@
+@@ -262,15 +262,16 @@ int pri_restart(struct pri *pri)
  {
  	/* Restart Q.921 layer */
  	if (pri) {
 -		q921_reset(pri);
 -		q921_start(pri, pri->localtype == PRI_CPE);	
 +// XXX		q921_reset(pri);
-+//		q921_start(pri, pri->localtype == PRI_CPE);	
++//		q921_start(pri, pri->localtype == PRI_CPE);
  	}
  	return 0;
  }
@@ -478,7 +479,7 @@
  }
  
  struct pri *pri_new_cb(int fd, int nodetype, int switchtype, pri_io_cb io_read, pri_io_cb io_write, void *userdata)
-@@ -279,7 +280,7 @@
+@@ -279,7 +280,7 @@ struct pri *pri_new_cb(int fd, int nodet
  		io_read = __pri_read;
  	if (!io_write)
  		io_write = __pri_write;
@@ -487,7 +488,7 @@
  }
  
  void *pri_get_userdata(struct pri *pri)
-@@ -443,6 +444,15 @@
+@@ -443,6 +444,15 @@ void pri_facility_enable(struct pri *pri
  	return;
  }
  
@@ -503,7 +504,7 @@
  int pri_acknowledge(struct pri *pri, q931_call *call, int channel, int info)
  {
  	if (!pri || !call)
-@@ -486,6 +496,21 @@
+@@ -486,6 +496,21 @@ int pri_notify(struct pri *pri, q931_cal
  	return q931_notify(pri, call, channel, info);
  }
  
@@ -525,7 +526,7 @@
  void pri_destroycall(struct pri *pri, q931_call *call)
  {
  	if (pri && call)
-@@ -507,6 +532,83 @@
+@@ -507,6 +532,83 @@ int pri_answer(struct pri *pri, q931_cal
  	return q931_connect(pri, call, channel, nonisdn);
  }
  
@@ -609,8 +610,8 @@
  #if 0
  /* deprecated routines, use pri_hangup */
  int pri_release(struct pri *pri, q931_call *call, int cause)
-@@ -547,14 +649,35 @@
- 	return -1;
+@@ -561,14 +663,35 @@ int pri_channel_bridge(q931_call *call1,
+ 	}
  }
  
 -int pri_hangup(struct pri *pri, q931_call *call, int cause)
@@ -631,7 +632,7 @@
 +	if (aocunits > -1) {
 +	    call->aoc_units = aocunits;
 +	}
-+	
++
 +	if (pri->localtype == BRI_NETWORK_PTMP) {
 +	    res = q921_hangup(pri, call, 127);
 +	    if (res) {
@@ -647,7 +648,7 @@
  }
  
  int pri_reset(struct pri *pri, int channel)
-@@ -694,15 +817,15 @@
+@@ -708,15 +831,15 @@ int pri_call(struct pri *pri, q931_call 
  	return q931_setup(pri, c, &req);
  }	
  
@@ -667,7 +668,7 @@
  {
  	__pri_error = func;
  }
-@@ -714,10 +837,14 @@
+@@ -728,10 +851,14 @@ void pri_message(struct pri *pri, char *
  	va_start(ap, fmt);
  	vsnprintf(tmp, sizeof(tmp), fmt, ap);
  	va_end(ap);
@@ -686,7 +687,7 @@
  }
  
  void pri_error(struct pri *pri, char *fmt, ...)
-@@ -727,10 +854,14 @@
+@@ -741,10 +868,14 @@ void pri_error(struct pri *pri, char *fm
  	va_start(ap, fmt);
  	vsnprintf(tmp, sizeof(tmp), fmt, ap);
  	va_end(ap);
@@ -697,7 +698,7 @@
 + 	if (__pri_error && pri) {
 + 	    if (pri->debugfd >= 0)
 + 		write(pri->debugfd, tmp, strlen(tmp));
-+ 	    else 
++ 	    else
 + 		__pri_error(tmp, pri->span);
 + 	} else {
 +	    fputs(tmp, stderr);
@@ -705,7 +706,7 @@
  }
  
  /* Set overlap mode */
-@@ -771,11 +902,13 @@
+@@ -785,11 +916,13 @@ char *pri_dump_info_str(struct pri *pri)
  	}
  	len += sprintf(buf + len, "Q921 Outstanding: %d\n", q921outstanding);
  #endif
@@ -724,7 +725,7 @@
  	len += sprintf(buf + len, "Overlap Dial: %d\n", pri->overlapdial);
  	len += sprintf(buf + len, "T200 Timer: %d\n", pri->timers[PRI_TIMER_T200]);
  	len += sprintf(buf + len, "T203 Timer: %d\n", pri->timers[PRI_TIMER_T203]);
-@@ -785,6 +918,7 @@
+@@ -799,6 +932,7 @@ char *pri_dump_info_str(struct pri *pri)
  	len += sprintf(buf + len, "T313 Timer: %d\n", pri->timers[PRI_TIMER_T313]);
  	len += sprintf(buf + len, "N200 Counter: %d\n", pri->timers[PRI_TIMER_N200]);
  
@@ -732,7 +733,7 @@
  	return strdup(buf);
  }
  
-@@ -826,10 +960,11 @@
+@@ -840,10 +974,11 @@ int pri_sr_set_channel(struct pri_sr *sr
  	return 0;
  }
  
@@ -745,7 +746,7 @@
  	return 0;
  }
  
-@@ -858,3 +993,14 @@
+@@ -872,3 +1007,14 @@ int pri_sr_set_redirecting(struct pri_sr
  	sr->redirectingreason = reason;
  	return 0;
  }
@@ -760,9 +761,10 @@
 +#endif
 +#endif
 +}
-diff -urN libpri-1.4.1.orig/pridump.c libpri-1.4.1/pridump.c
---- libpri-1.4.1.orig/pridump.c	2006-07-05 18:17:05.000000000 +0200
-+++ libpri-1.4.1/pridump.c	2007-07-11 14:25:15.000000000 +0200
+Index: libpri-1.4.3/pridump.c
+===================================================================
+--- libpri-1.4.3.orig/pridump.c
++++ libpri-1.4.3/pridump.c
 @@ -1,9 +1,9 @@
  /*
   * libpri: An implementation of Primary Rate ISDN
@@ -775,11 +777,12 @@
   * All Rights Reserved.
   *
   * This program is free software; you can redistribute it and/or modify
-diff -urN libpri-1.4.1.orig/pri_facility.c libpri-1.4.1/pri_facility.c
---- libpri-1.4.1.orig/pri_facility.c	2007-06-06 23:58:22.000000000 +0200
-+++ libpri-1.4.1/pri_facility.c	2007-07-11 14:25:15.000000000 +0200
+Index: libpri-1.4.3/pri_facility.c
+===================================================================
+--- libpri-1.4.3.orig/pri_facility.c
++++ libpri-1.4.3/pri_facility.c
 @@ -1,26 +1,17 @@
--/*
+ /*
 - * libpri: An implementation of Primary Rate ISDN
 - *
 - * Written by Matthew Fredrickson <creslin at digium.com>
@@ -802,10 +805,9 @@
 - * 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)
 +
@@ -814,12 +816,12 @@
 +
 +   Copyright (C) 2005-2006 Junghanns.NET GmbH
 +   Klaus-Peter Junghanns <kpj at junghanns.net>
-+    
++
 +*/
  
  #include "compat.h"
  #include "libpri.h"
-@@ -350,9 +341,9 @@
+@@ -350,9 +341,9 @@ int asn1_name_decode(void * data, int le
  	if (datalen > buflen) {
  		/* Truncate */
  		datalen = buflen;
@@ -831,7 +833,7 @@
  }
  
  int asn1_string_encode(unsigned char asn1_type, void *data, int len, int max_len, void *src, int src_len)
-@@ -447,12 +438,55 @@
+@@ -447,12 +438,55 @@ static int rose_public_party_number_deco
  			return -1;
  		value->ton = ton;
  
@@ -842,7 +844,7 @@
  	return -1;
  }
  
-+static int rose_cd_destination_decode(struct pri *pri, q931_call *call, unsigned char *data, int len) 
++static int rose_cd_destination_decode(struct pri *pri, q931_call *call, unsigned char *data, int len)
 +{
 +	unsigned char *vdata = data;
 +	struct rose_component *comp1 = NULL, *comp2 = NULL;
@@ -852,13 +854,13 @@
 +		dump_apdu (pri, data, len);
 +
 +	do {
-+		GET_COMPONENT(comp1, pos1, vdata, len);	
++		GET_COMPONENT(comp1, pos1, vdata, len);
 +		CHECK_COMPONENT(comp1, ASN1_SEQUENCE, "!! Invalid CD destination argument. Expected Sequence (0x30) but Received 0x%02X\n");
 +		SUB_COMPONENT(comp1, pos1);
 +		GET_COMPONENT(comp1, pos1, vdata, len);
 +		switch (comp1->type) {
 +			case (ASN1_SEQUENCE | ASN1_CONSTRUCTOR):
-+				sublen2 = comp1->len; 
++				sublen2 = comp1->len;
 +				pos2 = pos1;
 +				comp2 = comp1;
 +				SUB_COMPONENT(comp2, pos2);
@@ -888,7 +890,7 @@
  static int rose_address_decode(struct pri *pri, q931_call *call, unsigned char *data, int len, struct addressingdataelements_presentednumberunscreened *value)
  {
  	int i = 0;
-@@ -517,11 +551,10 @@
+@@ -517,11 +551,10 @@ static int rose_address_decode(struct pr
  			pri_message(pri, "!! Unknown Party number component received 0x%X\n", comp->type);
  			return -1;
  		}
@@ -901,7 +903,7 @@
  	}
  	while (0);
  
-@@ -531,7 +564,6 @@
+@@ -531,7 +564,6 @@ static int rose_address_decode(struct pr
  static int rose_presented_number_unscreened_decode(struct pri *pri, q931_call *call, unsigned char *data, int len, struct addressingdataelements_presentednumberunscreened *value)
  {
  	int i = 0;
@@ -909,7 +911,7 @@
  	struct rose_component *comp = NULL;
  	unsigned char *vdata = data;
  
-@@ -546,9 +578,7 @@
+@@ -546,9 +578,7 @@ static int rose_presented_number_unscree
  		switch(comp->type) {
  		case (ASN1_CONTEXT_SPECIFIC | ASN1_CONSTRUCTOR | ASN1_TAG_0):		/* [0] presentationAllowedNumber */
  			value->pres = PRES_ALLOWED_USER_NUMBER_NOT_SCREENED;
@@ -920,7 +922,7 @@
  		case (ASN1_CONTEXT_SPECIFIC | ASN1_TAG_1):		/* [1] IMPLICIT presentationRestricted */
  			if (comp->len != 0) { /* must be NULL */
  				pri_error(pri, "!! Invalid PresentationRestricted component received (len != 0)\n");
-@@ -565,9 +595,7 @@
+@@ -565,9 +595,7 @@ static int rose_presented_number_unscree
  			return 2;
  		case (ASN1_CONTEXT_SPECIFIC | ASN1_CONSTRUCTOR | ASN1_TAG_3):		/* [3] presentationRestrictedNumber */
  			value->pres = PRES_PROHIB_USER_NUMBER_NOT_SCREENED;
@@ -931,7 +933,7 @@
  		default:
  			pri_message(pri, "Invalid PresentedNumberUnscreened component 0x%X\n", comp->type);
  		}
-@@ -578,7 +606,7 @@
+@@ -578,7 +606,7 @@ static int rose_presented_number_unscree
  	return -1;
  }
  
@@ -940,7 +942,7 @@
  {
  	int i = 0;
  	int diversion_counter;
-@@ -587,21 +615,9 @@
+@@ -587,21 +615,9 @@ static int rose_diverting_leg_informatio
  	struct addressingdataelements_presentednumberunscreened divertingnr;
   	struct addressingdataelements_presentednumberunscreened originalcallednr;
  	struct rose_component *comp = NULL;
@@ -963,7 +965,7 @@
  	do {
  		/* diversionCounter stuff */
  		GET_COMPONENT(comp, i, vdata, len);
-@@ -619,20 +635,18 @@
+@@ -619,20 +635,18 @@ static int rose_diverting_leg_informatio
  	
  		if(pri->debug & PRI_DEBUG_APDU)
  			pri_message(pri, "    Redirection reason: %d, total diversions: %d\n", diversion_reason, diversion_counter);
@@ -987,7 +989,7 @@
  				comp->len = res;
  				if (res < 0)
  					return -1;
-@@ -641,43 +655,33 @@
+@@ -641,43 +655,33 @@ static int rose_diverting_leg_informatio
  					pri_message(pri, "      ton = %d, pres = %d, npi = %d\n", divertingnr.ton, divertingnr.pres, divertingnr.npi);
  				}
  				break;
@@ -1038,7 +1040,7 @@
  
  		if (divertingnr.pres >= 0) {
  			call->redirectingplan = divertingnr.npi;
-@@ -690,15 +694,19 @@
+@@ -690,15 +694,19 @@ static int rose_diverting_leg_informatio
  			call->origcalledpres = originalcallednr.pres;
  			libpri_copy_string(call->origcallednum, originalcallednr.partyaddress, sizeof(call->origcallednum));
  		}
@@ -1061,7 +1063,7 @@
  static int rose_diverting_leg_information2_encode(struct pri *pri, q931_call *call)
  {
  	int i = 0, j, compsp = 0;
-@@ -916,6 +924,131 @@
+@@ -916,6 +924,131 @@ static int add_dms100_transfer_ability_a
  		return 0;
  }
  
@@ -1077,7 +1079,7 @@
 +    ASN1_PUSH(compstk, compsp, comp);
 +
 +    ASN1_ADD_BYTECOMP(comp, ASN1_INTEGER, buffer, i, get_invokeid(pri));
-+    ASN1_ADD_BYTECOMP(comp, ASN1_INTEGER, buffer, i, ROSE_CALLDEFLECTION); 
++    ASN1_ADD_BYTECOMP(comp, ASN1_INTEGER, buffer, i, ROSE_CALLDEFLECTION);
 +
 +    /* Argument sequence */
 +    ASN1_ADD_SIMPLE(comp, (ASN1_CONSTRUCTOR | ASN1_SEQUENCE), buffer, i);
@@ -1086,11 +1088,11 @@
 +    /* arg.Address */
 +    ASN1_ADD_SIMPLE(comp, (ASN1_CONSTRUCTOR | ASN1_SEQUENCE), buffer, i);
 +    ASN1_PUSH(compstk, compsp, comp);
-+    
++
 +#ifndef CD_UNLIKE_IN_CAPI
 +    /* arg.address.PartyNumber */
 +
-+    
++
 +    j = asn1_string_encode((ASN1_CONTEXT_SPECIFIC|ASN1_TAG_0), &buffer[i], sizeof(buffer)-i, 20, destination, strlen(destination));
 +    if (j<0) return -1;
 +    i += j;
@@ -1119,7 +1121,7 @@
 +    }
 +    if (pri_call_apdu_queue(c, Q931_FACILITY, buffer, i, NULL, NULL))
 +                     return -1;
-+   
++
 +        return 0;
 +}
 +
@@ -1136,7 +1138,7 @@
 +    ASN1_PUSH(compstk, compsp, comp);
 +
 +    ASN1_ADD_BYTECOMP(comp, ASN1_INTEGER, buffer, i, get_invokeid(pri));
-+    ASN1_ADD_BYTECOMP(comp, ASN1_INTEGER, buffer, i, ROSE_CALLREROUTING); 
++    ASN1_ADD_BYTECOMP(comp, ASN1_INTEGER, buffer, i, ROSE_CALLREROUTING);
 +
 +    /* Argument sequence */
 +    ASN1_ADD_SIMPLE(comp, (ASN1_CONSTRUCTOR | ASN1_SEQUENCE), buffer, i);
@@ -1173,7 +1175,7 @@
 +	ASN1_ADD_SIMPLE(comp, (ASN1_CONTEXT_SPECIFIC | ASN1_CONSTRUCTOR | ASN1_TAG_0), buffer, i);
 +	ASN1_PUSH(compstk, compsp, comp);
 +
-+	    j = asn1_string_encode(0x80, &buffer[i], sizeof(buffer)-i, 20, c->callednum, strlen(c->callednum)); 
++	    j = asn1_string_encode(0x80, &buffer[i], sizeof(buffer)-i, 20, c->callednum, strlen(c->callednum));
 +	    if(j<0) return -1;
 +	    i += j;
 +
@@ -1186,14 +1188,14 @@
 +    }
 +    if (pri_call_apdu_queue(c, Q931_FACILITY, buffer, i, NULL, NULL))
 +                     return -1;
-+   
++
 +        return 0;
 +}
 +
  /* Sending callername information functions */
  static int add_callername_facility_ies(struct pri *pri, q931_call *c, int cpe)
  {
-@@ -1162,7 +1295,7 @@
+@@ -1150,7 +1283,7 @@ static int aoc_aoce_charging_request_dec
  		CHECK_COMPONENT(comp, ASN1_ENUMERATED, "!! Invalid AOC Charging Request argument. Expected Enumerated (0x0A) but Received 0x%02X\n");
  		ASN1_GET_INTEGER(comp, chargingcase);				
  		if (chargingcase >= 0 && chargingcase <= 2) {
@@ -1202,7 +1204,7 @@
  				pri_message(pri, "Channel %d/%d, Call %d  - received AOC charging request - charging case: %i\n", 
  					call->ds1no, call->channelno, call->cr, chargingcase);
  		} else {
-@@ -1280,7 +1413,7 @@
+@@ -1268,7 +1401,7 @@ static int aoc_aoce_charging_unit_decode
  	return 0;
  }
  
@@ -1211,7 +1213,7 @@
  {
  	/* sample data: [ 91 a1 12 02 02 3a 78 02 01 24 30 09 30 07 a1 05 30 03 02 01 01 ] */
  	int i = 0, res = 0, compsp = 0;
-@@ -1334,20 +1467,21 @@
+@@ -1322,20 +1455,21 @@ static int aoc_aoce_charging_unit_encode
  		dump_apdu (pri, buffer, i);
  		
  	/* code below is untested */
@@ -1239,7 +1241,7 @@
  	return 0;
  }
  /* End AOC */
-@@ -1572,13 +1706,15 @@
+@@ -1560,13 +1694,15 @@ int rose_invoke_decode(struct pri *pri, 
  		NEXT_COMPONENT(comp, i);
  
  		/* No argument - return with error */
@@ -1260,7 +1262,7 @@
  
  		if (pri->debug & PRI_DEBUG_APDU)
  			pri_message(pri, "  [ Handling operation %d ]\n", operation_tag);
-@@ -1602,7 +1738,11 @@
+@@ -1590,7 +1726,11 @@ int rose_invoke_decode(struct pri *pri, 
  		case ROSE_DIVERTING_LEG_INFORMATION2:
  			if (pri->debug & PRI_DEBUG_APDU)
  				pri_message(pri, "  Handle DivertingLegInformation2\n");
@@ -1273,7 +1275,7 @@
  		case ROSE_AOC_NO_CHARGING_INFO_AVAILABLE:
  			if (pri->debug & PRI_DEBUG_APDU) {
  				pri_message(pri, "ROSE %i: AOC No Charging Info Available - not handled!", operation_tag);
-@@ -1630,6 +1770,7 @@
+@@ -1618,6 +1758,7 @@ int rose_invoke_decode(struct pri *pri, 
  			}
  			return -1;
  		case ROSE_AOC_AOCD_CHARGING_UNIT:
@@ -1281,16 +1283,16 @@
  			if (pri->debug & PRI_DEBUG_APDU) {
  				pri_message(pri, "ROSE %i: AOC-D Charging Unit - not handled!", operation_tag);
  				dump_apdu (pri, (u_int8_t *)comp, comp->len + 2);
-@@ -1644,7 +1785,7 @@
+@@ -1632,7 +1773,7 @@ int rose_invoke_decode(struct pri *pri, 
  		case ROSE_AOC_AOCE_CHARGING_UNIT:
  			return aoc_aoce_charging_unit_decode(pri, call, (u_int8_t *)comp, comp->len + 2);
  			if (0) { /* the following function is currently not used - just to make the compiler happy */
 -				aoc_aoce_charging_unit_encode(pri, call, call->aoc_units); /* use this function to forward the aoc-e on a bridged channel */ 
-+				aoc_aoce_charging_unit_encode(pri, call, call->aoc_units, 1); /* use this function to forward the aoc-e on a bridged channel */ 
++				aoc_aoce_charging_unit_encode(pri, call, call->aoc_units, 1); /* use this function to forward the aoc-e on a bridged channel */
  				return 0;
  			}
  		case ROSE_AOC_IDENTIFICATION_OF_CHARGE:
-@@ -1653,6 +1794,22 @@
+@@ -1641,6 +1782,22 @@ int rose_invoke_decode(struct pri *pri, 
  				dump_apdu (pri, (u_int8_t *)comp, comp->len + 2);
  			}
  			return -1;
@@ -1313,9 +1315,10 @@
  		default:
  			if (pri->debug & PRI_DEBUG_APDU) {
  				pri_message(pri, "!! Unable to handle ROSE operation %d", operation_tag);
-diff -urN libpri-1.4.1.orig/pri_facility.h libpri-1.4.1/pri_facility.h
---- libpri-1.4.1.orig/pri_facility.h	2006-02-14 20:22:26.000000000 +0100
-+++ libpri-1.4.1/pri_facility.h	2007-07-11 14:25:15.000000000 +0200
+Index: libpri-1.4.3/pri_facility.h
+===================================================================
+--- libpri-1.4.3.orig/pri_facility.h
++++ libpri-1.4.3/pri_facility.h
 @@ -34,7 +34,7 @@
  /* Operation ID values */
  /* Q.952 ROSE operations (Diverting) */
@@ -1343,7 +1346,7 @@
  /* ROSE definitions and data structures */
  #define INVOKE_IDENTIFIER			0x02
  #define INVOKE_LINKED_IDENTIFIER	0x80
-@@ -186,12 +191,6 @@
+@@ -186,12 +191,6 @@ struct rose_component {
  			(variable) = ((variable) << 8) | (component)->data[comp_idx]; \
  	} while (0)
  
@@ -1356,7 +1359,7 @@
  #define ASN1_ADD_SIMPLE(component, comptype, ptr, idx) \
  	do { \
  		(component) = (struct rose_component *)&((ptr)[(idx)]); \
-@@ -279,4 +278,10 @@
+@@ -279,4 +278,10 @@ int pri_call_add_standard_apdus(struct p
  
  int asn1_dump(struct pri *pri, void *comp, int len);
  
@@ -1367,9 +1370,10 @@
 +extern int aoc_aoce_charging_unit_encode(struct pri *pri, q931_call *c, long chargedunits, int send_facility_message);
 +
  #endif /* _PRI_FACILITY_H */
-diff -urN libpri-1.4.1.orig/pri_internal.h libpri-1.4.1/pri_internal.h
---- libpri-1.4.1.orig/pri_internal.h	2006-06-07 00:06:52.000000000 +0200
-+++ libpri-1.4.1/pri_internal.h	2007-07-11 14:25:15.000000000 +0200
+Index: libpri-1.4.3/pri_internal.h
+===================================================================
+--- libpri-1.4.3.orig/pri_internal.h
++++ libpri-1.4.3/pri_internal.h
 @@ -5,6 +5,8 @@
   *
   * Copyright (C) 2001, Linux Support Services, Inc.
@@ -1379,7 +1383,7 @@
   *
   * 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
-@@ -33,7 +35,10 @@
+@@ -34,7 +36,10 @@
  struct pri_sched {
  	struct timeval when;
  	void (*callback)(void *data);
@@ -1390,7 +1394,7 @@
  };
  
  struct q921_frame;
-@@ -41,8 +46,15 @@
+@@ -42,8 +47,15 @@ enum q931_state;
  enum q931_mode;
  
  /* No more than 128 scheduled events */
@@ -1406,7 +1410,7 @@
  #define MAX_TIMERS 32
  
  struct pri {
-@@ -54,6 +66,7 @@
+@@ -55,6 +67,7 @@ struct pri {
  	struct pri *master;		/* Master channel if appropriate */
  	struct pri_sched pri_sched[MAX_SCHED];	/* Scheduled events */
  	int debug;			/* Debug stuff */
@@ -1414,7 +1418,7 @@
  	int state;			/* State of D-channel */
  	int switchtype;		/* Switch type */
  	int nsf;		/* Network-Specific Facility (if any) */
-@@ -65,25 +78,42 @@
+@@ -66,25 +79,42 @@ struct pri {
  	int protodisc;
  	
  	/* Q.921 State */
@@ -1429,19 +1433,19 @@
 -	int retrans;		/* Retransmissions */
 -	int sentrej;		/* Are we in reject state */
 -	
-+  	int q921_state[Q921_MAX_TEIS];	
++  	int q921_state[Q921_MAX_TEIS];
 +  	char dchanup;
-+  	
++
 +  	/* 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; 
-+  
++
++  	unsigned int ri;
++
 +  	int busy[Q921_MAX_TEIS];			/* Peer is busy */
-+   
++
 +  	int window[Q921_MAX_TEIS];			/* Max window size */
 + 	int windowlen[Q921_MAX_TEIS];		/* Fullness of window */
 +  	int v_s[Q921_MAX_TEIS];			/* Next N(S) for transmission */
@@ -1451,9 +1455,9 @@
 +  	int solicitfbit[Q921_MAX_TEIS];	/* Have we sent an I or S frame with the F-bit set? */
 +  	int retrans[Q921_MAX_TEIS];		/* Retransmissions */
 +  	int sabme_retrans[Q921_MAX_TEIS];		/* Retransmissions */
-+  
++
 + 	int sentrej[Q921_MAX_TEIS];		/* Are we in reject state */
-+  	
++
 + 	/* Various timers */
 +  	int sabme_timer[Q921_MAX_TEIS];
 +  	int t203_timer[Q921_MAX_TEIS];
@@ -1461,7 +1465,7 @@
 +
 + 	int t201_timer[Q921_MAX_TEIS];
 +  	int t200_timer[Q921_MAX_TEIS];
-+ 
++
 +
  	int cref;			/* Next call reference value */
  	
@@ -1474,7 +1478,7 @@
  	/* All ISDN Timer values */
  	int timers[MAX_TIMERS];
  
-@@ -92,8 +122,8 @@
+@@ -93,8 +123,8 @@ struct pri {
  	int schedev;
  	pri_event ev;		/* Static event thingy */
  	
@@ -1485,7 +1489,7 @@
  	
  	/* Q.931 calls */
  	q931_call **callpool;
-@@ -112,6 +142,9 @@
+@@ -113,6 +143,9 @@ struct pri {
  
  	unsigned char last_invoke;	/* Last ROSE invoke ID */
  	unsigned char sendfacility;
@@ -1495,7 +1499,7 @@
  };
  
  struct pri_sr {
-@@ -121,6 +154,7 @@
+@@ -122,6 +155,7 @@ struct pri_sr {
  	int nonisdn;
  	char *caller;
  	int callerplan;
@@ -1503,7 +1507,7 @@
  	char *callername;
  	int callerpres;
  	char *called;
-@@ -133,6 +167,7 @@
+@@ -134,6 +168,7 @@ struct pri_sr {
  	int redirectingreason;
  	int justsignalling;
  	const char *useruserinfo;
@@ -1511,7 +1515,7 @@
  	int transferable;
  };
  
-@@ -171,8 +206,13 @@
+@@ -172,8 +207,13 @@ struct q931_call {
  	
  	int alive;			/* Whether or not the call is alive */
  	int acked;			/* Whether setup has been acked or not */
@@ -1519,13 +1523,13 @@
  	int sendhangupack;	/* Whether or not to send a hangup ack */
  	int proc;			/* Whether we've sent a call proceeding / alerting */
 + 	int alert;			/* Whether we've sent an alerting */
-+ 
++
 + 	int tei;
 + 	q921_call *phones;
  	
  	int ri;				/* Restart Indicator (Restart Indicator IE) */
  
-@@ -209,6 +249,8 @@
+@@ -210,6 +250,8 @@ struct q931_call {
  	char callerani[256];	/* Caller */
  	char callernum[256];
  	char callername[256];
@@ -1534,17 +1538,17 @@
  
  	char keypad_digits[64];		/* Buffer for digits that come in KEYPAD_FACILITY */
  
-@@ -229,6 +271,9 @@
+@@ -230,6 +272,9 @@ struct q931_call {
  	char redirectingnum[256];	/* Number of redirecting party */
  	char redirectingname[256];	/* Name of redirecting party */
  
-+ 	int t303timer;		
-+ 	int t303running;		
++ 	int t303timer;
++ 	int t303running;
 +
  	/* Filled in cases of multiple diversions */
  	int origcalledplan;
  	int origcalledpres;
-@@ -239,17 +284,28 @@
+@@ -240,17 +285,28 @@ struct q931_call {
  	int useruserprotocoldisc;
  	char useruserinfo[256];
  	char callingsubaddr[256];	/* Calling parties sub address */
@@ -1552,7 +1556,7 @@
 + 	char callid[10];	/* call identity for SUSPEND/RESUME */
 + 	char digits[256];	/* additional digits received via info msgs (cpn or keypad) */
 + 	char display[256];	/* display ie received in info msgs or for sending */
-+ 
++
 + 	/* euroisdn facility fun */
 + 	int facility; /* FACILTIY received */
 + 	int aoc;
@@ -1573,18 +1577,10 @@
  extern pri_event *pri_schedule_run(struct pri *pri);
  
  extern void pri_schedule_del(struct pri *pri, int ev);
-@@ -257,7 +313,7 @@
- extern pri_event *pri_mkerror(struct pri *pri, char *errstr);
- 
- extern void pri_message(struct pri *pri, char *fmt, ...);
--
-+  
- extern void pri_error(struct pri *pri, char *fmt, ...);
- 
- void libpri_copy_string(char *dst, const char *src, size_t size);
-diff -urN libpri-1.4.1.orig/pri_q921.h libpri-1.4.1/pri_q921.h
---- libpri-1.4.1.orig/pri_q921.h	2006-02-14 20:22:26.000000000 +0100
-+++ libpri-1.4.1/pri_q921.h	2007-07-11 14:25:15.000000000 +0200
+Index: libpri-1.4.3/pri_q921.h
+===================================================================
+--- libpri-1.4.3.orig/pri_q921.h
++++ libpri-1.4.3/pri_q921.h
 @@ -5,6 +5,8 @@
   *
   * Copyright (C) 2001, Linux Support Services, Inc.
@@ -1608,7 +1604,7 @@
  #define Q921_TEI_GR303_EOC_PATH			0
  #define Q921_TEI_GR303_EOC_OPS			4
  #define Q921_TEI_GR303_TMC_SWITCHING		0
-@@ -164,12 +173,14 @@
+@@ -164,12 +173,14 @@ typedef enum q921_state {
  extern void q921_dump(struct pri *pri, q921_h *h, int len, int showraw, int txrx);
  
  /* Bring up the D-channel */
@@ -1626,9 +1622,10 @@
 +extern int q921_transmit_iframe(struct pri *pri, void *buf, int len, int cr, int tei);
  
  #endif
-diff -urN libpri-1.4.1.orig/pri_q931.h libpri-1.4.1/pri_q931.h
---- libpri-1.4.1.orig/pri_q931.h	2006-07-06 23:11:37.000000000 +0200
-+++ libpri-1.4.1/pri_q931.h	2007-07-11 14:25:15.000000000 +0200
+Index: libpri-1.4.3/pri_q931.h
+===================================================================
+--- libpri-1.4.3.orig/pri_q931.h
++++ libpri-1.4.3/pri_q931.h
 @@ -5,6 +5,8 @@
   *
   * Copyright (C) 2001, Linux Support Services, Inc.
@@ -1638,7 +1635,7 @@
   *
   * 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
-@@ -190,6 +192,10 @@
+@@ -190,6 +192,10 @@ typedef struct q931_ie {
  #define Q931_IE_CODESET(x)		((x) >> 8)
  #define Q931_IE_IE(x)			((x) & 0xff)
  #define Q931_FULL_IE(codeset, ie)	(((codeset) << 8) | ((ie) & 0xff))
@@ -1649,7 +1646,7 @@
  
  #define Q931_DISPLAY					0x28
  #define Q931_IE_SEGMENTED_MSG			0x00
-@@ -218,6 +224,8 @@
+@@ -218,6 +224,8 @@ typedef struct q931_ie {
  #define Q931_IE_USER_USER				0x7E
  #define Q931_IE_ESCAPE_FOR_EXT			0x7F
  
@@ -1658,7 +1655,7 @@
  
  /* Call state stuff */
  #define Q931_CALL_STATE_NULL				0
-@@ -247,7 +255,7 @@
+@@ -247,7 +255,7 @@ typedef struct q931_ie {
  /* Q.SIG specific */
  #define QSIG_IE_TRANSIT_COUNT		0x31
  
@@ -1667,7 +1664,7 @@
  
  extern int q931_alerting(struct pri *pri, q931_call *call, int channel, int info);
  
-@@ -263,6 +271,10 @@
+@@ -263,6 +271,10 @@ extern int q931_information(struct pri *
  
  extern int q931_keypad_facility(struct pri *pri, q931_call *call, char *digits);
  
@@ -1678,7 +1675,7 @@
  extern int q931_connect(struct pri *pri, q931_call *call, int channel, int nonisdn);
  
  extern int q931_release(struct pri *pri, q931_call *call, int cause);
-@@ -271,6 +283,10 @@
+@@ -271,6 +283,10 @@ extern int q931_disconnect(struct pri *p
  
  extern int q931_hangup(struct pri *pri, q931_call *call, int cause);
  
@@ -1689,7 +1686,7 @@
  extern int q931_restart(struct pri *pri, int channel);
  
  extern int q931_facility(struct pri *pri, q931_call *call);
-@@ -286,6 +302,22 @@
+@@ -286,6 +302,22 @@ extern void q931_dump(struct pri *pri, q
  
  extern void __q931_destroycall(struct pri *pri, q931_call *c);
  
@@ -1698,7 +1695,7 @@
 +extern int q931_hold_reject(struct pri *pri, q931_call *c);
 +
 +extern int q931_retrieve_acknowledge(struct pri *pri, q931_call *c, int channel);
-+	
++
 +extern int q931_retrieve_reject(struct pri *pri, q931_call *c);
 +
 +extern int q931_suspend_acknowledge(struct pri *pri, q931_call *c, char *display);
@@ -1712,9 +1709,10 @@
  extern void q931_dl_indication(struct pri *pri, int event);
  
  #endif
-diff -urN libpri-1.4.1.orig/prisched.c libpri-1.4.1/prisched.c
---- libpri-1.4.1.orig/prisched.c	2006-02-14 20:22:26.000000000 +0100
-+++ libpri-1.4.1/prisched.c	2007-07-11 14:25:15.000000000 +0200
+Index: libpri-1.4.3/prisched.c
+===================================================================
+--- libpri-1.4.3.orig/prisched.c
++++ libpri-1.4.3/prisched.c
 @@ -1,10 +1,12 @@
  /*
   * libpri: An implementation of Primary Rate ISDN
@@ -1742,7 +1740,7 @@
  
  
  static int maxsched = 0;
-@@ -36,7 +37,7 @@
+@@ -36,7 +37,7 @@ int pri_schedule_event(struct pri *pri, 
  	int x;
  	struct timeval tv;
  	for (x=1;x<MAX_SCHED;x++)
@@ -1751,7 +1749,7 @@
  			break;
  	if (x == MAX_SCHED) {
  		pri_error(pri, "No more room in scheduler\n");
-@@ -53,7 +54,39 @@
+@@ -53,7 +54,39 @@ int pri_schedule_event(struct pri *pri, 
  	}
  	pri->pri_sched[x].when = tv;
  	pri->pri_sched[x].callback = function;
@@ -1791,16 +1789,16 @@
  	return x;
  }
  
-@@ -65,7 +98,7 @@
+@@ -65,7 +98,7 @@ struct timeval *pri_schedule_next(struct
  	if (pri->subchannel)
  		closest = pri_schedule_next(pri->subchannel);
  	for (x=1;x<MAX_SCHED;x++) {
 -		if (pri->pri_sched[x].callback && 
-+		if ((pri->pri_sched[x].callback || pri->pri_sched[x].callback2) && 
++		if ((pri->pri_sched[x].callback || pri->pri_sched[x].callback2) &&
  			(!closest || (closest->tv_sec > pri->pri_sched[x].when.tv_sec) ||
  				((closest->tv_sec == pri->pri_sched[x].when.tv_sec) && 
  				 (closest->tv_usec > pri->pri_sched[x].when.tv_usec))))
-@@ -76,26 +109,38 @@
+@@ -76,26 +109,38 @@ struct timeval *pri_schedule_next(struct
  
  static pri_event *__pri_schedule_run(struct pri *pri, struct timeval *tv)
  {
@@ -1844,16 +1842,17 @@
              if (pri->schedev)
                    return &pri->ev;
  	    }
-@@ -116,4 +161,6 @@
+@@ -116,4 +161,6 @@ void pri_schedule_del(struct pri *pri,in
  	if ((id >= MAX_SCHED) || (id < 0)) 
  		pri_error(pri, "Asked to delete sched id %d???\n", id);
  	pri->pri_sched[id].callback = NULL;
 +	pri->pri_sched[id].callback2 = NULL;
  }
 +
-diff -urN libpri-1.4.1.orig/pritest.c libpri-1.4.1/pritest.c
---- libpri-1.4.1.orig/pritest.c	2006-07-05 18:17:05.000000000 +0200
-+++ libpri-1.4.1/pritest.c	2007-07-11 14:25:15.000000000 +0200
+Index: libpri-1.4.3/pritest.c
+===================================================================
+--- libpri-1.4.3.orig/pritest.c
++++ libpri-1.4.3/pritest.c
 @@ -1,9 +1,9 @@
  /*
   * libpri: An implementation of Primary Rate ISDN
@@ -1877,7 +1876,7 @@
  
  
  static int offset = 0;
-@@ -56,7 +56,7 @@
+@@ -56,7 +56,7 @@ static int offset = 0;
  static void do_channel(ZAP *z)
  {
  	/* This is the part that runs on a given channel */
@@ -1886,7 +1885,7 @@
  }
  
  struct pri_chan {
-@@ -72,6 +72,14 @@
+@@ -72,6 +72,14 @@ static int str2node(char *node)
  		return PRI_CPE;
  	if (!strcasecmp(node, "network"))
  		return PRI_NETWORK;
@@ -1901,7 +1900,7 @@
  	return -1;
  }
  
-@@ -281,6 +289,10 @@
+@@ -281,6 +289,10 @@ static void handle_pri_event(struct pri 
  		}
  		
  		break;
@@ -1912,9 +1911,10 @@
  	default:
  		fprintf(stderr, "--!! Unknown PRI event %d\n", e->e);
  	}
-diff -urN libpri-1.4.1.orig/pri_timers.h libpri-1.4.1/pri_timers.h
---- libpri-1.4.1.orig/pri_timers.h	2006-02-14 20:22:26.000000000 +0100
-+++ libpri-1.4.1/pri_timers.h	2007-07-11 14:25:15.000000000 +0200
+Index: libpri-1.4.3/pri_timers.h
+===================================================================
+--- libpri-1.4.3.orig/pri_timers.h
++++ libpri-1.4.3/pri_timers.h
 @@ -25,19 +25,51 @@
  #ifndef _PRI_TIMERS_H
  #define _PRI_TIMERS_H
@@ -1980,9 +1980,10 @@
  
  /* XXX Only our default timers are setup now XXX */
  #define PRI_TIMERS_UNKNOWN PRI_TIMERS_DEFAULT
-diff -urN libpri-1.4.1.orig/q921.c libpri-1.4.1/q921.c
---- libpri-1.4.1.orig/q921.c	2006-07-06 23:11:37.000000000 +0200
-+++ libpri-1.4.1/q921.c	2007-07-11 14:25:15.000000000 +0200
+Index: libpri-1.4.3/q921.c
+===================================================================
+--- libpri-1.4.3.orig/q921.c
++++ libpri-1.4.3/q921.c
 @@ -1,10 +1,12 @@
  /*
   * libpri: An implementation of Primary Rate ISDN
@@ -1998,15 +1999,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 <stdio.h>
- #include <string.h>
- #include <stdlib.h>
 @@ -50,19 +52,24 @@
  	(hf).h.tei = (pri)->tei; \
  } while(0)
@@ -2023,7 +2015,7 @@
 -	f = pri->txqueue;
 +	int teio = tei - Q921_TEI_BASE;
 +	if (((teio < 0) || (teio > Q921_MAX_TEIS)) || (pri->localtype != BRI_NETWORK_PTMP)) { teio=0; }
-+	
++
 +	f = pri->txqueue[teio];
  	while(f) {
 -		p = f;
@@ -2040,7 +2032,7 @@
  }
  
  static int q921_transmit(struct pri *pri, q921_h *h, int len) 
-@@ -88,11 +95,15 @@
+@@ -88,11 +95,15 @@ static int q921_transmit(struct pri *pri
  		pri_error(pri, "Short write: %d/%d (%s)\n", res, len + 2, strerror(errno));
  		return -1;
  	}
@@ -2058,7 +2050,7 @@
  {
  	q921_h h;
  	Q921_INIT(pri, h);
-@@ -100,6 +111,7 @@
+@@ -100,6 +111,7 @@ static void q921_send_ua(struct pri *pri
  	h.u.m2 = 0;		/* M2 = 0 */
  	h.u.p_f = pfbit;	/* Final bit on */
  	h.u.ft = Q921_FRAMETYPE_U;
@@ -2066,7 +2058,7 @@
  	switch(pri->localtype) {
  	case PRI_NETWORK:
  		h.h.c_r = 0;
-@@ -107,6 +119,19 @@
+@@ -107,6 +119,19 @@ static void q921_send_ua(struct pri *pri
  	case PRI_CPE:
  		h.h.c_r = 1;
  		break;
@@ -2086,7 +2078,7 @@
  	default:
  		pri_error(pri, "Don't know how to U/A on a type %d node\n", pri->localtype);
  		return;
-@@ -116,18 +141,364 @@
+@@ -116,18 +141,364 @@ static void q921_send_ua(struct pri *pri
  	q921_transmit(pri, &h, 3);
  }
  
@@ -2129,8 +2121,7 @@
 + 	q921_transmit(pri, &h, 3);
 + }
 +*/
- 
--static void q921_send_sabme(void *vpri, int now)
++
 +static void q921_send_dm(struct pri *pri, int pfbit, int tei)
 +{
 + 	q921_h h;
@@ -2168,7 +2159,7 @@
 +  		pri_message(pri, "Sending DM\n");
 +  	q921_transmit(pri, &h, 3);
 +}
-+   
++
 +static void q921_send_teireq(void *vpri) {
 +    struct pri *pri = vpri;
 +    unsigned short ri=0x6464;
@@ -2176,10 +2167,10 @@
 +    ri = rand();
 +
 +    if (pri->localtype != BRI_CPE_PTMP) {
-+	pri_error(pri, "TEI req for non-ptmp???\n"); 
++	pri_error(pri, "TEI req for non-ptmp???\n");
 +  	return;
 +    }
-+    if (pri->t202_timer[0]) { 
++    if (pri->t202_timer[0]) {
 +	pri_schedule_del(pri, pri->t202_timer[0]);
 + 	pri->t202_timer[0] = 0;
 +    }
@@ -2197,18 +2188,18 @@
 +#endif
 +	return;
 +    }
-+ 
++
 +    pri->t202_timer[0] = pri_schedule_event(pri, pri->timers[PRI_TIMER_T202], q921_send_teireq, pri);
-+  
++
 +    pri->ri = ri;
 +    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 = 0;	
-+        f->h.ea1 = 0;	
-+        f->h.ea2 = 1;	
++	f->h.c_r = 0;
++        f->h.ea1 = 0;
++        f->h.ea2 = 1;
 +        f->m2 = 0;
 +        f->m3 = 0;
 +        f->ft = Q921_FRAMETYPE_U;
@@ -2222,23 +2213,23 @@
 +	q921_transmit(pri,(q921_h *)&(f->h),8);
 +    }
 +}
-+  
++
 +static void q921_send_teiassign(struct pri *pri,int ri,int tei) {
 +    q921_u *f;
-+  
++
 +    if (pri->localtype != BRI_NETWORK_PTMP) {
-+	pri_error(pri, "TEI assign for non-ptmp???\n"); 
++	pri_error(pri, "TEI assign 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;	
-+  	f->h.ea1 = 0;	
-+  	f->h.ea2 = 1;	
++  	f->h.c_r = 1;
++  	f->h.ea1 = 0;
++  	f->h.ea2 = 1;
 +  	f->m2 = 0;
 +  	f->m3 = 0;
 +  	f->ft = Q921_FRAMETYPE_U;
@@ -2255,25 +2246,25 @@
 +	pri_error(pri, "q921_send_teiassign: failed to malloc f!\n");
 +    }
 +}
-+  
++
 +static void q921_send_teichkresp(struct pri *pri,int tei) {
 +    q921_u *f;
 +    unsigned short ri=0x6464;
 +    ri = rand();
-+  
++
 +    if (pri->localtype != BRI_CPE_PTMP) {
-+	pri_error(pri, "TEI check response for non-ptmp???\n"); 
++	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 = 0; // command u->n	
-+  	f->h.ea1 = 0;	
-+  	f->h.ea2 = 1;	
++  	f->h.c_r = 0; // command u->n
++  	f->h.ea1 = 0;
++  	f->h.ea2 = 1;
 +  	f->m2 = 0;
 +  	f->m3 = 0;
 +  	f->ft = Q921_FRAMETYPE_U;
@@ -2293,20 +2284,20 @@
 +    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"); 
++	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->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;
@@ -2321,23 +2312,23 @@
 +  	free(f);
 +    }
 +}
-+ 
++
 +static void q921_send_teiverify(struct pri *pri,int tei) {
 +    q921_u *f;
-+  
++
 +    if ((pri->localtype != BRI_CPE) && (pri->localtype != BRI_CPE_PTMP)) {
-+  	pri_error(pri, "TEI verify for non-ptmp???\n"); 
++  	pri_error(pri, "TEI verify 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 = 0; // command u->n	
-+  	f->h.ea1 = 0;	
-+  	f->h.ea2 = 1;	
++  	f->h.c_r = 0; // command u->n
++  	f->h.ea1 = 0;
++  	f->h.ea2 = 1;
 +  	f->m2 = 0;
 +  	f->m3 = 0;
 +  	f->ft = Q921_FRAMETYPE_U;
@@ -2357,20 +2348,20 @@
 +      q921_u *f;
 +      unsigned short ri=0x6464;
 +      ri = rand();
-+  
++
 +      if (pri->localtype != BRI_NETWORK_PTMP) {
-+  	pri_error(pri, "TEI remove for non-ptmp???\n"); 
++  	pri_error(pri, "TEI remove 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;	
-+  	f->h.ea1 = 0;	
-+  	f->h.ea2 = 1;	
++  	f->h.c_r = 1;
++  	f->h.ea1 = 0;
++  	f->h.ea2 = 1;
 +  	f->m2 = 0;
 +  	f->m3 = 0;
 +  	f->ft = Q921_FRAMETYPE_U;
@@ -2385,23 +2376,23 @@
 +  	free(f);
 +      }
 +}
-+  
++
 +static void q921_send_teidenied(struct pri *pri, int ri, int tei) {
 +      q921_u *f;
-+  
++
 +      if (pri->localtype != BRI_NETWORK_PTMP) {
-+  	pri_error(pri, "TEI ID denied for non-ptmp???\n"); 
++  	pri_error(pri, "TEI ID denied 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;	
-+  	f->h.ea1 = 0;	
-+  	f->h.ea2 = 1;	
++  	f->h.c_r = 1;
++  	f->h.ea1 = 0;
++  	f->h.ea2 = 1;
 +  	f->m2 = 0;
 +  	f->m3 = 0;
 +  	f->ft = Q921_FRAMETYPE_U;
@@ -2416,10 +2407,11 @@
 +  	free(f);
 +      }
 +}
-+  
-+ 
++
+ 
+-static void q921_send_sabme(void *vpri, int now)
 +static void q921_send_sabme_now(void *vpri, int tei);
-+  
++
 +static void q921_send_sabme(void *vpri, int now, int tei)
  {
  	struct pri *pri = vpri;
@@ -2429,7 +2421,7 @@
 -	pri->sabme_timer = pri_schedule_event(pri, pri->timers[PRI_TIMER_T200], q921_send_sabme_now, pri);
 +  	int teio=tei - Q921_TEI_BASE;
 +  	if (((teio < 0) || (teio > Q921_MAX_TEIS)) || (pri->localtype != BRI_NETWORK_PTMP)) { teio=0; }
-+  
++
 +  	if (pri->sabme_timer[teio]) {
 +  	    pri_schedule_del(pri, pri->sabme_timer[teio]);
 +  	    pri->sabme_timer[teio] = 0;
@@ -2456,7 +2448,7 @@
  	h.u.m3 = 3;	/* M3 = 3 */
  	h.u.m2 = 3;	/* M2 = 3 */
  	h.u.p_f = 1;	/* Poll bit set */
-@@ -139,27 +510,44 @@
+@@ -139,27 +510,44 @@ static void q921_send_sabme(void *vpri, 
  	case PRI_CPE:
  		h.h.c_r = 0;
  		break;
@@ -2494,9 +2486,9 @@
 -	q921_send_sabme(vpri, 1);
 +	q921_send_sabme(vpri, 1, tei);
  }
-+  
  
 -static int q921_ack_packet(struct pri *pri, int num)
++
 +static int q921_ack_packet(struct pri *pri, int num, int tei)
  {
  	struct q921_frame *f, *prev = NULL;
@@ -2508,7 +2500,7 @@
  	while(f) {
  		if (f->h.n_s == num) {
  			/* Cancel each packet as necessary */
-@@ -167,26 +555,26 @@
+@@ -167,26 +555,26 @@ static int q921_ack_packet(struct pri *p
  			if (prev)
  				prev->next = f->next;
  			else
@@ -2543,7 +2535,7 @@
  					q921_transmit(pri, (q921_h *)(&f->h), f->len);
  					break;
  				}
-@@ -200,77 +588,130 @@
+@@ -200,77 +588,130 @@ static int q921_ack_packet(struct pri *p
  	return 0;
  }
  
@@ -2579,7 +2571,7 @@
 -			pri_message(pri, "-- Restarting T203 counter\n");
 -		/* Nothing to transmit, start the T203 counter instead */
 -		pri->t203_timer = pri_schedule_event(pri, pri->timers[PRI_TIMER_T203], t203_expire, pri);
-+	struct q921_frame *f, *tmp = NULL;	
++	struct q921_frame *f, *tmp = NULL;
 +	int teio=tei - Q921_TEI_BASE;
 +	if (((teio < 0) || (teio > Q921_MAX_TEIS)) || (pri->localtype != BRI_NETWORK_PTMP)) { teio=0; }
 +	f = pri->txqueue[teio];
@@ -2604,7 +2596,7 @@
 +		f = f->next;
 +	    }
 +	}
-+	
++
 +	if (devnull) {
 +	    pri->txqueue[teio] = NULL;
 +	    pri->v_s[teio] = 0;
@@ -2650,8 +2642,8 @@
 -		cnt += q921_ack_packet(pri, x);	
 -	if (!pri->txqueue) {
 +		pri_message(pri, "-- ACKing all packets from %d to (but not including) %d\n", pri->v_a[teio], ack);
-+	for (x=pri->v_a[teio]; x != ack; Q921_INC(x)) 
-+		cnt += q921_ack_packet(pri, x, tei);	
++	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 */
 +		pri_schedule_del(pri, pri->t200_timer[teio]);
@@ -2706,7 +2698,7 @@
  	h.s.p_f = pf;	
  	switch(pri->localtype) {
  	case PRI_NETWORK:
-@@ -279,23 +720,38 @@
+@@ -279,23 +720,38 @@ static void q921_reject(struct pri *pri,
  	case PRI_CPE:
  		h.h.c_r = 1;
  		break;
@@ -2750,7 +2742,7 @@
  	h.s.p_f = pbit;		/* Poll/Final set appropriately */
  	switch(pri->localtype) {
  	case PRI_NETWORK:
-@@ -310,85 +766,190 @@
+@@ -310,85 +766,190 @@ static void q921_rr(struct pri *pri, int
  		else
  			h.h.c_r = 1;
  		break;
@@ -2806,7 +2798,7 @@
  			pri_message(pri, "-- T200 counter expired, What to do...\n");
  		/* Force Poll bit */
 -		pri->txqueue->h.p_f = 1;	
-+		pri->txqueue[teio]->h.p_f = 1;	
++		pri->txqueue[teio]->h.p_f = 1;
  		/* Update nr */
 -		pri->txqueue->h.n_r = pri->v_r;
 -		pri->v_na = pri->v_r;
@@ -2825,11 +2817,11 @@
 -		if (pri->busy) 
 -			q921_rr(pri, 1, 1);
 +            pri_message(pri, "-- Retransmitting %d bytes\n", pri->txqueue[teio]->len);
-+		if (pri->busy[teio]) 
++		if (pri->busy[teio])
 +			q921_rr(pri, 1, 1, tei);
  		else {
 -			if (!pri->txqueue->transmitted) 
-+			if (!pri->txqueue[teio]->transmitted) 
++			if (!pri->txqueue[teio]->transmitted)
  				pri_error(pri, "!! Not good - head of queue has not been transmitted yet\n");
 -			q921_transmit(pri, (q921_h *)&pri->txqueue->h, pri->txqueue->len);
 +			q921_transmit(pri, (q921_h *)&pri->txqueue[teio]->h, pri->txqueue[teio]->len);
@@ -2978,7 +2970,7 @@
  	f = malloc(sizeof(q921_frame) + len + 2);
  	if (f) {
  		memset(f,0,sizeof(q921_frame) + len + 2);
-@@ -406,48 +967,81 @@
+@@ -406,48 +967,81 @@ int q921_transmit_iframe(struct pri *pri
  			else
  				f->h.h.c_r = 1;
  		break;
@@ -3037,7 +3029,7 @@
 +		if  ((pri->q921_state[teio] != Q921_LINK_CONNECTION_ESTABLISHED) && ((pri->localtype == BRI_CPE_PTMP) || (pri->localtype == BRI_CPE) || (pri->localtype == BRI_NETWORK))){
 +		    /* no p2p datalink, yet. queue up the iframes... */
 +		    if (pri->debug & PRI_DEBUG_Q921_STATE)
-+			pri_message(pri, "Layer 3 transmit waiting for layer 2\n");		
++			pri_message(pri, "Layer 3 transmit waiting for layer 2\n");
 +		} else {
 +		    /* Immediately transmit unless we're in a recovery state, or the window
 +		      size is too big */
@@ -3081,7 +3073,7 @@
  	} else {
  		pri_error(pri, "!! Out of memory for Q.921 transmit\n");
  		return -1;
-@@ -455,49 +1049,78 @@
+@@ -455,49 +1049,78 @@ int q921_transmit_iframe(struct pri *pri
  	return 0;
  }
  
@@ -3172,12 +3164,12 @@
  		/* Send an RR if one wasn't sent already */
 -		if (pri->v_na != pri->v_r) 
 -			q921_rr(pri, 0, 0);
-+		if (pri->v_na[teio] != pri->v_r[teio]) 
++		if (pri->v_na[teio] != pri->v_r[teio])
 +			q921_rr(pri, 0, 0, i->h.tei);
  		if (res == -1) {
  			return NULL;
  		}
-@@ -506,10 +1129,10 @@
+@@ -506,10 +1129,10 @@ static pri_event *q921_handle_iframe(str
  	} else {
  		/* If we haven't already sent a reject, send it now, otherwise
  		   we are obliged to RR */
@@ -3191,7 +3183,7 @@
  	}
  	return NULL;
  }
-@@ -647,72 +1270,135 @@
+@@ -647,72 +1270,135 @@ void q921_dump(struct pri *pri, q921_h *
  	};
  }
  
@@ -3236,12 +3228,12 @@
 + 	    pri_schedule_del(pri, pri->sabme_timer[teio]);
 + 	    pri->sabme_timer[teio] = 0;
 + 	}
-+ 	
++
 + 	if (pri->t202_timer[teio]) {
 + 	    pri_schedule_del(pri, pri->t202_timer[teio]);
 + 	    pri->t202_timer[teio] = 0;
 + 	}
-+ 	
++
 +/* neonova test */
 + 	if (pri->t203_timer[teio]) {
 + 	    pri_schedule_del(pri, pri->t203_timer[teio]);
@@ -3263,10 +3255,6 @@
  	
 -	/* Notify Layer 3 */
 -	q931_dl_indication(pri, PRI_EVENT_DCHAN_UP);
--
--	/* Report event that D-Channel is now up */
--	pri->ev.gen.e = PRI_EVENT_DCHAN_UP;
--	return &pri->ev;
 +	if  (((pri->localtype == BRI_CPE_PTMP) || (pri->localtype == BRI_CPE) || (pri->localtype == BRI_NETWORK)) && (pri->txqueue[teio])) {
 +	    /* transmit queued iframes ans start T200 (handled by flush_txqueue) */
 +	    q921_flush_txqueue(pri, tei, 0);
@@ -3275,7 +3263,10 @@
 +	} else {
 +	    /* Start the T203 timer */
 +	    pri->t203_timer[teio] = pri_schedule_event2(pri, pri->timers[PRI_TIMER_T203], t203_expire, pri, tei);
-+	    
+ 
+-	/* Report event that D-Channel is now up */
+-	pri->ev.gen.e = PRI_EVENT_DCHAN_UP;
+-	return &pri->ev;
 +	    /* Report event that D-Channel is now up */
 +	    pri->ev.gen.e = PRI_EVENT_DCHAN_UP;
 +	    pri->ev.gen.tei = tei;
@@ -3305,10 +3296,10 @@
 + 		}
 + 	    }
 + 	}
++
++	q921_reset(pri, tei, 1);
  
 -	/* Report event that D-Channel is now up */
-+	q921_reset(pri, tei, 1);
-+	
 + 	/* Report event that D-Channel is now down */
  	pri->ev.gen.e = PRI_EVENT_DCHAN_DOWN;
 + 	pri->ev.gen.tei = tei;
@@ -3374,7 +3365,7 @@
  }
  
  static pri_event *__q921_receive_qualified(struct pri *pri, q921_h *h, int len)
-@@ -720,12 +1406,16 @@
+@@ -720,12 +1406,16 @@ static pri_event *__q921_receive_qualifi
  	q921_frame *f;
  	pri_event *ev;
  	int sendnow;
@@ -3393,7 +3384,7 @@
  			return NULL;
  		}
  		/* Informational frame */
-@@ -736,8 +1426,10 @@
+@@ -736,8 +1426,10 @@ static pri_event *__q921_receive_qualifi
  		return q921_handle_iframe(pri, &h->i, len);	
  		break;
  	case 1:
@@ -3405,7 +3396,7 @@
  			return NULL;
  		}
  		if (len < 4) {
-@@ -747,56 +1439,75 @@
+@@ -747,56 +1439,75 @@ static pri_event *__q921_receive_qualifi
  		switch(h->s.ss) {
  		case 0:
  			/* Receiver Ready */
@@ -3453,13 +3444,13 @@
 +		    q921_rr(pri, h->s.p_f, 0, h->h.tei);
 +//	    	}
 +	    }
-+	 }
+ 	 }
+-         pri->busy = 1;
 +         pri->busy[teio] = 1;
 +	 if (pri->t200_timer[teio]) {
 +	    pri_schedule_del(pri, pri->t200_timer[teio]);
 +	    pri->t200_timer[teio] = 0;
- 	 }
--         pri->busy = 1;
++	 }
 +	 pri->t200_timer[teio] = pri_schedule_event2(pri, pri->timers[PRI_TIMER_T200], t200_expire, pri, h->h.tei);
           break;   
        case 2:
@@ -3497,7 +3488,7 @@
                       /* This should never happen */
  		     if (!h->s.p_f || h->s.n_r) {
  			pri_error(pri, "!! Got reject for frame %d, but we only have others!\n", h->s.n_r);
-@@ -804,23 +1515,37 @@
+@@ -804,23 +1515,37 @@ static pri_event *__q921_receive_qualifi
                 } else {
                       /* Hrm, we have nothing to send, but have been REJ'd.  Reset v_a, v_s, etc */
  				pri_error(pri, "!! Got reject for frame %d, but we have nothing -- resetting!\n", h->s.n_r);
@@ -3545,7 +3536,7 @@
  		}
  		break;
  	case 3:
-@@ -837,8 +1562,16 @@
+@@ -837,8 +1562,16 @@ static pri_event *__q921_receive_qualifi
  					if (pri->debug & (PRI_DEBUG_Q921_STATE | PRI_DEBUG_Q921_DUMP))
  						pri_message(pri, "-- Got DM Mode from peer.\n");
  					/* Disconnected mode, try again after T200 */
@@ -3564,7 +3555,7 @@
  					return ev;
  						
  				} else {
-@@ -846,21 +1579,153 @@
+@@ -846,21 +1579,153 @@ static pri_event *__q921_receive_qualifi
  						pri_message(pri, "-- Ignoring unsolicited DM with p/f set to 0\n");
  #if 0
  					/* Requesting that we start */
@@ -3598,7 +3589,7 @@
 + 							pri_schedule_del(pri, pri->t202_timer[0]);
 + 							pri->t202_timer[0] = 0;
 + 						    }
-+ 						    pri->tei = h->u.data[4] >> 1; 
++ 						    pri->tei = h->u.data[4] >> 1;
 + 						    pri->ri = 0;
 + 						    if (pri->debug & PRI_DEBUG_Q921_STATE)
 + 							pri_message(pri, "received TEI assign TEI = %d ri=%d\n",pri->tei,(unsigned short) (h->u.data[1] << 8) + h->u.data[2]);
@@ -3609,7 +3600,7 @@
 + 					    case Q921_TEI_ID_REMOVE:
 + 					    	if (pri->localtype != BRI_CPE_PTMP)
 + 						    break;
-+ 						if (((h->u.data[4] >> 1) == Q921_TEI_GROUP) || (pri->tei == (h->u.data[4] >> 1))){ 
++ 						if (((h->u.data[4] >> 1) == Q921_TEI_GROUP) || (pri->tei == (h->u.data[4] >> 1))){
 + 						    if (pri->debug & PRI_DEBUG_Q921_STATE)
 + 							pri_message(pri, "received TEI remove TEI = %d\n",pri->tei);
 + 						    pri->tei = 0;
@@ -3622,14 +3613,14 @@
 + 					    case Q921_TEI_ID_REQUEST:
 + 						if (pri->localtype != BRI_NETWORK_PTMP)
 + 						    break;
-+ 						
++
 + 						tei = h->u.data[4] >> 1;
 + 						if (tei != Q921_TEI_GROUP) {
 + 						    pri_message(pri, "got TEI request for unavailable TEI..\n");
 + 						    q921_send_teidenied(pri,((unsigned int)(h->u.data[1] << 8) + h->u.data[2]),h->u.data[4] >> 1);
 + 						    break;
 + 						}
-+ 						
++
 + 						for (tei=0;tei<Q921_MAX_TEIS;tei++) {
 + 						    if (pri->q921_teis[tei] == 0) {
 + 						        pri->q921_teis[tei] = 1;
@@ -3641,7 +3632,7 @@
 + 						} else {
 + 						    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:
@@ -3669,13 +3660,13 @@
 + 					    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);
-+ 					} 
++ 					}
 + 					break;
 +  					case Q931_PROTOCOL_DISCRIMINATOR:
-+ 					    if ((pri->localtype == BRI_CPE_PTMP) || (pri->localtype == BRI_CPE)){ 
++ 					    if ((pri->localtype == BRI_CPE_PTMP) || (pri->localtype == BRI_CPE)){
 + 						res = q931_receive(pri, (q931_h *)h->u.data, len-3, h->h.tei);
 +  						/* Send an RR if one wasn't sent already */
-+ 						if (pri->v_na[teio] != pri->v_r[teio]) 
++ 						if (pri->v_na[teio] != pri->v_r[teio])
 + 						    q921_rr(pri, 0, 0, pri->tei);
 + 						if (res == -1) {
 + 						    return NULL;
@@ -3723,7 +3714,7 @@
  			return ev;
  		case 3:
  			if (h->u.m2 == 3) {
-@@ -882,17 +1747,29 @@
+@@ -882,17 +1747,29 @@ static pri_event *__q921_receive_qualifi
  					}
  				}
  				/* Send Unnumbered Acknowledgement */
@@ -3759,7 +3750,7 @@
  			} else 
  				pri_error(pri, "!! Weird frame received (m3=3, m2 = %d)\n", h->u.m2);
  			break;
-@@ -916,20 +1793,44 @@
+@@ -916,20 +1793,44 @@ static pri_event *__q921_receive(struct 
  	pri_event *ev;
  	/* Discard FCS */
  	len -= 2;
@@ -3793,13 +3784,13 @@
 + 		if ((pri->q921_teis[h->h.tei - Q921_TEI_BASE] != 1) && (h->h.tei != Q921_TEI_GROUP)) {
 + 		    if (pri->debug & PRI_DEBUG_Q921_DUMP)
 + 			pri_message(pri, "Received a Q.921 message from unassigned TEI %d.. Sending DM and assigning.\n", h->h.tei);
-+ 		    // send DM 
++ 		    // send DM
 + 		    q921_send_dm(pri, 1, h->h.tei);
-+ 		    pri->q921_teis[h->h.tei - Q921_TEI_BASE] = 1; 
++ 		    pri->q921_teis[h->h.tei - Q921_TEI_BASE] = 1;
 + 		}
 + 	    }
-+ 	}    
-+	
++ 	}
++
 +	if (!pri->master && pri->debug & (PRI_DEBUG_Q921_DUMP | PRI_DEBUG_Q921_RAW))
 +		q921_dump(pri, h, len, pri->debug & PRI_DEBUG_Q921_RAW, 0);
  
@@ -3811,7 +3802,7 @@
  #ifdef PROCESS_SUBCHANNELS
  		/* If it's not us, try any subchannels we have */
  		if (pri->subchannel)
-@@ -937,10 +1838,16 @@
+@@ -937,10 +1838,16 @@ static pri_event *__q921_receive(struct 
  		else 
  #endif
  			return NULL;
@@ -3830,7 +3821,7 @@
  	return ev;
  }
  
-@@ -954,14 +1861,58 @@
+@@ -954,14 +1861,58 @@ pri_event *q921_receive(struct pri *pri,
  	return e;
  }
  
@@ -3860,12 +3851,12 @@
 +	    q921_reset(pri,0,1);
 +	}
 + 	/* Do the SABME XXX Maybe we should implement T_WAIT? XXX */
-+	if ((pri->localtype == PRI_NETWORK) || (pri->localtype == PRI_CPE) || (pri->localtype == BRI_NETWORK) || (pri->localtype == BRI_CPE)) { 
++	if ((pri->localtype == PRI_NETWORK) || (pri->localtype == PRI_CPE) || (pri->localtype == BRI_NETWORK) || (pri->localtype == BRI_CPE)) {
 +	    pri->sabme_retrans[0] = 0;
 +	    q921_send_sabme(pri, now, 0);
 +	}
-+	
-+	if (pri->localtype == BRI_NETWORK_PTMP) { 
++
++	if (pri->localtype == BRI_NETWORK_PTMP) {
 +	    if (tei == 0) {
 +		// initial start or complete restart
 +		q921_send_teiremove(pri, 127);
@@ -3879,8 +3870,8 @@
 +		// restart of a single p2p datalink
 +		q921_start_tei(pri,tei);
 +	    }
-+	} 
-+	if (pri->localtype == BRI_CPE_PTMP){ 
++	}
++	if (pri->localtype == BRI_CPE_PTMP){
 +	    if (tei == 0) {
 +#ifdef RELAX_TRB
 +		/* let's get a TEI */
@@ -3889,7 +3880,7 @@
 +	    } else {
 +		/* save the planet by recycling */
 +		pri->sabme_retrans[0] = 0;
-+		q921_send_sabme(pri, now, tei);		
++		q921_send_sabme(pri, now, tei);
 +	    }
  	}
 -	/* Reset our interface */
@@ -3897,9 +3888,10 @@
 -	/* Do the SABME XXX Maybe we should implement T_WAIT? XXX */
 -	q921_send_sabme(pri, now);
  }
-diff -urN libpri-1.4.1.orig/q931.c libpri-1.4.1/q931.c
---- libpri-1.4.1.orig/q931.c	2007-06-19 20:23:36.000000000 +0200
-+++ libpri-1.4.1/q931.c	2007-07-11 14:25:15.000000000 +0200
+Index: libpri-1.4.3/q931.c
+===================================================================
+--- libpri-1.4.3.orig/q931.c
++++ libpri-1.4.3/q931.c
 @@ -1,10 +1,12 @@
  /*
   * libpri: An implementation of Primary Rate ISDN
@@ -3915,15 +3907,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>
@@ -3932,14 +3915,14 @@
  #include <string.h>
  #include <ctype.h>
  #include <stdio.h>
-@@ -208,6 +211,14 @@
+@@ -208,6 +211,14 @@ static struct msgtype facilities[] = {
  #define LOC_INTERNATIONAL_NETWORK	0x7
  #define LOC_NETWORK_BEYOND_INTERWORKING	0xa
  
 +struct q921_call {
-+ int tei;	
-+ int proc;		
-+ int channel;	
++ int tei;
++ int proc;
++ int channel;
 + q921_call *next;
 +};
 +
@@ -3947,7 +3930,7 @@
  static char *ie2str(int ie);
  static char *msg2str(int msg);
  
-@@ -256,6 +267,7 @@
+@@ -256,6 +267,7 @@ static char *code2str(int code, struct m
  static void call_init(struct q931_call *c)
  {
  	memset(c, 0, sizeof(*c));
@@ -3955,7 +3938,7 @@
  	c->alive = 0;
  	c->sendhangupack = 0;
  	c->forceinvert = -1;	
-@@ -268,8 +280,16 @@
+@@ -268,8 +280,16 @@ static void call_init(struct q931_call *
  	c->next = NULL;
  	c->sentchannel = 0;
  	c->newcall = 1;
@@ -3972,7 +3955,7 @@
  }
  
  static char *binary(int b, int len) {
-@@ -287,14 +307,17 @@
+@@ -287,14 +307,17 @@ static FUNC_RECV(receive_channel_id)
  {	
  	int x;
  	int pos=0;
@@ -3996,7 +3979,7 @@
  		case 0:
  			call->justsignalling = 1;
  			break;
-@@ -303,6 +326,7 @@
+@@ -303,6 +326,7 @@ static FUNC_RECV(receive_channel_id)
  		default:
  			pri_error(pri, "!! Unexpected Channel selection %d\n", ie->data[0] & 3);
  			return -1;
@@ -4004,7 +3987,7 @@
  	}
  #endif
  	if (ie->data[0] & 0x08)
-@@ -364,10 +388,16 @@
+@@ -364,10 +388,16 @@ static FUNC_SEND(transmit_channel_id)
  	}
  		
  	/* Start with standard stuff */
@@ -4023,7 +4006,7 @@
  	/* Add exclusive flag if necessary */
  	if (call->chanflags & FLAG_EXCLUSIVE)
  		ie->data[pos] |= 0x08;
-@@ -384,6 +414,7 @@
+@@ -384,6 +414,7 @@ static FUNC_SEND(transmit_channel_id)
  	} else
  		pos++;
  	if ((call->channelno > -1) || (call->slotmap != -1)) {
@@ -4031,7 +4014,7 @@
  		/* We'll have the octet 8.2 and 8.3's present */
  		ie->data[pos++] = 0x83;
  		if (call->channelno > -1) {
-@@ -399,11 +430,43 @@
+@@ -399,11 +430,43 @@ static FUNC_SEND(transmit_channel_id)
  			ie->data[pos++] = (call->slotmap & 0xff);
  			return pos + 2;
  		}
@@ -4057,13 +4040,13 @@
 + 		    }
 + 		}
 + 		return pos + 2;
-+ 	    }	
++ 	    }
 +         } else {
 + 	    if (pri->localtype == BRI_CPE) {
 + 	        ie->data[pos++] = 0x80 | 3;
 + 	        return pos + 2;
 + 	    }
-+ 	}	
++ 	}
 +
  	if (call->ds1no > 0) {
  		/* We're done */
@@ -4072,11 +4055,11 @@
 + 	if (msgtype == Q931_RESTART_ACKNOWLEDGE) {
 +	    /* restart complete interface! */
 +	    return 0;
-+	}	
++	}
  	pri_error(pri, "!! No channel map, no channel, and no ds1?  What am I supposed to identify?\n");
  	return -1;
  }
-@@ -749,9 +812,13 @@
+@@ -750,9 +813,13 @@ char *pri_pres2str(int pres)
  	return code2str(pres, press, sizeof(press) / sizeof(press[0]));
  }
  
@@ -4092,7 +4075,7 @@
  		num[0] = 0;
  		return;
  	}
-@@ -761,7 +828,7 @@
+@@ -762,7 +829,7 @@ static void q931_get_number(unsigned cha
  
  static FUNC_DUMP(dump_called_party_number)
  {
@@ -4101,7 +4084,7 @@
  
  	q931_get_number(cnum, sizeof(cnum), ie->data + 1, len - 3);
  	pri_message(pri, "%c Called Number (len=%2d) [ Ext: %d  TON: %s (%d)  NPI: %s (%d)  '%s' ]\n",
-@@ -770,7 +837,7 @@
+@@ -771,7 +838,7 @@ static FUNC_DUMP(dump_called_party_numbe
  
  static FUNC_DUMP(dump_called_party_subaddr)
  {
@@ -4110,7 +4093,7 @@
  	q931_get_number(cnum, sizeof(cnum), ie->data + 1, len - 3);
  	pri_message(pri, "%c Called Sub-Address (len=%2d) [ Ext: %d  Type: %s (%d)  O: %d  '%s' ]\n",
  		prefix, len, ie->data[0] >> 7,
-@@ -780,7 +847,7 @@
+@@ -781,7 +848,7 @@ static FUNC_DUMP(dump_called_party_subad
  
  static FUNC_DUMP(dump_calling_party_number)
  {
@@ -4119,7 +4102,7 @@
  	if (ie->data[0] & 0x80)
  		q931_get_number(cnum, sizeof(cnum), ie->data + 1, len - 3);
  	else
-@@ -794,7 +861,7 @@
+@@ -795,7 +862,7 @@ static FUNC_DUMP(dump_calling_party_numb
  
  static FUNC_DUMP(dump_calling_party_subaddr)
  {
@@ -4128,7 +4111,7 @@
  	q931_get_number(cnum, sizeof(cnum), ie->data + 1, len - 3);
  	pri_message(pri, "%c Calling Sub-Address (len=%2d) [ Ext: %d  Type: %s (%d)  O: %d  '%s' ]\n",
  		prefix, len, ie->data[0] >> 7,
-@@ -804,7 +871,7 @@
+@@ -805,7 +872,7 @@ static FUNC_DUMP(dump_calling_party_suba
  
  static FUNC_DUMP(dump_redirecting_number)
  {
@@ -4137,7 +4120,7 @@
  	int i = 0;
  	/* To follow Q.931 (4.5.1), we must search for start of octet 4 by
  	   walking through all bytes until one with ext bit (8) set to 1 */
-@@ -831,7 +898,7 @@
+@@ -832,7 +899,7 @@ static FUNC_DUMP(dump_redirecting_number
  
  static FUNC_DUMP(dump_connected_number)
  {
@@ -4146,7 +4129,7 @@
  	int i = 0;
  	/* To follow Q.931 (4.5.1), we must search for start of octet 4 by
  	   walking through all bytes until one with ext bit (8) set to 1 */
-@@ -873,7 +940,7 @@
+@@ -874,7 +941,7 @@ static FUNC_RECV(receive_redirecting_num
  		}
  	}
  	while(!(ie->data[i++] & 0x80));
@@ -4155,7 +4138,7 @@
  	return 0;
  }
  
-@@ -881,7 +948,7 @@
+@@ -882,7 +949,7 @@ static FUNC_SEND(transmit_redirecting_nu
  {
  	if (order > 1)
  		return 0;
@@ -4164,7 +4147,7 @@
  		ie->data[0] = call->redirectingplan;
  		ie->data[1] = call->redirectingpres;
  		ie->data[2] = (call->redirectingreason & 0x0f) | 0x80;
-@@ -893,7 +960,7 @@
+@@ -894,7 +961,7 @@ static FUNC_SEND(transmit_redirecting_nu
  
  static FUNC_DUMP(dump_redirecting_subaddr)
  {
@@ -4173,7 +4156,7 @@
  	q931_get_number(cnum, sizeof(cnum), ie->data + 2, len - 4);
  	pri_message(pri, "%c Redirecting Sub-Address (len=%2d) [ Ext: %d  Type: %s (%d)  O: %d  '%s' ]\n",
  		prefix, len, ie->data[0] >> 7,
-@@ -904,14 +971,14 @@
+@@ -905,14 +972,14 @@ static FUNC_DUMP(dump_redirecting_subadd
  static FUNC_RECV(receive_calling_party_subaddr)
  {
  	/* copy digits to call->callingsubaddr */
@@ -4190,7 +4173,7 @@
  	call->calledplan = ie->data[0] & 0x7f;
  	return 0;
  }
-@@ -941,7 +1008,7 @@
+@@ -942,7 +1009,7 @@ static FUNC_RECV(receive_calling_party_n
  
  	if (call->callerpres == PRES_ALLOWED_NETWORK_NUMBER ||
  		call->callerpres == PRES_PROHIB_NETWORK_NUMBER) {
@@ -4199,7 +4182,7 @@
  		call->callerplanani = ie->data[0] & 0x7f;
  
  		if (!*call->callernum) { /*Copy ANI to CallerID if CallerID is not already set */
-@@ -950,7 +1017,7 @@
+@@ -951,7 +1018,7 @@ static FUNC_RECV(receive_calling_party_n
  		}
  		
  	} else {
@@ -4208,16 +4191,16 @@
  		call->callerplan = ie->data[0] & 0x7f;
  	}
  
-@@ -961,7 +1028,7 @@
+@@ -962,7 +1029,7 @@ static FUNC_SEND(transmit_calling_party_
  {
  	ie->data[0] = call->callerplan;
  	ie->data[1] = 0x80 | call->callerpres;
 -	if (*call->callernum) 
-+	if (strlen(call->callernum)) 
++	if (strlen(call->callernum))
  		memcpy(ie->data + 2, call->callernum, strlen(call->callernum));
  	return strlen(call->callernum) + 4;
  }
-@@ -979,11 +1046,89 @@
+@@ -980,11 +1047,89 @@ static FUNC_DUMP(dump_user_user)
  static FUNC_RECV(receive_user_user)
  {        
          call->useruserprotocoldisc = ie->data[0] & 0xff;
@@ -4242,10 +4225,10 @@
 + 	}
 +  	return 0;
 +}
-+  
++
 +static FUNC_SEND(transmit_call_identity)
 +{
-+	if (strlen(call->callid)) 
++	if (strlen(call->callid))
 +		memcpy(ie->data , call->callid, strlen(call->callid));
 +	return strlen(call->callednum) + 3;
 +}
@@ -4254,7 +4237,7 @@
 +{
 +  	return 0;
 +}
-+  
++
 +static FUNC_SEND(transmit_high_layer_compat)
 +{
 +    if (call->transcapability != PRI_TRANS_CAP_RESTRICTED_DIGITAL && call->transcapability != PRI_TRANS_CAP_DIGITAL && call->transcapability != PRI_TRANS_CAP_DIGITAL_W_TONES) {
@@ -4269,7 +4252,7 @@
 +{
 +	int x;
 +	pri_message(pri, "%c High-layer compatibilty (len=%2d) [ ", prefix, len);
-+	for (x=0;x<ie->len;x++) 
++	for (x=0;x<ie->len;x++)
 +		pri_message(pri, "0x%02X ", ie->data[x]);
 +	pri_message(pri, " ]\n");
 +}
@@ -4289,7 +4272,7 @@
 +	}
 +  	return 0;
 +}
-+  
++
 +static FUNC_SEND(transmit_low_layer_compat)
 +{
 +    if (call->llc[0] == 0) return 0;
@@ -4301,7 +4284,7 @@
 +{
 +	int x;
 +	pri_message(pri, "%c Low-layer compatibilty (len=%2d) [ ", prefix, len);
-+	for (x=0;x<ie->len;x++) 
++	for (x=0;x<ie->len;x++)
 +		pri_message(pri, "0x%02X ", ie->data[x]);
 +	pri_message(pri, " ]\n");
 +}
@@ -4309,7 +4292,7 @@
  static FUNC_SEND(transmit_user_user)
  {        
  	int datalen = strlen(call->useruserinfo);
-@@ -1065,7 +1210,7 @@
+@@ -1066,7 +1211,7 @@ static FUNC_RECV(receive_display)
  		data++;
  		len--;
  	}
@@ -4318,7 +4301,7 @@
  	return 0;
  }
  
-@@ -1129,6 +1274,111 @@
+@@ -1130,6 +1275,111 @@ static FUNC_RECV(receive_progress_indica
  	return 0;
  }
  
@@ -4391,12 +4374,12 @@
 +  	    }
 +  	    if (ie->data[13] + 14 == ie->len) {
 +   		q931_get_number(call->callername, sizeof(call->callername) - 1, ie->data + 14, ie->len - 14);
-+  	    } 
++  	    }
 +  	    call->facility = 0x0;
 +  	}
 +  	return 0;
 +   }
-+   
++
 +  static FUNC_SEND(transmit_facility_kpj)
 +  {
 +  	int i = 0;
@@ -4421,7 +4404,7 @@
 +  		    ie->data[i++] = 0x22; /* operation value AOC-D */
 +  		    break;
 +  	    }
-+  	    // ARGUMENTS!	
++  	    // ARGUMENTS!
 +  	}
 +  //	return 2 + i;
 +  }
@@ -4430,7 +4413,7 @@
  static FUNC_SEND(transmit_facility)
  {
  	struct apdu_event *tmp;
-@@ -1154,6 +1404,182 @@
+@@ -1155,6 +1405,182 @@ static FUNC_SEND(transmit_facility)
  	return i + 2;
  }
  
@@ -4613,7 +4596,7 @@
  static FUNC_RECV(receive_facility)
  {
  	int i = 0;
-@@ -1361,6 +1787,25 @@
+@@ -1362,6 +1788,25 @@ static FUNC_DUMP(dump_call_identity)
  	pri_message(pri, " ]\n");
  }
  
@@ -4639,7 +4622,7 @@
  static FUNC_DUMP(dump_time_date)
  {
  	pri_message(pri, "%c Time Date (len=%2d) [ ", prefix, len);
-@@ -1381,7 +1826,7 @@
+@@ -1382,7 +1827,7 @@ static FUNC_DUMP(dump_time_date)
  
  static FUNC_DUMP(dump_keypad_facility)
  {
@@ -4648,7 +4631,7 @@
  	
  	if (ie->len == 0 || ie->len > sizeof(tmp))
  		return;
-@@ -1991,8 +2436,8 @@
+@@ -1992,8 +2437,8 @@ static struct ie ies[] = {
  	{ 1, Q931_REDIRECTING_SUBADDR, "Redirecting Subaddress", dump_redirecting_subaddr },
  	{ 0, Q931_TRANSIT_NET_SELECT, "Transit Network Selection" },
  	{ 1, Q931_RESTART_INDICATOR, "Restart Indicator", dump_restart_indicator, receive_restart_indicator, transmit_restart_indicator },
@@ -4659,7 +4642,7 @@
  	{ 1, Q931_PACKET_SIZE, "Packet Size" },
  	{ 0, Q931_IE_FACILITY, "Facility" , dump_facility, receive_facility, transmit_facility },
  	{ 1, Q931_IE_REDIRECTION_NUMBER, "Redirection Number" },
-@@ -2001,11 +2446,11 @@
+@@ -2002,11 +2447,11 @@ static struct ie ies[] = {
  	{ 1, Q931_IE_INFO_REQUEST, "Feature Request" },
  	{ 1, Q931_IE_FEATURE_IND, "Feature Indication" },
  	{ 1, Q931_IE_SEGMENTED_MSG, "Segmented Message" },
@@ -4673,7 +4656,7 @@
  	{ 1, Q931_IE_KEYPAD_FACILITY, "Keypad Facility", dump_keypad_facility, receive_keypad_facility, transmit_keypad_facility },
  	{ 0, Q931_IE_SIGNAL, "Signal", dump_signal },
  	{ 1, Q931_IE_SWITCHHOOK, "Switch-hook" },
-@@ -2013,6 +2458,7 @@
+@@ -2014,6 +2459,7 @@ static struct ie ies[] = {
  	{ 1, Q931_IE_ESCAPE_FOR_EXT, "Escape for Extension" },
  	{ 1, Q931_IE_CALL_STATUS, "Call Status" },
  	{ 1, Q931_IE_CHANGE_STATUS, "Change Status" },
@@ -4681,16 +4664,7 @@
  	{ 1, Q931_IE_CONNECTED_ADDR, "Connected Number", dump_connected_number },
  	{ 1, Q931_IE_CONNECTED_NUM, "Connected Number", dump_connected_number },
  	{ 1, Q931_IE_ORIGINAL_CALLED_NUMBER, "Original Called Number", dump_redirecting_number, receive_redirecting_number, transmit_redirecting_number },
-@@ -2085,7 +2531,7 @@
- {
- 	if ((ie->ie & 0x80) != 0)
- 		return 1;
--	else
-+	else 
- 		return 2 + ie->len;
- }
- 
-@@ -2115,10 +2561,10 @@
+@@ -2116,10 +2562,10 @@ static inline int q931_cr(q931_h *h)
  			break;
  		case 1:
  			cr = h->crv[0];
@@ -4703,7 +4677,7 @@
  			break;
  		default:
  			pri_error(NULL, "Call Reference Length not supported: %d\n", h->crlen);
-@@ -2161,14 +2607,46 @@
+@@ -2162,14 +2608,46 @@ static inline void q931_dumpie(struct pr
  	pri_error(pri, "!! %c Unknown IE %d (cs%d, len = %d)\n", prefix, Q931_IE_IE(base_ie), Q931_IE_CODESET(base_ie), ielen(ie));
  }
  
@@ -4715,7 +4689,7 @@
 +	while(cur) {
 +	    if (cur->tei == tei) {
 +		    return cur;
-+	    } 
++	    }
 +	    cur = cur->next;
 +	}
 +	/* No call exists, make a new one */
@@ -4753,7 +4727,7 @@
  		prev = cur;
  		cur = cur->next;
  	}
-@@ -2181,6 +2659,7 @@
+@@ -2182,6 +2660,7 @@ static q931_call *q931_getcall(struct pr
  		/* Call reference */
  		cur->cr = cr;
  		cur->pri = pri;
@@ -4761,7 +4735,7 @@
  		/* Append to end of list */
  		if (prev)
  			prev->next = cur;
-@@ -2196,24 +2675,42 @@
+@@ -2197,24 +2676,42 @@ q931_call *q931_new_call(struct pri *pri
  	do {
  		cur = *pri->callpool;
  		pri->cref++;
@@ -4772,7 +4746,7 @@
 +			    pri->cref = 1;
 +		} else {
 +		    // BRI
-+		    if (pri->cref > 255)
++		    if (pri->cref > 127)
 +			    pri->cref = 1;
 + 		}
  		while(cur) {
@@ -4811,7 +4785,7 @@
  			if (prev)
  				prev->next = cur->next;
  			else
-@@ -2222,6 +2719,8 @@
+@@ -2223,6 +2720,8 @@ static void q931_destroy(struct pri *pri
  				pri_message(pri, "NEW_HANGUP DEBUG: Destroying the call, ourstate %s, peerstate %s\n",callstate2str(cur->ourcallstate),callstate2str(cur->peercallstate));
  			if (cur->retranstimer)
  				pri_schedule_del(pri, cur->retranstimer);
@@ -4820,7 +4794,7 @@
  			pri_call_apdu_queue_cleanup(cur);
  			free(cur);
  			return;
-@@ -2232,16 +2731,16 @@
+@@ -2233,16 +2732,16 @@ static void q931_destroy(struct pri *pri
  	pri_error(pri, "Can't destroy call %d!\n", cr);
  }
  
@@ -4840,7 +4814,7 @@
  	return;
  }
  
-@@ -2353,6 +2852,10 @@
+@@ -2354,6 +2853,10 @@ static int q931_handle_ie(int codeset, s
  {
  	unsigned int x;
  	int full_ie = Q931_FULL_IE(codeset, ie->ie);
@@ -4851,7 +4825,7 @@
  	if (pri->debug & PRI_DEBUG_Q931_STATE)
  		pri_message(pri, "-- Processing IE %d (cs%d, %s)\n", ie->ie, codeset, ie2str(full_ie));
  	for (x=0;x<sizeof(ies) / sizeof(ies[0]);x++) {
-@@ -2370,21 +2873,36 @@
+@@ -2371,21 +2874,36 @@ static int q931_handle_ie(int codeset, s
  	return -1;
  }
  
@@ -4893,7 +4867,7 @@
  	}
  	if (pri->subchannel) {
  		/* On GR-303, top bit is always 0 */
-@@ -2393,13 +2911,23 @@
+@@ -2394,13 +2912,23 @@ static void init_header(struct pri *pri,
  	mh->f = 0;
  	*hb = h;
  	*mhb = mh;
@@ -4921,7 +4895,7 @@
  	/* The transmit operation might dump the q921 header, so logging the q931
  	   message body after the transmit puts the sections of the message in the
  	   right order in the log */
-@@ -2424,7 +2952,11 @@
+@@ -2425,7 +2953,11 @@ static int send_message(struct pri *pri,
  	
  	memset(buf, 0, sizeof(buf));
  	len = sizeof(buf);
@@ -4934,7 +4908,7 @@
  	mh->msg = msgtype;
  	x=0;
  	codeset = 0;
-@@ -2442,7 +2974,11 @@
+@@ -2443,7 +2975,11 @@ static int send_message(struct pri *pri,
  	}
  	/* Invert the logic */
  	len = sizeof(buf) - len;
@@ -4947,7 +4921,7 @@
  	c->acked = 1;
  	return 0;
  }
-@@ -2492,12 +3028,34 @@
+@@ -2493,12 +3029,34 @@ int q931_keypad_facility(struct pri *pri
  	return send_message(pri, call, Q931_INFORMATION, keypad_facility_ies);
  }
  
@@ -4982,7 +4956,7 @@
  	return send_message(pri, c, Q931_RESTART_ACKNOWLEDGE, restart_ack_ies);
  }
  
-@@ -2516,7 +3074,6 @@
+@@ -2517,7 +3075,6 @@ int q931_notify(struct pri *pri, q931_ca
  		if ((info > 0x2) || (info < 0x00))
  			return 0;
  	}
@@ -4990,16 +4964,16 @@
  	if (info >= 0)
  		c->notify = info & 0x7F;
  	else
-@@ -2559,6 +3116,8 @@
+@@ -2560,6 +3117,8 @@ static int call_proceeding_ies[] = { Q93
  
  int q931_call_proceeding(struct pri *pri, q931_call *c, int channel, int info)
  {
 +	// never send two PROCEEDINGs!
-+	if (c->proc > 0) return 0;		
++	if (c->proc > 0) return 0;
  	if (channel) { 
  		c->ds1no = (channel & 0xff00) >> 8;
  		c->ds1explicit = (channel & 0x10000) >> 16;
-@@ -2585,8 +3144,12 @@
+@@ -2586,8 +3145,12 @@ static int alerting_ies[] = { Q931_PROGR
  static int alerting_ies[] = { -1 };
  #endif
  
@@ -5008,11 +4982,11 @@
  int q931_alerting(struct pri *pri, q931_call *c, int channel, int info)
  {
 +	// never send two ALERTINGs!
-+	if (c->alert > 0) return 0;		
++	if (c->alert > 0) return 0;
  	if (!c->proc) 
  		q931_call_proceeding(pri, c, channel, 0);
  	if (info) {
-@@ -2597,14 +3160,130 @@
+@@ -2598,14 +3161,130 @@ int q931_alerting(struct pri *pri, q931_
  		c->progressmask = 0;
  	UPDATE_OURCALLSTATE(pri, c, Q931_CALL_STATE_CALL_RECEIVED);
  	c->peercallstate = Q931_CALL_STATE_CALL_DELIVERED;
@@ -5029,9 +5003,8 @@
 +		return send_message(pri, c, Q931_ALERTING, alerting_BRI_ies);
 +	    }
 +	}
- }
- 
--static int connect_ies[] = {  Q931_CHANNEL_IDENT, Q931_PROGRESS_INDICATOR, -1 };
++}
++
 +static int hold_acknowledge_ies[] = { -1 };
 +
 +int q931_hold_acknowledge(struct pri *pri, q931_call *c)
@@ -5065,8 +5038,9 @@
 +int q931_retrieve_reject(struct pri *pri, q931_call *c)
 +{
 +	return send_message(pri, c, Q931_RETRIEVE_REJECT, retrieve_reject_ies);
-+}
-+
+ }
+ 
+-static int connect_ies[] = {  Q931_CHANNEL_IDENT, Q931_PROGRESS_INDICATOR, -1 };
 +static int suspend_acknowledge_ies[] = { Q931_DISPLAY, -1 };
 +
 +int q931_suspend_acknowledge(struct pri *pri, q931_call *c, char *display)
@@ -5145,7 +5119,7 @@
  	if (channel) { 
  		c->ds1no = (channel & 0xff00) >> 8;
  		c->ds1explicit = (channel & 0x10000) >> 16;
-@@ -2622,9 +3301,39 @@
+@@ -2623,9 +3302,39 @@ int q931_setup_ack(struct pri *pri, q931
  	UPDATE_OURCALLSTATE(pri, c, Q931_CALL_STATE_OVERLAP_RECEIVING);
  	c->peercallstate = Q931_CALL_STATE_OVERLAP_SENDING;
  	c->alive = 1;
@@ -5185,7 +5159,7 @@
  static void pri_connect_timeout(void *data)
  {
  	struct q931_call *c = data;
-@@ -2679,6 +3388,7 @@
+@@ -2680,6 +3389,7 @@ static void pri_disconnect_timeout(void 
  
  int q931_connect(struct pri *pri, q931_call *c, int channel, int nonisdn)
  {
@@ -5193,7 +5167,7 @@
  	if (channel) { 
  		c->ds1no = (channel & 0xff00) >> 8;
  		c->ds1explicit = (channel & 0x10000) >> 16;
-@@ -2693,25 +3403,34 @@
+@@ -2694,25 +3404,34 @@ int q931_connect(struct pri *pri, q931_c
  		c->progressmask = PRI_PROG_CALLED_NOT_ISDN;
  	} else
  		c->progressmask = 0;
@@ -5231,7 +5205,7 @@
  	UPDATE_OURCALLSTATE(pri, c, Q931_CALL_STATE_RELEASE_REQUEST);
  	/* c->peercallstate stays the same */
  	if (c->alive) {
-@@ -2727,7 +3446,14 @@
+@@ -2728,7 +3447,14 @@ int q931_release(struct pri *pri, q931_c
  			} else {
  				c->retranstimer = pri_schedule_event(pri, pri->timers[PRI_TIMER_T308], pri_release_finaltimeout, c);
  			}
@@ -5247,7 +5221,7 @@
  		} else
  			return send_message(pri, c, Q931_RELEASE_COMPLETE, release_ies); /* Yes, release_ies, not release_complete_ies */
  	} else
-@@ -2739,7 +3465,7 @@
+@@ -2740,7 +3466,7 @@ static int restart_ies[] = { Q931_CHANNE
  int q931_restart(struct pri *pri, int channel)
  {
  	struct q931_call *c;
@@ -5256,7 +5230,7 @@
  	if (!c)
  		return -1;
  	if (!channel)
-@@ -2756,10 +3482,12 @@
+@@ -2757,10 +3483,12 @@ int q931_restart(struct pri *pri, int ch
  	return send_message(pri, c, Q931_RESTART, restart_ies);
  }
  
@@ -5269,7 +5243,7 @@
  	UPDATE_OURCALLSTATE(pri, c, Q931_CALL_STATE_DISCONNECT_REQUEST);
  	c->peercallstate = Q931_CALL_STATE_DISCONNECT_INDICATION;
  	if (c->alive) {
-@@ -2771,15 +3499,31 @@
+@@ -2772,15 +3500,31 @@ int q931_disconnect(struct pri *pri, q93
  		if (c->retranstimer)
  			pri_schedule_del(pri, c->retranstimer);
  		c->retranstimer = pri_schedule_event(pri, pri->timers[PRI_TIMER_T305], pri_disconnect_timeout, c);
@@ -5302,7 +5276,7 @@
  static int gr303_setup_ies[] =  { Q931_BEARER_CAPABILITY, Q931_CHANNEL_IDENT, -1 };
  
  static int cis_setup_ies[] = { Q931_BEARER_CAPABILITY, Q931_CHANNEL_IDENT, Q931_IE_FACILITY, Q931_CALLED_PARTY_NUMBER, -1 };
-@@ -2786,7 +3530,13 @@
+@@ -2788,7 +3532,13 @@ static int cis_setup_ies[] = { Q931_BEAR
  int q931_setup(struct pri *pri, q931_call *c, struct pri_sr *req)
  {
  	int res;
@@ -5317,7 +5291,7 @@
  	
  	c->transcapability = req->transmode;
  	c->transmoderate = TRANS_MODE_64_CIRCUIT;
-@@ -2811,6 +3561,7 @@
+@@ -2813,6 +3563,7 @@ int q931_setup(struct pri *pri, q931_cal
  		c->chanflags = FLAG_EXCLUSIVE;
  	else if (c->channelno)
  		c->chanflags = FLAG_PREFERRED;
@@ -5325,7 +5299,7 @@
  	if (req->caller) {
  		libpri_copy_string(c->callernum, req->caller, sizeof(c->callernum));
  		c->callerplan = req->callerplan;
-@@ -2866,18 +3617,25 @@
+@@ -2868,18 +3619,25 @@ int q931_setup(struct pri *pri, q931_cal
  
  	pri_call_add_standard_apdus(pri, c);
  
@@ -5342,7 +5316,7 @@
  		res = send_message(pri, c, Q931_SETUP, setup_ies);
 +	} else {
 +		res = send_message(pri, c, Q931_SETUP, setup_cpe_ies);
-+	}	
++	}
  	if (!res) {
  		c->alive = 1;
  		/* make sure we call PRI_EVENT_HANGUP_ACK once we send/receive RELEASE_COMPLETE */
@@ -5354,7 +5328,7 @@
  	}
  	return res;
  	
-@@ -2893,7 +3651,11 @@
+@@ -2895,7 +3653,11 @@ static int q931_release_complete(struct 
  	if (cause > -1) {
  		c->cause = cause;
  		c->causecode = CODE_CCITT;
@@ -5367,7 +5341,7 @@
  		/* release_ies has CAUSE in it */
  		res = send_message(pri, c, Q931_RELEASE_COMPLETE, release_ies);
  	} else
-@@ -2918,6 +3680,125 @@
+@@ -2920,6 +3682,125 @@ static int q931_connect_acknowledge(stru
  	return 0;
  }
  
@@ -5381,7 +5355,7 @@
 +
 + if (!pri || !c)
 +    return -1;
-+ 
++
 + if (pri->localtype != BRI_NETWORK_PTMP){
 +	return 0;
 + }
@@ -5393,7 +5367,7 @@
 +//	pri_error(pri, "tei %d\n", tei);
 +
 + cur = c->phones;
-+ 
++
 + tc = c->cause;
 + ttei = c->tei;
 + while (cur) {
@@ -5422,11 +5396,11 @@
 +	res = Q931_RES_HAVEEVENT;
 +	pri->ev.hangup.channel = c->channelno;
 +	pri->ev.e = PRI_EVENT_HANGUP_ACK;   */
-+ } 
-+ return res; 
++ }
++ return res;
 +}
 +
-+/* here we handle release_completes from the phones 
++/* here we handle release_completes from the phones
 +    because some (elmeg) phones do not send a disconnect
 +    message when the phone is busy */
 +int q921_handle_hangup(struct pri *pri, q931_call *c, int tei)
@@ -5434,16 +5408,16 @@
 +     q921_call *cur,*match,*prev=NULL;
 +     int left=0;
 +     int res=0;
-+     
++
 +     if (!pri || !c)
 + 	return -1;
-+ 
++
 +     if (pri->localtype != BRI_NETWORK_PTMP){
 + 	return 0;
 +     }
-+ 
++
 +     cur = c->phones;
-+     
++
 +     while (cur) {
 + 	if (cur->tei == tei) {
 + 	    match = cur;
@@ -5458,14 +5432,14 @@
 + 	prev = cur;
 + 	if (cur) cur = cur->next;
 +     }
-+ 
++
 +     cur = c->phones;
-+     
++
 +     while (cur) {
 + 	left++;
 + 	cur = cur->next;
 +     }
-+     
++
 +     // if all phones have signalled busy AND the timer is not running anymore!
 +#ifdef FASTBUSYONBUSY
 +    if ((c->cause == PRI_CAUSE_USER_BUSY) && (c->t303timer)) {
@@ -5480,20 +5454,20 @@
 + 	res = Q931_RES_HAVEEVENT;
 + 	pri->ev.hangup.cause = PRI_CAUSE_USER_BUSY;
 + 	pri->ev.hangup.channel = c->channelno | (c->ds1no << 8);
-+ 	pri->ev.hangup.cref = c->cr;          		
++ 	pri->ev.hangup.cref = c->cr;
 + 	pri->ev.hangup.call = c;
 +	pri->ev.hangup.aoc_units = 0;
-+ 	pri->ev.e = PRI_EVENT_HANGUP; 
-+     } 
-+     return res; 
++ 	pri->ev.e = PRI_EVENT_HANGUP;
++     }
++     return res;
 + }
 +
-+ 
++
 +
  int q931_hangup(struct pri *pri, q931_call *c, int cause)
  {
  	int disconnect = 1;
-@@ -2929,7 +3810,7 @@
+@@ -2931,7 +3812,7 @@ int q931_hangup(struct pri *pri, q931_ca
  	/* If mandatory IE was missing, insist upon that cause code */
  	if (c->cause == PRI_CAUSE_MANDATORY_IE_MISSING)
  		cause = c->cause;
@@ -5502,7 +5476,7 @@
  		/* We'll send RELEASE_COMPLETE with these causes */
  		disconnect = 0;
  		release_compl = 1;
-@@ -2943,7 +3824,7 @@
+@@ -2945,7 +3826,7 @@ int q931_hangup(struct pri *pri, q931_ca
  	case Q931_CALL_STATE_NULL:
  		if (c->peercallstate == Q931_CALL_STATE_NULL)
  			/* free the resources if we receive or send REL_COMPL */
@@ -5511,7 +5485,7 @@
  		else if (c->peercallstate == Q931_CALL_STATE_RELEASE_REQUEST)
  			q931_release_complete(pri,c,cause);
  		break;
-@@ -2967,6 +3848,11 @@
+@@ -2969,6 +3850,11 @@ int q931_hangup(struct pri *pri, q931_ca
  		/* received SETUP_ACKNOWLEDGE */
  		/* send DISCONNECT in general */
  		if (c->peercallstate != Q931_CALL_STATE_NULL && c->peercallstate != Q931_CALL_STATE_DISCONNECT_REQUEST && c->peercallstate != Q931_CALL_STATE_DISCONNECT_INDICATION && c->peercallstate != Q931_CALL_STATE_RELEASE_REQUEST && c->peercallstate != Q931_CALL_STATE_RESTART_REQUEST && c->peercallstate != Q931_CALL_STATE_RESTART) {
@@ -5519,11 +5493,11 @@
 +			    if (c->tei == 127) {
 +			        break;
 +			    }
-+			} 
++			}
  			if (disconnect)
  				q931_disconnect(pri,c,cause);
  			else if (release_compl)
-@@ -2986,8 +3872,14 @@
+@@ -2988,8 +3874,14 @@ int q931_hangup(struct pri *pri, q931_ca
  		break;
  	case Q931_CALL_STATE_DISCONNECT_INDICATION:
  		/* received DISCONNECT */
@@ -5531,14 +5505,14 @@
 +		    if (c->tei == 127) {
 +			break;
 +		    }
-+		} 
++		}
  		if (c->peercallstate == Q931_CALL_STATE_DISCONNECT_REQUEST) {
  			c->alive = 1;
 +//		    pri_error(pri, "sending release to %d\n", c->tei);
  			q931_release(pri,c,cause);
  		}
  		break;
-@@ -3001,19 +3893,17 @@
+@@ -3003,19 +3895,17 @@ int q931_hangup(struct pri *pri, q931_ca
  		pri_error(pri, "q931_hangup shouldn't be called in this state, ourstate %s, peerstate %s\n",callstate2str(c->ourcallstate),callstate2str(c->peercallstate));
  		break;
  	default:
@@ -5561,7 +5535,7 @@
  	q931_call *c;
  	q931_ie *ie;
  	unsigned int x;
-@@ -3025,6 +3915,7 @@
+@@ -3027,6 +3917,7 @@ int q931_receive(struct pri *pri, q931_h
  	int codeset, cur_codeset;
  	int last_ie[8];
  	struct apdu_event *cur = NULL;
@@ -5569,7 +5543,7 @@
  
  	memset(last_ie, 0, sizeof(last_ie));
  	if (pri->debug & PRI_DEBUG_Q931_DUMP)
-@@ -3038,13 +3929,13 @@
+@@ -3040,13 +3931,13 @@ int q931_receive(struct pri *pri, q931_h
  		   KLUDGE this by changing byte 4 from a 0xf (SERVICE) 
  		   to a 0x7 (SERVICE ACKNOWLEDGE) */
  		h->raw[h->crlen + 2] -= 0x8;
@@ -5585,7 +5559,7 @@
  	if (!c) {
  		pri_error(pri, "Unable to locate call %d\n", q931_cr(h));
  		return -1;
-@@ -3067,6 +3958,7 @@
+@@ -3069,6 +3960,7 @@ int q931_receive(struct pri *pri, q931_h
  	case Q931_SETUP:
  		if (pri->debug & PRI_DEBUG_Q931_STATE)
  			pri_message(pri, "-- Processing Q.931 Call Setup\n");
@@ -5593,7 +5567,7 @@
  		c->channelno = -1;
  		c->slotmap = -1;
  		c->chanflags = 0;
-@@ -3102,17 +3994,27 @@
+@@ -3104,17 +3996,34 @@ int q931_receive(struct pri *pri, q931_h
  		c->complete = 0;
  		c->nonisdn = 0;
  		c->aoc_units = -1;
@@ -5605,13 +5579,18 @@
 -	case Q931_CONNECT:
  	case Q931_ALERTING:
  	case Q931_PROGRESS:
--		c->useruserinfo[0] = '\0';
++ 		if (c->t303timer) {
++ 		    c->t303running = 0;
++ 		    pri_schedule_del(pri, c->t303timer);
++  		}
+ 		c->useruserinfo[0] = '\0';
  		c->cause = -1;
- 		/* Fall through */
- 	case Q931_CALL_PROCEEDING:
--		c->progress = -1;
--		c->progressmask = 0;
--		break;
+-		/* Fall through */
+-	case Q931_CALL_PROCEEDING:
+ 		c->progress = -1;
+ 		c->progressmask = 0;
+ 		break;
++	case Q931_CALL_PROCEEDING:
 +		/* Fall through */
 +	case Q931_CONNECT:
 + 		if (c->t303timer) {
@@ -5626,7 +5605,7 @@
  	case Q931_CONNECT_ACKNOWLEDGE:
  		if (c->retranstimer)
  			pri_schedule_del(pri, c->retranstimer);
-@@ -3128,6 +4033,11 @@
+@@ -3130,11 +4039,20 @@ int q931_receive(struct pri *pri, q931_h
  			pri_schedule_del(pri, c->retranstimer);
  		c->retranstimer = 0;
  		c->useruserinfo[0] = '\0';
@@ -5638,7 +5617,16 @@
  		break;
  	case Q931_RELEASE_COMPLETE:
  		if (c->retranstimer)
-@@ -3151,22 +4061,32 @@
+ 			pri_schedule_del(pri, c->retranstimer);
+ 		c->retranstimer = 0;
++ 		if (c->t303timer) {
++ 		    c->t303running = 0;
++ 		    pri_schedule_del(pri, c->t303timer);
++  		}
+ 		c->useruserinfo[0] = '\0';
+ 		/* Fall through */
+ 	case Q931_STATUS:
+@@ -3153,22 +4071,32 @@ int q931_receive(struct pri *pri, q931_h
  	case Q931_STATUS_ENQUIRY:
  		break;
  	case Q931_SETUP_ACKNOWLEDGE:
@@ -5675,7 +5663,7 @@
  	case Q931_SUSPEND_ACKNOWLEDGE:
  	case Q931_SUSPEND_REJECT:
  		pri_error(pri, "!! Not yet handling pre-handle message type %s (%d)\n", msg2str(mh->msg), mh->msg);
-@@ -3175,7 +4095,7 @@
+@@ -3177,7 +4105,7 @@ int q931_receive(struct pri *pri, q931_h
  		pri_error(pri, "!! Don't know how to pre-handle message type %s (%d)\n", msg2str(mh->msg), mh->msg);
  		q931_status(pri,c, PRI_CAUSE_MESSAGE_TYPE_NONEXIST);
  		if (c->newcall) 
@@ -5684,7 +5672,7 @@
  		return -1;
  	}
  	/* Handle IEs */
-@@ -3256,12 +4176,19 @@
+@@ -3258,12 +4186,19 @@ int q931_receive(struct pri *pri, q931_h
  	missingmand = 0;
  	for (x=0;x<MAX_MAND_IES;x++) {
  		if (mandies[x]) {
@@ -5709,7 +5697,7 @@
  		}
  	}
  	
-@@ -3270,7 +4197,7 @@
+@@ -3272,7 +4207,7 @@ int q931_receive(struct pri *pri, q931_h
  	case Q931_RESTART:
  		if (missingmand) {
  			q931_status(pri, c, PRI_CAUSE_MANDATORY_IE_MISSING);
@@ -5718,7 +5706,7 @@
  			break;
  		}
  		UPDATE_OURCALLSTATE(pri, c, Q931_CALL_STATE_RESTART);
-@@ -3288,6 +4215,7 @@
+@@ -3290,6 +4225,7 @@ int q931_receive(struct pri *pri, q931_h
  		}
  		/* Must be new call */
  		if (!c->newcall) {
@@ -5726,7 +5714,7 @@
  			break;
  		}
  		if (c->progressmask & PRI_PROG_CALLER_NOT_ISDN)
-@@ -3305,16 +4233,20 @@
+@@ -3307,16 +4243,20 @@ int q931_receive(struct pri *pri, q931_h
  		pri->ev.ring.channel = c->channelno | (c->ds1no << 8) | (c->ds1explicit << 16);
  		pri->ev.ring.callingpres = c->callerpres;
  		pri->ev.ring.callingplan = c->callerplan;
@@ -5749,7 +5737,7 @@
  		libpri_copy_string(pri->ev.ring.origcalledname, c->origcalledname, sizeof(pri->ev.ring.origcalledname));
  		libpri_copy_string(pri->ev.ring.origcallednum, c->origcallednum, sizeof(pri->ev.ring.origcallednum));
  		libpri_copy_string(pri->ev.ring.redirectingnum, c->redirectingnum, sizeof(pri->ev.ring.redirectingnum));
-@@ -3324,11 +4256,13 @@
+@@ -3326,11 +4266,13 @@ int q931_receive(struct pri *pri, q931_h
  		pri->ev.ring.redirectingreason = c->redirectingreason;
  		pri->ev.ring.origredirectingreason = c->origredirectingreason;
  		pri->ev.ring.flexible = ! (c->chanflags & FLAG_EXCLUSIVE);
@@ -5764,7 +5752,7 @@
  		pri->ev.ring.redirectingreason = c->redirectingreason;
  		pri->ev.ring.progress = c->progress;
  		pri->ev.ring.progressmask = c->progressmask;
-@@ -3340,6 +4274,9 @@
+@@ -3342,6 +4284,9 @@ int q931_receive(struct pri *pri, q931_h
  		}
  		UPDATE_OURCALLSTATE(pri, c, Q931_CALL_STATE_CALL_DELIVERED);
  		c->peercallstate = Q931_CALL_STATE_CALL_RECEIVED;
@@ -5774,7 +5762,7 @@
  		pri->ev.e = PRI_EVENT_RINGING;
  		pri->ev.ringing.channel = c->channelno | (c->ds1no << 8) | (c->ds1explicit << 16);
  		pri->ev.ringing.cref = c->cr;
-@@ -3368,17 +4305,24 @@
+@@ -3370,17 +4315,24 @@ int q931_receive(struct pri *pri, q931_h
  			q931_status(pri, c, PRI_CAUSE_WRONG_MESSAGE);
  			break;
  		}
@@ -5799,7 +5787,7 @@
  		if (c->justsignalling) {  /* Make sure WE release when we initiatie a signalling only connection */
  			q931_release(pri, c, PRI_CAUSE_NORMAL_CLEARING);
  			break;
-@@ -3386,23 +4330,43 @@
+@@ -3388,23 +4340,43 @@ int q931_receive(struct pri *pri, q931_h
  			return Q931_RES_HAVEEVENT;
  	case Q931_FACILITY:
  		if (c->newcall) {
@@ -5827,17 +5815,17 @@
 +  		    pri->ev.facility.channel = c->channelno | (c->ds1no << 8);
 +  		    pri->ev.facility.cref = c->cr;
 +  		    pri->ev.facility.tei = c->tei;
-+  		    pri->ev.facility.call = c; 
++  		    pri->ev.facility.call = c;
 +  		    switch (c->facility) {
 +  			case 0x06: /* ECT execute */
-+  				pri->ev.facility.operation = 0x06; 
++  				pri->ev.facility.operation = 0x06;
 +  			    break;
 +  			case 0x0D: /* CD */
-+  				pri->ev.facility.operation = 0x0D; 
++  				pri->ev.facility.operation = 0x0D;
 +  				libpri_copy_string(pri->ev.facility.forwardnum, c->redirectingnum,  sizeof(pri->ev.facility.forwardnum));
 +  			    break;
 +  			default:
-+  				pri->ev.facility.operation = c->facility; 
++  				pri->ev.facility.operation = c->facility;
 +  		    }
 +  		} else {
 +  		    pri->ev.e = PRI_EVENT_FACNAME;
@@ -5845,7 +5833,7 @@
 +  		    libpri_copy_string(pri->ev.facname.callingnum, c->callernum, sizeof(pri->ev.facname.callingname));
 +  		    pri->ev.facname.channel = c->channelno | (c->ds1no << 8);
 +  		    pri->ev.facname.cref = c->cr;
-+  		    pri->ev.facname.call = c; 
++  		    pri->ev.facname.call = c;
 +   		}
  		return Q931_RES_HAVEEVENT;
  	case Q931_PROGRESS:
@@ -5856,7 +5844,7 @@
  			break;
  		}
  		pri->ev.e = PRI_EVENT_PROGRESS;
-@@ -3420,6 +4384,11 @@
+@@ -3422,6 +4394,11 @@ int q931_receive(struct pri *pri, q931_h
  			q931_status(pri,c,PRI_CAUSE_WRONG_MESSAGE);
  			break;
  		}
@@ -5868,7 +5856,7 @@
  		pri->ev.proceeding.channel = c->channelno | (c->ds1no << 8) | (c->ds1explicit << 16);
  		if (mh->msg == Q931_CALL_PROCEEDING) {
  			pri->ev.e = PRI_EVENT_PROCEEDING;
-@@ -3447,17 +4416,18 @@
+@@ -3449,17 +4426,18 @@ int q931_receive(struct pri *pri, q931_h
  		}
  		if (!(c->ourcallstate == Q931_CALL_STATE_CONNECT_REQUEST) &&
  		    !(c->ourcallstate == Q931_CALL_STATE_ACTIVE &&
@@ -5889,7 +5877,7 @@
  			break;
  		}
  		if (c->newcall) {
-@@ -3498,30 +4468,46 @@
+@@ -3500,30 +4478,46 @@ int q931_receive(struct pri *pri, q931_h
  		}
  		break;
  	case Q931_RELEASE_COMPLETE:
@@ -5952,7 +5940,7 @@
  		break;
  	case Q931_RELEASE:
  		if (missingmand) {
-@@ -3536,11 +4522,12 @@
+@@ -3538,11 +4532,12 @@ int q931_receive(struct pri *pri, q931_h
  		UPDATE_OURCALLSTATE(pri, c, Q931_CALL_STATE_NULL);
  		pri->ev.e = PRI_EVENT_HANGUP;
  		pri->ev.hangup.channel = c->channelno | (c->ds1no << 8) | (c->ds1explicit << 16);
@@ -5967,7 +5955,7 @@
  		c->useruserinfo[0] = '\0';
  		/* Don't send release complete if they send us release 
  		   while we sent it, assume a NULL state */
-@@ -3564,12 +4551,17 @@
+@@ -3566,12 +4561,17 @@ int q931_receive(struct pri *pri, q931_h
  		/* Return such an event */
  		pri->ev.e = PRI_EVENT_HANGUP_REQ;
  		pri->ev.hangup.channel = c->channelno | (c->ds1no << 8) | (c->ds1explicit << 16);
@@ -5988,7 +5976,7 @@
  		if (c->alive)
  			return Q931_RES_HAVEEVENT;
  		else
-@@ -3622,7 +4614,6 @@
+@@ -3624,7 +4624,6 @@ int q931_receive(struct pri *pri, q931_h
  		pri->ev.e = PRI_EVENT_SETUP_ACK;
  		pri->ev.setup_ack.channel = c->channelno | (c->ds1no << 8) | (c->ds1explicit << 16);
  		pri->ev.setup_ack.call = c;
@@ -5996,7 +5984,7 @@
  		cur = c->apdus;
  		while (cur) {
  			if (!cur->sent && cur->message == Q931_FACILITY) {
-@@ -3638,19 +4629,53 @@
+@@ -3640,19 +4639,53 @@ int q931_receive(struct pri *pri, q931_h
  		pri->ev.notify.channel = c->channelno;
  		pri->ev.notify.info = c->notify;
  		return Q931_RES_HAVEEVENT;
@@ -6054,7 +6042,7 @@
  	case Q931_SUSPEND_ACKNOWLEDGE:
  	case Q931_SUSPEND_REJECT:
  		pri_error(pri, "!! Not yet handling post-handle message type %s (%d)\n", msg2str(mh->msg), mh->msg);
-@@ -3660,7 +4685,7 @@
+@@ -3662,7 +4695,7 @@ int q931_receive(struct pri *pri, q931_h
  		pri_error(pri, "!! Don't know how to post-handle message type %s (%d)\n", msg2str(mh->msg), mh->msg);
  		q931_status(pri,c, PRI_CAUSE_MESSAGE_TYPE_NONEXIST);
  		if (c->newcall) 
@@ -6063,21 +6051,21 @@
  		return -1;
  	}
  	return 0;
-diff -urN libpri-1.4.1.orig/README libpri-1.4.1/README
---- libpri-1.4.1.orig/README	2006-02-15 19:01:03.000000000 +0100
-+++ libpri-1.4.1/README	2007-07-11 14:25:15.000000000 +0200
+Index: libpri-1.4.3/README
+===================================================================
+--- libpri-1.4.3.orig/README
++++ libpri-1.4.3/README
 @@ -1,6 +1,7 @@
 -libpri: An implementation of Primary Rate ISDN
--
++libpri: An implementation of Primate Rate ISDN (and BRI ISDN)
+ 
 -Written by Mark Spencer <markster at digium.com>
-+libpri: An implementation of Primate Rate ISDN (and BRI ISDN)
-+ 
 +Written by Mark Spencer <markster at linux-support.net>
 +Modified for BRI support by Klaus-Peter Junghanns <kpj at junghanns.net>
  
  What is libpri?
  ===============
-@@ -9,6 +10,7 @@
+@@ -9,6 +10,7 @@ libpri is a C implementation of the Prim
  based on the Bellcore specification SR-NWT-002343 for National ISDN.  As of
  May 12, 2001, it has been tested work with NI-2, Nortel DMS-100, and 
  Lucent 5E Custom protocols on switches from Nortel and Lucent.
@@ -6085,7 +6073,7 @@
  
  What is the license for libpri?
  ===============================
-@@ -22,9 +24,8 @@
+@@ -22,9 +24,8 @@ within the GPL) is licensed either under
  or the GPL of libpri.
  
  If you wish to use libpri in an application for which the GPL is not 




More information about the Pkg-voip-commits mailing list