From bf021e83dc973c6b4848b2713d77feb5a2a8c481 Mon Sep 17 00:00:00 2001 From: Ad Schellevis Date: Fri, 4 Dec 2015 14:30:14 +0100 Subject: [PATCH] (legacy) refactor system_advanced_network.php --- src/www/system_advanced_network.php | 428 ++++++++++++++-------------- 1 file changed, 217 insertions(+), 211 deletions(-) diff --git a/src/www/system_advanced_network.php b/src/www/system_advanced_network.php index 14e548bec..60b3eee27 100644 --- a/src/www/system_advanced_network.php +++ b/src/www/system_advanced_network.php @@ -1,32 +1,32 @@ . - All rights reserved. + Copyright (C) 2014-2015 Deciso B.V. + Copyright (C) 2005-2007 Scott Ullrich + Copyright (C) 2008 Shrew Soft Inc + Copyright (C) 2003-2004 Manuel Kasper . + All rights reserved. - Redistribution and use in source and binary forms, with or without - modification, are permitted provided that the following conditions are met: + 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. + 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. + 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. + 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"); @@ -35,84 +35,94 @@ require_once("filter.inc"); require_once("system.inc"); require_once("pfsense-utils.inc"); -function system_enable_arp_wrong_if() -{ - set_sysctl(array( - "net.link.ether.inet.log_arp_wrong_iface" => "1", - "net.link.ether.inet.log_arp_movements" => "1" - )); -} - -if (isset($_POST) && count($_POST) > 0) { +if ($_SERVER['REQUEST_METHOD'] === 'GET') { + $pconfig = array(); + $pconfig['ipv6allow'] = isset($config['system']['ipv6allow']); + $pconfig['ipv6nat_enable'] = isset($config['diag']['ipv6nat']['enable']); + $pconfig['ipv6nat_ipaddr'] = isset($config['diag']['ipv6nat']['ipaddr']) ? $config['diag']['ipv6nat']['ipaddr']:"" ; + $pconfig['prefer_ipv4'] = isset($config['system']['prefer_ipv4']); + $pconfig['polling'] = isset($config['system']['polling']); + $pconfig['disablechecksumoffloading'] = isset($config['system']['disablechecksumoffloading']); + $pconfig['disablesegmentationoffloading'] = isset($config['system']['disablesegmentationoffloading']); + $pconfig['disablelargereceiveoffloading'] = isset($config['system']['disablelargereceiveoffloading']); + $pconfig['disablevlanhwfilter'] = isset($config['system']['disablevlanhwfilter']); + $pconfig['sharednet'] = isset($config['system']['sharednet']); +} elseif ($_SERVER['REQUEST_METHOD'] === 'POST') { + $pconfig = $_POST; $input_errors = array(); - if (isset($_POST['ipv6nat_enable']) && !is_ipaddr($_POST['ipv6nat_ipaddr'])) { + if (!empty($pconfig['ipv6nat_enable']) && !is_ipaddr($_POST['ipv6nat_ipaddr'])) { $input_errors[] = gettext("You must specify an IP address to NAT IPv6 packets."); } - if (isset($_POST['ipv6nat_enable']) && $_POST['ipv6nat_enable'] == "yes") { - $config['diag']['ipv6nat'] = array(); + if (!empty($pconfig['ipv6nat_enable'])) { + $config['diag']['ipv6nat'] = array(); $config['diag']['ipv6nat']['enable'] = true; $config['diag']['ipv6nat']['ipaddr'] = $_POST['ipv6nat_ipaddr']; } elseif (isset($config['diag']['ipv6nat'])) { unset($config['diag']['ipv6nat']); } - if (isset($_POST['ipv6allow']) && $_POST['ipv6allow'] == "yes") { + if (!empty($pconfig['ipv6allow'])) { $config['system']['ipv6allow'] = true; - } else { + } elseif (isset($config['system']['ipv6allow'])) { unset($config['system']['ipv6allow']); } - if (isset($_POST['prefer_ipv4']) && $_POST['prefer_ipv4'] == "yes") { + if (!empty($pconfig['prefer_ipv4'])) { $config['system']['prefer_ipv4'] = true; - } else { + } elseif (isset($config['system']['prefer_ipv4'])) { unset($config['system']['prefer_ipv4']); } - if (isset($_POST['sharednet']) && $_POST['sharednet'] == "yes") { + if (!empty($pconfig['sharednet'])) { $config['system']['sharednet'] = true; - } else { + } elseif (isset($config['system']['sharednet'])) { unset($config['system']['sharednet']); } - if (isset($_POST['polling_enable']) && $_POST['polling_enable'] == "yes") { + if (!empty($pconfig['polling'])) { $config['system']['polling'] = true; - } else { + } elseif (isset($config['system']['polling'])) { unset($config['system']['polling']); } - if (isset($_POST['disablechecksumoffloading']) && $_POST['disablechecksumoffloading'] == "yes") { + if (!empty($pconfig['disablechecksumoffloading'])) { $config['system']['disablechecksumoffloading'] = true; - } else { + } elseif (isset($config['system']['disablechecksumoffloading'])) { unset($config['system']['disablechecksumoffloading']); } - if (isset($_POST['disablesegmentationoffloading']) && $_POST['disablesegmentationoffloading'] == "yes") { + if (!empty($pconfig['disablesegmentationoffloading'])) { $config['system']['disablesegmentationoffloading'] = true; - } else { + } elseif (isset($config['system']['disablesegmentationoffloading'])) { unset($config['system']['disablesegmentationoffloading']); } - if (isset($_POST['disablelargereceiveoffloading']) && $_POST['disablelargereceiveoffloading'] == "yes") { + if (!empty($_POST['disablelargereceiveoffloading'])) { $config['system']['disablelargereceiveoffloading'] = true; - } else { + } elseif (isset($config['system']['disablelargereceiveoffloading'])) { unset($config['system']['disablelargereceiveoffloading']); } - if (isset($_POST['disablevlanhwfilter']) && $_POST['disablevlanhwfilter'] == "yes") { + if (!empty($_POST['disablevlanhwfilter'])) { $config['system']['disablevlanhwfilter'] = true; - } else { + } elseif(isset($config['system']['disablevlanhwfilter'])) { unset($config['system']['disablevlanhwfilter']); } if (count($input_errors) == 0) { + setup_polling(); if (isset($config['system']['sharednet'])) { system_disable_arp_wrong_if(); } else { - system_enable_arp_wrong_if(); + // system_enable_arp_wrong_if + set_sysctl(array( + "net.link.ether.inet.log_arp_wrong_iface" => "1", + "net.link.ether.inet.log_arp_movements" => "1" + )); } setup_microcode(); @@ -124,183 +134,179 @@ if (isset($_POST) && count($_POST) > 0) { } } + $pgtitle = array(gettext("System"),gettext("Settings"),gettext("Networking")); include("head.inc"); ?> - + - + $( document ).ready(function() { + enable_change(false); + }); + //]]> +
-
-
- 0) { - print_input_errors($input_errors); - } - if (isset($savemsg)) { - print_info_box($savemsg); - } - ?> -
-
-
- - - - - - - - - - - - - - - + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + +
- onclick="enable_change(false)" /> -
-
-
-
-
- onclick="enable_change(false)" /> -
- +
+ 0) { + print_input_errors($input_errors); + } + if (isset($savemsg)) { + print_info_box($savemsg); + } +?> +
+
+ + + + + + + + + + + + + - - - - + + + + - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -
+ + +
+ onclick="enable_change(false)" /> + +
+ onclick="enable_change(false)" /> +
+
- /> -
- + +  :  + +
+ /> +
- /> -
- -
- /> -
- -
-   - -
- /> -
- -
-   - -
- /> -
- -
-   - -
- /> -
- -
-   - -
- /> -
- -
 " />
- -
-
-
- + "used instead of IPv6."); ?> + +
+ /> + + +
+ /> + + +
+ /> +
+ +
+ /> +
+ +
+ /> +
+ +
+ /> +
+ +
 " />
+ +
+
+
+
-