} if ($found === false) { $input_errors[] = sprintf(gettext("The gateway address %1\$s does not lie within one of the chosen interface's subnets."), $_POST['gateway']); } } } else { if (is_ipaddrv6($_POST['gateway'])) { /* do not do a subnet match on a link local address, it's valid */ if (!is_linklocal($_POST['gateway'])) { $parent_ip = get_interface_ipv6($_POST['interface']); $parent_sn = get_interface_subnetv6($_POST['interface']); if (empty($parent_ip) || empty($parent_sn)) { $input_errors[] = gettext("Cannot add IPv6 Gateway Address because no IPv6 address could be found on the interface."); } elseif (!isset($_POST["nonlocalgateway"])) { $subnets = array(gen_subnetv6($parent_ip, $parent_sn) . "/" . $parent_sn); $vips = link_interface_to_vips($_POST['interface']); if (is_array($vips)) { foreach ($vips as $vip) { if (!is_ipaddrv6($vip['subnet'])) { continue; } $subnets[] = gen_subnetv6($vip['subnet'], $vip['subnet_bits']) . "/" . $vip['subnet_bits']; } } $found = false; foreach ($subnets as $subnet) { if (ip_in_subnet($_POST['gateway'], $subnet)) { $found = true; break; } }
} } if (!$found) { $input_errors[] = sprintf(gettext("The gateway address %1\$s does not lie within one of the chosen interface's subnets."), $pconfig['gateway']); } } } elseif (is_ipaddrv6($pconfig['gateway'])) { /* do not do a subnet match on a link local address, it's valid */ if (!is_linklocal($pconfig['gateway'])) { $parent_ip = get_interface_ipv6($pconfig['interface']); $parent_sn = get_interface_subnetv6($pconfig['interface']); if (empty($parent_ip) || empty($parent_sn)) { $input_errors[] = gettext("Cannot add IPv6 Gateway Address because no IPv6 address could be found on the interface."); } else { $subnets = array(gen_subnetv6($parent_ip, $parent_sn) . "/" . $parent_sn); $vips = link_interface_to_vips($pconfig['interface']); if (is_array($vips)) { foreach ($vips as $vip) { if (!is_ipaddrv6($vip['subnet'])) { continue; } $subnets[] = gen_subnetv6($vip['subnet'], $vip['subnet_bits']) . "/" . $vip['subnet_bits']; } } $found = false; foreach ($subnets as $subnet) { if (ip_in_subnet($pconfig['gateway'], $subnet)) { $found = true; break; } }