diff --git a/src/www/system_routes.php b/src/www/system_routes.php
deleted file mode 100644
index a666a70c6..000000000
--- a/src/www/system_routes.php
+++ /dev/null
@@ -1,332 +0,0 @@
-.
- All rights reserved.
-
- Redistribution and use in source and binary forms, with or without
- modification, are permitted provided that the following conditions are met:
-
- 1. Redistributions of source code must retain the above copyright notice,
- this list of conditions and the following disclaimer.
-
- 2. Redistributions in binary form must reproduce the above copyright
- notice, this list of conditions and the following disclaimer in the
- documentation and/or other materials provided with the distribution.
-
- THIS SOFTWARE IS PROVIDED ``AS IS'' AND ANY EXPRESS OR IMPLIED WARRANTIES,
- INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY
- AND FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE
- AUTHOR BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY,
- OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF
- SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS
- INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN
- CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE)
- ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE
- POSSIBILITY OF SUCH DAMAGE.
-*/
-
-require_once("guiconfig.inc");
-require_once("interfaces.inc");
-require_once("filter.inc");
-require_once("system.inc");
-require_once("rrd.inc");
-
-function delete_static_route($id)
-{
- global $config, $a_routes;
-
- if (!isset($a_routes[$id])) {
- return;
- }
-
- $targets = array();
- if (is_alias($a_routes[$id]['network'])) {
- foreach (filter_expand_alias_array($a_routes[$id]['network']) as $tgt) {
- if (is_ipaddrv4($tgt)) {
- $tgt .= "/32";
- } elseif (is_ipaddrv6($tgt)) {
- $tgt .= "/128";
- }
- if (!is_subnet($tgt)) {
- continue;
- }
- $targets[] = $tgt;
- }
- } else {
- $targets[] = $a_routes[$id]['network'];
- }
-
- foreach ($targets as $tgt) {
- $family = (is_subnetv6($tgt) ? "-inet6" : "-inet");
- mwexec("/sbin/route delete {$family} " . escapeshellarg($tgt));
- }
-
- unset($targets);
-}
-
-$a_routes = &config_read_array('staticroutes', 'route');
-
-if ($_SERVER['REQUEST_METHOD'] === 'POST') {
- $pconfig = $_POST;
- if (isset($_POST['id']) && isset($a_routes[$_POST['id']])) {
- $id = $_POST['id'];
- }
- if (!empty($_POST['act'])) {
- $act = $_POST['act'];
- } else {
- $act = null;
- }
-
- if (!empty($pconfig['apply'])) {
- // todo: remove this ugly hook
- if (file_exists('/tmp/.system_routes.apply')) {
- $toapplylist = unserialize(file_get_contents('/tmp/.system_routes.apply'));
- foreach ($toapplylist as $toapply) {
- mwexec("{$toapply}");
- }
- @unlink('/tmp/.system_routes.apply');
- }
-
- system_routing_configure();
- filter_configure();
- setup_gateways_monitor();
- clear_subsystem_dirty('staticroutes');
- } elseif (isset($id) && $act == 'del') {
- delete_static_route($id);
- unset($a_routes[$id]);
- write_config();
- } elseif ($act == 'del_x' && isset($pconfig['route'])) {
- /* delete selected routes */
- if (is_array($pconfig['route'])) {
- foreach ($_POST['route'] as $routei) {
- delete_static_route($routei);
- unset($a_routes[$routei]);
- }
- write_config();
- }
- } elseif (isset($id) && $act == "toggle") {
- if (isset($a_routes[$id]['disabled'])) {
- unset($a_routes[$id]['disabled']);
- } else {
- delete_static_route($id);
- $a_routes[$id]['disabled'] = true;
- }
-
- write_config();
- mark_subsystem_dirty('staticroutes');
- } elseif ( $act == 'move' && isset($pconfig['route']) && count($pconfig['route']) > 0) {
- // move selected rules
- if (!isset($id)) {
- // if rule not set/found, move to end
- $id = count($a_routes);
- }
- $a_routes = legacy_move_config_list_items($a_routes, $id, $pconfig['route']);
- write_config();
- mark_subsystem_dirty('staticroutes');
- }
- header(url_safe('Location: /system_routes.php'));
- exit;
-}
-
-$a_gateways = return_gateways_array(true, true, true);
-legacy_html_escape_form_data($a_routes);
-legacy_html_escape_form_data($a_gateways);
-
-$main_buttons = array(
- array('label'=> gettext('Add route'), 'href'=>'system_routes_edit.php'),
-);
-
-include("head.inc");
-
-?>
-
-
-
-
-
-
-.
- Copyright (C) 2010 Scott Ullrich
- All rights reserved.
-
- Redistribution and use in source and binary forms, with or without
- modification, are permitted provided that the following conditions are met:
-
- 1. Redistributions of source code must retain the above copyright notice,
- this list of conditions and the following disclaimer.
-
- 2. Redistributions in binary form must reproduce the above copyright
- notice, this list of conditions and the following disclaimer in the
- documentation and/or other materials provided with the distribution.
-
- THIS SOFTWARE IS PROVIDED ``AS IS'' AND ANY EXPRESS OR IMPLIED WARRANTIES,
- INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY
- AND FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE
- AUTHOR BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY,
- OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF
- SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS
- INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN
- CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE)
- ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE
- POSSIBILITY OF SUCH DAMAGE.
-*/
-
-require_once("guiconfig.inc");
-require_once("filter.inc");
-require_once("interfaces.inc");
-
-$a_routes = &config_read_array('staticroutes', 'route');
-$a_gateways = return_gateways_array(true, true);
-
-if ($_SERVER['REQUEST_METHOD'] === 'GET') {
- if (isset($_GET['id']) && isset($a_routes[$_GET['id']])) {
- $id = $_GET['id'];
- $configId = $id;
- } elseif (isset($_GET['dup']) && isset($a_routes[$_GET['dup']])) {
- $configId = $_GET['dup'];
- }
- $pconfig = array();
-
- if (isset($configId)) {
- list($pconfig['network'],$pconfig['network_subnet']) =
- explode('/', $a_routes[$configId]['network']);
- $pconfig['gateway'] = $a_routes[$configId]['gateway'];
- $pconfig['descr'] = $a_routes[$configId]['descr'];
- $pconfig['disabled'] = isset($a_routes[$configId]['disabled']);
- } else {
- $pconfig['network'] = null;
- $pconfig['network_subnet'] = null;
- $pconfig['gateway'] = null;
- $pconfig['disabled'] = false;
- }
-} elseif ($_SERVER['REQUEST_METHOD'] === 'POST') {
- if (isset($_POST['id']) && isset($a_routes[$_POST['id']])) {
- $id = $_POST['id'];
- }
- global $aliastable;
-
- $input_errors = array();
- $pconfig = $_POST;
-
- /* input validation */
- $reqdfields = explode(" ", "network network_subnet gateway");
- $reqdfieldsn = explode(
- ",",
- gettext("Destination network") . "," .
- gettext("Destination network bit count") . "," .
- gettext("Gateway")
- );
-
- do_input_validation($pconfig, $reqdfields, $reqdfieldsn, $input_errors);
-
- if (($pconfig['network'] && !is_ipaddr($pconfig['network']) && !is_alias($pconfig['network']))) {
- $input_errors[] = gettext("A valid IPv4 or IPv6 destination network must be specified.");
- }
- if (($_POST['network_subnet'] && !is_numeric($pconfig['network_subnet']))) {
- $input_errors[] = gettext("A valid destination network bit count must be specified.");
- }
- if (($_POST['gateway']) && is_ipaddr($pconfig['network'])) {
- if (!isset($a_gateways[$pconfig['gateway']])) {
- $input_errors[] = gettext("A valid gateway must be specified.");
- }
- if (!validate_address_family($pconfig['network'], lookup_gateway_ip_by_name($pconfig['gateway']))) {
- $input_errors[] = gettext("The gateway '{$a_gateways[$pconfig['gateway']]['gateway']}' is a different Address Family as network '{$pconfig['network']}'.");
- }
- }
-
- /* check for overlaps */
- $current_targets = get_staticroutes(true);
- $new_targets = array();
- if (is_ipaddrv6($pconfig['network'])) {
- $osn = gen_subnetv6($pconfig['network'], $pconfig['network_subnet']) . "/" . $pconfig['network_subnet'];
- $new_targets[] = $osn;
- }
- if (is_ipaddrv4($pconfig['network'])) {
- if ($pconfig['network_subnet'] > 32) {
- $input_errors[] = gettext("A IPv4 subnet can not be over 32 bits.");
- } else {
- $osn = gen_subnet($pconfig['network'], $pconfig['network_subnet']) . "/" . $pconfig['network_subnet'];
- $new_targets[] = $osn;
- }
- } elseif (is_alias($pconfig['network'])) {
- $osn = $pconfig['network'];
- foreach (preg_split('/\s+/', $aliastable[$osn]) as $tgt) {
- if (is_ipaddrv4($tgt)) {
- $tgt .= "/32";
- }
- if (is_ipaddrv6($tgt)) {
- $tgt .= "/128";
- }
- if (!is_subnet($tgt)) {
- continue;
- }
- if (!is_subnetv6($tgt)) {
- continue;
- }
- $new_targets[] = $tgt;
- }
- }
- if (!isset($id)) {
- $id = count($a_routes);
- }
- $oroute = $a_routes[$id];
- $old_targets = array();
- if (!empty($oroute)) {
- if (is_alias($oroute['network'])) {
- foreach (filter_expand_alias_array($oroute['network']) as $tgt) {
- if (is_ipaddrv4($tgt)) {
- $tgt .= "/32";
- } elseif (is_ipaddrv6($tgt)) {
- $tgt .= "/128";
- }
- if (!is_subnet($tgt)) {
- continue;
- }
- $old_targets[] = $tgt;
- }
- } else {
- $old_targets[] = $oroute['network'];
- }
- }
-
- $overlaps = array_intersect($current_targets, $new_targets);
- $overlaps = array_diff($overlaps, $old_targets);
- if (count($overlaps)) {
- $input_errors[] = gettext("A route to these destination networks already exists") . ": " . implode(", ", $overlaps);
- }
-
- if (is_array($config['interfaces'])) {
- foreach (legacy_config_get_interfaces(array("virtual" => false)) as $if) {
- if (is_ipaddrv4($pconfig['network'])
- && isset($if['ipaddr']) && isset($if['subnet'])
- && is_ipaddrv4($if['ipaddr']) && is_numeric($if['subnet'])
- && ($_POST['network_subnet'] == $if['subnet'])
- && (gen_subnet($pconfig['network'], $pconfig['network_subnet']) == gen_subnet($if['ipaddr'], $if['subnet']))) {
- $input_errors[] = sprintf(gettext("This network conflicts with address configured on interface %s."), $if['descr']);
- } elseif (is_ipaddrv6($pconfig['network'])
- && isset($if['ipaddrv6']) && isset($if['subnetv6'])
- && is_ipaddrv6($if['ipaddrv6']) && is_numeric($if['subnetv6'])
- && ($_POST['network_subnet'] == $if['subnetv6'])
- && (gen_subnetv6($pconfig['network'], $pconfig['network_subnet']) == gen_subnetv6($if['ipaddrv6'], $if['subnetv6']))) {
- $input_errors[] = sprintf(gettext("This network conflicts with address configured on interface %s."), $if['descr']);
- }
- }
- }
-
- if (count($input_errors) == 0){
- $route = array();
- $route['network'] = $osn;
- $route['gateway'] = $pconfig['gateway'];
- $route['descr'] = $pconfig['descr'];
- if (!empty($pconfig['disabled'])) {
- $route['disabled'] = true;
- } else {
- unset($route['disabled']);
- }
-
- if (file_exists('/tmp/.system_routes.apply')) {
- $toapplylist = unserialize(file_get_contents('/tmp/.system_routes.apply'));
- } else {
- $toapplylist = array();
- }
- $a_routes[$id] = $route;
-
- if (!empty($oroute)) {
- $delete_targets = array_diff($old_targets, $new_targets);
- if (count($delete_targets)) {
- foreach ($delete_targets as $dts) {
- if (is_ipaddrv6($dts)) {
- $family = '-inet6';
- }
- $toapplylist[] = "/sbin/route delete {$family} {$dts}";
- }
- }
- }
- file_put_contents('/tmp/.system_routes.apply', serialize($toapplylist));
- mark_subsystem_dirty('staticroutes');
- write_config();
-
- header(url_safe('Location: /system_routes.php'));
- exit;
- }
-}
-
-legacy_html_escape_form_data($a_gateways);
-legacy_html_escape_form_data($pconfig);
-
-include("head.inc");
-
-?>
-
-
-
-
-
-
-
-
-
- 0) {
- print_input_errors($input_errors);
-} ?>
-
-
-
-
-