Definitions for Abstract Syntax Notation One, ASN.1. More...
Go to the source code of this file.
Data Structures | |
| struct | UNSIGNED64 |
Defines | |
| #define | MAX_OID_LEN 32 |
| #define | MAX_SUBID 0xFFFFFFFF |
| #define | MIN_OID_LEN 2 |
| #define | ASN_BOOLEAN 0x01 |
| #define | ASN_INTEGER 0x02 |
| #define | ASN_BIT_STR 0x03 |
| #define | ASN_OCTET_STR 0x04 |
| #define | ASN_NULL 0x05 |
| #define | ASN_OBJECT_ID 0x06 |
| #define | ASN_SEQUENCE 0x10 |
| #define | ASN_SET 0x11 |
| #define | ASN_UNIVERSAL 0x00 |
| #define | ASN_APPLICATION 0x40 |
| #define | ASN_CONTEXT 0x80 |
| #define | ASN_PRIVATE 0xC0 |
| #define | ASN_PRIMITIVE 0x00 |
| #define | ASN_CONSTRUCTOR 0x20 |
| #define | ASN_LONG_LEN 0x80 |
| #define | ASN_EXTENSION_ID 0x1F |
| #define | ASN_IPADDRESS (ASN_APPLICATION | 0) |
| #define | ASN_COUNTER (ASN_APPLICATION | 1) |
| #define | ASN_GAUGE (ASN_APPLICATION | 2) |
| #define | ASN_UNSIGNED (ASN_APPLICATION | 2) |
| #define | ASN_TIMETICKS (ASN_APPLICATION | 3) |
| #define | ASN_OPAQUE (ASN_APPLICATION | 4) |
| #define | ASN_NSAP (ASN_APPLICATION | 5) |
| #define | ASN_COUNTER64 (ASN_APPLICATION | 6) |
| #define | ASN_UINTEGER (ASN_APPLICATION | 7) |
| #define | ACL_RONLY 0xAAAA |
| #define | ACL_RWRITE 0xAABA |
| #define | ACL_NOACCESS 0x0000 |
| #define | ASN_BIT8 0x80 |
Typedefs | |
| typedef uint32_t | OID |
Functions | |
| const uint8_t * | AsnHeaderParse (const uint8_t *, size_t *, uint8_t *) |
| Interpret the ID and length of the next object. | |
| uint8_t * | AsnHeaderBuild (uint8_t *, size_t *, uint8_t, size_t) |
| Build an ASN header for an object with a given ID and length. | |
| const uint8_t * | AsnSequenceParse (const uint8_t *, size_t *, uint8_t) |
| Check the type and get the length of the next object. | |
| uint8_t * | AsnSequenceBuild (uint8_t *, size_t *, uint8_t, size_t) |
| Build an ASN header for a sequence with a given type and length. | |
| const uint8_t * | AsnIntegerParse (const uint8_t *, size_t *, uint8_t *, long *) |
| Pull a long out of an ASN integer type. | |
| uint8_t * | AsnIntegerBuild (uint8_t *, size_t *, uint8_t, long *) |
| Build an ASN object containing an integer. | |
| const uint8_t * | AsnUnsignedParse (const uint8_t *, size_t *, uint8_t *, uint32_t *) |
| Pull an unsigned long out of an ASN integer type. | |
| uint8_t * | AsnUnsignedBuild (uint8_t *, size_t *, uint8_t, uint32_t *) |
| Build an ASN object containing an unsigned integer. | |
| const uint8_t * | AsnOctetStringParse (const uint8_t *, size_t *, uint8_t *, uint8_t *, size_t *) |
| Pulls a string out of an ASN octet string type. | |
| uint8_t * | AsnOctetStringBuild (uint8_t *, size_t *, uint8_t, const uint8_t *, size_t) |
| Build an ASN object containing an octet string. | |
| const uint8_t * | AsnOidParse (const uint8_t *, size_t *, uint8_t *, OID *, size_t *) |
| Pulls an object identifier out of an ASN object ID type. | |
| uint8_t * | AsnOidBuild (uint8_t *, size_t *, uint8_t, const OID *, size_t) |
| Build an ASN object identifier. | |
| const uint8_t * | AsnNullParse (const uint8_t *, size_t *, uint8_t *) |
| Parse an ASN null type. | |
| uint8_t * | AsnNullBuild (uint8_t *, size_t *, uint8_t) |
| Build an ASN null object. | |
| const uint8_t * | AsnBitStringParse (const uint8_t *, size_t *, uint8_t *, uint8_t *, size_t *) |
| Pull a bitstring out of an ASN bitstring type. | |
| uint8_t * | AsnBitStringBuild (uint8_t *, size_t *, uint8_t, const uint8_t *, size_t) |
| Build an ASN bit string. | |
| const uint8_t * | AsnUnsigned64Parse (const uint8_t *, size_t *, uint8_t *, UNSIGNED64 *) |
| Pull a 64 bit unsigned long out of an ASN integer type. | |
| uint8_t * | AsnUnsigned64Build (uint8_t *, size_t *, uint8_t, const UNSIGNED64 *) |
| Build an ASN object containing a 64 bit unsigned integer. | |
Definitions for Abstract Syntax Notation One, ASN.1.
* $Id: asn1.h 4473 2012-08-20 15:12:45Z haraldkipp $ *
| #define MAX_OID_LEN 32 |
Referenced by AsnOidBuild().
| #define MAX_SUBID 0xFFFFFFFF |
| #define MIN_OID_LEN 2 |
| #define ASN_BOOLEAN 0x01 |
| #define ASN_INTEGER 0x02 |
Referenced by SnmpAgentProcessRequest(), SnmpAuthBuild(), SnmpPduAddVariable(), and SnmpVarBuild().
| #define ASN_BIT_STR 0x03 |
Referenced by SnmpVarBuild().
| #define ASN_OCTET_STR 0x04 |
Referenced by SnmpAuthBuild(), and SnmpVarBuild().
| #define ASN_NULL 0x05 |
Referenced by SnmpVarBuild().
| #define ASN_OBJECT_ID 0x06 |
Referenced by SnmpVarBuild(), and SnmpVarParse().
| #define ASN_SEQUENCE 0x10 |
Referenced by SnmpAuthBuild(), SnmpAuthParse(), SnmpVarBuild(), and SnmpVarParse().
| #define ASN_SET 0x11 |
| #define ASN_UNIVERSAL 0x00 |
Referenced by SnmpAgentProcessRequest(), SnmpAuthBuild(), SnmpVarBuild(), and SnmpVarParse().
| #define ASN_APPLICATION 0x40 |
| #define ASN_CONTEXT 0x80 |
| #define ASN_PRIVATE 0xC0 |
| #define ASN_PRIMITIVE 0x00 |
Referenced by SnmpAgentProcessRequest(), SnmpAuthBuild(), SnmpVarBuild(), and SnmpVarParse().
| #define ASN_CONSTRUCTOR 0x20 |
Referenced by SnmpAuthBuild(), SnmpAuthParse(), SnmpVarBuild(), and SnmpVarParse().
| #define ASN_LONG_LEN 0x80 |
| #define ASN_EXTENSION_ID 0x1F |
Referenced by AsnHeaderParse().
| #define ASN_IPADDRESS (ASN_APPLICATION | 0) |
Referenced by SnmpVarBuild().
| #define ASN_COUNTER (ASN_APPLICATION | 1) |
Referenced by SnmpPduAddVariable(), and SnmpVarBuild().
| #define ASN_GAUGE (ASN_APPLICATION | 2) |
Referenced by SnmpPduAddVariable(), and SnmpVarBuild().
| #define ASN_UNSIGNED (ASN_APPLICATION | 2) |
| #define ASN_TIMETICKS (ASN_APPLICATION | 3) |
Referenced by SnmpPduAddVariable(), and SnmpVarBuild().
| #define ASN_OPAQUE (ASN_APPLICATION | 4) |
Referenced by SnmpVarBuild().
| #define ASN_NSAP (ASN_APPLICATION | 5) |
Referenced by SnmpVarBuild().
| #define ASN_COUNTER64 (ASN_APPLICATION | 6) |
Referenced by SnmpVarBuild().
| #define ASN_UINTEGER (ASN_APPLICATION | 7) |
Referenced by SnmpPduAddVariable(), and SnmpVarBuild().
| #define ACL_RONLY 0xAAAA |
| #define ACL_RWRITE 0xAABA |
| #define ACL_NOACCESS 0x0000 |
| #define ASN_BIT8 0x80 |
Referenced by AsnOidParse().
Interpret the ID and length of the next object.
| data | Pointer to start of the object. |
| datalength | Contains the number of valid bytes following the start of the object. On exit, it is returned as the number of valid bytes following the ID and length. |
| type | Pointer to the variable that receives the ASN type of the object. |
References ASN_EXTENSION_ID, and NULL.
Referenced by AsnSequenceParse(), SnmpAgentProcessRequest(), and SnmpVarParse().
Build an ASN header for an object with a given ID and length.
This only works on data types < 30, i.e. no extension octets. The maximum length is 0xFFFF;
| data | Pointer to start of object. |
| datalength | Contains the number of available bytes following the start of the object. On exit, it is returned as the number of available bytes following the encoded ID and length of this object. |
| type | ASN type of the object. |
| length | Length of object. |
References NULL.
Referenced by AsnBitStringBuild(), AsnIntegerBuild(), AsnNullBuild(), AsnOctetStringBuild(), AsnOidBuild(), AsnUnsigned64Build(), and AsnUnsignedBuild().
Check the type and get the length of the next object.
Similare to AsnHeaderParse, but tests for expected type.
| data | Pointer to start of the object. |
| datalength | Contains the number of valid bytes following the start of the object. On exit, it is returned as the number of valid bytes following the ID and length. |
| type | The expected ASN type of the object. |
References AsnHeaderParse(), and NULL.
Referenced by SnmpAuthParse(), and SnmpVarParse().
Build an ASN header for a sequence with a given type and length.
This only works on data types < 30, i.e. no extension octets. The maximum length is 0xFFFF;
| data | Pointer to start of object. |
| datalength | Contains the number of available bytes following the start of the object. On exit, it is returned as the number of available bytes following the encoded ID and length of this object. |
| type | ASN type of the object. |
| length | Length of object. |
References NULL.
Referenced by SnmpAgentProcessRequest(), SnmpAuthBuild(), and SnmpVarBuild().
| const uint8_t* AsnIntegerParse | ( | const uint8_t * | data, |
| size_t * | datalength, | ||
| uint8_t * | type, | ||
| long * | intp | ||
| ) |
Pull a long out of an ASN integer type.
| data | Pointer to start of the object. |
| datalength | Contains the number of valid bytes following the start of the object. On exit, it is returned as the number of valid bytes following the end of this object. |
| type | Pointer to the variable that receives the ASN type of the object. |
| intp | Pointer to the variable that receives the value of the object. |
References NULL.
Referenced by SnmpAgentProcessRequest(), and SnmpAuthParse().
Build an ASN object containing an integer.
| data | Pointer to start of output buffer |
| datalength | Contains the number of available bytes following the start of the object. On exit, it is returned as the number of available bytes following the end of this object. |
| type | ASN type of the object. |
| intp | Value of the object. |
References AsnHeaderBuild(), and NULL.
Referenced by SnmpAgentProcessRequest(), SnmpAuthBuild(), and SnmpVarBuild().
| const uint8_t* AsnUnsignedParse | ( | const uint8_t * | data, |
| size_t * | datalength, | ||
| uint8_t * | type, | ||
| uint32_t * | intp | ||
| ) |
Pull an unsigned long out of an ASN integer type.
| data | Pointer to start of the object. |
| datalength | Contains the number of valid bytes following the start of the object. On exit, it is returned as the number of valid bytes following the end of this object. |
| type | Pointer to the variable that receives the ASN type of the object. |
| intp | Pointer to the variable that receives the value of the object. |
References NULL.
Build an ASN object containing an unsigned integer.
| data | Pointer to start of output buffer |
| datalength | Contains the number of available bytes following the start of the object. On exit, it is returned as the number of available bytes following the end of this object. |
| type | ASN type of the object. |
| intp | Value of the object. |
References AsnHeaderBuild(), and NULL.
Referenced by SnmpVarBuild().
| const uint8_t* AsnOctetStringParse | ( | const uint8_t * | data, |
| size_t * | datalength, | ||
| uint8_t * | type, | ||
| uint8_t * | string, | ||
| size_t * | strlength | ||
| ) |
Pulls a string out of an ASN octet string type.
| data | Pointer to start of the object. |
| datalength | Contains the number of valid bytes following the start of the object. On exit, it is returned as the number of valid bytes following the end of this object. |
| type | Pointer to the variable that receives the ASN type of the object. |
| string | Pointer to the variable that receives the value of the object. |
| strlength | Contains the size of the string buffer on entry. On exit, it is returned as the number of bytes stored in the string buffer. |
References memcpy(), and NULL.
Referenced by SnmpAuthParse().
| uint8_t* AsnOctetStringBuild | ( | uint8_t * | data, |
| size_t * | datalength, | ||
| uint8_t | type, | ||
| const uint8_t * | string, | ||
| size_t | strlength | ||
| ) |
Build an ASN object containing an octet string.
| data | Pointer to start of output buffer |
| datalength | Contains the number of available bytes following the start of the object. On exit, it is returned as the number of available bytes following the end of this object. |
| type | ASN type of the object. |
| string | Pointer to the value. If NULL, the octet string will be filled with zeros. |
| strlength | Number of bytes in the string value. |
References AsnHeaderBuild(), memcpy(), memset(), and NULL.
Referenced by SnmpAuthBuild(), and SnmpVarBuild().
| const uint8_t* AsnOidParse | ( | const uint8_t * | data, |
| size_t * | datalength, | ||
| uint8_t * | type, | ||
| OID * | objid, | ||
| size_t * | objidlength | ||
| ) |
Pulls an object identifier out of an ASN object ID type.
| data | Pointer to start of the object. |
| datalength | Contains the number of valid bytes following the start of the object. On exit, it is returned as the number of valid bytes following the end of this object. |
| type | Pointer to the variable that receives the ASN type of the object. |
| objid | Pointer to the variable that receives the object identifier. |
| objidlength | Points to a variable that contains the size of the output buffer on entry. On exit, it is returned as the number of sub IDs stored in the output buffer. |
References ASN_BIT8, and NULL.
Referenced by SnmpVarParse().
| uint8_t* AsnOidBuild | ( | uint8_t * | data, |
| size_t * | datalength, | ||
| uint8_t | type, | ||
| const OID * | objid, | ||
| size_t | objidlength | ||
| ) |
Build an ASN object identifier.
| data | Pointer to start of the object. |
| datalength | Contains the number of available bytes following the start of the object. On exit, it is returned as the number of available bytes following the end of this object. |
| type | ASN type of the object. |
| objid | Pointer to the object identifier. |
| objidlength | Number of sub IDs in the object identifier. |
References AsnHeaderBuild(), free(), malloc(), MAX_OID_LEN, and NULL.
Referenced by SnmpVarBuild().
Parse an ASN null type.
| data | Pointer to start of the object. |
| datalength | Contains the number of valid bytes following the start of the object. On exit, it is returned as the number of valid bytes following the end of this object. |
| type | Pointer to the variable that receives the ASN type of the object. |
References NULL.
Build an ASN null object.
| data | Pointer to start of the object. |
| datalength | Contains the number of available bytes following the start of the object. On exit, it is returned as the number of available bytes following the end of this object. |
| type | ASN type of the object. |
References AsnHeaderBuild().
Referenced by SnmpVarBuild().
| const uint8_t* AsnBitStringParse | ( | const uint8_t * | data, |
| size_t * | datalength, | ||
| uint8_t * | type, | ||
| uint8_t * | string, | ||
| size_t * | strlength | ||
| ) |
Pull a bitstring out of an ASN bitstring type.
| data | Pointer to start of the object. |
| datalength | Contains the number of valid bytes following the start of the object. On exit, it is returned as the number of valid bytes following the end of this object. |
| type | Pointer to the variable that receives the ASN type of the object. |
| string | Pointer to the variable that receives the value of the object. |
| strlength | Contains the size of the string buffer on entry. On exit, it is returned as the number of bytes stored in the string buffer. |
References memcpy(), and NULL.
| uint8_t* AsnBitStringBuild | ( | uint8_t * | data, |
| size_t * | datalength, | ||
| uint8_t | type, | ||
| const uint8_t * | string, | ||
| size_t | strlength | ||
| ) |
Build an ASN bit string.
| data | Pointer to start of output buffer |
| datalength | Contains the number of available bytes following the start of the object. On exit, it is returned as the number of available bytes following the end of this object. |
| type | ASN type of the object. |
| string | Pointer to the value. If NULL, the octet string will be filled with zeros. |
| strlength | Number of bytes in the string value. |
References AsnHeaderBuild(), memcpy(), and NULL.
Referenced by SnmpVarBuild().
| const uint8_t* AsnUnsigned64Parse | ( | const uint8_t * | data, |
| size_t * | datalength, | ||
| uint8_t * | type, | ||
| UNSIGNED64 * | cp | ||
| ) |
Pull a 64 bit unsigned long out of an ASN integer type.
| data | Pointer to start of the object. |
| datalength | Contains the number of valid bytes following the start of the object. On exit, it is returned as the number of valid bytes following the end of this object. |
| type | Pointer to the variable that receives the ASN type of the object. |
| intp | Pointer to the variable that receives the value of the object. |
References UNSIGNED64::high, UNSIGNED64::low, and NULL.
| uint8_t* AsnUnsigned64Build | ( | uint8_t * | data, |
| size_t * | datalength, | ||
| uint8_t | type, | ||
| const UNSIGNED64 * | cp | ||
| ) |
Build an ASN object containing a 64 bit unsigned integer.
| data | Pointer to start of output buffer |
| datalength | Contains the number of available bytes following the start of the object. On exit, it is returned as the number of available bytes following the end of this object. |
| type | ASN type of the object. |
| intp | Value of the object. |
References AsnHeaderBuild(), UNSIGNED64::high, UNSIGNED64::low, and NULL.
Referenced by SnmpVarBuild().