make discover_{phones,waps} work with LLDP capabilities as well
This commit is contained in:
@@ -146,7 +146,7 @@ sub match_to_setting {
|
||||
|
||||
sub _bail_msg { debug $_[0]; return 0; }
|
||||
|
||||
=head2 is_discoverable( $ip, $device_type? )
|
||||
=head2 is_discoverable( $ip, [$device_type, \@device_capabilities]? )
|
||||
|
||||
Given an IP address, returns C<true> if Netdisco on this host is permitted by
|
||||
the local configuration to discover the device.
|
||||
@@ -163,14 +163,20 @@ Returns false if the host is not permitted to discover the target device.
|
||||
=cut
|
||||
|
||||
sub is_discoverable {
|
||||
my ($ip, $remote_type) = @_;
|
||||
my ($ip, $remote_type, $remote_cap) = @_;
|
||||
my $device = get_device($ip) or return 0;
|
||||
$remote_type ||= '';
|
||||
$remote_cap ||= [];
|
||||
|
||||
return _bail_msg("is_discoverable: $device matches wap_platforms but discover_waps is not enabled")
|
||||
if (match_to_setting($remote_type, 'wap_platforms') and not setting('discover_waps'));
|
||||
if ((not setting('discover_waps')) and
|
||||
(match_to_setting($remote_type, 'wap_platforms') or
|
||||
scalar grep {match_to_setting($_, 'wap_capabilities')} @$remote_cap));
|
||||
|
||||
return _bail_msg("is_discoverable: $device matches phone_platforms but discover_phones is not enabled")
|
||||
if (match_to_setting($remote_type, 'phone_platforms') and not setting('discover_phones'));
|
||||
if ((not setting('discover_phones')) and
|
||||
(match_to_setting($remote_type, 'phone_platforms') or
|
||||
scalar grep {match_to_setting($_, 'phone_capabilities')} @$remote_cap));
|
||||
|
||||
return _bail_msg("is_discoverable: $device matched discover_no_type")
|
||||
if (match_to_setting($remote_type, 'discover_no_type'));
|
||||
|
||||
@@ -169,6 +169,7 @@ sub store_neighbors {
|
||||
my $remote_port = undef;
|
||||
my $remote_type = Encode::decode('UTF-8', $c_platform->{$entry} || '');
|
||||
my $remote_id = Encode::decode('UTF-8', $c_id->{$entry});
|
||||
my $remote_cap = $c_cap->{$entry} || [];
|
||||
|
||||
next unless $remote_ip;
|
||||
my $r_netaddr = NetAddr::IP::Lite->new($remote_ip);
|
||||
@@ -240,7 +241,7 @@ sub store_neighbors {
|
||||
debug sprintf ' [%s] neigh - %s with ID [%s] on %s',
|
||||
$device->ip, $remote_ip, ($remote_id || ''), $port;
|
||||
|
||||
if (is_discoverable($remote_ip, $remote_type)) {
|
||||
if (is_discoverable($remote_ip, $remote_type, $remote_cap)) {
|
||||
push @to_discover, [$remote_ip, $remote_id];
|
||||
}
|
||||
else {
|
||||
|
||||
Reference in New Issue
Block a user