NetBurner 3.5.7
PDF Version
snmp_table.h
1/*NB_REVISION*/
2
3/*NB_COPYRIGHT*/
4
5
6
7#ifndef _NB_SNMP_TABLE_H
8#define _NB_SNMP_TABLE_H
9
10
11typedef int *snmp_typeObjID;
12typedef const char *snmp_typeString;
13typedef int snmp_typeEnumVal;
14typedef int snmp_typeINTEGER;
16typedef unsigned int snmp_typeCounter;
17typedef int snmp_typeGauge;
18typedef unsigned long snmp_typeTimeTic;
19typedef unsigned long long snmp_typeCounter64;
20typedef unsigned int snmp_typeUnsigned;
21typedef unsigned int snmp_typeUInteger;
22typedef int snmp_typeInteger32;
25typedef unsigned long snmp_typeTimeTicks;
26
27void GetOid( const char *tOid, int *oid );
28
29#define SNMP_SET_WRONG_TYPE (-2)
30#define SNMP_SET_FAIL (-1)
31#define SNMP_SET_OK (0)
32
33#include "asn1.h"
34
35
36#define MAX_COMMUNITY_SIZE (80)
37
38struct SNMP_Request
39{
40 uint8_t community_buffer[MAX_COMMUNITY_SIZE];
41 uint8_t pdu_type;
42 uint32_t comm_mask;
43 int request_id;
44 int error_status;
45 int error_index;
46 int cur_index;
47 ASN get_asn;
48 ASN put_asn;
49 puint8_t pError_Index;
50 puint8_t pError_Value;
51};
52
53
54
55
56#define ASN_typeObjID ASN_OBJECT_ID
57#define ASN_typeString ASN_OCTET_STR
58#define ASN_typeEnumVal ASN_INTEGER
59#define ASN_typeINTEGER ASN_INTEGER
60#define ASN_typeNetAddr ASN_OCTET_STR
61#define ASN_typeCounter SMI_COUNTER32
62#define ASN_typeGauge SMI_GAUGE32
63#define ASN_typeTimeTic SMI_UNSIGNED32
64#define ASN_typeCounter64 SMI_COUNTER64
65#define ASN_typeUnsigned SMI_UNSIGNED32
66#define ASN_typeUInteger SMI_UNSIGNED32
67#define ASN_typeInteger32 SMI_INTEGER
68#define ASN_typeIpAddr SMI_IPADDRESS
69#define ASN_typeTimeTicks SMI_TIMETICKS
70
71
72
73typedef int*( GetpIFunc )();
74typedef const char*( GetCCFunc )();
75typedef void (GetOTFunc )(uint8_t * &pData, int & len);
76typedef int ( GetIFunc )();
77typedef unsigned int ( GetuIFunc )();
78typedef unsigned long ( GetulFunc )();
79typedef unsigned long long ( GetullFunc )();
80typedef MACADR ( GetMadrFunc )();
81
82typedef int ( PutpIFunc ) ( int *, int );
83typedef int ( PutCCFunc ) ( const char *, int );
84typedef int ( PutOTFunc ) ( const unsigned char *, int,int );
85typedef int ( PutIFunc ) ( int, int );
86typedef int ( PutuIFunc ) ( unsigned int, int );
87typedef int ( PutulFunc ) ( unsigned long, int );
88typedef int ( PutullFunc ) ( unsigned long long, int );
89typedef int ( PutMadrFunc )( MACADR, int );
90
91
92
93
94typedef int ( PutpIFuncTab ) ( int *, int, void * );
95typedef int ( PutCCFuncTab ) ( const char *, int, void * );
96typedef int ( PutOTFuncTab ) ( const unsigned char *,int,int, void * );
97typedef int ( PutIFuncTab ) ( int, int, void * );
98typedef int ( PutuIFuncTab ) ( unsigned int, int, void * );
99typedef int ( PutulFuncTab ) ( unsigned long, int, void * );
100typedef int ( PutullFuncTab ) ( unsigned long long, int, void * );
101typedef int ( PutMadrFuncTab )( MACADR, int, void * );
102
103
104
105
106
107typedef void ( GetOIDFunction ) ( SNMP_Request &req, void *data_el, int subid );
108
109
110struct ReadLookUpObject
111{
112 void *pData;
113 int Opaque_int;
114 GetOIDFunction *pf;
115 uint32_t cmask;
116 const char *pOid;
117 ReadLookUpObject *pNext;
118 ReadLookUpObject *pPrev;
119};
120
121
122typedef int ( PutOIDFunction )( SNMP_Request &req,
123 BOOL second_pass,
124 void *pdata,
125 int subid );
126
127struct WriteLookUpObject
128{
129 void *pData;
130 int ObjectType;
131 int WriteType;
132 PutOIDFunction *pf;
133 uint32_t cmask;
134 const char *pOid;
135 WriteLookUpObject *pNext;
136 WriteLookUpObject *pPrev;
137};
138
139
140
141
142
143class SNMPReadObject
144{
145 ReadLookUpObject luo;
146
147 void PopulatelookUpObj( const char *oid,
148 int typ,
149 void *pData,
150 GetOIDFunction *pf,
151 uint32_t commmask );
152
153 public:
154 static void GetpIFunction( SNMP_Request &req, void *data_el, int subid );
155 static void GetuIFunction( SNMP_Request &req, void *data_el, int subid );
156 static void GetCCFunction( SNMP_Request &req, void *data_el, int subid );
157 static void GetOTFunction( SNMP_Request &req, void *data_el, int subid );
158 static void GetIFunction( SNMP_Request &req, void *data_el, int subid );
159 static void GetulFunction( SNMP_Request &req, void *data_el, int subid );
160 static void GetullFunction( SNMP_Request &req, void *data_el, int subid );
161 static void GetMadrFunction( SNMP_Request &req, void *data_el, int subid );
162
163
164 public:
165 SNMPReadObject( const char *oid, int typ, GetpIFunc *pf, uint32_t commmask )
166 {
167 PopulatelookUpObj( oid, typ, ( void * ) pf, GetpIFunction, commmask );
168 };
169 SNMPReadObject( const char *oid, int typ, GetuIFunc *pf, uint32_t commmask )
170 {
171 PopulatelookUpObj( oid, typ, ( void * ) pf, GetuIFunction, commmask );
172 };
173
174
175 SNMPReadObject( const char *oid, int typ, GetCCFunc *pf, uint32_t commmask )
176 {
177 PopulatelookUpObj( oid, typ, ( void * ) pf, GetCCFunction, commmask );
178 };
179
180 SNMPReadObject( const char *oid, int typ, GetOTFunc *pf, uint32_t commmask )
181 {
182 PopulatelookUpObj( oid, typ, ( void * ) pf, GetOTFunction, commmask );
183 };
184
185
186 SNMPReadObject( const char *oid, int typ, GetIFunc *pf, uint32_t commmask )
187 {
188 PopulatelookUpObj( oid, typ, ( void * ) pf, GetIFunction, commmask );
189 };
190 SNMPReadObject( const char *oid, int typ, GetulFunc *pf, uint32_t commmask )
191 {
192 PopulatelookUpObj( oid, typ, ( void * ) pf, GetulFunction, commmask );
193 };
194 SNMPReadObject( const char *oid, int typ, GetullFunc *pf, uint32_t commmask )
195 {
196 PopulatelookUpObj( oid, typ, ( void * ) pf, GetullFunction, commmask );
197 };
198 SNMPReadObject( const char *oid, int typ, GetMadrFunc *pf, uint32_t commmask )
199 {
200 PopulatelookUpObj( oid, typ, ( void * ) pf, GetMadrFunction, commmask );
201 };
202};
203
204
205
206class SNMPWriteObject
207{
208 WriteLookUpObject luo;
209 /* returns non zero if set is ok */
210 static int PutpIFunction( SNMP_Request &req,
211 BOOL second_pass,
212 void *pdata,
213 int subid );
214 static int PutuIFunction( SNMP_Request &req,
215 BOOL second_pass,
216 void *pdata,
217 int subid );
218 static int PutCCFunction( SNMP_Request &req,BOOL second_pass,void *pdata,int subid );
219
220 static int PutOTFunction( SNMP_Request &req,BOOL second_pass,void *pdata,int subid );
221
222 static int PutIFunction( SNMP_Request &req, BOOL second_pass, void *pdata, int subid );
223
224 static int PutulFunction( SNMP_Request &req,BOOL second_pass,void *pdata,int subid );
225
226 static int PutullFunction( SNMP_Request &req,BOOL second_pass,void *pdata,int subid );
227
228 static int PutMadrFunction( SNMP_Request &req,BOOL second_pass,void *pdata,int subid );
229
230 void PopulatelookUpObj( const char *oid,int typ,void *pData,PutOIDFunction *pf,uint32_t commmask );
231
232
233 public:
234 SNMPWriteObject( const char *oid, int typ, PutpIFunc *pf, uint32_t commmask )
235 {
236 PopulatelookUpObj( oid, typ, ( void * ) pf, PutpIFunction, commmask );
237 };
238 SNMPWriteObject( const char *oid, int typ, PutuIFunc *pf, uint32_t commmask )
239 {
240 PopulatelookUpObj( oid, typ, ( void * ) pf, PutuIFunction, commmask );
241 };
242 SNMPWriteObject( const char *oid, int typ, PutCCFunc *pf, uint32_t commmask )
243 {
244 PopulatelookUpObj( oid, typ, ( void * ) pf, PutCCFunction, commmask );
245 };
246
247 SNMPWriteObject( const char *oid, int typ, PutOTFunc *pf, uint32_t commmask )
248 {
249 PopulatelookUpObj( oid, typ, ( void * ) pf, PutOTFunction, commmask );
250 };
251
252
253 SNMPWriteObject( const char *oid, int typ, PutIFunc *pf, uint32_t commmask )
254 {
255 PopulatelookUpObj( oid, typ, ( void * ) pf, PutIFunction, commmask );
256 };;
257 SNMPWriteObject( const char *oid, int typ, PutulFunc *pf, uint32_t commmask )
258 {
259 PopulatelookUpObj( oid, typ, ( void * ) pf, PutulFunction, commmask );
260 };
261 SNMPWriteObject( const char *oid, int typ, PutullFunc *pf, uint32_t commmask )
262 {
263 PopulatelookUpObj( oid, typ, ( void * ) pf, PutullFunction, commmask );
264 };
265 SNMPWriteObject( const char *oid, int typ, PutMadrFunc *pf, uint32_t commmask )
266 {
267 PopulatelookUpObj( oid, typ, ( void * ) pf, PutMadrFunction, commmask );
268 };
269};
270
271
272void InitializeMibs();
273
274
275#define SNMPREADFUNC(w,x,y,z,q) static SNMPReadObject W##w(x,y,z,q);
276#define SNMPWRITEFUNC(w,x,y,z,q) static SNMPWriteObject R##w(x,y,z,q);
277
278void AddToIndex( int asn_type, snmp_typeObjID val, int &len, int *oidadd );
279void AddToIndex( int asn_type, snmp_typeString val, int &len, int *oidadd );
280void AddToIndex( int asn_type, snmp_typeEnumVal val, int &len, int *oidadd );
281void AddToIndex( int asn_type, snmp_typeINTEGER val, int &len, int *oidadd );
282void AddToIndex( int asn_type, snmp_typeNetAddr val, int &len, int *oidadd );
283void AddToIndex( int asn_type, snmp_typeCounter val, int &len, int *oidadd );
284void AddToIndex( int asn_type, snmp_typeGauge val, int &len, int *oidadd );
285void AddToIndex( int asn_type, snmp_typeTimeTic val, int &len, int *oidadd );
286void AddToIndex( int asn_type, snmp_typeCounter64 val, int &len, int *oidadd );
287void AddToIndex( int asn_type, snmp_typeUnsigned val, int &len, int *oidadd );
288void AddToIndex( int asn_type, snmp_typeUInteger val, int &len, int *oidadd );
289void AddToIndex( int asn_type, snmp_typeInteger32 val, int &len, int *oidadd );
290void AddToIndex( int asn_type, snmp_typeIpAddr val, int &len, int *oidadd );
291void AddToIndex( int asn_type, snmp_typeTimeTicks val, int &len, int *oidadd );
292
293
294
295
296typedef void ( TableElementFunc )( SNMP_Request &req, void *data_el, int subid );
297
298void AddSnmpEntry( int subid,
299 const char *root,
300 int add_len,
301 int *suffix,
302 TableElementFunc *pf,
303 void *pData,
304 uint32_t comm_mask );
305
306void AddSnmpWriteEntry( int asn_type,
307 const char *root,
308 int add_len,
309 int *suffix,
310 PutpIFuncTab *pf,
311 void *pData,
312 uint32_t comm_mask );
313void AddSnmpWriteEntry( int asn_type,
314 const char *root,
315 int add_len,
316 int *suffix,
317 PutCCFuncTab *pf,
318 void *pData,
319 uint32_t comm_mask );
320
321void AddSnmpWriteEntry( int asn_type,
322 const char *root,
323 int add_len,
324 int *suffix,
325 PutOTFuncTab *pf,
326 void *pData,
327 uint32_t comm_mask );
328
329
330
331void AddSnmpWriteEntry( int asn_type,
332 const char *root,
333 int add_len,
334 int *suffix,
335 PutIFuncTab *pf,
336 void *pData,
337 uint32_t comm_mask );
338void AddSnmpWriteEntry( int asn_type,
339 const char *root,
340 int add_len,
341 int *suffix,
342 PutulFuncTab *pf,
343 void *pData,
344 uint32_t comm_mask );
345void AddSnmpWriteEntry( int asn_type,
346 const char *root,
347 int add_len,
348 int *suffix,
349 PutuIFuncTab *pf,
350 void *pData,
351 uint32_t comm_mask );
352void AddSnmpWriteEntry( int asn_type,
353 const char *root,
354 int add_len,
355 int *suffix,
356 PutullFuncTab *pf,
357 void *pData,
358 uint32_t comm_mask );
359void AddSnmpWriteEntry( int asn_type,
360 const char *root,
361 int add_len,
362 int *suffix,
363 PutMadrFuncTab *pf,
364 void *pData,
365 uint32_t comm_mask );
366
367void SnmpRemoveTableElement( const char *root, void *data_el );
368
369
370#endif
371
372
373
374
375
376
377
Used to store and manipulate IPv4 addresses in dual stack mode.
Definition nettypes.h:225
Used to hold and manipulate IPv4 and IPv6 addresses in dual stack mode.
Definition ipv6_addr.h:41
Used to store and manipulate MAC addresses.
Definition nettypes.h:69
class MACADR MACADR
Used to store and manipulate MAC addresses.