[thirdparty-commits] rmudgett: mISDNuser/trunk r26 - /mISDNuser/trunk/suppserv/

SVN commits to the Digium third-party software repository thirdparty-commits at lists.digium.com
Thu Oct 23 12:04:36 CDT 2008


Author: rmudgett
Date: Thu Oct 23 12:04:35 2008
New Revision: 26

URL: http://svn.digium.com/view/thirdparty?view=rev&rev=26
Log:
Added CCBS/CCNR facility message support

Added:
    mISDNuser/trunk/suppserv/asn1_ccbs.c   (with props)
    mISDNuser/trunk/suppserv/asn1_ccbs.h   (with props)
Modified:
    mISDNuser/trunk/suppserv/Makefile
    mISDNuser/trunk/suppserv/asn1.c
    mISDNuser/trunk/suppserv/asn1.h
    mISDNuser/trunk/suppserv/asn1_address.c
    mISDNuser/trunk/suppserv/asn1_aoc.c
    mISDNuser/trunk/suppserv/asn1_comp.c
    mISDNuser/trunk/suppserv/asn1_diversion.c
    mISDNuser/trunk/suppserv/asn1_enc.c
    mISDNuser/trunk/suppserv/asn1_generic.c
    mISDNuser/trunk/suppserv/fac.c
    mISDNuser/trunk/suppserv/suppserv.h

Modified: mISDNuser/trunk/suppserv/Makefile
URL: http://svn.digium.com/view/thirdparty/mISDNuser/trunk/suppserv/Makefile?view=diff&rev=26&r1=25&r2=26
==============================================================================
--- mISDNuser/trunk/suppserv/Makefile (original)
+++ mISDNuser/trunk/suppserv/Makefile Thu Oct 23 12:04:35 2008
@@ -4,7 +4,7 @@
 
 #CFLAGS += -DASN1_DEBUG
 
-SUPPSERV_OBJ = asn1.o asn1_enc.o asn1_generic.o asn1_aoc.o asn1_basic_service.o asn1_comp.o asn1_diversion.o asn1_address.o fac.o
+SUPPSERV_OBJ = asn1.o asn1_enc.o asn1_generic.o asn1_aoc.o asn1_basic_service.o asn1_comp.o asn1_ccbs.o asn1_diversion.o asn1_address.o fac.o
 SUPPSERV_PICOBJ = $(SUPPSERV_OBJ:%.o=%.lo)
 
 all: libsuppserv.a libsuppserv_pic.a libsuppserv.so

Modified: mISDNuser/trunk/suppserv/asn1.c
URL: http://svn.digium.com/view/thirdparty/mISDNuser/trunk/suppserv/asn1.c?view=diff&rev=26&r1=25&r2=26
==============================================================================
--- mISDNuser/trunk/suppserv/asn1.c (original)
+++ mISDNuser/trunk/suppserv/asn1.c Thu Oct 23 12:04:35 2008
@@ -45,10 +45,9 @@
 
 	CallASN1(ret, p, end, ParseTag(p, end, &tag));
 	CallASN1(ret, p, end, ParseLen(p, end, &len));
-#ifdef ASN1_DEBUG
-	for (j = 0; j < level*5; j++) print_asn1msg(PRT_DEBUG_DECODE, " ");
+	for (j = 0; j < level * 5; j++)
+		print_asn1msg(PRT_DEBUG_DECODE, " ");
 	print_asn1msg(PRT_DEBUG_DECODE, "TAG 0x%02x LEN %3d\n", tag, len);
-#endif
 	
 	if (tag & ASN1_TAG_CONSTRUCTED) {
 		if (len == -1) { // indefinite
@@ -62,19 +61,21 @@
 		} else {
 			tag_end = p + len;
 			while (p < tag_end) {
-				CallASN1(ret, p, end, ParseASN1(p, end, level +1));
+				CallASN1(ret, p, end, ParseASN1(p, end, level + 1));
 			}
 		}
 	} else {
-		for (j = 0; j < level*5; j++) print_asn1msg(PRT_DEBUG_DECODE, " ");
+		for (j = 0; j < level * 5; j++)
+			print_asn1msg(PRT_DEBUG_DECODE, " ");
 		while (len--) {
 			print_asn1msg(PRT_DEBUG_DECODE, "%02x ", *p);
 			p++;
 		}
 		print_asn1msg(PRT_DEBUG_DECODE, "\n");
 	}
-	for (j = 0; j < level*5; j++) print_asn1msg(PRT_DEBUG_DECODE, " ");
-	print_asn1msg(PRT_DEBUG_DECODE, "END (%d)\n", p - beg - 2);
+	for (j = 0; j < level * 5; j++)
+		print_asn1msg(PRT_DEBUG_DECODE, " ");
+	print_asn1msg(PRT_DEBUG_DECODE, "END (%ld)\n", p - beg - 2);
 	return p - beg;
 }
 #endif

Modified: mISDNuser/trunk/suppserv/asn1.h
URL: http://svn.digium.com/view/thirdparty/mISDNuser/trunk/suppserv/asn1.h?view=diff&rev=26&r1=25&r2=26
==============================================================================
--- mISDNuser/trunk/suppserv/asn1.h (original)
+++ mISDNuser/trunk/suppserv/asn1.h Thu Oct 23 12:04:35 2008
@@ -77,7 +77,7 @@
 };
 
 struct asn1Invoke {
-	__u16 invokeId;
+	__s16 invokeId;
 	__u16 operationValue;
 	union {
 		struct ActDivNotification actNot;
@@ -85,26 +85,82 @@
 		struct ReqCallDeflection reqCD;
 		struct FacAOCDChargingUnit AOCDchu;
 		struct FacAOCDCurrency AOCDcur;
+
+		struct FacStatusRequest_ARG StatusRequest;
+
+		/* CCBS/CCNR support */
+		struct FacCallInfoRetain CallInfoRetain;
+		struct FacEraseCallLinkageID EraseCallLinkageID;
+		struct FacCCBSDeactivate_ARG CCBSDeactivate;
+		struct FacCCBSErase CCBSErase;
+		struct FacCCBSRemoteUserFree CCBSRemoteUserFree;
+		struct FacCCBSCall CCBSCall;
+		struct FacCCBSStatusRequest_ARG CCBSStatusRequest;
+		struct FacCCBSBFree CCBSBFree;
+		struct FacCCBSStopAlerting CCBSStopAlerting;
+
+		/* CCBS support */
+		struct FacCCBSRequest_ARG CCBSRequest;
+		struct FacCCBSInterrogate_ARG CCBSInterrogate;
+
+		/* CCNR support */
+		struct FacCCBSRequest_ARG CCNRRequest;
+		struct FacCCBSInterrogate_ARG CCNRInterrogate;
 	} o;
 };
 
 struct asn1ReturnResult {
-	__u16 invokeId;
+	__s16 invokeId;
+	int operationValuePresent;
+	int operationValue;
 	union {
 		struct ServedUserNumberList list;
 		struct IntResultList resultList;
+
+		struct FacStatusRequest_RES StatusRequest;
+
+		/* CCBS/CCNR support */
+		struct FacCCBSStatusRequest_RES CCBSStatusRequest;
+
+		/* CCBS support */
+		struct FacCCBSRequest_RES CCBSRequest;
+		struct FacCCBSInterrogate_RES CCBSInterrogate;
+
+		/* CCNR support */
+		struct FacCCBSRequest_RES CCNRRequest;
+		struct FacCCBSInterrogate_RES CCNRInterrogate;
 	} o;
 };
 
+struct asn1Oid {
+	/* Number of subidentifier values in OID list */
+	__u16 numValues;
+
+	/*
+	 * OID subidentifier value list
+	 * Note the first value is really the first two OID subidentifiers.
+	 * They are compressed using this formula:
+	 * First_Value = (First_Subidentifier * 40) + Second_Subidentifier
+	 */
+	__u16 value[10];
+};
+
+struct asn1OidConvert {
+	enum FacOIDBase baseCode;
+	struct asn1Oid oid;
+};
+
 struct asn1ReturnError {
-	__u16 invokeId;
+	__s16 invokeId;
+	/*! \see enum FacErrorCode */
 	__u16 errorValue;
 };
 
 struct asn1Reject {
+	int invokeIdPresent;
 	int invokeId;
 	asn1Problem problem;
-	__u16 problemValue;
+	int problemValue;
 };
 
 struct asn1_parm {
@@ -113,7 +169,7 @@
 		struct asn1Invoke       inv;
 		struct asn1ReturnResult retResult;
 		struct asn1ReturnError  retError;
-		struct asn1Reject	reject;
+		struct asn1Reject       reject;
 	} u;
 };
 
@@ -128,98 +184,104 @@
 
 #define int_error() \
 	printf("mISDN: INTERNAL ERROR in %s:%d\n", \
-		   __FILE__, __LINE__)
+		__FILE__, __LINE__)
 
 int ParseTag(u_char *p, u_char *end, int *tag);
 int ParseLen(u_char *p, u_char *end, int *len);
 
-#define ASN1_TAG_BOOLEAN           (0x01) // is that true?
-#define ASN1_TAG_INTEGER           (0x02)
-#define ASN1_TAG_BIT_STRING        (0x03)
-#define ASN1_TAG_OCTET_STRING      (0x04)
-#define ASN1_TAG_NULL              (0x05)
-#define ASN1_TAG_OBJECT_IDENTIFIER (0x06)
-#define ASN1_TAG_ENUM              (0x0a)
-#define ASN1_TAG_SEQUENCE          (0x30)
-#define ASN1_TAG_SET               (0x31)
-#define ASN1_TAG_NUMERIC_STRING    (0x12)
-#define ASN1_TAG_PRINTABLE_STRING  (0x13)
-#define ASN1_TAG_IA5_STRING        (0x16)
-#define ASN1_TAG_UTC_TIME          (0x17)
-
-#define ASN1_TAG_CONSTRUCTED       (0x20)
-#define ASN1_TAG_CONTEXT_SPECIFIC  (0x80)
-
-#define ASN1_TAG_EXPLICIT          (0x100)
-#define ASN1_TAG_OPT               (0x200)
-#define ASN1_NOT_TAGGED            (0x400)
-
-#define CallASN1(ret, p, end, todo) do { \
-        ret = todo; \
-	if (ret < 0) { \
-                int_error(); \
-                return -1; \
-        } \
-        p += ret; \
-} while (0)
-
+#define ASN1_TAG_BOOLEAN           1
+#define ASN1_TAG_INTEGER           2
+#define ASN1_TAG_BIT_STRING        3
+#define ASN1_TAG_OCTET_STRING      4
+#define ASN1_TAG_NULL              5
+#define ASN1_TAG_OBJECT_IDENTIFIER 6
+#define ASN1_TAG_ENUM              10
+#define ASN1_TAG_SEQUENCE          (ASN1_TAG_CONSTRUCTED | 16)
+#define ASN1_TAG_SET               (ASN1_TAG_CONSTRUCTED | 17)
+#define ASN1_TAG_NUMERIC_STRING    18
+#define ASN1_TAG_PRINTABLE_STRING  19
+#define ASN1_TAG_IA5_STRING        22
+#define ASN1_TAG_UTC_TIME          23
+
+#define ASN1_TAG_CONSTRUCTED       0x20
+
+#define ASN1_TAG_TYPE_MASK         0xC0
+#define ASN1_TAG_UNIVERSAL         0x00
+#define ASN1_TAG_APPLICATION_WIDE  0x40
+#define ASN1_TAG_CONTEXT_SPECIFIC  0x80
+#define ASN1_TAG_PRIVATE           0xC0
+
+#define ASN1_TAG_EXPLICIT          0x100
+#define ASN1_TAG_OPT               0x200
+#define ASN1_NOT_TAGGED            0x400
+
+#define CallASN1(ret, p, end, todo) \
+	do { \
+		ret = todo; \
+		if (ret < 0) { \
+			int_error(); \
+			return -1; \
+		} \
+		p += ret; \
+	} while (0)
+
+/* INIT must be placed after the last variable declared */
 #define INIT \
 	int tag, len; \
 	int ret; \
 	u_char *beg; \
-        \
-        print_asn1msg(PRT_DEBUG_DECODE, " DEBUG> %s\n", __FUNCTION__); \
+	\
+	print_asn1msg(PRT_DEBUG_DECODE, " DEBUG> %s\n", __FUNCTION__); \
 	beg = p; \
 	CallASN1(ret, p, end, ParseTag(p, end, &tag)); \
 	CallASN1(ret, p, end, ParseLen(p, end, &len)); \
-        if (len >= 0) { \
-                if (p + len > end) \
-                        return -1; \
-                end = p + len; \
-        }
-
-#define XSEQUENCE_1(todo, act_tag, the_tag, arg1) do { \
-	if (p < end) { \
-  	        if (((the_tag) &~ ASN1_TAG_OPT) == ASN1_NOT_TAGGED) { \
-		        if (((u_char)act_tag == *p) || ((act_tag) == ASN1_NOT_TAGGED)) { \
-			        CallASN1(ret, p, end, todo(pc, p, end, arg1)); \
-                        } else { \
-                                if (!((the_tag) & ASN1_TAG_OPT)) { \
-                                        print_asn1msg(PRT_DEBUG_DECODE, " DEBUG> err 1 %s:%d\n", __FUNCTION__, __LINE__); \
-                	    	        return -1; \
-                                } \
-                        } \
-	        } else { \
-                        if ((the_tag) & ASN1_TAG_EXPLICIT) { \
-		                if ((u_char)(((the_tag) & 0xff) | (ASN1_TAG_CONTEXT_SPECIFIC | ASN1_TAG_CONSTRUCTED)) == *p) { \
-                                        int xtag, xlen; \
-	                                CallASN1(ret, p, end, ParseTag(p, end, &xtag)); \
-			                CallASN1(ret, p, end, ParseLen(p, end, &xlen)); \
-  	                                CallASN1(ret, p, end, todo(pc, p, end, arg1)); \
-                                } else { \
-                                        if (!(the_tag) & ASN1_TAG_OPT) { \
-                                                print_asn1msg(PRT_DEBUG_DECODE, " DEBUG> err 2 %s:%d\n", __FUNCTION__, __LINE__); \
-                        	    	        return -1; \
-                                        } \
-                                } \
-                        } else { \
-		                if ((u_char)(((the_tag) & 0xff) | (ASN1_TAG_CONTEXT_SPECIFIC | (act_tag & ASN1_TAG_CONSTRUCTED))) == *p) { \
-  	                                CallASN1(ret, p, end, todo(pc, p, end, arg1)); \
-                                } else { \
-                                        if (!(the_tag) & ASN1_TAG_OPT) { \
-                                                print_asn1msg(PRT_DEBUG_DECODE, " DEBUG> err 3 %s:%d\n", __FUNCTION__, __LINE__); \
-                        	    	        return -1; \
-                                        } \
-                                } \
-		        } \
+	if (len >= 0) { \
+		if (p + len > end) \
+			return -1; \
+		end = p + len; \
+	}
+
+#define XSEQUENCE_1(todo, act_tag, the_tag, arg1) \
+	do { \
+		if (p < end) { \
+			if (((the_tag) & ~ASN1_TAG_OPT) == ASN1_NOT_TAGGED) { \
+				if (((act_tag) == ASN1_NOT_TAGGED) || ((u_char) (act_tag) == *p)) { \
+					CallASN1(ret, p, end, todo(pc, p, end, arg1)); \
+				} else { \
+					if (!((the_tag) & ASN1_TAG_OPT)) { \
+						print_asn1msg(PRT_DEBUG_DECODE, " DEBUG> err 1 %s:%d\n", __FUNCTION__, __LINE__); \
+						return -1; \
+					} \
+				} \
+			} else if ((the_tag) & ASN1_TAG_EXPLICIT) { \
+				if ((u_char) (((the_tag) & 0xff) | (((act_tag) & ASN1_TAG_TYPE_MASK) | ASN1_TAG_CONSTRUCTED)) == *p) { \
+					int xtag, xlen; \
+					CallASN1(ret, p, end, ParseTag(p, end, &xtag)); \
+					CallASN1(ret, p, end, ParseLen(p, end, &xlen)); \
+					CallASN1(ret, p, end, todo(pc, p, end, arg1)); \
+				} else { \
+					if (!((the_tag) & ASN1_TAG_OPT)) { \
+						print_asn1msg(PRT_DEBUG_DECODE, " DEBUG> err 2 %s:%d\n", __FUNCTION__, __LINE__); \
+						return -1; \
+					} \
+				} \
+			} else { /* IMPLICIT */ \
+				if ((u_char) (((the_tag) & 0xff) | ((act_tag) & (ASN1_TAG_TYPE_MASK | ASN1_TAG_CONSTRUCTED))) == *p) { \
+					CallASN1(ret, p, end, todo(pc, p, end, arg1)); \
+				} else { \
+					if (!((the_tag) & ASN1_TAG_OPT)) { \
+						print_asn1msg(PRT_DEBUG_DECODE, " DEBUG> err 3 %s:%d\n", __FUNCTION__, __LINE__); \
+						return -1; \
+					} \
+				} \
+			} \
+		} else { \
+			if (!((the_tag) & ASN1_TAG_OPT)) { \
+				print_asn1msg(PRT_DEBUG_DECODE, " DEBUG> err 4 %s:%d\n", __FUNCTION__, __LINE__); \
+				return -1; \
+			} \
 		} \
-        } else { \
-                if (!(the_tag) & ASN1_TAG_OPT) { \
-                        print_asn1msg(PRT_DEBUG_DECODE, " DEBUG> err 4 %s:%d\n", __FUNCTION__, __LINE__); \
-			return -1; \
-                } \
-        } \
-} while (0)
+	} while (0)
 
 #define XSEQUENCE_OPT_1(todo, act_tag, the_tag, arg1) \
         XSEQUENCE_1(todo, act_tag, (the_tag | ASN1_TAG_OPT), arg1)
@@ -228,40 +290,75 @@
 #define XSEQUENCE_OPT(todo, act_tag, the_tag) XSEQUENCE_OPT_1(todo, act_tag, the_tag, -1)
 
 #define XCHOICE_1(todo, act_tag, the_tag, arg1) \
-	if (act_tag == ASN1_NOT_TAGGED) { \
-		return todo(pc, beg, end, arg1); \
-        } \
-        if (the_tag == ASN1_NOT_TAGGED) { \
-		  if (act_tag == tag) { \
-                            return todo(pc, beg, end, arg1); \
-                  } \
-         } else { \
-		  if ((the_tag | (0x80 | (act_tag & 0x20))) == tag) { \
-                            return todo(pc, beg, end, arg1); \
-                  } \
-	 }
+	do { \
+		if ((act_tag) == ASN1_NOT_TAGGED) { \
+			return todo(pc, beg, end, arg1); \
+		} else if ((the_tag) == ASN1_NOT_TAGGED) { \
+			if ((act_tag) == tag) { \
+				return todo(pc, beg, end, arg1); \
+			} \
+		} else { \
+			if (((the_tag) | ((act_tag) & (ASN1_TAG_TYPE_MASK | ASN1_TAG_CONSTRUCTED))) == tag) { \
+				return todo(pc, beg, end, arg1); \
+			} \
+		} \
+	} while (0)
 
 #define XCHOICE(todo, act_tag, the_tag) XCHOICE_1(todo, act_tag, the_tag, -1)
 
-#define XCHOICE_DEFAULT do {\
-          print_asn1msg(PRT_DEBUG_DECODE, " DEBUG> err 5 %s:%d\n", __FUNCTION__, __LINE__); \
-          return -1; \
-	  } while (0)
-
-#define CHECK_P do { \
-        if (p >= end) \
-                 return -1; \
-        } while (0) 
+#define XCHOICE_DEFAULT \
+	do { \
+		print_asn1msg(PRT_DEBUG_DECODE, " DEBUG> err 5 %s:%d\n", __FUNCTION__, __LINE__); \
+		return -1; \
+	} while (0)
+
+#define CHECK_P \
+	do { \
+		if (p >= end) \
+			return -1; \
+	} while (0) 
+
+const struct asn1OidConvert *FindOidByOidValue(int length, const __u16 oidValues[]);
+const struct asn1OidConvert *FindOidByEnum(__u16 value);
+__u16 ConvertOidToEnum(const struct asn1Oid *oid, __u16 errorValue);
+int ConvertEnumToOid(struct asn1Oid *oid, __u16 enumValue);
+#define IsEnumOid(enumValue)	\
+	((FAC_OID_BASE(1) <= (enumValue) \
+		&& (enumValue) < FAC_OID_BASE(FacOIDBase_Last)) ? 1 : 0)
+
+enum asn1ComponentTag {
+	asn1ComponentTag_Invoke	= ASN1_TAG_CONTEXT_SPECIFIC | ASN1_TAG_CONSTRUCTED | 1,
+	asn1ComponentTag_Result	= ASN1_TAG_CONTEXT_SPECIFIC | ASN1_TAG_CONSTRUCTED | 2,
+	asn1ComponentTag_Error	= ASN1_TAG_CONTEXT_SPECIFIC | ASN1_TAG_CONSTRUCTED | 3,
+	asn1ComponentTag_Reject	= ASN1_TAG_CONTEXT_SPECIFIC | ASN1_TAG_CONSTRUCTED | 4,
+};
+__u8 *encodeComponent_Head(__u8 *p, enum asn1ComponentTag componentTag);
+__u8 *encodeComponent_Head_Long_u8(__u8 *p, enum asn1ComponentTag componentTag);
+int encodeComponent_Length(__u8 *msg, __u8 *end);
+int encodeComponent_Length_Long_u8(__u8 *msg, __u8 *p);
+
+int encodeOperationValue(__u8 *dest, int operationValue);
+int encodeErrorValue(__u8 *dest, int errorValue);
 
 /*
 ** ASN.1 Encoding
 */
 
-int encodeNull(__u8 *dest);
-int encodeBoolean(__u8 *dest, __u32 i);
-int encodeInt(__u8 *dest, __u32 i);
-int encodeEnum(__u8 *dest, __u32 i);
-int encodeNumberDigits(__u8 *dest, __s8 *nd, __u8 len);
+#define ASN1_NUM_OCTETS_LONG_LENGTH_u8	2
+#define ASN1_NUM_OCTETS_LONG_LENGTH_u16	3
+int encodeLen_Long_u8(__u8 *dest, __u8 length);
+int encodeLen_Long_u16(__u8 *dest, __u16 length);
+
+int encodeNull(__u8 *dest, __u8 tagType);
+int encodeBoolean(__u8 *dest, __u8 tagType, __u32 i);
+int encodeInt(__u8 *dest, __u8 tagType, __s32 i);
+int encodeEnum(__u8 *dest, __u8 tagType, __s32 i);
+int encodeOctetString(__u8 *dest, __u8 tagType, const __s8 *str, __u8 len);
+int encodeNumericString(__u8 *dest, __u8 tagType, const __s8 *str, __u8 len);
+int encodePrintableString(__u8 *dest, __u8 tagType, const __s8 *str, __u8 len);
+int encodeIA5String(__u8 *dest, __u8 tagType, const __s8 *str, __u8 len);
+int encodeOid(__u8 *dest, __u8 tagType, const struct asn1Oid *oid);
+
 int encodePublicPartyNumber(__u8 *dest, __s8 *facilityPartyNumber);
 int encodePartyNumber(__u8 *dest, __s8 *facilityPartyNumber);
 int encodeServedUserNumber(__u8 *dest, __s8 *servedUserNumber);
@@ -271,13 +368,19 @@
 ** ASN.1 Parsing
 */
 
+struct asn1ParseString {
+	char *buf;		/* Where to put the parsed string characters */
+	size_t maxSize;	/* sizeof string buffer (Including an ASCIIz terminator) */
+	size_t length;	/* length of string put into the string buffer (Without the terminator) */
+};
 int ParseBoolean(struct asn1_parm *pc, u_char *p, u_char *end, int *i);
 int ParseNull(struct asn1_parm *pc, u_char *p, u_char *end, int dummy);
 int ParseInteger(struct asn1_parm *pc, u_char *p, u_char *end, int *i);
 int ParseEnum(struct asn1_parm *pc, u_char *p, u_char *end, int *i);
-int ParseIA5String(struct asn1_parm *pc, u_char *p, u_char *end, char *str);
-int ParseNumericString(struct asn1_parm *pc, u_char *p, u_char *end, char *str);
-int ParseOctetString(struct asn1_parm *pc, u_char *p, u_char *end, char *str);
+int ParseIA5String(struct asn1_parm *pc, u_char *p, u_char *end, struct asn1ParseString *str);
+int ParseNumericString(struct asn1_parm *pc, u_char *p, u_char *end, struct asn1ParseString *str);
+int ParseOctetString(struct asn1_parm *pc, u_char *p, u_char *end, struct asn1ParseString *str);
+int ParseOid(struct asn1_parm *pc, u_char *p, u_char *end, struct asn1Oid *oid);
 
 int ParseARGReqCallDeflection(struct asn1_parm *pc, u_char *p, u_char *end, struct ReqCallDeflection *reqCD);
 int ParseARGActivationStatusNotificationDiv(struct asn1_parm *pc, u_char *p, u_char *end, struct ActDivNotification *actNot);
@@ -312,9 +415,6 @@
 int ParseScreeningIndicator(struct asn1_parm *pc, u_char *p, u_char *end, char *str);
 int ParseNumberDigits(struct asn1_parm *pc, u_char *p, u_char *end, char *str);
 
-int ParseInvokeId(struct asn1_parm *parm, u_char *p, u_char *end, int *invokeId);
-int ParseOperationValue(struct asn1_parm *parm, u_char *p, u_char *end, int *operationValue);
-int ParseInvokeComponent(struct asn1_parm *parm, u_char *p, u_char *end, int dummy);
 int ParseReturnResultComponent(struct asn1_parm *parm, u_char *p, u_char *end, int dummy);
 int ParseComponent(struct asn1_parm *parm, u_char *p, u_char *end);
 int XParseComponent(struct asn1_parm *parm, u_char *p, u_char *end);

Modified: mISDNuser/trunk/suppserv/asn1_address.c
URL: http://svn.digium.com/view/thirdparty/mISDNuser/trunk/suppserv/asn1_address.c?view=diff&rev=26&r1=25&r2=26
==============================================================================
--- mISDNuser/trunk/suppserv/asn1_address.c (original)
+++ mISDNuser/trunk/suppserv/asn1_address.c Thu Oct 23 12:04:35 2008
@@ -40,10 +40,10 @@
 {
 	INIT;
 
-	XCHOICE_1(ParseAddressScreened, ASN1_TAG_SEQUENCE, 0, str);
-	XCHOICE_1(ParsePresentationRestricted, ASN1_TAG_NULL, 1, str);
-	XCHOICE_1(ParseNotAvailInterworking, ASN1_TAG_NULL, 2, str);
-	XCHOICE_1(ParseAddressScreened, ASN1_TAG_NULL, 3, str);
+	XCHOICE_1(ParseAddressScreened, ASN1_TAG_CONTEXT_SPECIFIC | ASN1_TAG_CONSTRUCTED, 0, str);
+	XCHOICE_1(ParsePresentationRestricted, ASN1_TAG_CONTEXT_SPECIFIC, 1, str);
+	XCHOICE_1(ParseNotAvailInterworking, ASN1_TAG_CONTEXT_SPECIFIC, 2, str);
+	XCHOICE_1(ParseAddressScreened, ASN1_TAG_CONTEXT_SPECIFIC, 3, str);
 	XCHOICE_DEFAULT;
 }
 
@@ -51,10 +51,10 @@
 {
 	INIT;
 
-	XCHOICE_1(ParseNumberScreened, ASN1_TAG_SEQUENCE, 0, str);
-	XCHOICE_1(ParsePresentationRestricted, ASN1_TAG_NULL, 1, str);
-	XCHOICE_1(ParseNotAvailInterworking, ASN1_TAG_NULL, 2, str);
-	XCHOICE_1(ParseNumberScreened, ASN1_TAG_NULL, 3, str);
+	XCHOICE_1(ParseNumberScreened, ASN1_TAG_CONTEXT_SPECIFIC | ASN1_TAG_CONSTRUCTED, 0, str);
+	XCHOICE_1(ParsePresentationRestricted, ASN1_TAG_CONTEXT_SPECIFIC, 1, str);
+	XCHOICE_1(ParseNotAvailInterworking, ASN1_TAG_CONTEXT_SPECIFIC, 2, str);
+	XCHOICE_1(ParseNumberScreened, ASN1_TAG_CONTEXT_SPECIFIC, 3, str);
 	XCHOICE_DEFAULT;
 }
 
@@ -63,10 +63,10 @@
 	struct PartyNumber partyNumber;
 	INIT;
 
-	XCHOICE_1(ParsePartyNumber, ASN1_TAG_SEQUENCE, 0, &partyNumber); // FIXME EXP
-	XCHOICE_1(ParsePresentationRestricted, ASN1_TAG_NULL, 1, str);
-	XCHOICE_1(ParseNotAvailInterworking, ASN1_TAG_NULL, 2, str);
-	XCHOICE_1(ParsePartyNumber, ASN1_TAG_SEQUENCE, 3, &partyNumber); // FIXME EXP
+	XCHOICE_1(ParsePartyNumber, ASN1_TAG_CONTEXT_SPECIFIC | ASN1_TAG_CONSTRUCTED, 0, &partyNumber); // FIXME EXP
+	XCHOICE_1(ParsePresentationRestricted, ASN1_TAG_CONTEXT_SPECIFIC, 1, str);
+	XCHOICE_1(ParseNotAvailInterworking, ASN1_TAG_CONTEXT_SPECIFIC, 2, str);
+	XCHOICE_1(ParsePartyNumber, ASN1_TAG_CONTEXT_SPECIFIC | ASN1_TAG_CONSTRUCTED, 3, &partyNumber); // FIXME EXP
 	XCHOICE_DEFAULT;
 }
 
@@ -119,14 +119,14 @@
 	INIT;
 
 	partyNumber->type = 0;
-	XCHOICE_1(ParseNumberDigits, ASN1_TAG_NUMERIC_STRING, 0, partyNumber->p.unknown); // unknownPartyNumber
+	XCHOICE_1(ParseNumberDigits, ASN1_TAG_CONTEXT_SPECIFIC, 0, partyNumber->p.unknown); // unknownPartyNumber
 	partyNumber->type = 1;
-	XCHOICE_1(ParsePublicPartyNumber, ASN1_TAG_SEQUENCE, 1, &partyNumber->p.publicPartyNumber); 
+	XCHOICE_1(ParsePublicPartyNumber, ASN1_TAG_CONTEXT_SPECIFIC | ASN1_TAG_CONSTRUCTED, 1, &partyNumber->p.publicPartyNumber); 
 #if 0
-	XCHOICE_1(ParseNumberDigits, ASN1_TAG_NUMERIC_STRING, 3, str); // dataPartyNumber
-	XCHOICE_1(ParseNumberDigits, ASN1_TAG_NUMERIC_STRING, 4, str); // telexPartyNumber
-	XCHOICE_1(ParsePrivatePartyNumber, ASN1_TAG_SEQUENCE, 5, str);
-	XCHOICE_1(ParseNumberDigits, ASN1_TAG_NUMERIC_STRING, 8, str); // nationalStandardPartyNumber
+	XCHOICE_1(ParseNumberDigits, ASN1_TAG_CONTEXT_SPECIFIC, 3, str); // dataPartyNumber
+	XCHOICE_1(ParseNumberDigits, ASN1_TAG_CONTEXT_SPECIFIC, 4, str); // telexPartyNumber
+	XCHOICE_1(ParsePrivatePartyNumber, ASN1_TAG_CONTEXT_SPECIFIC | ASN1_TAG_CONSTRUCTED, 5, str);
+	XCHOICE_1(ParseNumberDigits, ASN1_TAG_CONTEXT_SPECIFIC, 8, str); // nationalStandardPartyNumber
 #endif
 	XCHOICE_DEFAULT;
 }
@@ -145,7 +145,7 @@
 int ParsePrivatePartyNumber(struct asn1_parm *pc, u_char *p, u_char *end, char *str)
 {
 	int privateTypeOfNumber;
-	char numberDigits[20];
+	char numberDigits[30];
 	INIT;
 
 	XSEQUENCE_1(ParsePrivateTypeOfNumber, ASN1_TAG_ENUM, ASN1_NOT_TAGGED, &privateTypeOfNumber); 
@@ -199,12 +199,20 @@
 
 int ParseNSAPSubaddress(struct asn1_parm *pc, u_char *p, u_char *end, char *str)
 {
-	return ParseOctetString(pc, p, end, str);
+	struct asn1ParseString subaddress;
+
+	subaddress.buf = str;
+	subaddress.maxSize = 30;/* sizeof(struct Address.partySubaddress) */
+	return ParseOctetString(pc, p, end, &subaddress);
 }
 
 int ParseSubaddressInformation(struct asn1_parm *pc, u_char *p, u_char *end, char *str)
 {
-	return ParseOctetString(pc, p, end, str);
+	struct asn1ParseString subaddress;
+
+	subaddress.buf = str;
+	subaddress.maxSize = 30;/* sizeof(struct Address.partySubaddress) */
+	return ParseOctetString(pc, p, end, &subaddress);
 }
 
 int ParseScreeningIndicator(struct asn1_parm *pc, u_char *p, u_char *end, char *str)
@@ -229,5 +237,9 @@
 
 int ParseNumberDigits(struct asn1_parm *pc, u_char *p, u_char *end, char *str)
 {
-	return ParseNumericString(pc, p, end, str);
-}
+	struct asn1ParseString number;
+
+	number.buf = str;
+	number.maxSize = 30;/* sizeof(struct partyNumber.p.unknown) and sizeof(struct publicPartyNumber.numberDigits) */
+	return ParseNumericString(pc, p, end, &number);
+}

Modified: mISDNuser/trunk/suppserv/asn1_aoc.c
URL: http://svn.digium.com/view/thirdparty/mISDNuser/trunk/suppserv/asn1_aoc.c?view=diff&rev=26&r1=25&r2=26
==============================================================================
--- mISDNuser/trunk/suppserv/asn1_aoc.c (original)
+++ mISDNuser/trunk/suppserv/asn1_aoc.c Thu Oct 23 12:04:35 2008
@@ -75,9 +75,9 @@
 {
 	INIT;
 
-	XSEQUENCE_1(ParseRecordedCurrency, ASN1_TAG_SEQUENCE, 1, cur);
-	XSEQUENCE_1(ParseTypeOfChargingInfo, ASN1_TAG_ENUM, 2, &cur->typeOfChargingInfo);
-	XSEQUENCE_OPT_1(ParseAOCDBillingId, ASN1_TAG_ENUM, 3, &cur->billingId);
+	XSEQUENCE_1(ParseRecordedCurrency, ASN1_TAG_CONTEXT_SPECIFIC | ASN1_TAG_CONSTRUCTED, 1, cur);
+	XSEQUENCE_1(ParseTypeOfChargingInfo, ASN1_TAG_CONTEXT_SPECIFIC, 2, &cur->typeOfChargingInfo);
+	XSEQUENCE_OPT_1(ParseAOCDBillingId, ASN1_TAG_CONTEXT_SPECIFIC, 3, &cur->billingId);
 
 	return p - beg;
 }
@@ -90,7 +90,7 @@
 	XCHOICE_1(ParseAOCDSpecificCurrency, ASN1_TAG_SEQUENCE, ASN1_NOT_TAGGED, cur);
 
 	cur->freeOfCharge = 1;
-	XCHOICE(ParseNull, ASN1_TAG_NULL, 1); // freeOfCharge
+	XCHOICE(ParseNull, ASN1_TAG_CONTEXT_SPECIFIC, 1); // freeOfCharge
 	cur->freeOfCharge = 0;
 	XCHOICE_DEFAULT;
 }
@@ -102,9 +102,9 @@
 {
 	INIT;
 
-	XSEQUENCE_1(ParseRecordedUnitsList, ASN1_TAG_SEQUENCE, 1, &chu->recordedUnits);
-	XSEQUENCE_1(ParseTypeOfChargingInfo, ASN1_TAG_ENUM, 2, &chu->typeOfChargingInfo);
-	XSEQUENCE_OPT_1(ParseAOCDBillingId, ASN1_TAG_ENUM, 3, &chu->billingId);
+	XSEQUENCE_1(ParseRecordedUnitsList, ASN1_TAG_CONTEXT_SPECIFIC | ASN1_TAG_CONSTRUCTED, 1, &chu->recordedUnits);
+	XSEQUENCE_1(ParseTypeOfChargingInfo, ASN1_TAG_CONTEXT_SPECIFIC, 2, &chu->typeOfChargingInfo);
+	XSEQUENCE_OPT_1(ParseAOCDBillingId, ASN1_TAG_CONTEXT_SPECIFIC, 3, &chu->billingId);
 
 //	p_L3L4(pc, CC_CHARGE | INDICATION, &recordedUnits);
 
@@ -119,7 +119,7 @@
 	XCHOICE_1(ParseAOCDSpecificChargingUnits, ASN1_TAG_SEQUENCE, ASN1_NOT_TAGGED, chu);
 
 	chu->freeOfCharge = 1;
-	XCHOICE(ParseNull, ASN1_TAG_NULL, 1); // freeOfCharge
+	XCHOICE(ParseNull, ASN1_TAG_CONTEXT_SPECIFIC, 1); // freeOfCharge
 	chu->freeOfCharge = 0;
 
 	XCHOICE_DEFAULT;
@@ -132,8 +132,8 @@
 {
 	INIT;
 
-	XSEQUENCE_1(ParseCurrency, ASN1_TAG_IA5_STRING, 1, (char *)cur->currency);
-	XSEQUENCE_1(ParseAmount, ASN1_TAG_SEQUENCE, 2, cur);
+	XSEQUENCE_1(ParseCurrency, ASN1_TAG_CONTEXT_SPECIFIC, 1, (char *)cur->currency);
+	XSEQUENCE_1(ParseAmount, ASN1_TAG_CONTEXT_SPECIFIC | ASN1_TAG_CONSTRUCTED, 2, cur);
 
 	return p - beg;
 }
@@ -207,8 +207,8 @@
 	int billingId;
 	INIT;
 
-	XSEQUENCE(ParseRecordedCurrency, ASN1_TAG_SEQUENCE, 1);
-	XSEQUENCE_OPT_1(ParseAOCEBillingId, ASN1_TAG_ENUM, 2, &billingId);
+	XSEQUENCE(ParseRecordedCurrency, ASN1_TAG_CONTEXT_SPECIFIC | ASN1_TAG_CONSTRUCTED, 1);
+	XSEQUENCE_OPT_1(ParseAOCEBillingId, ASN1_TAG_CONTEXT_SPECIFIC, 2, &billingId);
 
 	return p - beg;
 }
@@ -219,7 +219,7 @@
 	INIT;
 
 	XCHOICE(ParseAOCESpecificCurrency, ASN1_TAG_SEQUENCE, ASN1_NOT_TAGGED);
-	XCHOICE(ParseNull, ASN1_TAG_NULL, 1); // freeOfCharge
+	XCHOICE(ParseNull, ASN1_TAG_CONTEXT_SPECIFIC, 1); // freeOfCharge
 	XCHOICE_DEFAULT;
 }
 
@@ -243,8 +243,8 @@
 	int billingId;
 	INIT;
 
-	XSEQUENCE_1(ParseRecordedUnitsList, ASN1_TAG_SEQUENCE, 1, &recordedUnits);
-	XSEQUENCE_OPT_1(ParseAOCEBillingId, ASN1_TAG_ENUM, 2, &billingId);
+	XSEQUENCE_1(ParseRecordedUnitsList, ASN1_TAG_CONTEXT_SPECIFIC | ASN1_TAG_CONSTRUCTED, 1, &recordedUnits);
+	XSEQUENCE_OPT_1(ParseAOCEBillingId, ASN1_TAG_CONTEXT_SPECIFIC, 2, &billingId);
 
 //	p_L3L4(pc, CC_CHARGE | INDICATION, &recordedUnits);
 
@@ -257,7 +257,7 @@
 	INIT;
 
 	XCHOICE(ParseAOCESpecificChargingUnits, ASN1_TAG_SEQUENCE, ASN1_NOT_TAGGED);
-	XCHOICE(ParseNull, ASN1_TAG_NULL, 1); // freeOfCharge
+	XCHOICE(ParseNull, ASN1_TAG_CONTEXT_SPECIFIC, 1); // freeOfCharge
 	XCHOICE_DEFAULT;
 }
 
@@ -285,7 +285,11 @@
 int
 ParseCurrency(struct asn1_parm *pc, u_char *p, u_char *end, char *currency)
 {
-	return ParseIA5String(pc, p, end, currency);
+	struct asn1ParseString str;
+
+	str.buf = currency;
+	str.maxSize = 11;/* sizeof(struct FacAOCDCurrency.currency) */
+	return ParseIA5String(pc, p, end, &str);
 }
 
 // Amount
@@ -295,8 +299,8 @@
 {
 	INIT;
 
-	XSEQUENCE_1(ParseCurrencyAmount, ASN1_TAG_INTEGER, 1, &cur->currencyAmount);
-	XSEQUENCE_1(ParseMultiplier, ASN1_TAG_INTEGER, 2, &cur->multiplier);
+	XSEQUENCE_1(ParseCurrencyAmount, ASN1_TAG_CONTEXT_SPECIFIC, 1, &cur->currencyAmount);
+	XSEQUENCE_1(ParseMultiplier, ASN1_TAG_CONTEXT_SPECIFIC, 2, &cur->multiplier);
 
 	return p - beg;
 }
@@ -341,7 +345,7 @@
 //	char partyNumber[30];
 	INIT;
 
-//	XCHOICE_1(ParsePartyNumber, ASN1_TAG_SEQUENCE, 0, partyNumber);
+//	XCHOICE_1(ParsePartyNumber, ASN1_TAG_CONTEXT_SPECIFIC | ASN1_TAG_CONSTRUCTED, 0, partyNumber);
 	XCHOICE(ParseChargeIdentifier, ASN1_TAG_INTEGER, ASN1_NOT_TAGGED);
 	XCHOICE_DEFAULT;
 }

Added: mISDNuser/trunk/suppserv/asn1_ccbs.c
URL: http://svn.digium.com/view/thirdparty/mISDNuser/trunk/suppserv/asn1_ccbs.c?view=auto&rev=26
==============================================================================
--- mISDNuser/trunk/suppserv/asn1_ccbs.c (added)
+++ mISDNuser/trunk/suppserv/asn1_ccbs.c Thu Oct 23 12:04:35 2008
@@ -1,0 +1,1846 @@
+/*
+ * $Id$
+ *
+ * CCBS Supplementary Services ETS 300 359-1
+ * CCNR Supplementary Services ETS 301 065-1
+ *
+ * CCBS/CCNR Facility ie encode/decode
+ */
+
+#include "asn1.h"
+#include "asn1_ccbs.h"
+#include "l3dss1.h"
+#include <stdio.h>
+#include <string.h>
+
+/* ------------------------------------------------------------------- */
+
+
+
+
+/* ******************************************************************* */
+/*!
+ * \internal
+ * \brief Encode the Q.931 ie values used for CCBS/CCNR.
+ *
+ * \param Dest Where to put the encoding
+ * \param Q931ie Q931 ie information to encode.
+ *
+ * \retval length
+ */
+static int encodeQ931ie(__u8 *Dest, const struct Q931_Bc_Hlc_Llc *Q931ie)
+{
+	__u8 *p;
+
+	/* [APPLICATION 0] IMPLICIT OCTET STRING */
+	Dest[0] = ASN1_TAG_APPLICATION_WIDE | 0;
+
+	/* Store value */
+	p = &Dest[2];
+	if (Q931ie->Bc.Length) {
+		*p++ = 0x04; /* Q.931 Bearer Capability ie tag */
+		*p++ = Q931ie->Bc.Length;
+		memcpy(p, Q931ie->Bc.Contents, Q931ie->Bc.Length);
+		p += Q931ie->Bc.Length;
+	}
+	if (Q931ie->Llc.Length) {
+		*p++ = 0x7C; /* Q.931 Low Layer Compatibility ie tag */
+		*p++ = Q931ie->Llc.Length;
+		memcpy(p, Q931ie->Llc.Contents, Q931ie->Llc.Length);
+		p += Q931ie->Llc.Length;
+	}
+	if (Q931ie->Hlc.Length) {
+		*p++ = 0x7D; /* Q.931 High Layer Compatibility ie tag */
+		*p++ = Q931ie->Hlc.Length;
+		memcpy(p, Q931ie->Hlc.Contents, Q931ie->Hlc.Length);
+		p += Q931ie->Hlc.Length;
+	}
+
+	/* length */
+	Dest[1] = p - &Dest[2];
+
+	return p - Dest;
+}	/* end encodeQ931ie() */
+
+
+
+
+/* ******************************************************************* */
+/*!
+ * \internal
+ * \brief Parse the Q.931 argument contents.
+ *
+ * \param pc Complete component message storage data.
+ * \param p Starting buffer position to parse arguments
+ * \param end End buffer position that must not go past.
+ * \param Q931ie Parameter storage to fill.
+ *
+ * \retval length of buffer consumed
+ * \retval -1 on error.
+ */
+static int ParseQ931ie(struct asn1_parm *pc, u_char *p, u_char *end, struct Q931_Bc_Hlc_Llc *Q931ie)
+{
+	__u8 Ie_type;
+	size_t Length;
+	INIT;
+
+	memset(Q931ie, 0, sizeof(*Q931ie));
+	do {
+		if (end < p + 2) {
+			/* Q.931 ie length error */
+			return -1;
+		}
+		Ie_type = *p++;
+		Length = *p++;
+		if (end < p + Length) {
+			/* Q.931 ie length error */
+			return -1;
+		}
+		switch (Ie_type) {
+		case 0x04: /* Q.931 Bearer Capability ie tag */
+			if (Length <= sizeof(Q931ie->Bc.Contents)) {
+				Q931ie->Bc.Length = Length;
+				memcpy(Q931ie->Bc.Contents, p, Length);
+			}
+			break;
+		case 0x7C: /* Q.931 Low Layer Compatibility ie tag */
+			if (Length <= sizeof(Q931ie->Llc.Contents)) {
+				Q931ie->Llc.Length = Length;
+				memcpy(Q931ie->Llc.Contents, p, Length);
+			}
+			break;
+		case 0x7D: /* Q.931 High Layer Compatibility ie tag */
+			if (Length <= sizeof(Q931ie->Hlc.Contents)) {
+				Q931ie->Hlc.Length = Length;
+				memcpy(Q931ie->Hlc.Contents, p, Length);
+			}
+			break;
+		default:
+			/* Unknown Q.931 ie in CCBS message */
+			break;
+		}	/* end switch */
+		p += Length;
+	} while (p < end);
+
+	return p - beg;
+}	/* end ParseQ931ie() */
+
+
+
+
+/* ******************************************************************* */
+/*!
+ * \internal
+ * \brief Parse the NumberDigits PartyNumber argument parameters.
+ *
+ * \param pc Complete component message storage data.
+ * \param p Starting buffer position to parse arguments
+ * \param end End buffer position that must not go past.
+ * \param PartyNumber Parameter storage to fill.
+ *
+ * \retval length of buffer consumed
+ * \retval -1 on error.
+ */
+static int ParseNumberDigits_Full(struct asn1_parm *pc, u_char *p, u_char *end, struct FacPartyNumber *PartyNumber)
+{
+	struct asn1ParseString Number;
+	int LengthConsumed;
+
+	Number.buf = (char *) PartyNumber->Number;
+	Number.maxSize = sizeof(PartyNumber->Number);
+	Number.length = 0;
+	LengthConsumed = ParseNumericString(pc, p, end, &Number);
+	PartyNumber->LengthOfNumber = Number.length;
+	return LengthConsumed;
+}	/* end ParseNumberDigits_Full() */
+
+
+
+
+/* ******************************************************************* */
+/*!
+ * \internal
+ * \brief Parse the NSAP PartyNumber argument parameters.
+ *
+ * \param pc Complete component message storage data.
+ * \param p Starting buffer position to parse arguments
+ * \param end End buffer position that must not go past.
+ * \param PartyNumber Parameter storage to fill.
+ *
+ * \retval length of buffer consumed
+ * \retval -1 on error.
+ */
+static int ParseNSAPPartyNumber(struct asn1_parm *pc, u_char *p, u_char *end, struct FacPartyNumber *PartyNumber)
+{
+	struct asn1ParseString Number;
+	int LengthConsumed;
+
+	Number.buf = (char *) PartyNumber->Number;
+	Number.maxSize = sizeof(PartyNumber->Number);
+	Number.length = 0;
+	LengthConsumed = ParseOctetString(pc, p, end, &Number);
+	PartyNumber->LengthOfNumber = Number.length;
+	return LengthConsumed;
+}	/* end ParseNSAPPartyNumber() */
+
+
+
+
+/* ******************************************************************* */
+/*!
+ * \internal
+ * \brief Encode the public or private network PartyNumber type.
+ *
+ * \param Dest Where to put the encoding
+ * \param Number
+ * \param LengthOfNumber
+ * \param TypeOfNumber
+ *
+ * \retval length
+ */
+static int encodeNetworkPartyNumber(__u8 *Dest, const __s8 *Number, __u8 LengthOfNumber, __u8 TypeOfNumber)
+{
+	__u8 *p;
+
+	Dest[0] = ASN1_TAG_SEQUENCE;
+	p = &Dest[2];
+	p += encodeEnum(p, ASN1_TAG_ENUM, TypeOfNumber);
+	p += encodeNumericString(p, ASN1_TAG_NUMERIC_STRING, Number, LengthOfNumber);
+
+	/* length */
+	Dest[1] = p - &Dest[2];
+
+	return p - Dest;
+}	/* end encodeNetworkPartyNumber() */
+
+
+
+
+/* ******************************************************************* */
+/*!
+ * \internal
+ * \brief Parse the public or private network PartyNumber argument parameters.
+ *
+ * \param pc Complete component message storage data.
+ * \param p Starting buffer position to parse arguments
+ * \param end End buffer position that must not go past.
+ * \param PartyNumber Parameter storage to fill.
+ *
+ * \retval length of buffer consumed
+ * \retval -1 on error.
+ */
+static int ParseNetworkPartyNumber(struct asn1_parm *pc, u_char *p, u_char *end, struct FacPartyNumber *PartyNumber)
+{
+	int TypeOfNumber;
+	INIT;
+
+	XSEQUENCE_1(ParseEnum, ASN1_TAG_ENUM, ASN1_NOT_TAGGED, &TypeOfNumber);
+	PartyNumber->TypeOfNumber = TypeOfNumber;
+	XSEQUENCE_1(ParseNumberDigits_Full, ASN1_TAG_NUMERIC_STRING, ASN1_NOT_TAGGED, PartyNumber);
+
+	return p - beg;
+}	/* end ParseNetworkPartyNumber() */
+
+
+
+
+/* ******************************************************************* */
+/*!
+ * \internal
+ * \brief Encode the PartyNumber type.
+ *
+ * \param Dest Where to put the encoding
+ * \param PartyNumber Number information to encode.
+ *
+ * \retval length
+ */
+static int encodePartyNumber_Full(__u8 *Dest, const struct FacPartyNumber *PartyNumber)
+{
+	int Length;
+
+	switch (PartyNumber->Type) {
+	case 0: /* Unknown PartyNumber */
+		Length = encodeNumericString(Dest, ASN1_TAG_CONTEXT_SPECIFIC | 0, (const __s8 *) PartyNumber->Number, PartyNumber->LengthOfNumber);
+		break;
+	case 1: /* Public PartyNumber */
+		Length = encodeNetworkPartyNumber(Dest, (const __s8 *) PartyNumber->Number, PartyNumber->LengthOfNumber, PartyNumber->TypeOfNumber);
+		Dest[0] &= ASN1_TAG_CONSTRUCTED;
+		Dest[0] |= ASN1_TAG_CONTEXT_SPECIFIC | 1;
+		break;
+	case 2: /* NSAP encoded PartyNumber */
+		Length = encodeOctetString(Dest, ASN1_TAG_CONTEXT_SPECIFIC | 2, (const __s8 *) PartyNumber->Number, PartyNumber->LengthOfNumber);
+		break;
+	case 3: /* Data PartyNumber (Not used) */
+		Length = encodeNumericString(Dest, ASN1_TAG_CONTEXT_SPECIFIC | 3, (const __s8 *) PartyNumber->Number, PartyNumber->LengthOfNumber);
+		break;
+	case 4: /* Telex PartyNumber (Not used) */
+		Length = encodeNumericString(Dest, ASN1_TAG_CONTEXT_SPECIFIC | 4, (const __s8 *) PartyNumber->Number, PartyNumber->LengthOfNumber);
+		break;
+	case 5: /* Private PartyNumber */
+		Length = encodeNetworkPartyNumber(Dest, (const __s8 *) PartyNumber->Number, PartyNumber->LengthOfNumber, PartyNumber->TypeOfNumber);
+		Dest[0] &= ASN1_TAG_CONSTRUCTED;
+		Dest[0] |= ASN1_TAG_CONTEXT_SPECIFIC | 5;
+		break;
+	case 8: /* National Standard PartyNumber (Not used) */
+		Length = encodeNumericString(Dest, ASN1_TAG_CONTEXT_SPECIFIC | 8, (const __s8 *) PartyNumber->Number, PartyNumber->LengthOfNumber);
+		break;
+	default:
+		Length = 0;
+		break;
+	}	/* end switch */
+
+	return Length;
+}	/* end encodePartyNumber_Full() */
+
+
+
+
+/* ******************************************************************* */
+/*!
+ * \internal
+ * \brief Parse the PartyNumber argument parameters.
+ *
+ * \param pc Complete component message storage data.
+ * \param p Starting buffer position to parse arguments
+ * \param end End buffer position that must not go past.
+ * \param PartyNumber Parameter storage to fill.
+ *
+ * \retval length of buffer consumed
+ * \retval -1 on error.
+ */
+static int ParsePartyNumber_Full(struct asn1_parm *pc, u_char *p, u_char *end, struct FacPartyNumber *PartyNumber)
+{
+	INIT;
+
+	PartyNumber->Type = 0;/* Unknown PartyNumber */
+	XCHOICE_1(ParseNumberDigits_Full, ASN1_TAG_CONTEXT_SPECIFIC, 0, PartyNumber);
+	PartyNumber->Type = 1;/* Public PartyNumber */
+	XCHOICE_1(ParseNetworkPartyNumber, ASN1_TAG_CONTEXT_SPECIFIC | ASN1_TAG_CONSTRUCTED, 1, PartyNumber);
+	PartyNumber->Type = 2;/* NSAP encoded PartyNumber */
+	XCHOICE_1(ParseNSAPPartyNumber, ASN1_TAG_CONTEXT_SPECIFIC, 2, PartyNumber);
+	PartyNumber->Type = 3;/* Data PartyNumber (Not used) */
+	XCHOICE_1(ParseNumberDigits_Full, ASN1_TAG_CONTEXT_SPECIFIC, 3, PartyNumber);
+	PartyNumber->Type = 4;/* Telex PartyNumber (Not used) */
+	XCHOICE_1(ParseNumberDigits_Full, ASN1_TAG_CONTEXT_SPECIFIC, 4, PartyNumber);
+	PartyNumber->Type = 5;/* Private PartyNumber */
+	XCHOICE_1(ParseNetworkPartyNumber, ASN1_TAG_CONTEXT_SPECIFIC | ASN1_TAG_CONSTRUCTED, 5, PartyNumber);
+	PartyNumber->Type = 8;/* National Standard PartyNumber (Not used) */
+	XCHOICE_1(ParseNumberDigits_Full, ASN1_TAG_CONTEXT_SPECIFIC, 8, PartyNumber);
+
+	XCHOICE_DEFAULT;
+}	/* end ParsePartyNumber_Full() */
+
+
+
+
+/* ******************************************************************* */
+/*!
+ * \internal
+ * \brief Parse the User information string PartySubaddress argument parameters.
+ *
+ * \param pc Complete component message storage data.
+ * \param p Starting buffer position to parse arguments
+ * \param end End buffer position that must not go past.
+ * \param PartySubaddress Parameter storage to fill.
+ *
+ * \retval length of buffer consumed
+ * \retval -1 on error.
+ */

[... 4184 lines stripped ...]



More information about the thirdparty-commits mailing list