move pseudo and layer checks into is_*able functions

This commit is contained in:
Oliver Gorwits
2019-08-25 23:55:38 +01:00
parent 8b010d4023
commit 61f9c89040
3 changed files with 20 additions and 18 deletions

View File

@@ -241,9 +241,10 @@ sub is_arpnipable {
=head2 is_arpnipable_now( $ip )
Same as C<is_arpnipable>, but also checks the last_arpnip field if the
device is in storage, and returns false if that host has been too recently
arpnipped.
Same as C<is_arpnipable>, but also compares the C<last_arpnip> field
of the C<device> to the C<arpnip_min_age> configuration. Also checks
for pseudo devices and for devices not supporting layer 3, with some
exceptions.
Returns false if the host is not permitted to arpnip the target device.
@@ -253,6 +254,12 @@ sub is_arpnipable_now {
my ($ip) = @_;
my $device = get_device($ip) or return 0;
return _bail_msg("is_arpnipable: $device is pseudo-device")
if $device->is_pseudo;
return _bail_msg("is_arpnipable: $device has no layer 3 capability")
unless $device->has_layer(3);
if ($device->in_storage
and $device->since_last_arpnip and setting('arpnip_min_age')
and $device->since_last_arpnip < setting('arpnip_min_age')) {
@@ -290,9 +297,10 @@ sub is_macsuckable {
=head2 is_macsuckable_now( $ip )
Same as C<is_macsuckable>, but also checks the last_macsuck field if the
device is in storage, and returns false if that host has been too recently
macsucked.
Same as C<is_macsuckable>, but also compares the C<last_macsuck> field
of the C<device> to the C<macsuck_min_age> configuration. Also checks
for pseudo devices and for devices not supporting layer 2, with some
exceptions.
Returns false if the host is not permitted to macsuck the target device.
@@ -302,6 +310,12 @@ sub is_macsuckable_now {
my ($ip) = @_;
my $device = get_device($ip) or return 0;
return _bail_msg("is_macsuckable: $device is pseudo-device")
if $device->is_pseudo;
return _bail_msg("is_macsuckable: $device has no layer 2 capability")
unless $device->has_layer(2);
if ($device->in_storage
and $device->since_last_macsuck and setting('macsuck_min_age')
and $device->since_last_macsuck < setting('macsuck_min_age')) {