Beispiel #1
0
                 $input_errors[] = gettext("You specified an IPv6 prefix ID that is out of range.") . " ({$_POST['track6-interface']}) - (0) - (" . sprintf('%x', $_POST['ipv6-num-prefix-ids-' . $_POST['track6-interface']]) . ")";
             } else {
                 foreach ($ifdescrs as $ifent => $ifdescr) {
                     if ($if == $ifent) {
                         continue;
                     }
                     if ($config['interfaces'][$ifent]['ipaddrv6'] == 'track6' && $config['interfaces'][$ifent]['track6-interface'] == $_POST['track6-interface'] && $config['interfaces'][$ifent]['track6-prefix-id'] == $track6_prefix_id) {
                         $input_errors[] = sprintf(gettext("This track6 prefix ID is already being used in %s."), $ifdescr);
                     }
                 }
             }
         }
         break;
 }
 /* normalize MAC addresses - lowercase and convert Windows-ized hyphenated MACs to colon delimited */
 $staticroutes = get_staticroutes(true);
 $_POST['spoofmac'] = strtolower(str_replace("-", ":", $_POST['spoofmac']));
 if ($_POST['ipaddr']) {
     if (!is_ipaddrv4($_POST['ipaddr'])) {
         $input_errors[] = gettext("A valid IPv4 address must be specified.");
     } else {
         $where_ipaddr_configured = where_is_ipaddr_configured($_POST['ipaddr'], $if, true, true, $_POST['subnet']);
         if (count($where_ipaddr_configured)) {
             $subnet_conflict_text = sprintf(gettext("IPv4 address %s is being used by or overlaps with:"), $_POST['ipaddr'] . "/" . $_POST['subnet']);
             foreach ($where_ipaddr_configured as $subnet_conflict) {
                 $subnet_conflict_text .= " " . convert_friendly_interface_to_friendly_descr($subnet_conflict['if']) . " (" . $subnet_conflict['ip_or_subnet'] . ")";
             }
             $input_errors[] = $subnet_conflict_text;
         }
         /* Do not accept network or broadcast address, except if subnet is 31 or 32 */
         if ($_POST['subnet'] < 31) {
 if ($_POST['network'] && !is_ipaddr($_POST['network']) && !is_alias($_POST['network'])) {
     $input_errors[] = gettext("A valid IPv4 or IPv6 destination network must be specified.");
 }
 if ($_POST['network_subnet'] && !is_numeric($_POST['network_subnet'])) {
     $input_errors[] = gettext("A valid destination network bit count must be specified.");
 }
 if ($_POST['gateway'] && is_ipaddr($_POST['network'])) {
     if (!isset($a_gateways[$_POST['gateway']])) {
         $input_errors[] = gettext("A valid gateway must be specified.");
     }
     if (!validate_address_family($_POST['network'], lookup_gateway_ip_by_name($_POST['gateway']))) {
         $input_errors[] = gettext("The gateway '{$a_gateways[$_POST['gateway']]['gateway']}' is a different Address Family as network '{$_POST['network']}'.");
     }
 }
 /* check for overlaps */
 $current_targets = get_staticroutes(true);
 $new_targets = array();
 if (is_ipaddrv6($_POST['network'])) {
     $osn = Net_IPv6::compress(gen_subnetv6($_POST['network'], $_POST['network_subnet'])) . "/" . $_POST['network_subnet'];
     $new_targets[] = $osn;
 }
 if (is_ipaddr($_POST['network'])) {
     if ($_POST['network_subnet'] > 32) {
         $input_errors[] = gettext("A IPv4 subnet can not be over 32 bits.");
     } else {
         $osn = gen_subnet($_POST['network'], $_POST['network_subnet']) . "/" . $_POST['network_subnet'];
         $new_targets[] = $osn;
     }
 } elseif (is_alias($_POST['network'])) {
     $osn = $_POST['network'];
     foreach (filter_expand_alias_array($_POST['network']) as $tgt) {