Debian Codegraph @

perl/SNMP/SNMP.pm

raw ◀ ▶
2 Debian patches touch this file
1 # SNMP.pm -- Perl 5 interface to the Net-SNMP toolkit
2 #
3 # written by G. S. Marzot ([email protected])
4 #
5 # Copyright (c) 1995-2006 G. S. Marzot. All rights reserved.
6 # This program is free software; you can redistribute it and/or
7 # modify it under the same terms as Perl itself.
8
9 package SNMP;
10 $VERSION = '5.09052'; # current release version number
11
12 use strict;
13 use warnings;
14
15 require Exporter;
16 require DynaLoader;
17 require AutoLoader;
18
19 use NetSNMP::default_store (':all');
20
21 @SNMP::ISA = qw(Exporter AutoLoader DynaLoader);
22 # Items to export into callers namespace by default. Note: do not export
23 # names by default without a very good reason. Use EXPORT_OK instead.
24 # Do not simply export all your public functions/methods/constants.
25 @SNMP::EXPORT = qw(
26 RECEIVED_MESSAGE
27 SNMPERR_BAD_ADDRESS
28 SNMPERR_BAD_LOCPORT
29 SNMPERR_BAD_SESSION
30 SNMPERR_GENERR
31 SNMPERR_TOO_LONG
32 SNMP_DEFAULT_ADDRESS
33 SNMP_DEFAULT_COMMUNITY_LEN
34 SNMP_DEFAULT_ENTERPRISE_LENGTH
35 SNMP_DEFAULT_ERRINDEX
36 SNMP_DEFAULT_ERRSTAT
37 SNMP_DEFAULT_PEERNAME
38 SNMP_DEFAULT_REMPORT
39 SNMP_DEFAULT_REQID
40 SNMP_DEFAULT_RETRIES
41 SNMP_DEFAULT_TIME
42 SNMP_DEFAULT_TIMEOUT
43 SNMP_DEFAULT_VERSION
44 TIMED_OUT
45 snmp_get
46 snmp_getnext
47 snmp_set
48 snmp_trap
49 SNMP_API_TRADITIONAL
50 SNMP_API_SINGLE
51 );
52
53 sub AUTOLOAD {
54 no strict;
55 # This AUTOLOAD is used to 'autoload' constants from the constant()
56 # XS function. If a constant is not found then control is passed
57 # to the AUTOLOAD in AutoLoader.
58 my($val,$pack,$file,$line);
59 my $constname;
60 ($constname = $AUTOLOAD) =~ s/.*:://;
61 # croak "&$module::constant not defined" if $constname eq 'constant';
62 ($!, $val) = constant($constname, @_ ? $_[0] : 0);
63 if ($! != 0) {
64 if ($! =~ /Invalid/) {
65 $AutoLoader::AUTOLOAD = $AUTOLOAD;
66 goto &AutoLoader::AUTOLOAD;
67 }
68 else {
69 ($pack,$file,$line) = caller;
70 die "Your vendor has not defined SNMP macro $constname, used at $file line $line.
71 ";
72 }
73 }
74 eval "sub $AUTOLOAD { $val }";
75 goto &$AUTOLOAD;
76 }
77
78 bootstrap SNMP;
79
80 # Preloaded methods go here.
81
82 # Package variables
83 tie $SNMP::debugging, 'SNMP::DEBUGGING';
84 tie $SNMP::debug_internals, 'SNMP::DEBUG_INTERNALS';
85 tie $SNMP::dump_packet, 'SNMP::DUMP_PACKET';
86 tie %SNMP::MIB, 'SNMP::MIB';
87 tie $SNMP::save_descriptions, 'SNMP::MIB::SAVE_DESCR';
88 tie $SNMP::replace_newer, 'SNMP::MIB::REPLACE_NEWER';
89 tie $SNMP::mib_options, 'SNMP::MIB::MIB_OPTIONS';
90
91 %SNMP::V3_SEC_LEVEL_MAP = (noAuthNoPriv => 1, authNoPriv => 2, authPriv =>3);
92
93 use vars qw(
94 $auto_init_mib $use_long_names $use_sprint_value $use_enums
95 $use_numeric %MIB $verbose $debugging $dump_packet $save_descriptions
96 $best_guess $non_increasing $replace_newer %session_params
97 $debug_internals $mib_options
98 );
99
100 $auto_init_mib = 1; # enable automatic MIB loading at session creation time
101 $use_long_names = 0; # non-zero to prefer longer mib textual identifiers rather
102 # than just leaf indentifiers (see translateObj)
103 # may also be set on a per session basis(see UseLongNames)
104 $use_sprint_value = 0; # non-zero to enable formatting of response values
105 # using the snmp libraries "snprint_value"
106 # may also be set on a per session basis(see UseSprintValue)
107 # note: returned values not suitable for 'set' operations
108 $use_enums = 0; # non-zero to return integers as enums and allow sets
109 # using enums where appropriate - integer data will
110 # still be accepted for set operations
111 # may also be set on a per session basis (see UseEnums)
112 $use_numeric = 0; # non-zero to return object tags as numeric OID's instead
113 # of converting to textual representations. use_long_names,
114 # if non-zero, returns the entire OID, otherwise, return just
115 # the label portion. use_long_names is also set if the
116 # use_numeric variable is set.
117 %MIB = (); # tied hash to access libraries internal mib tree structure
118 # parsed in from mib files
119 $verbose = 0; # controls warning/info output of SNMP module,
120 # 0 => no output, 1 => enables warning and info
121 # output from SNMP module itself (is also controlled
122 # by SNMP::debugging)
123 $debugging = 0; # non-zero to globally enable libsnmp do_debugging output
124 # set to >= 2 to enabling packet dumping (see below)
125 $dump_packet = 0; # non-zero to globally enable libsnmp dump_packet output.
126 # is also enabled when $debugging >= 2
127 $save_descriptions = 0; #tied scalar to control saving descriptions during
128 # mib parsing - must be set prior to mib loading
129 $best_guess = 0; # determine whether or not to enable best-guess regular
130 # expression object name translation. 1 = Regex (-Ib),
131 # 2 = random (-IR)
132 $non_increasing = 0; # stop polling with an "OID not increasing"-error
133 # when an OID does not increases in bulkwalk.
134 $replace_newer = 0; # determine whether or not to tell the parser to replace
135 # older MIB modules with newer ones when loading MIBs.
136 # WARNING: This can cause an incorrect hierarchy.
137
138 sub register_debug_tokens {
139 my $tokens = shift;
140
141 SNMP::_register_debug_tokens($tokens);
142 }
143
144 sub getenv {
145 my $name = shift;
146
147 return SNMP::_getenv($name);
148 }
149
150 sub setenv {
151 my $envname = shift;
152 my $envval = shift;
153 my $overwrite = shift;
154
155 return SNMP::_setenv($envname, $envval, $overwrite);
156 }
157
158 sub setMib {
159 # loads mib from file name provided
160 # setting second arg to true causes currently loaded mib to be replaced
161 # otherwise mib file will be added to existing loaded mib database
162 # NOTE: now deprecated in favor of addMibFiles and new module based funcs
163 my $file = shift;
164 my $force = shift || '0';
165 return 0 if $file and not (-r $file);
166 SNMP::_read_mib($file,$force);
167 }
168
169 sub initMib {
170 # equivalent to calling the snmp library init_mib if Mib is NULL
171 # if Mib is already loaded this function does nothing
172 # Pass a zero valued argument to get minimal mib tree initialization
173 # If non zero argument or no argument then full mib initialization
174
175 SNMP::init_snmp("perl");
176 return;
177
178
179 if (defined $_[0] and $_[0] == 0) {
180 SNMP::_init_mib_internals();
181 } else {
182 SNMP::_read_mib("");
183 }
184 }
185
186 sub addMibDirs {
187 # adds directories to search path when a module is requested to be loaded
188 SNMP::init_snmp("perl");
189 foreach (@_) {
190 SNMP::_add_mib_dir($_) or return undef;
191 }
192 return 1;
193 }
194
195 sub addMibFiles {
196 # adds mib definitions to currently loaded mib database from
197 # file(s) supplied
198 SNMP::init_snmp("perl");
199 foreach (@_) {
200 SNMP::_read_mib($_) or return undef;
201 }
202 return 1;
203 }
204
205 sub loadModules {
206 # adds mib module definitions to currently loaded mib database.
207 # Modules will be searched from previously defined mib search dirs
208 # Passing and arg of 'ALL' will cause all known modules to be loaded
209 SNMP::init_snmp("perl");
210 foreach (@_) {
211 SNMP::_read_module($_) or return undef;
212 }
213 return 1;
214 }
215
216 sub unloadModules {
217 # causes modules to be unloaded from mib database
218 # Passing and arg of 'ALL' will cause all known modules to be unloaded
219 warn("SNMP::unloadModules not implemented! (yet)");
220 }
221
222 sub translateObj {
223 # Translate object identifier(tag or numeric) into alternate representation
224 # (i.e., sysDescr => '.1.3.6.1.2.1.1.1' and '.1.3.6.1.2.1.1.1' => sysDescr)
225 # when $SNMP::use_long_names or second arg is non-zero the translation will
226 # return longer textual identifiers (e.g., system.sysDescr). An optional
227 # third argument of non-zero will cause the module name to be prepended
228 # to the text name (e.g. 'SNMPv2-MIB::sysDescr'). If no Mib is loaded
229 # when called and $SNMP::auto_init_mib is enabled then the Mib will be
230 # loaded. Will return 'undef' upon failure.
231 SNMP::init_snmp("perl");
232 my $obj = shift;
233 my $temp = shift;
234 my $include_module_name = shift || "0";
235 my $long_names = $temp || $SNMP::use_long_names;
236
237 return undef if not defined $obj;
238 my $res;
239 if ($obj =~ /^\.?(\d+\.)*\d+$/) {
240 $res = SNMP::_translate_obj($obj,1,$long_names,$SNMP::auto_init_mib,0,$include_module_name);
241 } elsif ($obj =~ /(\.\d+)*$/ && $SNMP::best_guess == 0) {
242 $res = SNMP::_translate_obj($`,0,$long_names,$SNMP::auto_init_mib,0,$include_module_name);
243 $res .= $& if defined $res and defined $&;
244 } elsif ($SNMP::best_guess) {
245 $res = SNMP::_translate_obj($obj,0,$long_names,$SNMP::auto_init_mib,$SNMP::best_guess,$include_module_name);
246 }
247
248 return($res);
249 }
250
251 sub getType {
252 # return SNMP data type for given textual identifier
253 # OBJECTID, OCTETSTR, INTEGER, NETADDR, IPADDR, COUNTER
254 # GAUGE, TIMETICKS, OPAQUE, or undef
255 my $tag = shift;
256 SNMP::_get_type($tag, $SNMP::best_guess);
257 }
258
259 sub mapEnum {
260 # return the corresponding integer value *or* tag for a given MIB attribute
261 # and value. The function will sense which direction to perform the conversion
262 # various arg formats are supported
263 # $val = SNMP::mapEnum($varbind); # note: will update $varbind
264 # $val = SNMP::mapEnum('ipForwarding', 'forwarding');
265 # $val = SNMP::mapEnum('ipForwarding', 1);
266 #
267 my $var = shift;
268 my ($tag, $val, $update);
269 if (ref($var) =~ /ARRAY/ or ref($var) =~ /Varbind/) {
270 $tag = SNMP::Varbind::tag($var);
271 $val = SNMP::Varbind::val($var);
272 $update = 1;
273 } else {
274 $tag = $var;
275 $val = shift;
276 }
277 my $iflag = $val =~ /^\d+$/;
278 my $res = SNMP::_map_enum($tag, $val, $iflag, $SNMP::best_guess);
279 if ($update and defined $res) { SNMP::Varbind::val($var) = $res; }
280 return($res);
281 }
282
283 %session_params = (DestHost => 1,
284 Community => 1,
285 Version => 1,
286 Timeout => 1,
287 Retries => 1,
288 RemotePort => 1,
289 LocalPort => 1);
290
291 sub strip_session_params {
292 my @params;
293 my @args;
294 my $param;
295 while ($param = shift) {
296 push(@params,$param, shift), next
297 if $session_params{$param};
298 push(@args,$param);
299 }
300 @_ = @args;
301 @params;
302 }
303
304
305 sub snmp_get {
306 # procedural form of 'get' method. sometimes quicker to code
307 # but is less efficient since the Session is created and destroyed
308 # with each call. Takes all the parameters of both SNMP::Session::new and
309 # SNMP::Session::get (*NOTE*: this api does not support async callbacks)
310
311 my @sess_params = &strip_session_params;
312 my $sess = new SNMP::Session(@sess_params);
313
314 $sess->get(@_);
315 }
316
317 sub snmp_getnext {
318 # procedural form of 'getnext' method. sometimes quicker to code
319 # but is less efficient since the Session is created and destroyed
320 # with each call. Takes all the parameters of both SNMP::Session::new and
321 # SNMP::Session::getnext (*NOTE*: this api does not support async callbacks)
322
323 my @sess_params = &strip_session_params;
324 my $sess = new SNMP::Session(@sess_params);
325
326 $sess->getnext(@_);
327 }
328
329 sub snmp_set {
330 # procedural form of 'set' method. sometimes quicker to code
331 # but is less efficient since the Session is created and destroyed
332 # with each call. Takes all the parameters of both SNMP::Session::new and
333 # SNMP::Session::set (*NOTE*: this api does not support async callbacks)
334
335 my @sess_params = &strip_session_params;
336 my $sess = new SNMP::Session(@sess_params);
337
338 $sess->set(@_);
339 }
340
341 sub snmp_trap {
342 # procedural form of 'trap' method. sometimes quicker to code
343 # but is less efficient since the Session is created and destroyed
344 # with each call. Takes all the parameters of both SNMP::TrapSession::new and
345 # SNMP::TrapSession::trap
346
347 my @sess_params = &strip_session_params;
348 my $sess = new SNMP::TrapSession(@sess_params);
349
350 $sess->trap(@_);
351 }
352
353 #---------------------------------------------------------------------
354 # Preserves the ability to call MainLoop() with no args so we don't
355 # break old code
356 #
357 # Alternately, MainLoop() could be called as an object method,
358 # ( $sess->MainLoop() ) , so that $self winds up in @_. Then it would
359 # be more like :
360 # my $self = shift;
361 # ....
362 # SNMP::_main_loop(......, $self->{SessPtr});
363 #---------------------------------------------------------------------
364 sub MainLoop {
365 my $ss = shift if(&SNMP::_api_mode() == SNMP::SNMP_API_SINGLE());
366 my $time = shift;
367 my $callback = shift;
368 my $time_sec = ($time ? int $time : 0);
369 my $time_usec = ($time ? int(($time-$time_sec)*1000000) : 0);
370 SNMP::_main_loop($time_sec,$time_usec,$callback,(defined($ss) ? $ss->{SessPtr} : ()));
371 }
372
373 sub finish {
374 SNMP::_mainloop_finish();
375 }
376
377 sub reply_cb {
378 # callback function for async snmp calls
379 # when triggered, will do a SNMP read on the
380 # given fd
381 my $fd = shift;
382 SNMP::_read_on_fd($fd);
383 }
384
385 sub select_info {
386 # retrieves SNMP used fd's and timeout info
387 # calculates timeout in fractional seconds
388 # ( easy to use with select statement )
389 my($block, $to_sec, $to_usec, @fd_set)=SNMP::_get_select_info();
390 my $time_sec_dec = ($block? 0 : $to_sec + $to_usec * 1e-6);
391 #print "fd's for snmp -> ", @fd_set, "\n";
392 #print "block -> ", $block, "\n";
393 #print "timeout_sec -> ", $to_sec, "\n";
394 #print "timeout_usec -> ", $to_usec, "\n";
395 #print "timeout dec -> ", $time_sec_dec, "\n";
396 return ($time_sec_dec,@fd_set);
397 }
398
399 sub check_timeout {
400 # check to see if a snmp session
401 # timed out, and if so triggers
402 # the callback function
403 SNMP::_check_timeout();
404 # check to see when have to check again
405 my($block, $to_sec, $to_usec, @fd_set)=SNMP::_get_select_info();
406 my $time_sec_dec = ($block? 0 : $to_sec + $to_usec * 1e-6);
407 #print "fd's for snmp -> ", @fd_set, "\n";
408 #print "block -> ", $block, "\n";
409 #print "timeout_sec -> ", $to_sec, "\n";
410 #print "timeout_usec -> ", $to_usec, "\n";
411 #print "timeout dec -> ", $time_sec_dec, "\n";
412 return ($time_sec_dec);
413 }
414
415 sub _tie {
416 # this is a little implementation hack so ActiveState can access pp_tie
417 # thru perl code. All other environments allow the calling of pp_tie from
418 # XS code but AS was not exporting it when PERL_OBJECT was used.
419 #
420 # short term solution was call this perl func which calls 'tie'
421 #
422 # longterm fix is to supply a patch which allows AS to export pp_tie in
423 # such a way that it can be called from XS code. gsarathy says:
424 # a patch to util.c is needed to provide access to PL_paddr
425 # so it is possible to call PL_paddr[OP_TIE] as the compiler does
426 tie($_[0],$_[1],$_[2],$_[3]);
427 }
428
429 sub split_vars {
430 # This sub holds the regex that is used throughout this module
431 # to parse the base part of an OID from the IID.
432 # eg: portName.9.30 -> ['portName','9.30']
433 my $vars = shift;
434
435 # The regex was changed to this simple form by patch 722075 for some reason.
436 # Testing shows now (2/05) that it is not needed, and that the long expression
437 # works fine. AB
438 # my ($tag, $iid) = ($vars =~ /^(.*?)\.?(\d+)+$/);
439
440 # These following two are the same. Broken down for easier maintenance
441 # my ($tag, $iid) = ($vars =~ /^((?:\.\d+)+|(?:\w+(?:\-*\w+)+))\.?(.*)$/);
442 my ($tag, $iid) =
443 ($vars =~ /^( # Capture $1
444 # 1. either this 5.5.5.5
445 (?:\.\d+)+ # for grouping, won't increment $1
446 |
447 # 2. or asdf-asdf-asdf-asdf
448 (?: # grouping again
449 \w+ # needs some letters followed by
450 (?:\-*\w+)+ # zero or more dashes, one or more letters
451 )
452 )
453 \.? # optionally match a dot
454 (.*) # whatever is left in the string is our iid ($2)
455 $/x
456 );
457 return [$tag,$iid];
458 }
459
460 package SNMP::Session;
461
462 sub new {
463 my $type = shift;
464 my $this = {};
465 my ($name, $aliases, $host_type, $len, $thisaddr);
466
467 SNMP::init_snmp("perl");
468
469 %$this = @_;
470
471 $this->{ErrorStr} = ''; # if methods return undef check for expln.
472 $this->{ErrorNum} = 0; # contains SNMP error return
473
474 $this->{Version} ||=
475 NetSNMP::default_store::netsnmp_ds_get_int(NetSNMP::default_store::NETSNMP_DS_LIBRARY_ID,
476 NetSNMP::default_store::NETSNMP_DS_LIB_SNMPVERSION) ||
477 SNMP::SNMP_DEFAULT_VERSION();
478
479 if ($this->{Version} eq 128) {
480 # special handling of the bogus v1 definition.
481 $this->{Version} = 1;
482 }
483
484 # allow override of local SNMP port
485 $this->{LocalPort} ||= 0;
486
487 # destination host defaults to localhost
488 $this->{DestHost} ||= 'localhost';
489
490 # community defaults to public
491 $this->{Community} ||= NetSNMP::default_store::netsnmp_ds_get_string(NetSNMP::default_store::NETSNMP_DS_LIBRARY_ID(),
492 NetSNMP::default_store::NETSNMP_DS_LIB_COMMUNITY()) || 'public';
493
494 # number of retries before giving up, defaults to SNMP_DEFAULT_RETRIES
495 $this->{Retries} = SNMP::SNMP_DEFAULT_RETRIES() unless defined($this->{Retries});
496
497 # timeout before retry, defaults to SNMP_DEFAULT_TIMEOUT
498 $this->{Timeout} = SNMP::SNMP_DEFAULT_TIMEOUT() unless defined($this->{Timeout});
499 # flag to enable fixing pdu and retrying with a NoSuch error
500 $this->{RetryNoSuch} ||= 0;
501
502 # backwards compatibility. Make host = host:port
503 if ($this->{RemotePort} && $this->{DestHost} !~ /:/) {
504 $this->{DestHost} = $this->{DestHost} . ":" . $this->{RemotePort};
505 }
506
507 if ($this->{DestHost} =~ /^(dtls|tls|ssh)/) {
508 # only works with version 3
509 $this->{Version} = 3;
510 }
511
512 if ($this->{Version} eq '1' or $this->{Version} eq '2'
513 or $this->{Version} eq '2c') {
514 $this->{SessPtr} = SNMP::_new_session($this->{Version},
515 $this->{Community},
516 $this->{DestHost},
517 $this->{LocalPort},
518 $this->{Retries},
519 $this->{Timeout},
520 );
521 } elsif ($this->{Version} eq '3' ) {
522 $this->{SecName} ||=
523 NetSNMP::default_store::netsnmp_ds_get_string(NetSNMP::default_store::NETSNMP_DS_LIBRARY_ID(),
524 NetSNMP::default_store::NETSNMP_DS_LIB_SECNAME()) ||
525 'initial';
526 if (!$this->{SecLevel}) {
527 $this->{SecLevel} =
528 NetSNMP::default_store::netsnmp_ds_get_int(NetSNMP::default_store::NETSNMP_DS_LIBRARY_ID(),
529 NetSNMP::default_store::NETSNMP_DS_LIB_SECLEVEL()) ||
530 $SNMP::V3_SEC_LEVEL_MAP{'noAuthNoPriv'};
531 } elsif ($this->{SecLevel} !~ /^\d+$/) {
532 $this->{SecLevel} = $SNMP::V3_SEC_LEVEL_MAP{$this->{SecLevel}};
533 }
534 $this->{SecEngineId} ||= '';
535 $this->{ContextEngineId} ||= $this->{SecEngineId};
536 $this->{Context} ||=
537 NetSNMP::default_store::netsnmp_ds_get_string(NetSNMP::default_store::NETSNMP_DS_LIBRARY_ID(),
538 NetSNMP::default_store::NETSNMP_DS_LIB_CONTEXT()) || '';
539
540 if ($this->{DestHost} =~ /^(dtls|tls|ssh)/) {
541 # this is a tunneled protocol
542
543 $this->{'OurIdentity'} ||= '';
544 $this->{'TheirIdentity'} ||= '';
545 $this->{'TheirHostname'} ||= '';
546 $this->{'TrustCert'} ||= '';
547
548 $this->{'SecLevel'} = $SNMP::V3_SEC_LEVEL_MAP{'authPriv'};
549
550 $this->{SessPtr} =
551 SNMP::_new_tunneled_session($this->{Version},
552 $this->{DestHost},
553 $this->{Retries},
554 $this->{Timeout},
555 $this->{SecName},
556 $this->{SecLevel},
557 $this->{ContextEngineId},
558 $this->{Context},
559 $this->{'OurIdentity'},
560 $this->{'TheirIdentity'},
561 $this->{'TheirHostname'},
562 $this->{'TrustCert'},
563 );
564
565
566 } else {
567 # USM or some other internal security protocol
568
569 # USM specific parameters:
570 $this->{AuthProto} ||= 'DEFAULT'; # use the library's default
571 $this->{AuthPass} ||=
572 NetSNMP::default_store::netsnmp_ds_get_string(NetSNMP::default_store::NETSNMP_DS_LIBRARY_ID(),
573 NetSNMP::default_store::NETSNMP_DS_LIB_AUTHPASSPHRASE()) ||
574 NetSNMP::default_store::netsnmp_ds_get_string(NetSNMP::default_store::NETSNMP_DS_LIBRARY_ID(),
575 NetSNMP::default_store::NETSNMP_DS_LIB_PASSPHRASE()) || '';
576
577 $this->{AuthMasterKey} ||= '';
578 $this->{PrivMasterKey} ||= '';
579 $this->{AuthLocalizedKey} ||= '';
580 $this->{PrivLocalizedKey} ||= '';
581
582 $this->{PrivProto} ||= 'DEFAULT'; # use the library's default
583 $this->{PrivPass} ||=
584 NetSNMP::default_store::netsnmp_ds_get_string(NetSNMP::default_store::NETSNMP_DS_LIBRARY_ID(),
585 NetSNMP::default_store::NETSNMP_DS_LIB_PRIVPASSPHRASE()) ||
586 NetSNMP::default_store::netsnmp_ds_get_string(NetSNMP::default_store::NETSNMP_DS_LIBRARY_ID(),
587 NetSNMP::default_store::NETSNMP_DS_LIB_PASSPHRASE()) || '';
588 $this->{EngineBoots} = 0 if not defined $this->{EngineBoots};
589 $this->{EngineTime} = 0 if not defined $this->{EngineTime};
590
591 $this->{SessPtr} =
592 SNMP::_new_v3_session($this->{Version},
593 $this->{DestHost},
594 $this->{Retries},
595 $this->{Timeout},
596 $this->{SecName},
597 $this->{SecLevel},
598 $this->{SecEngineId},
599 $this->{ContextEngineId},
600 $this->{Context},
601 $this->{AuthProto},
602 $this->{AuthPass},
603 $this->{PrivProto},
604 $this->{PrivPass},
605 $this->{EngineBoots},
606 $this->{EngineTime},
607 $this->{AuthMasterKey},
608 length($this->{AuthMasterKey}),
609 $this->{PrivMasterKey},
610 length($this->{PrivMasterKey}),
611 $this->{AuthLocalizedKey},
612 length($this->{AuthLocalizedKey}),
613 $this->{PrivLocalizedKey},
614 length($this->{PrivLocalizedKey}),
615 );
616 }
617 }
618 unless ($this->{SessPtr}) {
619 warn("unable to create session") if $SNMP::verbose;
620 return undef;
621 }
622
623 SNMP::initMib($SNMP::auto_init_mib); # ensures that *some* mib is loaded
624
625 $this->{UseLongNames} = $SNMP::use_long_names
626 unless exists $this->{UseLongNames};
627 $this->{UseSprintValue} = $SNMP::use_sprint_value
628 unless exists $this->{UseSprintValue};
629 $this->{BestGuess} = $SNMP::best_guess unless exists $this->{BestGuess};
630 $this->{NonIncreasing} ||= $SNMP::non_increasing;
631 $this->{UseEnums} = $SNMP::use_enums unless exists $this->{UseEnums};
632 $this->{UseNumeric} = $SNMP::use_numeric unless exists $this->{UseNumeric};
633
634 # Force UseLongNames if UseNumeric is in use.
635 $this->{UseLongNames}++ if $this->{UseNumeric};
636
637 bless $this, $type;
638 }
639
640 sub update {
641 # *Not Implemented*
642 # designed to update the fields of session to allow retargetting to different
643 # host, community name change, timeout, retry changes etc. Unfortunately not
644 # working yet because some updates (the address in particular) need to be
645 # done on the internal session pointer which cannot be fetched w/o touching
646 # globals at this point which breaks win32. A patch to the net-snmp toolkit
647 # is needed
648 my $this = shift;
649 my ($name, $aliases, $host_type, $len, $thisaddr);
650 my %new_fields = @_;
651
652 @$this{keys %new_fields} = values %new_fields;
653
654 $this->{UseLongNames} = $SNMP::use_long_names
655 unless exists $this->{UseLongNames};
656 $this->{UseSprintValue} = $SNMP::use_sprint_value
657 unless exists $this->{UseSprintValue};
658 $this->{BestGuess} = $SNMP::best_guess unless exists $this->{BestGuess};
659 $this->{NonIncreasing} ||= $SNMP::non_increasing;
660 $this->{UseEnums} = $SNMP::use_enums unless exists $this->{UseEnums};
661 $this->{UseNumeric} = $SNMP::use_numeric unless exists $this->{UseNumeric};
662
663 # Force UseLongNames if UseNumeric is in use.
664 $this->{UseLongNames}++ if $this->{UseNumeric};
665
666 SNMP::_update_session($this->{Version},
667 $this->{Community},
668 $this->{DestHost},
669 $this->{RemotePort},
670 $this->{LocalPort},
671 $this->{Retries},
672 $this->{Timeout},
673 );
674
675
676 }
677
678 sub set {
679 my $this = shift;
680 my $vars = shift;
681 my $varbind_list_ref;
682 my $res = 0;
683
684 if (ref($vars) =~ /SNMP::VarList/) {
685 $varbind_list_ref = $vars;
686 } elsif (ref($vars) =~ /SNMP::Varbind/) {
687 $varbind_list_ref = [$vars];
688 } elsif (ref($vars) =~ /ARRAY/) {
689 $varbind_list_ref = [$vars];
690 $varbind_list_ref = $vars if ref($$vars[0]) =~ /ARRAY/;
691 } else {
692 #$varbind_list_ref = [[$tag, $iid, $val]];
693 my $split_vars = SNMP::split_vars($vars);
694 my $val = shift;
695 push @$split_vars,$val;
696 $varbind_list_ref = [$split_vars];
697 }
698 my $cb = shift;
699
700 $res = SNMP::_set($this, $varbind_list_ref, $cb);
701 }
702
703 sub get {
704 my $this = shift;
705 my $vars = shift;
706 my ($varbind_list_ref, @res);
707
708 if (ref($vars) =~ /SNMP::VarList/) {
709 $varbind_list_ref = $vars;
710 } elsif (ref($vars) =~ /SNMP::Varbind/) {
711 $varbind_list_ref = [$vars];
712 } elsif (ref($vars) =~ /ARRAY/) {
713 $varbind_list_ref = [$vars];
714 $varbind_list_ref = $vars if ref($$vars[0]) =~ /ARRAY/;
715 } else {
716 $varbind_list_ref = [SNMP::split_vars($vars)];
717 }
718
719 my $cb = shift;
720
721 @res = SNMP::_get($this, $this->{RetryNoSuch}, $varbind_list_ref, $cb);
722
723 return(wantarray() ? @res : $res[0]);
724 }
725
726
727 my $have_netsnmp_oid = eval { require NetSNMP::OID; };
728 sub gettable {
729
730 #
731 # getTable
732 # --------
733 #
734 # Get OIDs starting at $table_oid, and continue down the tree
735 # until we get to an OID which does not start with $table_oid,
736 # i.e. we have reached the end of this table.
737 #
738
739 my $state;
740
741 my ($this, $root_oid, @options) = @_;
742 $state->{'options'} = {@options};
743 my ($textnode, $varbinds, $vbl, $res, $repeat);
744
745 # translate the OID into numeric form if its not
746 if ($root_oid !~ /^[\.0-9]+$/) {
747 $textnode = $root_oid;
748 $root_oid = SNMP::translateObj($root_oid);
749 } else {
750 $textnode = SNMP::translateObj($root_oid);
751 }
752
753 # bail if we don't have a valid oid.
754 return if (!$root_oid);
755
756 # deficed if we're going to parse indexes
757 my $parse_indexes = (defined($state->{'options'}{'noindexes'})) ?
758 0 : $have_netsnmp_oid;
759
760 # get the list of columns we should look at.
761 my @columns;
762 if (!$state->{'options'}{'columns'}) {
763 if ($textnode) {
764 my %indexes;
765
766 if ($parse_indexes) {
767 # get indexes
768 my @indexes =
769 @{$SNMP::MIB{$textnode}{'children'}[0]{'indexes'} || []};
770 # quick translate into a hash
771 map { $indexes{$_} = 1; } @indexes;
772 }
773
774 # calculate the list of accessible columns that aren't indexes
775 my $children = $SNMP::MIB{$textnode}{'children'}[0]{'children'};
776 foreach my $c (@$children) {
777 push @{$state->{'columns'}},
778 $root_oid . ".1." . $c->{'subID'}
779 if (!$indexes{$c->{'label'}});
780 }
781 if ($#{$state->{'columns'}} == -1) {
782 # some tables are only indexes, and we need to walk at
783 # least one column. We pick the last.
784 push @{$state->{'columns'}}, $root_oid . ".1." .
785 $children->[$#$children]{'subID'}
786 if ref($state) eq 'HASH' and ref($children) eq 'ARRAY';
787 }
788 }
789 } else {
790 # XXX: requires specification in numeric OID... ack.!
791 @{$state->{'columns'}} = @{$state->{'options'}{'columns'}};
792
793 # if the columns aren't numeric, we need to turn them into
794 # numeric columns...
795 map {
796 if ($_ !~ /\.1\.3/) {
797 $_ = $SNMP::MIB{$_}{'objectID'};
798 }
799 } @{$state->{'columns'}};
800 }
801
802 # create the initial walking info.
803 foreach my $c (@{$state->{'columns'}}) {
804 push @{$state->{'varbinds'}}, [$c];
805 push @{$state->{'stopconds'}}, $c;
806 }
807
808 if ($#{$state->{'varbinds'}} == -1) {
809 print STDERR "ack: gettable failed to find any columns to look for.\n";
810 return;
811 }
812
813 $vbl = $state->{'varbinds'};
814
815 my $repeatcount;
816 if ($this->{Version} eq '1' || $state->{'options'}{nogetbulk}) {
817 $state->{'repeatcount'} = 1;
818 } elsif ($state->{'options'}{'repeat'}) {
819 $state->{'repeatcount'} = $state->{'options'}{'repeat'};
820 } elsif ($#{$state->{'varbinds'}} == -1) {
821 $state->{'repeatcount'} = 1;
822 } else {
823 # experimentally determined maybe guess at a best repeat value
824 # 1000 bytes max (safe), 30 bytes average for encoding of the
825 # varbind (experimentally determined to be closer to
826 # 26. Again, being safe. Then devide by the number of
827 # varbinds.
828 $state->{'repeatcount'} = int(1000 / 36 / ($#{$state->{'varbinds'}} + 1));
829 }
830 # Make sure we run at least once
831 if ($state->{'repeatcount'} < 1) {
832 $state->{'repeatcount'} = 1;
833 }
834
835 #
836 # if we've been configured with a callback, then call the
837 # sub-functions with a callback to our own "next" processing
838 # function (_gettable_do_it). or else call the blocking method and
839 # call the next processing function ourself.
840 #
841 if ($state->{'options'}{'callback'}) {
842 if ($this->{Version} ne '1' && !$state->{'options'}{'nogetbulk'}) {
843 $res = $this->getbulk(0, $state->{'repeatcount'}, $vbl,
844 [\&_gettable_do_it, $this, $vbl,
845 $parse_indexes, $textnode, $state]);
846 } else {
847 $res = $this->getnext($vbl,
848 [\&_gettable_do_it, $this, $vbl,
849 $parse_indexes, $textnode, $state]);
850 }
851 } else {
852 if ($this->{Version} ne '1' && !$state->{'options'}{'nogetbulk'}) {
853 $res = $this->getbulk(0, $state->{'repeatcount'}, $vbl);
854 } else {
855 $res = $this->getnext($vbl);
856 }
857 return $this->_gettable_do_it($vbl, $parse_indexes, $textnode, $state);
858 }
859 return 0;
860 }
861
862 sub _gettable_do_it() {
863 my ($this, $vbl, $parse_indexes, $textnode, $state) = @_;
864
865 my ($res);
866
867 $vbl = $_[$#_] if ($state->{'options'}{'callback'});
868
•869 my $num_vbls = defined($vbl) ? scalar @$vbl : 0;
870 my $num_stopconds = scalar @{$state->{'stopconds'}};
871
•872 while ($num_vbls > 0 && !$this->{ErrorNum}) {
873 my @found_eof = (0) x $num_stopconds;
874
875 for (my $i = 0; $i <= $#$vbl; $i++) {
876 my $row_oid = SNMP::translateObj($vbl->[$i][0]);
877 my $row_text = $vbl->[$i][0];
878 my $row_index = $vbl->[$i][1];
879 my $row_value = $vbl->[$i][2];
880 my $row_type = $vbl->[$i][3];
881
•882 my $stopcond_num = $i % $num_stopconds;
883 my $stopcond = $state->{'stopconds'}[$stopcond_num];
884 if ($row_oid !~ /^\Q$stopcond\E/ || $row_value eq 'ENDOFMIBVIEW') {
885 $found_eof[$stopcond_num] = 1;
886 } else {
887
888 if ($row_type eq "OBJECTID") {
889
890 # If the value returned is an OID, translate this
891 # back in to a textual OID
892
893 $row_value = SNMP::translateObj($row_value);
894
895 }
896
•897 # continue past this next time
898
899 $state->{'varbinds'}[$stopcond_num] = [ $row_text, $row_index ];
900
901 # Place the results in a hash
902
903 $state->{'result_hash'}{$row_index}{$row_text} = $row_value;
•904 }
905 }
906
•907 my @newstopconds = ();
908 my @newvarbinds = ();
909 for (my $i = 0; $i < $num_stopconds; ++$i) {
910 unless ($found_eof[$i]) {
911 push @newstopconds, $state->{'stopconds'}[$i];
912 push @newvarbinds, $state->{'varbinds'}[$i];
913 }
914 }
•915 if ($#newstopconds == -1) {
916 last;
917 }
•918 $state->{'varbinds'} = \@newvarbinds;
919 $state->{'stopconds'} = \@newstopconds;
920 $vbl = $state->{'varbinds'};
921
922 #
923 # if we've been configured with a callback, then call the
924 # sub-functions with a callback to our own "next" processing
925 # function (_gettable_do_it). or else call the blocking method and
926 # call the next processing function ourself.
927 #
928 if ($state->{'options'}{'callback'}) {
929 if ($this->{Version} ne '1' && !$state->{'options'}{'nogetbulk'}) {
930 $res = $this->getbulk(0, $state->{'repeatcount'}, $vbl,
931 [\&_gettable_do_it, $this, $vbl,
932 $parse_indexes, $textnode, $state]);
933 } else {
934 $res = $this->getnext($vbl,
935 [\&_gettable_do_it, $this, $vbl,
936 $parse_indexes, $textnode, $state]);
937 }
938 return;
939 } else {
940 if ($this->{Version} ne '1' && !$state->{'options'}{'nogetbulk'}) {
941 $res = $this->getbulk(0, $state->{'repeatcount'}, $vbl);
942 } else {
943 $res = $this->getnext($vbl);
944 }
945 }
946 }
947
948 # finish up
949 _gettable_end_routine($state, $parse_indexes, $textnode);
950
951 # return the hash if no callback was specified
952 if (!$state->{'options'}{'callback'}) {
953 return($state->{'result_hash'});
954 }
955
956 #
957 # if they provided a callback, call it
958 # (if an array pass the args as well)
959 #
960 if (ref($state->{'options'}{'callback'}) eq 'ARRAY') {
961 my $code = shift @{$state->{'options'}{'callback'}};
962 $code->(@{$state->{'options'}{'callback'}}, $state->{'result_hash'});
963 } else {
964 $state->{'options'}{'callback'}->($state->{'result_hash'});
965 }
966 }
967
968 sub _gettable_end_routine {
969 my ($state, $parse_indexes, $textnode) = @_;
970 if ($parse_indexes) {
971 my @indexes = @{$SNMP::MIB{$textnode}{'children'}[0]{'indexes'}};
972 my $i;
973 foreach my $trow (keys(%{$state->{'result_hash'}})) {
974 my $noid = new NetSNMP::OID($state->{'columns'}[0] . "." . $trow);
975 if (!$noid) {
976 print STDERR "***** ERROR parsing $state->{'columns'}[0].$trow MIB OID\n";
977 next;
978 }
979 my $nindexes = $noid->get_indexes();
980 if (!$nindexes || ref($nindexes) ne 'ARRAY' ||
981 $#indexes != $#$nindexes) {
982 print STDERR "***** ERROR parsing $state->{'columns'}[0].$trow MIB indexes:\n $noid => " . ref($nindexes) . "\n [should be an ARRAY]\n expended # indexes = $#indexes\n";
983 if (ref($nindexes) eq 'ARRAY') {
984 print STDERR "***** ERROR parsing $state->{'columns'}[0].$trow MIB indexes: " . ref($nindexes) . " $#indexes $#$nindexes\n";
985 }
986 next;
987 }
988
989 for ($i = 0; $i <= $#indexes; $i++) {
990 $state->{'result_hash'}{$trow}{$indexes[$i]} = $nindexes->[$i];
991 }
992 }
993 }
994 }
995
996
997 sub fget {
998 my $this = shift;
999 my $vars = shift;
1000 my ($varbind_list_ref, @res);
1001
1002 if (ref($vars) =~ /SNMP::VarList/) {
1003 $varbind_list_ref = $vars;
1004 } elsif (ref($vars) =~ /SNMP::Varbind/) {
1005 $varbind_list_ref = [$vars];
1006 } elsif (ref($vars) =~ /ARRAY/) {
1007 $varbind_list_ref = [$vars];
1008 $varbind_list_ref = $vars if ref($$vars[0]) =~ /ARRAY/;
1009 } else {
1010 $varbind_list_ref = [SNMP::split_vars($vars)];
1011 }
1012
1013 my $cb = shift;
1014
1015 SNMP::_get($this, $this->{RetryNoSuch}, $varbind_list_ref, $cb);
1016
1017 foreach my $varbind (@$varbind_list_ref) {
1018 my $sub = $this->{VarFormats}{SNMP::Varbind::tag($varbind)} ||
1019 $this->{TypeFormats}{SNMP::Varbind::type($varbind)};
1020 &$sub($varbind) if defined $sub;
1021 push(@res, SNMP::Varbind::val($varbind));
1022 }
1023
1024 return(wantarray() ? @res : $res[0]);
1025 }
1026
1027 sub getnext {
1028 my $this = shift;
1029 my $vars = shift;
1030 my ($varbind_list_ref, @res);
1031
1032 if (ref($vars) =~ /SNMP::VarList/) {
1033 $varbind_list_ref = $vars;
1034 } elsif (ref($vars) =~ /SNMP::Varbind/) {
1035 $varbind_list_ref = [$vars];
1036 } elsif (ref($vars) =~ /ARRAY/) {
1037 $varbind_list_ref = [$vars];
1038 $varbind_list_ref = $vars if ref($$vars[0]) =~ /ARRAY/;
1039 } else {
1040 $varbind_list_ref = [SNMP::split_vars($vars)];
1041 }
1042
1043 my $cb = shift;
1044
1045 @res = SNMP::_getnext($this, $varbind_list_ref, $cb);
1046
1047 return(wantarray() ? @res : $res[0]);
1048 }
1049
1050 sub fgetnext {
1051 my $this = shift;
1052 my $vars = shift;
1053 my ($varbind_list_ref, @res);
1054
1055 if (ref($vars) =~ /SNMP::VarList/) {
1056 $varbind_list_ref = $vars;
1057 } elsif (ref($vars) =~ /SNMP::Varbind/) {
1058 $varbind_list_ref = [$vars];
1059 } elsif (ref($vars) =~ /ARRAY/) {
1060 $varbind_list_ref = [$vars];
1061 $varbind_list_ref = $vars if ref($$vars[0]) =~ /ARRAY/;
1062 } else {
1063 $varbind_list_ref = [SNMP::split_vars($vars)];
1064 }
1065
1066 my $cb = shift;
1067
1068 SNMP::_getnext($this, $varbind_list_ref, $cb);
1069
1070 foreach my $varbind (@$varbind_list_ref) {
1071 my $sub = $this->{VarFormats}{SNMP::Varbind::tag($varbind)} ||
1072 $this->{TypeFormats}{SNMP::Varbind::type($varbind)};
1073 &$sub($varbind) if defined $sub;
1074 push(@res, SNMP::Varbind::val($varbind));
1075 }
1076
1077 return(wantarray() ? @res : $res[0]);
1078 }
1079
1080 sub getbulk {
1081 my $this = shift;
1082 my $nonrepeaters = shift;
1083 my $maxrepetitions = shift;
1084 my $vars = shift;
1085 my ($varbind_list_ref, @res);
1086
1087 if (ref($vars) =~ /SNMP::VarList/) {
1088 $varbind_list_ref = $vars;
1089 } elsif (ref($vars) =~ /SNMP::Varbind/) {
1090 $varbind_list_ref = [$vars];
1091 } elsif (ref($vars) =~ /ARRAY/) {
1092 $varbind_list_ref = [$vars];
1093 $varbind_list_ref = $vars if ref($$vars[0]) =~ /ARRAY/;
1094 } else {
1095 $varbind_list_ref = [SNMP::split_vars($vars)];
1096 }
1097
1098 my $cb = shift;
1099
1100 @res = SNMP::_getbulk($this, $nonrepeaters, $maxrepetitions, $varbind_list_ref, $cb);
1101
1102 return(wantarray() ? @res : $res[0]);
1103 }
1104
1105 sub bulkwalk {
1106 my $this = shift;
1107 my $nonrepeaters = shift;
1108 my $maxrepetitions = shift;
1109 my $vars = shift;
1110 my ($varbind_list_ref, @res);
1111
1112 if (ref($vars) =~ /SNMP::VarList/) {
1113 $varbind_list_ref = $vars;
1114 } elsif (ref($vars) =~ /SNMP::Varbind/) {
1115 $varbind_list_ref = [$vars];
1116 } elsif (ref($vars) =~ /ARRAY/) {
1117 $varbind_list_ref = [$vars];
1118 $varbind_list_ref = $vars if ref($$vars[0]) =~ /ARRAY/;
1119 } else {
1120 # my ($tag, $iid) = ($vars =~ /^((?:\.\d+)+|\w+)\.?(.*)$/);
1121 my ($tag, $iid) = ($vars =~ /^(.*?)\.?(\d+)+$/);
1122 $varbind_list_ref = [[$tag, $iid]];
1123 }
1124
1125 if (scalar @$varbind_list_ref == 0) {
1126 $this->{ErrorNum} = SNMP::constant("SNMPERR_GENERR", 0);
1127 $this->{ErrorStr} = "cannot bulkwalk() empty variable list";
1128 return undef;
1129 }
1130 if (scalar @$varbind_list_ref < $nonrepeaters) {
1131 $this->{ErrorNum} = SNMP::constant("SNMPERR_GENERR", 0);
1132 $this->{ErrorStr} = "bulkwalk() needs at least $nonrepeaters varbinds";
1133 return undef;
1134 }
1135
1136 my $cb = shift;
1137 @res = SNMP::_bulkwalk($this, $nonrepeaters, $maxrepetitions,
1138 $varbind_list_ref, $cb);
1139
1140 # Return, in list context, a copy of the array of arrays of Varbind refs.
1141 # In scalar context, return either a reference to the array of arrays of
1142 # Varbind refs, or the request ID for an asynchronous bulkwalk. This is
1143 # a compromise between the getbulk()-ish return, and the more useful array
1144 # of arrays of Varbinds return from the synchronous bulkwalk().
1145 #
1146 return @res if (wantarray());
1147 return defined($cb) ? $res[0] : \@res;
1148 }
1149
1150 my %trap_type = (coldStart => 0, warmStart => 1, linkDown => 2, linkUp => 3,
1151 authFailure => 4, egpNeighborLoss => 5, specific => 6 );
1152 sub trap {
1153 # (v1) enterprise, agent, generic, specific, uptime, <vars>
1154 # $sess->trap(enterprise=>'.1.3.6.1.4.1.2021', # or 'ucdavis' [default]
1155 # agent => '127.0.0.1', # or 'localhost',[default 1st intf on host]
1156 # generic => specific, # can be omitted if 'specific' supplied
1157 # specific => 5, # can be omitted if 'generic' supplied
1158 # uptime => 1234, # default to localhost uptime (0 on win32)
1159 # [[ifIndex, 1, 1],[sysLocation, 0, "here"]]); # optional vars
1160 # # always last
1161 # (v2) oid, uptime, <vars>
1162 # $sess->trap(uptime => 1234,
1163 # oid => 'snmpRisingAlarm',
1164 # [[ifIndex, 1, 1],[sysLocation, 0, "here"]]); # optional vars
1165 # # always last
1166 # # always last
1167
1168
1169 my $this = shift;
1170 my $vars = pop if ref($_[$#_]); # last arg may be varbind or varlist
1171 my %param = @_;
1172 my ($varbind_list_ref, @res);
1173
1174 if (ref($vars) =~ /SNMP::VarList/) {
1175 $varbind_list_ref = $vars;
1176 } elsif (ref($vars) =~ /SNMP::Varbind/) {
1177 $varbind_list_ref = [$vars];
1178 } elsif (ref($vars) =~ /ARRAY/) {
1179 $varbind_list_ref = [$vars];
1180 $varbind_list_ref = $vars if ref($$vars[0]) =~ /ARRAY/;
1181 }
1182
1183 if ($this->{Version} =~ '^1') {
1184 my $enterprise = $param{enterprise} || 'ucdavis';
1185 $enterprise = SNMP::translateObj($enterprise)
1186 unless $enterprise =~ /^[\.\d]+$/;
1187 my $agent = $param{agent} || '';
1188 my $generic = $param{generic} || 'specific';
1189 $generic = $trap_type{$generic} || $generic;
1190 my $uptime = $param{uptime} || SNMP::_sys_uptime();
1191 my $specific = $param{specific} || 0;
1192 @res = SNMP::_trapV1($this, $enterprise, $agent, $generic, $specific,
1193 $uptime, $varbind_list_ref);
1194 } elsif ($this->{Version} =~ '^[23]') {
1195 my $trap_oid = $param{oid} || $param{trapoid} || '.0.0';
1196 my $uptime = $param{uptime} || SNMP::_sys_uptime();
1197 @res = SNMP::_trapV2($this, $uptime, $trap_oid, $varbind_list_ref);
1198 } else {
1199 warn("error:trap: Unsupported SNMP version " . $this->{Version} . "\n");
1200 }
1201
1202 return(wantarray() ? @res : $res[0]);
1203 }
1204
1205 sub inform {
1206 # (v3) oid, uptime, <vars>
1207 # $sess->inform(uptime => 1234,
1208 # oid => 'coldStart',
1209 # [[ifIndex, 1, 1],[sysLocation, 0, "here"]]); # optional vars
1210 # # then callback
1211 # always last
1212
1213
1214 my $this = shift;
1215 my $vars;
1216 my $cb;
1217 $cb = pop if ref($_[$#_]) eq 'CODE'; # last arg may be code
1218 $vars = pop if ref($_[$#_]); # varbind or varlist
1219 my %param = @_;
1220 my ($varbind_list_ref, @res);
1221
1222 if (ref($vars) =~ /SNMP::VarList/) {
1223 $varbind_list_ref = $vars;
1224 } elsif (ref($vars) =~ /SNMP::Varbind/) {
1225 $varbind_list_ref = [$vars];
1226 } elsif (ref($vars) =~ /ARRAY/) {
1227 $varbind_list_ref = [$vars];
1228 $varbind_list_ref = $vars if ref($$vars[0]) =~ /ARRAY/;
1229 }
1230
1231 my $trap_oid = $param{oid} || $param{trapoid};
1232 my $uptime = $param{uptime} || SNMP::_sys_uptime();
1233
1234 if ($this->{Version} =~ '^[23]') {
1235 @res = SNMP::_inform($this, $uptime, $trap_oid, $varbind_list_ref, $cb);
1236 } else {
1237 warn("error:inform: This version doesn't support the command\n");
1238 }
1239
1240 return(wantarray() ? @res : $res[0]);
1241 }
1242
•1243 sub get_sec_engine_id {
1244 my $this = shift;
1245 return SNMP::_get_sec_engine_id($this);
1246 }
1247
1248 sub get_context_engine_id {
1249 my $this = shift;
1250 return SNMP::_get_context_engine_id($this);
1251 }
1252
1253 package SNMP::TrapSession;
1254 @SNMP::TrapSession::ISA = ('SNMP::Session');
1255
1256 sub new {
1257 my $type = shift;
1258
1259 # allow override of remote SNMP trap port
1260 unless (grep(/RemotePort/, @_)) {
1261 push(@_, 'RemotePort', 162); # push on new default for trap session
1262 }
1263
1264 SNMP::Session::new($type, @_);
1265 }
1266
1267 package SNMP::Varbind;
1268
1269 $SNMP::Varbind::tag_f = 0;
1270 $SNMP::Varbind::iid_f = 1;
1271 $SNMP::Varbind::val_f = 2;
1272 $SNMP::Varbind::type_f = 3;
1273 $SNMP::Varbind::time_f = 4;
1274
1275 sub new {
1276 my $type = shift;
1277 my $this = shift;
1278 $this ||= [];
1279 bless $this;
1280 }
1281
1282 sub tag {
1283 $_[0]->[$SNMP::Varbind::tag_f];
1284 }
1285
1286 sub iid {
1287 $_[0]->[$SNMP::Varbind::iid_f];
1288 }
1289
1290 sub val {
1291 $_[0]->[$SNMP::Varbind::val_f];
1292 }
1293
1294 sub type {
1295 $_[0]->[$SNMP::Varbind::type_f];
1296 }
1297
1298 sub name {
1299 if (defined($_[0]->[$SNMP::Varbind::iid_f]) && ($_[0]->[$SNMP::Varbind::iid_f] =~ m/^[0-9]+$/)) {
1300 return $_[0]->[$SNMP::Varbind::tag_f] . "." . $_[0]->[$SNMP::Varbind::iid_f];
1301 }
1302
1303 return $_[0]->[$SNMP::Varbind::tag_f];
1304 }
1305
1306 sub fmt {
1307 my $self = shift;
1308 return $self->name . " = \"" . $self->val . "\" (" . $self->type . ")";
1309 }
1310
1311
1312 #sub DESTROY {
1313 # print "SNMP::Varbind::DESTROY($_[0])\n";
1314 #}
1315
1316 package SNMP::VarList;
1317
1318 sub new {
1319 my $type = shift;
1320 my $this = [];
1321 my $varb;
1322 foreach $varb (@_) {
1323 $varb = new SNMP::Varbind($varb) unless ref($varb) =~ /SNMP::Varbind/;
1324 push(@{$this}, $varb);
1325 }
1326
1327 bless $this;
1328 }
1329
1330 #sub DESTROY {
1331 # print "SNMP::VarList::DESTROY($_[0])\n";
1332 #}
1333
1334 package SNMP::DEBUGGING;
1335 # controls info/debugging output from SNMP module and libsnmp
1336 # $SNMP::debugging == 1 => enables general info and warning output
1337 # (eqiv. to setting $SNMP::verbose)
1338 # $SNMP::debugging == 2 => enables do_debugging from libsnmp as well
1339 # $SNMP::debugging == 3 => enables packet_dump from libsnmp as well
1340 sub TIESCALAR { my $class = shift; my $val; bless \$val, $class; }
1341
1342 sub FETCH { ${$_[0]}; }
1343
1344 sub STORE {
1345 $SNMP::verbose = $_[1];
1346 SNMP::_set_debugging($_[1]>1);
1347 $SNMP::dump_packet = ($_[1]>2);
1348 ${$_[0]} = $_[1];
1349 }
1350
1351 sub DELETE {
1352 $SNMP::verbose = 0;
1353 SNMP::_set_debugging(0);
1354 $SNMP::dump_packet = 0;
1355 ${$_[0]} = undef;
1356 }
1357
1358 package SNMP::DEBUG_INTERNALS; # Controls SNMP.xs debugging.
1359 sub TIESCALAR { my $class = shift; my $val; bless \$val, $class; }
1360
1361 sub FETCH { ${$_[0]}; }
1362
1363 sub STORE {
1364 SNMP::_debug_internals($_[1]);
1365 ${$_[0]} = $_[1];
1366 }
1367
1368 sub DELETE {
1369 SNMP::_debug_internals(0);
1370 ${$_[0]} = undef;
1371 }
1372
1373 package SNMP::DUMP_PACKET;
1374 # controls packet dump output from libsnmp
1375
1376 sub TIESCALAR { my $class = shift; my $val; bless \$val, $class; }
1377
1378 sub FETCH { ${$_[0]}; }
1379
1380 sub STORE { SNMP::_dump_packet($_[1]); ${$_[0]} = $_[1]; }
1381
1382 sub DELETE { SNMP::_dump_packet(0); ${$_[0]} = 0; }
1383
1384 package SNMP::MIB;
1385
1386 sub TIEHASH {
1387 bless {};
1388 }
1389
1390 sub FETCH {
1391 my $this = shift;
1392 my $key = shift;
1393
1394 if (!defined $this->{$key}) {
1395 tie(%{$this->{$key}}, 'SNMP::MIB::NODE', $key) or return undef;
1396 }
1397 $this->{$key};
1398 }
1399
1400 sub STORE {
1401 warn "STORE(@_) : write access to the MIB not implemented\n";
1402 }
1403
1404 sub DELETE {
1405 delete $_[0]->{$_[1]}; # just delete cache entry
1406 }
1407
1408 sub FIRSTKEY { return '.1'; } # this should actually start at .0 but
1409 # because nodes are not stored in lexico
1410 # order in ucd-snmp node tree walk will
1411 # miss most of the tree
1412 sub NEXTKEY { # this could be sped up by using an XS __get_next_oid maybe
1413 my $node = $_[0]->FETCH($_[1])->{nextNode};
1414 $node->{objectID};
1415 }
1416 sub EXISTS { exists $_[0]->{$_[1]} || $_[0]->FETCH($_[1]); }
1417 sub CLEAR { undef %{$_[0]}; } # clear the cache
1418
1419 package SNMP::MIB::NODE;
1420 my %node_elements =
1421 (
1422 objectID => 0, # dotted decimal fully qualified OID
1423 label => 0, # leaf textual identifier (e.g., 'sysDescr')
1424 subID => 0, # leaf numeric OID component of objectID (e.g., '1')
1425 moduleID => 0, # textual identifier for module (e.g., 'RFC1213-MIB')
1426 parent => 0, # parent node
1427 children => 0, # array reference of children nodes
1428 indexes => 0, # returns array of column labels
1429 implied => 0, # boolean: is the last index IMPLIED
1430 varbinds => 0, # returns array of trap/notification varbinds
1431 nextNode => 0, # next lexico node (BUG! does not return in lexico order)
1432 type => 0, # returns simple type (see getType for values)
1433 access => 0, # returns ACCESS (ReadOnly, ReadWrite, WriteOnly,
1434 # NoAccess, Notify, Create)
1435 status => 0, # returns STATUS (Mandatory, Optional, Obsolete,
1436 # Deprecated)
1437 syntax => 0, # returns 'textualConvention' if defined else 'type'
1438 textualConvention => 0, # returns TEXTUAL-CONVENTION
1439 units => 0, # returns UNITS
1440 hint => 0, # returns HINT
1441 enums => 0, # returns hash ref {tag => num, ...}
1442 ranges => 0, # returns array ref of hash ref [{low => num, high => num}]
1443 defaultValue => 0, # returns default value
1444 description => 0, # returns DESCRIPTION ($SNMP::save_descriptions must
1445 # be set prior to MIB initialization/parsing
1446 augments => 0, # textual identifier of augmented object
1447 );
1448
1449 # sub TIEHASH - implemented in SNMP.xs
1450
1451 # sub FETCH - implemented in SNMP.xs
1452
1453 sub STORE {
1454 warn "STORE(@_): write access to MIB node not implemented\n";
1455 }
1456
1457 sub DELETE {
1458 warn "DELETE(@_): write access to MIB node not implemented\n";
1459 }
1460
1461 sub FIRSTKEY { my $k = keys %node_elements; (each(%node_elements))[0]; }
1462 sub NEXTKEY { (each(%node_elements))[0]; }
1463 sub EXISTS { exists($node_elements{$_[1]}); }
1464 sub CLEAR {
1465 warn "CLEAR(@_): write access to MIB node not implemented\n";
1466 }
1467
1468 #sub DESTROY {
1469 # warn "DESTROY(@_): write access to MIB node not implemented\n";
1470 # # print "SNMP::MIB::NODE::DESTROY : $_[0]->{label} ($_[0])\n";
1471 #}
1472 package SNMP::MIB::SAVE_DESCR;
1473
1474 sub TIESCALAR { my $class = shift; my $val; bless \$val, $class; }
1475
1476 sub FETCH { ${$_[0]}; }
1477
1478 sub STORE { SNMP::_set_save_descriptions($_[1]); ${$_[0]} = $_[1]; }
1479
1480 sub DELETE { SNMP::_set_save_descriptions(0); ${$_[0]} = 0; }
1481
1482 package SNMP::MIB::REPLACE_NEWER; # Controls MIB parsing
1483
1484 sub TIESCALAR { my $class = shift; my $val; bless \$val, $class; }
1485
1486 sub FETCH { ${$_[0]}; }
1487
1488 sub STORE {
1489 SNMP::_set_replace_newer($_[1]);
1490 ${$_[0]} = $_[1];
1491 }
1492
1493 sub DELETE {
1494 SNMP::_set_replace_newer(0);
1495 ${$_[0]} = 0;
1496 }
1497
1498 package SNMP::MIB::MIB_OPTIONS;
1499
1500 sub TIESCALAR { my $class = shift; my $val; bless \$val, $class; }
1501
1502 sub FETCH { ${$_[0]}; }
1503
1504 sub STORE { SNMP::_mib_toggle_options($_[1]); ${$_[0]} = $_[1]; }
1505
1506 sub DELETE { SNMP::_mib_toggle_options(0); ${$_[0]} = ''; }
1507
1508 package SNMP;
1509 END{SNMP::_sock_cleanup() if defined &SNMP::_sock_cleanup;}
1510 # Autoload methods go after __END__, and are processed by the autosplit prog.
1511
1512 1;
1513 __END__
1514
1515 =head1 NAME
1516
1517 SNMP - The Perl5 'SNMP' Extension Module for the Net-SNMP SNMP package.
1518
1519 =head1 SYNOPSIS
1520
1521 use SNMP;
1522 ...
1523 $sess = new SNMP::Session(DestHost => localhost, Community => public);
1524 $val = $sess->get('sysDescr.0');
1525 ...
1526 $vars = new SNMP::VarList([sysDescr,0], [sysContact,0], [sysLocation,0]);
1527 @vals = $sess->get($vars);
1528 ...
1529 $vb = new SNMP::Varbind();
1530 do {
1531 $val = $sess->getnext($vb);
1532 print "@{$vb}\n";
1533 } until ($sess->{ErrorNum});
1534 ...
1535 $SNMP::save_descriptions = 1;
1536 SNMP::initMib(); # assuming mib is not already loaded
1537 print "$SNMP::MIB{sysDescr}{description}\n";
1538
1539 =head1 DESCRIPTION
1540
1541
1542 Note: The perl SNMP 5.0 module which comes with net-snmp 5.0 and
1543 higher is different than previous versions in a number of ways. Most
1544 importantly, it behaves like a proper net-snmp application and calls
1545 init_snmp properly, which means it will read configuration files and
1546 use those defaults where appropriate automatically parse MIB files,
1547 etc. This will likely affect your perl applications if you have, for
1548 instance, default values set up in your snmp.conf file (as the perl
1549 module will now make use of those defaults). The documentation,
1550 however, has sadly not been updated yet (aside from this note), nor is
1551 the read_config default usage implementation fully complete.
1552
1553 The basic operations of the SNMP protocol are provided by this module
1554 through an object oriented interface for modularity and ease of use.
1555 The primary class is SNMP::Session which encapsulates the persistent
1556 aspects of a connection between the management application and the
1557 managed agent. Internally the class is implemented as a blessed hash
1558 reference. This class supplies 'get', 'getnext', 'set', 'fget', and
1559 'fgetnext' method calls. The methods take a variety of input argument
1560 formats and support both synchronous and asynchronous operation through
1561 a polymorphic API (i.e., method behaviour varies dependent on args
1562 passed - see below).
1563
1564 =head1 SNMP::Session
1565
1566 $sess = new SNMP::Session(DestHost => 'host', ...)
1567
1568 The following arguments may be passed to new as a hash.
1569
1570 =head2 Basic Options
1571
1572 =over 4
1573
1574 =item DestHost
1575
1576 Hostname or IP address of the SNMP agent you want to talk to.
1577 Specified in Net-SNMP formatted agent addresses. These addresses
1578 typically look like one of the following:
1579
1580 localhost
1581 tcp:localhost
1582 tls:localhost
1583 tls:localhost:9876
1584 udp6:[::1]:9876
1585 unix:/some/path/to/file/socket
1586
1587 Defaults to 'localhost'.
1588
1589 =item Version
1590
1591 SNMP version to use.
1592
1593 The default is taken from library configuration - probably 3 [1, 2
1594 (same as 2c), 2c, 3].
1595
1596 =item Timeout
1597
1598 The number of micro-seconds to wait before resending a request.
1599
1600 The default is '1000000'
1601
1602 =item Retries
1603
1604 The number of times to retry a request.
1605
1606 The default is '5'
1607
1608 =item RetryNoSuch
1609
1610 If enabled NOSUCH errors in 'get' pdus will
1611 be repaired, removing the varbind in error, and resent -
1612 undef will be returned for all NOSUCH varbinds, when set
1613 to '0' this feature is disabled and the entire get request
1614 will fail on any NOSUCH error (applies to v1 only)
1615
1616 The default is '0'.
1617
1618 =back
1619
1620 =head2 SNMPv3/TLS Options
1621
1622 =over
1623
1624 =item OurIdentity
1625
1626 Our X.509 identity to use, which should either be a fingerprint or the
1627 filename that holds the certificate.
1628
1629 =item TheirIdentity
1630
1631 The remote server's identity to connect to, specified as either a
1632 fingerprint or a file name. Either this must be specified, or the
1633 hostname below along with a trust anchor.
1634
1635 =item TheirHostname
1636
1637 The remote server's hostname that is expected. If their certificate
1638 was signed by a CA then their hostname presented in the certificate
1639 must match this value or the connection fails to be established (to
1640 avoid man-in-the-middle attacks).
1641
1642 =item TrustCert
1643
1644 A trusted certificate to use as trust anchor (like a CA certificate)
1645 for verifying a remote server's certificate. If a CA certificate is
1646 used to validate a certificate then the TheirHostname parameter must
1647 also be specified to ensure their presented hostname in the certificate
1648 matches.
1649
1650 =back
1651
1652 =head2 SNMPv3/USM Options
1653
1654 =over
1655
1656 =item SecName
1657
1658 The SNMPv3 security name to use (most for SNMPv3 with USM).
1659
1660 The default is 'initial'.
1661
1662 =item SecLevel
1663
1664 The SNMPv3 security level to use [noAuthNoPriv, authNoPriv, authPriv] (v3)
1665
1666 The default is 'noAuthNoPriv'.
1667
1668 =item SecEngineId
1669
1670 The SNMPv3 security engineID to use (if the snmpv3 security model
1671 needs it; for example USM). The format is as a string without the leading '0x'.
1672 So if snmptrapd.conf has C<-e 0x8000000001020304>, use C<< SecEngineId =>
1673 '8000000001020304' >>.
1674
1675 The default is <none>, security engineID and it will be probed if not
1676 supplied (v3)
1677
1678 =item ContextEngineId
1679
1680 The SNMPv3 context engineID to use.
1681
1682 The default is the <none> and will be set either to the SecEngineId
1683 value if set or discovered or will be discovered in other ways if
1684 using TLS (RFC5343 based discovery).
1685
1686 =item Context
1687
1688 The SNMPv3 context name to use.
1689
1690 The default is '' (an empty string)
1691
1692 =item AuthProto
1693
1694 The SNMPv3/USM authentication protocol to use [MD5, SHA].
1695
1696 The default is 'MD5'.
1697
1698 =item AuthPass
1699
1700 The SNMPv3/USM authentication passphrase to use.
1701
1702 default <none>, authentication passphrase
1703
1704 =item PrivProto
1705
1706 The SNMPv3/USM privacy protocol to use [DES, AES].
1707
1708 The default is 'DES'.
1709
1710 =item PrivPass
1711
1712 The SNMPv3/USM privacy passphrase to use.
1713
1714 default <none>, privacy passphrase (v3)
1715
1716 =item AuthMasterKey
1717
1718 =item PrivMasterKey
1719
1720 =item AuthLocalizedKey
1721
1722 =item PrivLocalizedKey
1723
1724 Directly specified SNMPv3 USM user keys (used if you want to specify
1725 the keys instead of deriving them from a password as above).
1726
1727 =back
1728
1729 =head2 SNMPv1 and SNMPv2c Options
1730
1731 =over
1732
1733 =item Community
1734
1735 For SNMPv1 and SNMPv2c, the clear-text community name to use.
1736
1737 The default is 'public'.
1738
1739 =back
1740
1741 =head2 Other Configuration Options
1742
1743 =over
1744
1745 =item VarFormats
1746
1747 default 'undef', used by 'fget[next]', holds an hash
1748 reference of output value formatters, (e.g., {<obj> =>
1749 <sub-ref>, ... }, <obj> must match the <obj> and format
1750 used in the get operation. A special <obj>, '*', may be
1751 used to apply all <obj>s, the supplied sub is called to
1752 translate the value to a new format. The sub is called
1753 passing the Varbind as the arg
1754
1755 =item TypeFormats
1756
1757 default 'undef', used by 'fget[next]', holds an hash
1758 reference of output value formatters, (e.g., {<type> =>
1759 <sub-ref>, ... }, the supplied sub is called to translate
1760 the value to a new format, unless a VarFormat mathces first
1761 (e.g., $sess->{TypeFormats}{INTEGER} = \&mapEnum();
1762 although this can be done more efficiently by enabling
1763 $SNMP::use_enums or session creation param 'UseEnums')
1764
1765 =item UseLongNames
1766
1767 defaults to the value of SNMP::use_long_names at time
1768 of session creation. set to non-zero to have <tags>
1769 for 'getnext' methods generated preferring longer Mib name
1770 convention (e.g., system.sysDescr vs just sysDescr)
1771
1772 =item UseSprintValue
1773
1774 defaults to the value of SNMP::use_sprint_value at time
1775 of session creation. set to non-zero to have return values
1776 for 'get' and 'getnext' methods formatted with the libraries
1777 snprint_value function. This will result in certain data types
1778 being returned in non-canonical format Note: values returned
1779 with this option set may not be appropriate for 'set' operations
1780 (see discussion of value formats in <vars> description section)
1781
1782 =item UseEnums
1783
1784 defaults to the value of SNMP::use_enums at time of session
1785 creation. set to non-zero to have integer return values
1786 converted to enumeration identifiers if possible, these values
1787 will also be acceptable when supplied to 'set' operations
1788
1789 =item UseNumeric
1790
1791 defaults to the value of SNMP::use_numeric at time of session
1792 creation. set to non-zero to have <tags> for get methods returned
1793 as numeric OID's rather than descriptions. UseLongNames will be
1794 set so that the full OID is returned to the caller.
1795
1796 =item BestGuess
1797
1798 defaults to the value of SNMP::best_guess at time of session
1799 creation. this setting controls how <tags> are parsed. setting to
1800 0 causes a regular lookup. setting to 1 causes a regular expression
1801 match (defined as -Ib in snmpcmd) and setting to 2 causes a random
1802 access lookup (defined as -IR in snmpcmd).
1803
1804 =item NonIncreasing
1805
1806 defaults to the value of SNMP::non_increasing at time of session
1807 creation. this setting controls if a non-increasing OID during
1808 bulkwalk will causes an error. setting to 0 causes the default
1809 behaviour (which may, in very badly performing agents, result in a never-ending loop).
1810 setting to 1 causes an error (OID not increasing) when this error occur.
1811
1812 =item ErrorStr
1813
1814 read-only, holds the error message assoc. w/ last request
1815
1816 =item ErrorNum
1817
1818 read-only, holds the snmp_err or staus of last request
1819
1820 =item ErrorInd
1821
1822 read-only, holds the snmp_err_index when appropriate
1823
1824 =back
1825
1826 Private variables:
1827
1828 =over
1829
1830 =item DestAddr
1831
1832 internal field used to hold the translated DestHost field
1833
1834 =item SessPtr
1835
1836 internal field used to cache a created session structure
1837
1838 =item RemotePort
1839
1840 Obsolete. Please use the DestHost specifier to indicate the hostname
1841 and port combination instead of this paramet.
1842
1843 =back
1844
1845 =head2 SNMP::Session methods
1846
1847 =over
1848
1849 =item $sess->update(E<lt>fieldsE<gt>)
1850
1851 Updates the SNMP::Session object with the values fields
1852 passed in as a hash list (similar to new(E<lt>fieldsE<gt>))
1853 B<(WARNING! not fully implemented)>
1854
1855 =item $sess->get(E<lt>varsE<gt> [,E<lt>callbackE<gt>])
1856
1857 do SNMP GET, multiple <vars> formats accepted.
1858 for syncronous operation <vars> will be updated
1859 with value(s) and type(s) and will also return
1860 retrieved value(s). If <callback> supplied method
1861 will operate asynchronously
1862
1863 =item $sess->fget(E<lt>varsE<gt> [,E<lt>callbackE<gt>])
1864
1865 do SNMP GET like 'get' and format the values according
1866 the handlers specified in $sess->{VarFormats} and
1867 $sess->{TypeFormats}
1868
1869 =item $sess->getnext(E<lt>varsE<gt> [,E<lt>callbackE<gt>])
1870
1871 do SNMP GETNEXT, multiple <vars> formats accepted,
1872 returns retrieved value(s), <vars> passed as arguments are
1873 updated to indicate next lexicographical <obj>,<iid>,<val>,
1874 and <type>
1875
1876 Note: simple string <vars>,(e.g., 'sysDescr.0')
1877 form is not updated. If <callback> supplied method
1878 will operate asynchronously
1879
1880 =item $sess->fgetnext(E<lt>varsE<gt> [,E<lt>callbackE<gt>])
1881
1882 do SNMP GETNEXT like getnext and format the values according
1883 the handlers specified in $sess->{VarFormats} and
1884 $sess->{TypeFormats}
1885
1886 =item $sess->set(E<lt>varsE<gt> [,E<lt>callbackE<gt>])
1887
1888 do SNMP SET, multiple <vars> formats accepted.
1889 the value field in all <vars> formats must be in a canonical
1890 format (i.e., well known format) to ensure unambiguous
1891 translation to SNMP MIB data value (see discussion of
1892 canonical value format <vars> description section),
1893 returns snmp_errno. If <callback> supplied method
1894 will operate asynchronously
1895
1896 =item $sess->getbulk(E<lt>non-repeatersE<gt>, E<lt>max-repeatersE<gt>, E<lt>varsE<gt>)
1897
1898 do an SNMP GETBULK, from the list of Varbinds, the single
1899 next lexico instance is fetched for the first n Varbinds
1900 as defined by <non-repeaters>. For remaining Varbinds,
1901 the m lexico instances are retrieved each of the remaining
1902 Varbinds, where m is <max-repeaters>.
1903
1904 =item $sess->bulkwalk(E<lt>non-repeatersE<gt>, E<lt>max-repeatersE<gt>, E<lt>varsE<gt> [,E<lt>callbackE<gt>])
1905
1906 Do a "bulkwalk" of the list of Varbinds. This is done by
1907 sending a GETBULK request (see getbulk() above) for the
1908 Varbinds. For each requested variable, the response is
1909 examined to see if the next lexico instance has left the
1910 requested sub-tree. Any further instances returned for
1911 this variable are ignored, and the walk for that sub-tree
1912 is considered complete.
1913
1914 If any sub-trees were not completed when the end of the
1915 responses is reached, another request is composed, consisting
1916 of the remaining variables. This process is repeated until
1917 all sub-trees have been completed, or too many packets have
1918 been exchanged (to avoid loops).
1919
1920 The bulkwalk() method returns an array containing an array of
1921 Varbinds, one for each requested variable, in the order of the
1922 variable requests. Upon error, bulkwalk() returns undef and
1923 sets $sess->ErrorStr and $sess->ErrorNum. If a callback is
1924 supplied, bulkwalk() returns the SNMP request id, and returns
1925 immediately. The callback will be called with the supplied
1926 argument list and the returned variables list.
1927
1928 Note: Because the client must "discover" that the tree is
1929 complete by comparing the returned variables with those that
1930 were requested, there is a potential "gotcha" when using the
1931 max-repeaters value. Consider the following code to print a
1932 list of interfaces and byte counts:
1933
1934 $numInts = $sess->get('ifNumber.0');
1935 ($desc, $in, $out) = $sess->bulkwalk(0, $numInts,
1936 [['ifDescr'], ['ifInOctets'], ['ifOutOctets']]);
1937
1938 for $i (0..($numInts - 1)) {
1939 printf "Interface %4s: %s inOctets, %s outOctets\n",
1940 $$desc[$i]->val, $$in[$i]->val, $$out[$i]->val;
1941 }
1942
1943 This code will produce *two* requests to the agent -- the first
1944 to get the interface values, and the second to discover that all
1945 the information was in the first packet. To get around this,
1946 use '$numInts + 1' for the max_repeaters value. This asks the
1947 agent to include one additional (unrelated) variable that signals
1948 the end of the sub-tree, allowing bulkwalk() to determine that
1949 the request is complete.
1950
1951 =item $results = $sess->gettable(E<lt>TABLE OIDE<gt>, E<lt>OPTIONSE<gt>)
1952
1953 This will retrieve an entire table of data and return a hash reference
1954 to that data. The returned hash reference will have indexes of the
1955 OID suffixes for the index data as the key. The value for each entry
1956 will be another hash containing the data for a given row. The keys to
1957 that hash will be the column names, and the values will be the data.
1958
1959 Example:
1960
1961 #!/usr/bin/perl
1962
1963 use SNMP;
1964 use Data::Dumper;
1965
1966 my $s = new SNMP::Session(DestHost => 'localhost');
1967
1968 print Dumper($s->gettable('ifTable'));
1969
1970 On my machine produces:
1971
1972 $VAR1 = {
1973 '6' => {
1974 'ifMtu' => '1500',
1975 'ifPhysAddress' => 'PV',
1976 # ...
1977 'ifInUnknownProtos' => '0'
1978 },
1979 '4' => {
1980 'ifMtu' => '1480',
1981 'ifPhysAddress' => '',
1982 # ...
1983 'ifInUnknownProtos' => '0'
1984 },
1985 # ...
1986 };
1987
1988 By default, it will try to do as optimized retrieval as possible.
1989 It'll request multiple columns at once, and use GETBULK if possible.
1990 A few options may be specified by passing in an I<OPTIONS> hash
1991 containing various parameters:
1992
1993 =over
1994
1995 =item noindexes => 1
1996
1997 Instructs the code not to parse the indexes and place the results in
1998 the second hash. If you don't need the index data, this will be
1999 faster.
2000
2001 =item columns => [ colname1, ... ]
2002
2003 This specifies which columns to collect. By default, it will try to
2004 collect all the columns defined in the MIB table.
2005
2006 =item repeat => I<COUNT>
2007
2008 Specifies a GETBULK repeat I<COUNT>. IE, it will request this many
2009 varbinds back per column when using the GETBULK operation. Shortening
2010 this will mean smaller packets which may help going through some
2011 systems. By default, this value is calculated and attempts to guess
2012 at what will fit all the results into 1000 bytes. This calculation is
2013 fairly safe, hopefully, but you can either raise or lower the number
2014 using this option if desired. In lossy networks, you want to make
2015 sure that the packets don't get fragmented and lowering this value is
2016 one way to help that.
2017
2018 =item nogetbulk => 1
2019
2020 Force the use of GETNEXT rather than GETBULK. (always true for
2021 SNMPv1, as it doesn't have GETBULK anyway). Some agents are great
2022 implementers of GETBULK and this allows you to force the use of
2023 GETNEXT operations instead.
2024
2025 =item callback => \&subroutine
2026
2027 =item callback => [\&subroutine, optarg1, optarg2, ...]
2028
2029 If a callback is specified, gettable will return quickly without
2030 returning results. When the results are finally retrieved the
2031 callback subroutine will be called (see the other sections defining
2032 callback behaviour and how to make use of SNMP::MainLoop which is
2033 required for this to work). An additional argument of the normal hash
2034 result will be added to the callback subroutine arguments.
2035
2036 Note 1: internally, the gettable function uses it's own callbacks
2037 which are passed to getnext/getbulk as appropriate.
2038
2039 Note 2: callback support is only available in the SNMP module version
2040 5.04 and above. To test for this in code intending to support both
2041 versions prior to 5.04 and 5.04 and up, the following should work:
2042
2043 if ($response = $sess->gettable('ifTable', callback => \&my_sub)) {
2044 # got a response, gettable doesn't support callback
2045 my_sub($response);
2046 $no_mainloop = 1;
2047 }
2048
2049 Deciding on whether to use SNMP::MainLoop is left as an exercise to
2050 the reader since it depends on whether your code uses other callbacks
2051 as well.
2052
2053 =back
2054
•2055 =item $sess->get_sec_engine_id
2056
2057 Returns the security engine ID for the current session, whether probed
2058 or provided by the client, in hex format suitable for the SecEngineId
2059 parameter when creating a session in the future. Returns undef if we have not
2060 had not had any contact with the remote agent yet.
2061
2062 =item $sess->get_context_engine_id
2063
2064 Like get_sec_engine_id, but for the context engine ID (ContextEngineId).
2065
2066 =back
2067
2068 =head1 SNMP::TrapSession
2069
2070 $sess = new SNMP::Session(DestHost => 'host', ...)
2071
2072 supports all applicable fields from SNMP::Session
2073 (see above)
2074
2075 =head2 SNMP::TrapSession methods
2076
2077 =over
2078
2079 =item $sess->trap(enterprise, agent, generic, specific, uptime, <vars>)
2080
2081 $sess->trap(enterprise=>'.1.3.6.1.4.1.2021', # or 'ucdavis' [default]
2082 agent => '127.0.0.1', # or 'localhost',[dflt 1st intf on host]
2083 generic => specific, # can be omitted if 'specific' supplied
2084 specific => 5, # can be omitted if 'generic' supplied
2085 uptime => 1234, # dflt to localhost uptime (0 on win32)
2086 [[ifIndex, 1, 1],[sysLocation, 0, "here"]]); # optional vars
2087 # always last
2088
2089 =item trap(oid, uptime, <vars>) - v2 format
2090
2091 $sess->trap(oid => 'snmpRisingAlarm',
2092 uptime => 1234,
2093 [[ifIndex, 1, 1],[sysLocation, 0, "here"]]); # optional vars
2094 # always last
2095
2096 =back
2097
2098 =head1 Acceptable variable formats:
2099
2100 <vars> may be one of the following forms:
2101
2102 =over
2103
2104 =item SNMP::VarList
2105
2106 represents an array of MIB objects to get or set,
2107 implemented as a blessed reference to an array of
2108 SNMP::Varbinds, (e.g., [<varbind1>, <varbind2>, ...])
2109
2110 =item SNMP::Varbind
2111
2112 represents a single MIB object to get or set, implemented as
2113 a blessed reference to a 4 element array;
2114 [<obj>, <iid>, <val>, <type>].
2115
2116 =over
2117
2118 =item <obj>
2119
2120 one of the following forms:
2121
2122 =over
2123
2124 =item 1)
2125
2126 leaf identifier (e.g., 'sysDescr') assumed to be
2127 unique for practical purposes
2128
2129 =item 2)
2130
2131 fully qualified identifier (e.g.,
2132 '.iso.org.dod.internet.mgmt.mib-2.system.sysDescr')
2133
2134 =item 3)
2135
2136 fully qualified, dotted-decimal, numeric OID (e.g.,
2137 '.1.3.6.1.2.1.1.1')
2138
2139 =back
2140
2141 =item <iid>
2142
2143 the dotted-decimal, instance identifier. for
2144 scalar MIB objects use '0'
2145
2146 =item <val>
2147
2148 the SNMP data value retrieved from or being set
2149 to the agents MIB. for (f)get(next) operations
2150 <val> may have a variety of formats as determined by
2151 session and package settings. However for set
2152 operations the <val> format must be canonical to
2153 ensure unambiguous translation. The canonical forms
2154 are as follows:
2155
2156 =over
2157
2158 =item OBJECTID
2159
2160 dotted-decimal (e.g., .1.3.6.1.2.1.1.1)
2161
2162 =item OCTETSTR
2163
2164 perl scalar containing octets
2165
2166 =item INTEGER
2167
2168 decimal signed integer (or enum)
2169
2170 =item NETADDR
2171
2172 dotted-decimal
2173
2174 =item IPADDR
2175
2176 dotted-decimal
2177
2178 =item COUNTER
2179
2180 decimal unsigned integer
2181
2182 =item COUNTER64
2183
2184 decimal unsigned integer
2185
2186 =item GAUGE
2187
2188 decimal unsigned integer
2189
2190 =item UINTEGER
2191
2192 decimal unsigned integer
2193
2194 =item TICKS
2195
2196 decimal unsigned integer
2197
2198 =item OPAQUE
2199
2200 perl scalar containing octets
2201
2202 =item NULL
2203
2204 perl scalar containing nothing
2205
2206 =back
2207
2208 =item <type>
2209
2210 SNMP data type (see list above), this field is
2211 populated by 'get' and 'getnext' operations. In
2212 some cases the programmer needs to populate this
2213 field when passing to a 'set' operation. this
2214 field need not be supplied when the attribute
2215 indicated by <tag> is already described by loaded
2216 Mib modules. for 'set's, if a numeric OID is used
2217 and the object is not currently in the loaded Mib,
2218 the <type> field must be supplied
2219
2220 =back
2221
2222 =item simple string
2223
2224 light weight form of <var> used to 'set' or 'get' a
2225 single attribute without constructing an SNMP::Varbind.
2226 stored in a perl scalar, has the form '<tag>.<iid>',
2227 (e.g., 'sysDescr.0'). for 'set' operations the value
2228 is passed as a second arg. Note: This argument form is
2229 not updated in get[next] operations as are the other forms.
2230
2231 =back
2232
2233 =head1 Acceptable callback formats
2234
2235 <callback> may be one of the following forms:
2236
2237 =over
2238
2239 =item without arguments
2240
2241 =over
2242
2243 =item \&subname
2244
2245 =item sub { ... }
2246
2247 =back
2248
2249 =item or with arguments
2250
2251 =over
2252
2253 =item [ \&subname, $arg1, ... ]
2254
2255 =item [ sub { ... }, $arg1, ... ]
2256
2257 =item [ "method", $obj, $arg1, ... ]
2258
2259 =back
2260
2261 =back
2262
2263 callback will be called when response is received or timeout
2264 occurs. the last argument passed to callback will be a
2265 SNMP::VarList reference. In case of timeout the last argument
2266 will be undef.
2267
2268 =over
2269
2270 =item &SNMP::MainLoop([<timeout>, [<callback>]])
2271
2272 to be used with async SNMP::Session
2273 calls. MainLoop must be called after initial async calls
2274 so return packets from the agent will be processed.
2275 If no args supplied this function enters an infinite loop
2276 so program must be exited in a callback or externally
2277 interrupted. If <timeout(sic)
2278
2279 =item &SNMP::finish()
2280
2281 This function, when called from an SNMP::MainLoop() callback
2282 function, will cause the current SNMP::MainLoop() to return
2283 after the callback is completed. finish() can be used to
2284 terminate an otherwise-infinite MainLoop. A new MainLoop()
2285 instance can then be started to handle further requests.
2286
2287 =back
2288
2289 =head1 SNMP package variables and functions
2290
2291 =over
2292
2293 =item $SNMP::VERSION
2294
2295 the current version specifier (e.g., 3.1.0)
2296
2297 =item $SNMP::auto_init_mib
2298
2299 default '1', set to 0 to disable automatic reading
2300 of the MIB upon session creation. set to non-zero
2301 to call initMib at session creation which will result
2302 in MIB loading according to Net-SNMP env. variables (see
2303 man mib_api)
2304
2305 =item $SNMP::verbose
2306
2307 default '0', controls warning/info output of
2308 SNMP module, 0 => no output, 1 => enables warning/info
2309 output from SNMP module itself (is also controlled
2310 by SNMP::debugging - see below)
2311
2312 =item $SNMP::use_long_names
2313
2314 default '0', set to non-zero to enable the use of
2315 longer Mib identifiers. see translateObj. will also
2316 influence the formatting of <tag> in varbinds returned
2317 from 'getnext' operations. Can be set on a per session
2318 basis (UseLongNames)
2319
2320 =item $SNMP::use_sprint_value
2321
2322 default '0', set to non-zero to enable formatting of
2323 response values using the snmp libraries snprint_value
2324 function. can also be set on a per session basis (see
2325 UseSprintValue) Note: returned values may not be
2326 suitable for 'set' operations
2327
2328 =item $SNMP::use_enums
2329
2330 default '0',set non-zero to return values as enums and
2331 allow sets using enums where appropriate. integer data
2332 will still be accepted for set operations. can also be
2333 set on a per session basis (see UseEnums)
2334
2335 =item $SNMP::use_numeric
2336
2337 default to '0',set to non-zero to have <tags> for 'get'
2338 methods returned as numeric OID's rather than descriptions.
2339 UseLongNames will be set so that the entire OID will be
2340 returned. Set on a per-session basis (see UseNumeric).
2341
2342 =item $SNMP::best_guess
2343
2344 default '0'. This setting controls how <tags> are
2345 parsed. Setting to 0 causes a regular lookup. Setting
2346 to 1 causes a regular expression match (defined as -Ib
2347 in snmpcmd) and setting to 2 causes a random access
2348 lookup (defined as -IR in snmpcmd). Can also be set
2349 on a per session basis (see BestGuess)
2350
2351 =item $SNMP::save_descriptions
2352
2353 default '0',set non-zero to have mib parser save
2354 attribute descriptions. must be set prior to mib
2355 initialization
2356
2357 =item $SNMP::debugging
2358
2359 default '0', controls debugging output level
2360 within SNMP module and libsnmp
2361
2362 =over
2363
2364 =item 1
2365
2366 enables 'SNMP::verbose' (see above)
2367
2368 =item 2
2369
2370 level 1 plus snmp_set_do_debugging(1)
2371
2372 =item 3
2373
2374 level 2 plus snmp_set_dump_packet(1)
2375
2376 =back
2377
2378 =item $SNMP::dump_packet
2379
2380 default '0', set [non-]zero to independently set
2381 snmp_set_dump_packet()
2382
2383 =item SNMP::register_debug_tokens()
2384
2385 Allows to register one or more debug tokens, just like the -D option of snmpd.
2386 Each debug token enables a group of debug statements. An example:
2387 SNMP::register_debug_tokens("tdomain,netsnmp_unix");
2388
2389 =back
2390
2391 =head1 %SNMP::MIB
2392
2393 a tied hash to access parsed MIB information. After
2394 the MIB has been loaded this hash allows access to
2395 to the parsed in MIB meta-data(the structure of the
2396 MIB (i.e., schema)). The hash returns blessed
2397 references to SNMP::MIB::NODE objects which represent
2398 a single MIB attribute. The nodes can be fetched with
2399 multiple 'key' formats - the leaf name (e.g.,sysDescr)
2400 or fully/partially qualified name (e.g.,
2401 system.sysDescr) or fully qualified numeric OID. The
2402 returned node object supports the following fields:
2403
2404 =over
2405
2406 =item objectID
2407
2408 dotted decimal fully qualified OID
2409
2410 =item label
2411
2412 leaf textual identifier (e.g., 'sysDescr')
2413
2414 =item subID
2415
2416 leaf numeric OID component of objectID (e.g., '1')
2417
2418 =item moduleID
2419
2420 textual identifier for module (e.g., 'RFC1213-MIB')
2421
2422 =item parent
2423
2424 parent node
2425
2426 =item children
2427
2428 array reference of children nodes
2429
2430 =item nextNode
2431
2432 next lexico node B<(BUG!does not return in lexico order)>
2433
2434 =item type
2435
2436 returns application type (see getType for values)
2437
2438 =item access
2439
2440 returns ACCESS (ReadOnly, ReadWrite, WriteOnly,
2441 NoAccess, Notify, Create)
2442
2443 =item status
2444
2445 returns STATUS (Mandatory, Optional, Obsolete,
2446 Deprecated)
2447
2448 =item syntax
2449
2450 returns 'textualConvention' if defined else 'type'
2451
2452 =item textualConvention
2453
2454 returns TEXTUAL-CONVENTION
2455
2456 =item TCDescription
2457
2458 returns the TEXTUAL-CONVENTION's DESCRIPTION field.
2459
2460 =item units
2461
2462 returns UNITS
2463
2464 =item hint
2465
2466 returns HINT
2467
2468 =item enums
2469
2470 returns hash ref {tag => num, ...}
2471
2472 =item ranges
2473
2474 returns array ref of hash ref [{low => num, high => num}, ...]
2475
2476 =item description
2477
2478 returns DESCRIPTION ($SNMP::save_descriptions must
2479 be set prior to MIB initialization/parsing)
2480
2481 =item reference
2482
2483 returns the REFERENCE clause
2484
2485 =item indexes
2486
2487 returns the objects in the INDEX clause
2488
2489 =item implied
2490
2491 returns true if the last object in the INDEX is IMPLIED
2492
2493 =back
2494
2495 =head1 MIB Functions
2496
2497 =over
2498
2499 =item &SNMP::setMib(<file>)
2500
2501 allows dynamic parsing of the mib and explicit
2502 specification of mib file independent of environment
2503 variables. called with no args acts like initMib,
2504 loading MIBs indicated by environment variables (see
2505 Net-SNMP mib_api docs). passing non-zero second arg
2506 forces previous mib to be freed and replaced
2507 B<(Note: second arg not working since freeing previous
2508 Mib is more involved than before)>.
2509
2510 =item &SNMP::initMib()
2511
2512 calls library init_mib function if Mib not already
2513 loaded - does nothing if Mib already loaded. will
2514 parse directories and load modules according to
2515 environment variables described in Net-SNMP documentations.
2516 (see man mib_api, MIBDIRS, MIBS, MIBFILE(S), etc.)
2517
2518 =item &SNMP::addMibDirs(<dir>,...)
2519
2520 calls library add_mibdir for each directory
2521 supplied. will cause directory(s) to be added to
2522 internal list and made available for searching in
2523 subsequent loadModules calls
2524
2525 =item &SNMP::addMibFiles(<file>,...)
2526
2527 calls library read_mib function. The file(s)
2528 supplied will be read and all Mib module definitions
2529 contained therein will be added to internal mib tree
2530 structure
2531
2532 =item &SNMP::loadModules(<mod>,...)
2533
2534 calls library read_module function. The
2535 module(s) supplied will be searched for in the
2536 current mibdirs and and added to internal mib tree
2537 structure. Passing special <mod>, 'ALL', will cause
2538 all known modules to be loaded.
2539
2540 =item &SNMP::unloadModules(<mod>,...)
2541
2542 B<*Not Implemented*>
2543
2544 =item &SNMP::translateObj(<var>[,arg,[arg]])
2545
2546 will convert a text obj tag to an OID and vice-versa.
2547 Any iid suffix is retained numerically. Default
2548 behaviour when converting a numeric OID to text
2549 form is to return leaf identifier only
2550 (e.g.,'sysDescr') but when $SNMP::use_long_names
2551 is non-zero or a non-zero second arg is supplied it
2552 will return a longer textual identifier. An optional
2553 third argument of non-zero will cause the module name
2554 to be prepended to the text name (e.g.
2555 'SNMPv2-MIB::sysDescr'). When converting a text obj,
2556 the $SNMP::best_guess option is used. If no Mib is
2557 loaded when called and $SNMP::auto_init_mib is enabled
2558 then the Mib will be loaded. Will return 'undef' upon
2559 failure.
2560
2561 =item &SNMP::getType(<var>)
2562
2563 return SNMP data type for given textual identifier
2564 OBJECTID, OCTETSTR, INTEGER, NETADDR, IPADDR, COUNTER
2565 GAUGE, TIMETICKS, OPAQUE, or undef
2566
2567 =item &SNMP::mapEnum(<var>)
2568
2569 converts integer value to enumertion tag defined
2570 in Mib or converts tag to integer depending on
2571 input. the function will return the corresponding
2572 integer value *or* tag for a given MIB attribute
2573 and value. The function will sense which direction
2574 to perform the conversion. Various arg formats are
2575 supported
2576
2577 =over
2578
2579 =item $val = SNMP::mapEnum($varbind);
2580
2581 where $varbind is SNMP::Varbind or equiv.
2582 note: $varbind will be updated
2583
2584 =item $val = SNMP::mapEnum('ipForwarding', 'forwarding');
2585
2586 =item $val = SNMP::mapEnum('ipForwarding', 1);
2587
2588 =back
2589
2590 =back
2591
2592 =head1 Exported SNMP utility functions
2593
2594 Note: utility functions do not support async operation yet.
2595
2596 =over
2597
2598 =item &snmp_get()
2599
2600 takes args of SNMP::Session::new followed by those of
2601 SNMP::Session::get
2602
2603 =item &snmp_getnext()
2604
2605 takes args of SNMP::Session::new followed by those of
2606 SNMP::Session::getnext
2607
2608 =item &snmp_set()
2609
2610 takes args of SNMP::Session::new followed by those of
2611 SNMP::Session::set
2612
2613 =item &snmp_trap()
2614
2615 takes args of SNMP::TrapSession::new followed by those of
2616 SNMP::TrapSession::trap
2617
2618 =back
2619
2620 =head1 Trouble Shooting
2621
2622 If problems occur there are number areas to look at to narrow down the
2623 possibilities.
2624
2625 The first step should be to test the Net-SNMP installation
2626 independently from the Perl5 SNMP interface.
2627
2628 Try running the apps from the Net-SNMP distribution.
2629
2630 Make sure your agent (snmpd) is running and properly configured with
2631 read-write access for the community you are using.
2632
2633 Ensure that your MIBs are installed and enviroment variables are set
2634 appropriately (see man mib_api)
2635
2636 Be sure to remove old net-snmp installations and ensure headers and
2637 libraries from old CMU installations are not being used by mistake.
2638
2639 If the problem occurs during compilation/linking check that the snmp
2640 library being linked is actually the Net-SNMP library (there have been
2641 name conflicts with existing snmp libs).
2642
2643 Also check that the header files are correct and up to date.
2644
2645 Sometimes compiling the Net-SNMP library with
2646 'position-independent-code' enabled is required (HPUX specifically).
2647
2648 If you cannot resolve the problem you can post to
2649 comp.lang.perl.modules or
2650 net-snmp-users@[email protected]
2651
2652 please give sufficient information to analyze the problem (OS type,
2653 versions for OS/Perl/Net-SNMP/compiler, complete error output, etc.)
2654
2655 =head1 Acknowledgements
2656
2657 Many thanks to all those who supplied patches, suggestions and
2658 feedback.
2659
2660 Joe Marzot (the original author)
2661 Wes Hardaker and the net-snmp-coders
2662 Dave Perkins
2663 Marcel Wiget
2664 David Blackburn
2665 John Stofell
2666 Gary Hayward
2667 Claire Harrison
2668 Achim Bohnet
2669 Doug Kingston
2670 Jacques Vidrine
2671 Carl Jacobsen
2672 Wayne Marquette
2673 Scott Schumate
2674 Michael Slifcak
2675 Srivathsan Srinivasagopalan
2676 Bill Fenner
2677 Jef Peeraer
2678 Daniel Hagerty
2679 Karl "Rat" Schilke and Electric Lightwave, Inc.
2680 Perl5 Porters
2681 Alex Burger
2682
2683 Apologies to any/all who's patch/feature/request was not mentioned or
2684 included - most likely it was lost when paying work intruded on my
2685 fun. Please try again if you do not see a desired feature. This may
2686 actually turn out to be a decent package with such excellent help and
2687 the fact that I have more time to work on it than in the past.
2688
2689 =head1 AUTHOR
2690
2691 bugs, comments, questions to [email protected]
2692
2693 =head1 Copyright
2694
2695 Copyright (c) 1995-2000 G. S. Marzot. All rights reserved.
2696 This program is free software; you can redistribute it and/or
2697 modify it under the same terms as Perl itself.
2698
2699 Copyright (c) 2001-2002 Networks Associates Technology, Inc. All
2700 Rights Reserved. This program is free software; you can
2701 redistribute it and/or modify it under the same terms as Perl
2702 itself.
2703
2704 =cut