summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorScott Ullrich <sullrich@pfsense.org>2005-01-22 07:58:30 +0000
committerScott Ullrich <sullrich@pfsense.org>2005-01-22 07:58:30 +0000
commit58722116426df0e5c5cb7e9a89f4ac91ecf54940 (patch)
treeed6281ac856a4e722fc8c4ad83d7d21b562da1e4
parentd09c8936cafc53aa5cf38945164f72dfaab40fda (diff)
downloadpfsense-58722116426df0e5c5cb7e9a89f4ac91ecf54940.zip
pfsense-58722116426df0e5c5cb7e9a89f4ac91ecf54940.tar.gz
FIx bug in filter_altq_get_queuename
-rw-r--r--etc/inc/filter.inc105
1 files changed, 56 insertions, 49 deletions
diff --git a/etc/inc/filter.inc b/etc/inc/filter.inc
index 63e1250..b8c798d 100644
--- a/etc/inc/filter.inc
+++ b/etc/inc/filter.inc
@@ -149,7 +149,6 @@ function filter_get_rule_real_interface($associatedrulenumber) {
}
}
-
function filter_get_rule_interface($associatedrulenumber) {
global $config;
foreach ($config['shaper']['rule'] as $rule) {
@@ -216,6 +215,14 @@ function filter_translate_real_interface_to_type($interface) {
return $int;
}
+function filter_translate_type_to_real_interface($interface) {
+ global $config;
+ $int = "na";
+ if($interface == "wan") return $config['interfaces']['wan']['if'];
+ if($interface == "lan") return $config['interfaces']['lan']['if'];
+ return $int;
+}
+
function filter_setup_altq_interfaces() {
global $config;
$altq_rules = "";
@@ -237,17 +244,19 @@ function filter_setup_altq_interfaces() {
}
}
}
- if(isset($ifname['bandwidth'])) {
- $subnet = $ifname['ipaddr'] . "/" . $ifname['subnet'];
- if($queue_names <> ""){
- $altq_rules .= "altq on " . $ifname['if'] . " ";
- $altq_rules .= $config['system']['schedulertype'] . " bandwidth " . $ifname['bandwidth'] . $ifname['bandwidthtype'] . " ";
- $altq_rules .= "queue { " . $queue_names . " }";
- }
- $altq_rules .= "\n";
- $is_first = "";
- $queue_names = "";
+
+ $subnet = $ifname['ipaddr'] . "/" . $ifname['subnet'];
+ if($queue_names <> ""){
+ $altq_rules .= "altq on " . $ifname['if'] . " ";
+ if($ifname['bandwidth'] <> "")
+ $bandwidth = " bandwidth " . $ifname['bandwidth'] . $ifname['bandwidthtype'];
+ $altq_rules .= $config['system']['schedulertype'] . $bandwidth . " ";
+ $altq_rules .= "queue { " . $queue_names . " }";
}
+ $altq_rules .= "\n";
+ $is_first = "";
+ $queue_names = "";
+
}
return $altq_rules;
}
@@ -297,6 +306,8 @@ function filter_generate_altq_rules() {
continue;
}
+ $ipfrules .= "# " . $rule['descr'] . "\n";
+
/* does the rule deal with a PPTP interface? */
if ($rule['interface'] == "pptp") {
@@ -397,8 +408,17 @@ function filter_generate_altq_rules() {
$line .= "on ng" . ($iif+1) . " ";
}
+ $interface = "";
+ if($rule['interface'] <> "")
+ $interface = "on " . filter_translate_type_to_real_interface($rule['interface']) . " ";
+ $line .= $interface;
+
if (isset($rule['protocol'])) {
$line .= "proto {$rule['protocol']} ";
+ } else {
+ if($rule['source']['port'] <> "" || $rule['destination']['port'] <> "") {
+ $line .= "proto tcp ";
+ }
}
/* source address */
@@ -428,32 +448,26 @@ function filter_generate_altq_rules() {
break;
}
+
+
if (isset($rule['source']['not'])) {
$line .= "from !$src ";
} else {
$line .= "from $src ";
}
- if (in_array($rule['protocol'], array("tcp","udp","tcp/udp"))) {
+ if (!isset($rule['protocol']) || in_array($rule['protocol'], array("tcp","udp"))) {
- if ($rule['source']['port']) {
- $srcport = explode("-", $rule['source']['port']);
+ if ($rule['source']['port'] <> "") {
+ $srcport = explode("-", $rule['source']['port']);
- if ((!$srcport[1]) || ($srcport[0] == $srcport[1])) {
- $line .= "port = {$srcport[0]} ";
- } else if (($srcport[0] == 1) && ($srcport[1] == 65535)) {
- /* no need for a port statement here */
- } else if ($srcport[1] == 65535) {
- $line .= "port >= {$srcport[0]} ";
- } else if ($srcport[0] == 1) {
- $line .= "port <= {$srcport[1]} ";
- } else {
- $srcport[0]--;
- $srcport[1]++;
- $line .= "port {$srcport[0]} >< {$srcport[1]} ";
- }
- }
- }
+ if ((!$srcport[1]) || ($srcport[0] == $srcport[1])) {
+ $line .= "port = {$srcport[0]} ";
+ } else {
+ $line .= "port {$srcport[0]} >< {$srcport[1]} ";
+ }
+ }
+ }
/* destination address */
if (isset($rule['destination']['any'])) {
@@ -488,26 +502,19 @@ function filter_generate_altq_rules() {
$line .= "to $dst ";
}
- if (in_array($rule['protocol'], array("tcp","udp","tcp/udp"))) {
+ if (!isset($rule['protocol']) || in_array($rule['protocol'], array("tcp","udp"))) {
- if ($rule['destination']['port']) {
- $dstport = explode("-", $rule['destination']['port']);
+ if ($rule['destination']['port'] <> "") {
+ $srcport = explode("-", $rule['destination']['port']);
+
+ if ((!$srcport[1]) || ($srcport[0] == $srcport[1])) {
+ $line .= "port = {$srcport[0]} ";
+ } else {
+ $line .= "port {$srcport[0]} >< {$srcport[1]} ";
+ }
+ }
+ }
- if ((!$dstport[1]) || ($dstport[0] == $dstport[1])) {
- $line .= "port = {$dstport[0]} ";
- } else if (($dstport[0] == 1) && ($dstport[1] == 65535)) {
- /* no need for a port statement here */
- } else if ($dstport[1] == 65535) {
- $line .= "port >= {$dstport[0]} ";
- } else if ($dstport[0] == 1) {
- $line .= "port <= {$dstport[1]} ";
- } else {
- $dstport[0]--;
- $dstport[1]++;
- $line .= "port {$dstport[0]} >< {$dstport[1]} ";
- }
- }
- }
if (($rule['protocol'] == "icmp") && $rule['icmptype']) {
$line .= "icmp-type {$rule['icmptype']} ";
@@ -566,7 +573,7 @@ function filter_generate_altq_rules() {
#$line .= "group $groupnum ";
}
- $line .= "queue " . filter_altq_get_queuename($que['associatedrule']);
+ $line .= "queue " . filter_altq_get_queuename($rule['targetqueue']);
$line .= "\n";
@@ -583,7 +590,7 @@ function filter_altq_get_queuename($queuenum) {
global $config;
$x=0;
foreach($config['shaper']['queue'] as $rule) {
- if($x == $associatedrulenumber)
+ if($x == $queuenum)
return $rule['name'];
$x++;
}
OpenPOWER on IntegriCloud