From 5ac685ad8c457a062302db020583478bd1b2f907 Mon Sep 17 00:00:00 2001 From: Thierry Vignaud Date: Thu, 18 Oct 2012 20:50:51 +0000 Subject: (check_ip) split it out of check() --- dhcp_wizard/Dhcp.pm | 7 ++++--- 1 file changed, 4 insertions(+), 3 deletions(-) (limited to 'dhcp_wizard') diff --git a/dhcp_wizard/Dhcp.pm b/dhcp_wizard/Dhcp.pm index 389f0750..dc983512 100755 --- a/dhcp_wizard/Dhcp.pm +++ b/dhcp_wizard/Dhcp.pm @@ -151,12 +151,13 @@ sub compute_range2 { "$s.$n"; } +sub check_ip { return $_[0] < 0 || $_[0] > 255 ? 0 : 1 } + sub check { - my $check_ip = sub { return $_[0] < 0 || $_[0] > 255 ? 0 : 1 }; my $r1_trunc = "$1.$2.$3" if $o->{var}{ip1} =~ /(\d{1,3})\.(\d{1,3})\.(\d{1,3})\.(\d{1,3})/; - foreach ($1, $2, $3, $4) { $check_ip->($_) or return 'ip_range_error' } + foreach ($1, $2, $3, $4) { check_ip($_) or return 'ip_range_error' } my $r2_trunc = "$1.$2.$3" if $o->{var}{ip2} =~ /(\d{1,3})\.(\d{1,3})\.(\d{1,3})\.(\d{1,3})/; - foreach ($1, $2, $3, $4) { $check_ip->($_) or return 'ip_range_error' } + foreach ($1, $2, $3, $4) { check_ip($_) or return 'ip_range_error' } my $d1 = $4 if $o->{var}{ip1} =~ /(\d{1,3})\.(\d{1,3})\.(\d{1,3})\.(\d{1,3})/; my $d2 = $4 if $o->{var}{ip2} =~ /(\d{1,3})\.(\d{1,3})\.(\d{1,3})\.(\d{1,3})/; my $s_trunc = "$1.$2.$3" if $wiz_ip_server =~ /(\d{1,3})\.(\d{1,3})\.(\d{1,3})\.(\d{1,3})/; -- cgit v1.2.1