move pseudo and layer checks into is_*able functions
This commit is contained in:
		| @@ -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')) { | ||||
|   | ||||
| @@ -16,12 +16,6 @@ register_worker({ phase => 'check' }, sub { | ||||
|   return Status->error("arpnip skipped: $device not yet discovered") | ||||
|     unless $device->in_storage; | ||||
|  | ||||
|   return Status->info("macsuck skipped: $device is pseudo-device") | ||||
|     if $device->is_pseudo; | ||||
|  | ||||
|   return Status->info("arpnip skipped: $device has no layer 3 capability") | ||||
|     unless $device->has_layer(3); | ||||
|  | ||||
|   return Status->info("arpnip skipped: $device is not arpnipable") | ||||
|     unless is_arpnipable_now($device); | ||||
|  | ||||
|   | ||||
| @@ -16,12 +16,6 @@ register_worker({ phase => 'check' }, sub { | ||||
|   return Status->error("macsuck skipped: $device not yet discovered") | ||||
|     unless $device->in_storage; | ||||
|  | ||||
|   return Status->info("macsuck skipped: $device is pseudo-device") | ||||
|     if $device->is_pseudo; | ||||
|  | ||||
|   return Status->info("macsuck skipped: $device has no layer 2 capability") | ||||
|     unless $device->has_layer(2); | ||||
|  | ||||
|   return Status->info("macsuck skipped: $device is not macsuckable") | ||||
|     unless is_macsuckable_now($device); | ||||
|  | ||||
|   | ||||
		Reference in New Issue
	
	Block a user