[Pkg-voip-commits] r1086 - libpri/trunk/debian/patches

Tzafrir Cohen tzafrir-guest at costa.debian.org
Thu Dec 22 18:31:59 UTC 2005


Author: tzafrir-guest
Date: 2005-12-22 18:31:58 +0000 (Thu, 22 Dec 2005)
New Revision: 1086

Modified:
   libpri/trunk/debian/patches/bristuff.dpatch
Log:
bristuff 0.3.0-PRE1d


Modified: libpri/trunk/debian/patches/bristuff.dpatch
===================================================================
--- libpri/trunk/debian/patches/bristuff.dpatch	2005-12-22 18:30:56 UTC (rev 1085)
+++ libpri/trunk/debian/patches/bristuff.dpatch	2005-12-22 18:31:58 UTC (rev 1086)
@@ -2,12 +2,62 @@
 ## bristuff.dpatch by Tzafrir Cohen <tzafrir.cohen at xorcom.com>
 ##
 ## All lines beginning with `## DP:' are a description of the patch.
-## DP: The libpri part of bristuff, version 0.3.0-PRE-1
+## DP: The libpri part of bristuff, version 0.3.0-PRE-1d
 
 @DPATCH@
-diff -urNad libpri-1.2.0-release/libpri.h /tmp/dpep.aQ7o1G/libpri-1.2.0-release/libpri.h
---- libpri-1.2.0-release/libpri.h	2005-10-21 23:21:22.000000000 +0200
-+++ /tmp/dpep.aQ7o1G/libpri-1.2.0-release/libpri.h	2005-11-23 04:05:24.939538825 +0200
+diff -urN libpri-1.2.1.orig/README libpri-1.2.1/README
+--- libpri-1.2.1.orig/README	2005-11-29 19:39:18.000000000 +0100
++++ libpri-1.2.1/README	2005-06-13 09:02:39.000000000 +0200
+@@ -1,6 +1,7 @@
+-libpri: An implementation of Primate Rate 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 @@
+ 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.
++The BRI and euroISDN modifications are based on ETS 300 102-1.
+ 
+ What is the license for libpri?
+ ===============================
+@@ -22,9 +24,8 @@
+ or the GPL of libpri.
+ 
+ If you wish to use libpri in an application for which the GPL is not 
+-appropriate (e.g. a proprietary embedded system), licenses for libpri 
+-under more flexible terms can be readily obtained through Digium, Inc. 
+-at reasonable cost.
++appropriate (e.g. a proprietary embedded system), then you have to use
++a non-standard compliant version without BRI support.
+ 
+ 
+ How do I report bugs or contribute?
+diff -urN libpri-1.2.1.orig/TODO libpri-1.2.1/TODO
+--- libpri-1.2.1.orig/TODO	2005-11-29 19:39:18.000000000 +0100
++++ libpri-1.2.1/TODO	2005-12-21 14:24:02.000000000 +0100
+@@ -2,9 +2,7 @@
+ -- D-Channel Backup
+ -- Test against 4e
+ 
+-Q.921:
+--- Support unnumbered information frames
+-
+ Q.931:
+--- Locking Shift IE
+--- Implement the 11 missing Q.931 timers
++-- Locking Shift IE (you did that already, didnt you??)
++-- Implement the 10 missing Q.931 timers
++-- more facilities
+diff -urN libpri-1.2.1.orig/libpri.h libpri-1.2.1/libpri.h
+--- libpri-1.2.1.orig/libpri.h	2005-11-29 19:39:18.000000000 +0100
++++ libpri-1.2.1/libpri.h	2005-11-20 15:18:11.000000000 +0100
 @@ -26,8 +26,12 @@
  #define _LIBPRI_H
  
@@ -71,7 +121,7 @@
  } pri_event_answer;
  
  typedef struct pri_event_facname {
-@@ -302,10 +315,12 @@
+@@ -302,26 +315,29 @@
  	int e;
  	int channel;				/* Channel requested */
  	int callingpres;			/* Presentation of Calling CallerID */
@@ -87,14 +137,29 @@
  	char callingname[256];		/* Calling name (if provided) */
  	int calledplan;				/* Dialing plan of Called number */
  	int ani2;                   /* ANI II */
-@@ -321,6 +336,7 @@
- 	int layer1;					/* User layer 1 */
+ 	char callednum[256];		/* Called number */
+-	char redirectingnum[256];	/* Redirecting number */
+-	char redirectingname[256];	/* Redirecting name */
+-	int redirectingreason;		/* Reason for redirect */
++	char redirectingnum[256];		/* Redirecting number */
++	char redirectingname[256];		/* Redirecting name */
++	int redirectingreason;			/* Reason for redirect */
+ 	int callingplanrdnis;			/* Dialing plan of Redirecting Number */
+-	char useruserinfo[260];		/* User->User info */
++	char useruserinfo[260];			/* User->User info */
+ 	int flexible;				/* Are we flexible with our channel selection? */
+ 	int cref;					/* Call Reference Number */
+ 	int ctype;					/* Call type (see PRI_TRANS_CAP_* */
+-	int layer1;					/* User layer 1 */
++	int layer1;				/* User layer 1 */
  	int complete;				/* Have we seen "Complete" i.e. no more number? */
  	q931_call *call;			/* Opaque call pointer */
+-	char callingsubaddr[256];	/* Calling parties subaddress */
 +	int tei;				/* belongs to this tei */
- 	char callingsubaddr[256];	/* Calling parties subaddress */
++	char callingsubaddr[256];		/* Calling parties subaddress */
  	int progress;
  	int progressmask;
+ 	char origcalledname[256];
 @@ -335,6 +351,8 @@
  	int channel;				/* Channel requested */
  	int cause;
@@ -283,10 +348,10 @@
  
  /* Set overlap mode */
  #define PRI_SET_OVERLAPDIAL
-diff -urNad libpri-1.2.0-release/pri.c /tmp/dpep.aQ7o1G/libpri-1.2.0-release/pri.c
---- libpri-1.2.0-release/pri.c	2005-10-21 22:20:22.000000000 +0200
-+++ /tmp/dpep.aQ7o1G/libpri-1.2.0-release/pri.c	2005-11-23 04:05:24.942538410 +0200
-@@ -48,6 +48,14 @@
+diff -urN libpri-1.2.1.orig/pri.c libpri-1.2.1/pri.c
+--- libpri-1.2.1.orig/pri.c	2005-11-29 19:39:18.000000000 +0100
++++ libpri-1.2.1/pri.c	2005-11-25 17:09:30.000000000 +0100
+@@ -48,6 +36,14 @@
  		return "Network";
  	case PRI_CPE:
  		return "CPE";
@@ -301,7 +366,7 @@
  	default:
  		return "Invalid value";
  	}
-@@ -187,7 +195,7 @@
+@@ -187,7 +183,7 @@
  	return res;
  }
  
@@ -310,7 +375,7 @@
  {
  	struct pri *p;
  	p = malloc(sizeof(struct pri));
-@@ -207,6 +215,8 @@
+@@ -207,6 +203,8 @@
  		p->master = master;
  		p->callpool = &p->localpool;
  		pri_default_timers(p, switchtype);
@@ -319,7 +384,7 @@
  #ifdef LIBPRI_COUNTERS
  		p->q921_rxcount = 0;
  		p->q921_txcount = 0;
-@@ -217,7 +227,7 @@
+@@ -217,7 +215,7 @@
  			p->protodisc = GR303_PROTOCOL_DISCRIMINATOR;
  			p->sapi = Q921_SAPI_GR303_EOC;
  			p->tei = Q921_TEI_GR303_EOC_OPS;
@@ -328,7 +393,7 @@
  			if (!p->subchannel) {
  				free(p);
  				p = NULL;
-@@ -226,7 +236,7 @@
+@@ -226,7 +224,7 @@
  			p->protodisc = GR303_PROTOCOL_DISCRIMINATOR;
  			p->sapi = Q921_SAPI_GR303_TMC_CALLPROC;
  			p->tei = Q921_TEI_GR303_TMC_CALLPROC;
@@ -337,7 +402,7 @@
  			if (!p->subchannel) {
  				free(p);
  				p = NULL;
-@@ -242,7 +252,7 @@
+@@ -242,7 +240,7 @@
  		}
  		/* Start Q.921 layer, Wait if we're the network */
  		if (p)
@@ -346,7 +411,7 @@
  	}
  	return p;
  }
-@@ -262,15 +272,16 @@
+@@ -262,15 +260,16 @@
  {
  	/* Restart Q.921 layer */
  	if (pri) {
@@ -367,7 +432,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 +290,7 @@
+@@ -279,7 +278,7 @@
  		io_read = __pri_read;
  	if (!io_write)
  		io_write = __pri_write;
@@ -376,7 +441,16 @@
  }
  
  void *pri_get_userdata(struct pri *pri)
-@@ -443,6 +454,15 @@
+@@ -385,7 +384,7 @@
+ {
+ 	/* Return a configuration error */
+ 	pri->ev.err.e = PRI_EVENT_CONFIG_ERR;
+-	libpri_copy_string(pri->ev.err.err, errstr, sizeof(pri->ev.err.err));
++	strncpy(pri->ev.err.err, errstr, sizeof(pri->ev.err.err) - 1);
+ 	return &pri->ev;
+ }
+ 
+@@ -443,6 +442,15 @@
  	return;
  }
  
@@ -392,7 +466,7 @@
  int pri_acknowledge(struct pri *pri, q931_call *call, int channel, int info)
  {
  	if (!pri || !call)
-@@ -478,6 +498,21 @@
+@@ -478,6 +486,21 @@
  	return q931_notify(pri, call, channel, info);
  }
  
@@ -414,7 +488,7 @@
  void pri_destroycall(struct pri *pri, q931_call *call)
  {
  	if (pri && call)
-@@ -499,6 +534,76 @@
+@@ -499,6 +522,76 @@
  	return q931_connect(pri, call, channel, nonisdn);
  }
  
@@ -491,7 +565,7 @@
  #if 0
  /* deprecated routines, use pri_hangup */
  int pri_release(struct pri *pri, q931_call *call, int cause)
-@@ -543,12 +648,24 @@
+@@ -543,12 +636,29 @@
  
  int pri_hangup(struct pri *pri, q931_call *call, int cause)
  {
@@ -502,6 +576,11 @@
  		/* normal clear cause */
  		cause = 16;
 -	return q931_hangup(pri, call, cause);
++	if ((cause == 34 || cause == 44 || cause == 82 || cause == 1 || cause == 81) && (call->ourcallstate == Q931_CALL_STATE_ACTIVE)) {
++	    pri_error(pri, "Cause code %d not allowed when disconnecting an active call. Changing to cause 16.\n", cause);
++	    cause = 16;
++	}
++
 +	if (pri->localtype == BRI_NETWORK_PTMP) {
 +	    res = q921_hangup(pri, call, 127);
 +	    if (res) {
@@ -517,7 +596,7 @@
  }
  
  int pri_reset(struct pri *pri, int channel)
-@@ -688,15 +805,15 @@
+@@ -688,15 +798,15 @@
  	return q931_setup(pri, c, &req);
  }	
  
@@ -537,7 +616,7 @@
  {
  	__pri_error = func;
  }
-@@ -708,10 +825,14 @@
+@@ -708,10 +818,14 @@
  	va_start(ap, fmt);
  	vsnprintf(tmp, sizeof(tmp), fmt, ap);
  	va_end(ap);
@@ -556,7 +635,7 @@
  }
  
  void pri_error(struct pri *pri, char *fmt, ...)
-@@ -721,10 +842,14 @@
+@@ -721,10 +835,14 @@
  	va_start(ap, fmt);
  	vsnprintf(tmp, sizeof(tmp), fmt, ap);
  	va_end(ap);
@@ -575,7 +654,7 @@
  }
  
  /* Set overlap mode */
-@@ -765,11 +890,13 @@
+@@ -765,11 +883,13 @@
  	}
  	len += sprintf(buf + len, "Q921 Outstanding: %d\n", q921outstanding);
  #endif
@@ -594,7 +673,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]);
-@@ -778,6 +905,7 @@
+@@ -778,6 +898,7 @@
  	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]);
  
@@ -602,7 +681,7 @@
  	return strdup(buf);
  }
  
-@@ -851,3 +979,10 @@
+@@ -851,3 +972,10 @@
  	sr->redirectingreason = reason;
  	return 0;
  }
@@ -613,10 +692,10 @@
 +	q921_reset(pri, pri->tei, 1);
 +    }
 +}
-diff -urNad libpri-1.2.0-release/pri_facility.c /tmp/dpep.aQ7o1G/libpri-1.2.0-release/pri_facility.c
---- libpri-1.2.0-release/pri_facility.c	2005-10-04 20:35:48.000000000 +0300
-+++ /tmp/dpep.aQ7o1G/libpri-1.2.0-release/pri_facility.c	2005-11-23 04:05:24.946537856 +0200
-@@ -208,9 +208,9 @@
+diff -urN libpri-1.2.1.orig/pri_facility.c libpri-1.2.1/pri_facility.c
+--- libpri-1.2.1.orig/pri_facility.c	2005-11-29 19:39:18.000000000 +0100
++++ libpri-1.2.1/pri_facility.c	2005-11-20 15:58:10.000000000 +0100
+@@ -208,9 +195,9 @@
  	if (datalen > buflen) {
  		/* Truncate */
  		datalen = buflen;
@@ -628,7 +707,7 @@
  }
  
  int asn1_string_encode(unsigned char asn1_type, void *data, int len, int max_len, void *src, int src_len)
-@@ -305,7 +305,7 @@
+@@ -305,7 +292,7 @@
  			return -1;
  		value->ton = ton;
  
@@ -637,7 +716,7 @@
  
  	} while(0);
  	return -1;
-@@ -375,11 +375,10 @@
+@@ -375,11 +362,10 @@
  			pri_message(pri, "!! Unknown Party number component received 0x%X\n", comp->type);
  			return -1;
  		}
@@ -650,7 +729,7 @@
  	}
  	while (0);
  
-@@ -389,7 +388,6 @@
+@@ -389,7 +375,6 @@
  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;
@@ -658,7 +737,7 @@
  	struct rose_component *comp = NULL;
  	unsigned char *vdata = data;
  
-@@ -404,9 +402,7 @@
+@@ -404,9 +389,7 @@
  		switch(comp->type) {
  		case (ASN1_CONTEXT_SPECIFIC | ASN1_CONSTRUCTOR | ASN1_TAG_0):		/* [0] presentationAllowedNumber */
  			value->pres = PRES_ALLOWED_USER_NUMBER_NOT_SCREENED;
@@ -669,7 +748,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");
-@@ -423,9 +419,7 @@
+@@ -423,9 +406,7 @@
  			return 2;
  		case (ASN1_CONTEXT_SPECIFIC | ASN1_CONSTRUCTOR | ASN1_TAG_3):		/* [3] presentationRestrictedNumber */
  			value->pres = PRES_PROHIB_USER_NUMBER_NOT_SCREENED;
@@ -680,7 +759,7 @@
  		default:
  			pri_message(pri, "Invalid PresentedNumberUnscreened component 0x%X\n", comp->type);
  		}
-@@ -436,7 +430,7 @@
+@@ -436,7 +417,7 @@
  	return -1;
  }
  
@@ -689,7 +768,7 @@
  {
  	int i = 0;
  	int diversion_counter;
-@@ -445,21 +439,9 @@
+@@ -445,21 +426,9 @@
  	struct addressingdataelements_presentednumberunscreened divertingnr;
   	struct addressingdataelements_presentednumberunscreened originalcallednr;
  	struct rose_component *comp = NULL;
@@ -712,7 +791,7 @@
  	do {
  		/* diversionCounter stuff */
  		GET_COMPONENT(comp, i, vdata, len);
-@@ -477,20 +459,18 @@
+@@ -477,20 +446,18 @@
  	
  		if(pri->debug & PRI_DEBUG_APDU)
  			pri_message(pri, "    Redirection reason: %d, total diversions: %d\n", diversion_reason, diversion_counter);
@@ -736,7 +815,7 @@
  				comp->len = res;
  				if (res < 0)
  					return -1;
-@@ -499,43 +479,33 @@
+@@ -499,64 +466,62 @@
  					pri_message(pri, "      ton = %d, pres = %d, npi = %d\n", divertingnr.ton, divertingnr.pres, divertingnr.npi);
  				}
  				break;
@@ -787,7 +866,41 @@
  
  		if (divertingnr.pres >= 0) {
  			call->redirectingplan = divertingnr.npi;
-@@ -694,6 +664,64 @@
+ 			call->redirectingpres = divertingnr.pres;
+ 			call->redirectingreason = diversion_reason;
+-			libpri_copy_string(call->redirectingnum, divertingnr.partyaddress, sizeof(call->redirectingnum));
++			strncpy(call->redirectingnum, divertingnr.partyaddress, sizeof(call->redirectingnum)-1);
++			call->redirectingnum[sizeof(call->redirectingnum)-1] = '\0';
+ 		}
+ 		if (originalcallednr.pres >= 0) {
+ 			call->origcalledplan = originalcallednr.npi;
+ 			call->origcalledpres = originalcallednr.pres;
+-			libpri_copy_string(call->origcallednum, originalcallednr.partyaddress, sizeof(call->origcallednum));
++			strncpy(call->origcallednum, originalcallednr.partyaddress, sizeof(call->origcallednum)-1);
++			call->origcallednum[sizeof(call->origcallednum)-1] = '\0';
++		}
++		if (strlen(redirectingname) > 0) {
++			strncpy(call->redirectingname, redirectingname, sizeof(call->redirectingname));
++			call->redirectingname[sizeof(call->redirectingname)-1] = '\0';
++		}
++		if (strlen(origcalledname) > 0) {
++			strncpy(call->origcalledname, origcalledname, sizeof(call->origcalledname));
++			call->origcalledname[sizeof(call->origcalledname)-1] = '\0';
+ 		}
+-		libpri_copy_string(call->redirectingname, redirectingname, sizeof(call->redirectingname));
+-		libpri_copy_string(call->origcalledname, origcalledname, sizeof(call->origcalledname));
+ 		return 0;
+ 	}
+ 	while (0);
+ 
+ 	return -1;
+ }
+-				
++
+ static int rose_diverting_leg_information2_encode(struct pri *pri, q931_call *call)
+ {
+ 	int i = 0, j, compsp = 0;
+@@ -694,6 +659,64 @@
  	return 0;
  }
  
@@ -852,7 +965,7 @@
  /* Sending callername information functions */
  static int add_callername_facility_ies(struct pri *pri, q931_call *c, int cpe)
  {
-@@ -1132,6 +1160,7 @@
+@@ -1132,6 +1155,7 @@
  	int operation_tag;
  	unsigned char *vdata = data;
  	struct rose_component *comp = NULL, *invokeid = NULL, *operationid = NULL;
@@ -860,7 +973,7 @@
  	
  	do {
  		/* Invoke ID stuff */
-@@ -1148,13 +1177,15 @@
+@@ -1148,13 +1172,15 @@
  		NEXT_COMPONENT(comp, i);
  
  		/* No argument - return with error */
@@ -881,7 +994,7 @@
  
  		if (pri->debug & PRI_DEBUG_APDU)
  			pri_message(pri, "  [ Handling operation %d ]\n", operation_tag);
-@@ -1178,7 +1209,11 @@
+@@ -1178,7 +1204,11 @@
  		case ROSE_DIVERTING_LEG_INFORMATION2:
  			if (pri->debug & PRI_DEBUG_APDU)
  				pri_message(pri, "  Handle DivertingLegInformation2\n");
@@ -894,7 +1007,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);
-@@ -1229,6 +1264,32 @@
+@@ -1229,6 +1259,32 @@
  				dump_apdu (pri, (u_int8_t *)comp, comp->len + 2);
  			}
  			return -1;
@@ -927,9 +1040,9 @@
  		default:
  			if (pri->debug & PRI_DEBUG_APDU) {
  				pri_message(pri, "!! Unable to handle ROSE operation %d", operation_tag);
-diff -urNad libpri-1.2.0-release/pri_facility.h /tmp/dpep.aQ7o1G/libpri-1.2.0-release/pri_facility.h
---- libpri-1.2.0-release/pri_facility.h	2005-07-12 23:15:20.000000000 +0300
-+++ /tmp/dpep.aQ7o1G/libpri-1.2.0-release/pri_facility.h	2005-11-23 04:05:24.949537440 +0200
+diff -urN libpri-1.2.1.orig/pri_facility.h libpri-1.2.1/pri_facility.h
+--- libpri-1.2.1.orig/pri_facility.h	2005-11-29 19:39:18.000000000 +0100
++++ libpri-1.2.1/pri_facility.h	2005-07-26 12:16:40.000000000 +0200
 @@ -34,7 +34,7 @@
  /* Operation ID values */
  /* Q.952 ROSE operations (Diverting) */
@@ -975,9 +1088,9 @@
 +extern int add_call_deflection_facility_ie(struct pri *pri, q931_call *c, char *destination);
 +
  #endif /* _PRI_FACILITY_H */
-diff -urNad libpri-1.2.0-release/pri_internal.h /tmp/dpep.aQ7o1G/libpri-1.2.0-release/pri_internal.h
---- libpri-1.2.0-release/pri_internal.h	2005-10-21 22:20:22.000000000 +0200
-+++ /tmp/dpep.aQ7o1G/libpri-1.2.0-release/pri_internal.h	2005-11-23 04:05:24.952537024 +0200
+diff -urN libpri-1.2.1.orig/pri_internal.h libpri-1.2.1/pri_internal.h
+--- libpri-1.2.1.orig/pri_internal.h	2005-11-29 19:39:18.000000000 +0100
++++ libpri-1.2.1/pri_internal.h	2005-11-20 15:38:47.000000000 +0100
 @@ -30,7 +30,10 @@
  struct pri_sched {
  	struct timeval when;
@@ -1110,7 +1223,7 @@
  	
  	int ri;				/* Restart Indicator (Restart Indicator IE) */
  
-@@ -202,11 +235,14 @@
+@@ -202,15 +235,18 @@
  	int callerplan;
  	int callerplanani;
  	int callerpres;			/* Caller presentation */
@@ -1128,6 +1241,11 @@
  
  	int ani2;               /* ANI II */
  	
+-	int calledplan;
++	int  calledplan;
+ 	int nonisdn;
+ 	char callednum[256];	/* Called Number */
+ 	int complete;			/* no more digits coming */
 @@ -225,16 +261,27 @@
  	char redirectingnum[256];	/* Number of redirecting party */
  	char redirectingname[256];	/* Name of redirecting party */
@@ -1144,7 +1262,8 @@
 -	char origcallednum[256];	/* Orignal number of person being called */
 +	char origcallednum[256];		/* Orignal number of person being called */
  
- 	int useruserprotocoldisc;
+-	int useruserprotocoldisc;
++        int useruserprotocoldisc;
  	char useruserinfo[256];
  	char callingsubaddr[256];	/* Calling parties sub address */
 +
@@ -1175,9 +1294,9 @@
  extern void pri_error(struct pri *pri, char *fmt, ...);
  
  void libpri_copy_string(char *dst, const char *src, size_t size);
-diff -urNad libpri-1.2.0-release/pri_q921.h /tmp/dpep.aQ7o1G/libpri-1.2.0-release/pri_q921.h
---- libpri-1.2.0-release/pri_q921.h	2005-05-23 18:06:33.000000000 +0300
-+++ /tmp/dpep.aQ7o1G/libpri-1.2.0-release/pri_q921.h	2005-11-23 04:05:24.955536609 +0200
+diff -urN libpri-1.2.1.orig/pri_q921.h libpri-1.2.1/pri_q921.h
+--- libpri-1.2.1.orig/pri_q921.h	2005-11-29 19:39:18.000000000 +0100
++++ libpri-1.2.1/pri_q921.h	2005-06-13 09:02:39.000000000 +0200
 @@ -47,6 +47,13 @@
  #define Q921_FRAMETYPE_S	0x1
  
@@ -1210,9 +1329,9 @@
 +extern int q921_transmit_iframe(struct pri *pri, void *buf, int len, int cr, int tei);
  
  #endif
-diff -urNad libpri-1.2.0-release/pri_q931.h /tmp/dpep.aQ7o1G/libpri-1.2.0-release/pri_q931.h
---- libpri-1.2.0-release/pri_q931.h	2005-05-23 18:06:33.000000000 +0300
-+++ /tmp/dpep.aQ7o1G/libpri-1.2.0-release/pri_q931.h	2005-11-23 04:05:24.958536193 +0200
+diff -urN libpri-1.2.1.orig/pri_q931.h libpri-1.2.1/pri_q931.h
+--- libpri-1.2.1.orig/pri_q931.h	2005-11-29 19:39:18.000000000 +0100
++++ libpri-1.2.1/pri_q931.h	2005-06-13 09:02:39.000000000 +0200
 @@ -190,6 +190,10 @@
  #define Q931_IE_CODESET(x)		((x) >> 8)
  #define Q931_IE_IE(x)			((x) & 0xff)
@@ -1288,9 +1407,50 @@
 +//extern int q931_facility(struct pri *pri, q931_call *c, int operation, char *arguments);
 +
  #endif
-diff -urNad libpri-1.2.0-release/prisched.c /tmp/dpep.aQ7o1G/libpri-1.2.0-release/prisched.c
---- libpri-1.2.0-release/prisched.c	2005-06-22 01:47:39.000000000 +0300
-+++ /tmp/dpep.aQ7o1G/libpri-1.2.0-release/prisched.c	2005-11-23 04:05:24.961535777 +0200
+diff -urN libpri-1.2.1.orig/pri_timers.h libpri-1.2.1/pri_timers.h
+--- libpri-1.2.1.orig/pri_timers.h	2005-11-29 19:39:18.000000000 +0100
++++ libpri-1.2.1/pri_timers.h	2005-06-13 09:02:39.000000000 +0200
+@@ -27,17 +27,17 @@
+ 
+ /* -1 means we dont currently support the timer/counter */
+ #define PRI_TIMERS_DEFAULT {	3,	/* N200 */ \
+-				-1,	/* N201 */ \
+-				-1,	/* N202 */ \
++				260,	/* N201 */ \
++				3,	/* N202 */ \
+ 				7,	/* K */ \
+ 				1000,	/* T200 */ \
+-				-1,	/* T201 */ \
+-				-1,	/* T202 */ \
++				2000,	/* T201 */ \
++				5000,	/* T202 */ \
+ 				10000,	/* T203 */ \
+ 				-1,	/* T300 */ \
+ 				-1,	/* T301 */ \
+ 				-1,	/* T302 */ \
+-				-1,	/* T303 */ \
++				4000,	/* T303 */ \
+ 				-1,	/* T304 */ \
+ 				30000,	/* T305 */ \
+ 				-1,	/* T306 */ \
+diff -urN libpri-1.2.1.orig/pridump.c libpri-1.2.1/pridump.c
+--- libpri-1.2.1.orig/pridump.c	2005-11-29 19:39:18.000000000 +0100
++++ libpri-1.2.1/pridump.c	2005-11-20 15:10:20.000000000 +0100
+@@ -1,9 +1,9 @@
+ /*
+  * libpri: An implementation of Primary Rate ISDN
+  *
+- * Written by Mark Spencer <markster at digium.com>
++ * Written by Mark Spencer <markster at linux-support.net>
+  *
+- * Copyright (C) 2001-2005, Digium
++ * Copyright (C) 2001, Linux Support Services, Inc.
+  * All Rights Reserved.
+  *
+  * This program is free software; you can redistribute it and/or modify
+diff -urN libpri-1.2.1.orig/prisched.c libpri-1.2.1/prisched.c
+--- libpri-1.2.1.orig/prisched.c	2005-11-29 19:39:18.000000000 +0100
++++ libpri-1.2.1/prisched.c	2005-06-13 09:02:39.000000000 +0200
 @@ -22,10 +22,9 @@
   *
   */
@@ -1361,12 +1521,17 @@
  			(!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))))
-@@ -78,24 +109,36 @@
+@@ -76,26 +107,38 @@
+ 
+ static pri_event *__pri_schedule_run(struct pri *pri, struct timeval *tv)
  {
- 	int x;
- 	void (*callback)(void *);
+-	int x;
+-	void (*callback)(void *);
+-	void *data;
++ 	int x;
++ 	void (*callback)(void *);
 +	void (*callback2)(void *, int);
- 	void *data;
++ 	void *data;
 +	int data2;
  	pri_event *e;
 +
@@ -1407,9 +1572,9 @@
 +	pri->pri_sched[id].callback2 = NULL;
  }
 +
-diff -urNad libpri-1.2.0-release/pritest.c /tmp/dpep.aQ7o1G/libpri-1.2.0-release/pritest.c
---- libpri-1.2.0-release/pritest.c	2005-06-22 01:47:39.000000000 +0300
-+++ /tmp/dpep.aQ7o1G/libpri-1.2.0-release/pritest.c	2005-11-23 04:05:24.964535362 +0200
+diff -urN libpri-1.2.1.orig/pritest.c libpri-1.2.1/pritest.c
+--- libpri-1.2.1.orig/pritest.c	2005-11-29 19:39:18.000000000 +0100
++++ libpri-1.2.1/pritest.c	2005-06-13 09:02:39.000000000 +0200
 @@ -51,8 +51,8 @@
  #define PRI_DEF_NODETYPE	PRI_CPE
  #define PRI_DEF_SWITCHTYPE	PRI_SWITCH_NI2
@@ -1456,44 +1621,33 @@
  	default:
  		fprintf(stderr, "--!! Unknown PRI event %d\n", e->e);
  	}
-diff -urNad libpri-1.2.0-release/pri_timers.h /tmp/dpep.aQ7o1G/libpri-1.2.0-release/pri_timers.h
---- libpri-1.2.0-release/pri_timers.h	2005-04-09 02:04:37.000000000 +0300
-+++ /tmp/dpep.aQ7o1G/libpri-1.2.0-release/pri_timers.h	2005-11-23 04:05:24.966535085 +0200
-@@ -27,17 +27,17 @@
- 
- /* -1 means we dont currently support the timer/counter */
- #define PRI_TIMERS_DEFAULT {	3,	/* N200 */ \
--				-1,	/* N201 */ \
--				-1,	/* N202 */ \
-+				260,	/* N201 */ \
-+				3,	/* N202 */ \
- 				7,	/* K */ \
- 				1000,	/* T200 */ \
--				-1,	/* T201 */ \
--				-1,	/* T202 */ \
-+				2000,	/* T201 */ \
-+				5000,	/* T202 */ \
- 				10000,	/* T203 */ \
- 				-1,	/* T300 */ \
- 				-1,	/* T301 */ \
- 				-1,	/* T302 */ \
--				-1,	/* T303 */ \
-+				4000,	/* T303 */ \
- 				-1,	/* T304 */ \
- 				30000,	/* T305 */ \
- 				-1,	/* T306 */ \
-diff -urNad libpri-1.2.0-release/q921.c /tmp/dpep.aQ7o1G/libpri-1.2.0-release/q921.c
---- libpri-1.2.0-release/q921.c	2005-06-22 01:47:39.000000000 +0300
-+++ /tmp/dpep.aQ7o1G/libpri-1.2.0-release/q921.c	2005-11-23 04:05:24.972534253 +0200
-@@ -5,6 +5,8 @@
+diff -urN libpri-1.2.1.orig/q921.c libpri-1.2.1/q921.c
+--- libpri-1.2.1.orig/q921.c	2005-12-06 22:35:50.000000000 +0100
++++ libpri-1.2.1/q921.c	2005-07-25 16:53:22.000000000 +0200
+@@ -1,10 +1,12 @@
+ /*
+  * libpri: An implementation of Primary Rate ISDN
   *
-  * Copyright (C) 2001-2005, Digium
+- * Written by Mark Spencer <markster at digium.com>
++ * Written by Mark Spencer <markster at linux-support.net>
+  *
+- * Copyright (C) 2001-2005, Digium
++ * Copyright (C) 2001, Linux Support Services, Inc.
   * All Rights Reserved.
 + * Copyright (C) 2003,2004,2005 Junghanns.NET GmbH
 + * Klaus-Peter Junghanns <kpj at junghanns.net>
   *
   * 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,23 @@
  	(hf).h.tei = (pri)->tei; \
  } while(0)
@@ -1512,13 +1666,17 @@
 +	
 +	f = pri->txqueue[teio];
  	while(f) {
- 		p = f;
- 		f = f->next;
- 		/* Free frame */
- 		free(p);
+-		p = f;
+-		f = f->next;
+-		/* Free frame */
+-		free(p);
++	    p = f;
++	    f = f->next;
++	    /* Free frame */
++	    free(p);
  	}
 -	pri->txqueue = NULL;
-+       pri->txqueue[teio] = NULL;
++        pri->txqueue[teio] = NULL;
  }
  
  static int q921_transmit(struct pri *pri, q921_h *h, int len) 
@@ -1994,16 +2152,9 @@
 +static void t203_expire(void *, int tei);
 +static void t200_expire(void *, int tei);
 +static pri_event *q921_dchannel_down(struct pri *pri, int tei);
- 
--static void reschedule_t203(struct pri *pri)
++
 +static void reschedule_t203(struct pri *pri, int tei)
- {
--	if (pri->t203_timer) {
--		pri_schedule_del(pri, pri->t203_timer);
--		if (pri->debug &  PRI_DEBUG_Q921_STATE)
--			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);
++{
 + 	int teio=tei - Q921_TEI_BASE;
 + 	if (((teio < 0) || (teio > Q921_MAX_TEIS)) || (pri->localtype != BRI_NETWORK_PTMP)) { teio=0; }
 + 	if (pri->t203_timer[teio]) {
@@ -2017,9 +2168,16 @@
 +		}
 +  	}
 +}
-+
+ 
+-static void reschedule_t203(struct pri *pri)
 +static void q921_flush_txqueue(struct pri *pri, int tei, int devnull)
-+{
+ {
+-	if (pri->t203_timer) {
+-		pri_schedule_del(pri, pri->t203_timer);
+-		if (pri->debug &  PRI_DEBUG_Q921_STATE)
+-			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;	
 +	int teio=tei - Q921_TEI_BASE;
 +	if (((teio < 0) || (teio > Q921_MAX_TEIS)) || (pri->localtype != BRI_NETWORK_PTMP)) { teio=0; }
@@ -2273,7 +2431,7 @@
           if (pri->debug & PRI_DEBUG_Q921_STATE)
 -            pri_message(pri, "-- Retransmitting %d bytes\n", pri->txqueue->len);
 -		if (pri->busy) 
--			q921_rr(pri, 1, 0);
+-			q921_rr(pri, 1, 1);
 -		else {
 -			if (!pri->txqueue->transmitted) 
 +        	pri_message(pri, "-- Retransmitting %d bytes\n", pri->txqueue[teio]->len);
@@ -2822,8 +2980,9 @@
  			if (ev)
  				return ev;
  			if (h->s.p_f) {
- 				/* If it's a p/f one then send back a RR in return with the p/f bit set */
+-				/* If it's a p/f one then send back a RR in return with the p/f bit set */
 -				if (pri->solicitfbit) {
++			/* If it's a p/f one then send back a RR in return with the p/f bit set */
 +//			pri_error(pri, "-- h->s.pf %d pri->solicitfbit[teio] %d\n", h->s.p_f, pri->solicitfbit[teio]);
 +				if (pri->solicitfbit[teio]) {
  					if (pri->debug & PRI_DEBUG_Q921_STATE) 
@@ -3296,18 +3455,33 @@
 -	/* Do the SABME XXX Maybe we should implement T_WAIT? XXX */
 -	q921_send_sabme(pri, now);
  }
-diff -urNad libpri-1.2.0-release/q931.c /tmp/dpep.aQ7o1G/libpri-1.2.0-release/q931.c
---- libpri-1.2.0-release/q931.c	2005-10-25 18:59:59.000000000 +0200
-+++ /tmp/dpep.aQ7o1G/libpri-1.2.0-release/q931.c	2005-11-23 04:05:24.984532591 +0200
-@@ -5,6 +5,8 @@
+diff -urN libpri-1.2.1.orig/q931.c libpri-1.2.1/q931.c
+--- libpri-1.2.1.orig/q931.c	2005-12-01 03:34:44.000000000 +0100
++++ libpri-1.2.1/q931.c	2005-12-21 14:23:13.000000000 +0100
+@@ -1,10 +1,12 @@
+ /*
+  * libpri: An implementation of Primary Rate ISDN
   *
-  * Copyright (C) 2001-2005, Digium
+- * Written by Mark Spencer <markster at digium.com>
++ * Written by Mark Spencer <markster at linux-support.net>
+  *
+- * Copyright (C) 2001-2005, Digium
++ * Copyright (C) 2001, Linux Support Services, Inc.
   * All Rights Reserved.
 + * Copyright (C) 2003,2004,2005 Junghanns.NET GmbH
 + * Klaus-Peter Junghanns <kpj at junghanns.net>
   *
   * 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>
@@ -3747,6 +3921,15 @@
  	return 0;
  }
  
+@@ -946,7 +1064,7 @@
+ {
+ 	ie->data[0] = call->callerplan;
+ 	ie->data[1] = 0x80 | call->callerpres;
+-	if (*call->callernum) 
++	if (strlen(call->callernum)) 
+ 		memcpy(ie->data + 2, call->callernum, strlen(call->callernum));
+ 	return strlen(call->callernum) + 4;
+ }
 @@ -964,11 +1082,33 @@
  static FUNC_RECV(receive_user_user)
  {        
@@ -4125,7 +4308,7 @@
  static FUNC_RECV(receive_facility)
  {
  	int i = 0;
-@@ -1366,7 +1806,7 @@
+@@ -1366,39 +1806,60 @@
  
  static FUNC_DUMP(dump_keypad_facility)
  {
@@ -4134,7 +4317,11 @@
  	
  	if (ie->len == 0 || ie->len > sizeof(tmp))
  		return;
-@@ -1377,7 +1817,7 @@
+ 	
+-	libpri_copy_string(tmp, (char *) ie->data, sizeof(tmp));
++	strncpy(tmp, (char *) ie->data, sizeof(tmp));
+ 	pri_message(pri, "%c Keypad Facility (len=%2d) [ %s ]\n", prefix, ie->len, tmp );
+ }
  
  static FUNC_RECV(receive_keypad_facility)
  {
@@ -4143,7 +4330,20 @@
  
  	if (ie->len == 0)
  		return -1;
-@@ -1392,11 +1832,31 @@
+ 
+ 	if (ie->len > (sizeof(call->digitbuf) - 1))
+-		mylen = (sizeof(call->digitbuf) - 1);
++		mylen = sizeof(call->digitbuf) - 1;
+ 	else
+ 		mylen = ie->len;
+ 
+-	memcpy(call->digitbuf, ie->data, mylen);
++	strncpy(call->digitbuf, (char *) ie->data, mylen);
+ 
+-	call->digitbuf[mylen] = 0;
++	/* I must be really neurotic */
++	call->digitbuf[sizeof(call->digitbuf)-1] = '\0';
+ 
  	return 0;
  }
  
@@ -4176,7 +4376,7 @@
  	if (buf) {
  		x=y=0;
  		if ((x < ie->len) && (ie->data[x] & 0x80)) {
-@@ -1411,7 +1871,7 @@
+@@ -1413,7 +1874,7 @@
  	}
  }
  
@@ -4185,7 +4385,7 @@
  {
  	char tmp[1024] = "";
  	int x=0;
-@@ -1421,7 +1881,7 @@
+@@ -1423,7 +1884,7 @@
  		    ((*c >= 'a') && (*c <= 'z')) ||
  		    ((*c >= '0') && (*c <= '9'))) {
  			if (!lastascii) {
@@ -4194,7 +4394,7 @@
  					tmp[x++] = ',';
  					tmp[x++] = ' ';
  				}
-@@ -1433,7 +1893,7 @@
+@@ -1435,7 +1896,7 @@
  			if (lastascii) {
  				tmp[x++] = '\'';
  			}
@@ -4203,7 +4403,7 @@
  				tmp[x++] = ',';
  				tmp[x++] = ' ';
  			}
-@@ -1446,14 +1906,14 @@
+@@ -1448,14 +1909,14 @@
  	}
  	if (lastascii)
  		tmp[x++] = '\'';
@@ -4221,7 +4421,7 @@
  }
  
  static FUNC_DUMP(dump_network_spec_fac)
-@@ -1463,7 +1923,7 @@
+@@ -1465,7 +1926,7 @@
  		pri_message(pri, code2str(ie->data[1], facilities, sizeof(facilities) / sizeof(facilities[0])));
  	}
  	else
@@ -4230,7 +4430,7 @@
  	pri_message(pri, " ]\n");
  }
  
-@@ -1940,11 +2400,11 @@
+@@ -1942,11 +2403,11 @@
  	{ 1, Q931_IE_INFO_REQUEST, "Feature Request" },
  	{ 1, Q931_IE_FEATURE_IND, "Feature Indication" },
  	{ 1, Q931_IE_SEGMENTED_MSG, "Segmented Message" },
@@ -4244,7 +4444,7 @@
  	{ 1, Q931_IE_KEYPAD_FACILITY, "Keypad Facility", dump_keypad_facility, receive_keypad_facility },
  	{ 0, Q931_IE_SIGNAL, "Signal", dump_signal },
  	{ 1, Q931_IE_SWITCHHOOK, "Switch-hook" },
-@@ -1952,6 +2412,7 @@
+@@ -1954,6 +2415,7 @@
  	{ 1, Q931_IE_ESCAPE_FOR_EXT, "Escape for Extension" },
  	{ 1, Q931_IE_CALL_STATUS, "Call Status" },
  	{ 1, Q931_IE_CHANGE_STATUS, "Change Status" },
@@ -4252,7 +4452,16 @@
  	{ 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 },
-@@ -2052,10 +2513,10 @@
+@@ -2024,7 +2486,7 @@
+ {
+ 	if ((ie->ie & 0x80) != 0)
+ 		return 1;
+-	else
++	else 
+ 		return 2 + ie->len;
+ }
+ 
+@@ -2054,10 +2516,10 @@
  			break;
  		case 1:
  			cr = h->crv[0];
@@ -4265,7 +4474,7 @@
  			break;
  		default:
  			pri_error(NULL, "Call Reference Length not supported: %d\n", h->crlen);
-@@ -2069,14 +2530,14 @@
+@@ -2071,14 +2533,14 @@
  	int full_ie = Q931_FULL_IE(codeset, ie->ie);
  	int base_ie;
  
@@ -4285,7 +4494,7 @@
  
  	/* Special treatment for shifts */
  	if((full_ie & 0xf0) == Q931_LOCKING_SHIFT)
-@@ -2096,14 +2557,46 @@
+@@ -2098,14 +2560,46 @@
  	pri_error(pri, "!! %c Unknown IE %d (len = %d)\n", prefix, base_ie, ielen(ie));
  }
  
@@ -4335,7 +4544,7 @@
  		prev = cur;
  		cur = cur->next;
  	}
-@@ -2116,6 +2609,7 @@
+@@ -2118,6 +2612,7 @@
  		/* Call reference */
  		cur->cr = cr;
  		cur->pri = pri;
@@ -4343,7 +4552,7 @@
  		/* Append to end of list */
  		if (prev)
  			prev->next = cur;
-@@ -2131,24 +2625,42 @@
+@@ -2133,24 +2628,42 @@
  	do {
  		cur = *pri->callpool;
  		pri->cref++;
@@ -4393,7 +4602,7 @@
  			if (prev)
  				prev->next = cur->next;
  			else
-@@ -2157,6 +2669,8 @@
+@@ -2159,6 +2672,8 @@
  				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);
@@ -4402,7 +4611,7 @@
  			pri_call_apdu_queue_cleanup(cur);
  			free(cur);
  			return;
-@@ -2167,16 +2681,16 @@
+@@ -2169,16 +2684,16 @@
  	pri_error(pri, "Can't destroy call %d!\n", cr);
  }
  
@@ -4422,7 +4631,7 @@
  	return;
  }
  
-@@ -2288,6 +2802,10 @@
+@@ -2290,6 +2805,10 @@
  {
  	unsigned int x;
  	int full_ie = Q931_FULL_IE(codeset, ie->ie);
@@ -4433,7 +4642,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++) {
-@@ -2305,21 +2823,36 @@
+@@ -2307,21 +2826,36 @@
  	return -1;
  }
  
@@ -4475,7 +4684,7 @@
  	}
  	if (pri->subchannel) {
  		/* On GR-303, top bit is always 0 */
-@@ -2328,13 +2861,23 @@
+@@ -2330,13 +2864,23 @@
  	mh->f = 0;
  	*hb = h;
  	*mhb = mh;
@@ -4503,7 +4712,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 */
-@@ -2360,7 +2903,11 @@
+@@ -2362,7 +2906,11 @@
  	
  	memset(buf, 0, sizeof(buf));
  	len = sizeof(buf);
@@ -4516,7 +4725,7 @@
  	mh->msg = msgtype;
  	x=0;
  	codeset = 0;
-@@ -2395,11 +2942,34 @@
+@@ -2397,11 +2945,34 @@
  	}
  	/* Invert the logic */
  	len = sizeof(buf) - len;
@@ -4552,7 +4761,7 @@
  static int status_ies[] = { Q931_CAUSE, Q931_CALL_STATE, -1 };
  
  static int q931_status(struct pri *pri, q931_call *c, int cause)
-@@ -2437,17 +3007,45 @@
+@@ -2439,17 +3010,45 @@
  	return send_message(pri, c, Q931_INFORMATION, information_ies);
  }
  
@@ -4600,7 +4809,7 @@
  int q931_facility(struct pri*pri, q931_call *c)
  {
  	return send_message(pri, c, Q931_FACILITY, facility_ies);
-@@ -2461,7 +3059,6 @@
+@@ -2463,7 +3062,6 @@
  		if ((info > 0x2) || (info < 0x00))
  			return 0;
  	}
@@ -4608,7 +4817,16 @@
  	if (info >= 0)
  		c->notify = info & 0x7F;
  	else
-@@ -2530,8 +3127,14 @@
+@@ -2506,6 +3104,8 @@
+ 
+ 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 (channel) { 
+ 		c->ds1no = (channel & 0xff00) >> 8;
+ 		c->ds1explicit = (channel & 0x10000) >> 16;
+@@ -2532,8 +3132,14 @@
  static int alerting_ies[] = { -1 };
  #endif
  
@@ -4623,7 +4841,7 @@
  	if (!c->proc) 
  		q931_call_proceeding(pri, c, channel, 0);
  	if (info) {
-@@ -2542,11 +3145,126 @@
+@@ -2544,11 +3150,126 @@
  		c->progressmask = 0;
  	c->ourcallstate = Q931_CALL_STATE_CALL_RECEIVED;
  	c->peercallstate = Q931_CALL_STATE_CALL_DELIVERED;
@@ -4751,7 +4969,7 @@
   
  int q931_setup_ack(struct pri *pri, q931_call *c, int channel, int nonisdn)
  {
-@@ -2567,9 +3285,35 @@
+@@ -2569,9 +3290,36 @@
  	c->ourcallstate = Q931_CALL_STATE_OVERLAP_RECEIVING;
  	c->peercallstate = Q931_CALL_STATE_OVERLAP_SENDING;
  	c->alive = 1;
@@ -4778,6 +4996,7 @@
 +	pri->ev.e = PRI_EVENT_HANGUP;
 +	pri->ev.hangup.channel = c->channelno;
 +	pri->ev.hangup.cref = c->cr;
++	pri->ev.hangup.aoc_units = -1;
 +//	pri->ev.hangup.cause = c->cause;
 +	pri->ev.hangup.cause = PRI_CAUSE_SWITCH_CONGESTION;
 +	pri->ev.hangup.call = c;
@@ -4787,7 +5006,7 @@
  static void pri_connect_timeout(void *data)
  {
  	struct q931_call *c = data;
-@@ -2645,7 +3389,12 @@
+@@ -2647,7 +3395,12 @@
  	c->retranstimer = 0;
  	if ((pri->localtype == PRI_CPE) && (!pri->subchannel))
  		c->retranstimer = pri_schedule_event(pri, pri->timers[PRI_TIMER_T313], pri_connect_timeout, c);
@@ -4801,7 +5020,7 @@
  }
  
  static int release_ies[] = { Q931_CAUSE, Q931_IE_USER_USER, -1 };
-@@ -2679,7 +3428,7 @@
+@@ -2681,7 +3434,7 @@
  int q931_restart(struct pri *pri, int channel)
  {
  	struct q931_call *c;
@@ -4810,7 +5029,7 @@
  	if (!c)
  		return -1;
  	if (!channel)
-@@ -2716,6 +3465,9 @@
+@@ -2718,6 +3471,9 @@
  		return 0;
  }
  
@@ -4820,7 +5039,7 @@
  static int setup_ies[] = { Q931_BEARER_CAPABILITY, Q931_CHANNEL_IDENT, Q931_IE_FACILITY, Q931_PROGRESS_INDICATOR, Q931_NETWORK_SPEC_FAC, Q931_DISPLAY, Q931_IE_USER_USER,
  	Q931_CALLING_PARTY_NUMBER, Q931_CALLED_PARTY_NUMBER, Q931_REDIRECTING_NUMBER, Q931_SENDING_COMPLETE, Q931_IE_ORIGINATING_LINE_INFO, Q931_IE_GENERIC_DIGITS, -1 };
  
-@@ -2726,7 +3478,12 @@
+@@ -2728,7 +3484,12 @@
  int q931_setup(struct pri *pri, q931_call *c, struct pri_sr *req)
  {
  	int res;
@@ -4834,7 +5053,7 @@
  	
  	c->transcapability = req->transmode;
  	c->transmoderate = TRANS_MODE_64_CIRCUIT;
-@@ -2752,12 +3509,12 @@
+@@ -2754,12 +3515,12 @@
  	else if (c->channelno)
  		c->chanflags = FLAG_PREFERRED;
  	if (req->caller) {
@@ -4850,7 +5069,7 @@
  		if ((pri->switchtype == PRI_SWITCH_DMS100) ||
  		    (pri->switchtype == PRI_SWITCH_ATT4ESS)) {
  			/* Doesn't like certain presentation types */
-@@ -2766,13 +3523,13 @@
+@@ -2768,13 +3529,13 @@
  		}
  		c->callerpres = req->callerpres;
  	} else {
@@ -4867,7 +5086,7 @@
  		c->redirectingplan = req->redirectingplan;
  		if ((pri->switchtype == PRI_SWITCH_DMS100) ||
  		    (pri->switchtype == PRI_SWITCH_ATT4ESS)) {
-@@ -2783,13 +3540,13 @@
+@@ -2785,13 +3546,13 @@
  		c->redirectingpres = req->redirectingpres;
  		c->redirectingreason = req->redirectingreason;
  	} else {
@@ -4883,7 +5102,7 @@
  		c->calledplan = req->calledplan;
  	} else
  		return -1;
-@@ -2810,12 +3567,17 @@
+@@ -2812,12 +3573,17 @@
  		res = send_message(pri, c, Q931_SETUP, cis_setup_ies);
  	else
  		res = send_message(pri, c, Q931_SETUP, setup_ies);
@@ -4901,7 +5120,7 @@
  	}
  	return res;
  	
-@@ -2831,7 +3593,11 @@
+@@ -2833,7 +3599,11 @@
  	if (cause > -1) {
  		c->cause = cause;
  		c->causecode = CODE_CCITT;
@@ -4914,7 +5133,7 @@
  		/* release_ies has CAUSE in it */
  		res = send_message(pri, c, Q931_RELEASE_COMPLETE, release_ies);
  	} else
-@@ -2856,6 +3622,117 @@
+@@ -2858,6 +3628,117 @@
  	return 0;
  }
  
@@ -5032,7 +5251,7 @@
  int q931_hangup(struct pri *pri, q931_call *c, int cause)
  {
  	int disconnect = 1;
-@@ -2881,7 +3758,7 @@
+@@ -2883,7 +3764,7 @@
  	case Q931_CALL_STATE_NULL:
  		if (c->peercallstate == Q931_CALL_STATE_NULL)
  			/* free the resources if we receive or send REL_COMPL */
@@ -5041,7 +5260,7 @@
  		else if (c->peercallstate == Q931_CALL_STATE_RELEASE_REQUEST)
  			q931_release_complete(pri,c,cause);
  		break;
-@@ -2907,6 +3784,11 @@
+@@ -2909,6 +3790,11 @@
  		/* 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) {
@@ -5053,7 +5272,7 @@
  			if (disconnect)
  				q931_disconnect(pri,c,cause);
  			else if (release_compl)
-@@ -2922,8 +3804,14 @@
+@@ -2924,8 +3810,14 @@
  		break;
  	case Q931_CALL_STATE_DISCONNECT_INDICATION:
  		/* received DISCONNECT */
@@ -5068,7 +5287,7 @@
  			q931_release(pri,c,cause);
  		}
  		break;
-@@ -2937,19 +3825,17 @@
+@@ -2939,19 +3831,17 @@
  		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:
@@ -5091,7 +5310,7 @@
  	q931_call *c;
  	q931_ie *ie;
  	unsigned int x;
-@@ -2974,13 +3860,13 @@
+@@ -2976,13 +3866,13 @@
  		   KLUDGE this by changing byte 4 from a 0xf (SERVICE) 
  		   to a 0x7 (SERVICE ACKNOWLEDGE) */
  		h->raw[h->crlen + 2] -= 0x8;
@@ -5107,7 +5326,7 @@
  	if (!c) {
  		pri_error(pri, "Unable to locate call %d\n", q931_cr(h));
  		return -1;
-@@ -2998,11 +3884,12 @@
+@@ -3000,11 +3890,12 @@
  		c->ri = -1;
  		break;
  	case Q931_FACILITY:
@@ -5121,7 +5340,7 @@
  		c->channelno = -1;
  		c->slotmap = -1;
  		c->chanflags = 0;
-@@ -3018,33 +3905,49 @@
+@@ -3020,33 +3911,49 @@
  		c->calledplan = -1;
  		c->callerplan = -1;
  		c->callerpres = -1;
@@ -5145,17 +5364,17 @@
 -		c->origcalledname[0] = '\0';
 -		c->useruserprotocoldisc = -1; 
 -		c->useruserinfo[0] = '\0';
-+               c->redirectingplan = -1;
-+               c->redirectingpres = -1;
-+               c->redirectingreason = -1;
-+               c->origcalledplan = -1;
-+               c->origcalledpres = -1;
-+               c->origredirectingreason = -1;
++                c->redirectingplan = -1;
++                c->redirectingpres = -1;
++                c->redirectingreason = -1;
++                c->origcalledplan = -1;
++                c->origcalledpres = -1;
++                c->origredirectingreason = -1;
 +		strcpy(c->redirectingnum, "");
 +		strcpy(c->origcallednum, "");
 +		strcpy(c->redirectingname, "");
 +		strcpy(c->origcalledname, "");
-+               c->useruserprotocoldisc = -1; 
++                c->useruserprotocoldisc = -1; 
 +		strcpy(c->useruserinfo, "");
  		c->complete = 0;
  		c->nonisdn = 0;
@@ -5177,8 +5396,9 @@
 + 		break;
  	case Q931_ALERTING:
  	case Q931_PROGRESS:
- 		c->useruserinfo[0] = '\0';
+-		c->useruserinfo[0] = '\0';
 -		c->cause = -1;
++ 		c->useruserinfo[0] = '\0';
  	case Q931_CALL_PROCEEDING:
 + 		if (c->t303timer) {
 + 		    c->t303running = 0;
@@ -5188,7 +5408,7 @@
  		c->progress = -1;
  		c->progressmask = 0;
  		break;
-@@ -3059,14 +3962,19 @@
+@@ -3061,16 +3968,21 @@
  		c->causecode = -1;
  		c->causeloc = -1;
  		c->aoc_units = -1;
@@ -5208,9 +5428,12 @@
 -			pri_schedule_del(pri, c->retranstimer);
 +		    pri_schedule_del(pri, c->retranstimer);
  		c->retranstimer = 0;
- 		c->useruserinfo[0] = '\0';
+-		c->useruserinfo[0] = '\0';
++ 		c->useruserinfo[0] = '\0';
  	case Q931_STATUS:
-@@ -3084,22 +3992,32 @@
+ 		c->cause = -1;
+ 		c->causecode = -1;
+@@ -3086,22 +3998,32 @@
  	case Q931_STATUS_ENQUIRY:
  		break;
  	case Q931_SETUP_ACKNOWLEDGE:
@@ -5247,7 +5470,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);
-@@ -3108,7 +4026,7 @@
+@@ -3110,7 +4032,7 @@
  		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) 
@@ -5256,13 +5479,15 @@
  		return -1;
  	}
  	memset(mandies, 0, sizeof(mandies));
-@@ -3188,12 +4106,17 @@
+@@ -3190,12 +4112,20 @@
  	missingmand = 0;
  	for (x=0;x<MAX_MAND_IES;x++) {
  		if (mandies[x]) {
 -			/* check if there is no channel identification when we're configured as network -> that's not an error */
 -			if (((pri->localtype != PRI_NETWORK) || (mh->msg != Q931_SETUP) || (mandies[x] != Q931_CHANNEL_IDENT)) &&
 -			     ((mh->msg != Q931_PROGRESS) || (mandies[x] != Q931_PROGRESS_INDICATOR))) {
+-				pri_error(pri, "XXX Missing handling for mandatory IE %d (cs%d, %s) XXX\n", Q931_IE_IE(mandies[x]), Q931_IE_CODESET(mandies[x]), ie2str(mandies[x]));
+-				missingmand++;
 +		    int network = pri->localtype == PRI_NETWORK || pri->localtype == BRI_NETWORK || pri->localtype == BRI_NETWORK_PTMP;
 +		    /* check if there is no channel identification when we're configured as network -> that's not an error */
 + 		    if (network) {
@@ -5270,14 +5495,17 @@
 +			     ((mh->msg == Q931_PROGRESS) && (mandies[x] == Q931_PROGRESS_INDICATOR))) {
 +			    /* according to ets 300 102-1 a progress indicator is mandatory, but so what? ;-)  */
 +			} else {
- 				pri_error(pri, "XXX Missing handling for mandatory IE %d (cs%d, %s) XXX\n", Q931_IE_IE(mandies[x]), Q931_IE_CODESET(mandies[x]), ie2str(mandies[x]));
- 				missingmand++;
++			    pri_error(pri, "XXX Missing handling for mandatory IE %d (cs%d, %s) XXX\n", Q931_IE_IE(mandies[x]), Q931_IE_CODESET(mandies[x]), ie2str(mandies[x]));
++			    missingmand++;
  			}
++		    } else {
++			pri_error(pri, "XXX Missing handling for mandatory IE %d (cs%d, %s) XXX\n", Q931_IE_IE(mandies[x]), Q931_IE_CODESET(mandies[x]), ie2str(mandies[x]));
++			missingmand++;
 +		    }
  		}
  	}
  	
-@@ -3202,7 +4125,7 @@
+@@ -3204,7 +4134,7 @@
  	case Q931_RESTART:
  		if (missingmand) {
  			q931_status(pri, c, PRI_CAUSE_MANDATORY_IE_MISSING);
@@ -5286,7 +5514,7 @@
  			break;
  		}
  		c->ourcallstate = Q931_CALL_STATE_RESTART;
-@@ -3220,6 +4143,7 @@
+@@ -3222,6 +4152,7 @@
  		}
  		/* Must be new call */
  		if (!c->newcall) {
@@ -5294,7 +5522,7 @@
  			break;
  		}
  		if (c->progressmask & PRI_PROG_CALLER_NOT_ISDN)
-@@ -3237,27 +4161,31 @@
+@@ -3239,27 +4170,31 @@
  		pri->ev.ring.channel = c->channelno | (c->ds1no << 8) | (c->ds1explicit << 16);
  		pri->ev.ring.callingpres = c->callerpres;
  		pri->ev.ring.callingplan = c->callerplan;
@@ -5338,7 +5566,7 @@
  		pri->ev.ring.layer1 = c->userl1;
  		pri->ev.ring.complete = c->complete; 
  		pri->ev.ring.ctype = c->transcapability;
-@@ -3270,6 +4198,9 @@
+@@ -3272,6 +4207,9 @@
  			q931_release_complete(pri,c,PRI_CAUSE_INVALID_CALL_REFERENCE);
  			break;
  		}
@@ -5348,7 +5576,7 @@
  		c->ourcallstate = Q931_CALL_STATE_CALL_DELIVERED;
  		c->peercallstate = Q931_CALL_STATE_CALL_RECEIVED;
  		pri->ev.e = PRI_EVENT_RINGING;
-@@ -3290,17 +4221,24 @@
+@@ -3292,17 +4230,24 @@
  			q931_status(pri, c, PRI_CAUSE_WRONG_MESSAGE);
  			break;
  		}
@@ -5373,7 +5601,7 @@
  		if (c->justsignalling) {  /* Make sure WE release when we initiatie a signalling only connection */
  			q931_release(pri, c, PRI_CAUSE_NORMAL_CLEARING);
  			break;
-@@ -3308,23 +4246,43 @@
+@@ -3310,23 +4255,43 @@
  			return Q931_RES_HAVEEVENT;
  	case Q931_FACILITY:
  		if (c->newcall) {
@@ -5430,7 +5658,7 @@
  			break;
  		}
  		pri->ev.e = PRI_EVENT_PROGRESS;
-@@ -3342,6 +4300,11 @@
+@@ -3344,6 +4309,11 @@
  			q931_status(pri,c,PRI_CAUSE_WRONG_MESSAGE);
  			break;
  		}
@@ -5442,7 +5670,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;
-@@ -3368,7 +4331,7 @@
+@@ -3370,7 +4340,7 @@
  	case Q931_STATUS:
  		if (missingmand) {
  			q931_status(pri, c, PRI_CAUSE_MANDATORY_IE_MISSING);
@@ -5451,7 +5679,7 @@
  			break;
  		}
  		if (c->newcall) {
-@@ -3405,31 +4368,67 @@
+@@ -3407,31 +4377,67 @@
  			if (res)
  				return res;
  		}
@@ -5543,7 +5771,7 @@
  		break;
  	case Q931_RELEASE:
  		if (missingmand) {
-@@ -3445,6 +4444,7 @@
+@@ -3447,6 +4453,7 @@
  		pri->ev.e = PRI_EVENT_HANGUP;
  		pri->ev.hangup.channel = c->channelno | (c->ds1no << 8) | (c->ds1explicit << 16);
  		pri->ev.hangup.cref = c->cr;
@@ -5551,7 +5779,7 @@
  		pri->ev.hangup.cause = c->cause;
  		pri->ev.hangup.call = c;
  		pri->ev.hangup.aoc_units = c->aoc_units;
-@@ -3473,8 +4473,14 @@
+@@ -3475,8 +4482,14 @@
  		pri->ev.e = PRI_EVENT_HANGUP_REQ;
  		pri->ev.hangup.channel = c->channelno | (c->ds1no << 8) | (c->ds1explicit << 16);
  		pri->ev.hangup.cref = c->cr;
@@ -5566,7 +5794,7 @@
  		pri->ev.hangup.aoc_units = c->aoc_units;
  		if (c->alive)
  			return Q931_RES_HAVEEVENT;
-@@ -3500,14 +4506,14 @@
+@@ -3502,14 +4515,14 @@
  			pri->ev.e = PRI_EVENT_KEYPAD_DIGIT;
  			pri->ev.digit.call = c;
  			pri->ev.digit.channel = c->channelno | (c->ds1no << 8);
@@ -5584,7 +5812,7 @@
  		pri->ev.ring.complete = c->complete; 	/* this covers IE 33 (Sending Complete) */
  		return Q931_RES_HAVEEVENT;
  	case Q931_STATUS_ENQUIRY:
-@@ -3525,7 +4531,7 @@
+@@ -3527,7 +4540,7 @@
  		c->peercallstate = Q931_CALL_STATE_OVERLAP_RECEIVING;
  		pri->ev.e = PRI_EVENT_SETUP_ACK;
  		pri->ev.setup_ack.channel = c->channelno | (c->ds1no << 8) | (c->ds1explicit << 16);
@@ -5593,7 +5821,7 @@
  		cur = c->apdus;
  		while (cur) {
  			if (!cur->sent && cur->message == Q931_FACILITY) {
-@@ -3541,19 +4547,53 @@
+@@ -3543,19 +4556,53 @@
  		pri->ev.notify.channel = c->channelno;
  		pri->ev.notify.info = c->notify;
  		return Q931_RES_HAVEEVENT;
@@ -5651,7 +5879,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);
-@@ -3563,7 +4603,7 @@
+@@ -3565,7 +4612,7 @@
  		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) 
@@ -5660,53 +5888,3 @@
  		return -1;
  	}
  	return 0;
-diff -urNad libpri-1.2.0-release/README /tmp/dpep.aQ7o1G/libpri-1.2.0-release/README
---- libpri-1.2.0-release/README	2005-02-20 00:04:11.000000000 +0200
-+++ /tmp/dpep.aQ7o1G/libpri-1.2.0-release/README	2005-11-23 04:05:24.987532175 +0200
-@@ -1,6 +1,7 @@
--libpri: An implementation of Primate Rate ISDN
--
-+libpri: An implementation of Primate Rate ISDN (and BRI ISDN)
-+ 
- Written by Mark Spencer <markster at digium.com>
-+Modified for BRI support by Klaus-Peter Junghanns <kpj at junghanns.net>
- 
- What is libpri?
- ===============
-@@ -9,6 +10,7 @@
- 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.
-+The BRI and euroISDN modifications are based on ETS 300 102-1.
- 
- What is the license for libpri?
- ===============================
-@@ -22,9 +24,8 @@
- or the GPL of libpri.
- 
- If you wish to use libpri in an application for which the GPL is not 
--appropriate (e.g. a proprietary embedded system), licenses for libpri 
--under more flexible terms can be readily obtained through Digium, Inc. 
--at reasonable cost.
-+appropriate (e.g. a proprietary embedded system), then you have to use
-+a non-standard compliant version without BRI support.
- 
- 
- How do I report bugs or contribute?
-diff -urNad libpri-1.2.0-release/TODO /tmp/dpep.aQ7o1G/libpri-1.2.0-release/TODO
---- libpri-1.2.0-release/TODO	2001-05-12 19:53:13.000000000 +0300
-+++ /tmp/dpep.aQ7o1G/libpri-1.2.0-release/TODO	2005-11-23 04:05:24.990531760 +0200
-@@ -2,9 +2,7 @@
- -- D-Channel Backup
- -- Test against 4e
- 
--Q.921:
---- Support unnumbered information frames
--
- Q.931:
---- Locking Shift IE
---- Implement the 11 missing Q.931 timers
-+-- Locking Shift IE (you did that already, didnt you??)
-+-- Implement the 10 missing Q.931 timers
-+-- more facilities
-\ ץבוקה ףוסב השדח-הרוש ות רסח




More information about the Pkg-voip-commits mailing list