-
Notifications
You must be signed in to change notification settings - Fork 7
/
Copy pathbraaasn.h
91 lines (70 loc) · 2.22 KB
/
braaasn.h
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
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
#ifdef SOLARIS_SPARC
typedef uint32_t uint32_t;
typedef uint16_t uint16_t;
typedef uint8_t uint8_t;
typedef uint64_t uint64_t;
#endif
// #define DEBUG
// #undef DEBUG
#ifdef DEBUG
#include <stdio.h>
#define debug(format, arg...) fprintf(stderr, format, ## arg)
#else
#define debug(format, arg...) {}
#endif
#define BRAAASN_OCTETSTRING_LIMIT (1024*1024)
#define BRAAASN_INTEGER 0x02
#define BRAAASN_BITSTRING 0x03
#define BRAAASN_OCTETSTRING 0x04
#define BRAAASN_NULL 0x05
#define BRAAASN_OID 0x06
#define BRAAASN_ERR_NOSUCHOBJECT 0x80
#define BRAAASN_ERR_NOSUCHINSTANCE 0x81
#define BRAAASN_ERR_ENDOFMIBVIEW 0x82
#define BRAAASN_SEQUENCE 0x30
#define BRAAASN_PDU_GETREQUEST 0xa0
#define BRAAASN_PDU_GETRESPONSE 0xa2
#define BRAAASN_PDU_GETNEXTREQUEST 0xa1
#define BRAAASN_PDU_GETBULKREQUEST 0xa5
#define BRAAASN_PDU_SETREQUEST 0xa3
#define BRAAASN_PDU_UNKNOWN 0
#define BRAAASN_IPADDR 0x40
#define BRAAASN_COUNTER 0x41
#define BRAAASN_GAUGE 0x42
#define BRAAASN_TIMETICKS 0x43
#define BRAAASN_OPAQUE 0x44
#define BRAAASN_COUNTER64 0x46
#define BRAAASN_NSAPADDR 0x45
/* ^^Not supported */
struct braa_asnobject
{
uint8_t type;
int32_t ldata;
void * pdata;
};
typedef struct braa_asnobject asnobject;
static inline struct braa_asnobject * braa_ASNObject_Create(uint8_t type, uint32_t ldata, void * pdata)
{
struct braa_asnobject * ret;
assert(ret = (struct braa_asnobject*) malloc(sizeof(struct braa_asnobject)));
ret->type = type;
ret->ldata = ldata;
ret->pdata = pdata;
return(ret);
}
int braa_ASNObject_EncodeBER(struct braa_asnobject * data, uint8_t * buffer, uint32_t size);
struct braa_asnobject * braa_ASNObject_DecodeBER(uint8_t * data, uint32_t size);
void braa_ASNObject_Dispose(struct braa_asnobject * obj);
void braa_ASNObject_Dump(struct braa_asnobject * obj);
void braa_ASNObject_ToString(struct braa_asnobject * obj, unsigned char * buffer, int size, int hexdump);
asnobject * braa_ASNObject_CreateFromString(char * str);
#define BRAA_ERROR_UNKNOWN 0
#define BRAA_ERROR_TOOBIG 1
#define BRAA_ERROR_NOSUCHNAME 2
#define BRAA_ERROR_BADVALUE 3
#define BRAA_ERROR_READONLY 4
#define BRAA_ERROR_GENERIC 5
#define BRAA_VERSION_SNMP1 0
#define BRAA_VERSION_SNMP2C 1
#define gmalloc(x) malloc(x)
#define grealloc(x, y) realloc(x, y)