Developer's Guide
 All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Macros Groups Pages
p6asn1.h
Go to the documentation of this file.
1 
17 #ifndef P6ASN1_H__
18 #define P6ASN1_H__ 1
19 
20 #include "p6com.h"
21 
22 
23 #ifdef __cplusplus
24 namespace P6R {
25 extern "C" {
26 #endif
27 
28 // Standard BER Universal Tag Values
29 const P6UINT8 BER_boolean = 0x01;
30 const P6UINT8 BER_integer = 0x02;
31 const P6UINT8 BER_bitString = 0x03;
32 const P6UINT8 BER_octetString = 0x04;
33 const P6UINT8 BER_NULL = 0x05;
34 const P6UINT8 BER_OID = 0x06; // OBJECT IDENTIFIER
35 const P6UINT8 BER_ODC = 0x07; // Object Descriptor
36 const P6UINT8 BER_external = 0x08;
37 const P6UINT8 BER_real = 0x09;
38 const P6UINT8 BER_enum = 0x0A; // ENUMERATED
39 const P6UINT8 BER_sequence = 0x30; // SEQUENCE and SEQUENCE OF
40 const P6UINT8 BER_set = 0x31; // SET and SET OF
41 
52 typedef struct
53 {
56 } P6ASN1OCTET;
57 
58 
80 typedef struct
81 {
83  union {
92  } type;
93 } P6ASN1INTEGER;
94 
95 
106 typedef enum
107 {
108  ASN1_BER = 0x00,
109  ASN1_DER = 0x01
111 
112 
121 const P6ASN1FLAGS P6ASN1_NOFLAGS = 0x00000000;
122 
135 const P6ASN1REALFLAGS P6ASN1REAL_NOFLAGS = 0x00000000;
136 const P6ASN1REALFLAGS P6ASN1REAL_MINUSINFINITY = 0x00000001;
137 const P6ASN1REALFLAGS P6ASN1REAL_PLUSINFINITY = 0x00000002;
138 
139 
152 #undef INTERFACE
153 #define INTERFACE p6IAsn1
155 {
169  P6DECLCOMMETHOD(initialize)(P6THIS_ P6ASN1FLAGS flags, P6ASN1TRANSFERENCODING type ) P6PURE;
170 
171 
172  // [A] Encoding functions
200  P6DECLCOMMETHOD(encodeLength)(P6THIS_ P6UINT8* pBuffer,
201  P6UINT32 bufSize,
202  P6UINT32& index,
203  P6UINT32 length,
204  P6INT8 useOctets) P6PURE;
205 
227  P6DECLCOMMETHOD(encodeOID)(P6THIS_ P6UINT8* pBuffer,
228  P6UINT32 bufSize,
229  P6UINT32& index,
230  const P6CHAR* pOID) P6PURE;
231 
254  P6DECLCOMMETHOD(encodeOctetString)(P6THIS_ P6UINT8* pBuffer,
255  P6UINT32 bufSize,
256  P6UINT32& index,
257  P6ASN1OCTET* pString,
258  P6UINT8 overrideTag) P6PURE;
259 
279  P6DECLCOMMETHOD(encodeInteger32)(P6THIS_ P6UINT8* pBuffer,
280  P6UINT32 bufSize,
281  P6UINT32& index,
282  P6INT32 intValue,
283  P6UINT8 overrideTag) P6PURE;
284 
305  P6DECLCOMMETHOD(encodeInteger64)(P6THIS_ P6UINT8* pBuffer,
306  P6UINT32 bufSize,
307  P6UINT32& index,
308  P6INT64 intValue,
309  P6UINT8 overrideTag) P6PURE;
310 
330  P6DECLCOMMETHOD(encodeUnsigned32)(P6THIS_ P6UINT8* pBuffer,
331  P6UINT32 bufSize,
332  P6UINT32& index,
333  P6UINT32 numValue,
334  P6UINT8 applicationTag) P6PURE;
335 
355  P6DECLCOMMETHOD(encodeUnsigned64)(P6THIS_ P6UINT8* pBuffer,
356  P6UINT32 bufSize,
357  P6UINT32& index,
358  P6UINT64 numValue,
359  P6UINT8 applicationTag) P6PURE;
360 
379  P6DECLCOMMETHOD(encodeInteger)(P6THIS_ P6UINT8* pBuffer,
380  P6UINT32 bufSize,
381  P6UINT32& index,
382  P6ASN1INTEGER integer,
383  P6UINT8 overrideTag) P6PURE;
384 
404  P6DECLCOMMETHOD(encodeIPAddr)(P6THIS_ P6UINT8* pBuffer,
405  P6UINT32 bufSize,
406  P6UINT32& index,
407  P6UINT32 ipAddress,
408  P6UINT8 overrideTag) P6PURE;
409 
425  P6DECLCOMMETHOD(encodeNULL)(P6THIS_ P6UINT8* pBuffer,
426  P6UINT32 bufSize,
427  P6UINT32& index,
428  P6UINT8 overrideTag) P6PURE;
429 
456  P6DECLCOMMETHOD(encodeBoolean)(P6THIS_ P6UINT8* pBuffer,
457  P6UINT32 bufSize,
458  P6UINT32& index,
459  P6BOOL value,
460  P6UINT8 overrideTag) P6PURE;
461 
489  P6DECLCOMMETHOD(encodeReal)(P6THIS_ P6UINT8* pBuffer,
490  P6UINT32 bufSize,
491  P6UINT32& index,
492  P6FLOAT numValue,
493  P6ASN1REALFLAGS flags,
494  P6UINT8 overrideTag) P6PURE;
495 
496 
497  // [B] Decoding functions
522  P6DECLCOMMETHOD(decodeLength)(P6THIS_ P6UINT8* pBuffer,
523  P6UINT32 bufSize,
524  P6UINT32& index,
525  P6UINT32& length) P6PURE;
526 
553  P6DECLCOMMETHOD(decodeInteger)(P6THIS_ P6UINT8* pBuffer,
554  P6UINT32 bufSize,
555  P6UINT32& index,
556  P6ASN1INTEGER& value) P6PURE;
557 
585  P6DECLCOMMETHOD(decodeUnsigned)(P6THIS_ P6UINT8* pBuffer,
586  P6UINT32 bufSize,
587  P6UINT32& index,
588  P6ASN1INTEGER& value) P6PURE;
589 
608  P6DECLCOMMETHOD(decodeBoolean)(P6THIS_ P6UINT8* pBuffer,
609  P6UINT32 bufSize,
610  P6UINT32& index,
611  P6BOOL& value) P6PURE;
612 
627  P6DECLCOMMETHOD(toP6Int32)(P6THIS_ P6ASN1INTEGER iValue, P6INT32& value ) P6PURE;
628 
644  P6DECLCOMMETHOD(toP6Uint32)(P6THIS_ P6ASN1INTEGER iValue, P6UINT32& value ) P6PURE;
645 
660  P6DECLCOMMETHOD(toP6Int64)(P6THIS_ P6ASN1INTEGER iValue, P6INT64& value ) P6PURE;
661 
676  P6DECLCOMMETHOD(toP6Uint64)(P6THIS_ P6ASN1INTEGER iValue, P6UINT64& value ) P6PURE;
677 
690  P6DECLCOMMETHOD(isNegative)(P6THIS_ P6ASN1INTEGER value, P6BOOL& negative ) P6PURE;
691 
702  P6DECLCOMMETHOD(setZero)(P6THIS_ P6ASN1INTEGER& value ) P6PURE;
703 
732  P6DECLCOMMETHOD(decodeOctetString)(P6THIS_ P6UINT8* pBuffer,
733  P6UINT32 bufSize,
734  P6UINT32& index,
735  P6ASN1OCTET& value) P6PURE;
736 
767  P6DECLCOMMETHOD(decodeOID)(P6THIS_ P6UINT8* pBuffer,
768  P6UINT32 bufSize,
769  P6UINT32& index,
770  P6CHAR* pOID,
771  P6UINT32& oidSize) P6PURE;
772 
797  P6DECLCOMMETHOD(decodeIPAddr)(P6THIS_ P6UINT8* pBuffer,
798  P6UINT32 bufSize,
799  P6UINT32& index,
800  P6UINT32& ipAddress) P6PURE;
801 
821  P6DECLCOMMETHOD(decodeNULL)(P6THIS_ P6UINT8* pBuffer,
822  P6UINT32 bufSize,
823  P6UINT32& index) P6PURE;
824 
850  P6DECLCOMMETHOD(decodeReal)(P6THIS_ P6UINT8* pBuffer,
851  P6UINT32 bufSize,
852  P6UINT32& index,
853  P6FLOAT& numValue,
854  P6ASN1REALFLAGS& flags) P6PURE;
855 
876  P6DECLCOMMETHOD(skipField)(P6THIS_ P6UINT8* pBuffer,
877  P6UINT32 bufSize,
878  P6UINT8 tag,
879  P6UINT32& index) P6PURE;
880 
881 
882 
883  // [C] Utility functions
899  P6DECLCOMMETHOD(copyOctetString)(P6THIS_ const P6ASN1OCTET* pSource, P6ASN1OCTET* pDestination ) P6PURE;
900 
912  P6DECLCOMMETHOD(freeOctetString)(P6THIS_ P6ASN1OCTET* pOctets ) P6PURE;
913 };
914 
915 // {B3521209-E863-464e-8F6B-F467E1B07A5E}
916 #define IF_p6IAsn1 {0xb3521209,0xe863,0x464e,{0x8f,0x6b,0xf4,0x67,0xe1,0xb0,0x7a,0x5e}}
917 
918 // {ED95D016-7E66-4d02-A9E6-0595C788D357}
919 #define COMP_p6Asn1 {0xed95d016,0x7e66,0x4d02,{0xa9,0xe6,0x5,0x95,0xc7,0x88,0xd3,0x57}}
920 
921 #ifdef __cplusplus
922 }
923 } // namespace
924 #endif
925 
926 
927 #endif
928 
929 
P6INT32 int32
Definition: p6asn1.h:88
const P6UINT8 BER_boolean
Definition: p6asn1.h:29
P6LONGLONG P6INT64
Definition: p6types.h:56
const P6UINT8 BER_ODC
Definition: p6asn1.h:35
unsigned int P6UINT32
Definition: p6types.h:46
const P6UINT8 BER_set
Definition: p6asn1.h:40
const P6UINT8 BER_OID
Definition: p6asn1.h:34
#define P6DECLAREICOM
Definition: p6defs.h:175
#define P6PURE
Definition: p6defs.h:176
const P6UINT8 BER_real
Definition: p6asn1.h:37
unsigned char P6BOOL
Boolean type.
Definition: p6types.h:112
const P6UINT8 BER_enum
Definition: p6asn1.h:38
const P6ASN1REALFLAGS P6ASN1REAL_PLUSINFINITY
Definition: p6asn1.h:137
P6UINT32 P6ASN1REALFLAGS
P6ASN1REALFLAGS.
Definition: p6asn1.h:134
char P6INT8
Definition: p6types.h:37
P6UINT8 uInt8
Definition: p6asn1.h:85
const P6ASN1REALFLAGS P6ASN1REAL_MINUSINFINITY
Definition: p6asn1.h:136
unsigned char P6UINT8
Definition: p6types.h:36
const P6UINT8 BER_bitString
Definition: p6asn1.h:31
const P6UINT8 BER_octetString
Definition: p6asn1.h:32
unsigned short int P6UINT16
Definition: p6types.h:40
int P6INT32
Definition: p6types.h:47
The base interface all [p6]COM components must derive from and implement.
Definition: p6comdef.h:97
const P6ASN1REALFLAGS P6ASN1REAL_NOFLAGS
Definition: p6asn1.h:135
P6ASN1TRANSFERENCODING
A transfer encoding takes the Abstract Syntax Notation (ASN) and traslates it to bytes in a network p...
Definition: p6asn1.h:106
P6UINT64 uInt64
Definition: p6asn1.h:91
This interface supports low level ASN.1 encoding and decoding functions.
Definition: p6asn1.h:154
P6UINT32 length
Definition: p6asn1.h:54
P6UINT32 P6ASN1FLAGS
P6ASN1FLAGS.
Definition: p6asn1.h:120
P6ULONGLONG P6UINT64
Definition: p6types.h:55
P6INT64 int64
Definition: p6asn1.h:90
P6INT16 int16
Definition: p6asn1.h:86
const P6ASN1FLAGS P6ASN1_NOFLAGS
Definition: p6asn1.h:121
short int P6INT16
Definition: p6types.h:41
const P6UINT8 BER_NULL
Definition: p6asn1.h:33
#define P6DECLCOMMETHOD(method)
Definition: p6defs.h:173
P6UINT8 choice
Definition: p6asn1.h:82
#define P6THIS_
Definition: p6defs.h:177
double P6FLOAT
Definition: p6types.h:74
P6UINT16 uInt16
Definition: p6asn1.h:87
const P6UINT8 BER_integer
Definition: p6asn1.h:30
P6COM definitions and interfaces.
P6UINT32 uInt32
Definition: p6asn1.h:89
P6UINT8 * pBytes
Definition: p6asn1.h:55
Matches the ASN.1 type of an array of binary bytes (i.e., any byte can be zero).
Definition: p6asn1.h:52
const P6UINT8 BER_external
Definition: p6asn1.h:36
char P6CHAR
Narrow character type.
Definition: p6types.h:84
const P6UINT8 BER_sequence
Definition: p6asn1.h:39
#define P6DECLAREIF_(iface, baseif)
Definition: p6defs.h:172
Used in decoding functions, since we do not know the type of the integer until we look at its length ...
Definition: p6asn1.h:80