2 * ReactOS Simple Network Management Protocol - SNMP
6 * Copyright (C) 2002 Robert Dickenson <robd@reactos.org>
8 * This program is free software; you can redistribute it and/or modify
9 * it under the terms of the GNU General Public License as published by
10 * the Free Software Foundation; either version 2 of the License, or
11 * (at your option) any later version.
13 * This program is distributed in the hope that it will be useful,
14 * but WITHOUT ANY WARRANTY; without even the implied warranty of
15 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
16 * GNU General Public License for more details.
18 * You should have received a copy of the GNU General Public License
19 * along with this program; if not, write to the Free Software
20 * Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA.
31 ///////////////////////////////////////////////////////////////////////////////
35 #define SNMP_MEM_ALLOC_ERROR 1
36 #define SNMP_BERAPI_INVALID_LENGTH 10
37 #define SNMP_BERAPI_INVALID_TAG 11
38 #define SNMP_BERAPI_OVERFLOW 12
39 #define SNMP_BERAPI_SHORT_BUFFER 13
40 #define SNMP_BERAPI_INVALID_OBJELEM 14
41 #define SNMP_PDUAPI_UNRECOGNIZED_PDU 20
42 #define SNMP_PDUAPI_INVALID_ES 21
43 #define SNMP_PDUAPI_INVALID_GT 22
44 #define SNMP_AUTHAPI_INVALID_VERSION 30
45 #define SNMP_AUTHAPI_INVALID_MSG_TYPE 31
46 #define SNMP_AUTHAPI_TRIV_AUTH_FAILED 32
48 ////////////////////////////////////////////////////////////////////////////////
49 // SNMP Type Definitions
63 } AsnObjectIdentifier;
65 typedef LONG AsnInteger32;
66 typedef ULONG AsnUnsigned32;
67 typedef ULARGE_INTEGER AsnCounter64;
68 typedef AsnUnsigned32 AsnCounter32;
69 typedef AsnUnsigned32 AsnGauge32;
70 typedef AsnUnsigned32 AsnTimeticks;
71 typedef AsnOctetString AsnBits;
72 typedef AsnOctetString AsnSequence;
73 typedef AsnOctetString AsnImplicitSequence;
74 typedef AsnOctetString AsnIPAddress;
75 typedef AsnOctetString AsnNetworkAddress;
76 typedef AsnOctetString AsnDisplayString;
77 typedef AsnOctetString AsnOpaque;
82 AsnInteger32 number; // ASN_INTEGER & ASN_INTEGER32
83 AsnUnsigned32 unsigned32; // ASN_UNSIGNED32
84 AsnCounter64 counter64; // ASN_COUNTER64
85 AsnOctetString string; // ASN_OCTETSTRING
86 AsnBits bits; // ASN_BITS
87 AsnObjectIdentifier object; // ASN_OBJECTIDENTIFIER
88 AsnSequence sequence; // ASN_SEQUENCE
89 AsnIPAddress address; // ASN_IPADDRESS
90 AsnCounter32 counter; // ASN_COUNTER32
91 AsnGauge32 gauge; // ASN_GAUGE32
92 AsnTimeticks ticks; // ASN_TIMETICKS
93 AsnOpaque arbitrary; // ASN_OPAQUE
97 typedef AsnObjectIdentifier AsnObjectName;
98 typedef AsnAny AsnObjectSyntax;
102 AsnObjectSyntax value;
112 ////////////////////////////////////////////////////////////////////////////////
113 // SNMP Function Prototypes
117 #ifndef SNMP_FUNC_TYPE
118 #define SNMP_FUNC_TYPE
121 //LPVOID SNMP_FUNC_TYPE SnmpUtilMemAlloc(UINT nBytes);
122 //VOID SNMP_FUNC_TYPE SnmpUtilMemFree(LPVOID pMem);
123 //SNMPAPI SNMP_FUNC_TYPE SnmpUtilOidCpy(AsnObjectIdentifier* pOidDst, AsnObjectIdentifier* pOidSrc);
124 //VOID SNMP_FUNC_TYPE SnmpUtilOidFree(AsnObjectIdentifier* pOid);
125 //VOID SNMP_FUNC_TYPE SnmpUtilVarBindFree(SnmpVarBind* pVb);
127 LPVOID SNMP_FUNC_TYPE SnmpUtilMemAlloc(
128 UINT nBytes // bytes to allocate for object
131 VOID SNMP_FUNC_TYPE SnmpUtilMemFree(
132 LPVOID pMem // pointer to memory object to release
135 LPVOID SNMP_FUNC_TYPE SnmpUtilMemReAlloc(
136 LPVOID pMem, // pointer to memory object
137 UINT nBytes // bytes to allocate
140 VOID SNMP_FUNC_TYPE SnmpSvcInitUptime();
142 DWORD SNMP_FUNC_TYPE SnmpSvcGetUptime();
144 VOID SNMP_FUNC_TYPE SnmpSvcSetLogLevel(
145 INT nLogLevel // level of severity of the event
148 VOID SNMP_FUNC_TYPE SnmpSvcSetLogType(
149 INT nLogType // destination for debug output
152 SNMPAPI SNMP_FUNC_TYPE SnmpUtilAsnAnyCpy(
153 AsnAny *pAnyDst, // destination structure
154 AsnAny *pAnySrc // source structure
157 VOID SNMP_FUNC_TYPE SnmpUtilAsnAnyFree(
158 AsnAny *pAny // pointer to structure to free
161 //VOID SNMP_FUNC_TYPE SnmpUtilDbgPrint(
162 // INT nLogLevel, // level of severity of event
163 // LPSTR szFormat // pointer to a format string
166 LPSTR SNMP_FUNC_TYPE SnmpUtilIdsToA(
167 UINT *Ids, // object identifier to convert
168 UINT IdLength // number of elements
171 SNMPAPI SNMP_FUNC_TYPE SnmpUtilOctetsCmp(
172 AsnOctetString *pOctets1, // first octet string
173 AsnOctetString *pOctets2 // second octet string
176 SNMPAPI SNMP_FUNC_TYPE SnmpUtilOctetsCpy(
177 AsnOctetString *pOctetsDst, // destination octet string
178 AsnOctetString *pOctetsSrc // source octet string
181 VOID SNMP_FUNC_TYPE SnmpUtilOctetsFree(
182 AsnOctetString *pOctets // octet string to free
185 SNMPAPI SNMP_FUNC_TYPE SnmpUtilOctetsNCmp(
186 AsnOctetString *pOctets1, // first octet string
187 AsnOctetString *pOctets2, // second octet string
188 UINT nChars // maximum length to compare
191 SNMPAPI SNMP_FUNC_TYPE SnmpUtilOidAppend(
192 AsnObjectIdentifier *pOidDst, // destination object identifier
193 AsnObjectIdentifier *pOidSrc // source object identifier
196 SNMPAPI SNMP_FUNC_TYPE SnmpUtilOidCmp(
197 AsnObjectIdentifier *pOid1, // first object identifier
198 AsnObjectIdentifier *pOid2 // second object identifier
201 SNMPAPI SNMP_FUNC_TYPE SnmpUtilOidCpy(
202 AsnObjectIdentifier *pOidDst, // destination object identifier
203 AsnObjectIdentifier *pOidSrc // source object identifier
206 VOID SNMP_FUNC_TYPE SnmpUtilOidFree(
207 AsnObjectIdentifier *pOid // object identifier to free
210 SNMPAPI SNMP_FUNC_TYPE SnmpUtilOidNCmp(
211 AsnObjectIdentifier *pOid1, // first object identifier
212 AsnObjectIdentifier *pOid2, // second object identifier
213 UINT nSubIds // maximum length to compare
216 LPSTR SNMP_FUNC_TYPE SnmpUtilOidToA(
217 AsnObjectIdentifier *Oid // object identifier to convert
220 VOID SNMP_FUNC_TYPE SnmpUtilPrintAsnAny(
221 AsnAny *pAny // pointer to value to print
224 VOID SNMP_FUNC_TYPE SnmpUtilPrintOid(
225 AsnObjectIdentifier *Oid // object identifier to print
228 SNMPAPI SNMP_FUNC_TYPE SnmpUtilVarBindCpy(
229 SnmpVarBind *pVbDst, // destination variable bindings
230 SnmpVarBind *pVbSrc // source variable bindings
233 VOID SNMP_FUNC_TYPE SnmpUtilVarBindFree(
234 SnmpVarBind *pVb // variable binding to free
237 SNMPAPI SNMP_FUNC_TYPE SnmpUtilVarBindListCpy(
238 SnmpVarBindList *pVblDst, // destination variable bindings list
239 SnmpVarBindList *pVblSrc // source variable bindings list
242 VOID SNMP_FUNC_TYPE SnmpUtilVarBindListFree(
243 SnmpVarBindList *pVbl // variable bindings list to free
248 ////////////////////////////////////////////////////////////////////////////////
249 // SNMP Debugging Definitions
252 #define SNMP_LOG_SILENT 0x0
253 #define SNMP_LOG_FATAL 0x1
254 #define SNMP_LOG_ERROR 0x2
255 #define SNMP_LOG_WARNING 0x3
256 #define SNMP_LOG_TRACE 0x4
257 #define SNMP_LOG_VERBOSE 0x5
259 #define SNMP_OUTPUT_TO_CONSOLE 0x1
260 #define SNMP_OUTPUT_TO_LOGFILE 0x2
261 //#define SNMP_OUTPUT_TO_EVENTLOG 0x4 // no longer supported
262 #define SNMP_OUTPUT_TO_DEBUGGER 0x8
264 ////////////////////////////////////////////////////////////////////////////////
265 // SNMP Debugging Prototypes
271 IN INT nLogLevel, // see log levels above...
277 #define SNMPDBG(_x_) SnmpUtilDbgPrint _x_
283 ////////////////////////////////////////////////////////////////////////////////