Beispiel #1
0
 $range_match = 0;
 if ($_POST['ipaddr']) {
     $dynsubnet_start = ip2ulong($config['dhcpd'][$if]['range']['from']);
     $dynsubnet_end = ip2ulong($config['dhcpd'][$if]['range']['to']);
     if (ip2ulong($_POST['ipaddr']) >= $dynsubnet_start && ip2ulong($_POST['ipaddr']) <= $dynsubnet_end) {
         $range_match++;
     }
     //check pool ranges
     foreach ($a_pools as $pidx => $p) {
         if (is_inrange_v4($_POST['ipaddr'], $p['range']['from'], $p['range']['to'])) {
             $range_match++;
         }
     }
     //check pool subnets
     foreach ($a_pools as $pidx => $p) {
         if (is_innet_v4($p['custom_subnet'] . "/" . mask2cidr_v4($p['custom_subnet_mask']), $_POST['ipaddr'])) {
             $range_match++;
         }
     }
     $lansubnet_start = ip2ulong(long2ip32(ip2long($ifcfgip) & gen_subnet_mask_long($ifcfgsn)));
     $lansubnet_end = ip2ulong(long2ip32(ip2long($ifcfgip) | ~gen_subnet_mask_long($ifcfgsn)));
     if (ip2ulong($_POST['ipaddr']) > $lansubnet_start && ip2ulong($_POST['ipaddr']) < $lansubnet_end) {
         $range_match++;
     }
 }
 if ($range_match == 0) {
     $input_errors[] = sprintf(gettext("The IP address does not match any configured range or pool."), $ifcfgdescr);
 }
 if ($_POST['gateway'] && !is_ipaddrv4($_POST['gateway'])) {
     $input_errors[] = gettext("A valid IP address must be specified for the gateway.");
 }
Beispiel #2
0
 }
 if ($_POST['custom_subnet_mask'] && is_validmask_v4($_POST['custom_subnet_mask']) != 1) {
     $input_errors[] = gettext("A valid custom subnet maks must be specified.");
 }
 if ($_POST['range_to'] && !is_ipaddrv4($_POST['range_to'])) {
     $input_errors[] = gettext("A valid range must be specified.");
 }
 if ($_POST['gateway'] && $_POST['gateway'] != "none" && !is_ipaddrv4($_POST['gateway'])) {
     $input_errors[] = gettext("A valid IP address must be specified for the gateway.");
 }
 if ($_POST['wins1'] && !is_ipaddrv4($_POST['wins1']) || $_POST['wins2'] && !is_ipaddrv4($_POST['wins2'])) {
     $input_errors[] = gettext("A valid IP address must be specified for the primary/secondary WINS servers.");
 }
 $parent_ip = is_ipaddrv4($_POST['custom_subnet']) ? $_POST['custom_subnet'] : get_interface_ip($_POST['if']);
 if (is_ipaddrv4($parent_ip) && $_POST['gateway'] && $_POST['gateway'] != "none") {
     $parent_sn = is_validmask_v4($_POST['custom_subnet_mask']) ? mask2cidr_v4($_POST['custom_subnet_mask']) : get_interface_subnet($_POST['if']);
     if (!ip_in_subnet($_POST['gateway'], gen_subnet($parent_ip, $parent_sn) . "/" . $parent_sn) && !ip_in_interface_alias_subnet($_POST['if'], $_POST['gateway'])) {
         $input_errors[] = sprintf(gettext("The gateway address %s does not lie within the chosen interface's subnet."), $_POST['gateway']);
     }
 }
 for ($dns = 1; $dns <= 4; $dns++) {
     if ($_POST["dns{$dns}"] && !is_ipaddrv4($_POST["dns{$dns}"])) {
         $input_errors[] = gettext("A valid IP address must be specified for each of the DNS servers.");
     }
 }
 if ($_POST['deftime'] && (!is_numeric($_POST['deftime']) || $_POST['deftime'] < 60)) {
     $input_errors[] = gettext("The default lease time must be at least 60 seconds.");
 }
 if (isset($config['captiveportal']) && is_array($config['captiveportal'])) {
     $deftime = 7200;
     // Default value if it's empty
Beispiel #3
0
             }
         }
         /* exit as soon as we have an interface */
         if ($data['if'] != "") {
             break;
         }
     }
 } else {
     foreach ($config['dhcpd'] as $dhcpif => $dhcpifconf) {
         if (is_array($dhcpifconf['range']) && $lip >= ip2ulong($dhcpifconf['range']['from']) && $lip <= ip2ulong($dhcpifconf['range']['to'])) {
             $data['if'] = $dhcpif;
             break;
         }
         if (is_array($dhcpifconf['pool'])) {
             foreach ($dhcpifconf['pool'] as $iface_pool) {
                 if (is_ipaddrv4($iface_pool['custom_subnet']) && is_validmask_v4($iface_pool['custom_subnet_mask']) && is_innet_v4($iface_pool['custom_subnet'] . "/" . mask2cidr_v4($iface_pool['custom_subnet_mask']), $data['ip'])) {
                     $data['if'] = $dhcpif;
                 }
             }
         }
     }
 }
 echo "<tr>\n";
 echo "<td class=\"listlr\">{$fspans}{$data['ip']}{$fspane}</td>\n";
 $mac = $data['mac'];
 $mac_hi = strtoupper($mac[0] . $mac[1] . $mac[3] . $mac[4] . $mac[6] . $mac[7]);
 if ($data['online'] != "online") {
     if (isset($mac_man[$mac_hi])) {
         // Manufacturer for this MAC is defined
         echo "<td class=\"listr\">{$fspans}<a href=\"services_wol.php?if={$data['if']}&amp;mac={$mac}\" title=\"" . gettext("{$mac} - send Wake on LAN packet to this MAC address") . "\">{$mac}</a><br /><font size=\"-2\"><i>{$mac_man[$mac_hi]}</i></font>{$fspane}</td>\n";
     } else {