-
Notifications
You must be signed in to change notification settings - Fork 13
/
ArduinoSNMP.cpp
650 lines (544 loc) · 17.6 KB
/
ArduinoSNMP.cpp
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
255
256
257
258
259
260
261
262
263
264
265
266
267
268
269
270
271
272
273
274
275
276
277
278
279
280
281
282
283
284
285
286
287
288
289
290
291
292
293
294
295
296
297
298
299
300
301
302
303
304
305
306
307
308
309
310
311
312
313
314
315
316
317
318
319
320
321
322
323
324
325
326
327
328
329
330
331
332
333
334
335
336
337
338
339
340
341
342
343
344
345
346
347
348
349
350
351
352
353
354
355
356
357
358
359
360
361
362
363
364
365
366
367
368
369
370
371
372
373
374
375
376
377
378
379
380
381
382
383
384
385
386
387
388
389
390
391
392
393
394
395
396
397
398
399
400
401
402
403
404
405
406
407
408
409
410
411
412
413
414
415
416
417
418
419
420
421
422
423
424
425
426
427
428
429
430
431
432
433
434
435
436
437
438
439
440
441
442
443
444
445
446
447
448
449
450
451
452
453
454
455
456
457
458
459
460
461
462
463
464
465
466
467
468
469
470
471
472
473
474
475
476
477
478
479
480
481
482
483
484
485
486
487
488
489
490
491
492
493
494
495
496
497
498
499
500
501
502
503
504
505
506
507
508
509
510
511
512
513
514
515
516
517
518
519
520
521
522
523
524
525
526
527
528
529
530
531
532
533
534
535
536
537
538
539
540
541
542
543
544
545
546
547
548
549
550
551
552
553
554
555
556
557
558
559
560
561
562
563
564
565
566
567
568
569
570
571
572
573
574
575
576
577
578
579
580
581
582
583
584
585
586
587
588
589
590
591
592
593
594
595
596
597
598
599
600
601
602
603
604
605
606
607
608
609
610
611
612
613
614
615
616
617
618
619
620
621
622
623
624
625
626
627
628
629
630
631
632
633
634
635
636
637
638
639
640
641
642
643
644
645
646
647
648
649
650
/*
ArduinoSNMP.cpp - An Arduino library for a lightweight SNMP Agent. v2.2
Copyright (C) 2013 Rex Park <rex.park@me.com>, Portions (C) 2010 Eric C. Gionet <lavco_eg@hotmail.com>
All rights reserved.
This library is free software; you can redistribute it and/or
modify it under the terms of the GNU Lesser General Public
License as published by the Free Software Foundation; either
version 2.1 of the License, or (at your option) any later version.
This library is distributed in the hope that it will be useful,
but WITHOUT ANY WARRANTY; without even the implied warranty of
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
Lesser General Public License for more details.
You should have received a copy of the GNU Lesser General Public
License along with this library; if not, write to the Free Software
Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA
*/
#include "ArduinoSNMP.h"
#include <EthernetUdp.h>
EthernetUDP Udp;
SNMP_API_STAT_CODES SNMPClass::begin(const char *getCommName, const char *setCommName, const char *trapCommName, uint16_t port)
{
//initialize request counter
requestCounter = 1;
_extra_data_size = 0;
_udp_extra_data_packet = false;
// set community name set/get sizes
_setSize = strlen(setCommName);
_getSize = strlen(getCommName);
_trapSize = strlen(trapCommName);
//
// validate get/set community name sizes
if ( _setSize > SNMP_MAX_NAME_LEN + 1 || _getSize > SNMP_MAX_NAME_LEN + 1 || _trapSize > SNMP_MAX_NAME_LEN + 1) {
return SNMP_API_STAT_NAME_TOO_BIG;
}
//
// set community names
_getCommName = getCommName;
_setCommName = setCommName;
_trapCommName = trapCommName;
// validate session port number
if ( port == NULL || port == 0 ) port = SNMP_DEFAULT_PORT;
//
// init UDP socket
Udp.stop();
Udp.begin(port);
return SNMP_API_STAT_SUCCESS;
}
boolean SNMPClass::listen(void)
{
// if bytes are available in receive buffer
// and pointer to a function (delegate function)
// isn't null, trigger the function
if(Udp.parsePacket() > 1024){
_udp_extra_data_packet = true;
}else{
_udp_extra_data_packet = false;
}
if (Udp.available()){
if(_callback != NULL){
(*_callback)();
}else{
return true;
}
}
return false;
}
/**
* Parses incoming SNMP messages.
*
* Original Auther: Rex Park
* Updated: November 7, 2015 (Added support for Inform responses (SNMP_PDU_RESPONSE)
*/
SNMP_API_STAT_CODES SNMPClass::requestPdu(SNMP_PDU *pdu, char *extra_data, int extra_data_max_size)
{
// sequence length
uint16_t seqLen, valLen, vblLen, pduLen;
// version
byte verLen, verEnd;
// community string
byte comLen, comEnd;
// pdu
byte pduTyp, pduEnd;
byte ridLen, ridEnd;
byte errLen, errEnd;
byte eriLen, eriEnd;
byte vblTyp;
byte vbiTyp, vbiLen;
byte obiLen, obiEnd;
byte valTyp, valEnd;
int i;
// set packet packet size (skip UDP header)
_packetSize = Udp.available();
_packetPos = 0;
// reset packet array
memset(_packet, 0, SNMP_MAX_PACKET_LEN);
//
// validate packet
if ( _packetSize <= 0) {
return SNMP_API_STAT_PACKET_TOO_BIG;
}
// get UDP packet
if(_udp_extra_data_packet == true){
if(extra_data != NULL){
memset(extra_data, 0, extra_data_max_size);
}
Udp.read(_packet, _packetSize - extra_data_max_size);
if(extra_data != NULL){
Udp.read((byte*)extra_data, extra_data_max_size);
}
}else{
Udp.read(_packet, _packetSize);
}
// Serial.println("Incomming: ");
// for(int i = 0; i < _packetSize; i++){
// Serial.print(_packet[i],HEX);
// Serial.print(" ");
// }
// Serial.println();
// packet check 1
if ( _packet[0] != 0x30 ) {
return SNMP_API_STAT_PACKET_INVALID;
}
// sequence length
if(_packet[1] >= 0x82){
seqLen = combine_msb_lsb(_packet[2], _packet[3]);
_packetPos = 4;
}
else if(_packet[1] == 0x81){
seqLen = _packet[2];
_packetPos = 3;
}else{
seqLen = _packet[1];
_packetPos = 2;
}
// version
if(_packet[_packetPos] != 0x02){
return SNMP_API_STAT_PACKET_INVALID;
}
verLen = _packet[_packetPos+1];//used to be hard coded as index 3
verEnd = _packetPos+1 + verLen;
// community string
comLen = _packet[verEnd + 2];
comEnd = verEnd + 2 + comLen;
// pdu
pduTyp = _packet[comEnd + 1];
if(_packet[comEnd + 2] >= 0x82){
pduLen = combine_msb_lsb(_packet[comEnd +3], _packet[comEnd +4]);
pduEnd = comEnd + 2 + pduLen + 2;
_packetPos = comEnd + 2 + 2;
}
else if(_packet[comEnd + 2] == 0x81){
pduLen = _packet[comEnd +3];
pduEnd = comEnd + 2 + pduLen + 1;
_packetPos = comEnd + 2 + 1;
}else{
pduLen = _packet[comEnd + 2];
pduEnd = comEnd + 2 + pduLen;
_packetPos = comEnd + 2;
}
//request id
ridLen = _packet[_packetPos + 2];
ridEnd = _packetPos + 2 + ridLen;
//error
errLen = _packet[ridEnd + 2];
errEnd = ridEnd + 2 + errLen;
//error index
eriLen = _packet[errEnd + 2];
eriEnd = errEnd + 2 + eriLen;
//variable bindings
vblTyp = _packet[eriEnd + 1];
if(_packet[eriEnd + 2] >= 0x82){
vblLen = combine_msb_lsb(_packet[eriEnd +3], _packet[eriEnd +4]);
_packetPos = eriEnd + 2 + 2;
}
else if(_packet[eriEnd + 2] == 0x81){
vblLen = _packet[eriEnd +3];
_packetPos = eriEnd + 2 + 1;
}else{
vblLen = _packet[eriEnd + 2];
_packetPos = eriEnd + 2;
}
//variable bindings id
vbiTyp = _packet[_packetPos + 1];
if(_packet[_packetPos + 2] > 0x80){
vbiLen = combine_msb_lsb(_packet[_packetPos +3], _packet[_packetPos +4]);
_packetPos = _packetPos + 2 + 2;
}else{
vbiLen = _packet[_packetPos + 2];
_packetPos = _packetPos + 2;
}
//object identifier
obiLen = _packet[_packetPos + 2];
obiEnd = _packetPos + 2 + obiLen;
//unknown
valTyp = _packet[obiEnd + 1];
if(_packet[obiEnd + 2] >= 0x82){
valLen = combine_msb_lsb(_packet[obiEnd +3], _packet[obiEnd +4]);
valEnd = obiEnd + 2 + valLen + 2;
}
else if(_packet[obiEnd + 2] == 0x81){
valLen = _packet[obiEnd + 3];
valEnd = obiEnd + 2 + valLen + 1;
}else{
valLen = _packet[obiEnd + 2];
valEnd = obiEnd + 2 + valLen;
}
// Serial.println(verEnd);
// Serial.println(comEnd);
// Serial.println(ridEnd);
// Serial.println(errEnd);
// Serial.println(eriEnd);
// Serial.println(obiEnd);
// Serial.println(pduEnd);
// Serial.println(pduTyp,HEX);
// extract version
pdu->version = _packet[verEnd];
// Serial.println(pdu->version,HEX);
// validate version
if(pdu->version != 0x0 && pdu->version != 0x1){
return SNMP_API_STAT_PACKET_INVALID;
}
// pdu-type
pdu->type = (SNMP_PDU_TYPES)pduTyp;
_dstType = pdu->type;
// validate community size
if ( comLen > SNMP_MAX_NAME_LEN ) {
// set pdu error
pdu->error = SNMP_ERR_TOO_BIG;
//
return SNMP_API_STAT_NAME_TOO_BIG;
}
// validate community name
if ( pdu->type == SNMP_PDU_SET && comLen == _setSize ) {
if(memcmp(_setCommName,_packet+verEnd+3,_setSize) != 0){
pdu->error = SNMP_ERR_NO_SUCH_NAME;
return SNMP_API_STAT_NO_SUCH_NAME;
}
} else if ( pdu->type == SNMP_PDU_GET) {
if(memcmp(_getCommName,_packet+verEnd+3,comLen) != 0 && memcmp(_setCommName,_packet+verEnd+3,comLen) != 0){
pdu->error = SNMP_ERR_NO_SUCH_NAME;
return SNMP_API_STAT_NO_SUCH_NAME;
}
} else if (pdu->type == SNMP_PDU_RESPONSE){
if(memcmp(_trapCommName,_packet+verEnd+3,comLen) != 0){
pdu->error = SNMP_ERR_NO_SUCH_NAME;
return SNMP_API_STAT_NO_SUCH_NAME;
}
}
else {
// set pdu error
pdu->error = SNMP_ERR_NO_SUCH_NAME;
//
return SNMP_API_STAT_NO_SUCH_NAME;
}
// extract reqiest-id 0x00 0x00 0x00 0x01 (4-byte int aka int32)
pdu->requestId = 0;
for ( i = 0; i < ridLen; i++ ) {
pdu->requestId = (pdu->requestId << 8) | _packet[ridEnd-ridLen+1 + i];
}
// extract error
pdu->error = SNMP_ERR_NO_ERROR;
int32_t err = 0;
for ( i = 0; i < errLen; i++ ) {
err = (err << 8) | _packet[errEnd-errLen+1 + i];
}
pdu->error = (SNMP_ERR_CODES)err;
// extract error-index
pdu->errorIndex = 0;
for ( i = 0; i < eriLen; i++ ) {
pdu->errorIndex = (pdu->errorIndex << 8) | _packet[eriEnd-eriLen+1 + i];
}
/**
* OID
*/
//validate length
if ( obiLen > SNMP_MAX_OID_LEN ) {
pdu->error = SNMP_ERR_TOO_BIG;
return SNMP_API_STAT_OID_TOO_BIG;
}
//decode OID
memset(pdu->value.OID.data, 0, SNMP_MAX_OID_LEN);
if(pdu->value.OID.decode(_packet + (obiEnd-obiLen+1), obiLen) != SNMP_API_STAT_SUCCESS){
return SNMP_API_STAT_MALLOC_ERR;
}
/**
* Value
*/
//syntax type
pdu->value.syntax = (SNMP_SYNTAXES)valTyp;
//check length of data
if ( valLen > SNMP_MAX_VALUE_LEN && _udp_extra_data_packet == false) {
pdu->error = SNMP_ERR_TOO_BIG;
return SNMP_API_STAT_VALUE_TOO_BIG;
}
//set value size
pdu->value.size = valLen;
if(_udp_extra_data_packet == true){
// memset(extra_data, '\0', extra_data_max_size);
// for ( i = 0; i < valLen; i++ ) {
// extra_data[i] = _packet[obiEnd+3 + i];
// }
}else{
memset(pdu->value.data, 0, SNMP_MAX_VALUE_LEN);
for ( i = 0; i < valLen; i++ ) {
pdu->value.data[i] = _packet[obiEnd+3 + i];
}
}
return SNMP_API_STAT_SUCCESS;
}
/**
* Sends a PDU as a v1 trap. (needs testing after v2 trap changes)
* OID: The full enterprise OID for the trap you want to send: everything in the trap's OID from the initial .1
* up to the enterprise number, including any subtrees within the enterprise but not the specific trap number.
* value: will be an array of pre-encoded data
*
* Original Author: Yazgoo
* Updated: Rex Park, March 29, 2013. (Adjusting for new encoding changes and PDU structure)
*
* Broken as of November 10th 2013 due to writeHeaders re-write. Needs to be modified to work like responsePdu
*/
uint32_t SNMPClass::sendTrapv1(SNMP_PDU *pdu, SNMP_TRAP_TYPES trap_type, int16_t specific_trap, IPAddress manager_address){
byte i;
SNMP_VALUE value;
_dstType = pdu->type = SNMP_PDU_TRAP;
_packetPos = 0;
uint16_t size = 27 + 2 + pdu->value.size;
this->writeHeaders(pdu);
//unknown
_packet[_packetPos++] = (byte) size - 1;
i = _packetPos-1;//i now stores the location of the PDU size, need to update after OID encoding.
//Enterprise OID
_packetPos += pdu->value.OID.encode(_packet + _packetPos);
//adjust sizes now that OID is encoded.
_packetSize += pdu->value.OID.size-2;
_packet[1] += pdu->value.OID.size-2;
_packet[i] += pdu->value.OID.size-2;
//Agent IP
value.encode_address(SNMP_SYNTAX_IP_ADDRESS, pdu->agent_address, _packet + _packetPos);
_packetPos += value.size;
//trap type
value.encode(SNMP_SYNTAX_INT, (int16_t)trap_type, _packet + _packetPos);
_packetPos += value.size;
//specific trap id
value.encode(SNMP_SYNTAX_INT, specific_trap, _packet + _packetPos);
_packetPos += value.size;
//Time Ticks
//Similar error as previous commit in ArduinoSNMP.h.
//value.encode(SNMP_SYNTAX_TIME_TICKS, millis() / 10, _packet + _packetPos);
value.encode(SNMP_SYNTAX_TIME_TICKS, (const uint64_t)millis()/10, _packet + _packetPos);
_packetPos +=6;//syntax + length + 4 octets
//unknown
_packet[_packetPos++] = (byte) SNMP_SYNTAX_SEQUENCE;
_packet[_packetPos++] = (byte) 4 + pdu->value.size;
//trap data, already encoded prior to function call
for ( i = 0; i < pdu->value.size; i++ ) {
_packet[_packetPos++] = pdu->value.data[i];
}
writePacket(manager_address, SNMP_MANAGER_PORT);
return pdu->requestId;
}
/**
* Generates SNMP header data.
*
* Original Auther: Rex Park
* Updated: November 7, 2015 (Added support for Informs (SNMP_PDU_INFORM_REQUEST)
*/
uint16_t SNMPClass::writeHeaders(SNMP_PDU *pdu)
{
byte i;
// SNMP community string
if(_dstType == SNMP_PDU_SET){
for(i = _setSize-1; i >= 0 && i <= 30; i--){
_packet[_packetPos--] = (byte)_setCommName[i];
}
_packet[_packetPos--] = (byte)_setSize; // length
}else if(_dstType == SNMP_PDU_TRAP || _dstType == SNMP_PDU_TRAP2 || _dstType == SNMP_PDU_INFORM_REQUEST){
for(i = _trapSize-1; i >= 0 && i <= 30; i--){
_packet[_packetPos--] = (byte)_trapCommName[i];
}
_packet[_packetPos--] = (byte)_trapSize; // length
}else {
for(i = _getSize-1; i >= 0 && i <= 30; i--){
_packet[_packetPos--] = (byte)_getCommName[i];
}
_packet[_packetPos--] = (byte)_getSize; // length
}
_packet[_packetPos--] = (byte)SNMP_SYNTAX_OCTETS;// type
// version
_packet[_packetPos--] = (byte)pdu->version;// value
_packet[_packetPos--] = 0x01; // length
_packet[_packetPos--] = (byte)SNMP_SYNTAX_INT;//type
//start of header
//length of all data after this point
_packet[_packetPos] = lsb(packet_length()+_extra_data_size);
_packet[_packetPos-1] = msb(packet_length()+_extra_data_size);
_packetPos -= 2;
_packet[_packetPos--] = 0x82;//Sending length in two octets
_packet[_packetPos--] = (byte)SNMP_SYNTAX_SEQUENCE;
//packet type
if ( _dstType == SNMP_PDU_SET ) {
_packetSize += _setSize;
} else if ( _dstType == SNMP_PDU_TRAP ) {
_packetSize += _trapSize;
} else {
_packetSize += _getSize;
}
return _packetPos;
}
uint32_t SNMPClass::send_message(SNMP_PDU *pdu, IPAddress to_address, uint16_t to_port, byte *temp_buff, char *extra_data)
{
memset(_packet, 0, SNMP_MAX_PACKET_LEN);
_packetPos = SNMP_MAX_PACKET_LEN-1;
int32_u u;
int t = 0;
_extra_data_size = 0;
if(extra_data != NULL){
_extra_data_size = strlen(extra_data);
}
// Varbind List
if(pdu->type == SNMP_PDU_RESPONSE){
t = pdu->add_data_private(&pdu->value,_packet + _packetPos,true,temp_buff, _extra_data_size);
_packetPos -= t;
//length of entire value being passed
_packet[_packetPos--] = lsb(t+_extra_data_size);
_packet[_packetPos--] = msb(t+_extra_data_size);
_packet[_packetPos--] = 0x82;//Sending length in two octets
}else if(pdu->type == SNMP_PDU_TRAP2 || pdu->type == SNMP_PDU_INFORM_REQUEST){
//set and increment requestId
pdu->requestId = requestCounter++;
for (t = pdu->value.size-1; t >= 0; t-- ) {
_packet[_packetPos--] = pdu->value.data[t];
}
//length of entire value being passed
_packet[_packetPos--] = lsb(pdu->value.size);
_packet[_packetPos--] = msb(pdu->value.size);
_packet[_packetPos--] = 0x82;//Sending length in two octets
}
_packet[_packetPos--] = (byte)SNMP_SYNTAX_SEQUENCE;// type
// Error Index (size always 4 e.g. 4-byte int)
u.int32 = pdu->errorIndex;
_packet[_packetPos--] = u.data[0];
_packet[_packetPos--] = u.data[1];
_packet[_packetPos--] = u.data[2];
_packet[_packetPos--] = u.data[3];
_packet[_packetPos--] = 0x04;
_packet[_packetPos--] = (byte)SNMP_SYNTAX_INT;// type
// Error (size always 4 e.g. 4-byte int)
u.int32 = pdu->error;
_packet[_packetPos--] = u.data[0];
_packet[_packetPos--] = u.data[1];
_packet[_packetPos--] = u.data[2];
_packet[_packetPos--] = u.data[3];
_packet[_packetPos--] = 0x04;
_packet[_packetPos--] = (byte)SNMP_SYNTAX_INT;// type
// Request ID (size always 4 e.g. 4-byte int)
u.int32 = pdu->requestId;
_packet[_packetPos--] = u.data[0];
_packet[_packetPos--] = u.data[1];
_packet[_packetPos--] = u.data[2];
_packet[_packetPos--] = u.data[3];
_packet[_packetPos--] = 0x04;
_packet[_packetPos--] = (byte)SNMP_SYNTAX_INT;// type
//length value of all previous data
_packet[_packetPos] = lsb(packet_length()+_extra_data_size);
_packet[_packetPos-1] = msb(packet_length()+_extra_data_size);
_packetPos -= 2;
_packet[_packetPos--] = 0x82;//Sending length in two octets
// SNMP PDU type
_packet[_packetPos--] = (byte)pdu->type;
//data needed for header
_dstType = pdu->type;
//byte header_size = this->writeHeaders(pdu);
this->writeHeaders(pdu);
_packetSize = packet_length();
// Serial.println("Outgoing: ");
// for(byte i = 0; i < _packetSize; i++){
// Serial.print(_packet[_packetPos+1+i],HEX);
// Serial.print("-");
// }
// Serial.println();
this->writePacket(to_address, to_port, extra_data);
return pdu->requestId;
}
/**
* Copies an external byte array into _packet and then sends it out.
*
* Original Auther: Rex Park
* Added: November 8, 2015 (Designed to be used with a system that resends informs that haven't been acknowledged)
*/
void SNMPClass::send_message(IPAddress address, uint16_t port, byte *packet, uint16_t packet_size){
Udp.beginPacket(address, port);
Udp.write(packet, packet_size);
Udp.endPacket();
}
void SNMPClass::writePacket(IPAddress address, uint16_t port, char *extra_data)
{
Udp.beginPacket(address, port);
Udp.write(_packet+_packetPos+1, _packetSize);
if(extra_data != NULL){
Udp.write((byte*)extra_data, _extra_data_size);
}
Udp.endPacket();
}
void SNMPClass::resend_message(IPAddress address, uint16_t port, char *extra_data)
{
this->writePacket(address, port, extra_data);
}
void SNMPClass::onPduReceive(onPduReceiveCallback pduReceived)
{
_callback = pduReceived;
}
void SNMPClass::freePdu(SNMP_PDU *pdu)
{
pdu->clear();
}
uint16_t SNMPClass::copy_packet(byte *packet_store){
memcpy(packet_store,_packet+_packetPos+1,_packetSize);
return _packetSize;
}
void SNMPClass::clear_packet(){
memset(_packet,0,SNMP_MAX_PACKET_LEN);
}
IPAddress SNMPClass::remoteIP(){
return Udp.remoteIP();
}
uint16_t SNMPClass::remotePort(){
return Udp.remotePort();
}
uint16_t SNMPClass::packet_length(){
return SNMP_MAX_PACKET_LEN - _packetPos - 1;
}
//returns the first byte of a two byte integer
byte SNMPClass::msb(uint16_t num){
return num >> 8;
}
//returns the second byte of a two byte integer
byte SNMPClass::lsb(uint16_t num){
return num & 0xFF;
}
uint16_t SNMPClass::combine_msb_lsb(byte msb, byte lsb){
return (msb << 8)| lsb;
}
// Create one global object
SNMPClass SNMP;