libpri patch [Was: Asterisk 1.2.9 and friends]

Geoff Oakham goakham at itdepartment.com
Sat Jun 10 21:43:49 UTC 2006


Kilian, thanks for pointing out the subversion repository--that was  
exactly what I needed.  Below are the changes I need to make to  
libpri in order to get it to compile.  Feel free to apply it to trunk  
and/or give me feedback.

Cheers,

Geoff

Ps. the patch was generated with 'svn diff > /tmp/libpri.patch'.  I  
can send another version if this one gets messed up or whatnot.  GUI  
mail clients.. what can you do?

Index: libpri/trunk/debian/patches/bristuff.dpatch
===================================================================
--- libpri/trunk/debian/patches/bristuff.dpatch	(revision 1825)
+++ libpri/trunk/debian/patches/bristuff.dpatch	(working copy)
@@ -12,8 +12,8 @@
--- libpri-1.2.2.orig/README	2005-11-29 19:39:18.000000000 +0100
+++ libpri-1.2.2/README	2006-01-18 12:28:07.000000000 +0100
@@ -1,6 +1,7 @@
--libpri: An implementation of Primate Rate ISDN
-+libpri: An implementation of Primate Rate ISDN (and BRI ISDN)
+-libpri: An implementation of Primary Rate ISDN
++libpri: An implementation of Primary 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>
@@ -187,14 +187,6 @@
   	q931_call *call;			/* Opaque call pointer */
   	long aoc_units;				/* Advise of Charge number of charged units */
   	char useruserinfo[260];		/* User->User info */
-@@ -359,6 +381,7 @@
- typedef struct pri_event_setup_ack {
- 	int e;
- 	int channel;
-+	q931_call *call;			/* Opaque call pointer */
- } pri_event_setup_ack;
-
- typedef struct pri_event_notify {
@@ -374,20 +397,80 @@
   	char digits[64];
   } pri_event_keypad_digit;
@@ -4011,18 +4003,14 @@
   	pri_error(pri, "!! No channel map, no channel, and no ds1?  What  
am I supposed to identify?\n");
   	return -1;
   }
-@@ -734,8 +797,12 @@
+@@ -734,8 +797,8 @@
   	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) {
-+	    pri_error(NULL, "q931_get_number received invalid len = %d\n",  
len);
-+	    return;
-+	}
- 	if (len > maxlen - 1) {
+ 	if ((len < 0) || (len > maxlen - 1)) {
   		num[0] = 0;
   		return;
@@ -746,50 +813,75 @@
@@ -4093,14 +4081,14 @@
   static FUNC_DUMP(dump_calling_party_subaddr)
   {
-	unsigned char cnum[256];
--	q931_get_number(cnum, sizeof(cnum), ie->data + 2, 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);
+	char cnum[256];
+ 	if (len >= 4) {
-+ 	    q931_get_number(cnum, sizeof(cnum), ie->data + 2, 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,
@@ -4208,9 +4196,9 @@
   static FUNC_RECV(receive_calling_party_subaddr)
   {
   	/* copy digits to call->callingsubaddr */
-- 	q931_get_number((unsigned char *) call->callingsubaddr, sizeof 
(call->callingsubaddr), ie->data + 2, len - 4);
+- 	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);
++  	    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);
+ 	}
@@ -6327,15 +6315,6 @@
   		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;
-@@ -3530,7 +4642,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);
--
-+		pri->ev.setup_ack.call = c;
- 		cur = c->apdus;
- 		while (cur) {
- 			if (!cur->sent && cur->message == Q931_FACILITY) {
@@ -3546,19 +4658,53 @@
   		pri->ev.notify.channel = c->channelno;
   		pri->ev.notify.info = c->notify;
Index: libpri/trunk/debian/changelog
===================================================================
--- libpri/trunk/debian/changelog	(revision 1825)
+++ libpri/trunk/debian/changelog	(working copy)
@@ -1,3 +1,11 @@
+libpri (1.2.3-1) unstable; urgency=low
+
+  * typo 'primary' fixed from 'primate'
+  * pri_event_setup_ack.call now part of upstream version
+  * negative length checking in q931_get_number merged from upstream
+
+ -- Geoffrey Oakham (Office) <goakham at itdepartment.com>  Sat, 10 Jun  
2006 16:14:20 -0400
+
libpri (1.2.3-1) UNRELEASED; urgency=low
    * NOT RELEASED YET





More information about the Pkg-voip-maintainers mailing list