[Asterisk-cvs] libpri libpri.h, 1.53, 1.54 pri_facility.c, 1.16, 1.17 pri_internal.h, 1.23, 1.24 q931.c, 1.129, 1.130

kpfleming at lists.digium.com kpfleming at lists.digium.com
Tue Jun 21 16:36:36 CDT 2005


Update of /usr/cvsroot/libpri
In directory mongoose.digium.com:/tmp/cvs-serv8249

Modified Files:
	libpri.h pri_facility.c pri_internal.h q931.c 
Log Message:
record network-provided-number as ANI when supplied (bug #4537)


Index: libpri.h
===================================================================
RCS file: /usr/cvsroot/libpri/libpri.h,v
retrieving revision 1.53
retrieving revision 1.54
diff -u -d -r1.53 -r1.54
--- libpri.h	23 May 2005 16:51:30 -0000	1.53
+++ libpri.h	21 Jun 2005 20:37:22 -0000	1.54
@@ -299,6 +299,7 @@
 	int channel;				/* Channel requested */
 	int callingpres;			/* Presentation of Calling CallerID */
 	int callingplan;			/* Dialing plan of Calling entity */
+	char callingani[256];		/* Calling ANI */
 	char callingnum[256];		/* Calling number */
 	char callingname[256];		/* Calling name (if provided) */
 	int calledplan;				/* Dialing plan of Called number */
@@ -558,6 +559,7 @@
 #define PRI_RECEIVE_SUBADDR
 #define PRI_REDIRECTING_REASON
 #define PRI_AOC_UNITS
+#define PRI_ANI
 
 /* Send notification */
 extern int pri_notify(struct pri *pri, q931_call *c, int channel, int info);

Index: pri_facility.c
===================================================================
RCS file: /usr/cvsroot/libpri/pri_facility.c,v
retrieving revision 1.16
retrieving revision 1.17
diff -u -d -r1.16 -r1.17
--- pri_facility.c	3 Jun 2005 18:29:25 -0000	1.16
+++ pri_facility.c	21 Jun 2005 20:37:22 -0000	1.17
@@ -187,7 +187,7 @@
 	int datalen = 0, res = 0;
 
 	if (comp->len == ASN1_LEN_INDEF) {
-		datalen = strlen(comp->data);
+		datalen = strlen((char *)comp->data);
 		res = datalen + 2;
 	} else
 		datalen = res = comp->len;
@@ -234,7 +234,7 @@
 			return -1;
 		}
 		if (comp->len == ASN1_LEN_INDEF) {
-			datalen = strlen(comp->data);
+			datalen = strlen((char *)comp->data);
 			res = datalen + 2;
 		} else
 			res = datalen = comp->len;

Index: pri_internal.h
===================================================================
RCS file: /usr/cvsroot/libpri/pri_internal.h,v
retrieving revision 1.23
retrieving revision 1.24
diff -u -d -r1.23 -r1.24
--- pri_internal.h	23 May 2005 15:06:33 -0000	1.23
+++ pri_internal.h	21 Jun 2005 20:37:22 -0000	1.24
@@ -200,7 +200,8 @@
 	
 	int callerplan;
 	int callerpres;			/* Caller presentation */
-	char callernum[256];	/* Caller */
+	char callerani[256];	/* Caller */
+	char callernum[256];
 	char callername[256];
 
 	char digitbuf[64];	/* Buffer for digits that come in KEYPAD_FACILITY */

Index: q931.c
===================================================================
RCS file: /usr/cvsroot/libpri/q931.c,v
retrieving revision 1.129
retrieving revision 1.130
diff -u -d -r1.129 -r1.130
--- q931.c	29 May 2005 15:08:23 -0000	1.129
+++ q931.c	21 Jun 2005 20:37:22 -0000	1.130
@@ -866,7 +866,7 @@
 {
 	if (order > 1)
 		return 0;
-	if (call->redirectingnum && strlen(call->redirectingnum)) {
+	if (call->redirectingnum && *call->redirectingnum) {
 		ie->data[0] = call->redirectingplan;
 		ie->data[1] = call->redirectingpres;
 		ie->data[2] = (call->redirectingreason & 0x0f) | 0x80;
@@ -904,32 +904,45 @@
 static FUNC_SEND(transmit_called_party_number)
 {
 	ie->data[0] = 0x80 | call->calledplan;
-	if (strlen(call->callednum)) 
+	if (*call->callednum)
 		memcpy(ie->data + 1, call->callednum, strlen(call->callednum));
 	return strlen(call->callednum) + 3;
 }
 
 static FUNC_RECV(receive_calling_party_number)
 {
-        int extbit;
+	u_int8_t *data;
+	size_t length;
+	int extbit;
         
-        call->callerplan = ie->data[0] & 0x7f;
-        extbit = (ie->data[0] >> 7) & 0x01;
+	call->callerplan = ie->data[0] & 0x7f;
+	extbit = (ie->data[0] >> 7) & 0x01;
 
-	/* Somebody's broken PRI stack sent a calling
-	 party number IE twice.  One with the callernam
-	 and one without. */
-	if (strlen(call->callernum))
-		return 0;
+	if (extbit) {
+		data = ie->data + 1;
+		length = len - 3;
+		call->callerpres = 0; /* PI presentation allowed
+								 SI user-provided, not screened */        
+	}
+	else {
+		data = ie->data + 2;
+		length = len - 4;
+		call->callerpres = ie->data[1] & 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);
+
+		/*
+		 * Copy ANI to Caller*ID if Caller*ID is not already set
+		 */
+		if (!*call->callernum)
+			strncpy(call->callernum, call->callerani, sizeof(call->callernum) - 1);
+	}
+	else
+		q931_get_number((u_int8_t *)call->callernum, sizeof(call->callernum), data, length);
 
-        if (extbit) {
-	  q931_get_number((unsigned char *) call->callernum, sizeof(call->callernum), ie->data + 1, len - 3);
-	  call->callerpres = 0; /* PI presentation allowed
-				   SI user-provided, not screened */        
-        } else {
-	  q931_get_number((unsigned char *) call->callernum, sizeof(call->callernum), ie->data + 2, len - 4);
-	  call->callerpres = ie->data[1] & 0x7f;
-        }
 	return 0;
 }
 
@@ -937,7 +950,7 @@
 {
 	ie->data[0] = call->callerplan;
 	ie->data[1] = 0x80 | call->callerpres;
-	if (strlen(call->callernum)) 
+	if (*call->callernum) 
 		memcpy(ie->data + 2, call->callernum, strlen(call->callernum));
 	return strlen(call->callernum) + 4;
 }
@@ -1027,7 +1040,7 @@
 static FUNC_SEND(transmit_display)
 {
 	int i;
-	if ((pri->switchtype != PRI_SWITCH_NI1) && strlen(call->callername)) {
+	if ((pri->switchtype != PRI_SWITCH_NI1) && *call->callername) {
 		i = 0;
 		if(pri->switchtype != PRI_SWITCH_EUROISDN_E1) {
 			ie->data[0] = 0xb1;
@@ -1150,7 +1163,7 @@
 			}
 		} while (0);
 	}
-	if (/*(pri->switchtype == PRI_SWITCH_EUROISDN_E1) &&*/ call->redirectingnum && strlen(call->redirectingnum)) {
+	if (/*(pri->switchtype == PRI_SWITCH_EUROISDN_E1) &&*/ call->redirectingnum && *call->redirectingnum) {
 		if (!(first_i = i)) {
 			/* Add protocol information header */
 			ie->data[i++] = 0x80 | Q932_PROTOCOL_ROSE;
@@ -1185,7 +1198,7 @@
 		switch(call->redirectingpres) {
 		case PRES_ALLOWED_USER_NUMBER_NOT_SCREENED:
 		case PRES_ALLOWED_USER_NUMBER_PASSED_SCREEN:
-			if (call->redirectingnum && strlen(call->redirectingnum)) {
+			if (call->redirectingnum && *call->redirectingnum) {
 				ASN1_ADD_SIMPLE(comp, 0xA0, ie->data, i);
 				ASN1_PUSH(compstk, compsp, comp);
 
@@ -1234,7 +1247,7 @@
 		switch(call->redirectingpres) {
 		case PRES_ALLOWED_USER_NUMBER_NOT_SCREENED:
 		case PRES_ALLOWED_USER_NUMBER_PASSED_SCREEN:
-			if (call->redirectingnum && strlen(call->redirectingnum)) {
+			if (call->redirectingnum && *call->redirectingnum) {
 				ASN1_ADD_SIMPLE(comp, 0xA0, ie->data, i);
 				ASN1_PUSH(compstk, compsp, comp);
 
@@ -1569,7 +1582,7 @@
 		    ((*c >= 'a') && (*c <= 'z')) ||
 		    ((*c >= '0') && (*c <= '9'))) {
 			if (!lastascii) {
-				if (strlen(tmp)) { 
+				if (*tmp) { 
 					tmp[x++] = ',';
 					tmp[x++] = ' ';
 				}
@@ -1581,7 +1594,7 @@
 			if (lastascii) {
 				tmp[x++] = '\'';
 			}
-			if (strlen(tmp)) { 
+			if (*tmp) { 
 				tmp[x++] = ',';
 				tmp[x++] = ' ';
 			}
@@ -3368,6 +3381,7 @@
 		pri->ev.ring.callingpres = c->callerpres;
 		pri->ev.ring.callingplan = c->callerplan;
 		pri->ev.ring.ani2 = c->ani2;
+		strncpy(pri->ev.ring.callingani, c->callerani, sizeof(pri->ev.ring.callingani) - 1);
 		strncpy(pri->ev.ring.callingnum, c->callernum, sizeof(pri->ev.ring.callingnum) - 1);
 		strncpy(pri->ev.ring.callingname, c->callername, sizeof(pri->ev.ring.callingname) - 1);
 		pri->ev.ring.calledplan = c->calledplan;
@@ -3434,7 +3448,7 @@
 		}
 		pri->ev.e = PRI_EVENT_FACNAME;
 		strncpy(pri->ev.facname.callingname, c->callername, sizeof(pri->ev.facname.callingname) - 1);
-		strncpy(pri->ev.facname.callingnum, c->callernum, sizeof(pri->ev.facname.callingname) - 1);
+		strncpy(pri->ev.facname.callingnum, c->callernum, sizeof(pri->ev.facname.callingnum) - 1);
 		pri->ev.facname.channel = c->channelno | (c->ds1no << 8) | (c->ds1explicit << 16);
 		pri->ev.facname.cref = c->cr;
 		pri->ev.facname.call = c;




More information about the svn-commits mailing list