RtlUnicodeStringToCountedOemString() is now "pass"ed
[reactos.git] / include / snmp.h
1 /*
2  *  ReactOS Simple Network Management Protocol - SNMP
3  *
4  *  snmp.h
5  *
6  *  Copyright (C) 2002  Robert Dickenson <robd@reactos.org>
7  *
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.
12  *
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.
17  *
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.
21  */
22
23 #ifndef __SNMP_H__
24 #define __SNMP_H__
25
26 #ifdef __cplusplus
27 extern "C" {
28 #endif
29
30
31 ///////////////////////////////////////////////////////////////////////////////
32 // SNMP Error Codes
33 //
34         
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
47
48 ////////////////////////////////////////////////////////////////////////////////
49 // SNMP Type Definitions
50 //
51
52 #include <pshpack4.h>
53
54 typedef struct {
55     BYTE* stream;
56     UINT length;
57     BOOL dynamic;
58 } AsnOctetString;
59
60 typedef struct {
61     UINT idLength;
62     UINT* ids;
63 } AsnObjectIdentifier;
64
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;
78
79 typedef struct {
80     BYTE asnType;
81     union {
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
94     } asnValue;
95 } AsnAny;
96
97 typedef AsnObjectIdentifier AsnObjectName;
98 typedef AsnAny AsnObjectSyntax;
99
100 typedef struct {
101     AsnObjectName name;
102     AsnObjectSyntax value;
103 } SnmpVarBind;
104
105 typedef struct {
106     SnmpVarBind* list;
107     UINT len;
108 } SnmpVarBindList;
109
110 #include <poppack.h>
111
112 ////////////////////////////////////////////////////////////////////////////////
113 // SNMP Function Prototypes
114 //
115
116 #define SNMPAPI INT
117 #ifndef SNMP_FUNC_TYPE
118 #define SNMP_FUNC_TYPE
119 #endif
120
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);
126
127 LPVOID SNMP_FUNC_TYPE SnmpUtilMemAlloc(
128   UINT nBytes  // bytes to allocate for object
129 );
130
131 VOID SNMP_FUNC_TYPE SnmpUtilMemFree(
132   LPVOID pMem  // pointer to memory object to release
133 );
134
135 LPVOID SNMP_FUNC_TYPE SnmpUtilMemReAlloc(
136   LPVOID pMem,  // pointer to memory object
137   UINT nBytes   // bytes to allocate
138 );
139
140 VOID SNMP_FUNC_TYPE SnmpSvcInitUptime();
141
142 DWORD SNMP_FUNC_TYPE SnmpSvcGetUptime();
143
144 VOID SNMP_FUNC_TYPE SnmpSvcSetLogLevel(
145   INT nLogLevel  // level of severity of the event
146 );
147
148 VOID SNMP_FUNC_TYPE SnmpSvcSetLogType(
149   INT nLogType  // destination for debug output
150 );
151
152 SNMPAPI SNMP_FUNC_TYPE SnmpUtilAsnAnyCpy(
153   AsnAny *pAnyDst,  // destination structure
154   AsnAny *pAnySrc   // source structure
155 );
156
157 VOID SNMP_FUNC_TYPE SnmpUtilAsnAnyFree(
158   AsnAny *pAny  // pointer to structure to free
159 );
160
161 //VOID SNMP_FUNC_TYPE SnmpUtilDbgPrint(
162 //  INT nLogLevel,  // level of severity of event 
163 //  LPSTR szFormat  // pointer to a format string 
164 //);
165
166 LPSTR SNMP_FUNC_TYPE SnmpUtilIdsToA(
167   UINT *Ids,     // object identifier to convert
168   UINT IdLength  // number of elements
169 );
170
171 SNMPAPI SNMP_FUNC_TYPE SnmpUtilOctetsCmp(
172   AsnOctetString *pOctets1,  // first octet string
173   AsnOctetString *pOctets2   // second octet string
174 );
175
176 SNMPAPI SNMP_FUNC_TYPE SnmpUtilOctetsCpy(
177   AsnOctetString *pOctetsDst,  // destination octet string
178   AsnOctetString *pOctetsSrc   // source octet string
179 );
180
181 VOID SNMP_FUNC_TYPE SnmpUtilOctetsFree(
182   AsnOctetString *pOctets  // octet string to free
183 );
184
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
189 );
190
191 SNMPAPI SNMP_FUNC_TYPE SnmpUtilOidAppend(
192   AsnObjectIdentifier *pOidDst,  // destination object identifier
193   AsnObjectIdentifier *pOidSrc   // source object identifier
194 );
195
196 SNMPAPI SNMP_FUNC_TYPE SnmpUtilOidCmp(
197   AsnObjectIdentifier *pOid1,  // first object identifier
198   AsnObjectIdentifier *pOid2   // second object identifier
199 );
200
201 SNMPAPI SNMP_FUNC_TYPE SnmpUtilOidCpy(
202   AsnObjectIdentifier *pOidDst,  // destination object identifier
203   AsnObjectIdentifier *pOidSrc   // source object identifier
204 );
205
206 VOID SNMP_FUNC_TYPE SnmpUtilOidFree(
207   AsnObjectIdentifier *pOid  // object identifier to free
208 );
209
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
214 );
215
216 LPSTR SNMP_FUNC_TYPE SnmpUtilOidToA(
217   AsnObjectIdentifier *Oid  // object identifier to convert
218 );
219
220 VOID SNMP_FUNC_TYPE SnmpUtilPrintAsnAny(
221   AsnAny *pAny  // pointer to value to print
222 );
223
224 VOID SNMP_FUNC_TYPE SnmpUtilPrintOid(
225   AsnObjectIdentifier *Oid  // object identifier to print
226 );
227
228 SNMPAPI SNMP_FUNC_TYPE SnmpUtilVarBindCpy(
229   SnmpVarBind *pVbDst,  // destination variable bindings
230   SnmpVarBind *pVbSrc   // source variable bindings
231 );
232
233 VOID SNMP_FUNC_TYPE SnmpUtilVarBindFree(
234   SnmpVarBind *pVb  // variable binding to free
235 );
236
237 SNMPAPI SNMP_FUNC_TYPE SnmpUtilVarBindListCpy(
238   SnmpVarBindList *pVblDst,  // destination variable bindings list
239   SnmpVarBindList *pVblSrc   // source variable bindings list
240 );
241
242 VOID SNMP_FUNC_TYPE SnmpUtilVarBindListFree(
243   SnmpVarBindList *pVbl  // variable bindings list to free
244 );
245
246
247
248 ////////////////////////////////////////////////////////////////////////////////
249 // SNMP Debugging Definitions
250 //
251
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
258
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
263
264 ////////////////////////////////////////////////////////////////////////////////
265 // SNMP Debugging Prototypes
266 //
267
268 VOID
269 SNMP_FUNC_TYPE
270 SnmpUtilDbgPrint(
271     IN INT nLogLevel,   // see log levels above...
272     IN LPSTR szFormat,
273     IN ...
274     );
275
276 #if DBG
277 #define SNMPDBG(_x_)                    SnmpUtilDbgPrint _x_
278 #else
279 #define SNMPDBG(_x_)
280 #endif
281
282
283 ////////////////////////////////////////////////////////////////////////////////
284
285 #ifdef __cplusplus
286 };
287 #endif
288
289 #endif // __SNMP_H__
290