network-functions: Add check_subnet()

Signed-off-by: Michael Tremer <michael.tremer@ipfire.org>
This commit is contained in:
Michael Tremer
2015-08-25 21:55:40 +01:00
parent 7577ec1eb1
commit 883c5453d9
2 changed files with 16 additions and 0 deletions

View File

@@ -163,6 +163,21 @@ sub check_ip_address_and_netmask($$) {
return &check_netmask($netmask);
}
# Returns True for all valid subnets like a.b.c.d/e or a.b.c.d/a.b.c.d
sub check_subnet($) {
my $subnet = shift;
my ($address, $network) = split(/\//, $subnet, 2);
# Check if the IP address is fine.
my $result = &check_ip_address($address);
unless ($result) {
return $result;
}
return &check_prefix($network) || &check_netmask($network);
}
# For internal use only. Will take an IP address and
# return it in a normalised style. Like 8.8.8.010 -> 8.8.8.8.
sub _normalise_ip_address($) {

View File

@@ -5,3 +5,4 @@ srv/web/ipfire/cgi-bin/logs.cgi/log.dat
srv/web/ipfire/cgi-bin/mail.cgi
var/ipfire/langs
var/ipfire/menu/40-services.menu
var/ipfire/network-functions.pl