diff options
author | Ermal Luçi <eri@pfsense.org> | 2008-03-17 22:11:54 +0000 |
---|---|---|
committer | Ermal Luçi <eri@pfsense.org> | 2008-03-17 22:11:54 +0000 |
commit | 2e89f64275be061c3d06ba51a84790d00dd391bc (patch) | |
tree | 8631ef4127fc681188080c68049a38741622ca55 /usr/local/www/wizards/traffic_shaper_wizard_multi_lan.inc | |
parent | f9b7608e630e60f074bd9832a39f423aa67eb0de (diff) | |
download | pfsense-2e89f64275be061c3d06ba51a84790d00dd391bc.zip pfsense-2e89f64275be061c3d06ba51a84790d00dd391bc.tar.gz |
* Insert other wizards
1- multi Lan/Wan
2- multi Lan/Wan with dedicated links
* Correct checking and math done during the wizards
Diffstat (limited to 'usr/local/www/wizards/traffic_shaper_wizard_multi_lan.inc')
-rw-r--r-- | usr/local/www/wizards/traffic_shaper_wizard_multi_lan.inc | 154 |
1 files changed, 96 insertions, 58 deletions
diff --git a/usr/local/www/wizards/traffic_shaper_wizard_multi_lan.inc b/usr/local/www/wizards/traffic_shaper_wizard_multi_lan.inc index 66181bd..87d2590 100644 --- a/usr/local/www/wizards/traffic_shaper_wizard_multi_lan.inc +++ b/usr/local/www/wizards/traffic_shaper_wizard_multi_lan.inc @@ -35,12 +35,12 @@ function step1_submitphpaction() { if (!isset($_POST['numberofconnections'])) { $message=gettext("You need to specify the number of local interfaces connected."); - header("Location:wizard.php?xml=traffic_shaper_wizard_multi_lan.xml&stepid=0&message={$message}"); + header("Location:wizard.php?xml=traffic_shaper_wizard.xml&stepid=0&message={$message}"); exit; } if (intval($_POST['numberofconnections']) > 100 || intval($_POST['numberofconnections']) < 1) { $message=gettext("The number of local interfaces supported is between 1 and 100."); - header("Location:wizard.php?xml=traffic_shaper_wizard_multi_lan.xml&stepid=0&message={$message}"); + header("Location:wizard.php?xml=traffic_shaper_wizard.xml&stepid=0&message={$message}"); exit; } } @@ -55,7 +55,7 @@ function step2_stepbeforeformdisplay() { continue; if (!isset($ifdesc['enable']) && $if != "lan" && $if != "wan") continue; - if ($if == "wan") + if ($if == "lan") continue; $numberofinterfaces++; $iflist[] = $if; @@ -63,7 +63,7 @@ function step2_stepbeforeformdisplay() { $numberofconnections = intval($config['ezshaper']['step1']['numberofconnections']); if ($numberofconnections > $numberofinterfaces) { $message=gettext("You do not have {$numberofconnections} of local interfaces!"); - header("Location:wizard.php?xml=traffic_shaper_wizard_multi_lan.xml&stepid=0&message={$message}"); + header("Location:wizard.php?xml=traffic_shaper_wizard.xml&stepid=0&message={$message}"); exit; } @@ -81,7 +81,7 @@ function step2_stepbeforeformdisplay() { $field['type'] = "listtopic"; $fields[] = $field; $field = array(); - $field['name'] = "uploadscheduler"; + $field['name'] = "uploaddscheduler"; $field['type'] = "select"; $field['typehint'] = "Queueing discipline to apply on the upload of this connection."; $field['options']['option'] = array(); @@ -221,30 +221,40 @@ function step2_stepsubmitphpaction() { for ($j = $j; $j < $steps; $j++) { if ($_POST["conn{$i}interface"] == $_POST["conn{$j}interface"]) { $message=gettext("You cannot select the same interface for connections {$i} and {$j}."); - header("Location: wizard.php?xml=traffic_shaper_wizard_multi_lan.xml&stepid=1&message={$message}"); + header("Location: wizard.php?xml=traffic_shaper_wizard.xml&stepid=1&message={$message}"); exit; } - } - } - if (!is_numeric($_POST["connupload"])) { - $message = gettext("Upload bandwidth of connection is not valid."); - header("Location: wizard.php?xml=traffic_shaper_wizard_multi_lan.xml&stepid=1&message={$message}"); - exit; - } - if (!is_numeric($_POST["conndownload"])) { - $message = gettext("Download bandwidth of connection is not valid."); - header("Location: wizard.php?xml=traffic_shaper_wizard_multi_lan.xml&stepid=1&message={$message}"); + if (!is_numeric($_POST["conn{$i}upload"])) { + $message = gettext("Upload bandwidth of connection {$i} is not valid."); + header("Location: wizard.php?xml=traffic_shaper_wizard.xml&stepid=1&message={$message}"); + exit; + } + if (!is_numeric($_POST["conn{$i}download"])) { + $message = gettext("Download bandwidth of connection {$i} is not valid."); + header("Location: wizard.php?xml=traffic_shaper_wizard.xml&stepid=1&message={$message}"); + exit; + } + $upbw = floatval($_POST["conn{$i}upload"]); + $downbw = floatval($_POST["conn{$i}download"]); + if ($upbw == 0 || $downbw = 0) { + $message = gettext("You cannot specify 0 bandwidth!") +; + header("Location: wizard.php?xml=traffic_shaper_wizard.xml&stepid=1&message +={$message}"); exit; } - $upbw = floatval($_POST["connupload"]); - $downbw = floatval($_POST["conndownload"]); - if ($upbw == 0 || $downbw = 0) { - $message = gettext("You cannot specify 0 bandwidth!"); - header("Location: wizard.php?xml=traffic_shaper_wizard_multi_lan.xml&stepid=1&message={$message}"); - - exit; + if (intval($upbw) < 128 && $_POST["conn{$i}uploadspeed"] == "Kb" && trim($_POST["conn{$i}scheduler"]) == "CBQ") { + $message=gettext("We do not support Bandwidths smaller than 128Kbit/s for CBQ scheduler."); + header("Location: wizard.php?xml=traffic_shaper_wizard.xml&stepid=1&message={$message}"); + exit; + } + if ($downbw < 128 && $_POST["conn{$i}downloadspeed"] == "Kb" && trim($_POST["downloadscheduler"]) == "CBQ") { + $message=gettext("We do not support Bandwidths smaller than 128Kbit/s for CBQ scheduler."); + header("Location: wizard.php?xml=traffic_shaper_wizard.xml&stepid=1&message={$message}"); + exit; } - + } + } /* This is necessary since the wizard expects predefined fields. */ unset($config['ezshaper']['step2']); @@ -273,7 +283,7 @@ function step3_stepsubmitphpaction() { if(!is_alias($_POST['address'])) { /* item is not an ip or alias. error out */ $message=gettext("Address must be a valid IP address or Firewall Alias. Please correct this value to continue."); - header("Location: wizard.php?xml=traffic_shaper_wizard_multi_lan.xml&stepid=2&message={$message}"); + header("Location: wizard.php?xml=traffic_shaper_wizard.xml&stepid=2&message={$message}"); exit; } } @@ -284,7 +294,7 @@ function step3_stepsubmitphpaction() { if ($_POST["connupload"]) { if (!is_numeric($_POST["connupload"])) { $message = gettext("Upload bandwidth of connection {$i} is not valid."); - header("Location: wizard.php?xml=traffic_shaper_wizard_multi_lan.xml&stepid=2&message={$message}"); + header("Location: wizard.php?xml=traffic_shaper_wizard.xml&stepid=2&message={$message}"); exit; } $factor = wizard_get_bandwidthtype_scale($config['ezshaper']['step2']["conn{$i}uploadspeed"]); @@ -293,7 +303,7 @@ function step3_stepsubmitphpaction() { $input_bw = $factor * floatval($_POST["conn{$i}upload"]); if ((0.8 * $ifbw) < $input_bw) { $message=gettext("You cannot set the VoIP upload bandwidth on connection {$i} higher than 80% of the connection."); - header("Location: wizard.php?xml=traffic_shaper_wizard_multi_lan.xml&stepid=2&message={$message}"); + header("Location: wizard.php?xml=traffic_shaper_wizard.xml&stepid=2&message={$message}"); exit; } } @@ -307,24 +317,24 @@ function step4_stepsubmitphpaction() { if ( $_POST['enable'] ) { if(!$_POST['bandwidth']) { $message="You need to specify a value for bandwidth!"; - header("Location: wizard.php?xml=traffic_shaper_wizard_multi_lan.xml&stepid=3&message={$message}"); + header("Location: wizard.php?xml=traffic_shaper_wizard.xml&stepid=3&message={$message}"); exit; } if(!is_numeric($_POST['bandwidth'])) { $message="The posted value is not a valid bandwidth."; - header("Location: wizard.php?xml=traffic_shaper_wizard_multi_lan.xml&stepid=3&message={$message}"); + header("Location: wizard.php?xml=traffic_shaper_wizard.xml&stepid=3&message={$message}"); exit; } /* if (wizard_get_bwunit($_POST['bandwidth']) <> "%") { $message = gettext("Only percentage bandwidth specification is allowed."); - header("Location: wizard.php?xml=traffic_shaper_wizard_multi_lan.xml&stepid=3&message={$message}"); + header("Location: wizard.php?xml=traffic_shaper_wizard.xml&stepid=3&message={$message}"); exit; } $bw = wizard_get_bw($_POST['bandwidth']); if($bw > 15 && $bw < 2) { $message="Values should be between 2% and 15%!"; - header("Location: wizard.php?xml=traffic_shaper_wizard_multi_lan.xml&stepid=3&message={$message}"); + header("Location: wizard.php?xml=traffic_shaper_wizard.xml&stepid=3&message={$message}"); exit; } */ @@ -333,7 +343,7 @@ function step4_stepsubmitphpaction() { if(!is_alias($_POST['address'])) { /* item is not an ip or alias. error out */ $message=gettext("Address must be a valid IP address or Firewall Alias. Please correct this value to continue."); - header("Location: wizard.php?xml=traffic_shaper_wizard_multi_lan.xml&stepid=3&message={$message}"); + header("Location: wizard.php?xml=traffic_shaper_wizard.xml&stepid=3&message={$message}"); } } } @@ -346,19 +356,19 @@ function step5_stepsubmitphpaction() { if (isset($_POST['bandwidth']) && $_POST['bandwidth'] <> "") { if(!is_numeric($_POST['bandwidth'])) { $message="Posted value is not a valid bandwidth."; - header("Location: wizard.php?xml=traffic_shaper_wizard_multi_lan.xml&stepid=4&message={$message}"); + header("Location: wizard.php?xml=traffic_shaper_wizard.xml&stepid=4&message={$message}"); } /* if (wizard_get_bwunit($_POST['bandwidth']) <> "%") { $message = gettext("Only percentage bandwidth specification is allowed."); - header("Location: wizard.php?xml=traffic_shaper_wizard_multi_lan.xml&stepid=4&message={$message}"); + header("Location: wizard.php?xml=traffic_shaper_wizard.xml&stepid=4&message={$message}"); exit; } $bw = wizard_get_bw($_POST['bandwidth']); if($bw > 15 && $bw < 2) { $message="Values should be between 2% and 15%!"; - header("Location: wizard.php?xml=traffic_shaper_wizard_multi_lan.xml&stepid=3&message={$message}"); + header("Location: wizard.php?xml=traffic_shaper_wizard.xml&stepid=3&message={$message}"); exit; } */ @@ -771,12 +781,24 @@ $othersplist = array(); $voip = true; $voipbw = $config['ezshaper']['step3']["conndownload"]; $voipbwunit = $config['ezshaper']['step3']["conndownloadspeed"]; + if ($sched != "HFSC") { + if ($voipbwunit == "%") + $factor = $upbw/100; + else + $factor = wizard_get_bandwidthtype_scale($voipbwunit); + $remainbw += $voipbw * $factor; + } else + $remainbw += 32000; /* 32Kbit/s forHFSC linksharing */ } if ($config['ezshaper']['step4']['enable']) { $penalty = true; $penaltybw = $config['ezshaper']['step4']['bandwidth']; $penaltybwunit = $config['ezshaper']['step4']['bandwidthunit']; - $remainbw += floatval($config['ezshaper']['step4']['bandwidth']) * $config['ezshaper']['step4']['bandwidthunit']; + if ($penaltybwunit == "%") + $factor = $upbw/100; + else + $factor = wizard_get_bandwidthtype_scale($penaltybwunit); + $remainbw += $penaltybw * $factor; } else { $penalty = false; $penaltybw = 0; @@ -787,7 +809,11 @@ $othersplist = array(); $p2pcatchall = true; $p2pcatchbw = $config['ezshaper']['step5']['bandwidth']; $p2pcatchbwunit = $config['ezshaper']['step5']['bandwidthunit']; - $remainbw += floatval($config['ezshaper']['step5']['bandwidth']) * $config['ezshaper']['step5']['bandwidthunit']; + if ($p2pcatchbwunit == "%") + $factor = $upbw/100; + else + $factor = wizard_get_bandwidthtype_scale($p2pcatchbwunit); + $remainbw += $p2pcatchbw * $factor; } else { $p2pcatchall = false; $p2pcatchbw = 0; @@ -809,13 +835,15 @@ $othersplist = array(); $otherpriority = false; } $remainbw = round($remainbw / $upbw * 100, 2); + /* if ($remainbw > 0 && $remainbw > 30) { $message=gettext("Custom Bandwidths are greater than 30%. Please lower them for the wizard to continue."); - header("Location: wizard.php?xml=traffic_shaper_wizard_multi_lan.xml&stepid=2&message={$message}"); + header("Location: wizard.php?xml=traffic_shaper_wizard.xml&stepid=2&message={$message}"); exit; } else { + */ $remainbw = 100 - $remainbw; - } + //} if ($sched == "PRIQ") $q =& new priq_queue(); @@ -834,10 +862,7 @@ $othersplist = array(); $tmpcf['bandwidthtype'] = "%"; } else if ($sched == "HFSC") { - if ($ifbw > 0) - $lkbw = 0.20 * $remainbw; - else - $lkbw = 25; + $lkbw = 0.20 * $remainbw; $tmpcf['linkshare3'] = "{$lkbw}%"; $tmpcf['linkshare2'] = 100; $tmpcf['linkshare1'] = "0b"; @@ -967,9 +992,9 @@ $othersplist = array(); } $tmpcf['realtime'] = "on"; $tmpcf['realtime2'] = "10"; - $tmpcf['bandwidth'] = 20; + $tmpcf['bandwidth'] = 32; $tmpcf['realtime1'] = "0b"; - $tmpcf['bandwidthtype'] = "%"; + $tmpcf['bandwidthtype'] = "Kb"; } array_push($tmppath, "qVoIP"); $qtmp =& $altq->add_queue($q, &$tmpcf, &$tmppath, $input_errors); @@ -1119,19 +1144,29 @@ $othersplist = array(); $otherpriority = false; $remainbw = 0; - $factor = wizard_get_bandwidthtype_scale($config['ezshaper']['step2']["connuploadspeed"]); - $ifbw = $factor * floatval($config['ezshaper']['step2']["connupload"]); if ($config['ezshaper']['step3']['enable']) { $voip = true; $voipbw = $config['ezshaper']['step3']["connupload"]; $voipbwunit = $config['ezshaper']['step3']["connuploadspeed"]; + if ($sched != "HFSC") { + if ($voipbwunit == "%") + $factor = $upbw/100; + else + $factor = wizard_get_bandwidthtype_scale($voipbwunit); + $remainbw += $voipbw * $factor; + } else + $remainbw += 32000; /* 32Kbit/s forHFSC linksharing */ } if ($config['ezshaper']['step4']['enable']) { $penalty = true; $penaltybw = $config['ezshaper']['step4']['bandwidth']; $penaltybwunit = $config['ezshaper']['step4']['bandwidthunit']; - $remainbw += floatval($config['ezshaper']['step4']['bandwidth']) * $config['ezshaper']['step4']['bandwidthunit']; + if ($penaltybwunit == "%") + $factor = $upbw/100; + else + $factor = wizard_get_bandwidthtype_scale($penaltybwunit); + $remainbw += $penaltybw * $factor; } else { $penalty = false; $penaltybw = 0; @@ -1142,7 +1177,11 @@ $othersplist = array(); $p2pcatchall = true; $p2pcatchbw = $config['ezshaper']['step5']['bandwidth']; $p2pcatchbwunit = $config['ezshaper']['step5']['bandwidthunit']; - $remainbw += floatval($config['ezshaper']['step5']['bandwidth']) * $config['ezshaper']['step5']['bandwidthunit']; + if ($p2pcatchbwunit == "%") + $factor = $upbw/100; + else + $factor = wizard_get_bandwidthtype_scale($p2pcatchbwunit); + $remainbw += $p2pcatchbw * $factor; } else { $p2pcatchall = false; $p2pcatchbw = 0; @@ -1163,14 +1202,16 @@ $othersplist = array(); } else { $otherpriority = false; } - $remainbw = round($remainbw / $ifbw * 100, 2); + $remainbw = round($remainbw / $lanbw * 100, 2); + /* if ($remainbw > 0 && $remainbw > 30) { $message=gettext("Custom Bandwidths are greater than 30%. Please lower them for the wizard to continue."); - header("Location: wizard.php?xml=traffic_shaper_wizard_multi_lan.xml&stepid=2&message={$message}"); + header("Location: wizard.php?xml=traffic_shaper_wizard.xml&stepid=2&message={$message}"); exit; } else { + */ $remainbw = 100 - $remainbw; - } + //} if ($sched == "PRIQ") $q =& new priq_queue(); @@ -1189,10 +1230,7 @@ $othersplist = array(); $tmpcf['bandwidthtype'] = "%"; } else if ($sched == "HFSC") { - if ($ifbw > 0) - $lkbw = 0.20 * $remainbw; - else - $lkbw = 25; + $lkbw = 0.20 * $remainbw; $tmpcf['linkshare3'] = "{$lkbw}%"; $tmpcf['linkshare2'] = 100; $tmpcf['linkshare1'] = "0b"; @@ -1322,9 +1360,9 @@ $othersplist = array(); } $tmpcf['realtime'] = "on"; $tmpcf['realtime2'] = "10"; - $tmpcf['bandwidth'] = 20; + $tmpcf['bandwidth'] = 32; $tmpcf['realtime1'] = "0b"; - $tmpcf['bandwidthtype'] = "%"; + $tmpcf['bandwidthtype'] = "Kb"; } array_push($tmppath, "qVoIP"); $qtmp =& $altq->add_queue($q, &$tmpcf, &$tmppath, $input_errors); |