From 42809b4a0394bf4f06e7a74bd5f7612e2513d0a4 Mon Sep 17 00:00:00 2001 From: gnhb Date: Tue, 4 May 2010 15:35:29 +0700 Subject: Use "PPPs" as the new Tab name in Interfaces -> Assign. Rename files and update affected files. Also, add upgrade_config function 062_to_063. --- etc/inc/globals.inc | 2 +- etc/inc/interfaces.inc | 18 +- etc/inc/pfsense-utils.inc | 2 +- etc/inc/upgrade_config.inc | 17 + usr/local/www/interfaces_assign.php | 39 +- usr/local/www/interfaces_bridge.php | 3 +- usr/local/www/interfaces_gif.php | 3 +- usr/local/www/interfaces_gre.php | 3 +- usr/local/www/interfaces_groups.php | 3 +- usr/local/www/interfaces_lagg.php | 3 +- usr/local/www/interfaces_mlppp.php | 133 ---- usr/local/www/interfaces_mlppp_edit.php | 866 -------------------- usr/local/www/interfaces_ppps.php | 133 ++++ usr/local/www/interfaces_ppps_edit.php | 885 +++++++++++++++++++++ usr/local/www/interfaces_qinq.php | 3 +- usr/local/www/interfaces_vlan.php | 3 +- usr/local/www/interfaces_wireless.php | 3 +- .../interfaces_mlppp_edit/interfaces_mlppp_edit.js | 105 --- .../javascript/interfaces_ppps_edit/ppps_edit.js | 105 +++ 19 files changed, 1175 insertions(+), 1154 deletions(-) delete mode 100644 usr/local/www/interfaces_mlppp.php delete mode 100644 usr/local/www/interfaces_mlppp_edit.php create mode 100644 usr/local/www/interfaces_ppps.php create mode 100644 usr/local/www/interfaces_ppps_edit.php delete mode 100644 usr/local/www/javascript/interfaces_mlppp_edit/interfaces_mlppp_edit.js create mode 100644 usr/local/www/javascript/interfaces_ppps_edit/ppps_edit.js diff --git a/etc/inc/globals.inc b/etc/inc/globals.inc index 86d50f9..782251a 100644 --- a/etc/inc/globals.inc +++ b/etc/inc/globals.inc @@ -88,7 +88,7 @@ $g = array( "disablehelpmenu" => false, "disablehelpicon" => false, "debug" => false, - "latest_config" => "6.2", + "latest_config" => "6.3", "nopkg_platforms" => array("cdrom"), "minimum_ram_warning" => "105", "minimum_ram_warning_text" => "128 MB", diff --git a/etc/inc/interfaces.inc b/etc/inc/interfaces.inc index 94c5311..d11c52f 100644 --- a/etc/inc/interfaces.inc +++ b/etc/inc/interfaces.inc @@ -884,13 +884,14 @@ function interface_ppp_configure($interface) { $wancfg = &$config['interfaces'][$interface]; if (is_array($config['ppps']['ppp']) && count($config['ppps']['ppp'])) { foreach ($config['ppps']['ppp'] as $pppid => $ppp) { - //$ppp['port'] = $ppp['ports']; - if ($interface == $ppp['ifname']) + if ($wancfg['ptpid'] == $ppp['ptpid']) break; } } - if (!$ppp || !isset($ppp['ifname'])) - return; + if (!$ppp || $wancfg['ptpid'] != $ppp['ptpid'] || stristr($ppp['ports'], ",")){ + log_error("PPP configuration error."); + return; + } /* if ($interface == "wan") $pppid = "0"; @@ -996,7 +997,7 @@ EOD; EOD; $mpdconf .= << $ppp) { + if (isset($ppp['port'])){ + $config['ppps']['ppp'][$pppid]['ports'] = $ppp['port']; + unset($config['ppps']['ppp'][$pppid]['port']); + } + if (!isset($ppp['type'])){ + $config['ppps']['ppp'][$pppid]['type'] = "ppp"; + } + if (!isset($ppp['ptpid'])){ + $config['ppps']['ppp'][$pppid]['ptpid'] = uniqid('', true); + } + } + } +} ?> diff --git a/usr/local/www/interfaces_assign.php b/usr/local/www/interfaces_assign.php index ed80d46..d4001d0 100755 --- a/usr/local/www/interfaces_assign.php +++ b/usr/local/www/interfaces_assign.php @@ -131,8 +131,10 @@ if (is_array($config['ppps']['ppp']) && count($config['ppps']['ppp'])) { $portname = $ppp['type'].$pppid; $portlist[$portname] = $ppp; $portlist[$portname]['isppp'] = true; - $portlist[$portname]['pppid'] = $pppid; - $portlist[$portname]['descr'] = strtoupper($ppp['type']) . $pppid ." - ".$ppp['descr']; + if (isset($ppp['descr'])) + $portlist[$portname]['descr'] = strtoupper($ppp['type']) . " - ". $ppp['descr']; + else + $portlist[$portname]['descr'] = strtoupper($ppp['type']) . " - ". $ppp['ports']; } } @@ -188,13 +190,6 @@ if ($_POST['apply']) { if (!$input_errors) { - /* The 'ifname' must be unset for all PPPs before continuing or we can get legacy data - left in the ppps config sections */ - if (is_array($config['ppps']['ppp']) && count($config['ppps']['ppp'])){ - foreach ($config['ppps']['ppp'] as $pppid => $ppp) { - unset($config['ppps']['ppp'][$pppid]['ifname']); - } - } /* No errors detected, so update the config */ foreach ($_POST as $ifname => $ifport) { @@ -213,12 +208,16 @@ if ($_POST['apply']) { /*For PPP interfaces, write link type to IP address field to signal that IP addr is dynamic and comes from PPP, PPPoE, or PPTP */ if (isset($portlist[$ifport]['isppp'])){ + if ($ifname == "wan") + $config['interfaces'][$ifname]['if'] = $portlist[$ifport]['type'] ."0"; + else + $config['interfaces'][$ifname]['if'] = $portlist[$ifport]['type'] . substr($ifname,3); + $config['interfaces'][$ifname]['ipaddr'] = $portlist[$ifport]['type']; - foreach ($config['ppps']['ppp'] as $pppid => $ppp) { - if ($portlist[$ifport]['pppid'] == $pppid) - $config['ppps']['ppp'][$pppid]['ifname'] = $ifname; - } - } + $config['interfaces'][$ifname]['ptpid'] = $portlist[$ifport]['ptpid']; + } else + unset($config['interfaces'][$ifname]['ptpid']); + /* check for wireless interfaces, set or clear ['wireless'] */ if (preg_match($g['wireless_regex'], $ifport)) { if (!is_array($config['interfaces'][$ifname]['wireless'])) @@ -294,13 +293,6 @@ if ($_GET['act'] == "del") { unset($config['nat']['rule'][$x]['interface']); } } - /* Clean up association with deleted interface in PPPs config section */ - if (is_array($config['ppps']['ppp']) && count($config['ppps']['ppp'])){ - foreach ($config['ppps']['ppp'] as $pppid => $ppp) { - if ($ppp['ifname'] == $id) - unset($config['ppps']['ppp'][$pppid]['ifname']); - } - } write_config(); @@ -396,8 +388,7 @@ if(file_exists("/var/run/interface_mismatch_reboot_needed")) $tab_array[2] = array("Wireless", false, "interfaces_wireless.php"); $tab_array[3] = array("VLANs", false, "interfaces_vlan.php"); $tab_array[4] = array("QinQs", false, "interfaces_qinq.php"); - $tab_array[5] = array("PPP", false, "interfaces_ppp.php"); - $tab_array[6] = array("MLPPP", false, "interfaces_mlppp.php"); + $tab_array[5] = array("PPPs", false, "interfaces_ppps.php"); $tab_array[7] = array("GRE", false, "interfaces_gre.php"); $tab_array[8] = array("GIF", false, "interfaces_gif.php"); $tab_array[9] = array("Bridges", false, "interfaces_bridge.php"); @@ -427,7 +418,7 @@ if(file_exists("/var/run/interface_mismatch_reboot_needed")) $portinfo): ?>