| 1 |
|
| 2 |
|
| 3 |
|
| 4 |
|
| 5 |
|
| 6 |
|
| 7 |
|
| 8 |
|
| 9 |
|
| 10 |
|
| 11 |
|
| 12 |
|
| 13 |
|
| 14 |
|
| 15 |
|
| 16 |
|
| 17 |
|
| 18 |
|
| 19 |
|
| 20 |
|
| 21 |
|
| 22 |
|
| 23 |
|
| 24 |
|
| 25 |
#ifndef MOD_SNMP_ASN1_H |
| 26 |
#define MOD_SNMP_ASN1_H |
| 27 |
|
| 28 |
#include "mod_snmp.h" |
| 29 |
|
| 30 |
typedef uint32_t oid_t; |
| 31 |
|
| 32 |
|
| 33 |
|
| 34 |
|
| 35 |
|
| 36 |
|
| 37 |
#define SNMP_ASN1_OID_MAX_LEN 128 |
| 38 |
#define SNMP_ASN1_OID_MAX_ID 0xffff |
| 39 |
|
| 40 |
|
| 41 |
#define SNMP_ASN1_TYPE_BOOLEAN 0x01 |
| 42 |
#define SNMP_ASN1_TYPE_INTEGER 0x02 |
| 43 |
#define SNMP_ASN1_TYPE_BITSTRING 0x03 |
| 44 |
#define SNMP_ASN1_TYPE_OCTETSTRING 0x04 |
| 45 |
#define SNMP_ASN1_TYPE_NULL 0x05 |
| 46 |
#define SNMP_ASN1_TYPE_OID 0x06 |
| 47 |
#define SNMP_ASN1_TYPE_SEQUENCE 0x10 |
| 48 |
#define SNMP_ASN1_TYPE_SET 0x11 |
| 49 |
|
| 50 |
|
| 51 |
#define SNMP_ASN1_CLASS_UNIVERSAL 0x00 |
| 52 |
#define SNMP_ASN1_CLASS_APPLICATION 0x40 |
| 53 |
#define SNMP_ASN1_CLASS_CONTEXT 0x80 |
| 54 |
#define SNMP_ASN1_CLASS_PRIVATE 0xc0 |
| 55 |
|
| 56 |
|
| 57 |
#define SNMP_ASN1_PRIMITIVE 0x00 |
| 58 |
#define SNMP_ASN1_CONSTRUCT 0x20 |
| 59 |
|
| 60 |
|
| 61 |
#define SNMP_ASN1_LEN_LONG 0x80 |
| 62 |
#define SNMP_ASN1_LEN_EXTENSION 0xff |
| 63 |
#define SNMP_ASN1_LEN_INDEFINITE 0x80 |
| 64 |
|
| 65 |
const char *snmp_asn1_get_oidstr(pool *p, oid_t *asn1_oid, |
| 66 |
unsigned int asn1_oidlen); |
| 67 |
const char *snmp_asn1_get_tagstr(pool *p, unsigned char asn1_type); |
| 68 |
|
| 69 |
|
| 70 |
#define SNMP_ASN1_FL_KNOWN_LEN 0x01 |
| 71 |
#define SNMP_ASN1_FL_NO_TRACE_TYPESTR 0x02 |
| 72 |
#define SNMP_ASN1_FL_UNSIGNED 0x04 |
| 73 |
|
| 74 |
int snmp_asn1_read_header(pool *p, unsigned char **buf, size_t *buflen, |
| 75 |
unsigned char *asn1_type, unsigned int *asn1_len, int flags); |
| 76 |
int snmp_asn1_read_int(pool *p, unsigned char **buf, size_t *buflen, |
| 77 |
unsigned char *asn1_type, long *asn1_int, int flags); |
| 78 |
int snmp_asn1_read_uint(pool *p, unsigned char **buf, size_t *buflen, |
| 79 |
unsigned char *asn1_type, unsigned long *asn1_uint); |
| 80 |
int snmp_asn1_read_null(pool *p, unsigned char **buf, size_t *buflen, |
| 81 |
unsigned char *asn1_type); |
| 82 |
int snmp_asn1_read_oid(pool *p, unsigned char **buf, size_t *buflen, |
| 83 |
unsigned char *asn1_type, oid_t *asn1_oid, unsigned int *asn1_oidlen); |
| 84 |
|
| 85 |
|
| 86 |
int snmp_asn1_read_string(pool *p, unsigned char **buf, size_t *buflen, |
| 87 |
unsigned char *asn1_type, char **asn_1str, unsigned int *asn1_strlen); |
| 88 |
|
| 89 |
|
| 90 |
|
| 91 |
int snmp_asn1_write_header(pool *p, unsigned char **buf, size_t *buflen, |
| 92 |
unsigned char asn1_type, unsigned int asn1_len, int flags); |
| 93 |
int snmp_asn1_write_int(pool *p, unsigned char **buf, size_t *buflen, |
| 94 |
unsigned char asn1_type, long asn1_int, int flags); |
| 95 |
int snmp_asn1_write_uint(pool *p, unsigned char **buf, size_t *buflen, |
| 96 |
unsigned char asn1_type, unsigned long asn1_uint); |
| 97 |
int snmp_asn1_write_null(pool *p, unsigned char **buf, size_t *buflen, |
| 98 |
unsigned char asn1_type); |
| 99 |
int snmp_asn1_write_oid(pool *p, unsigned char **buf, size_t *buflen, |
| 100 |
unsigned char asn1_type, oid_t *asn1_oid, unsigned int asn1_oidlen); |
| 101 |
|
| 102 |
|
| 103 |
int snmp_asn1_write_string(pool *p, unsigned char **buf, size_t *buflen, |
| 104 |
unsigned char asn1_type, const char *asn1_str, unsigned int asn1_strlen); |
| 105 |
|
| 106 |
|
| 107 |
|
| 108 |
|
| 109 |
|
| 110 |
|
| 111 |
|
| 112 |
|
| 113 |
|
| 114 |
|
| 115 |
|
| 116 |
int snmp_asn1_write_exception(pool *p, unsigned char **buf, size_t *buflen, |
| 117 |
unsigned char asn1_type, unsigned char asn1_ex); |
| 118 |
|
| 119 |
|
| 120 |
|
| 121 |
#endif |