source: Daodan/MinGW/include/snmp.h@ 1132

Last change on this file since 1132 was 1046, checked in by alloc, 8 years ago

Daodan: Added Windows MinGW and build batch file

File size: 9.4 KB
Line 
1/*
2 snmp.h - Header file for the Windows SNMP API
3
4 Written by Filip Navara <xnavara@volny.cz>
5
6 References (2003-08-25):
7 http://msdn.microsoft.com/library/en-us/snmp/snmp/snmp_reference.asp
8
9 This library is distributed in the hope that it will be useful,
10 but WITHOUT ANY WARRANTY; without even the implied warranty of
11 MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.
12*/
13
14#ifndef _SNMP_H
15#define _SNMP_H
16#if __GNUC__ >= 3
17#pragma GCC system_header
18#endif
19
20#ifndef _WINDOWS_H
21#include <windows.h>
22#endif
23
24#include <pshpack4.h>
25
26#ifndef WINSNMPAPI
27#define WINSNMPAPI WINAPI
28#endif
29
30#ifdef __cplusplus
31extern "C" {
32#endif
33
34#define DEFAULT_SNMP_PORT_UDP 161
35#define DEFAULT_SNMP_PORT_IPX 36879
36#define DEFAULT_SNMPTRAP_PORT_UDP 162
37#define DEFAULT_SNMPTRAP_PORT_IPX 36880
38#ifndef _SNMP_ASN_DEFINED
39#define _SNMP_ASN_DEFINED
40#define ASN_UNIVERSAL 0x00
41#define ASN_PRIMITIVE 0x00
42#define ASN_CONSTRUCTOR 0x20
43#define ASN_APPLICATION 0x40
44#define ASN_CONTEXT 0x80
45#define ASN_PRIVATE 0xC0
46#define SNMP_PDU_GET (ASN_CONTEXT | ASN_CONSTRUCTOR | 0)
47#define SNMP_PDU_GETNEXT (ASN_CONTEXT | ASN_CONSTRUCTOR | 1)
48#define SNMP_PDU_RESPONSE (ASN_CONTEXT | ASN_CONSTRUCTOR | 2)
49#define SNMP_PDU_SET (ASN_CONTEXT | ASN_CONSTRUCTOR | 3)
50#define SNMP_PDU_GETBULK (ASN_CONTEXT | ASN_CONSTRUCTOR | 4)
51#define SNMP_PDU_V1TRAP (ASN_CONTEXT | ASN_CONSTRUCTOR | 4)
52#define SNMP_PDU_INFORM (ASN_CONTEXT | ASN_CONSTRUCTOR | 6)
53#define SNMP_PDU_TRAP (ASN_CONTEXT | ASN_CONSTRUCTOR | 7)
54#define SNMP_PDU_REPORT (ASN_CONTEXT | ASN_CONSTRUCTOR | 8)
55#endif /* _SNMP_ASN_DEFINED */
56#define ASN_INTEGER (ASN_UNIVERSAL | ASN_PRIMITIVE | 2)
57#define ASN_BITS (ASN_UNIVERSAL | ASN_PRIMITIVE | 3)
58#define ASN_OCTETSTRING (ASN_UNIVERSAL | ASN_PRIMITIVE | 4)
59#define ASN_NULL (ASN_UNIVERSAL | ASN_PRIMITIVE | 5)
60#define ASN_OBJECTIDENTIFIER (ASN_UNIVERSAL | ASN_PRIMITIVE | 6)
61#define ASN_INTEGER32 ASN_INTEGER
62#define ASN_SEQUENCE (ASN_UNIVERSAL | ASN_CONSTRUCTOR | 0x10)
63#define ASN_SEQUENCEOF ASN_SEQUENCE
64#define ASN_IPADDRESS (ASN_APPLICATION | ASN_PRIMITIVE | 0x00)
65#define ASN_COUNTER32 (ASN_APPLICATION | ASN_PRIMITIVE | 0x01)
66#define ASN_GAUGE32 (ASN_APPLICATION | ASN_PRIMITIVE | 0x02)
67#define ASN_TIMETICKS (ASN_APPLICATION | ASN_PRIMITIVE | 0x03)
68#define ASN_OPAQUE (ASN_APPLICATION | ASN_PRIMITIVE | 0x04)
69#define ASN_COUNTER64 (ASN_APPLICATION | ASN_PRIMITIVE | 0x06)
70#define ASN_UNSIGNED32 (ASN_APPLICATION | ASN_PRIMITIVE | 0x07)
71#define SNMP_EXCEPTION_NOSUCHOBJECT (ASN_CONTEXT | ASN_PRIMITIVE | 0x00)
72#define SNMP_EXCEPTION_NOSUCHINSTANCE (ASN_CONTEXT | ASN_PRIMITIVE | 0x01)
73#define SNMP_EXCEPTION_ENDOFMIBVIEW (ASN_CONTEXT | ASN_PRIMITIVE | 0x02)
74#define SNMP_EXTENSION_GET SNMP_PDU_GET
75#define SNMP_EXTENSION_GET_NEXT SNMP_PDU_GETNEXT
76#define SNMP_EXTENSION_GET_BULK SNMP_PDU_GETBULK
77#define SNMP_EXTENSION_SET_TEST (ASN_PRIVATE | ASN_CONSTRUCTOR | 0x0)
78#define SNMP_EXTENSION_SET_COMMIT SNMP_PDU_SET
79#define SNMP_EXTENSION_SET_UNDO (ASN_PRIVATE | ASN_CONSTRUCTOR | 0x1)
80#define SNMP_EXTENSION_SET_CLEANUP (ASN_PRIVATE | ASN_CONSTRUCTOR | 0x2)
81#define SNMP_ERRORSTATUS_NOERROR 0
82#define SNMP_ERRORSTATUS_TOOBIG 1
83#define SNMP_ERRORSTATUS_NOSUCHNAME 2
84#define SNMP_ERRORSTATUS_BADVALUE 3
85#define SNMP_ERRORSTATUS_READONLY 4
86#define SNMP_ERRORSTATUS_GENERR 5
87#define SNMP_ERRORSTATUS_NOACCESS 6
88#define SNMP_ERRORSTATUS_WRONGTYPE 7
89#define SNMP_ERRORSTATUS_WRONGLENGTH 8
90#define SNMP_ERRORSTATUS_WRONGENCODING 9
91#define SNMP_ERRORSTATUS_WRONGVALUE 10
92#define SNMP_ERRORSTATUS_NOCREATION 11
93#define SNMP_ERRORSTATUS_INCONSISTENTVALUE 12
94#define SNMP_ERRORSTATUS_RESOURCEUNAVAILABLE 13
95#define SNMP_ERRORSTATUS_COMMITFAILED 14
96#define SNMP_ERRORSTATUS_UNDOFAILED 15
97#define SNMP_ERRORSTATUS_AUTHORIZATIONERROR 16
98#define SNMP_ERRORSTATUS_NOTWRITABLE 17
99#define SNMP_ERRORSTATUS_INCONSISTENTNAME 18
100#define SNMP_GENERICTRAP_COLDSTART 0
101#define SNMP_GENERICTRAP_WARMSTART 1
102#define SNMP_GENERICTRAP_LINKDOWN 2
103#define SNMP_GENERICTRAP_LINKUP 3
104#define SNMP_GENERICTRAP_AUTHFAILURE 4
105#define SNMP_GENERICTRAP_EGPNEIGHLOSS 5
106#define SNMP_GENERICTRAP_ENTERSPECIFIC 6
107#define SNMP_ACCESS_NONE 0
108#define SNMP_ACCESS_NOTIFY 1
109#define SNMP_ACCESS_READ_ONLY 2
110#define SNMP_ACCESS_READ_WRITE 3
111#define SNMP_ACCESS_READ_CREATE 4
112#define SNMPAPI_ERROR FALSE
113#define SNMPAPI_NOERROR TRUE
114#define SNMP_LOG_SILENT 0
115#define SNMP_LOG_FATAL 1
116#define SNMP_LOG_ERROR 2
117#define SNMP_LOG_WARNING 3
118#define SNMP_LOG_TRACE 4
119#define SNMP_LOG_VERBOSE 5
120#define SNMP_OUTPUT_TO_CONSOLE 1
121#define SNMP_OUTPUT_TO_LOGFILE 2
122#define SNMP_OUTPUT_TO_EVENTLOG 4
123#define SNMP_OUTPUT_TO_DEBUGGER 8
124#define SNMP_MAX_OID_LEN 128
125#define SNMP_MEM_ALLOC_ERROR 1
126#define SNMP_BERAPI_INVALID_LENGTH 10
127#define SNMP_BERAPI_INVALID_TAG 11
128#define SNMP_BERAPI_OVERFLOW 12
129#define SNMP_BERAPI_SHORT_BUFFER 13
130#define SNMP_BERAPI_INVALID_OBJELEM 14
131#define SNMP_PDUAPI_UNRECOGNIZED_PDU 20
132#define SNMP_PDUAPI_INVALID_ES 21
133#define SNMP_PDUAPI_INVALID_GT 22
134#define SNMP_AUTHAPI_INVALID_VERSION 30
135#define SNMP_AUTHAPI_INVALID_MSG_TYPE 31
136#define SNMP_AUTHAPI_TRIV_AUTH_FAILED 32
137
138#ifndef RC_INVOKED
139
140typedef INT SNMPAPI;
141typedef LONG AsnInteger32;
142typedef ULONG AsnUnsigned32;
143typedef ULARGE_INTEGER AsnCounter64;
144typedef AsnUnsigned32 AsnCounter32;
145typedef AsnUnsigned32 AsnGauge32;
146typedef AsnUnsigned32 AsnTimeticks;
147typedef struct {
148 BYTE *stream;
149 UINT length;
150 BOOL dynamic;
151} AsnOctetString, AsnBits, AsnSequence, AsnImplicitSequence, AsnIPAddress, AsnNetworkAddress, AsnDisplayString, AsnOpaque;
152typedef struct {
153 UINT idLength;
154 UINT *ids;
155} AsnObjectIdentifier, AsnObjectName;
156typedef struct {
157 BYTE asnType;
158 union {
159 AsnInteger32 number;
160 AsnUnsigned32 unsigned32;
161 AsnCounter64 counter64;
162 AsnOctetString string;
163 AsnBits bits;
164 AsnObjectIdentifier object;
165 AsnSequence sequence;
166 AsnIPAddress address;
167 AsnCounter32 counter;
168 AsnGauge32 gauge;
169 AsnTimeticks ticks;
170 AsnOpaque arbitrary;
171 } asnValue;
172} AsnAny, AsnObjectSyntax;
173typedef struct {
174 AsnObjectName name;
175 AsnObjectSyntax value;
176} SnmpVarBind;
177typedef struct {
178 SnmpVarBind *list;
179 UINT len;
180} SnmpVarBindList;
181
182VOID WINSNMPAPI SnmpExtensionClose(void);
183BOOL WINSNMPAPI SnmpExtensionInit(DWORD,HANDLE*,AsnObjectIdentifier*);
184BOOL WINSNMPAPI SnmpExtensionInitEx(AsnObjectIdentifier*);
185BOOL WINSNMPAPI SnmpExtensionMonitor(LPVOID);
186BOOL WINSNMPAPI SnmpExtensionQuery(BYTE,SnmpVarBindList*,AsnInteger32*,AsnInteger32*);
187BOOL WINSNMPAPI SnmpExtensionQueryEx(DWORD,DWORD,SnmpVarBindList*,AsnOctetString*,AsnInteger32*,AsnInteger32*);
188BOOL WINSNMPAPI SnmpExtensionTrap(AsnObjectIdentifier*,AsnInteger32*,AsnInteger32*,AsnTimeticks*,SnmpVarBindList*);
189DWORD WINSNMPAPI SnmpSvcGetUptime(void);
190VOID WINSNMPAPI SnmpSvcSetLogLevel(INT);
191VOID WINSNMPAPI SnmpSvcSetLogType(INT);
192SNMPAPI WINSNMPAPI SnmpUtilAsnAnyCpy(AsnAny*,AsnAny*);
193VOID WINSNMPAPI SnmpUtilAsnAnyFree(AsnAny*);
194VOID WINSNMPAPI SnmpUtilDbgPrint(INT,LPSTR,...);
195LPSTR WINSNMPAPI SnmpUtilIdsToA(UINT*,UINT);
196LPVOID WINSNMPAPI SnmpUtilMemAlloc(UINT);
197VOID WINSNMPAPI SnmpUtilMemFree(LPVOID);
198LPVOID WINSNMPAPI SnmpUtilMemReAlloc(LPVOID,UINT);
199SNMPAPI WINSNMPAPI SnmpUtilOctetsCmp(AsnOctetString*,AsnOctetString*);
200SNMPAPI WINSNMPAPI SnmpUtilOctetsCpy(AsnOctetString*,AsnOctetString*);
201VOID WINSNMPAPI SnmpUtilOctetsFree(AsnOctetString*);
202SNMPAPI WINSNMPAPI SnmpUtilOctetsNCmp(AsnOctetString*,AsnOctetString*,UINT);
203SNMPAPI WINSNMPAPI SnmpUtilOidAppend(AsnObjectIdentifier*,AsnObjectIdentifier*);
204SNMPAPI WINSNMPAPI SnmpUtilOidCmp(AsnObjectIdentifier*,AsnObjectIdentifier*);
205SNMPAPI WINSNMPAPI SnmpUtilOidCpy(AsnObjectIdentifier*,AsnObjectIdentifier*);
206VOID WINSNMPAPI SnmpUtilOidFree(AsnObjectIdentifier*);
207SNMPAPI WINSNMPAPI SnmpUtilOidNCmp(AsnObjectIdentifier*,AsnObjectIdentifier*,UINT);
208LPSTR WINSNMPAPI SnmpUtilOidToA(AsnObjectIdentifier*);
209VOID WINSNMPAPI SnmpUtilPrintAsnAny(AsnAny*);
210VOID WINSNMPAPI SnmpUtilPrintOid(AsnObjectIdentifier*);
211SNMPAPI WINSNMPAPI SnmpUtilVarBindCpy( SnmpVarBind*,SnmpVarBind*);
212SNMPAPI WINSNMPAPI SnmpUtilVarBindListCpy(SnmpVarBindList*,SnmpVarBindList*);
213VOID WINSNMPAPI SnmpUtilVarBindFree(SnmpVarBind*);
214VOID WINSNMPAPI SnmpUtilVarBindListFree(SnmpVarBindList*);
215
216#ifndef SNMPSTRICT
217#define SNMP_malloc SnmpUtilMemAlloc
218#define SNMP_free SnmpUtilMemFree
219#define SNMP_realloc SnmpUtilMemReAlloc
220#define SNMP_DBG_malloc SnmpUtilMemAlloc
221#define SNMP_DBG_free SnmpUtilMemFree
222#define SNMP_DBG_realloc SnmpUtilMemReAlloc
223#define SNMP_oidappend SnmpUtilOidAppend
224#define SNMP_oidcmp SnmpUtilOidCmp
225#define SNMP_oidcpy SnmpUtilOidCpy
226#define SNMP_oidfree SnmpUtilOidFree
227#define SNMP_oidncmp SnmpUtilOidNCmp
228#define SNMP_printany SnmpUtilPrintAsnAny
229#define SNMP_CopyVarBind SnmpUtilVarBindCpy
230#define SNMP_CopyVarBindList SnmpUtilVarBindListCpy
231#define SNMP_FreeVarBind SnmpUtilVarBindFree
232#define SNMP_FreeVarBindList SnmpUtilVarBindListFree
233#define ASN_RFC1155_IPADDRESS ASN_IPADDRESS
234#define ASN_RFC1155_COUNTER ASN_COUNTER32
235#define ASN_RFC1155_GAUGE ASN_GAUGE32
236#define ASN_RFC1155_TIMETICKS ASN_TIMETICKS
237#define ASN_RFC1155_OPAQUE ASN_OPAQUE
238#define ASN_RFC1213_DISPSTRING ASN_OCTETSTRING
239#define ASN_RFC1157_GETREQUEST SNMP_PDU_GET
240#define ASN_RFC1157_GETNEXTREQUEST SNMP_PDU_GETNEXT
241#define ASN_RFC1157_GETRESPONSE SNMP_PDU_RESPONSE
242#define ASN_RFC1157_SETREQUEST SNMP_PDU_SET
243#define ASN_RFC1157_TRAP SNMP_PDU_V1TRAP
244#define ASN_CONTEXTSPECIFIC ASN_CONTEXT
245#define ASN_PRIMATIVE ASN_PRIMITIVE
246#define RFC1157VarBindList SnmpVarBindList
247#define RFC1157VarBind SnmpVarBind
248#define AsnInteger AsnInteger32
249#define AsnCounter AsnCounter32
250#define AsnGauge AsnGauge32
251#endif /* SNMPSTRICT */
252
253#endif /* RC_INVOKED */
254
255#ifdef __cplusplus
256}
257#endif
258#include <poppack.h>
259#endif
Note: See TracBrowser for help on using the repository browser.