2 winsnmp.h - Header file for the Windows SNMP API
4 Written by Filip Navara <xnavara@volny.cz>
6 References (2003-08-25):
8 http://www.winsnmp.com/docs/winsnmp.doc
11 http://www.winsnmp.com/docs/winsnmp2.txt
13 WinSNMP v3.0 API Addendum
14 http://www.winsnmp.com/docs/winsnmp3.htm
17 http://msdn.microsoft.com/library/en-us/snmp/snmp/winsnmp_api_reference.asp
19 This library is distributed in the hope that it will be useful,
20 but WITHOUT ANY WARRANTY; without even the implied warranty of
21 MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.
27 #pragma GCC system_header
37 #define WINSNMPAPI WINAPI
44 #define MAXOBJIDSIZE 128
45 #define MAXOBJIDSTRSIZE 1408
46 #define MAXVENDORINFO 32
47 #ifndef _SNMP_ASN_DEFINED
48 #define _SNMP_ASN_DEFINED
49 #define ASN_UNIVERSAL 0x00
50 #define ASN_PRIMITIVE 0x00
51 #define ASN_CONSTRUCTOR 0x20
52 #define ASN_APPLICATION 0x40
53 #define ASN_CONTEXT 0x80
54 #define ASN_PRIVATE 0xC0
55 #define SNMP_PDU_GET (ASN_CONTEXT | ASN_CONSTRUCTOR | 0)
56 #define SNMP_PDU_GETNEXT (ASN_CONTEXT | ASN_CONSTRUCTOR | 1)
57 #define SNMP_PDU_RESPONSE (ASN_CONTEXT | ASN_CONSTRUCTOR | 2)
58 #define SNMP_PDU_SET (ASN_CONTEXT | ASN_CONSTRUCTOR | 3)
59 #define SNMP_PDU_GETBULK (ASN_CONTEXT | ASN_CONSTRUCTOR | 4)
60 #define SNMP_PDU_V1TRAP (ASN_CONTEXT | ASN_CONSTRUCTOR | 4)
61 #define SNMP_PDU_INFORM (ASN_CONTEXT | ASN_CONSTRUCTOR | 6)
62 #define SNMP_PDU_TRAP (ASN_CONTEXT | ASN_CONSTRUCTOR | 7)
63 #define SNMP_PDU_REPORT (ASN_CONTEXT | ASN_CONSTRUCTOR | 8)
64 #endif /* _SNMP_ASN_DEFINED */
65 #define SNMP_SYNTAX_SEQUENCE (ASN_UNIVERSAL | ASN_CONSTRUCTOR | 0x10)
66 #define SNMP_SYNTAX_INT (ASN_UNIVERSAL | ASN_PRIMITIVE | 0x02)
67 #define SNMP_SYNTAX_BITS (ASN_UNIVERSAL | ASN_PRIMITIVE | 0x03)
68 #define SNMP_SYNTAX_OCTETS (ASN_UNIVERSAL | ASN_PRIMITIVE | 0x04)
69 #define SNMP_SYNTAX_NULL (ASN_UNIVERSAL | ASN_PRIMITIVE | 0x05)
70 #define SNMP_SYNTAX_OID (ASN_UNIVERSAL | ASN_PRIMITIVE | 0x06)
71 #define SNMP_SYNTAX_IPADDR (ASN_APPLICATION | ASN_PRIMITIVE | 0x00)
72 #define SNMP_SYNTAX_CNTR32 (ASN_APPLICATION | ASN_PRIMITIVE | 0x01)
73 #define SNMP_SYNTAX_GAUGE32 (ASN_APPLICATION | ASN_PRIMITIVE | 0x02)
74 #define SNMP_SYNTAX_TIMETICKS (ASN_APPLICATION | ASN_PRIMITIVE | 0x03)
75 #define SNMP_SYNTAX_OPAQUE (ASN_APPLICATION | ASN_PRIMITIVE | 0x04)
76 #define SNMP_SYNTAX_NSAPADDR (ASN_APPLICATION | ASN_PRIMITIVE | 0x05)
77 #define SNMP_SYNTAX_CNTR64 (ASN_APPLICATION | ASN_PRIMITIVE | 0x06)
78 #define SNMP_SYNTAX_UINT32 (ASN_APPLICATION | ASN_PRIMITIVE | 0x07)
79 #define SNMP_SYNTAX_NOSUCHOBJECT (ASN_CONTEXT | ASN_PRIMITIVE | 0x00)
80 #define SNMP_SYNTAX_NOSUCHINSTANCE (ASN_CONTEXT | ASN_PRIMITIVE | 0x01)
81 #define SNMP_SYNTAX_ENDOFMIBVIEW (ASN_CONTEXT | ASN_PRIMITIVE | 0x02)
82 #define SNMP_SYNTAX_INT32 SNMP_SYNTAX_INT
83 #define SNMP_TRAP_COLDSTART 0
84 #define SNMP_TRAP_WARMSTART 1
85 #define SNMP_TRAP_LINKDOWN 2
86 #define SNMP_TRAP_LINKUP 3
87 #define SNMP_TRAP_AUTHFAIL 4
88 #define SNMP_TRAP_EGPNEIGHBORLOSS 5
89 #define SNMP_TRAP_ENTERPRISESPECIFIC 6
90 #define SNMP_ERROR_NOERROR 0
91 #define SNMP_ERROR_TOOBIG 1
92 #define SNMP_ERROR_NOSUCHNAME 2
93 #define SNMP_ERROR_BADVALUE 3
94 #define SNMP_ERROR_READONLY 4
95 #define SNMP_ERROR_GENERR 5
96 #define SNMP_ERROR_NOACCESS 6
97 #define SNMP_ERROR_WRONGTYPE 7
98 #define SNMP_ERROR_WRONGLENGTH 8
99 #define SNMP_ERROR_WRONGENCODING 9
100 #define SNMP_ERROR_WRONGVALUE 10
101 #define SNMP_ERROR_NOCREATION 11
102 #define SNMP_ERROR_INCONSISTENTVALUE 12
103 #define SNMP_ERROR_RESOURCEUNAVAILABLE 13
104 #define SNMP_ERROR_COMMITFAILED 14
105 #define SNMP_ERROR_UNDOFAILED 15
106 #define SNMP_ERROR_AUTHORIZATIONERROR 16
107 #define SNMP_ERROR_NOTWRITABLE 17
108 #define SNMP_ERROR_INCONSISTENTNAME 18
109 #define SNMP_SEC_MODEL_V1 1
110 #define SNMP_SEC_MODEL_V2 2
111 #define SNMP_SEC_MODEL_USM 3
112 #define SNMP_NOAUTH_NOPRIV 0
113 #define SNMP_AUTH_NOPRIV 1
114 #define SNMP_AUTH_PRIV 3
115 #define SNMP_USM_NO_AUTH_PROTOCOL 1
116 #define SNMP_USM_HMACMD5_AUTH_PROTOCOL 2
117 #define SNMP_USM_HMACSHA_AUTH_PROTOCOL 3
118 #define SNMP_USM_NO_PRIV_PROTOCOL 1
119 #define SNMP_USM_DES_PRIV_PROTOCOL 2
120 #define SNMPAPI_TRANSLATED 0
121 #define SNMPAPI_UNTRANSLATED_V1 1
122 #define SNMPAPI_UNTRANSLATED_V2 2
123 #define SNMPAPI_UNTRANSLATED_V3 3
124 #define SNMPAPI_OFF 0
126 #define SNMPAPI_FAILURE 0
127 #define SNMPAPI_SUCCESS 1
128 #define SNMPAPI_NO_SUPPORT 0
129 #define SNMPAPI_V1_SUPPORT 1
130 #define SNMPAPI_V2_SUPPORT 2
131 #define SNMPAPI_M2M_SUPPORT 3
132 #define SNMPAPI_V3_SUPPORT 3
133 #define SNMPAPI_ALLOC_ERROR 2
134 #define SNMPAPI_CONTEXT_INVALID 3
135 #define SNMPAPI_CONTEXT_UNKNOWN 4
136 #define SNMPAPI_ENTITY_INVALID 5
137 #define SNMPAPI_ENTITY_UNKNOWN 6
138 #define SNMPAPI_INDEX_INVALID 7
139 #define SNMPAPI_NOOP 8
140 #define SNMPAPI_OID_INVALID 9
141 #define SNMPAPI_OPERATION_INVALID 10
142 #define SNMPAPI_OUTPUT_TRUNCATED 11
143 #define SNMPAPI_PDU_INVALID 12
144 #define SNMPAPI_SESSION_INVALID 13
145 #define SNMPAPI_SYNTAX_INVALID 14
146 #define SNMPAPI_VBL_INVALID 15
147 #define SNMPAPI_MODE_INVALID 16
148 #define SNMPAPI_SIZE_INVALID 17
149 #define SNMPAPI_NOT_INITIALIZED 18
150 #define SNMPAPI_MESSAGE_INVALID 19
151 #define SNMPAPI_HWND_INVALID 20
152 #define SNMPAPI_ENGINE_INVALID 30
153 #define SNMPAPI_ENGINE_DISCOVERY_FAILED 31
154 #define SNMPAPI_OTHER_ERROR 99
155 #define SNMPAPI_TL_NOT_INITIALIZED 100
156 #define SNMPAPI_TL_NOT_SUPPORTED 101
157 #define SNMPAPI_TL_NOT_AVAILABLE 102
158 #define SNMPAPI_TL_RESOURCE_ERROR 103
159 #define SNMPAPI_TL_UNDELIVERABLE 104
160 #define SNMPAPI_TL_SRC_INVALID 105
161 #define SNMPAPI_TL_INVALID_PARAM 106
162 #define SNMPAPI_TL_IN_USE 107
163 #define SNMPAPI_TL_TIMEOUT 108
164 #define SNMPAPI_TL_PDU_TOO_BIG 109
165 #define SNMPAPI_TL_OTHER 199
166 #define SNMPAPI_RPT_INVALIDMSG 200
167 #define SNMPAPI_RPT_INASNPARSEERR 201
168 #define SNMPAPI_RPT_UNKNOWNSECMODEL 202
169 #define SNMPAPI_RPT_UNKNOWNENGINEID 203
170 #define SNMPAPI_RPT_UNSUPPSECLEVEL 204
171 #define SNMPAPI_RPT_UNKNOWNUSERNAME 205
172 #define SNMPAPI_RPT_WRONGDIGEST 206
173 #define SNMPAPI_RPT_NOTINTIMEWINDOW 207
174 #define SNMPAPI_RPT_DECRYPTIONERROR 208
175 #define SNMPAPI_RPT_OTHER 299
179 typedef HANDLE HSNMP_SESSION
, *LPHSNMP_SESSION
;
180 typedef HANDLE HSNMP_CONTEXT
, *LPHSNMP_CONTEXT
;
181 typedef HANDLE HSNMP_VBL
, *LPHSNMP_VBL
;
182 typedef HANDLE HSNMP_PDU
, *LPHSNMP_PDU
;
183 typedef HANDLE HSNMP_ENTITY
, *LPHSNMP_ENTITY
;
184 typedef unsigned char smiBYTE
, *smiLPBYTE
;
185 typedef signed int smiINT
, *smiLPINT
;
186 typedef signed int smiINT32
, *smiLPINT32
;
187 typedef unsigned int smiUINT32
, *smiLPUINT32
;
188 typedef smiUINT32 smiCNTR32
, *smiLPCNTR32
;
189 typedef smiUINT32 smiGAUGE32
, *smiLPGAUGE32
;
190 typedef smiUINT32 smiTIMETICKS
, *smiLPTIMETICKS
;
191 typedef smiUINT32 SNMPAPI_STATUS
;
195 } smiOCTETS
, *smiLPOCTETS
, smiOPAQUE
, *smiLPOPAQUE
, smiBITS
, *smiLPBITS
, smiIPADDR
, *smiLPIPADDR
, smiNSAPADDR
, *smiLPNSAPADDR
;
196 typedef const smiLPOCTETS smiLPCOCTETS
;
201 typedef const smiLPOID smiLPCOID
;
205 } smiCNTR64
, *smiLPCNTR64
;
216 } smiVALUE
, *smiLPVALUE
;
217 typedef const smiLPVALUE smiLPCVALUE
;
219 CHAR vendorName
[MAXVENDORINFO
*2];
220 CHAR vendorContact
[MAXVENDORINFO
*2];
221 CHAR vendorVersionId
[MAXVENDORINFO
];
222 CHAR vendorVersionDate
[MAXVENDORINFO
];
223 smiUINT32 vendorEnterprise
;
224 } smiVENDORINFO
, FAR
*smiLPVENDORINFO
;
225 typedef SNMPAPI_STATUS (CALLBACK
*SNMPAPI_CALLBACK
)(HSNMP_SESSION
,HWND
,UINT
,WPARAM
,LPARAM
,LPVOID
);
228 HSNMP_ENTITY hEntity
;
229 HSNMP_SESSION hSession
;
230 smiUINT32 nTranslateMode
;
231 smiUINT32 nSnmpVersion
;
232 smiOCTETS dFriendlyName
;
233 smiUINT32 nAddressFamily
;
234 smiOCTETS dAddressString
;
235 smiUINT32 nRequestPort
;
236 smiUINT32 nNotificationPort
;
237 smiUINT32 nMaxMsgSize
;
239 smiUINT32 nEngineBoots
;
240 smiUINT32 nEngineTime
;
241 smiUINT32 nEngineSeconds
;
242 smiUINT32 nRetransmitMode
;
243 smiTIMETICKS nPolicyTimeout
;
244 smiUINT32 nPolicyRetry
;
245 smiTIMETICKS nActualTimeout
;
246 smiUINT32 nActualRetry
;
247 } smiENTITYINFO
, *smiLPENTITYINFO
;
250 HSNMP_CONTEXT hContext
;
251 HSNMP_SESSION hSession
;
252 smiUINT32 nTranslateMode
;
253 smiUINT32 nSnmpVersion
;
254 smiOCTETS dFriendlyName
;
255 smiOCTETS dContextEngineID
;
256 smiOCTETS dContextName
;
257 smiOCTETS dSecurityName
;
258 smiUINT32 nSecurityModel
;
259 smiUINT32 nSecurityLevel
;
260 smiUINT32 nSecurityAuthProtocol
;
261 smiOCTETS dSecurityAuthKey
;
262 smiUINT32 nSecurityPrivProtocol
;
263 smiOCTETS dSecurityPrivKey
;
264 } smiCONTEXTINFO
, *smiLPCONTEXTINFO
;
266 SNMPAPI_STATUS WINSNMPAPI
SnmpCancelMsg(HSNMP_SESSION
,smiINT32
);
267 SNMPAPI_STATUS WINSNMPAPI
SnmpCleanup(VOID
);
268 SNMPAPI_STATUS WINSNMPAPI
SnmpClose(HSNMP_SESSION
);
269 SNMPAPI_STATUS WINSNMPAPI
SnmpContextToStr(HSNMP_CONTEXT
,smiLPOCTETS
);
270 SNMPAPI_STATUS WINSNMPAPI
SnmpCountVbl(HSNMP_VBL
);
271 HSNMP_PDU WINSNMPAPI
SnmpCreatePdu(HSNMP_SESSION
,smiINT
,smiINT32
,smiINT
,smiINT
,HSNMP_VBL
);
272 HSNMP_SESSION WINSNMPAPI
SnmpCreateSession(HWND
,UINT
,SNMPAPI_CALLBACK
,LPVOID
);
273 HSNMP_VBL WINSNMPAPI
SnmpCreateVbl(HSNMP_SESSION
,smiLPCOID
,smiLPCVALUE
);
274 SNMPAPI_STATUS WINSNMPAPI
SnmpDecodeMsg(HSNMP_SESSION
,LPHSNMP_ENTITY
,LPHSNMP_ENTITY
,LPHSNMP_CONTEXT
,LPHSNMP_PDU
,smiLPCOCTETS
);
275 SNMPAPI_STATUS WINSNMPAPI
SnmpDeleteVb(HSNMP_VBL
,smiUINT32
);
276 HSNMP_PDU WINSNMPAPI
SnmpDuplicatePdu(HSNMP_SESSION
,HSNMP_PDU
);
277 HSNMP_VBL WINSNMPAPI
SnmpDuplicateVbl(HSNMP_SESSION
,HSNMP_VBL
);
278 SNMPAPI_STATUS WINSNMPAPI
SnmpEncodeMsg(HSNMP_SESSION
,HSNMP_ENTITY
,HSNMP_ENTITY
,HSNMP_CONTEXT
,HSNMP_PDU
,smiLPOCTETS
);
279 SNMPAPI_STATUS WINSNMPAPI
SnmpEntityToStr(HSNMP_ENTITY
,smiUINT32
,LPSTR
);
280 SNMPAPI_STATUS WINSNMPAPI
SnmpFreeContext(HSNMP_CONTEXT
);
281 SNMPAPI_STATUS WINSNMPAPI
SnmpFreeDescriptor(smiUINT32
,smiLPOPAQUE
);
282 SNMPAPI_STATUS WINSNMPAPI
SnmpFreeEntity(HSNMP_ENTITY
);
283 SNMPAPI_STATUS WINSNMPAPI
SnmpFreePdu(HSNMP_PDU
);
284 SNMPAPI_STATUS WINSNMPAPI
SnmpFreeVbl(HSNMP_VBL
);
285 SNMPAPI_STATUS WINSNMPAPI
SnmpGetLastError(HSNMP_SESSION
);
286 SNMPAPI_STATUS WINSNMPAPI
SnmpGetPduData(HSNMP_PDU
,smiLPINT
,smiLPINT32
,smiLPINT
,smiLPINT
,LPHSNMP_VBL
);
287 SNMPAPI_STATUS WINSNMPAPI
SnmpGetRetransmitMode(smiLPUINT32
);
288 SNMPAPI_STATUS WINSNMPAPI
SnmpGetRetry(HSNMP_ENTITY
,smiLPUINT32
,smiLPUINT32
);
289 SNMPAPI_STATUS WINSNMPAPI
SnmpGetTimeout(HSNMP_ENTITY
,smiLPTIMETICKS
,smiLPTIMETICKS
);
290 SNMPAPI_STATUS WINSNMPAPI
SnmpGetTranslateMode(smiLPUINT32
);
291 SNMPAPI_STATUS WINSNMPAPI
SnmpGetVb(HSNMP_VBL
,smiUINT32
,smiLPOID
,smiLPVALUE
);
292 SNMPAPI_STATUS WINSNMPAPI
SnmpGetVendorInfo(smiLPVENDORINFO
);
293 SNMPAPI_STATUS WINSNMPAPI
SnmpListen(HSNMP_ENTITY
,SNMPAPI_STATUS
);
294 SNMPAPI_STATUS WINSNMPAPI
SnmpOidCompare(smiLPCOID
,smiLPCOID
,smiUINT32
,smiLPINT
);
295 SNMPAPI_STATUS WINSNMPAPI
SnmpOidCopy(smiLPCOID
,smiLPOID
);
296 SNMPAPI_STATUS WINSNMPAPI
SnmpOidToStr(smiLPCOID
,smiUINT32
,LPSTR
);
297 HSNMP_SESSION WINSNMPAPI
SnmpOpen(HWND
,UINT
);
298 SNMPAPI_STATUS WINSNMPAPI
SnmpRecvMsg(HSNMP_SESSION
,LPHSNMP_ENTITY
,LPHSNMP_ENTITY
,LPHSNMP_CONTEXT
,LPHSNMP_PDU
);
299 SNMPAPI_STATUS WINSNMPAPI
SnmpRegister(HSNMP_SESSION
,HSNMP_ENTITY
,HSNMP_ENTITY
,HSNMP_CONTEXT
,smiLPCOID
,smiUINT32
);
300 SNMPAPI_STATUS WINSNMPAPI
SnmpSendMsg(HSNMP_SESSION
,HSNMP_ENTITY
,HSNMP_ENTITY
,HSNMP_CONTEXT
,HSNMP_PDU
);
301 SNMPAPI_STATUS WINSNMPAPI
SnmpSetPduData(HSNMP_PDU
,const smiINT
*,const smiINT32
*,const smiINT
*,const smiINT
*,const HSNMP_VBL
*);
302 SNMPAPI_STATUS WINSNMPAPI
SnmpSetPort(HSNMP_ENTITY
,UINT
);
303 SNMPAPI_STATUS WINSNMPAPI
SnmpSetRetransmitMode(smiUINT32
);
304 SNMPAPI_STATUS WINSNMPAPI
SnmpSetRetry(HSNMP_ENTITY
,smiUINT32
);
305 SNMPAPI_STATUS WINSNMPAPI
SnmpSetTimeout(HSNMP_ENTITY
,smiTIMETICKS
);
306 SNMPAPI_STATUS WINSNMPAPI
SnmpSetTranslateMode(smiUINT32
);
307 SNMPAPI_STATUS WINSNMPAPI
SnmpSetVb(HSNMP_VBL
,smiUINT32
,smiLPCOID
,smiLPCVALUE
);
308 SNMPAPI_STATUS WINSNMPAPI
SnmpStartup(smiLPUINT32
,smiLPUINT32
,smiLPUINT32
,smiLPUINT32
,smiLPUINT32
);
309 HSNMP_CONTEXT WINSNMPAPI
SnmpStrToContext(HSNMP_SESSION
,smiLPCOCTETS
);
310 HSNMP_ENTITY WINSNMPAPI
SnmpStrToEntity(HSNMP_SESSION
,LPCSTR
);
311 SNMPAPI_STATUS WINSNMPAPI
SnmpStrToOid(LPCSTR
,smiLPOID
);
312 /* Added in WinSNMP v3.0, not present in some (all?) versions of MS wsnmp32.dll */
313 HSNMP_ENTITY WINSNMPAPI
SnmpCreateEntity(HSNMP_SESSION
,smiLPENTITYINFO
);
314 SNMPAPI_STATUS WINSNMPAPI
SnmpGetEntityInfo(HSNMP_ENTITY
,smiLPENTITYINFO
);
315 SNMPAPI_STATUS WINSNMPAPI
SnmpSetEntityInfo(HSNMP_ENTITY
,smiLPENTITYINFO
);
316 SNMPAPI_STATUS WINSNMPAPI
SnmpFreeEntityInfo(smiLPENTITYINFO
);
317 HSNMP_CONTEXT WINSNMPAPI
SnmpCreateContext(HSNMP_SESSION
,smiLPCONTEXTINFO
);
318 SNMPAPI_STATUS WINSNMPAPI
SnmpGetContextInfo(HSNMP_CONTEXT
,smiLPCONTEXTINFO
);
319 SNMPAPI_STATUS WINSNMPAPI
SnmpSetContextInfo(HSNMP_CONTEXT
,smiLPCONTEXTINFO
);
320 SNMPAPI_STATUS WINSNMPAPI
SnmpFreeContextInfo(smiLPCONTEXTINFO
);
321 SNMPAPI_STATUS WINSNMPAPI
SnmpPasswordToKey(smiLPOCTETS
,smiINT32
,smiLPOCTETS
);
323 #endif /* RC_INVOKED */