diff --git a/etc/inc/util.inc b/etc/inc/util.inc index 7b8ebe8095..3ef01fcee0 100644 --- a/etc/inc/util.inc +++ b/etc/inc/util.inc @@ -27,8 +27,6 @@ POSSIBILITY OF SUCH DAMAGE. */ -require_once 'IPv6.inc'; - /* kill a process by pid file */ function killbypid($pidfile) { sigkillbypid($pidfile, "TERM"); @@ -122,8 +120,9 @@ function is_ipaddr($ipaddr) { return false; } -/* returns true if $ipaddr is a valid IPv4/IPv6 address or an alias thereof */ +/* returns true if $ipaddr is a valid dotted IPv4 address or an alias thereof */ function is_ipaddroralias($ipaddr) { + global $aliastable, $config; if(is_array($config['aliases']['alias'])) { @@ -133,22 +132,22 @@ function is_ipaddroralias($ipaddr) { } } - if (isset($aliastable[$ipaddr]) && (is_ipaddr($aliastable[$ipaddr]) || Net_IPv6::checkIPv6($aliastable[$ipaddr]))) { + if (isset($aliastable[$ipaddr]) && is_ipaddr($aliastable[$ipaddr])) return true; - } else { - return (is_ipaddr($ipaddr) || Net_IPv6::checkIPv6($ipaddr)); - } + else + return is_ipaddr($ipaddr); + } /* returns true if $ipaddr is a valid dotted IPv4 address or any alias */ function is_ipaddroranyalias($ipaddr) { + global $aliastable; - if (isset($aliastable[$ipaddr])) { + if (isset($aliastable[$ipaddr])) return true; - } else { - return (is_ipaddr($ipaddr) || Net_IPv6::checkIPv6($ipaddr)); - } + else + return is_ipaddr($ipaddr); } /* returns true if $subnet is a valid subnet in CIDR format */ @@ -167,26 +166,6 @@ function is_subnet($subnet) { return true; } -/* returns true if $subnet is a valid IPv6 network address */ -function is_subnet_ipv6($subnet, $max = 64) { - if (!is_string($subnet)) { - return false; - } - - list ($hp, $np) = explode('/', $subnet); - - if (!Net_IPv6::checkIPv6($hp)) { - return false; - } - - if (!is_numeric($np) || ($np < 1) || ($np > $max)) { - return false; - } - - return true; -} - - /* returns true if $subnet is a valid subnet in CIDR format or an alias thereof */ function is_subnetoralias($subnet) { @@ -524,15 +503,15 @@ function alias_expand_value($name) { /* expand a host or network alias, if necessary */ function alias_expand($name) { + global $aliastable; - if (isset($aliastable[$name])) { + if (isset($aliastable[$name])) return "\${$name}"; - } else if (is_ipaddr($name) || is_subnet($name) || Net_IPv6::checkIPv6($name) || is_subnet_ipv6($name)) { + else if (is_ipaddr($name) || is_subnet($name)) return "{$name}"; - } else { + else return null; - } } /* expand a host alias, if necessary */ @@ -542,16 +521,14 @@ function alias_expand_host($name) { if (isset($aliastable[$name])) { $ip_arr = explode(" ", $aliastable[$name]); foreach($ip_arr as $ip) { - if (!is_ipaddr($ip) || Net_IPv6::checkIPv6($ip)) { + if (!is_ipaddr($ip)) return null; - } } return $aliastable[$name]; - } else if (is_ipaddr($name) || Net_IPv6::checkIPv6($name)) { + } else if (is_ipaddr($name)) return $name; - } else { + else return null; - } } /* expand a network alias, if necessary */ @@ -635,8 +612,8 @@ function arp_get_mac_by_ip($ip) { /* return a fieldname that is safe for xml usage */ function xml_safe_fieldname($fieldname) { - $replace = array('/', ' ', '!', '@', '#', '$', '%', '^', '&', '*', '(', ')', - '+', '=', '{', '}', '[', ']', '|', '/', '<', '>', '?', + $replace = array('/', '-', ' ', '!', '@', '#', '$', '%', '^', '&', '*', '(', ')', + '_', '+', '=', '{', '}', '[', ']', '|', '/', '<', '>', '?', ':', ',', '.', '\'', '\\' ); return strtolower(str_replace($replace, "", $fieldname)); @@ -670,9 +647,8 @@ function mac_format($clientmac) { function resolve_retry($hostname, $retries = 5) { - if (is_ipaddr($hostname) || Net_IPv6::checkIPv6($hostname)) { + if (is_ipaddr($hostname)) return $hostname; - } for ($i = 0; $i < $retries; $i++) { $ip = gethostbyname($hostname); diff --git a/usr/local/www/firewall_rules_edit.php b/usr/local/www/firewall_rules_edit.php index cae0389d7c..ecbb87eccc 100755 --- a/usr/local/www/firewall_rules_edit.php +++ b/usr/local/www/firewall_rules_edit.php @@ -40,7 +40,6 @@ require("guiconfig.inc"); -require_once("IPv6.inc"); $specialsrcdst = explode(" ", "any wanip lanip lan pptp pppoe"); @@ -92,9 +91,6 @@ if (isset($id) && $a_filter[$id]) { if ($a_filter[$id]['protocol'] == "icmp") $pconfig['icmptype'] = $a_filter[$id]['icmptype']; - if ($a_filter[$id]['protocol'] == "icmp6") - $pconfig['icmp6type'] = $a_filter[$id]['icmp6type']; - address_to_pconfig($a_filter[$id]['source'], $pconfig['src'], $pconfig['srcmask'], $pconfig['srcnot'], $pconfig['srcbeginport'], $pconfig['srcendport']); @@ -162,9 +158,9 @@ if (isset($_GET['dup'])) unset($id); if ($_POST) { - if ($_POST['type'] == "reject" && !($_POST['proto'] == "tcp" || $_POST['proto'] == "tcp6")) { - $input_errors[] = "Reject type rules only works when the protocol is set to TCP or TCP6."; - } + + if ($_POST['type'] == "reject" && $_POST['proto'] <> "tcp") + $input_errors[] = "Reject type rules only works when the protocol is set to TCP."; if (($_POST['proto'] != "tcp") && ($_POST['proto'] != "udp") && ($_POST['proto'] != "tcp/udp")) { $_POST['srcbeginport'] = 0; @@ -288,7 +284,7 @@ if ($_POST) { if (!is_specialnet($_POST['srctype'])) { if (($_POST['src'] && !is_ipaddroranyalias($_POST['src']))) { - $input_errors[] = "A valid source IPv4/IPv6 address or alias must be specified."; + $input_errors[] = "A valid source IP address or alias must be specified."; } if (($_POST['srcmask'] && !is_numericint($_POST['srcmask']))) { $input_errors[] = "A valid source bit count must be specified."; @@ -296,7 +292,7 @@ if ($_POST) { } if (!is_specialnet($_POST['dsttype'])) { if (($_POST['dst'] && !is_ipaddroranyalias($_POST['dst']))) { - $input_errors[] = "A valid destination IPv4/IPv6 address or alias must be specified."; + $input_errors[] = "A valid destination IP address or alias must be specified."; } if (($_POST['dstmask'] && !is_numericint($_POST['dstmask']))) { $input_errors[] = "A valid destination bit count must be specified."; @@ -396,11 +392,6 @@ if ($_POST) { else unset($filterent['icmptype']); - if ($_POST['proto'] == "icmp6" && $_POST['icmp6type']) - $filterent['icmp6type'] = $_POST['icmp6type']; - else - unset($filterent['icmp6type']); - pconfig_to_address($filterent['source'], $_POST['src'], $_POST['srcmask'], $_POST['srcnot'], $_POST['srcbeginport'], $_POST['srcendport']); @@ -475,8 +466,6 @@ include("head.inc"); ?> - - @@ -590,7 +579,7 @@ include("head.inc"); - "Destination unreachable", - "toobig" => "Packet too big", - "timex" => "Time exceeded", - "parampro" => "Invalid IPv6 header", - "echoreq" => "Echo service request", - "echorep" => "Echo service reply", - "groupqry" => "Group membership query", - "listqry" => "Multicast listener query", - "grouprep" => "Group membership report", - "listenrep" => "Multicast listener report", - "groupterm" => "Group membership termination", - "listendone" => "Multicast listerner done", - "routersol" => "Router solicitation", - "routeradv" => "Router advertisement", - "neighbrsol" => "Neighbor solicitation", - "neighbradv" => "Neighbor advertisement", - "redir" => "Shorter route exists", - "routrrenum" => "Route renumbering", - "fqdnreq" => "FQDN query", - "niqry" => "Node information query", - "wrureq" => "Who-are-you request", - "fqdnrep" => "FQDN reply", - "nirep" => "Node information reply", - "wrurep" => "Who-are-you reply", - "mtraceresp" => "mtrace response", - "mtrace" => "mtrace messages" - ); -?> - - $descr): ?> - - - - -
- If you selected ICMP6 for the protocol above, you may specify an ICMP6 type here. - - Source @@ -690,31 +635,11 @@ include("head.inc"); Type:   - + - - - + + diff --git a/usr/local/www/interfaces.php b/usr/local/www/interfaces.php index c30223212d..c14e6be3c0 100755 --- a/usr/local/www/interfaces.php +++ b/usr/local/www/interfaces.php @@ -40,8 +40,7 @@ ##|*MATCH=interfaces.php* ##|-PRIV -require_once("guiconfig.inc"); -require_once("IPv6.inc"); +require("guiconfig.inc"); if ($_REQUEST['if']) $if = $_REQUEST['if']; @@ -155,14 +154,10 @@ if ($if == "wan" || $if == "lan") else $pconfig['enable'] = isset($wancfg['enable']); -if (is_array($config['aliases']['alias'])) { - foreach($config['aliases']['alias'] as $alias) { - if($alias['name'] == $wancfg['descr']) { - $input_errors[] = gettext("Sorry, an alias with the name {$wancfg['descr']} already exists."); - } - } -} - +if (is_array($config['aliases']['alias'])) +foreach($config['aliases']['alias'] as $alias) + if($alias['name'] == $wancfg['descr']) + $input_errors[] = gettext("Sorry, an alias with the name {$wancfg['descr']} already exists."); if ($wancfg['ipaddr'] == "dhcp") { $pconfig['type'] = "dhcp"; } else if ($wancfg['ipaddr'] == "carpdev-dhcp") { @@ -172,25 +167,14 @@ if ($wancfg['ipaddr'] == "dhcp") { $pconfig['type'] = "pppoe"; } else if ($wancfg['ipaddr'] == "pptp") { $pconfig['type'] = "pptp"; -} else if ($wancfg['ipaddr'] == "" && $wancfg['ipaddr_ipv6'] == "") { +} else if ($wancfg['ipaddr'] != "") { + $pconfig['type'] = "static"; + $pconfig['ipaddr'] = $wancfg['ipaddr']; + $pconfig['subnet'] = $wancfg['subnet']; + $pconfig['gateway'] = $wancfg['gateway']; + $pconfig['pointtopoint'] = $wancfg['pointtopoint']; +} else $pconfig['type'] = "none"; -} else { - if ($wancfg['ipaddr'] != "") { - $pconfig['type'] = "static"; - $pconfig['ipaddr'] = $wancfg['ipaddr']; - $pconfig['subnet'] = $wancfg['subnet']; - $pconfig['gateway'] = $wancfg['gateway']; - $pconfig['pointtopoint'] = $wancfg['pointtopoint']; - } - - if ($wancfg['ipaddr_ipv6'] != "") { - $pconfig['type'] = "static"; - $pconfig['ipaddr_ipv6'] = $wancfg['ipaddr_ipv6']; - $pconfig['subnet_ipv6'] = $wancfg['subnet_ipv6']; - $pconfig['gateway_ipv6'] = $wancfg['gateway_ipv6']; - $pconfig['pointtopoint_ipv6'] = $wancfg['pointtopoint_ipv6']; - } -} $pconfig['blockpriv'] = isset($wancfg['blockpriv']); $pconfig['blockbogons'] = isset($wancfg['blockbogons']); @@ -312,16 +296,8 @@ if ($_POST) { } /* input validation */ if ($_POST['type'] == "static") { - if ($_POST['ipaddr'] != "") { - $reqdfields = explode(" ", "ipaddr subnet gateway"); - $reqdfieldsn = explode(",", "IPv4 Address,IPv4 Subnet Bit Count,IPv4 Gateway"); - } else if ($_POST['ipaddr_ipv6'] != "") { - $reqdfields = explode(" ", "ipaddr_ipv6 subnet_ipv6 gateway_ipv6"); - $reqdfieldsn = explode(",", "IPv6 Address,IPv6 Subnet Bit Count,IPv6 Gateway"); - } else { - $input_errors[] = "An IPv4 or IPv6 Address is required."; - } - + $reqdfields = explode(" ", "ipaddr subnet gateway"); + $reqdfieldsn = explode(",", "IP address,Subnet bit count,Gateway"); do_input_validation($_POST, $reqdfields, $reqdfieldsn, &$input_errors); } else if ($_POST['type'] == "PPPoE") { if ($_POST['pppoe_dialondemand']) { @@ -345,13 +321,9 @@ if ($_POST) { /* normalize MAC addresses - lowercase and convert Windows-ized hyphenated MACs to colon delimited */ $_POST['spoofmac'] = strtolower(str_replace("-", ":", $_POST['spoofmac'])); if (($_POST['ipaddr'] && !is_ipaddr($_POST['ipaddr']))) - $input_errors[] = "A valid IPv4 address must be specified."; + $input_errors[] = "A valid IP address must be specified."; if (($_POST['subnet'] && !is_numeric($_POST['subnet']))) - $input_errors[] = "A valid IPv4 subnet bit count must be specified."; - if ($_POST['ipaddr_ipv6'] && !Net_IPv6::checkIPv6($_POST['ipaddr_ipv6'])) - $input_errors[] = "A valid IPv6 address must be specified."; - if ($_POST['subnet_ipv6'] && !is_numeric($_POST['subnet_ipv6'])) - $input_errors[] = "A valid IPv6 prefix length must be specified."; + $input_errors[] = "A valid subnet bit count must be specified."; if (($_POST['alias-address'] && !is_ipaddr($_POST['alias-address']))) $input_errors[] = "A valid alias IP address must be specified."; if (($_POST['alias-subnet'] && !is_numeric($_POST['alias-subnet']))) @@ -365,9 +337,7 @@ if ($_POST) { $input_errors[] = "A valid gateway must be specified."; } if (($_POST['pointtopoint'] && !is_ipaddr($_POST['pointtopoint']))) - $input_errors[] = "A valid IPv4 point-to-point address must be specified."; - if (($_POST['pointtopoint_ipv6'] && !is_ipaddr($_POST['pointtopoint_ipv6']))) - $input_errors[] = "A valid IPv6 point-to-point address must be specified."; + $input_errors[] = "A valid point-to-point IP address must be specified."; if (($_POST['provider'] && !is_domain($_POST['provider']))) $input_errors[] = "The service name contains invalid characters."; if (($_POST['pppoe_idletimeout'] != "") && !is_numericint($_POST['pppoe_idletimeout'])) @@ -438,10 +408,6 @@ if ($_POST) { unset($wancfg['subnet']); unset($wancfg['gateway']); unset($wancfg['pointtopoint']); - unset($wancfg['ipaddr_ipv6']); - unset($wancfg['subnet_ipv6']); - unset($wancfg['gateway_ipv6']); - unset($wancfg['pointtopoint_ipv6']); unset($wancfg['dhcphostname']); unset($wancfg['pppoe_username']); unset($wancfg['pppoe_password']); @@ -467,17 +433,10 @@ if ($_POST) { if ($_POST['type'] == "static") { $wancfg['ipaddr'] = $_POST['ipaddr']; $wancfg['subnet'] = $_POST['subnet']; - $wancfg['ipaddr_ipv6'] = $_POST['ipaddr_ipv6']; - $wancfg['subnet_ipv6'] = $_POST['subnet_ipv6']; - - if ($_POST['gateway'] != "none") { + if ($_POST['gateway'] != "none") $wancfg['gateway'] = $_POST['gateway']; - $wancfg['gateway_ipv6'] = $_POST['gateway_ipv6']; - } - if (isset($wancfg['ispointtopoint'])) { + if (isset($wancfg['ispointtopoint'])) $wancfg['pointtopoint'] = $_POST['pointtopoint']; - $wancfg['pointtopoint_ipv6'] = $_POST['pointtopoint_ipv6']; - } } else if ($_POST['type'] == "dhcp") { $wancfg['ipaddr'] = "dhcp"; $wancfg['dhcphostname'] = $_POST['dhcphostname']; @@ -753,7 +712,7 @@ $types = array("none" => "None", "static" => "Static", "dhcp" => "DHCP", "pppoe" else $('allcfg').hide(); } - + function show_periodic_reset(obj) { if (obj.checked) $('presetwrap').show(); @@ -863,7 +822,7 @@ $types = array("none" => "None", "static" => "Static", "dhcp" => "DHCP", "pppoe" - + @@ -885,7 +844,7 @@ $types = array("none" => "None", "static" => "Static", "dhcp" => "DHCP", "pppoe" - + @@ -899,10 +858,10 @@ $types = array("none" => "None", "static" => "Static", "dhcp" => "DHCP", "pppoe" 0) { foreach ($a_gateways as $gateway) { - if($gateway['interface'] == $if && $gateway['type'] == 'IPv4') { + if($gateway['interface'] == $if) { ?> "None", "static" => "Static", "dhcp" => "DHCP", "pppoe"
Static IPv4 configurationStatic IP configuration
IP address
Point-to-point IPv4 address Point-to-point IP address

- + + - - - - Static IPv6 configuration - - - IP address - - / - - - - - - Point-to-point IPv6 address - - - - - - Gateway - -
- Select a existing Gateway from the list or add one on the Gateways page
- TODO: use Ajax, similar to IPv4 - - - - diff --git a/usr/local/www/system.php b/usr/local/www/system.php index 650c7970c7..fe466da40a 100755 --- a/usr/local/www/system.php +++ b/usr/local/www/system.php @@ -38,7 +38,6 @@ require("guiconfig.inc"); -require_once("IPv6.inc"); $pconfig['hostname'] = $config['system']['hostname']; $pconfig['domain'] = $config['system']['domain']; @@ -111,25 +110,12 @@ if ($_POST) { if ($_POST['domain'] && !is_domain($_POST['domain'])) { $input_errors[] = "The domain may only contain the characters a-z, 0-9, '-' and '.'."; } - /* if (($_POST['dns1'] && !is_ipaddr($_POST['dns1'])) || ($_POST['dns2'] && !is_ipaddr($_POST['dns2']))) { $input_errors[] = "A valid IP address must be specified for the primary/secondary DNS server."; } if (($_POST['dns3'] && !is_ipaddr($_POST['dns3'])) || ($_POST['dns4'] && !is_ipaddr($_POST['dns4']))) { $input_errors[] = "A valid IP address must be specified for the primary/secondary DNS server."; } - */ - - if ( - $_POST['dns1'] && !is_ipaddr($_POST['dns1']) && !Net_IPv6::checkIPv6($_POST['dns1']) || - $_POST['dns2'] && !is_ipaddr($_POST['dns2']) && !Net_IPv6::checkIPv6($_POST['dns2']) || - $_POST['dns3'] && !is_ipaddr($_POST['dns3']) && !Net_IPv6::checkIPv6($_POST['dns3']) || - $_POST['dns4'] && !is_ipaddr($_POST['dns4']) && !Net_IPv6::checkIPv6($_POST['dns4']) - ) { - $input_errors[] = "A valid IPv4/IPv6 address must be specified for the primary/secondary DNS server."; - } - - if ($_POST['webguiport'] && (!is_numericint($_POST['webguiport']) || ($_POST['webguiport'] < 1) || ($_POST['webguiport'] > 65535))) { $input_errors[] = "A valid TCP/IP port must be specified for the webConfigurator port."; @@ -267,7 +253,7 @@ include("head.inc");
- e.g. example.com + e.g. mycorp.com @@ -321,7 +307,7 @@ include("head.inc");
- IPv4/IPv6 addresses; these are also used for the DHCP + IP addresses; these are also used for the DHCP service, DNS forwarder and for PPTP VPN clients.
diff --git a/usr/local/www/system_gateways_edit.php b/usr/local/www/system_gateways_edit.php index 314b45dfe1..a8aa571897 100755 --- a/usr/local/www/system_gateways_edit.php +++ b/usr/local/www/system_gateways_edit.php @@ -38,17 +38,17 @@ require("guiconfig.inc"); -require_once("IPv6.inc"); $a_gateways = return_gateways_array(); - -if (isset($_GET['id'])) { - $id = $_GET['id']; -} else if (isset($_POST['id'])) { - $id = $_POST['id']; -} else { - $id = -1; +$a_gateways_arr = array(); +foreach($a_gateways as $gw) { + $a_gateways_arr[] = $gw; } +$a_gateways = $a_gateways_arr; + +$id = $_GET['id']; +if (isset($_POST['id'])) + $id = $_POST['id']; if (isset($_GET['dup'])) { $id = $_GET['dup']; @@ -62,7 +62,6 @@ if (isset($id) && $a_gateways[$id]) { $pconfig['monitor'] = $a_gateways[$id]['monitor']; $pconfig['descr'] = $a_gateways[$id]['descr']; $pconfig['attribute'] = $a_gateways[$id]['attribute']; - $pconfig['type'] = $a_gateways[$id]['type']; } if (isset($_GET['dup'])) { @@ -81,33 +80,15 @@ if ($_POST) { do_input_validation($_POST, $reqdfields, $reqdfieldsn, &$input_errors); - /* Does this gateway name already exist? */ - foreach($config['gateways']['gateway_item'] as $gw) - if($gw['name'] == $_POST['name']) - $input_errors[] = "This gateway name already exists."; - if (! isset($_POST['name'])) { $input_errors[] = "A valid gateway name must be specified."; } - - if ($_POST['type'] == 'IPv4') { - if (!is_ipaddr($_POST['gateway']) && $pconfig['attribute'] != 'system') { - $input_errors[] = "A valid IPv4 gateway address must be specified."; - } - - if ($_POST['monitor'] && !is_ipaddr($_POST['monitor'])) { - $input_errors[] = "A valid IPv4 monitor address must be specified."; - } - } else if ($_POST['type'] == 'IPv6') { - if (!Net_IPv6::checkIPv6($_POST['gateway']) && $pconfig['attribute'] != 'system') { - $input_errors[] = "A valid IPv6 gateway address must be specified."; - } - - if ($_POST['monitor'] && !Net_IPv6::checkIPv6($_POST['monitor'])) { - $input_errors[] = "A valid IPv6 monitor address must be specified."; - } - } else { - $input_errors[] = "A network type must be specified."; + /* skip system gateways which have been automatically added */ + if ($_POST['gateway'] && (!is_ipaddr($_POST['gateway'])) && ($pconfig['attribute'] != "system")) { + $input_errors[] = "A valid gateway IP address must be specified."; + } + if ((($_POST['monitor'] <> "") && !is_ipaddr($_POST['monitor']))) { + $input_errors[] = "A valid monitor IP address must be specified."; } /* check for overlaps */ @@ -148,18 +129,16 @@ if ($_POST) { $gateway['name'] = $_POST['name']; $gateway['gateway'] = $_POST['gateway']; $gateway['descr'] = $_POST['descr']; - $gateway['type'] = $_POST['type']; if ($_POST['defaultgw'] == "yes") { - $i=0; - foreach ($a_gateways as $gateway) { - if($id != $i && $config['gateways']['gateway_item'][$i]['type'] == $_POST['type']) { - unset($config['gateways']['gateway_item'][$i]['defaultgw']); - } else if ($config['gateways']['gateway_item'][$i]['type'] == $_POST['type']) { - $config['gateways']['gateway_item'][$i]['defaultgw'] = true; - } + $i = 0; + foreach($a_gateways as $gw) { + unset($config['gateways'][$i]['defaultgw']); $i++; } + $gateway['defaultgw'] = true; + } else { + unset($gateway['defaultgw']); } /* when saving the manual gateway we use the attribute which has the corresponding id */ @@ -231,33 +210,11 @@ include("head.inc");
Gateway name - - Type - - - - Gateway -
Gateway IPv4/IPv6 address +
Gateway IP address Default Gateway @@ -272,7 +229,7 @@ EOD; Alternative monitor IP
- Enter an alternative address here to be used to monitor the link. This is used for the + Enter a alternative address here to be used to monitor the link. This is used for the quality RRD graphs as well as the load balancer entries. Use this if the gateway does not respond to icmp requests.