~ubuntu-branches/ubuntu/trusty/net-snmp/trusty

« back to all changes in this revision

Viewing changes to perl/agent/Support/Support.pm

  • Committer: Bazaar Package Importer
  • Author(s): Jochen Friedrich
  • Date: 2009-11-12 16:17:40 UTC
  • mto: (1.4.1 experimental)
  • mto: This revision was merged to the branch mainline in revision 32.
  • Revision ID: james.westby@ubuntu.com-20091112161740-t2xvix834vmtxa9f
Tags: upstream-5.4.2.1~dfsg
ImportĀ upstreamĀ versionĀ 5.4.2.1~dfsg

Show diffs side-by-side

added added

removed removed

Lines of Context:
17
17
use NetSNMP::OID (':all');
18
18
use NetSNMP::agent (':all');
19
19
use NetSNMP::ASN (':all');
 
20
use NetSNMP::default_store (':all');
20
21
use Data::Dumper;
21
 
use XML::Simple;
22
 
use IO::File;
23
22
 
24
23
 
25
24
use vars qw(@ISA @EXPORT @EXPORT_OK $VERSION);
27
26
@ISA       = qw(Exporter getLeaf);
28
27
@EXPORT    = qw(registerAgent getOidElement setOidElement);
29
28
@EXPORT_OK = qw();
30
 
$VERSION = '5.0401';
 
29
$VERSION = '5.04021';
31
30
 
32
31
use strict;
33
32
 
59
58
# Some parts borrowed from the perl cookbook
60
59
################################################################
61
60
sub buildTree {
62
 
    foreach my $key (keys %$oidtable) {
 
61
    my ($new_oidtable) = @_;
 
62
    foreach my $key (keys %$new_oidtable) {
63
63
        insert($oidtree, $key);
64
64
    }
65
65
}
124
124
sub registerAgent {
125
125
    my $agent = shift;
126
126
    my $regat = shift;
127
 
    $oidtable = shift;
 
127
    my $new_oidtable = shift;
 
128
 
 
129
    foreach (keys %$new_oidtable) { $oidtable->{$_} = $new_oidtable->{$_}; }
 
130
 
 
131
    # This is necessary to avoid problems traversing trees where the
 
132
    # IID index is range-limited to not include .0, which is used as a 
 
133
    # placeholder in the oidtable.
 
134
     netsnmp_ds_set_boolean(NETSNMP_DS_LIBRARY_ID, 
 
135
                            NETSNMP_DS_LIB_DONT_CHECK_RANGE, 1);
128
136
 
129
137
    print STDERR "Building OID tree\n";
130
 
    buildTree();
131
 
 
 
138
    buildTree($new_oidtable);    
132
139
    doLinks($oidtree);
133
 
 
 
140
 
134
141
#    print Dumper($oidtable);
135
142
 
136
143
    # Debug. Print the list of oids in their next ordering
407
414
            my $nextoid = $current->{next};
408
415
            print "Trying $nextoid\n"   if ($debugging);
409
416
            $current = $oidtable->{$nextoid};
410
 
            $curoid = new NetSNMP::OID($nextoid);
 
417
            $curoid = $current ? new NetSNMP::OID($nextoid) : undef;
411
418
        }
412
419
    }
413
420
 
435
442
            # No not this one so try the next
436
443
            $nextoid = $current->{next};
437
444
            $current = $oidtable->{$nextoid};
438
 
            $curoid = new NetSNMP::OID($nextoid);
 
445
            $curoid = $current ? new NetSNMP::OID($nextoid) : undef;
439
446
            print "Trying next $curoid $nextoid\n"   if ($debugging);
440
447
        } else {
441
448