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

Tzafrir Cohen tzafrir-guest at costa.debian.org
Fri Jun 16 07:50:26 UTC 2006


Author: tzafrir-guest
Date: 2006-06-16 07:50:22 +0000 (Fri, 16 Jun 2006)
New Revision: 1894

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

Modified: libpri/trunk/debian/changelog
===================================================================
--- libpri/trunk/debian/changelog	2006-06-15 18:49:03 UTC (rev 1893)
+++ libpri/trunk/debian/changelog	2006-06-16 07:50:22 UTC (rev 1894)
@@ -1,8 +1,9 @@
 libpri (1.2.3-2) UNRELEASED; urgency=low
 
   * NOT RELEASED YET
+  * bristuff 0.3.0-PRE-1q 
 
- -- Mark Purcell <msp at debian.org>  Wed, 14 Jun 2006 12:18:38 +1000
+ -- Tzafrir Cohen <tzafrir.cohen at xorcom.com>  Fri, 16 Jun 2006 10:23:10 +0300
 
 libpri (1.2.3-1) unstable; urgency=low
 

Modified: libpri/trunk/debian/patches/bristuff.dpatch
===================================================================
--- libpri/trunk/debian/patches/bristuff.dpatch	2006-06-15 18:49:03 UTC (rev 1893)
+++ libpri/trunk/debian/patches/bristuff.dpatch	2006-06-16 07:50:22 UTC (rev 1894)
@@ -9,13 +9,16 @@
 ## DP: copyright statements.
 
 @DPATCH@
-diff -urNad libpri-1.2.3~/README libpri-1.2.3/README
---- libpri-1.2.3~/README	2006-02-16 04:59:38.000000000 +1100
-+++ libpri-1.2.3/README	2006-06-14 12:09:23.000000000 +1000
+diff -urN libpri-1.2.3.orig/README libpri-1.2.3/README
+--- libpri-1.2.3.orig/README	2006-02-15 18:59:38.000000000 +0100
++++ libpri-1.2.3/README	2006-01-18 12:28:07.000000000 +0100
 @@ -1,6 +1,7 @@
- libpri: An implementation of Primary Rate ISDN
- 
- Written by Mark Spencer <markster at digium.com>
+-libpri: An implementation of Primary 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?
@@ -40,9 +43,9 @@
  
  
  How do I report bugs or contribute?
-diff -urNad libpri-1.2.3~/TODO libpri-1.2.3/TODO
---- libpri-1.2.3~/TODO	2005-11-30 05:39:18.000000000 +1100
-+++ libpri-1.2.3/TODO	2006-06-14 12:09:23.000000000 +1000
+diff -urN libpri-1.2.3.orig/TODO libpri-1.2.3/TODO
+--- libpri-1.2.3.orig/TODO	2005-11-29 19:39:18.000000000 +0100
++++ libpri-1.2.3/TODO	2006-01-18 12:28:07.000000000 +0100
 @@ -2,9 +2,7 @@
  -- D-Channel Backup
  -- Test against 4e
@@ -56,9 +59,9 @@
 +-- Locking Shift IE (you did that already, didnt you??)
 +-- Implement the 10 missing Q.931 timers
 +-- more facilities
-diff -urNad libpri-1.2.3~/libpri.h libpri-1.2.3/libpri.h
---- libpri-1.2.3~/libpri.h	2006-04-28 02:08:39.000000000 +1000
-+++ libpri-1.2.3/libpri.h	2006-06-14 12:09:23.000000000 +1000
+diff -urN libpri-1.2.3.orig/libpri.h libpri-1.2.3/libpri.h
+--- libpri-1.2.3.orig/libpri.h	2006-04-27 18:08:39.000000000 +0200
++++ libpri-1.2.3/libpri.h	2006-06-06 14:28:32.000000000 +0200
 @@ -5,6 +5,8 @@
   *
   * Copyright (C) 2001, Linux Support Services, Inc.
@@ -384,37 +387,9 @@
  
  /* Set overlap mode */
  #define PRI_SET_OVERLAPDIAL
-diff -urNad libpri-1.2.3~/pri.c libpri-1.2.3/pri.c
---- libpri-1.2.3~/pri.c	2005-11-30 05:39:18.000000000 +1100
-+++ libpri-1.2.3/pri.c	2006-06-14 12:09:23.000000000 +1000
-@@ -3,22 +3,12 @@
-  *
-  * Written by Mark Spencer <markster at digium.com>
-  *
-- * Copyright (C) 2001-2005, Digium
-- * All Rights Reserved.
-+ * This program is confidential ( <- I dont think so! )
-  *
-- * This program is free software; you can redistribute it and/or modify
-- * it under the terms of the GNU General Public License as published by
-- * the Free Software Foundation; either version 2 of the License, or
-- * (at your option) any later version.
-- * 
-- * This program is distributed in the hope that it will be useful,
-- * but WITHOUT ANY WARRANTY; without even the implied warranty of
-- * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
-- * GNU General Public License for more details.
-- * 
-- * You should have received a copy of the GNU General Public License
-- * along with this program; if not, write to the Free Software
-- * Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA. 
-+ * Copyright (C) 2001, Linux Support Services, Inc.
-+ * All Rights Reserved.
-+ * Copyright (C) 2003-2006 Junghanns.NET GmbH
-+ * Klaus-Peter Junghanns <kpj at junghanns.net>
-  *
-  */
- 
+diff -urN libpri-1.2.3.orig/pri.c libpri-1.2.3/pri.c
+--- libpri-1.2.3.orig/pri.c	2005-11-29 19:39:18.000000000 +0100
++++ libpri-1.2.3/pri.c	2006-06-09 10:17:29.000000000 +0200
 @@ -48,6 +38,14 @@
  		return "Network";
  	case PRI_CPE:
@@ -756,20 +731,22 @@
  	return 0;
  }
  
-@@ -851,3 +979,10 @@
+@@ -851,3 +979,12 @@
  	sr->redirectingreason = reason;
  	return 0;
  }
 +
 +void pri_shutdown(struct pri *pri)
 +{
++#ifndef LAYER2ALWAYSUP
 +    if ((pri->localtype == BRI_NETWORK) || (pri->localtype == BRI_CPE) || (pri->localtype == BRI_CPE_PTMP)) {
 +	q921_reset(pri, pri->tei, 1);
 +    }
++#endif
 +}
-diff -urNad libpri-1.2.3~/pri_facility.c libpri-1.2.3/pri_facility.c
---- libpri-1.2.3~/pri_facility.c	2006-02-14 10:06:02.000000000 +1100
-+++ libpri-1.2.3/pri_facility.c	2006-06-14 12:09:23.000000000 +1000
+diff -urN libpri-1.2.3.orig/pri_facility.c libpri-1.2.3/pri_facility.c
+--- libpri-1.2.3.orig/pri_facility.c	2006-02-14 00:06:02.000000000 +0100
++++ libpri-1.2.3/pri_facility.c	2006-06-06 14:26:01.000000000 +0200
 @@ -1,26 +1,17 @@
 -/*
 - * libpri: An implementation of Primary Rate ISDN
@@ -1236,9 +1213,9 @@
  		default:
  			if (pri->debug & PRI_DEBUG_APDU) {
  				pri_message(pri, "!! Unable to handle ROSE operation %d", operation_tag);
-diff -urNad libpri-1.2.3~/pri_facility.h libpri-1.2.3/pri_facility.h
---- libpri-1.2.3~/pri_facility.h	2005-11-30 05:39:18.000000000 +1100
-+++ libpri-1.2.3/pri_facility.h	2006-06-14 12:09:23.000000000 +1000
+diff -urN libpri-1.2.3.orig/pri_facility.h libpri-1.2.3/pri_facility.h
+--- libpri-1.2.3.orig/pri_facility.h	2005-11-29 19:39:18.000000000 +0100
++++ libpri-1.2.3/pri_facility.h	2006-04-15 21:35:05.000000000 +0200
 @@ -34,7 +34,7 @@
  /* Operation ID values */
  /* Q.952 ROSE operations (Diverting) */
@@ -1287,9 +1264,9 @@
 +extern int aoc_aoce_charging_unit_encode(struct pri *pri, q931_call *c, long chargedunits, int send_facility_message);
 +
  #endif /* _PRI_FACILITY_H */
-diff -urNad libpri-1.2.3~/pri_internal.h libpri-1.2.3/pri_internal.h
---- libpri-1.2.3~/pri_internal.h	2005-11-30 05:39:18.000000000 +1100
-+++ libpri-1.2.3/pri_internal.h	2006-06-14 12:09:23.000000000 +1000
+diff -urN libpri-1.2.3.orig/pri_internal.h libpri-1.2.3/pri_internal.h
+--- libpri-1.2.3.orig/pri_internal.h	2005-11-29 19:39:18.000000000 +0100
++++ libpri-1.2.3/pri_internal.h	2006-04-15 21:57:19.000000000 +0200
 @@ -5,6 +5,8 @@
   *
   * Copyright (C) 2001, Linux Support Services, Inc.
@@ -1517,9 +1494,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.3~/pri_q921.h libpri-1.2.3/pri_q921.h
---- libpri-1.2.3~/pri_q921.h	2005-11-30 05:39:18.000000000 +1100
-+++ libpri-1.2.3/pri_q921.h	2006-06-14 12:09:23.000000000 +1000
+diff -urN libpri-1.2.3.orig/pri_q921.h libpri-1.2.3/pri_q921.h
+--- libpri-1.2.3.orig/pri_q921.h	2005-11-29 19:39:18.000000000 +0100
++++ libpri-1.2.3/pri_q921.h	2006-04-15 21:57:24.000000000 +0200
 @@ -5,6 +5,8 @@
   *
   * Copyright (C) 2001, Linux Support Services, Inc.
@@ -1561,9 +1538,9 @@
 +extern int q921_transmit_iframe(struct pri *pri, void *buf, int len, int cr, int tei);
  
  #endif
-diff -urNad libpri-1.2.3~/pri_q931.h libpri-1.2.3/pri_q931.h
---- libpri-1.2.3~/pri_q931.h	2005-11-30 05:39:18.000000000 +1100
-+++ libpri-1.2.3/pri_q931.h	2006-06-14 12:09:23.000000000 +1000
+diff -urN libpri-1.2.3.orig/pri_q931.h libpri-1.2.3/pri_q931.h
+--- libpri-1.2.3.orig/pri_q931.h	2005-11-29 19:39:18.000000000 +0100
++++ libpri-1.2.3/pri_q931.h	2006-04-15 21:57:29.000000000 +0200
 @@ -5,6 +5,8 @@
   *
   * Copyright (C) 2001, Linux Support Services, Inc.
@@ -1648,9 +1625,9 @@
 +//extern int q931_facility(struct pri *pri, q931_call *c, int operation, char *arguments);
 +
  #endif
-diff -urNad libpri-1.2.3~/pri_timers.h libpri-1.2.3/pri_timers.h
---- libpri-1.2.3~/pri_timers.h	2005-11-30 05:39:18.000000000 +1100
-+++ libpri-1.2.3/pri_timers.h	2006-06-14 12:09:23.000000000 +1000
+diff -urN libpri-1.2.3.orig/pri_timers.h libpri-1.2.3/pri_timers.h
+--- libpri-1.2.3.orig/pri_timers.h	2005-11-29 19:39:18.000000000 +0100
++++ libpri-1.2.3/pri_timers.h	2006-01-18 12:28:07.000000000 +0100
 @@ -27,17 +27,17 @@
  
  /* -1 means we dont currently support the timer/counter */
@@ -1674,9 +1651,9 @@
  				-1,	/* T304 */ \
  				30000,	/* T305 */ \
  				-1,	/* T306 */ \
-diff -urNad libpri-1.2.3~/pridump.c libpri-1.2.3/pridump.c
---- libpri-1.2.3~/pridump.c	2005-11-30 05:39:18.000000000 +1100
-+++ libpri-1.2.3/pridump.c	2006-06-14 12:09:23.000000000 +1000
+diff -urN libpri-1.2.3.orig/pridump.c libpri-1.2.3/pridump.c
+--- libpri-1.2.3.orig/pridump.c	2005-11-29 19:39:18.000000000 +0100
++++ libpri-1.2.3/pridump.c	2006-01-18 12:28:07.000000000 +0100
 @@ -1,9 +1,9 @@
  /*
   * libpri: An implementation of Primary Rate ISDN
@@ -1689,9 +1666,9 @@
   * All Rights Reserved.
   *
   * This program is free software; you can redistribute it and/or modify
-diff -urNad libpri-1.2.3~/prisched.c libpri-1.2.3/prisched.c
---- libpri-1.2.3~/prisched.c	2005-11-30 05:39:18.000000000 +1100
-+++ libpri-1.2.3/prisched.c	2006-06-14 12:09:23.000000000 +1000
+diff -urN libpri-1.2.3.orig/prisched.c libpri-1.2.3/prisched.c
+--- libpri-1.2.3.orig/prisched.c	2005-11-29 19:39:18.000000000 +0100
++++ libpri-1.2.3/prisched.c	2006-04-15 21:57:42.000000000 +0200
 @@ -1,10 +1,12 @@
  /*
   * libpri: An implementation of Primary Rate ISDN
@@ -1828,9 +1805,9 @@
 +	pri->pri_sched[id].callback2 = NULL;
  }
 +
-diff -urNad libpri-1.2.3~/pritest.c libpri-1.2.3/pritest.c
---- libpri-1.2.3~/pritest.c	2005-11-30 05:39:18.000000000 +1100
-+++ libpri-1.2.3/pritest.c	2006-06-14 12:09:23.000000000 +1000
+diff -urN libpri-1.2.3.orig/pritest.c libpri-1.2.3/pritest.c
+--- libpri-1.2.3.orig/pritest.c	2005-11-29 19:39:18.000000000 +0100
++++ libpri-1.2.3/pritest.c	2006-01-18 12:28:07.000000000 +0100
 @@ -1,9 +1,9 @@
  /*
   * libpri: An implementation of Primary Rate ISDN
@@ -1889,9 +1866,9 @@
  	default:
  		fprintf(stderr, "--!! Unknown PRI event %d\n", e->e);
  	}
-diff -urNad libpri-1.2.3~/q921.c libpri-1.2.3/q921.c
---- libpri-1.2.3~/q921.c	2005-12-07 08:35:50.000000000 +1100
-+++ libpri-1.2.3/q921.c	2006-06-14 12:09:23.000000000 +1000
+diff -urN libpri-1.2.3.orig/q921.c libpri-1.2.3/q921.c
+--- libpri-1.2.3.orig/q921.c	2005-12-06 22:35:50.000000000 +0100
++++ libpri-1.2.3/q921.c	2006-06-15 14:55:46.000000000 +0200
 @@ -1,10 +1,12 @@
  /*
   * libpri: An implementation of Primary Rate ISDN
@@ -2453,16 +2430,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]) {
@@ -2476,9 +2446,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; }
@@ -3370,14 +3347,14 @@
 +		    q921_rr(pri, h->s.p_f, 0, h->h.tei);
 +//	    	}
 +	    }
- 	 }
--         pri->busy = 1;
--         break;   
++	 }
 +         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;
+-         break;   
 +	 pri->t200_timer[teio] = pri_schedule_event2(pri, pri->timers[PRI_TIMER_T200], t200_expire, pri, h->h.tei);
 +         break;
        case 2:
@@ -3500,7 +3477,7 @@
  					return ev;
  						
  				} else {
-@@ -830,21 +1602,144 @@
+@@ -830,21 +1602,148 @@
  						pri_message(pri, "-- Ignoring unsolicited DM with p/f set to 0\n");
  #if 0
  					/* Requesting that we start */
@@ -3610,16 +3587,16 @@
 + 					} 
 + 					break;
 + 					case Q931_PROTOCOL_DISCRIMINATOR:
-+ 					    if (pri->localtype == BRI_CPE_PTMP) {
-+ 					    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]) 
-+ 						q921_rr(pri, 0, 0, pri->tei);
-+ 					    if (res == -1) {
-+ 						return NULL;
-+ 					    }
-+ 					    if (res & Q931_RES_HAVEEVENT)
-+ 						return &pri->ev;
++ 					    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]) 
++ 						    q921_rr(pri, 0, 0, pri->tei);
++ 						if (res == -1) {
++ 						    return NULL;
++ 						}
++ 						if (res & Q931_RES_HAVEEVENT)
++ 						    return &pri->ev;
 +					    }
 + 					break;
 + 				    }
@@ -3641,17 +3618,21 @@
 -			q921_start(pri, 0);
 +			q921_send_ua(pri, h->u.p_f, h->h.tei);
 +			ev = q921_dchannel_down(pri, h->h.tei);
++#ifndef LAYER2ALWAYSUP
 +			if ((pri->localtype == BRI_CPE_PTMP) || (pri->localtype == BRI_CPE) || (pri->localtype == BRI_NETWORK)) {
 +    			    /* release layer 2 */
 +			    return NULL;
 + 			}
 + 			if ((pri->localtype == PRI_NETWORK) || (pri->localtype == PRI_CPE)){
++#endif
 +     			    q921_start(pri, 0, 0);
++#ifndef LAYER2ALWAYSUP
 + 			}
++#endif
  			return ev;
  		case 3:
  			if (h->u.m2 == 3) {
-@@ -866,17 +1761,28 @@
+@@ -866,17 +1765,28 @@
  					}
  				}
  				/* Send Unnumbered Acknowledgement */
@@ -3686,7 +3667,7 @@
  			} else 
  				pri_error(pri, "!! Weird frame received (m3=3, m2 = %d)\n", h->u.m2);
  			break;
-@@ -901,19 +1807,42 @@
+@@ -901,19 +1811,42 @@
  	/* Discard FCS */
  	len -= 2;
  	
@@ -3736,7 +3717,7 @@
  #ifdef PROCESS_SUBCHANNELS
  		/* If it's not us, try any subchannels we have */
  		if (pri->subchannel)
-@@ -921,10 +1850,16 @@
+@@ -921,10 +1854,16 @@
  		else 
  #endif
  			return NULL;
@@ -3755,7 +3736,7 @@
  	return ev;
  }
  
-@@ -938,14 +1873,58 @@
+@@ -938,14 +1877,58 @@
  	return e;
  }
  
@@ -3822,9 +3803,9 @@
 -	/* Do the SABME XXX Maybe we should implement T_WAIT? XXX */
 -	q921_send_sabme(pri, now);
  }
-diff -urNad libpri-1.2.3~/q931.c libpri-1.2.3/q931.c
---- libpri-1.2.3~/q931.c	2006-04-28 02:08:39.000000000 +1000
-+++ libpri-1.2.3/q931.c	2006-06-14 12:10:18.000000000 +1000
+diff -urN libpri-1.2.3.orig/q931.c libpri-1.2.3/q931.c
+--- libpri-1.2.3.orig/q931.c	2006-04-27 18:08:39.000000000 +0200
++++ libpri-1.2.3/q931.c	2006-06-13 10:53:33.000000000 +0200
 @@ -1,10 +1,12 @@
  /*
   * libpri: An implementation of Primary Rate ISDN
@@ -4001,36 +3982,39 @@
  	pri_error(pri, "!! No channel map, no channel, and no ds1?  What am I supposed to identify?\n");
  	return -1;
  }
-@@ -734,10 +797,11 @@
+@@ -734,9 +797,13 @@
  	return code2str(pres, press, sizeof(press) / sizeof(press[0]));
  }
  
 -static void q931_get_number(unsigned char *num, int maxlen, unsigned char *src, int len)
 +static void q931_get_number(char *num, int maxlen, unsigned char *src, int len)
  {
- 	if ((len < 0) || (len > maxlen - 1)) {
+-	if ((len < 0) || (len > maxlen - 1)) {
++	if (len < 0) {
++	    pri_error(NULL, "q931_get_number received invalid len = %d\n", len);
++	    return;
++	}
++	if (len > maxlen - 1) {
  		num[0] = 0;
-+		pri_error(NULL, "q931_get_number received invalid len = %d\n", len);
  		return;
  	}
- 	memcpy(num, src, len);
-@@ -746,50 +810,78 @@
+@@ -746,50 +813,75 @@
  
  static FUNC_DUMP(dump_called_party_number)
  {
 -	unsigned char cnum[256];
-+	char cnum[256];
-+	if (len >= 3) {
-+	    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",
-+		    prefix, len, ie->data[0] >> 7, ton2str((ie->data[0] >> 4) & 0x07), (ie->data[0] >> 4) & 0x07, npi2str(ie->data[0] & 0x0f), ie->data[0] & 0x0f, cnum);
-+	} else {
-+	    pri_error(pri, "Called Number (len=%2d) too short.\n", len);
-+	}
- 
+-
 -	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",
 -		prefix, len, ie->data[0] >> 7, ton2str((ie->data[0] >> 4) & 0x07), (ie->data[0] >> 4) & 0x07, npi2str(ie->data[0] & 0x0f), ie->data[0] & 0x0f, cnum);
++	char cnum[256];
++ 	if (len >= 3) {
++ 	    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",
++ 		    prefix, len, ie->data[0] >> 7, ton2str((ie->data[0] >> 4) & 0x07), (ie->data[0] >> 4) & 0x07, npi2str(ie->data[0] & 0x0f), ie->data[0] & 0x0f, cnum);
++ 	} else {
++ 	    pri_error(pri, "Called Number (len=%2d) too short.\n", len);
++ 	}
  }
  
  static FUNC_DUMP(dump_called_party_subaddr)
@@ -4038,17 +4022,19 @@
 -	unsigned char cnum[256];
 -	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,
+-		subaddrtype2str((ie->data[0] & 0x70) >> 4), (ie->data[0] & 0x70) >> 4,
+-		(ie->data[0] & 0x08) >> 3, cnum);
 +	char cnum[256];
-+	if (len >= 3) {
-+	    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,
- 		subaddrtype2str((ie->data[0] & 0x70) >> 4), (ie->data[0] & 0x70) >> 4,
- 		(ie->data[0] & 0x08) >> 3, cnum);
-+	} else {
-+	    pri_error(pri, "Called Party Subaddress (len=%2d) too short.\n", len);
-+	}
-+
++ 	if (len >= 3) {
++ 	    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,
++  		subaddrtype2str((ie->data[0] & 0x70) >> 4), (ie->data[0] & 0x70) >> 4,
++  		(ie->data[0] & 0x08) >> 3, cnum);
++ 	} else {
++ 	    pri_error(pri, "Called Party Subaddress (len=%2d) too short.\n", len);
++ 	}
  }
  
  static FUNC_DUMP(dump_calling_party_number)
@@ -4060,20 +4046,21 @@
 -		q931_get_number(cnum, sizeof(cnum), ie->data + 2, len - 4);
 -	pri_message(pri, "%c Calling Number (len=%2d) [ Ext: %d  TON: %s (%d)  NPI: %s (%d)\n", prefix, len, ie->data[0] >> 7, ton2str((ie->data[0] >> 4) & 0x07), (ie->data[0] >> 4) & 0x07, npi2str(ie->data[0] & 0x0f), ie->data[0] & 0x0f);
 -	if (ie->data[0] & 0x80)
-+	char cnum[256];
-+	if ((ie->data[0] & 0x80) && (len >= 3)) {
-+	    	q931_get_number(cnum, sizeof(cnum), ie->data + 1, len - 3);
-+		pri_message(pri, "%c Calling Number (len=%2d) [ Ext: %d  TON: %s (%d)  NPI: %s (%d)\n", prefix, len, ie->data[0] >> 7, ton2str((ie->data[0] >> 4) & 0x07), (ie->data[0] >> 4) & 0x07, npi2str(ie->data[0] & 0x0f), ie->data[0] & 0x0f);
- 		pri_message(pri, "%c                           Presentation: %s (%d) '%s' ]\n", prefix, pri_pres2str(0), 0, cnum);
+-		pri_message(pri, "%c                           Presentation: %s (%d) '%s' ]\n", prefix, pri_pres2str(0), 0, cnum);
 -	else
-+	} else if (len >= 4) {
-+		q931_get_number(cnum, sizeof(cnum), ie->data + 2, len - 4);
-+		pri_message(pri, "%c Calling Number (len=%2d) [ Ext: %d  TON: %s (%d)  NPI: %s (%d)\n", prefix, len, ie->data[0] >> 7, ton2str((ie->data[0] >> 4) & 0x07), (ie->data[0] >> 4) & 0x07, npi2str(ie->data[0] & 0x0f), ie->data[0] & 0x0f);
- 		pri_message(pri, "%c                           Presentation: %s (%d) '%s' ]\n", prefix, pri_pres2str(ie->data[1] & 0x7f), ie->data[1] & 0x7f, cnum);
-+	} else {
-+	    pri_error(pri, "Calling Party Number (len=%2d) too short.\n", len);
-+	}
-+
+-		pri_message(pri, "%c                           Presentation: %s (%d) '%s' ]\n", prefix, pri_pres2str(ie->data[1] & 0x7f), ie->data[1] & 0x7f, cnum);
++  	char cnum[256];
++ 	if ((ie->data[0] & 0x80) && (len >= 3)) {
++  		q931_get_number(cnum, sizeof(cnum), ie->data + 1, len - 3);
++ 		pri_message(pri, "%c Calling Number (len=%2d) [ Ext: %d  TON: %s (%d)  NPI: %s (%d)\n", prefix, len, ie->data[0] >> 7, ton2str((ie->data[0] >> 4) & 0x07), (ie->data[0] >> 4) & 0x07, npi2str(ie->data[0] & 0x0f), ie->data[0] & 0x0f);
++  		pri_message(pri, "%c                           Presentation: %s (%d) '%s' ]\n", prefix, pri_pres2str(0), 0, cnum);
++ 	} else if (len >= 4) {
++ 		q931_get_number(cnum, sizeof(cnum), ie->data + 2, len - 4);
++ 		pri_message(pri, "%c Calling Number (len=%2d) [ Ext: %d  TON: %s (%d)  NPI: %s (%d)\n", prefix, len, ie->data[0] >> 7, ton2str((ie->data[0] >> 4) & 0x07), (ie->data[0] >> 4) & 0x07, npi2str(ie->data[0] & 0x0f), ie->data[0] & 0x0f);
++  		pri_message(pri, "%c                           Presentation: %s (%d) '%s' ]\n", prefix, pri_pres2str(ie->data[1] & 0x7f), ie->data[1] & 0x7f, cnum);
++ 	} else {
++ 	    pri_error(pri, "Calling Party Number (len=%2d) too short.\n", len);
++ 	}
  }
  
  static FUNC_DUMP(dump_calling_party_subaddr)
@@ -4081,28 +4068,31 @@
 -	unsigned char cnum[256];
 -	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,
+-		subaddrtype2str((ie->data[0] & 0x70) >> 4), (ie->data[0] & 0x70) >> 4,
+-		(ie->data[0] & 0x08) >> 3, cnum);
 +	char cnum[256];
-+	if (len >= 4) {
-+	    q931_get_number(cnum, sizeof(cnum), ie->data + 2, len - 4);
-+	    pri_message(pri, "%c Calling Sub-Address (len=%2d) [ Ext: %d  Type: %s (%d) O: %d '%s' ]\n",
- 		prefix, len, ie->data[0] >> 7,
- 		subaddrtype2str((ie->data[0] & 0x70) >> 4), (ie->data[0] & 0x70) >> 4,
- 		(ie->data[0] & 0x08) >> 3, cnum);
-+	} else {
-+	    pri_error(pri, "Calling Party Subaddress (len=%2d) too short.\n", len);
-+	}
++ 	if (len >= 4) {
++ 	    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,
++  		subaddrtype2str((ie->data[0] & 0x70) >> 4), (ie->data[0] & 0x70) >> 4,
++  		(ie->data[0] & 0x08) >> 3, cnum);
++ 	} else {
++ 	    pri_error(pri, "Calling Party Subaddress (len=%2d) too short.\n", len);
++ 	}
 +}
 +
 +static FUNC_DUMP(dump_colp)
 +{
-+	char cnum[256];
-+	if (len >= 4) {
-+	    q931_get_number(cnum, sizeof(cnum), ie->data + 2, len - 4);
-+	    pri_message(pri, "%c COLP (len=%2d) [ Ext: %d  TON: %s (%d)  NPI: %s (%d)\n", prefix, len, ie->data[0] >> 7, ton2str((ie->data[0] >> 4) & 0x07), (ie->data[0] >> 4) & 0x07, npi2str(ie->data[0] & 0x0f), ie->data[0] & 0x0f);
-+	    pri_message(pri, "%c                           Presentation: %s (%d) '%s' ]\n", prefix, pri_pres2str(ie->data[1] & 0x7f), ie->data[1] & 0x7f, cnum);
-+	} else {
-+	    pri_error(pri, "COLP (len=%2d) too short.\n", len);
-+	}
++ 	char cnum[256];
++ 	if (len >= 4) {
++ 	    q931_get_number(cnum, sizeof(cnum), ie->data + 2, len - 4);
++ 	    pri_message(pri, "%c COLP (len=%2d) [ Ext: %d  TON: %s (%d)  NPI: %s (%d)\n", prefix, len, ie->data[0] >> 7, ton2str((ie->data[0] >> 4) & 0x07), (ie->data[0] >> 4) & 0x07, npi2str(ie->data[0] & 0x0f), ie->data[0] & 0x0f);
++ 	    pri_message(pri, "%c                           Presentation: %s (%d) '%s' ]\n", prefix, pri_pres2str(ie->data[1] & 0x7f), ie->data[1] & 0x7f, cnum);
++ 	} else {
++ 	    pri_error(pri, "COLP (len=%2d) too short.\n", len);
++ 	}
  }
  
  static FUNC_DUMP(dump_redirecting_number)
@@ -4166,35 +4156,37 @@
  		ie->data[0] = call->redirectingplan;
  		ie->data[1] = call->redirectingpres;
  		ie->data[2] = (call->redirectingreason & 0x0f) | 0x80;
-@@ -878,67 +978,91 @@
+@@ -878,67 +978,90 @@
  
  static FUNC_DUMP(dump_redirecting_subaddr)
  {
 -	unsigned char cnum[256];
 -	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,
+-		subaddrtype2str((ie->data[0] & 0x70) >> 4), (ie->data[0] & 0x70) >> 4,
+-		(ie->data[0] & 0x08) >> 3, cnum);
 +	char cnum[256];
-+	if (len >= 4) {
-+	    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,
- 		subaddrtype2str((ie->data[0] & 0x70) >> 4), (ie->data[0] & 0x70) >> 4,
- 		(ie->data[0] & 0x08) >> 3, cnum);
-+	} else {
-+	    pri_error(pri, "Redirecting Subaddress (len=%2d) too short.\n", len);
-+	}
-+
++ 	if (len >= 4) {
++ 	    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,
++  		subaddrtype2str((ie->data[0] & 0x70) >> 4), (ie->data[0] & 0x70) >> 4,
++  		(ie->data[0] & 0x08) >> 3, cnum);
++ 	} else {
++ 	    pri_error(pri, "Redirecting Subaddress (len=%2d) too short.\n", len);
++ 	}
  }
  
  static FUNC_RECV(receive_calling_party_subaddr)
  {
  	/* copy digits to call->callingsubaddr */
 - 	q931_get_number((unsigned char *) call->callingsubaddr, sizeof(call->callingsubaddr), ie->data + 1, len - 3);
-+	if (len >= 4) {
-+	    q931_get_number(call->callingsubaddr, sizeof(call->callingsubaddr), ie->data + 2, len - 4);
-+	} else {
++ 	if (len >= 4) {
++  	    q931_get_number(call->callingsubaddr, sizeof(call->callingsubaddr), ie->data + 1, len - 3);
++ 	} else {
 +	    pri_error(call->pri, "Calling Party Subaddress (len=%2d) too short.\n", len);
-+	}
++ 	}
  	return 0;
  }
  
@@ -4203,17 +4195,17 @@
 -	/* copy digits to call->callednum */
 - 	q931_get_number((unsigned char *) call->callednum, sizeof(call->callednum), ie->data + 1, len - 3);
 -	call->calledplan = ie->data[0] & 0x7f;
-+	/* copy digits to call->callednum or call->digits */
-+	if (len >= 3) {
-+	    if (msgtype == Q931_INFORMATION) {
-+		q931_get_number(call->digits, sizeof(call->digits), ie->data + 1, len - 3);
-+	    } else {
-+		q931_get_number(call->callednum, sizeof(call->callednum), ie->data + 1, len - 3);
-+	    }
-+	    call->calledplan = ie->data[0] & 0x7f;
-+	} else {
-+	    pri_error(call->pri, "Called Party Number (len=%2d) too short.\n", len);
-+	}
++ 	/* copy digits to call->callednum or call->digits */
++ 	if (len >= 3) {
++ 	    if (msgtype == Q931_INFORMATION) {
++  		q931_get_number(call->digits, sizeof(call->digits), ie->data + 1, len - 3);
++ 	    } else {
++  		q931_get_number(call->callednum, sizeof(call->callednum), ie->data + 1, len - 3);
++ 	    }
++ 	    call->calledplan = ie->data[0] & 0x7f;
++ 	} else {
++ 	    pri_error(call->pri, "Called Party Number (len=%2d) too short.\n", len);
++ 	}
  	return 0;
  }
  
@@ -4221,7 +4213,7 @@
  {
  	ie->data[0] = 0x80 | call->calledplan;
 -	if (*call->callednum)
-+	if (strlen(call->callednum))
++	if (strlen(call->callednum)) 
  		memcpy(ie->data + 1, call->callednum, strlen(call->callednum));
  	return strlen(call->callednum) + 3;
  }
@@ -4235,16 +4227,12 @@
 -		data = ie->data + 1;
 -		length = len - 3;
 -		call->callerpres = 0; /* PI presentation allowed SI user-provided, not screened */        
-+/// callerani!!
-+	if (strlen(call->callernum)) {
-+	    call->callerplanuser = ie->data[0] & 0x7f;
- 	} else {
+-	} else {
 -		data = ie->data + 2;
 -		length = len - 4;
 -		call->callerpres = ie->data[1] & 0x7f;
-+	    call->callerplan = ie->data[0] & 0x7f;
- 	}
- 
+-	}
+-
 -	if (call->callerpres == PRES_ALLOWED_NETWORK_NUMBER ||
 -		call->callerpres == PRES_PROHIB_NETWORK_NUMBER) {
 -		q931_get_number((u_int8_t *)call->callerani, sizeof(call->callerani), data, length);
@@ -4255,41 +4243,49 @@
 -			call->callerplan = call->callerplanani;
 -		}
 -		
-+	  if (ie->data[0] & 0x80) {
-+	  if (len >= 3) {
-+	     if (strlen(call->callernum)) {
-+ 		// got A NUM already (this is not 100% correct, but the network should do it this way to protect bad implementations
-+		 q931_get_number(call->callerani, sizeof(call->callerani), ie->data + 1, len - 3);
-+		call->callerpresuser = 0; /* PI presentation allowed
-+				   SI user-provided, not screened */
-+	    } else {
-+ 		q931_get_number(call->callernum, sizeof(call->callernum), ie->data + 1, len - 3);
-+		call->callerpres = 0; /* PI presentation allowed
-+				   SI user-provided, not screened */
-+	    }
- 	} else {
+-	} else {
 -		q931_get_number((u_int8_t *)call->callernum, sizeof(call->callernum), data, length);
 -		call->callerplan = ie->data[0] & 0x7f;
-+		pri_error(call->pri, "Calling Party Number (len=%2d) too short.\n", len);
- 	}
--
-+	} else {
-+	  if (len >= 4) {
-+	     if (strlen(call->callernum)) {
-+		q931_get_number(call->callerani, sizeof(call->callerani), ie->data + 2, len - 4);
-+		 call->callerpresuser = ie->data[1] & 0x7f;
-+	     } else {
-+		 q931_get_number(call->callernum, sizeof(call->callernum), ie->data + 2, len - 4);
-+		 call->callerpres = ie->data[1] & 0x7f;
-+	    }
-+   	  } else {
-+		pri_error(call->pri, "Calling Party Number (len=%2d) too short.\n", len);
-+	  }
-+	  }
+-	}
++/// callerani!!
++ 	if (strlen(call->callernum)) {
++     	    call->callerplanuser = ie->data[0] & 0x7f;
++ 	} else {
++     	    call->callerplan = ie->data[0] & 0x7f;
++ 	}
+ 
++        if (ie->data[0] & 0x80) {
++ 	  if (len >= 3) {
++ 	     if (strlen(call->callernum)) {
++ 		// got A NUM already (this is not 100% correct, but the network should do it this way to protect bad implementations
++ 		 q931_get_number(call->callerani, sizeof(call->callerani), ie->data + 1, len - 3);
++ 	        call->callerpresuser = 0; /* PI presentation allowed
++ 				   SI user-provided, not screened */        
++ 	    } else {
++ 		 q931_get_number(call->callernum, sizeof(call->callernum), ie->data + 1, len - 3);
++ 		 call->callerpres = 0; /* PI presentation allowed
++  				   SI user-provided, not screened */        
++ 	    }
++ 	  } else {
++ 		pri_error(call->pri, "Calling Party Number (len=%2d) too short.\n", len);
++ 	  }
++        } else {
++ 	  if (len >= 4) {
++ 	     if (strlen(call->callernum)) {
++ 	        q931_get_number(call->callerani, sizeof(call->callerani), ie->data + 2, len - 4);
++ 		 call->callerpresuser = ie->data[1] & 0x7f;
++ 	      } else {
++ 		 q931_get_number(call->callernum, sizeof(call->callernum), ie->data + 2, len - 4);
++ 	         call->callerpres = ie->data[1] & 0x7f;
++ 	    }
++ 	  } else {
++ 		pri_error(call->pri, "Calling Party Number (len=%2d) too short.\n", len);
++ 	  }
++        }
  	return 0;
  }
  
-@@ -946,7 +1070,7 @@
+@@ -946,7 +1069,7 @@
  {
  	ie->data[0] = call->callerplan;
  	ie->data[1] = 0x80 | call->callerpres;
@@ -4298,7 +4294,7 @@
  		memcpy(ie->data + 2, call->callernum, strlen(call->callernum));
  	return strlen(call->callernum) + 4;
  }
-@@ -964,11 +1088,89 @@
+@@ -964,11 +1087,89 @@
  static FUNC_RECV(receive_user_user)
  {        
          call->useruserprotocoldisc = ie->data[0] & 0xff;
@@ -4390,7 +4386,7 @@
  static FUNC_SEND(transmit_user_user)
  {        
  	int datalen = strlen(call->useruserinfo);
-@@ -1050,22 +1252,41 @@
+@@ -1050,22 +1251,41 @@
  		data++;
  		len--;
  	}
@@ -4437,7 +4433,7 @@
  	}
  	return 0;
  }
-@@ -1112,6 +1333,111 @@
+@@ -1112,6 +1332,111 @@
  	return 0;
  }
  
@@ -4549,7 +4545,7 @@
  static FUNC_SEND(transmit_facility)
  {
  	struct apdu_event *tmp;
-@@ -1138,6 +1464,182 @@
+@@ -1138,6 +1463,182 @@
  	return i + 2;
  }
  
@@ -4732,7 +4728,7 @@
  static FUNC_RECV(receive_facility)
  {
  	int i = 0;
-@@ -1346,6 +1848,7 @@
+@@ -1346,6 +1847,7 @@
  	pri_message(pri, " ]\n");
  }
  
@@ -4740,7 +4736,7 @@
  static FUNC_DUMP(dump_time_date)
  {
  	pri_message(pri, "%c Time Date (len=%2d) [ ", prefix, len);
-@@ -1366,7 +1869,7 @@
+@@ -1366,7 +1868,7 @@
  
  static FUNC_DUMP(dump_keypad_facility)
  {
@@ -4749,7 +4745,7 @@
  	
  	if (ie->len == 0 || ie->len > sizeof(tmp))
  		return;
-@@ -1377,28 +1880,49 @@
+@@ -1377,28 +1879,49 @@
  
  static FUNC_RECV(receive_keypad_facility)
  {
@@ -4804,7 +4800,7 @@
  	if (buf) {
  		x=y=0;
  		if ((x < ie->len) && (ie->data[x] & 0x80)) {
-@@ -1413,7 +1937,7 @@
+@@ -1413,7 +1936,7 @@
  	}
  }
  
@@ -4813,7 +4809,7 @@
  {
  	char tmp[1024] = "";
  	int x=0;
-@@ -1423,7 +1947,7 @@
+@@ -1423,7 +1946,7 @@
  		    ((*c >= 'a') && (*c <= 'z')) ||
  		    ((*c >= '0') && (*c <= '9'))) {
  			if (!lastascii) {
@@ -4822,7 +4818,7 @@
  					tmp[x++] = ',';
  					tmp[x++] = ' ';
  				}
-@@ -1435,7 +1959,7 @@
+@@ -1435,7 +1958,7 @@
  			if (lastascii) {
  				tmp[x++] = '\'';
  			}
@@ -4831,7 +4827,7 @@
  				tmp[x++] = ',';
  				tmp[x++] = ' ';
  			}
-@@ -1448,14 +1972,14 @@
+@@ -1448,14 +1971,14 @@
  	}
  	if (lastascii)
  		tmp[x++] = '\'';
@@ -4849,7 +4845,7 @@
  }
  
  static FUNC_DUMP(dump_network_spec_fac)
-@@ -1465,7 +1989,7 @@
+@@ -1465,7 +1988,7 @@
  		pri_message(pri, code2str(ie->data[1], facilities, sizeof(facilities) / sizeof(facilities[0])));
  	}
  	else
@@ -4858,7 +4854,7 @@
  	pri_message(pri, " ]\n");
  }
  
-@@ -1932,8 +2456,8 @@
+@@ -1932,8 +2455,8 @@
  	{ 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 },
@@ -4869,7 +4865,7 @@
  	{ 1, Q931_PACKET_SIZE, "Packet Size" },
  	{ 1, Q931_IE_FACILITY, "Facility" , dump_facility, receive_facility, transmit_facility },
  	{ 1, Q931_IE_REDIRECTION_NUMBER, "Redirection Number" },
-@@ -1942,11 +2466,11 @@
+@@ -1942,11 +2465,11 @@
  	{ 1, Q931_IE_INFO_REQUEST, "Feature Request" },
  	{ 1, Q931_IE_FEATURE_IND, "Feature Indication" },
  	{ 1, Q931_IE_SEGMENTED_MSG, "Segmented Message" },
@@ -4883,7 +4879,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" },
-@@ -1954,6 +2478,7 @@
+@@ -1954,6 +2477,7 @@
  	{ 1, Q931_IE_ESCAPE_FOR_EXT, "Escape for Extension" },
  	{ 1, Q931_IE_CALL_STATUS, "Call Status" },
  	{ 1, Q931_IE_CHANGE_STATUS, "Change Status" },
@@ -4891,7 +4887,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 },
-@@ -2024,7 +2549,7 @@
+@@ -2024,7 +2548,7 @@
  {
  	if ((ie->ie & 0x80) != 0)
  		return 1;
@@ -4900,7 +4896,7 @@
  		return 2 + ie->len;
  }
  
-@@ -2054,10 +2579,10 @@
+@@ -2054,10 +2578,10 @@
  			break;
  		case 1:
  			cr = h->crv[0];
@@ -4913,7 +4909,7 @@
  			break;
  		default:
  			pri_error(NULL, "Call Reference Length not supported: %d\n", h->crlen);
-@@ -2071,14 +2596,14 @@
+@@ -2071,14 +2595,14 @@
  	int full_ie = Q931_FULL_IE(codeset, ie->ie);
  	int base_ie;
  
@@ -4933,7 +4929,7 @@
  
  	/* Special treatment for shifts */
  	if((full_ie & 0xf0) == Q931_LOCKING_SHIFT)
-@@ -2098,14 +2623,46 @@
+@@ -2098,14 +2622,46 @@
  	pri_error(pri, "!! %c Unknown IE %d (len = %d)\n", prefix, base_ie, ielen(ie));
  }
  
@@ -4983,7 +4979,7 @@
  		prev = cur;
  		cur = cur->next;
  	}
-@@ -2118,6 +2675,7 @@
+@@ -2118,6 +2674,7 @@
  		/* Call reference */
  		cur->cr = cr;
  		cur->pri = pri;
@@ -4991,7 +4987,7 @@
  		/* Append to end of list */
  		if (prev)
  			prev->next = cur;
-@@ -2133,24 +2691,42 @@
+@@ -2133,24 +2690,42 @@
  	do {
  		cur = *pri->callpool;
  		pri->cref++;
@@ -5041,7 +5037,7 @@
  			if (prev)
  				prev->next = cur->next;
  			else
-@@ -2159,6 +2735,8 @@
+@@ -2159,6 +2734,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);
@@ -5050,7 +5046,7 @@
  			pri_call_apdu_queue_cleanup(cur);
  			free(cur);
  			return;
-@@ -2169,16 +2747,16 @@
+@@ -2169,16 +2746,16 @@
  	pri_error(pri, "Can't destroy call %d!\n", cr);
  }
  
@@ -5070,7 +5066,7 @@
  	return;
  }
  
-@@ -2290,6 +2868,10 @@
+@@ -2290,6 +2867,10 @@
  {
  	unsigned int x;
  	int full_ie = Q931_FULL_IE(codeset, ie->ie);
@@ -5081,7 +5077,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++) {
-@@ -2307,21 +2889,36 @@
+@@ -2307,21 +2888,36 @@
  	return -1;
  }
  
@@ -5123,7 +5119,7 @@
  	}
  	if (pri->subchannel) {
  		/* On GR-303, top bit is always 0 */
-@@ -2330,13 +2927,23 @@
+@@ -2330,13 +2926,23 @@
  	mh->f = 0;
  	*hb = h;
  	*mhb = mh;
@@ -5151,7 +5147,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 */
-@@ -2362,7 +2969,11 @@
+@@ -2362,7 +2968,11 @@
  	
  	memset(buf, 0, sizeof(buf));
  	len = sizeof(buf);
@@ -5164,7 +5160,7 @@
  	mh->msg = msgtype;
  	x=0;
  	codeset = 0;
-@@ -2397,11 +3008,34 @@
+@@ -2397,11 +3007,34 @@
  	}
  	/* Invert the logic */
  	len = sizeof(buf) - len;
@@ -5200,7 +5196,7 @@
  static int status_ies[] = { Q931_CAUSE, Q931_CALL_STATE, -1 };
  
  static int q931_status(struct pri *pri, q931_call *c, int cause)
-@@ -2439,17 +3073,45 @@
+@@ -2439,17 +3072,45 @@
  	return send_message(pri, c, Q931_INFORMATION, information_ies);
  }
  
@@ -5248,7 +5244,7 @@
  int q931_facility(struct pri*pri, q931_call *c)
  {
  	return send_message(pri, c, Q931_FACILITY, facility_ies);
-@@ -2463,7 +3125,6 @@
+@@ -2463,7 +3124,6 @@
  		if ((info > 0x2) || (info < 0x00))
  			return 0;
  	}
@@ -5256,7 +5252,7 @@
  	if (info >= 0)
  		c->notify = info & 0x7F;
  	else
-@@ -2506,6 +3167,8 @@
+@@ -2506,6 +3166,8 @@
  
  int q931_call_proceeding(struct pri *pri, q931_call *c, int channel, int info)
  {
@@ -5265,7 +5261,7 @@
  	if (channel) { 
  		c->ds1no = (channel & 0xff00) >> 8;
  		c->ds1explicit = (channel & 0x10000) >> 16;
-@@ -2532,8 +3195,12 @@
+@@ -2532,8 +3194,12 @@
  static int alerting_ies[] = { -1 };
  #endif
  
@@ -5278,13 +5274,12 @@
  	if (!c->proc) 
  		q931_call_proceeding(pri, c, channel, 0);
  	if (info) {
-@@ -2544,14 +3211,130 @@
+@@ -2544,14 +3210,130 @@
  		c->progressmask = 0;
  	c->ourcallstate = Q931_CALL_STATE_CALL_RECEIVED;
  	c->peercallstate = Q931_CALL_STATE_CALL_DELIVERED;
 +	c->alert = 1;
- 	c->alive = 1;
--	return send_message(pri, c, Q931_ALERTING, alerting_ies);
++	c->alive = 1;
 +	if ((pri->localtype == PRI_NETWORK) || (pri->localtype == PRI_CPE)) {
 +	    return send_message(pri, c, Q931_ALERTING, alerting_ies);
 +	} else {
@@ -5295,9 +5290,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)
@@ -5391,7 +5385,8 @@
 +		c->channelno = channel;
 +	c->chanflags &= ~FLAG_PREFERRED;
 +	c->chanflags |= FLAG_EXCLUSIVE;
-+	c->alive = 1;
+ 	c->alive = 1;
+-	return send_message(pri, c, Q931_ALERTING, alerting_ies);
 +	c->ourcallstate = Q931_CALL_STATE_ACTIVE;
 +	c->peercallstate = Q931_CALL_STATE_ACTIVE;
 +	strncpy(tempcallername,c->callername,sizeof(tempcallername));
@@ -5399,9 +5394,10 @@
 +	res = send_message(pri, c, Q931_RESUME_ACKNOWLEDGE, resume_acknowledge_ies);
 +	strncpy(c->callername,tempcallername,sizeof(c->callername));
 +	return res;
-+}
+ }
+ 
+-static int connect_ies[] = {  Q931_CHANNEL_IDENT, Q931_PROGRESS_INDICATOR, -1 };
 +
-+
 +static int connect_ies[] = {  Q931_CHANNEL_IDENT, Q931_PROGRESS_INDICATOR, Q931_DISPLAY, -1 };
 +static int connect_NET_ies[] = {  Q931_CHANNEL_IDENT, Q931_PROGRESS_INDICATOR, Q931_IE_TIME_DATE, -1 };
   
@@ -5411,7 +5407,11 @@
  	if (channel) { 
  		c->ds1no = (channel & 0xff00) >> 8;
  		c->ds1explicit = (channel & 0x10000) >> 16;
-@@ -2569,9 +3352,36 @@
+@@ -2566,12 +3348,40 @@
+ 		c->progressmask = PRI_PROG_CALLED_NOT_ISDN;
+ 	} else
+ 		c->progressmask = 0;
++c->progressmask = PRI_PROG_INBAND_AVAILABLE;
  	c->ourcallstate = Q931_CALL_STATE_OVERLAP_RECEIVING;
  	c->peercallstate = Q931_CALL_STATE_OVERLAP_SENDING;
  	c->alive = 1;
@@ -6304,7 +6304,15 @@
  		libpri_copy_string(pri->ev.ring.callingsubaddr, c->callingsubaddr, sizeof(pri->ev.ring.callingsubaddr));
  		pri->ev.ring.complete = c->complete; 	/* this covers IE 33 (Sending Complete) */
  		return Q931_RES_HAVEEVENT;
-@@ -3547,19 +4660,53 @@
+@@ -3531,7 +4644,6 @@
+ 		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;
+-
+ 		cur = c->apdus;
+ 		while (cur) {
+ 			if (!cur->sent && cur->message == Q931_FACILITY) {
+@@ -3547,19 +4659,53 @@
  		pri->ev.notify.channel = c->channelno;
  		pri->ev.notify.info = c->notify;
  		return Q931_RES_HAVEEVENT;
@@ -6362,7 +6370,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);
-@@ -3569,7 +4716,7 @@
+@@ -3569,7 +4715,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) 




More information about the Pkg-voip-commits mailing list