[Asterisk-cvs] libpri pri_facility.c, 1.18, 1.19 pri_facility.h, 1.8, 1.9

mattf at lists.digium.com mattf at lists.digium.com
Tue Jul 12 16:07:11 CDT 2005


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

Modified Files:
	pri_facility.c pri_facility.h 
Log Message:
Fix for non constructed number component


Index: pri_facility.c
===================================================================
RCS file: /usr/cvsroot/libpri/pri_facility.c,v
retrieving revision 1.18
retrieving revision 1.19
diff -u -d -r1.18 -r1.19
--- pri_facility.c	21 Jun 2005 22:47:39 -0000	1.18
+++ pri_facility.c	12 Jul 2005 20:15:20 -0000	1.19
@@ -231,6 +231,26 @@
 	return 2 + src_len;
 }
 
+int asn1_copy_string(char * buf, int buflen, struct rose_component *comp)
+{
+	int res;
+	int datalen;
+
+	if ((comp->len > buflen) && (comp->len != ASN1_LEN_INDEF))
+		return -1;
+
+	if (comp->len == ASN1_LEN_INDEF) {
+		datalen = strlen(comp->data);
+		res = datalen + 2;
+	} else
+		res = datalen = comp->len;
+
+	memcpy(buf, comp->data, datalen);
+	buf[datalen] = 0;
+
+	return res;
+}
+
 static int rose_number_digits_decode(struct pri *pri, q931_call *call, unsigned char *data, int len, struct addressingdataelements_presentednumberunscreened *value)
 {
 	int i = 0;
@@ -309,6 +329,13 @@
 			value->npi = PRI_NPI_UNKNOWN;
 			value->ton = PRI_TON_UNKNOWN;
 			break;
+		case (ASN1_CONTEXT_SPECIFIC | ASN1_TAG_0):	/* [0] unknownPartyNumber */
+			res = asn1_copy_string(value->partyaddress, sizeof(value->partyaddress), comp);
+			if (res < 0)
+				return -1;
+			value->npi = PRI_NPI_UNKNOWN;
+			value->ton = PRI_TON_UNKNOWN;
+			break;
 		case (ASN1_CONTEXT_SPECIFIC | ASN1_CONSTRUCTOR | ASN1_TAG_1):	/* [1] publicPartyNumber */
 			res = rose_public_party_number_decode(pri, call, comp->data, comp->len, value);
 			if (res < 0)

Index: pri_facility.h
===================================================================
RCS file: /usr/cvsroot/libpri/pri_facility.h,v
retrieving revision 1.8
retrieving revision 1.9
diff -u -d -r1.8 -r1.9
--- pri_facility.h	2 Jun 2005 20:58:32 -0000	1.8
+++ pri_facility.h	12 Jul 2005 20:15:20 -0000	1.9
@@ -232,6 +232,8 @@
 /* Decoder for the invoke part of a ROSE request */
 extern int rose_invoke_decode(struct pri *pri, struct q931_call *call, unsigned char *data, int len);
 
+extern int asn1_copy_string(char * buf, int buflen, struct rose_component *comp);
+
 extern int asn1_string_encode(unsigned char asn1_type, void *data, int len, int max_len, void *src, int src_len);
 
 /* Get Name types from ASN.1 */




More information about the svn-commits mailing list