$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."); }
} } } } } } } } } } if (!$input_errors) { /* make sure the range lies within the current subnet */ $subnet_start = ip2ulong(long2ip32(ip2long($parent_ip) & gen_subnet_mask_long($parent_sn))); $subnet_end = ip2ulong(long2ip32(ip2long($parent_ip) | ~gen_subnet_mask_long($parent_sn))); $parent_ip2 = long2ip32(ip2long($parent_ip) & gen_subnet_mask_long($parent_sn)); if (!is_innet_v4("{$parent_ip}/{$parent_sn}", $_POST['range_from']) || !is_innet_v4("{$parent_ip}/{$parent_sn}", $_POST['range_to'])) { $input_errors[] = gettext("Ip range overlaps network range({$parent_ip2}/{$parent_sn})."); } if (ip2ulong($_POST['range_from']) > ip2ulong($_POST['range_to'])) { $input_errors[] = gettext("The range is invalid (first element higher than second element)."); } if (is_numeric($pool) || $act == "newpool") { $rfrom = $config['dhcpd'][$if]['range']['from']; $rto = $config['dhcpd'][$if]['range']['to']; if (is_inrange_v4($_POST['range_from'], $rfrom, $rto) || is_inrange_v4($_POST['range_to'], $rfrom, $rto)) { $input_errors[] = gettext("The specified range must not be within the DHCP range for this interface."); } } foreach ($a_pools as $id => $p) { if (is_numeric($pool) && $id == $pool) { continue;
} } /* 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']}&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 {