OK to include device ports when doing arpnip
This commit is contained in:
@@ -11,6 +11,7 @@
|
|||||||
* Fix SSL-proxy behaviour by using only path+query in links (W. Gould)
|
* Fix SSL-proxy behaviour by using only path+query in links (W. Gould)
|
||||||
* Avoid macsuck generated SQL bug when cleaning NULL VLAN (W. Gould)
|
* Avoid macsuck generated SQL bug when cleaning NULL VLAN (W. Gould)
|
||||||
* During macsuck get VLAN from Q-BRIDGE if available (jeneric)
|
* During macsuck get VLAN from Q-BRIDGE if available (jeneric)
|
||||||
|
* OK to include device ports when doing arpnip (jeneric)
|
||||||
|
|
||||||
2.017000 - 2013-09-23
|
2.017000 - 2013-09-23
|
||||||
|
|
||||||
|
|||||||
@@ -3,7 +3,6 @@ package App::Netdisco::Core::Arpnip;
|
|||||||
use Dancer qw/:syntax :script/;
|
use Dancer qw/:syntax :script/;
|
||||||
use Dancer::Plugin::DBIC 'schema';
|
use Dancer::Plugin::DBIC 'schema';
|
||||||
|
|
||||||
use App::Netdisco::Util::PortMAC 'get_port_macs';
|
|
||||||
use App::Netdisco::Util::SanityCheck 'check_mac';
|
use App::Netdisco::Util::SanityCheck 'check_mac';
|
||||||
use App::Netdisco::Util::DNS ':all';
|
use App::Netdisco::Util::DNS ':all';
|
||||||
use NetAddr::IP::Lite ':lower';
|
use NetAddr::IP::Lite ':lower';
|
||||||
@@ -44,12 +43,10 @@ sub do_arpnip {
|
|||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
|
||||||
my $port_macs = get_port_macs($device);
|
|
||||||
|
|
||||||
# get v4 arp table
|
# get v4 arp table
|
||||||
my @v4 = _get_arps($device, $port_macs, $snmp->at_paddr, $snmp->at_netaddr);
|
my @v4 = _get_arps($device, $snmp->at_paddr, $snmp->at_netaddr);
|
||||||
# get v6 neighbor cache
|
# get v6 neighbor cache
|
||||||
my @v6 = _get_arps($device, $port_macs, $snmp->ipv6_n2p_mac, $snmp->ipv6_n2p_addr);
|
my @v6 = _get_arps($device, $snmp->ipv6_n2p_mac, $snmp->ipv6_n2p_addr);
|
||||||
|
|
||||||
# get directly connected networks
|
# get directly connected networks
|
||||||
my @subnets = _gather_subnets($device, $snmp);
|
my @subnets = _gather_subnets($device, $snmp);
|
||||||
@@ -78,13 +75,13 @@ sub do_arpnip {
|
|||||||
|
|
||||||
# get an arp table (v4 or v6)
|
# get an arp table (v4 or v6)
|
||||||
sub _get_arps {
|
sub _get_arps {
|
||||||
my ($device, $port_macs, $paddr, $netaddr) = @_;
|
my ($device, $paddr, $netaddr) = @_;
|
||||||
my @arps = ();
|
my @arps = ();
|
||||||
|
|
||||||
while (my ($arp, $node) = each %$paddr) {
|
while (my ($arp, $node) = each %$paddr) {
|
||||||
my $ip = $netaddr->{$arp};
|
my $ip = $netaddr->{$arp};
|
||||||
next unless defined $ip;
|
next unless defined $ip;
|
||||||
next unless check_mac($device, $node, $port_macs);
|
next unless check_mac($device, $node);
|
||||||
push @arps, [$node, $ip, hostname_from_ip($ip)];
|
push @arps, [$node, $ip, hostname_from_ip($ip)];
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|||||||
@@ -44,22 +44,25 @@ MAC address is well-formed (according to common formats)
|
|||||||
|
|
||||||
MAC address is not all-zero, broadcast, CLIP, VRRP or HSRP
|
MAC address is not all-zero, broadcast, CLIP, VRRP or HSRP
|
||||||
|
|
||||||
|
=back
|
||||||
|
|
||||||
|
Optionally pass a cached set of Device port MAC addresses as the third
|
||||||
|
argument, in which case an additional check is added:
|
||||||
|
|
||||||
|
=over 4
|
||||||
|
|
||||||
=item *
|
=item *
|
||||||
|
|
||||||
MAC address does not belong to an interface on any known Device
|
MAC address does not belong to an interface on any known Device
|
||||||
|
|
||||||
=back
|
=back
|
||||||
|
|
||||||
Optionally pass a cached set of Device port MAC addresses as the third
|
|
||||||
argument, or else C<check_mac> will retrieve this for itself from the
|
|
||||||
database.
|
|
||||||
|
|
||||||
=cut
|
=cut
|
||||||
|
|
||||||
sub check_mac {
|
sub check_mac {
|
||||||
my ($device, $node, $port_macs) = @_;
|
my ($device, $node, $port_macs) = @_;
|
||||||
$port_macs ||= get_port_macs($device);
|
|
||||||
my $mac = Net::MAC->new(mac => $node, 'die' => 0, verbose => 0);
|
my $mac = Net::MAC->new(mac => $node, 'die' => 0, verbose => 0);
|
||||||
|
$port_macs ||= {};
|
||||||
|
|
||||||
# incomplete MAC addresses (BayRS frame relay DLCI, etc)
|
# incomplete MAC addresses (BayRS frame relay DLCI, etc)
|
||||||
if ($mac->get_error) {
|
if ($mac->get_error) {
|
||||||
|
|||||||
Reference in New Issue
Block a user