source: Daodan/MSYS2/mingw32/i686-w64-mingw32/include/snmp.h@ 1167

Last change on this file since 1167 was 1166, checked in by rossy, 3 years ago

Daodan: Replace MinGW build env with an up-to-date MSYS2 env

File size: 11.4 KB
Line 
1/**
2 * This file has no copyright assigned and is placed in the Public Domain.
3 * This file is part of the mingw-w64 runtime package.
4 * No warranty is given; refer to the file DISCLAIMER.PD within this package.
5 */
6#ifndef _INC_SNMP
7#define _INC_SNMP
8
9#include <windows.h>
10
11#ifdef __cplusplus
12extern "C" {
13#endif
14
15#include <pshpack4.h>
16
17 typedef struct {
18 BYTE *stream;
19 UINT length;
20 WINBOOL dynamic;
21 } AsnOctetString;
22
23 typedef struct {
24 UINT idLength;
25 UINT *ids;
26 } AsnObjectIdentifier;
27
28 typedef LONG AsnInteger32;
29 typedef ULONG AsnUnsigned32;
30 typedef ULARGE_INTEGER AsnCounter64;
31 typedef AsnUnsigned32 AsnCounter32;
32 typedef AsnUnsigned32 AsnGauge32;
33 typedef AsnUnsigned32 AsnTimeticks;
34 typedef AsnOctetString AsnBits;
35 typedef AsnOctetString AsnSequence;
36 typedef AsnOctetString AsnImplicitSequence;
37 typedef AsnOctetString AsnIPAddress;
38 typedef AsnOctetString AsnNetworkAddress;
39 typedef AsnOctetString AsnDisplayString;
40 typedef AsnOctetString AsnOpaque;
41
42 typedef struct {
43 BYTE asnType;
44 union {
45 AsnInteger32 number;
46
47 AsnUnsigned32 unsigned32;
48 AsnCounter64 counter64;
49 AsnOctetString string;
50 AsnBits bits;
51 AsnObjectIdentifier object;
52 AsnSequence sequence;
53 AsnIPAddress address;
54 AsnCounter32 counter;
55 AsnGauge32 gauge;
56 AsnTimeticks ticks;
57 AsnOpaque arbitrary;
58 } asnValue;
59 } AsnAny;
60
61 typedef AsnObjectIdentifier AsnObjectName;
62 typedef AsnAny AsnObjectSyntax;
63
64 typedef struct {
65 AsnObjectName name;
66 AsnObjectSyntax value;
67 } SnmpVarBind;
68
69 typedef struct {
70 SnmpVarBind *list;
71 UINT len;
72 } SnmpVarBindList;
73
74#include <poppack.h>
75
76#ifndef _INC_WINSNMP
77#define ASN_UNIVERSAL 0x00
78#define ASN_APPLICATION 0x40
79#define ASN_CONTEXT 0x80
80#define ASN_PRIVATE 0xC0
81#define ASN_PRIMITIVE 0x00
82#define ASN_CONSTRUCTOR 0x20
83
84#define SNMP_PDU_GET (ASN_CONTEXT | ASN_CONSTRUCTOR | 0x0)
85#define SNMP_PDU_GETNEXT (ASN_CONTEXT | ASN_CONSTRUCTOR | 0x1)
86#define SNMP_PDU_RESPONSE (ASN_CONTEXT | ASN_CONSTRUCTOR | 0x2)
87#define SNMP_PDU_SET (ASN_CONTEXT | ASN_CONSTRUCTOR | 0x3)
88#define SNMP_PDU_V1TRAP (ASN_CONTEXT | ASN_CONSTRUCTOR | 0x4)
89#define SNMP_PDU_GETBULK (ASN_CONTEXT | ASN_CONSTRUCTOR | 0x5)
90#define SNMP_PDU_INFORM (ASN_CONTEXT | ASN_CONSTRUCTOR | 0x6)
91#define SNMP_PDU_TRAP (ASN_CONTEXT | ASN_CONSTRUCTOR | 0x7)
92#endif
93
94#define ASN_INTEGER (ASN_UNIVERSAL | ASN_PRIMITIVE | 0x02)
95#define ASN_BITS (ASN_UNIVERSAL | ASN_PRIMITIVE | 0x03)
96#define ASN_OCTETSTRING (ASN_UNIVERSAL | ASN_PRIMITIVE | 0x04)
97#define ASN_NULL (ASN_UNIVERSAL | ASN_PRIMITIVE | 0x05)
98#define ASN_OBJECTIDENTIFIER (ASN_UNIVERSAL | ASN_PRIMITIVE | 0x06)
99#define ASN_INTEGER32 ASN_INTEGER
100
101#define ASN_SEQUENCE (ASN_UNIVERSAL | ASN_CONSTRUCTOR | 0x10)
102#define ASN_SEQUENCEOF ASN_SEQUENCE
103
104#define ASN_IPADDRESS (ASN_APPLICATION | ASN_PRIMITIVE | 0x00)
105#define ASN_COUNTER32 (ASN_APPLICATION | ASN_PRIMITIVE | 0x01)
106#define ASN_GAUGE32 (ASN_APPLICATION | ASN_PRIMITIVE | 0x02)
107#define ASN_TIMETICKS (ASN_APPLICATION | ASN_PRIMITIVE | 0x03)
108#define ASN_OPAQUE (ASN_APPLICATION | ASN_PRIMITIVE | 0x04)
109#define ASN_COUNTER64 (ASN_APPLICATION | ASN_PRIMITIVE | 0x06)
110#define ASN_UINTEGER32 (ASN_APPLICATION | ASN_PRIMITIVE | 0x07)
111#define ASN_RFC2578_UNSIGNED32 ASN_GAUGE32
112
113#define SNMP_EXCEPTION_NOSUCHOBJECT (ASN_CONTEXT | ASN_PRIMITIVE | 0x00)
114#define SNMP_EXCEPTION_NOSUCHINSTANCE (ASN_CONTEXT | ASN_PRIMITIVE | 0x01)
115#define SNMP_EXCEPTION_ENDOFMIBVIEW (ASN_CONTEXT | ASN_PRIMITIVE | 0x02)
116
117#define SNMP_EXTENSION_GET SNMP_PDU_GET
118#define SNMP_EXTENSION_GET_NEXT SNMP_PDU_GETNEXT
119#define SNMP_EXTENSION_GET_BULK SNMP_PDU_GETBULK
120#define SNMP_EXTENSION_SET_TEST (ASN_PRIVATE | ASN_CONSTRUCTOR | 0x0)
121#define SNMP_EXTENSION_SET_COMMIT SNMP_PDU_SET
122#define SNMP_EXTENSION_SET_UNDO (ASN_PRIVATE | ASN_CONSTRUCTOR | 0x1)
123#define SNMP_EXTENSION_SET_CLEANUP (ASN_PRIVATE | ASN_CONSTRUCTOR | 0x2)
124
125#define SNMP_ERRORSTATUS_NOERROR 0
126#define SNMP_ERRORSTATUS_TOOBIG 1
127#define SNMP_ERRORSTATUS_NOSUCHNAME 2
128#define SNMP_ERRORSTATUS_BADVALUE 3
129#define SNMP_ERRORSTATUS_READONLY 4
130#define SNMP_ERRORSTATUS_GENERR 5
131#define SNMP_ERRORSTATUS_NOACCESS 6
132#define SNMP_ERRORSTATUS_WRONGTYPE 7
133#define SNMP_ERRORSTATUS_WRONGLENGTH 8
134#define SNMP_ERRORSTATUS_WRONGENCODING 9
135#define SNMP_ERRORSTATUS_WRONGVALUE 10
136#define SNMP_ERRORSTATUS_NOCREATION 11
137#define SNMP_ERRORSTATUS_INCONSISTENTVALUE 12
138#define SNMP_ERRORSTATUS_RESOURCEUNAVAILABLE 13
139#define SNMP_ERRORSTATUS_COMMITFAILED 14
140#define SNMP_ERRORSTATUS_UNDOFAILED 15
141#define SNMP_ERRORSTATUS_AUTHORIZATIONERROR 16
142#define SNMP_ERRORSTATUS_NOTWRITABLE 17
143#define SNMP_ERRORSTATUS_INCONSISTENTNAME 18
144
145#define SNMP_GENERICTRAP_COLDSTART 0
146#define SNMP_GENERICTRAP_WARMSTART 1
147#define SNMP_GENERICTRAP_LINKDOWN 2
148#define SNMP_GENERICTRAP_LINKUP 3
149#define SNMP_GENERICTRAP_AUTHFAILURE 4
150#define SNMP_GENERICTRAP_EGPNEIGHLOSS 5
151#define SNMP_GENERICTRAP_ENTERSPECIFIC 6
152
153#define SNMP_ACCESS_NONE 0
154#define SNMP_ACCESS_NOTIFY 1
155#define SNMP_ACCESS_READ_ONLY 2
156#define SNMP_ACCESS_READ_WRITE 3
157#define SNMP_ACCESS_READ_CREATE 4
158
159#define SNMPAPI INT
160#define SNMP_FUNC_TYPE WINAPI
161
162#define SNMPAPI_NOERROR TRUE
163#define SNMPAPI_ERROR FALSE
164
165 WINBOOL SNMP_FUNC_TYPE SnmpExtensionInit(DWORD dwUptimeReference,HANDLE *phSubagentTrapEvent,AsnObjectIdentifier *pFirstSupportedRegion);
166 WINBOOL SNMP_FUNC_TYPE SnmpExtensionInitEx(AsnObjectIdentifier *pNextSupportedRegion);
167 WINBOOL SNMP_FUNC_TYPE SnmpExtensionMonitor(LPVOID pAgentMgmtData);
168 WINBOOL SNMP_FUNC_TYPE SnmpExtensionQuery(BYTE bPduType,SnmpVarBindList *pVarBindList,AsnInteger32 *pErrorStatus,AsnInteger32 *pErrorIndex);
169 WINBOOL SNMP_FUNC_TYPE SnmpExtensionQueryEx(UINT nRequestType,UINT nTransactionId,SnmpVarBindList *pVarBindList,AsnOctetString *pContextInfo,AsnInteger32 *pErrorStatus,AsnInteger32 *pErrorIndex);
170 WINBOOL SNMP_FUNC_TYPE SnmpExtensionTrap(AsnObjectIdentifier *pEnterpriseOid,AsnInteger32 *pGenericTrapId,AsnInteger32 *pSpecificTrapId,AsnTimeticks *pTimeStamp,SnmpVarBindList *pVarBindList);
171 VOID SNMP_FUNC_TYPE SnmpExtensionClose();
172
173 typedef WINBOOL (SNMP_FUNC_TYPE *PFNSNMPEXTENSIONINIT)(DWORD dwUpTimeReference,HANDLE *phSubagentTrapEvent,AsnObjectIdentifier *pFirstSupportedRegion);
174 typedef WINBOOL (SNMP_FUNC_TYPE *PFNSNMPEXTENSIONINITEX)(AsnObjectIdentifier *pNextSupportedRegion);
175 typedef WINBOOL (SNMP_FUNC_TYPE *PFNSNMPEXTENSIONMONITOR)(LPVOID pAgentMgmtData);
176 typedef WINBOOL (SNMP_FUNC_TYPE *PFNSNMPEXTENSIONQUERY)(BYTE bPduType,SnmpVarBindList *pVarBindList,AsnInteger32 *pErrorStatus,AsnInteger32 *pErrorIndex);
177 typedef WINBOOL (SNMP_FUNC_TYPE *PFNSNMPEXTENSIONQUERYEX)(UINT nRequestType,UINT nTransactionId,SnmpVarBindList *pVarBindList,AsnOctetString *pContextInfo,AsnInteger32 *pErrorStatus,AsnInteger32 *pErrorIndex);
178 typedef WINBOOL (SNMP_FUNC_TYPE *PFNSNMPEXTENSIONTRAP)(AsnObjectIdentifier *pEnterpriseOid,AsnInteger32 *pGenericTrapId,AsnInteger32 *pSpecificTrapId,AsnTimeticks *pTimeStamp,SnmpVarBindList *pVarBindList);
179 typedef VOID (SNMP_FUNC_TYPE *PFNSNMPEXTENSIONCLOSE)();
180
181 SNMPAPI SNMP_FUNC_TYPE SnmpUtilOidCpy(AsnObjectIdentifier *pOidDst,AsnObjectIdentifier *pOidSrc);
182 SNMPAPI SNMP_FUNC_TYPE SnmpUtilOidAppend(AsnObjectIdentifier *pOidDst,AsnObjectIdentifier *pOidSrc);
183 SNMPAPI SNMP_FUNC_TYPE SnmpUtilOidNCmp(AsnObjectIdentifier *pOid1,AsnObjectIdentifier *pOid2,UINT nSubIds);
184 SNMPAPI SNMP_FUNC_TYPE SnmpUtilOidCmp(AsnObjectIdentifier *pOid1,AsnObjectIdentifier *pOid2);
185 VOID SNMP_FUNC_TYPE SnmpUtilOidFree(AsnObjectIdentifier *pOid);
186 SNMPAPI SNMP_FUNC_TYPE SnmpUtilOctetsCmp(AsnOctetString *pOctets1,AsnOctetString *pOctets2);
187 SNMPAPI SNMP_FUNC_TYPE SnmpUtilOctetsNCmp(AsnOctetString *pOctets1,AsnOctetString *pOctets2,UINT nChars);
188 SNMPAPI SNMP_FUNC_TYPE SnmpUtilOctetsCpy(AsnOctetString *pOctetsDst,AsnOctetString *pOctetsSrc);
189 VOID SNMP_FUNC_TYPE SnmpUtilOctetsFree(AsnOctetString *pOctets);
190 SNMPAPI SNMP_FUNC_TYPE SnmpUtilAsnAnyCpy(AsnAny *pAnyDst,AsnAny *pAnySrc);
191 VOID SNMP_FUNC_TYPE SnmpUtilAsnAnyFree(AsnAny *pAny);
192 SNMPAPI SNMP_FUNC_TYPE SnmpUtilVarBindCpy(SnmpVarBind *pVbDst,SnmpVarBind *pVbSrc);
193 VOID SNMP_FUNC_TYPE SnmpUtilVarBindFree(SnmpVarBind *pVb);
194 SNMPAPI SNMP_FUNC_TYPE SnmpUtilVarBindListCpy(SnmpVarBindList *pVblDst,SnmpVarBindList *pVblSrc);
195 VOID SNMP_FUNC_TYPE SnmpUtilVarBindListFree(SnmpVarBindList *pVbl);
196 VOID SNMP_FUNC_TYPE SnmpUtilMemFree(LPVOID pMem);
197 LPVOID SNMP_FUNC_TYPE SnmpUtilMemAlloc(UINT nBytes);
198 LPVOID SNMP_FUNC_TYPE SnmpUtilMemReAlloc(LPVOID pMem,UINT nBytes);
199 LPSTR SNMP_FUNC_TYPE SnmpUtilOidToA(AsnObjectIdentifier *Oid);
200 LPSTR SNMP_FUNC_TYPE SnmpUtilIdsToA(UINT *Ids,UINT IdLength);
201 VOID SNMP_FUNC_TYPE SnmpUtilPrintOid(AsnObjectIdentifier *Oid);
202 VOID SNMP_FUNC_TYPE SnmpUtilPrintAsnAny(AsnAny *pAny);
203 DWORD SNMP_FUNC_TYPE SnmpSvcGetUptime();
204 VOID SNMP_FUNC_TYPE SnmpSvcSetLogLevel(INT nLogLevel);
205 VOID SNMP_FUNC_TYPE SnmpSvcSetLogType(INT nLogType);
206
207#define SNMP_LOG_SILENT 0x0
208#define SNMP_LOG_FATAL 0x1
209#define SNMP_LOG_ERROR 0x2
210#define SNMP_LOG_WARNING 0x3
211#define SNMP_LOG_TRACE 0x4
212#define SNMP_LOG_VERBOSE 0x5
213
214#define SNMP_OUTPUT_TO_CONSOLE 0x1
215#define SNMP_OUTPUT_TO_LOGFILE 0x2
216#define SNMP_OUTPUT_TO_EVENTLOG 0x4
217#define SNMP_OUTPUT_TO_DEBUGGER 0x8
218
219 VOID WINAPIV SnmpUtilDbgPrint(INT nLogLevel,LPSTR szFormat,...);
220
221#define SNMPDBG(_x_)
222
223#define DEFINE_SIZEOF(Array) (sizeof(Array)/sizeof((Array)[0]))
224#define DEFINE_OID(SubIdArray) {DEFINE_SIZEOF(SubIdArray),(SubIdArray)}
225#define DEFINE_NULLOID() {0,NULL}
226#define DEFINE_NULLOCTETS() {NULL,0,FALSE}
227
228#define DEFAULT_SNMP_PORT_UDP 161
229#define DEFAULT_SNMP_PORT_IPX 36879
230#define DEFAULT_SNMPTRAP_PORT_UDP 162
231#define DEFAULT_SNMPTRAP_PORT_IPX 36880
232
233#define SNMP_MAX_OID_LEN 128
234
235#define SNMP_MEM_ALLOC_ERROR 1
236#define SNMP_BERAPI_INVALID_LENGTH 10
237#define SNMP_BERAPI_INVALID_TAG 11
238#define SNMP_BERAPI_OVERFLOW 12
239#define SNMP_BERAPI_SHORT_BUFFER 13
240#define SNMP_BERAPI_INVALID_OBJELEM 14
241#define SNMP_PDUAPI_UNRECOGNIZED_PDU 20
242#define SNMP_PDUAPI_INVALID_ES 21
243#define SNMP_PDUAPI_INVALID_GT 22
244#define SNMP_AUTHAPI_INVALID_VERSION 30
245#define SNMP_AUTHAPI_INVALID_MSG_TYPE 31
246#define SNMP_AUTHAPI_TRIV_AUTH_FAILED 32
247
248#ifndef SNMPSTRICT
249
250#define SNMP_oidcpy SnmpUtilOidCpy
251#define SNMP_oidappend SnmpUtilOidAppend
252#define SNMP_oidncmp SnmpUtilOidNCmp
253#define SNMP_oidcmp SnmpUtilOidCmp
254#define SNMP_oidfree SnmpUtilOidFree
255
256#define SNMP_CopyVarBindList SnmpUtilVarBindListCpy
257#define SNMP_FreeVarBindList SnmpUtilVarBindListFree
258#define SNMP_CopyVarBind SnmpUtilVarBindCpy
259#define SNMP_FreeVarBind SnmpUtilVarBindFree
260
261#define SNMP_printany SnmpUtilPrintAsnAny
262
263#define SNMP_free SnmpUtilMemFree
264#define SNMP_malloc SnmpUtilMemAlloc
265#define SNMP_realloc SnmpUtilMemReAlloc
266
267#define SNMP_DBG_free SnmpUtilMemFree
268#define SNMP_DBG_malloc SnmpUtilMemAlloc
269#define SNMP_DBG_realloc SnmpUtilMemReAlloc
270
271#define ASN_RFC1155_IPADDRESS ASN_IPADDRESS
272#define ASN_RFC1155_COUNTER ASN_COUNTER32
273#define ASN_RFC1155_GAUGE ASN_GAUGE32
274#define ASN_RFC1155_TIMETICKS ASN_TIMETICKS
275#define ASN_RFC1155_OPAQUE ASN_OPAQUE
276#define ASN_RFC1213_DISPSTRING ASN_OCTETSTRING
277
278#define ASN_RFC1157_GETREQUEST SNMP_PDU_GET
279#define ASN_RFC1157_GETNEXTREQUEST SNMP_PDU_GETNEXT
280#define ASN_RFC1157_GETRESPONSE SNMP_PDU_RESPONSE
281#define ASN_RFC1157_SETREQUEST SNMP_PDU_SET
282#define ASN_RFC1157_TRAP SNMP_PDU_V1TRAP
283
284#define ASN_CONTEXTSPECIFIC ASN_CONTEXT
285#define ASN_PRIMATIVE ASN_PRIMITIVE
286
287#define RFC1157VarBindList SnmpVarBindList
288#define RFC1157VarBind SnmpVarBind
289#define AsnInteger AsnInteger32
290#define AsnCounter AsnCounter32
291#define AsnGauge AsnGauge32
292#define ASN_UNSIGNED32 ASN_UINTEGER32
293#endif
294
295#ifdef __cplusplus
296}
297#endif
298
299#endif /* _INC_SNMP */
300
Note: See TracBrowser for help on using the repository browser.