Source code of Windows XP (NT5)
You can not select more than 25 topics Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.

414 lines
19 KiB

  1. /*
  2. * Copyright (C) 1995-1999 Open Systems Solutions, Inc. All rights reserved.
  3. *
  4. * FILE: @(#)iaapi.h 5.3.1.1 97/03/18
  5. */
  6. /* THIS FILE IS PROPRIETARY MATERIAL OF OPEN SYSTEMS SOLUTIONS, INC. AND
  7. * MAY BE USED ONLY BY DIRECT LICENSEES OF OPEN SYSTEMS SOLUTIONS, INC.
  8. * THIS FILE MAY NOT BE DISTRIBUTED. */
  9. /*****************************************************************************/
  10. /* */
  11. /* Declare the types used in the Interpretive ASN.1 API */
  12. /* */
  13. /*****************************************************************************/
  14. #ifndef IAAPI_H
  15. #define IAAPI_H
  16. #if _MSC_VER > 1000
  17. #pragma once
  18. #endif
  19. #ifndef ASN1CODE_H
  20. #include "asn1code.h"
  21. #endif
  22. #ifndef ASN1HDR_H
  23. #include "asn1hdr.h"
  24. #endif
  25. typedef void *TypeHndl; /* handle used in referencing types */
  26. #define INDEFLENGTH -1 /* This value is returned by encodingLength()
  27. * for INDEFINITE length encoded values. */
  28. /* ASN.1 builtin types sorted alphabetically and assigned an enumerator */
  29. typedef enum ASN1Type {
  30. asn1UnknownType = 0,
  31. asn1ANY = 1, asn1NumericString = 17,
  32. asn1BIT_STRING = 2, asn1OBJECT_IDENTIFIER = 18,
  33. asn1BMPString = 3, asn1OCTET_STRING = 19,
  34. asn1BOOLEAN = 4, asn1ObjectDescriptor = 20,
  35. asn1CHARACTER_STRING = 5, asn1OpenType = 21,
  36. asn1CHOICE = 6, asn1PrintableString = 22,
  37. asn1EMBEDDED_PDV = 7, asn1REAL = 23,
  38. asn1ENUMERATED = 8, asn1SEQUENCE = 24,
  39. asn1EXTERNAL = 9, asn1SEQUENCE_OF = 25,
  40. asn1GeneralString = 10, asn1SET = 26,
  41. asn1GeneralizedTime = 11, asn1SET_OF = 27,
  42. asn1GraphicString = 12, asn1TeletexString = 28,
  43. asn1IA5String = 13, asn1UTCTime = 29,
  44. asn1INSTANCE_OF = 14, asn1UniversalString = 30,
  45. asn1INTEGER = 15, asn1VideotexString = 31,
  46. asn1NULL = 16, asn1VisibleString = 32
  47. } ASN1Type;
  48. /* Types compatible codes */
  49. typedef enum TypesCompatibilityCodes {
  50. compatible = 0, /* Types are compatible */
  51. differentTypes = 1, /* Types are not identical */
  52. defaultsDifferent = 2, /* Default values are not the same */
  53. onlyOneHasDefault = 3, /* Only one type has a default value */
  54. oneHasPointerOtherDoesnt = 4, /* Only one type has a POINTER directive */
  55. numberOfComponentsDifferent = 5, /* Different number of components */
  56. oneIsOptionalOtherIsnt = 6, /* Only one type is OPTIONAL */
  57. oneIsExtensibleOtherIsnt = 7, /* Only one type is extensible */
  58. differentNamedItems = 8, /* Different component identifiers */
  59. differentKinds = 9, /* Different type representations */
  60. componentsHaveDifferentKinds = 10,/* Different component representations */
  61. differentSubIdNumber = 11, /* Different number of sub-identifiers in
  62. * an OBJECT IDENTIFIER with the OBJECTID
  63. * directive */
  64. differentSubIdTypes = 12, /* Different types of sub-identifiers in
  65. * an OBJECT IDENTIFIER with the OBJECTID
  66. * directive */
  67. differentSize = 13, /* Different size of INTEGER or REAL values */
  68. type1IsPointerOfTypeRef2 = 14, /* Two types reference the other
  69. * type but the first one has the
  70. * POINTER directive */
  71. type2IsPointerOfTypeRef1 = 15, /* Two types reference the other type
  72. * but the second one has the POINTER
  73. * directive */
  74. differentSizeOfLengthField = 16 /* Different sizes of the length field in
  75. * type representations */
  76. } TypesCompatibilityCodes;
  77. /* ASN.1 tag classes */
  78. typedef enum ASN1TagClass {
  79. UNIVERSAL, APPLICATION, CONTEXT_SPECIFIC, PRIVATE, NULLENCODING
  80. } ASN1TagClass;
  81. typedef int IAAPI_ERRTYPE; /* Datatype for IAAPI error codes */
  82. /* IAAPI ERROR CODES */
  83. #define IAAPI_NOERROR 0 /* No error occurred */
  84. #define IAAPI_OUTMEMORY 1 /* No more memory can be allocated */
  85. #define IAAPI_BADBIT 2 /* Bad bit string or hex string */
  86. #define IAAPI_BADBOOLEAN 3 /* Not TRUE or FALSE value */
  87. #define IAAPI_BADNULL 4 /* Not "NULL" value */
  88. #define IAAPI_TOOBIG 5 /* Value exceeds size constraint */
  89. #define IAAPI_BADREAL 6 /* Not a valid REAL value */
  90. #define IAAPI_BADTIME 7 /* Not a valid UTCTime or GeneralizedTime */
  91. #define IAAPI_BADOBJID 8 /* Not a valid OBJECT IDENTIFIER value */
  92. #define IAAPI_BADANY 9 /* Bad ANY value */
  93. #define IAAPI_BADNAME 10 /* Bad INTEGER or ENUMERATED name */
  94. #define IAAPI_BADNMD 11 /* Bad BIT STRING NAMED NUMBER value */
  95. #define IAAPI_NOTSUP 12 /* Type not supported */
  96. #define IAAPI_BADNUM 13 /* Bad INTEGER or ENUMERATED number */
  97. #define IAAPI_BADINDX 14 /* Bad component index into a structured type */
  98. #define IAAPI_BADDEC 15 /* Bad decoded value, possibly NULL */
  99. #define IAAPI_ENCFAL 16 /* Failure to encode value */
  100. #define IAAPI_NLENC 17 /* Null encoding or length is 0 */
  101. #define IAAPI_DECFAL 18 /* Decoding failed */
  102. #define IAAPI_BADTGINDX 19 /* Bad tag number index into encoded value */
  103. #define IAAPI_BADTYPE 20 /* Incorrect type handle for the function */
  104. #define IAAPI_CPYFAIL 21 /* Copying a decoded value failed */
  105. #define IAAPI_NOTCOMPATIBLE 22 /* Types are not compatible */
  106. #define IAAPI_BADDISPLAYVALUE 23 /* Failure to parse a PDU display value */
  107. #define IAAPI_BADIDENTIFIER 24 /* Bad identifier in a parsing display value */
  108. #define IAAPI_DUPLCOMPVALUE 25 /* Duplicate value for one component in a parsing value*/
  109. #define IAAPI_ENCOPENTYPEORANYFAILED 26 /* Encoding failed for ANY or open type value*/
  110. #define IAAPI_FREETPFAL 27 /* Failure to free decoded value */
  111. #define IAAPI_BADENC 28 /* Error exists in the encoded data */
  112. #define IAAPI_BADHINT 29 /* Bad HUGE INTEGER value */
  113. #define IAAPI_BADENCOID 30 /* Bad ENCODED OBJECT IDENTIFIER value */
  114. #define IAAPI_BADOBJ 31 /* Object can not be marked */
  115. #define IAAPI_UNKNOWNOBJ 32 /* Invalid object handle */
  116. #define IAAPI_MEM_ERROR 33 /* Memory violation error occurred */
  117. #define IAAPI_ACCESS_SERIALIZATION 34 /* Access serialization error occurred */
  118. #if defined(_MSC_VER) && (defined(_WIN32) || defined(WIN32))
  119. #pragma pack(push, ossPacking, 4)
  120. #elif defined(_MSC_VER) && (defined(_WINDOWS) || defined(_MSDOS))
  121. #pragma pack(1)
  122. #elif defined(__BORLANDC__) && defined(__MSDOS__)
  123. #pragma option -a1
  124. #elif defined(__BORLANDC__) && defined(__WIN32__)
  125. #pragma option -a4
  126. #elif defined(__IBMC__)
  127. #pragma pack(4)
  128. #elif defined(__WATCOMC__) && defined(__NT__)
  129. #pragma pack(push, 4)
  130. #elif defined(__WATCOMC__) && (defined(__WINDOWS__) || defined(__DOS__))
  131. #pragma pack(push, 1)
  132. #endif /* _MSC_VER && _WIN32 */
  133. #ifdef macintosh
  134. #pragma options align=mac68k
  135. #endif
  136. /* Structure for holding values of type INTEGER */
  137. typedef struct IntValue {
  138. enum {signedNumber, unsignedNumber} sign;
  139. union {
  140. LONG_LONG signedInt;
  141. ULONG_LONG unsignedInt;
  142. } value;
  143. } IntValue;
  144. /* Structure for IAAPI initialization values */
  145. typedef struct IAAPI_initializers {
  146. char charInitializer;
  147. short shortInitializer;
  148. int intInitializer;
  149. long longInitializer;
  150. LONG_LONG llongInitializer;
  151. void * pointerInitializer;
  152. char * floatInitializer;
  153. char * doubleInitializer;
  154. } IAAPI_initializers;
  155. /*
  156. * Type definition for a value reference structure.
  157. */
  158. typedef struct ValRef {
  159. char *name; /* value reference name */
  160. void *address; /* pointer to decoded value */
  161. unsigned short etype; /* index into etype array */
  162. } ValRef;
  163. /* Union containing the different types for an object value */
  164. typedef union IaapiObjValType {
  165. char * fileName;
  166. int socketIdentifier;
  167. } IaapiObjValType;
  168. #if defined(_MSC_VER) && (defined(_WIN32) || defined(WIN32))
  169. #pragma pack(pop, ossPacking)
  170. #elif defined(_MSC_VER) && (defined(_WINDOWS) || defined(_MSDOS))
  171. #pragma pack()
  172. #elif defined(__BORLANDC__) && (defined(__WIN32__) || defined(__MSDOS__))
  173. #pragma option -a.
  174. #elif defined(__IBMC__)
  175. #pragma pack()
  176. #elif defined(__WATCOMC__)
  177. #pragma pack(pop)
  178. #endif /* _MSC_VER && _WIN32 */
  179. #ifdef macintosh
  180. #pragma options align=reset
  181. #endif
  182. #ifdef __cplusplus
  183. extern "C" {
  184. #endif
  185. /***************************************************/
  186. /* Functions defined by the Interpretive ASN.1 API */
  187. /***************************************************/
  188. extern int DLL_ENTRY ossDefaultIAAPI_ERR(OssGlobal *world, int return_code);
  189. extern void *DLL_ENTRY ossGetIaapiErrorHandlingFunction(OssGlobal *world);
  190. extern void DLL_ENTRY ossSetIaapiErrorHandlingFunction(OssGlobal *world,
  191. int (DLL_ENTRY_FPTR *_System func)
  192. (OssGlobal *, int error_code));
  193. extern void DLL_ENTRY ossSetInitializationValues(OssGlobal *world,
  194. IAAPI_initializers *initStruct);
  195. extern void DLL_ENTRY ossTermIAAPI(OssGlobal *world);
  196. extern unsigned short DLL_ENTRY ossCtlTblVersionNumber(OssGlobal *world);
  197. extern ossBoolean DLL_ENTRY ossCtlTblUsableOnlyByPER(OssGlobal *world);
  198. extern ossBoolean DLL_ENTRY ossCtlTblUsableOnlyByBER(OssGlobal *world);
  199. extern ossBoolean DLL_ENTRY ossDebugWasSpecified(OssGlobal *world);
  200. extern ossBoolean DLL_ENTRY ossConstrainWasSpecified(OssGlobal *world);
  201. extern int DLL_ENTRY ossNumberOfPDUs(OssGlobal *world);
  202. extern TypeHndl DLL_ENTRY ossTypeHandleOfPDU(OssGlobal *world, int pduNum);
  203. extern TypeHndl DLL_ENTRY ossPduTypeHandleByName(OssGlobal *world, const char *name);
  204. extern int DLL_ENTRY ossPduNumberByType(OssGlobal *world, TypeHndl type);
  205. extern ossBoolean DLL_ENTRY ossTypeIsConstrained(OssGlobal *world, TypeHndl type);
  206. extern ASN1Type DLL_ENTRY ossAsn1TypeId(OssGlobal *world, TypeHndl type);
  207. extern const char *DLL_ENTRY ossBuiltinTypeName(OssGlobal *world, ASN1Type typeId);
  208. extern const char *DLL_ENTRY ossTypeReferenceName(OssGlobal *world, TypeHndl type);
  209. extern TypesCompatibilityCodes DLL_ENTRY ossTypesCompatible(OssGlobal *world,
  210. TypeHndl type1, TypeHndl type2);
  211. extern int DLL_ENTRY ossNumberOfNamedItems(OssGlobal *world, TypeHndl type);
  212. extern TypeHndl DLL_ENTRY ossTypeHandleOfComponent(OssGlobal *world,
  213. TypeHndl parent, unsigned int ix);
  214. extern ossBoolean DLL_ENTRY ossComponentIsOptional(OssGlobal *world,
  215. TypeHndl type, unsigned int ix);
  216. extern ossBoolean DLL_ENTRY ossComponentHasDefaultValue(OssGlobal *world,
  217. TypeHndl parentType, unsigned int ix);
  218. extern void *DLL_ENTRY ossComponentDefaultValue(OssGlobal *world,
  219. TypeHndl parentType, unsigned int ix);
  220. extern ossBoolean DLL_ENTRY ossComponentValueIsPresent(OssGlobal *world,
  221. TypeHndl parentType, unsigned int ix,
  222. void *parentValue);
  223. extern ossBoolean DLL_ENTRY ossComponentIsInitializationValue(OssGlobal *world,
  224. TypeHndl chldType, void *compAddress);
  225. extern unsigned int DLL_ENTRY ossItemIndexByName(OssGlobal *world,
  226. TypeHndl type, const char *name);
  227. extern const char *DLL_ENTRY ossAsn1ItemName(OssGlobal *world, TypeHndl type,
  228. unsigned int ix);
  229. extern long DLL_ENTRY ossItemIntValue(OssGlobal *world, TypeHndl type,
  230. unsigned int ix);
  231. extern ossBoolean DLL_ENTRY ossExtensionMarkerIsPresent(OssGlobal *world,
  232. TypeHndl type);
  233. extern int DLL_ENTRY ossNumberOfRootItems(OssGlobal *world, TypeHndl type);
  234. extern ossBoolean DLL_ENTRY ossCompAppearsAfterExtensionMarker(OssGlobal *world,
  235. TypeHndl type, unsigned int ix);
  236. extern int DLL_ENTRY ossNumberOfTags(OssGlobal *world, TypeHndl type);
  237. extern int DLL_ENTRY ossAsn1TagNumber(OssGlobal *world, TypeHndl type,
  238. unsigned int ix);
  239. extern ASN1TagClass DLL_ENTRY ossAsn1TagClass(OssGlobal *world, TypeHndl type,
  240. unsigned int ix);
  241. extern ossBoolean DLL_ENTRY ossUpperBoundIsPresent(OssGlobal *world, TypeHndl type);
  242. extern ossBoolean DLL_ENTRY ossLowerBoundIsPresent(OssGlobal *world, TypeHndl type);
  243. extern unsigned long DLL_ENTRY ossLowerBoundOfSizeConstraint(OssGlobal *world,
  244. TypeHndl type);
  245. extern unsigned long DLL_ENTRY ossUpperBoundOfSizeConstraint(OssGlobal *world,
  246. TypeHndl type);
  247. extern IntValue DLL_ENTRY ossMinValueOfInteger(OssGlobal *world, TypeHndl type);
  248. extern IntValue DLL_ENTRY ossMaxValueOfInteger(OssGlobal *world, TypeHndl type);
  249. extern unsigned long DLL_ENTRY ossPermittedAlphabetLength(OssGlobal *world,
  250. TypeHndl type);
  251. extern const long *DLL_ENTRY ossPermittedAlphabetConstraint(OssGlobal *world,
  252. TypeHndl type);
  253. extern unsigned short DLL_ENTRY ossGetNumberOfValueReferences(OssGlobal *world);
  254. extern const char *DLL_ENTRY ossGetNameOfValueReference(OssGlobal *world,
  255. unsigned short int compIndex);
  256. extern const void *DLL_ENTRY ossGetDecodedValueOfValueReference(OssGlobal *world,
  257. unsigned short int compIndex);
  258. extern TypeHndl DLL_ENTRY ossGetTypeHandleOfValueReference(OssGlobal *world,
  259. unsigned short int compIndex);
  260. extern IAAPI_ERRTYPE DLL_ENTRY ossPutDecodedValueOfPDU(OssGlobal *world,
  261. int pduNum, char *remainingBuf, void **pduVal);
  262. extern IAAPI_ERRTYPE DLL_ENTRY ossPutSimpleTypeValue(OssGlobal *world,
  263. TypeHndl type, char *userTypedvalue,
  264. void **decodedValue);
  265. extern IAAPI_ERRTYPE DLL_ENTRY ossPutStructTypeValue(OssGlobal *world,
  266. TypeHndl parent, void *compValue,
  267. unsigned int compIndex, void **structToUpdate);
  268. extern IAAPI_ERRTYPE DLL_ENTRY ossDeleteComponent(OssGlobal *world,
  269. TypeHndl parentType, unsigned int compIndex,
  270. void **parentValue);
  271. extern IAAPI_ERRTYPE DLL_ENTRY ossPutOpenTypeDecodedValue(OssGlobal *world,
  272. TypeHndl type, int pduNum, void *decodedValue,
  273. OpenType **openValue);
  274. extern IAAPI_ERRTYPE DLL_ENTRY ossPutEncodedValue(OssGlobal *world,
  275. TypeHndl type, OssBuf encodedValue,
  276. void **decodedValue);
  277. extern char *DLL_ENTRY ossGetValueOfSimpleType(OssGlobal *world, TypeHndl type,
  278. void *decodedValue);
  279. extern void *DLL_ENTRY ossUpdateValueOfSimpleType(OssGlobal *world,TypeHndl type,
  280. char *userTypedValue, void *oldValue);
  281. extern IAAPI_ERRTYPE DLL_ENTRY ossGetDecodedValueOfComponent(OssGlobal *world,
  282. TypeHndl parentType, void *parentDecodedValue,
  283. unsigned int compIndex, void **componentValue);
  284. extern IAAPI_ERRTYPE DLL_ENTRY ossGetOpenTypeValue(OssGlobal *world,
  285. TypeHndl type, void *openValue, int *pduNum,
  286. void **decodedValue, OssBuf *encodedValue);
  287. extern IAAPI_ERRTYPE DLL_ENTRY ossIaapiMarkObject(OssGlobal *world, TypeHndl type,
  288. OssObjType objectType, void *object);
  289. extern OssObjType DLL_ENTRY ossGetObjectType(OssGlobal *world,
  290. TypeHndl type, void *object);
  291. extern ossBoolean DLL_ENTRY ossTypeIsExternalObject(OssGlobal *world,
  292. TypeHndl type);
  293. extern IAAPI_ERRTYPE DLL_ENTRY ossSetTypeAsExternalObject(OssGlobal *world,
  294. TypeHndl type, ossBoolean marked);
  295. extern void *DLL_ENTRY ossPutObjectValue(OssGlobal *world, TypeHndl type,
  296. void *objectValue, OssObjType objectType);
  297. extern IAAPI_ERRTYPE DLL_ENTRY ossGetObjectValue(OssGlobal *world,
  298. TypeHndl type, void *object,
  299. OssObjType objType, IaapiObjValType *objVal);
  300. extern ossBoolean DLL_ENTRY ossValueIsValid(OssGlobal *world,
  301. TypeHndl type, void *value);
  302. extern unsigned long DLL_ENTRY ossGetValueLength(OssGlobal *world,
  303. TypeHndl type, void *value);
  304. extern IAAPI_ERRTYPE DLL_ENTRY ossCopyTypeValue(OssGlobal *world, TypeHndl type,
  305. void *valueIn, void **valueOut);
  306. extern IAAPI_ERRTYPE DLL_ENTRY ossValueEncode(OssGlobal *world, TypeHndl type,
  307. void *value, OssBuf *encodedValue);
  308. extern IAAPI_ERRTYPE DLL_ENTRY ossFreeDecodedValue(OssGlobal *world,
  309. TypeHndl type, void *valPtr);
  310. extern void DLL_ENTRY ossFreeDisplayString(OssGlobal *world, char *dsplString);
  311. extern void DLL_ENTRY ossFreeIaapiObjectValue(OssGlobal *world,
  312. OssObjType objType, IaapiObjValType *objVal);
  313. extern ossBoolean DLL_ENTRY ossEncodingIsConstructed(OssGlobal *world,
  314. unsigned char *curEnc, long bufLength);
  315. extern unsigned char *DLL_ENTRY ossGetNextBEREncoding(OssGlobal *world,
  316. unsigned char *curEnc, long *remBufLen);
  317. extern unsigned char *DLL_ENTRY ossGetNestedBEREncoding(OssGlobal *world,
  318. unsigned char *curEnc, long *remBufLen);
  319. extern long DLL_ENTRY ossNumberOfEncodingTags(OssGlobal *world,
  320. unsigned char *curEnc, long bufLength);
  321. extern ASN1TagClass DLL_ENTRY ossEncodingASN1Class(OssGlobal *world,
  322. unsigned char *curEnc, long bufLength, int ix);
  323. extern long DLL_ENTRY ossEncodingASN1Tag(OssGlobal *world,
  324. unsigned char *curEnc, long bufLength, int ix);
  325. extern char *DLL_ENTRY ossEncodingASN1Type(OssGlobal *world,
  326. unsigned char *curEnc, long bufLength);
  327. extern long DLL_ENTRY ossEncodingLength(OssGlobal *world,
  328. unsigned char *curEnc, long bufLength);
  329. extern char *DLL_ENTRY ossEncodingContents(OssGlobal *world,
  330. unsigned char *curEnc, long bufLength);
  331. extern char *DLL_ENTRY ossConvertEncodingIntoDisplayHexFmt(OssGlobal *world,
  332. unsigned char *encodedBufin, long bufLength);
  333. extern char *DLL_ENTRY ossConvertEncodingIntoDisplayBinFmt(OssGlobal *world,
  334. unsigned char *encodedBufin, long bufLength);
  335. extern OssBuf DLL_ENTRY ossConvertHexFmtToEncoding(OssGlobal *world,
  336. char *hexBufin, long bufLength);
  337. extern OssBuf DLL_ENTRY ossConvertBinFmtToEncoding(OssGlobal *world,
  338. char *binBufin, long bufLength);
  339. /***************************************************************************
  340. * Functions for printing ASN.1 types and values *
  341. ***************************************************************************/
  342. extern void DLL_ENTRY ossPrintPDUs(OssGlobal *world);
  343. extern void DLL_ENTRY ossPrintASN1DescriptionOfPDU(OssGlobal *world,
  344. int pduNum, ossBoolean refTypes);
  345. extern void DLL_ENTRY ossPrintASN1DescriptionOfType(OssGlobal *world,
  346. TypeHndl type, ossBoolean refTypes);
  347. extern void DLL_ENTRY ossPrintDecodedValuesOfPDUs(OssGlobal *world);
  348. extern void DLL_ENTRY ossPrintDecodedValueOfPDU(OssGlobal *world, int pduNum,
  349. void *decodedValue);
  350. extern void DLL_ENTRY ossPrintDecodedValueOfPDUByName(OssGlobal *world,
  351. TypeHndl type, char *name, void *decodedValue);
  352. extern void DLL_ENTRY ossPrintDecodedValueOfType(OssGlobal *world,
  353. TypeHndl type, void *decodedValue);
  354. extern void DLL_ENTRY ossPrintBEREncoding(OssGlobal *world, OssBuf *encValue);
  355. extern unsigned int DLL_ENTRY ossEncodingHeaderLength(OssGlobal *world,
  356. unsigned char *curEnc, long remBufLength);
  357. extern void DLL_ENTRY ossPrintBEREncodedValueInTLV(OssGlobal *world,
  358. OssBuf *encodedValue);
  359. #ifdef __cplusplus
  360. }
  361. #endif /* __cplusplus */
  362. #endif /* #ifndef IAAPI_H */