no need to pass $snmp around

This commit is contained in:
Oliver Gorwits
2017-09-13 20:29:21 +01:00
parent 58cd488ccc
commit 09214dce92
3 changed files with 28 additions and 13 deletions

View File

@@ -18,7 +18,7 @@ register_worker({ stage => 'second', driver => 'snmp' }, sub {
or return Status->defer("arpnip failed: could not SNMP connect to $device");
# get directly connected networks
my @subnets = gather_subnets($device, $snmp);
my @subnets = gather_subnets($device);
# TODO: IPv6 subnets
my $now = 'to_timestamp('. (join '.', gettimeofday) .')';
@@ -32,9 +32,12 @@ register_worker({ stage => 'second', driver => 'snmp' }, sub {
# gathers device subnets
sub gather_subnets {
my ($device, $snmp) = @_;
my $device = shift;
my @subnets = ();
my $snmp = App::Netdisco::Transport::SNMP->reader_for($device)
or die "arpnip failed: could not SNMP connect to $device";
my $ip_netmask = $snmp->ip_netmask;
foreach my $entry (keys %$ip_netmask) {
my $ip = NetAddr::IP::Lite->new($entry);