]>
| Commit | Line | Data |
|---|---|---|
| 1 | #!/usr/bin/perl | |
| 2 | ############################################################################### | |
| 3 | # # | |
| 4 | # IPFire.org - A linux based firewall # | |
| 5 | # Copyright (C) 2007-2022 IPFire Team <info@ipfire.org> # | |
| 6 | # # | |
| 7 | # This program is free software: you can redistribute it and/or modify # | |
| 8 | # it under the terms of the GNU General Public License as published by # | |
| 9 | # the Free Software Foundation, either version 3 of the License, or # | |
| 10 | # (at your option) any later version. # | |
| 11 | # # | |
| 12 | # This program is distributed in the hope that it will be useful, # | |
| 13 | # but WITHOUT ANY WARRANTY; without even the implied warranty of # | |
| 14 | # MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the # | |
| 15 | # GNU General Public License for more details. # | |
| 16 | # # | |
| 17 | # You should have received a copy of the GNU General Public License # | |
| 18 | # along with this program. If not, see <http://www.gnu.org/licenses/>. # | |
| 19 | # # | |
| 20 | ############################################################################### | |
| 21 | ||
| 22 | use RRDs; | |
| 23 | use strict; | |
| 24 | # enable only the following on debugging purpose | |
| 25 | # use warnings; | |
| 26 | # use CGI::Carp 'fatalsToBrowser'; | |
| 27 | ||
| 28 | require '/var/ipfire/general-functions.pl'; | |
| 29 | require "${General::swroot}/lang.pl"; | |
| 30 | require "${General::swroot}/header.pl"; | |
| 31 | require "${General::swroot}/graphs.pl"; | |
| 32 | ||
| 33 | my %qossettings = (); | |
| 34 | my %checked = (); | |
| 35 | my %netsettings = (); | |
| 36 | my $message = ''; | |
| 37 | my $errormessage = ""; | |
| 38 | my $c = ""; | |
| 39 | my $direntry = ""; | |
| 40 | my $classentry = ""; | |
| 41 | my $l7ruleentry = ""; | |
| 42 | my $portruleentry = ""; | |
| 43 | my $tosruleentry = ""; | |
| 44 | my @tmp = (); | |
| 45 | my @classes = (); | |
| 46 | my @l7rules = (); | |
| 47 | my @portrules = (); | |
| 48 | my @tosrules = (); | |
| 49 | my @tmpline = (); | |
| 50 | my @classline = (); | |
| 51 | my @l7ruleline = (); | |
| 52 | my @portruleline = (); | |
| 53 | my @tosruleline = (); | |
| 54 | my @proto = (); | |
| 55 | my %selected= (); | |
| 56 | my @checked = (); | |
| 57 | my $classfile = "/var/ipfire/qos/classes"; | |
| 58 | my $level7file = "/var/ipfire/qos/level7config"; | |
| 59 | my $portfile = "/var/ipfire/qos/portconfig"; | |
| 60 | my $tosfile = "/var/ipfire/qos/tosconfig"; | |
| 61 | &General::readhash("${General::swroot}/ethernet/settings", \%netsettings); | |
| 62 | ||
| 63 | $qossettings{'ENABLED'} = 'off'; | |
| 64 | $qossettings{'EDIT'} = 'no'; | |
| 65 | $qossettings{'OUT_SPD'} = ''; | |
| 66 | $qossettings{'INC_SPD'} = ''; | |
| 67 | $qossettings{'DEF_OUT_SPD'} = ''; | |
| 68 | $qossettings{'DEF_INC_SPD'} = ''; | |
| 69 | $qossettings{'DEFCLASS_INC'} = ''; | |
| 70 | $qossettings{'DEFCLASS_OUT'} = ''; | |
| 71 | $qossettings{'RED_DEV'} = 'ppp0'; | |
| 72 | $qossettings{'IMQ_DEV'} = 'imq0'; | |
| 73 | $qossettings{'VALID'} = 'yes'; | |
| 74 | ### Values that have to be initialized | |
| 75 | $qossettings{'ACTION'} = ''; | |
| 76 | $qossettings{'ACTIONDEF'} = ''; | |
| 77 | $qossettings{'ACTIONBW'} = ''; | |
| 78 | $qossettings{'RED_DEV_SEL'} = ''; | |
| 79 | $qossettings{'IMQ_DEV_SEL'} = ''; | |
| 80 | $qossettings{'PRIO'} = ''; | |
| 81 | $qossettings{'SPD'} = ''; | |
| 82 | $qossettings{'CLASS'} = ''; | |
| 83 | $qossettings{'QPORT'} = ''; | |
| 84 | $qossettings{'DPORT'} = ''; | |
| 85 | $qossettings{'QIP'} = ''; | |
| 86 | $qossettings{'DIP'} = ''; | |
| 87 | $qossettings{'PPROT'} = ''; | |
| 88 | $qossettings{'L7PROT'} = ''; | |
| 89 | $qossettings{'DEVICE'} = ''; | |
| 90 | $qossettings{'MINBWDTH'} = ''; | |
| 91 | $qossettings{'MAXBWDTH'} = ''; | |
| 92 | $qossettings{'BURST'} = ''; | |
| 93 | $qossettings{'CBURST'} = ''; | |
| 94 | $qossettings{'DOCLASS'} = ''; | |
| 95 | $qossettings{'DOLEVEL7'} = ''; | |
| 96 | $qossettings{'DOPORT'} = ''; | |
| 97 | $qossettings{'CLASS'} = ''; | |
| 98 | $qossettings{'CLASSPRFX'} = ''; | |
| 99 | $qossettings{'DEV'} = ''; | |
| 100 | $qossettings{'TOS'} = ''; | |
| 101 | $qossettings{'CAKE_PROFILE'} = 'conservative'; | |
| 102 | ||
| 103 | my %CAKE_PROFILES = ( | |
| 104 | "ethernet" => $Lang::tr{'cake profile ethernet 38'}, | |
| 105 | "ethernet ether-vlan" => $Lang::tr{'cake profile ethernet vlan 42'}, | |
| 106 | "raw" => $Lang::tr{'cake profile raw 0'}, | |
| 107 | "conservative" => $Lang::tr{'cake profile conservative 48'}, | |
| 108 | "docsis" => $Lang::tr{'cake profile docsis 18'}, | |
| 109 | "bridged-ptm" => $Lang::tr{'cake profile bridged-ptm 19'}, | |
| 110 | "pppoe-ptm" => $Lang::tr{'cake profile pppoe-ptm 27'}, | |
| 111 | "pppoe-llcsnap" => $Lang::tr{'cake profile pppoe-llcsnap 40'}, | |
| 112 | "pppoe-vcmux" => $Lang::tr{'cake profile pppoe-vcmux 32'}, | |
| 113 | "pppoa-llc" => $Lang::tr{'cake profile pppoa-llc 14'}, | |
| 114 | "pppoa-vcmux" => $Lang::tr{'cake profile pppoa-vcmux 10'}, | |
| 115 | "bridged-llcsnap" => $Lang::tr{'cake profile bridged-llcsnap 32'}, | |
| 116 | "bridged-vcmux" => $Lang::tr{'cake profile bridged-vcmux 24'}, | |
| 117 | "ipoa-llcsnap" => $Lang::tr{'cake profile ipoa-llcsnap 16'}, | |
| 118 | "ipoa-vcmux" => $Lang::tr{'cake profile ipoa-vcmux 8'}, | |
| 119 | ); | |
| 120 | ||
| 121 | &General::readhash("${General::swroot}/qos/settings", \%qossettings); | |
| 122 | &Header::getcgihash(\%qossettings); | |
| 123 | ||
| 124 | $qossettings{'RED_DEV'} = &General::get_red_interface(); | |
| 125 | ||
| 126 | my %color = (); | |
| 127 | my %mainsettings = (); | |
| 128 | &General::readhash("${General::swroot}/main/settings", \%mainsettings); | |
| 129 | &General::readhash("/srv/web/ipfire/html/themes/ipfire/include/colors.txt", \%color); | |
| 130 | ||
| 131 | $selected{'CAKE_PROFILE'} = (); | |
| 132 | foreach my $key (keys %CAKE_PROFILES) { | |
| 133 | $selected{'CAKE_PROFILE'}{$key} = ''; | |
| 134 | } | |
| 135 | $selected{'CAKE_PROFILE'}{$qossettings{'CAKE_PROFILE'}} = 'selected'; | |
| 136 | ||
| 137 | &Header::showhttpheaders(); | |
| 138 | ||
| 139 | &Header::openpage('QoS', 1, ''); | |
| 140 | &Header::openbigbox('100%', 'left', '', $errormessage); | |
| 141 | ||
| 142 | ############################################################################################################################ | |
| 143 | ############################################################################################################################ | |
| 144 | ||
| 145 | if ($qossettings{'DOCLASS'} eq $Lang::tr{'save'}) | |
| 146 | { | |
| 147 | &validclass(); | |
| 148 | &validminbwdth(); | |
| 149 | &validmaxbwdth(); | |
| 150 | if ( $qossettings{'VALID'} eq 'yes' ) { | |
| 151 | open( FILE, ">> $classfile" ) or die "Unable to write $classfile"; | |
| 152 | print FILE <<END | |
| 153 | $qossettings{'DEVICE'};$qossettings{'CLASS'};$qossettings{'PRIO'};$qossettings{'MINBWDTH'};$qossettings{'MAXBWDTH'};$qossettings{'BURST'};$qossettings{'CBURST'};$qossettings{'TOS'};$qossettings{'REMARK'}; | |
| 154 | END | |
| 155 | ; | |
| 156 | close FILE; | |
| 157 | } else { | |
| 158 | $qossettings{'ACTION'} = $Lang::tr{'parentclass add'}; | |
| 159 | } | |
| 160 | } | |
| 161 | elsif ($qossettings{'DOCLASS'} eq $Lang::tr{'edit'}) | |
| 162 | { | |
| 163 | open( FILE, "< $classfile" ) or die "Unable to read $classfile"; | |
| 164 | @classes = <FILE>; | |
| 165 | close FILE; | |
| 166 | open( FILE, "> $classfile" ) or die "Unable to write $classfile"; | |
| 167 | foreach $classentry (sort @classes) | |
| 168 | { | |
| 169 | @classline = split( /\;/, $classentry ); | |
| 170 | if ( $classline[1] ne $qossettings{'CLASS'} ) { | |
| 171 | print FILE $classentry; | |
| 172 | } else { | |
| 173 | $qossettings{'DEVICE'} = $classline[0]; | |
| 174 | $qossettings{'PRIO'} = $classline[2]; | |
| 175 | $qossettings{'MINBWDTH'} = $classline[3]; | |
| 176 | $qossettings{'MAXBWDTH'} = $classline[4]; | |
| 177 | $qossettings{'BURST'} = $classline[5]; | |
| 178 | $qossettings{'CBURST'} = $classline[6]; | |
| 179 | $qossettings{'TOS'} = $classline[7]; | |
| 180 | $qossettings{'REMARK'} = $classline[8]; | |
| 181 | $qossettings{'EDIT'} = 'yes'; | |
| 182 | } | |
| 183 | } | |
| 184 | close FILE; | |
| 185 | &parentclass(); | |
| 186 | &Header::closebigbox(); | |
| 187 | &Header::closepage(); | |
| 188 | exit | |
| 189 | } | |
| 190 | elsif ($qossettings{'DOCLASS'} eq $Lang::tr{'delete'}) | |
| 191 | { | |
| 192 | open( FILE, "< $classfile" ) or die "Unable to read $classfile"; | |
| 193 | @tmp = <FILE>; | |
| 194 | close FILE; | |
| 195 | open( FILE, "> $classfile" ) or die "Unable to write $classfile"; | |
| 196 | foreach $classentry (sort @tmp) | |
| 197 | { | |
| 198 | @tmpline = split( /\;/, $classentry ); | |
| 199 | if ( $tmpline[1] ne $qossettings{'CLASS'} ) | |
| 200 | { | |
| 201 | print FILE $classentry; | |
| 202 | } | |
| 203 | } | |
| 204 | close FILE; | |
| 205 | $message = "$Lang::tr{'Class'} $qossettings{'CLASS'} $Lang::tr{'Class was deleted'}"; | |
| 206 | } | |
| 207 | ||
| 208 | ############################################################################################################################ | |
| 209 | ############################################################################################################################ | |
| 210 | ||
| 211 | if ($qossettings{'DOLEVEL7'} eq $Lang::tr{'save'}) | |
| 212 | { | |
| 213 | if ( $qossettings{'QIP'} ne '' ) { | |
| 214 | if ((!&General::validipandmask($qossettings{'QIP'})) && (!&General::validip($qossettings{'QIP'}))) { | |
| 215 | $qossettings{'VALID'} = 'no'; | |
| 216 | $message = $Lang::tr{'The source IP address is invalid.'}; | |
| 217 | } | |
| 218 | } | |
| 219 | if ( $qossettings{'DIP'} ne '' ) { | |
| 220 | if ((!&General::validipandmask($qossettings{'DIP'})) && (!&General::validip($qossettings{'DIP'}))) { | |
| 221 | $qossettings{'VALID'} = 'no'; | |
| 222 | $message = $Lang::tr{'The destination IP address is invalid.'}; | |
| 223 | } | |
| 224 | } | |
| 225 | if ($qossettings{'CLASS'} >= 100 && $qossettings{'CLASS'} < 121) { | |
| 226 | $qossettings{'DEVICE'} = $qossettings{'RED_DEV'}; | |
| 227 | } elsif ($qossettings{'CLASS'} >= 1000 && $qossettings{'CLASS'} < 1021) { | |
| 228 | $qossettings{'DEVICE'} = $qossettings{'RED_DEV'}; | |
| 229 | } elsif ($qossettings{'CLASS'} >= 200 && $qossettings{'CLASS'} < 221) { | |
| 230 | $qossettings{'DEVICE'} = $qossettings{'IMQ_DEV'}; | |
| 231 | } elsif ($qossettings{'CLASS'} >= 2000 && $qossettings{'CLASS'} < 2021) { | |
| 232 | $qossettings{'DEVICE'} = $qossettings{'IMQ_DEV'}; | |
| 233 | } | |
| 234 | if ( $qossettings{'VALID'} eq 'yes' ) { | |
| 235 | open( FILE, ">> $level7file" ) or die "Unable to write $level7file"; | |
| 236 | print FILE <<END | |
| 237 | $qossettings{'CLASS'};$qossettings{'DEVICE'};$qossettings{'L7PROT'};$qossettings{'QIP'};$qossettings{'DIP'}; | |
| 238 | END | |
| 239 | ; | |
| 240 | close FILE; | |
| 241 | } else { | |
| 242 | $qossettings{'ACTION'} = $Lang::tr{'Add Level7 rule'}; | |
| 243 | } | |
| 244 | } elsif ($qossettings{'DOLEVEL7'} eq $Lang::tr{'delete'}) | |
| 245 | { | |
| 246 | open( FILE, "< $level7file" ) or die "Unable to read $level7file"; | |
| 247 | @l7rules = <FILE>; | |
| 248 | close FILE; | |
| 249 | &General::system("rm", "$level7file"); | |
| 250 | foreach $l7ruleentry (sort @l7rules) | |
| 251 | { | |
| 252 | @l7ruleline = split( /\;/, $l7ruleentry ); | |
| 253 | if ( ($l7ruleline[0] eq $qossettings{'CLASS'}) && ($l7ruleline[2] eq $qossettings{'L7PROT'})) | |
| 254 | {$message = "$Lang::tr{'Level7 Rule'} ($qossettings{'CLASS'} - $qossettings{'L7PROT'}) $Lang::tr{'was deleted'}.";} | |
| 255 | else | |
| 256 | { open( FILE, ">> $level7file" ) or die "Unable to read $level7file"; | |
| 257 | print FILE $l7ruleentry; | |
| 258 | close FILE; | |
| 259 | } | |
| 260 | } | |
| 261 | open( FILE, "< $level7file" ) or &General::system("touch", "$level7file");close FILE; | |
| 262 | } elsif ($qossettings{'DOLEVEL7'} eq $Lang::tr{'edit'}) | |
| 263 | { | |
| 264 | open( FILE, "< $level7file" ) or die "Unable to read $level7file"; | |
| 265 | @l7rules = <FILE>; | |
| 266 | close FILE; | |
| 267 | &General::system("rm", "$level7file"); | |
| 268 | foreach $l7ruleentry (sort @l7rules) | |
| 269 | { | |
| 270 | @l7ruleline = split( /\;/, $l7ruleentry ); | |
| 271 | if ( ($l7ruleline[0] eq $qossettings{'CLASS'}) && ($l7ruleline[2] eq $qossettings{'L7PROT'})) | |
| 272 | {$qossettings{'QIP'} = $l7ruleline[3];$qossettings{'DIP'} = $l7ruleline[4];} | |
| 273 | else { | |
| 274 | open( FILE, ">> $level7file" ) or die "Unable to write $level7file"; | |
| 275 | print FILE $l7ruleentry; | |
| 276 | close FILE; | |
| 277 | } | |
| 278 | } | |
| 279 | &level7rule; | |
| 280 | open( FILE, "< $level7file" ) or &General::system("touch", "$level7file");close FILE; | |
| 281 | } | |
| 282 | ||
| 283 | ############################################################################################################################ | |
| 284 | ############################################################################################################################ | |
| 285 | ||
| 286 | if ($qossettings{'DOPORT'} eq $Lang::tr{'save'}) | |
| 287 | { | |
| 288 | if ( $qossettings{'QIP'} ne '' ) { | |
| 289 | if ((!&General::validipandmask($qossettings{'QIP'})) && (!&General::validip($qossettings{'QIP'}))) { | |
| 290 | $qossettings{'VALID'} = 'no'; | |
| 291 | $message = $Lang::tr{'The source IP address is invalid.'}; | |
| 292 | } | |
| 293 | } | |
| 294 | if ( $qossettings{'DIP'} ne '' ) { | |
| 295 | if ((!&General::validipandmask($qossettings{'DIP'})) && (!&General::validip($qossettings{'DIP'}))) { | |
| 296 | $qossettings{'VALID'} = 'no'; | |
| 297 | $message = $Lang::tr{'The destination IP address is invalid.'}; | |
| 298 | } | |
| 299 | } | |
| 300 | if ($qossettings{'CLASS'} >= 100 && $qossettings{'CLASS'} < 121) { | |
| 301 | $qossettings{'DEVICE'} = $qossettings{'RED_DEV'}; | |
| 302 | } elsif ($qossettings{'CLASS'} >= 1000 && $qossettings{'CLASS'} < 1021) { | |
| 303 | $qossettings{'DEVICE'} = $qossettings{'RED_DEV'}; | |
| 304 | } elsif ($qossettings{'CLASS'} >= 200 && $qossettings{'CLASS'} < 221) { | |
| 305 | $qossettings{'DEVICE'} = $qossettings{'IMQ_DEV'}; | |
| 306 | } elsif ($qossettings{'CLASS'} >= 2000 && $qossettings{'CLASS'} < 2021) { | |
| 307 | $qossettings{'DEVICE'} = $qossettings{'IMQ_DEV'}; | |
| 308 | } | |
| 309 | if ( $qossettings{'VALID'} eq 'yes' ) { | |
| 310 | open( FILE, ">> $portfile" ) or die "Unable to write $portfile"; | |
| 311 | print FILE <<END | |
| 312 | $qossettings{'CLASS'};$qossettings{'DEVICE'};$qossettings{'PPROT'};$qossettings{'QIP'};$qossettings{'QPORT'};$qossettings{'DIP'};$qossettings{'DPORT'}; | |
| 313 | END | |
| 314 | ; | |
| 315 | close FILE; | |
| 316 | } else { | |
| 317 | $qossettings{'ACTION'} = $Lang::tr{'Add Port Rule'}; | |
| 318 | } | |
| 319 | } elsif ($qossettings{'DOPORT'} eq $Lang::tr{'delete'}) | |
| 320 | { | |
| 321 | open( FILE, "< $portfile" ) or die "Unable to read $portfile"; | |
| 322 | @portrules = <FILE>; | |
| 323 | close FILE; | |
| 324 | open( FILE, "> $portfile" ) or die "Unable to read $portfile"; | |
| 325 | foreach $portruleentry (sort @portrules) | |
| 326 | { | |
| 327 | @portruleline = split( /\;/, $portruleentry ); | |
| 328 | unless ( ($portruleline[0] eq $qossettings{'CLASS'}) && ($portruleline[2] eq $qossettings{'PPROT'}) && ($portruleline[3] eq $qossettings{'QIP'}) && ($portruleline[4] eq $qossettings{'QPORT'}) && ($portruleline[5] eq $qossettings{'DIP'}) && ($portruleline[6] eq $qossettings{'DPORT'})) | |
| 329 | { | |
| 330 | print FILE $portruleentry; | |
| 331 | } | |
| 332 | } | |
| 333 | close FILE; | |
| 334 | $message = "$Lang::tr{'Port Rule'} ($qossettings{'CLASS'} - $qossettings{'PPROT'}) $Lang::tr{'was deleted'}."; | |
| 335 | } elsif ($qossettings{'DOPORT'} eq $Lang::tr{'edit'}) | |
| 336 | { | |
| 337 | open( FILE, "< $portfile" ) or die "Unable to read $portfile"; | |
| 338 | @portrules = <FILE>; | |
| 339 | close FILE; | |
| 340 | &General::system("rm", "$portfile"); | |
| 341 | foreach $portruleentry (sort @portrules) | |
| 342 | { | |
| 343 | @portruleline = split( /\;/, $portruleentry ); | |
| 344 | if ( ($portruleline[0] eq $qossettings{'CLASS'}) && ($portruleline[2] eq $qossettings{'PPROT'}) && ($portruleline[3] eq $qossettings{'QIP'}) && ($portruleline[4] eq $qossettings{'QPORT'}) && ($portruleline[5] eq $qossettings{'DIP'}) && ($portruleline[6] eq $qossettings{'DPORT'})) | |
| 345 | {$qossettings{'CLASS'}=$portruleline[0];$qossettings{'PPROT'}=$portruleline[2];$qossettings{'QIP'}=$portruleline[3];$qossettings{'QPORT'}=$portruleline[4];$qossettings{'DIP'}=$portruleline[5];$qossettings{'DPORT'}=$portruleline[6];} | |
| 346 | else { | |
| 347 | open( FILE, ">> $portfile" ) or die "Unable to write $portfile"; | |
| 348 | print FILE $portruleentry; | |
| 349 | close FILE; | |
| 350 | } | |
| 351 | } | |
| 352 | &portrule; | |
| 353 | open( FILE, "< $portfile" ) or &General::system("touch", "$portfile");close FILE; | |
| 354 | } | |
| 355 | ||
| 356 | ############################################################################################################################ | |
| 357 | ############################################################################################################################ | |
| 358 | ||
| 359 | if ($qossettings{'DOTOS'} eq $Lang::tr{'save'}) | |
| 360 | { | |
| 361 | if ($qossettings{'CLASS'} >= 100 && $qossettings{'CLASS'} < 121) { | |
| 362 | $qossettings{'DEVICE'} = $qossettings{'RED_DEV'}; | |
| 363 | } elsif ($qossettings{'CLASS'} >= 1000 && $qossettings{'CLASS'} < 1021) { | |
| 364 | $qossettings{'DEVICE'} = $qossettings{'RED_DEV'}; | |
| 365 | } elsif ($qossettings{'CLASS'} >= 200 && $qossettings{'CLASS'} < 221) { | |
| 366 | $qossettings{'DEVICE'} = $qossettings{'IMQ_DEV'}; | |
| 367 | } elsif ($qossettings{'CLASS'} >= 2000 && $qossettings{'CLASS'} < 2021) { | |
| 368 | $qossettings{'DEVICE'} = $qossettings{'IMQ_DEV'}; | |
| 369 | } | |
| 370 | open( FILE, ">> $tosfile" ) or die "Unable to write $tosfile"; | |
| 371 | print FILE <<END | |
| 372 | $qossettings{'CLASS'};$qossettings{'DEVICE'};$qossettings{'TOS'}; | |
| 373 | END | |
| 374 | ; | |
| 375 | close FILE; | |
| 376 | } | |
| 377 | elsif ($qossettings{'DOTOS'} eq $Lang::tr{'delete'}) | |
| 378 | { | |
| 379 | open( FILE, "< $tosfile" ) or die "Unable to read $tosfile"; | |
| 380 | @tosrules = <FILE>; | |
| 381 | close FILE; | |
| 382 | open( FILE, "> $tosfile" ) or die "Unable to read $tosfile"; | |
| 383 | foreach $tosruleentry (sort @tosrules) | |
| 384 | { | |
| 385 | @tosruleline = split( /\;/, $tosruleentry ); | |
| 386 | unless ( ($tosruleline[0] eq $qossettings{'CLASS'}) && ($tosruleline[2] eq $qossettings{'TOS'})) | |
| 387 | { | |
| 388 | print FILE $tosruleentry; | |
| 389 | } | |
| 390 | } | |
| 391 | close FILE; | |
| 392 | $message = "$Lang::tr{'TOS Rule'} ($qossettings{'CLASS'} - $qossettings{'TOS'}) $Lang::tr{'was deleted'}."; | |
| 393 | } elsif ($qossettings{'DOTOS'} eq $Lang::tr{'edit'}) | |
| 394 | { | |
| 395 | open( FILE, "< $tosfile" ) or die "Unable to read $tosfile"; | |
| 396 | @tosrules = <FILE>; | |
| 397 | close FILE; | |
| 398 | open( FILE, "> $tosfile" ) or die "Unable to write $tosfile"; | |
| 399 | foreach $tosruleentry (sort @tosrules) | |
| 400 | { | |
| 401 | @tosruleline = split( /\;/, $tosruleentry ); | |
| 402 | if (( $tosruleline[0] eq $qossettings{'CLASS'} ) && ( $tosruleline[2] eq $qossettings{'TOS'} )) { | |
| 403 | $qossettings{'DEVICE'} = $tosruleline[1]; | |
| 404 | $qossettings{'CLASS'} = $tosruleline[0]; | |
| 405 | $qossettings{'TOS'} = $tosruleline[2]; | |
| 406 | $qossettings{'EDIT'} = 'yes'; | |
| 407 | } else { | |
| 408 | print FILE $tosruleentry; | |
| 409 | } | |
| 410 | } | |
| 411 | close FILE; | |
| 412 | &tosrule(); | |
| 413 | &Header::closebigbox(); | |
| 414 | &Header::closepage(); | |
| 415 | exit | |
| 416 | } | |
| 417 | ||
| 418 | ############################################################################################################################ | |
| 419 | ############################################################################################################################ | |
| 420 | ||
| 421 | if ($qossettings{'ACTION'} eq $Lang::tr{'start'}) | |
| 422 | { | |
| 423 | $qossettings{'ENABLED'} = 'on'; | |
| 424 | &General::writehash("${General::swroot}/qos/settings", \%qossettings); | |
| 425 | &General::system("/usr/local/bin/qosctrl", "generate"); | |
| 426 | &General::system("/usr/local/bin/qosctrl", "start"); | |
| 427 | &General::system("logger", "-t", "ipfire", "QoS started"); | |
| 428 | } | |
| 429 | elsif ($qossettings{'ACTION'} eq $Lang::tr{'stop'}) | |
| 430 | { | |
| 431 | $qossettings{'ENABLED'} = 'off'; | |
| 432 | &General::writehash("${General::swroot}/qos/settings", \%qossettings); | |
| 433 | &General::system("/usr/local/bin/qosctrl", "stop"); | |
| 434 | &General::system("/usr/local/bin/qosctrl", "generate"); | |
| 435 | &General::system("logger", "-t", "ipfire", "QoS stopped"); | |
| 436 | } | |
| 437 | elsif ($qossettings{'ACTION'} eq $Lang::tr{'restart'}) | |
| 438 | { | |
| 439 | if ($qossettings{'ENABLED'} eq 'on'){ | |
| 440 | &General::system("/usr/local/bin/qosctrl", "stop"); | |
| 441 | &General::system("/usr/local/bin/qosctrl", "generate"); | |
| 442 | &General::system("/usr/local/bin/qosctrl", "start"); | |
| 443 | &General::system("logger", "-t", "ipfire", "QoS restarted"); | |
| 444 | } | |
| 445 | } | |
| 446 | elsif ($qossettings{'ACTION'} eq $Lang::tr{'save'}) | |
| 447 | { | |
| 448 | if ($qossettings{'DEF_INC_SPD'} eq '') { | |
| 449 | $qossettings{'DEF_INC_SPD'} = int($qossettings{'INC_SPD'} * 0.9); | |
| 450 | } | |
| 451 | if ($qossettings{'DEF_OUT_SPD'} eq '') { | |
| 452 | $qossettings{'DEF_OUT_SPD'} = int($qossettings{'OUT_SPD'} * 0.9); | |
| 453 | } | |
| 454 | &General::writehash("${General::swroot}/qos/settings", \%qossettings); | |
| 455 | } | |
| 456 | elsif ($qossettings{'ACTION'} eq $Lang::tr{'template'} ) | |
| 457 | { | |
| 458 | if (($qossettings{'OUT_SPD'} > 0) && ($qossettings{'INC_SPD'} > 0)) { | |
| 459 | my @UP; | |
| 460 | #print "UP<br />"; | |
| 461 | for(my $i = 1; $i <= 10; $i++) { | |
| 462 | $UP[$i] = int($qossettings{'OUT_SPD'} / $i ); | |
| 463 | #print $i."=".$UP[$i]." "; | |
| 464 | } | |
| 465 | my @DOWN; | |
| 466 | #print "<br /><br />Down<br />"; | |
| 467 | for(my $i = 1; $i <= 20; $i++) { | |
| 468 | $DOWN[$i] = int($qossettings{'INC_SPD'} / $i); | |
| 469 | #print $i."=".$DOWN[$i]." "; | |
| 470 | } | |
| 471 | open( FILE, "> $classfile" ) or die "Unable to write $classfile"; | |
| 472 | print FILE <<END | |
| 473 | imq0;200;1;$DOWN[20];$DOWN[1];;;8;VoIP; | |
| 474 | imq0;203;4;$DOWN[20];$DOWN[1];;;0;VPN; | |
| 475 | imq0;204;5;$DOWN[20];$DOWN[1];;;8;Webtraffic; | |
| 476 | imq0;210;6;1;$DOWN[1];;;0;Default; | |
| 477 | imq0;220;7;1;$DOWN[1];;;1;P2P; | |
| 478 | $qossettings{'RED_DEV'};101;1;$UP[10];$UP[1];;;8;ACKs; | |
| 479 | $qossettings{'RED_DEV'};102;2;$UP[10];$UP[1];;;8;VoIP; | |
| 480 | $qossettings{'RED_DEV'};103;4;$UP[10];$UP[1];;;2;VPN; | |
| 481 | $qossettings{'RED_DEV'};104;5;$UP[10];$UP[1];;;8;Webtraffic; | |
| 482 | $qossettings{'RED_DEV'};110;6;1;$UP[1];;;0;Default; | |
| 483 | $qossettings{'RED_DEV'};120;7;1;$UP[1];;;1;P2P; | |
| 484 | END | |
| 485 | ; | |
| 486 | close FILE; | |
| 487 | open( FILE, "> $level7file" ) or die "Unable to write $level7file"; | |
| 488 | print FILE <<END | |
| 489 | 102;$qossettings{'RED_DEV'};dns;;; | |
| 490 | 102;$qossettings{'RED_DEV'};rtp;;; | |
| 491 | 102;$qossettings{'RED_DEV'};skypetoskype;;; | |
| 492 | 103;$qossettings{'RED_DEV'};ssh;;; | |
| 493 | 103;$qossettings{'RED_DEV'};rdp;;; | |
| 494 | 104;$qossettings{'RED_DEV'};http;;; | |
| 495 | 104;$qossettings{'RED_DEV'};ssl;;; | |
| 496 | 104;$qossettings{'RED_DEV'};pop3;;; | |
| 497 | 120;$qossettings{'RED_DEV'};applejuice;;; | |
| 498 | 120;$qossettings{'RED_DEV'};bittorrent;;; | |
| 499 | 200;imq0;rtp;;; | |
| 500 | 200;imq0;skypetoskype;;; | |
| 501 | 203;imq0;ssh;;; | |
| 502 | 203;imq0;rdp;;; | |
| 503 | 204;imq0;http;;; | |
| 504 | 204;imq0;pop3;;; | |
| 505 | 204;imq0;ssl;;; | |
| 506 | 220;imq0;applejuice;;; | |
| 507 | 220;imq0;bittorrent;;; | |
| 508 | END | |
| 509 | ; | |
| 510 | close FILE; | |
| 511 | open( FILE, "> $portfile" ) or die "Unable to write $portfile"; | |
| 512 | print FILE <<END | |
| 513 | 101;$qossettings{'RED_DEV'};icmp;;;;; | |
| 514 | 102;$qossettings{'RED_DEV'};tcp;;;;53; | |
| 515 | 102;$qossettings{'RED_DEV'};udp;;;;53; | |
| 516 | 103;$qossettings{'RED_DEV'};esp;;;;; | |
| 517 | 103;$qossettings{'RED_DEV'};tcp;;1194;;; | |
| 518 | 103;$qossettings{'RED_DEV'};udp;;1194;;; | |
| 519 | 103;$qossettings{'RED_DEV'};tcp;;;;1194; | |
| 520 | 103;$qossettings{'RED_DEV'};udp;;;;1194; | |
| 521 | 103;$qossettings{'RED_DEV'};udp;;4500;;4500; | |
| 522 | 103;$qossettings{'RED_DEV'};udp;;500;;500; | |
| 523 | 104;$qossettings{'RED_DEV'};tcp;;;;80; | |
| 524 | 200;imq0;icmp;;;;; | |
| 525 | 203;imq0;esp;;;;; | |
| 526 | 203;imq0;tcp;;;;1194; | |
| 527 | 203;imq0;udp;;;;1194; | |
| 528 | 203;imq0;tcp;;1194;;; | |
| 529 | 203;imq0;udp;;1194;;; | |
| 530 | 203;imq0;udp;;4500;;4500; | |
| 531 | 203;imq0;udp;;500;;500; | |
| 532 | 204;imq0;tcp;;80;;; | |
| 533 | END | |
| 534 | ; | |
| 535 | close FILE; | |
| 536 | if ($qossettings{'DEF_INC_SPD'} eq '') { | |
| 537 | $qossettings{'DEF_INC_SPD'} = int($qossettings{'INC_SPD'} * 0.9); | |
| 538 | } | |
| 539 | if ($qossettings{'DEF_OUT_SPD'} eq '') { | |
| 540 | $qossettings{'DEF_OUT_SPD'} = int($qossettings{'OUT_SPD'} * 0.9); | |
| 541 | } | |
| 542 | $qossettings{'DEFCLASS_INC'} = "210"; | |
| 543 | $qossettings{'DEFCLASS_OUT'} = "110"; | |
| 544 | $qossettings{'ENABLED'} = 'on'; | |
| 545 | &General::writehash("${General::swroot}/qos/settings", \%qossettings); | |
| 546 | &General::system("/usr/local/bin/qosctrl", "generate"); | |
| 547 | &General::system("/usr/local/bin/qosctrl", "start"); | |
| 548 | &General::system("logger", "-t", "ipfire", "QoS started"); | |
| 549 | } else { | |
| 550 | $message = $Lang::tr{'qos enter bandwidths'}; | |
| 551 | } | |
| 552 | } | |
| 553 | elsif ($qossettings{'ACTION'} eq $Lang::tr{'status'} ) | |
| 554 | { | |
| 555 | &Header::openbox('100%', 'left', 'QoS Status'); | |
| 556 | if ($qossettings{'ENABLED'} eq 'on'){ | |
| 557 | my $output = ""; | |
| 558 | my @output = &General::system_output("/usr/local/bin/qosctrl", "status"); | |
| 559 | $output = &Header::cleanhtml(join("", @output), "y"); | |
| 560 | print "<pre>$output</pre>\n"; | |
| 561 | } else { print "$Lang::tr{'QoS not enabled'}"; } | |
| 562 | &Header::closebox(); | |
| 563 | &Header::closebigbox(); | |
| 564 | &Header::closepage(); | |
| 565 | exit | |
| 566 | } | |
| 567 | elsif ($qossettings{'ACTION'} eq $Lang::tr{'parentclass add'} ) | |
| 568 | { | |
| 569 | &parentclass(); | |
| 570 | &Header::closebigbox(); | |
| 571 | &Header::closepage(); | |
| 572 | exit | |
| 573 | } | |
| 574 | elsif ($qossettings{'ACTION'} eq $Lang::tr{'Add Rule'}) | |
| 575 | { | |
| 576 | &Header::openbox('100%', 'center', $Lang::tr{'Add Rule'}); | |
| 577 | print <<END | |
| 578 | <table> | |
| 579 | <tr><td align='center'>$Lang::tr{'Choose Rule'} | |
| 580 | <tr><td align='center'> | |
| 581 | <input type="button" onClick="swapVisibility('l7rule')" value='$Lang::tr{'Level7 Rule'}' /> | |
| 582 | <input type="button" onClick="swapVisibility('portrule')" value='$Lang::tr{'Port Rule'}' /> | |
| 583 | <input type="button" onClick="swapVisibility('tosrule')" value='$Lang::tr{'TOS rule'}' /> | |
| 584 | </table> | |
| 585 | END | |
| 586 | ; | |
| 587 | &Header::closebox(); | |
| 588 | print <<END | |
| 589 | <div id='l7rule' style='display: none'> | |
| 590 | END | |
| 591 | ; | |
| 592 | &level7rule(); | |
| 593 | print <<END | |
| 594 | </div> | |
| 595 | <div id='portrule' style='display: none'> | |
| 596 | END | |
| 597 | ; | |
| 598 | &portrule(); | |
| 599 | print <<END | |
| 600 | </div> | |
| 601 | <div id='tosrule' style='display: none'> | |
| 602 | END | |
| 603 | ; | |
| 604 | &tosrule(); | |
| 605 | print <<END | |
| 606 | </div> | |
| 607 | END | |
| 608 | ; | |
| 609 | &Header::closebigbox(); | |
| 610 | &Header::closepage(); | |
| 611 | exit | |
| 612 | } | |
| 613 | if ($qossettings{'ACTIONBW'} eq "$Lang::tr{'modify'}" ) | |
| 614 | { | |
| 615 | &changebandwidth(); | |
| 616 | &Header::closebigbox(); | |
| 617 | &Header::closepage(); | |
| 618 | exit | |
| 619 | } | |
| 620 | if ($qossettings{'ACTIONDEF'} eq "$Lang::tr{'modify'}" ) | |
| 621 | { | |
| 622 | &changedefclasses(); | |
| 623 | &Header::closebigbox(); | |
| 624 | &Header::closepage(); | |
| 625 | exit | |
| 626 | } | |
| 627 | ||
| 628 | &General::readhash("${General::swroot}/qos/settings", \%qossettings); | |
| 629 | ||
| 630 | my $status = $Lang::tr{'stopped'}; | |
| 631 | my $statuscolor = '#993333'; | |
| 632 | if ( $qossettings{'ENABLED'} eq 'on' ) { | |
| 633 | $status = $Lang::tr{'running'}; | |
| 634 | $statuscolor = '#339933'; | |
| 635 | } | |
| 636 | ||
| 637 | if ( $netsettings{'RED_TYPE'} ne 'PPPOE' ) { | |
| 638 | $qossettings{'RED_DEV'} = $netsettings{'RED_DEV'}; | |
| 639 | } | |
| 640 | ||
| 641 | if ($errormessage) { | |
| 642 | &Header::openbox('100%', 'left', $Lang::tr{'error messages'}); | |
| 643 | print "<class name='base'>$errormessage\n"; | |
| 644 | print " </class>\n"; | |
| 645 | &Header::closebox(); | |
| 646 | } | |
| 647 | ||
| 648 | ############################################################################################################################ | |
| 649 | ############################################################################################################################ | |
| 650 | ||
| 651 | &Header::openbox('100%', 'center', ); | |
| 652 | ||
| 653 | print <<END | |
| 654 | <form method='post' action='$ENV{'SCRIPT_NAME'}'> | |
| 655 | <table width='100%'> | |
| 656 | END | |
| 657 | ; | |
| 658 | if ( $message ne "" ) { | |
| 659 | print "<tr><td colspan='2' align='center'><font color='red'>$message</font></tr>"; | |
| 660 | } | |
| 661 | print <<END | |
| 662 | <tr><td width='50%' align='left'><b>Quality of Service:</b></td> | |
| 663 | <td width='50%' align='center' bgcolor='$statuscolor'><font color='white'>$status</font></td></tr> | |
| 664 | <tr> | |
| 665 | <td colspan='2'><br></td> | |
| 666 | </tr> | |
| 667 | <tr><td width='100%' align='right' colspan='2'> | |
| 668 | <input type='submit' name='ACTION' value="$Lang::tr{'start'}"> | |
| 669 | <input type='submit' name='ACTION' value="$Lang::tr{'stop'}"> | |
| 670 | <input type='submit' name='ACTION' value="$Lang::tr{'restart'}" ></td></tr></table></form> | |
| 671 | END | |
| 672 | ; | |
| 673 | if (($qossettings{'OUT_SPD'} ne '') && ($qossettings{'INC_SPD'} ne '')) { | |
| 674 | print <<END | |
| 675 | <form method='post' action='$ENV{'SCRIPT_NAME'}'> | |
| 676 | <table width='100%'> | |
| 677 | <tr><td colspan='3'> | |
| 678 | <tr><td width='50%' align='right'>$Lang::tr{'downlink speed'}: <td width='30%' align='left'>$qossettings{'INC_SPD'} | |
| 679 | <td width='20%' rowspan='2' align='center' valign='middle'><input type='submit' name='ACTIONBW' value='$Lang::tr{'modify'}' /> | |
| 680 | <tr><td width='50%' align='right'>$Lang::tr{'uplink speed'}: <td width='30%' align='left'>$qossettings{'OUT_SPD'} | |
| 681 | </table></form> | |
| 682 | END | |
| 683 | ; | |
| 684 | } | |
| 685 | if (($qossettings{'DEFCLASS_OUT'} ne '') && ($qossettings{'DEFCLASS_INC'} ne '')) { | |
| 686 | print <<END | |
| 687 | <form method='post' action='$ENV{'SCRIPT_NAME'}'> | |
| 688 | <table width='100%'> | |
| 689 | <tr><td colspan='3'><hr /> | |
| 690 | <tr><td width='50%' align='right'>$Lang::tr{'downlink std class'}: <td width='30%' align='left'>$qossettings{'DEFCLASS_INC'} | |
| 691 | <td width='20%' rowspan='3' align='center' valign='middle'><input type='submit' name='ACTIONDEF' value='$Lang::tr{'modify'}' /> | |
| 692 | <tr><td width='50%' align='right'>$Lang::tr{'uplink std class'}: <td width='30%' align='left'>$qossettings{'DEFCLASS_OUT'} | |
| 693 | <tr><td colspan='3' width='100%'><hr /> | |
| 694 | <tr><td colspan='3' width='100%' align='center'> | |
| 695 | </table> | |
| 696 | </form> | |
| 697 | <form method='post' action='$ENV{'SCRIPT_NAME'}'> | |
| 698 | <table width='100%' border='0'> | |
| 699 | <tr><td width='100%' align='center'> | |
| 700 | <input type='submit' name='ACTION' value='$Lang::tr{'parentclass add'}' /> | |
| 701 | <input type='submit' name='ACTION' value='$Lang::tr{'status'}' /> | |
| 702 | </td></tr></table> | |
| 703 | </form> | |
| 704 | END | |
| 705 | ; | |
| 706 | } | |
| 707 | &Header::closebox(); | |
| 708 | ||
| 709 | if ( ($qossettings{'OUT_SPD'} eq '') || ($qossettings{'INC_SPD'} eq '') ) { | |
| 710 | &changebandwidth(); | |
| 711 | &Header::closebigbox(); | |
| 712 | &Header::closepage(); | |
| 713 | exit | |
| 714 | } | |
| 715 | ||
| 716 | if ( ($qossettings{'DEFCLASS_INC'} eq '') || ($qossettings{'DEFCLASS_OUT'} eq '') ) { | |
| 717 | &changedefclasses(); | |
| 718 | &Header::closebigbox(); | |
| 719 | &Header::closepage(); | |
| 720 | exit | |
| 721 | } | |
| 722 | ||
| 723 | &Header::openbox('100%', 'center', "$qossettings{'RED_DEV'} $Lang::tr{'graph'}, $Lang::tr{'uplink'}"); | |
| 724 | &Graphs::makegraphbox("qos.cgi",$qossettings{'RED_DEV'},"hour"); | |
| 725 | &Header::closebox(); | |
| 726 | &Header::openbox('100%', 'center', "$qossettings{'IMQ_DEV'} $Lang::tr{'graph'}, $Lang::tr{'downlink'}"); | |
| 727 | &Graphs::makegraphbox("qos.cgi",$qossettings{'IMQ_DEV'},"hour"); | |
| 728 | &Header::closebox(); | |
| 729 | ||
| 730 | &showclasses($qossettings{'RED_DEV'}); | |
| 731 | &showclasses($qossettings{'IMQ_DEV'}); | |
| 732 | ||
| 733 | &Header::closebigbox(); | |
| 734 | &Header::closepage(); | |
| 735 | ||
| 736 | ############################################################################################################################ | |
| 737 | ############################################################################################################################ | |
| 738 | ||
| 739 | sub changedefclasses { | |
| 740 | &Header::openbox('100%', 'center', $Lang::tr{'std classes'}); | |
| 741 | print <<END | |
| 742 | <form method='post' action='$ENV{'SCRIPT_NAME'}'> | |
| 743 | <table width='100%'> | |
| 744 | <tr><td width='100%' colspan='3'>$Lang::tr{'no filter pass'} | |
| 745 | <tr><td width='33%' align='right'>$Lang::tr{'download'}:<td width='33%' align='left'><select name='DEFCLASS_INC'> | |
| 746 | END | |
| 747 | ; | |
| 748 | for ( $c = 200 ; $c <= 220 ; $c++ ) | |
| 749 | { | |
| 750 | if ( $qossettings{'DEFCLASS_INC'} ne $c ) | |
| 751 | { print "<option value='$c'>$c</option>\n"; } | |
| 752 | else { print "<option selected value='$c'>$c</option>\n"; } | |
| 753 | } | |
| 754 | print <<END | |
| 755 | </select><td width='33%' align='center'> | |
| 756 | <tr><td width='33%' align='right'>$Lang::tr{'upload'}:<td width='33%' align='left'><select name='DEFCLASS_OUT'> | |
| 757 | END | |
| 758 | ; | |
| 759 | for ( $c = 100 ; $c <= 120 ; $c++ ) | |
| 760 | { | |
| 761 | if ( $qossettings{'DEFCLASS_OUT'} ne $c ) | |
| 762 | { print "<option value='$c'>$c</option>\n"; } | |
| 763 | else { print "<option selected value='$c'>$c</option>\n"; } | |
| 764 | } | |
| 765 | print <<END | |
| 766 | </select><td width='33%' align='center'><input type='submit' name='ACTION' value="$Lang::tr{'save'}" /> | |
| 767 | </table> | |
| 768 | </form> | |
| 769 | END | |
| 770 | ; | |
| 771 | &Header::closebox(); | |
| 772 | } | |
| 773 | ||
| 774 | sub changebandwidth { | |
| 775 | &Header::openbox('100%', 'center', $Lang::tr{'bandwidthsettings'}); | |
| 776 | ||
| 777 | if ($qossettings{'ENABLED'} eq 'on') { | |
| 778 | print "$Lang::tr{'bandwidtherror'}"; | |
| 779 | print "<table width='100%'><tr><td align='center'><a href='/cgi-bin/qos.cgi'><img src='/images/back.png' alt='$Lang::tr{'back'}' title='$Lang::tr{'back'}' /></a></td></tr></table>"; | |
| 780 | } else { | |
| 781 | print <<END; | |
| 782 | <form method='post' action='$ENV{'SCRIPT_NAME'}'> | |
| 783 | <input type='hidden' name='DEF_OUT_SPD' value='' /><input type='hidden' name='DEF_INC_SPD' value='' /> | |
| 784 | <table width='100%'> | |
| 785 | <tr> | |
| 786 | <td width='100%' colspan='2'>$Lang::tr{'down and up speed'}</td> | |
| 787 | </tr> | |
| 788 | <tr> | |
| 789 | <td width='50%' align='right'>$Lang::tr{'downlink speed'}:</td> | |
| 790 | <td width='50%' align='left'> | |
| 791 | <input type='text' name='INC_SPD' maxlength='8' value="$qossettings{'INC_SPD'}" /> | |
| 792 | </td> | |
| 793 | </tr> | |
| 794 | <tr> | |
| 795 | <td width='50%' align='right'>$Lang::tr{'uplink speed'}:</td> | |
| 796 | <td width='50%' align='left'> | |
| 797 | <input type='text' name='OUT_SPD' maxlength='8' value="$qossettings{'OUT_SPD'}" /> | |
| 798 | </td> | |
| 799 | </tr> | |
| 800 | ||
| 801 | <tr> | |
| 802 | <td colspan="2"> </td> | |
| 803 | </tr> | |
| 804 | ||
| 805 | <tr> | |
| 806 | <td width='50%' align='right'>$Lang::tr{'link-layer encapsulation'}:</td> | |
| 807 | <td width='50%' align='left'> | |
| 808 | <select name="CAKE_PROFILE"> | |
| 809 | END | |
| 810 | ||
| 811 | foreach my $key (sort { $CAKE_PROFILES{$a} cmp $CAKE_PROFILES{$b} } keys %CAKE_PROFILES) { | |
| 812 | print <<END; | |
| 813 | <option value="$key" $selected{'CAKE_PROFILE'}{$key}>$CAKE_PROFILES{$key}</option> | |
| 814 | END | |
| 815 | } | |
| 816 | ||
| 817 | print <<END; | |
| 818 | </select> | |
| 819 | </td> | |
| 820 | </tr> | |
| 821 | ||
| 822 | <tr> | |
| 823 | <td colspan="2"> </td> | |
| 824 | </tr> | |
| 825 | ||
| 826 | <tr> | |
| 827 | <td width='100%' align='center' colspan="2"> | |
| 828 | <input type='submit' name='ACTION' value="$Lang::tr{'template'}" /> | |
| 829 | <input type='submit' name='ACTION' value="$Lang::tr{'save'}" /> | |
| 830 | <input type='reset' name='ACTION' value="$Lang::tr{'reset'}" /> | |
| 831 | </td> | |
| 832 | </tr> | |
| 833 | </table> | |
| 834 | </form> | |
| 835 | <font color='red'>$Lang::tr{'template warning'}</font> | |
| 836 | END | |
| 837 | } | |
| 838 | ||
| 839 | &Header::closebox(); | |
| 840 | } | |
| 841 | ||
| 842 | sub parentclass { | |
| 843 | &Header::openbox('100%', 'center', $Lang::tr{'parentclass'}); | |
| 844 | print <<END | |
| 845 | <form method='post' action='$ENV{'SCRIPT_NAME'}'> | |
| 846 | <table width='100%'> | |
| 847 | END | |
| 848 | ; | |
| 849 | if ( $message ne "" ) { | |
| 850 | print "<tr><td colspan='3' align='center'>$message"; | |
| 851 | } | |
| 852 | if ( $qossettings{'EDIT'} eq 'yes' ) { | |
| 853 | print "<input type='hidden' name='CLASS' value='$qossettings{'CLASS'}' />"; | |
| 854 | print "<input type='hidden' name='DEVICE' value='$qossettings{'DEVICE'}' />"; | |
| 855 | } | |
| 856 | print <<END | |
| 857 | <tr><td width='100%' colspan='3'>$Lang::tr{'enter data'} | |
| 858 | <tr><td width='33%' align='right'>$Lang::tr{'interface'}: | |
| 859 | <td width='33%' align='left'> | |
| 860 | END | |
| 861 | ; | |
| 862 | if ( $qossettings{'EDIT'} eq 'yes' ) { | |
| 863 | print "<select name='DEVICE' disabled>"; | |
| 864 | } else { | |
| 865 | print "<select name='DEVICE'>"; | |
| 866 | } | |
| 867 | if ( $qossettings{'DEVICE'} eq $qossettings{'RED_DEV'} ) { | |
| 868 | $qossettings{'RED_DEV_SEL'} = 'selected'; | |
| 869 | } elsif ( $qossettings{'DEVICE'} eq $qossettings{'IMQ_DEV'} ) { | |
| 870 | $qossettings{'IMQ_DEV_SEL'} = 'selected'; | |
| 871 | } | |
| 872 | print <<END | |
| 873 | <option value='$qossettings{'RED_DEV'}' $qossettings{'RED_DEV_SEL'}>$qossettings{'RED_DEV'}</option> | |
| 874 | <option value='$qossettings{'IMQ_DEV'}' $qossettings{'IMQ_DEV_SEL'}>$qossettings{'IMQ_DEV'}</option></select> | |
| 875 | <td width='33%' align='center'> | |
| 876 | <tr><td width='33%' align='right'>$Lang::tr{'Class'}:<td width='33%' align='left'> | |
| 877 | END | |
| 878 | ; | |
| 879 | if ( $qossettings{'EDIT'} eq 'yes' ) { | |
| 880 | print "<select name='CLASS' disabled>"; | |
| 881 | } else { | |
| 882 | print "<select name='CLASS'>"; | |
| 883 | } | |
| 884 | for ( $c = 100 ; $c <= 120 ; $c++ ) | |
| 885 | { | |
| 886 | if ( $qossettings{'CLASS'} ne $c ) | |
| 887 | { print "<option value='$c'>$c</option>\n"; } | |
| 888 | else { print "<option selected value='$c'>$c</option>\n"; } | |
| 889 | } | |
| 890 | for ( $c = 200 ; $c <= 220 ; $c++ ) | |
| 891 | { | |
| 892 | if ( $qossettings{'CLASS'} ne $c ) | |
| 893 | { print "<option value='$c'>$c</option>\n"; } | |
| 894 | else { print "<option selected value='$c'>$c</option>\n"; } | |
| 895 | } | |
| 896 | print <<END | |
| 897 | </select> | |
| 898 | <td width='33%' align='center'> | |
| 899 | <tr><td width='33%' align='right'>$Lang::tr{'priority'}:<td width='33%' align='left'><select name='PRIO'> | |
| 900 | END | |
| 901 | ; | |
| 902 | for ( $c = 1 ; $c <= 7 ; $c++ ) | |
| 903 | { | |
| 904 | if ( $qossettings{'PRIO'} ne $c ) | |
| 905 | { print "<option value='$c'>$c</option>\n"; } | |
| 906 | else { print "<option selected value='$c'>$c</option>\n"; } | |
| 907 | } | |
| 908 | if ($qossettings{'MINBWDTH'} eq "") { $qossettings{'MINBWDTH'} = "1"; } | |
| 909 | print <<END | |
| 910 | </select> | |
| 911 | <td width='33%' align='center'> | |
| 912 | <tr><td width='33%' align='right'>$Lang::tr{'guaranteed bandwidth'}: | |
| 913 | <td width='33%' align='left'><input type='text' size='20' name='MINBWDTH' maxlength='8' required='1' value="$qossettings{'MINBWDTH'}" /> | |
| 914 | <td width='33%' align='center'> | |
| 915 | <tr><td width='33%' align='right'>$Lang::tr{'max bandwidth'} <img src='/blob.gif' alt='*' />: | |
| 916 | <td width='33%' align='left'><input type='text' size='20' name='MAXBWDTH' maxlength='8' required='1' value="$qossettings{'MAXBWDTH'}" /> | |
| 917 | <td width='33%' align='center'> | |
| 918 | <tr><td width='33%' align='right'>Burst: | |
| 919 | <td width='33%' align='left'><input type='text' size='20' name='BURST' maxlength='8' value="$qossettings{'BURST'}" /> | |
| 920 | <td width='33%' align='center'> | |
| 921 | <tr><td width='33%' align='right'>Ceilburst: | |
| 922 | <td width='33%' align='left'><input type='text' size='20' name='CBURST' maxlength='8' value="$qossettings{'CBURST'}" /> | |
| 923 | <td width='33%' align='center'> | |
| 924 | <tr><td width='33%' align='right'>$Lang::tr{'remark'}: | |
| 925 | <td width='66%' colspan='2' align='left'><input type='text' name='REMARK' size='40' maxlength='40' value="$qossettings{'REMARK'}" /> | |
| 926 | <tr><td width='33%' align='right'><img src='/blob.gif' alt='*' /> $Lang::tr{'required field'} | |
| 927 | <td width='33%' align='left'> | |
| 928 | <td width='33%' align='center'><input type='submit' name='DOCLASS' value='$Lang::tr{'save'}' /> <input type='reset' value='$Lang::tr{'reset'}' /> | |
| 929 | </table></form> | |
| 930 | END | |
| 931 | ; | |
| 932 | &Header::closebox(); | |
| 933 | } | |
| 934 | ||
| 935 | sub level7rule { | |
| 936 | &Header::openbox('100%', 'center', $Lang::tr{'Level7 Rule'}); | |
| 937 | print <<END | |
| 938 | <form method='post' action='$ENV{'SCRIPT_NAME'}'> | |
| 939 | <table width='100%'> | |
| 940 | END | |
| 941 | ; | |
| 942 | if ( $message ne "" ) { | |
| 943 | print "<tr><td colspan='3' align='center'><font color='red'>$message</font>"; | |
| 944 | } | |
| 945 | print <<END | |
| 946 | <tr><td colspan='3' width='100%'>$Lang::tr{'current class'}: $qossettings{'CLASS'} | |
| 947 | <tr><td width='100%' colspan='3'>$Lang::tr{'enter data'} | |
| 948 | <tr><td width='33%' align='right'>$Lang::tr{'protocol'}: | |
| 949 | <td width='33%' align='left'><select name='L7PROT'> | |
| 950 | END | |
| 951 | ; | |
| 952 | opendir( DIR, "/etc/l7-protocols/protocols" ); | |
| 953 | foreach $direntry ( sort readdir(DIR) ) | |
| 954 | { | |
| 955 | next if $direntry eq "."; | |
| 956 | next if $direntry eq ".."; | |
| 957 | next if -d "/etc/l7-protocols/protocols/$direntry"; | |
| 958 | @proto = split( /\./, $direntry ); | |
| 959 | if ( $proto[0] eq $qossettings{'L7PROT'} ) { | |
| 960 | print "<option value='$proto[0]' selected>$proto[0]</option>\n"; | |
| 961 | } else { | |
| 962 | print "<option value='$proto[0]'>$proto[0]</option>\n"; | |
| 963 | } | |
| 964 | } | |
| 965 | closedir DIR; | |
| 966 | print <<END | |
| 967 | </select><td width='33%' align='center'> | |
| 968 | <tr><td width='33%' align='right'>$Lang::tr{'source ip'}: | |
| 969 | <td width='33%' align='left'><input type='text' name='QIP' maxlength='31' value='$qossettings{'QIP'}' /> | |
| 970 | <td width='33%' align='center'> | |
| 971 | <tr><td width='33%' align='right'>$Lang::tr{'destination ip'}: | |
| 972 | <td width='33%' align='left'><input type='text' name='DIP' maxlength='31' value='$qossettings{'DIP'}' /> | |
| 973 | <td width='33%' align='center'><input type='hidden' name='CLASS' value='$qossettings{'CLASS'}' /><input type='submit' name='DOLEVEL7' value='$Lang::tr{'save'}' /> | |
| 974 | <tr><td colspan="3" align='center'><font color="red"><em>$Lang::tr{'qos warning'}</em></font> | |
| 975 | </table></form> | |
| 976 | END | |
| 977 | ; | |
| 978 | &Header::closebox(); | |
| 979 | } | |
| 980 | ||
| 981 | sub portrule { | |
| 982 | &Header::openbox('100%', 'center', $Lang::tr{'Add Port Rule'}); | |
| 983 | print <<END | |
| 984 | <form method='post' action='$ENV{'SCRIPT_NAME'}'> | |
| 985 | <table width='100%'> | |
| 986 | <tr><td width='100%' colspan='3'>$Lang::tr{'enter data'} | |
| 987 | <tr><td width='33%' align='right'>$Lang::tr{'protocol'}: | |
| 988 | <td width='33%' align='left'><select name='PPROT'> | |
| 989 | END | |
| 990 | ; | |
| 991 | open( FILE, "< /etc/protocols" ); | |
| 992 | @proto = <FILE>; | |
| 993 | close FILE; | |
| 994 | foreach $direntry (sort @proto) | |
| 995 | { | |
| 996 | @tmpline = split( /\ /, $direntry ); | |
| 997 | next if $tmpline[0] =~ "#"; | |
| 998 | if ( $tmpline[0] eq $qossettings{'PPROT'} ) { | |
| 999 | print "<option value='$tmpline[0]' selected>$tmpline[0]</option>\n"; | |
| 1000 | } else { | |
| 1001 | print "<option value='$tmpline[0]'>$tmpline[0]</option>\n"; | |
| 1002 | } | |
| 1003 | } | |
| 1004 | print <<END | |
| 1005 | </select><td width='33%' align='center'> | |
| 1006 | <tr><td width='33%' align='right'>$Lang::tr{'source port'}: | |
| 1007 | <td width='33%' align='left'><input type='text' name='QPORT' maxlength='11' value='$qossettings{'QPORT'}' /> | |
| 1008 | <td width='33%' align='center'> | |
| 1009 | <tr><td width='33%' align='right'>$Lang::tr{'destination port'}: | |
| 1010 | <td width='33%' align='left'><input type='text' name='DPORT' maxlength='11' value='$qossettings{'DPORT'}' /> | |
| 1011 | <td width='33%' align='center'> | |
| 1012 | <tr><td width='33%' align='right'>$Lang::tr{'source ip'}: | |
| 1013 | <td width='33%' align='left'><input type='text' name='QIP' maxlength='31' value='$qossettings{'QIP'}' /> | |
| 1014 | <td width='33%' align='center'> | |
| 1015 | <tr><td width='33%' align='right'>$Lang::tr{'destination ip'}: | |
| 1016 | <td width='33%' align='left'><input type='text' name='DIP' maxlength='31' value='$qossettings{'DIP'}' /> | |
| 1017 | <td width='33%' align='center'><input type='hidden' name='CLASS' value='$qossettings{'CLASS'}' /><input type='submit' name='DOPORT' value='$Lang::tr{'save'}' /> | |
| 1018 | </table></form> | |
| 1019 | END | |
| 1020 | ; | |
| 1021 | &Header::closebox(); | |
| 1022 | } | |
| 1023 | ||
| 1024 | sub tosrule { | |
| 1025 | &Header::openbox('100%', 'center', $Lang::tr{'TOS Rule'}); | |
| 1026 | if ($qossettings{'TOS'}) { | |
| 1027 | $checked{$qossettings{'TOS'}} = "checked"; | |
| 1028 | } | |
| 1029 | print <<END | |
| 1030 | <form method='post' action='$ENV{'SCRIPT_NAME'}'> | |
| 1031 | <table width='100%'> | |
| 1032 | END | |
| 1033 | ; | |
| 1034 | if ( $message ne "" ) { | |
| 1035 | print "<tr><td colspan='3' align='center'><font color='red'>$message</font>"; | |
| 1036 | } | |
| 1037 | print <<END | |
| 1038 | <tr><td colspan='2' width='100%'>$Lang::tr{'current class'}: $qossettings{'CLASS'} | |
| 1039 | <tr><td width='100%' colspan='2'>$Lang::tr{'Enter TOS'} | |
| 1040 | <tr><td width='50%' align='left'>$Lang::tr{'min delay'} (8) <td width='50%'><input type="radio" name="TOS" value="8" $checked[8] /> | |
| 1041 | <tr><td width='50%' align='left'>$Lang::tr{'max throughput'} (4) <td width='50%'><input type="radio" name="TOS" value="4" $checked[4] /> | |
| 1042 | <tr><td width='50%' align='left'>$Lang::tr{'max reliability'} (2) <td width='50%'><input type="radio" name="TOS" value="2" $checked[2] /> | |
| 1043 | <tr><td width='50%' align='left'>$Lang::tr{'min costs'} (1) <td width='50%'><input type="radio" name="TOS" value="1" $checked[1] /> | |
| 1044 | <tr><td width='100%' align='right' colspan='2'><input type='hidden' name='CLASS' value='$qossettings{'CLASS'}' /><input type='submit' name='DOTOS' value='$Lang::tr{'save'}' /> | |
| 1045 | </table></form> | |
| 1046 | END | |
| 1047 | ; | |
| 1048 | &Header::closebox(); | |
| 1049 | } | |
| 1050 | ||
| 1051 | sub showclasses { | |
| 1052 | $qossettings{'DEV'} = shift; | |
| 1053 | open( FILE, "< $classfile" ) or die "Unable to read $classfile"; | |
| 1054 | @classes = <FILE>; | |
| 1055 | close FILE; | |
| 1056 | if (@classes) { | |
| 1057 | open( FILE, "< $level7file" ) or die "Unable to read $level7file"; | |
| 1058 | @l7rules = <FILE>; | |
| 1059 | close FILE; | |
| 1060 | open( FILE, "< $tosfile" ) or die "Unable to read $tosfile"; | |
| 1061 | @tosrules = <FILE>; | |
| 1062 | close FILE; | |
| 1063 | open( FILE, "< $portfile" ) or die "Unable to read $portfile"; | |
| 1064 | @portrules = <FILE>; | |
| 1065 | close FILE; | |
| 1066 | foreach $classentry (sort @classes) | |
| 1067 | { | |
| 1068 | @classline = split( /\;/, $classentry ); | |
| 1069 | if ( $classline[0] eq $qossettings{'DEV'} ) | |
| 1070 | { | |
| 1071 | &Header::openbox('100%', 'center', "$Lang::tr{'Class'}: $classline[1] $classline[8]"); | |
| 1072 | print <<END | |
| 1073 | <table border='0' width='100%' cellspacing='0'> | |
| 1074 | <tr><td bgcolor='$color{'color20'}' width='10%' align='center'><b>$Lang::tr{'interface'}</b> | |
| 1075 | <td bgcolor='$color{'color20'}' width='10%' align='center'><b>$Lang::tr{'Class'}</b> | |
| 1076 | <td bgcolor='$color{'color20'}' width='10%' align='center'>$Lang::tr{'priority'} | |
| 1077 | <td bgcolor='$color{'color20'}' width='10%' align='center'>$Lang::tr{'guaranteed bandwidth'} | |
| 1078 | <td bgcolor='$color{'color20'}' width='10%' align='center'>$Lang::tr{'max bandwidth'} | |
| 1079 | <td bgcolor='$color{'color20'}' width='10%' align='center'>Burst | |
| 1080 | <td bgcolor='$color{'color20'}' width='10%' align='center'>Ceil Burst | |
| 1081 | <td bgcolor='$color{'color20'}' width='10%' align='center'>TOS | |
| 1082 | <td bgcolor='$color{'color20'}' width='20%' align='center'>$Lang::tr{'action'} | |
| 1083 | <tr><td align='center' bgcolor='$color{'color22'}'>$classline[0]</td> | |
| 1084 | <td align='center' bgcolor='$color{'color22'}'>$classline[1]</td> | |
| 1085 | <td align='center' bgcolor='$color{'color22'}'>$classline[2]</td> | |
| 1086 | <td align='center' bgcolor='$color{'color22'}'>$classline[3]</td> | |
| 1087 | <td align='center' bgcolor='$color{'color22'}'>$classline[4]</td> | |
| 1088 | <td align='center' bgcolor='$color{'color22'}'>$classline[5]</td> | |
| 1089 | <td align='center' bgcolor='$color{'color22'}'>$classline[6]</td> | |
| 1090 | <td align='center' bgcolor='$color{'color22'}'>$classline[7]</td> | |
| 1091 | <td align='right' bgcolor='$color{'color22'}'> | |
| 1092 | <table border='0'><tr> | |
| 1093 | <td><form method='post' action='$ENV{'SCRIPT_NAME'}'> | |
| 1094 | <input type='hidden' name='CLASS' value='$classline[1]' /> | |
| 1095 | <input type='hidden' name='ACTION' value='$Lang::tr{'Add Rule'}' /> | |
| 1096 | <input type='image' alt='$Lang::tr{'Add Rule'}' title='$Lang::tr{'Add Rule'}' src='/images/addgreen.gif' /> | |
| 1097 | </form> | |
| 1098 | <td><form method='post' action='$ENV{'SCRIPT_NAME'}'> | |
| 1099 | <input type='hidden' name='CLASS' value='$classline[1]' /> | |
| 1100 | <input type='hidden' name='DOCLASS' value='$Lang::tr{'edit'}' /> | |
| 1101 | <input type='image' alt='$Lang::tr{'edit'}' title='$Lang::tr{'edit'}' src='/images/edit.gif' /> | |
| 1102 | </form> | |
| 1103 | <td><form method='post' action='$ENV{'SCRIPT_NAME'}'> | |
| 1104 | <input type='hidden' name='CLASS' value='$classline[1]' /> | |
| 1105 | <input type='hidden' name='DOCLASS' value='$Lang::tr{'delete'}' /> | |
| 1106 | <input type='image' alt='$Lang::tr{'delete'}' title='$Lang::tr{'delete'}' src='/images/delete.gif' /> | |
| 1107 | </form> | |
| 1108 | </table> | |
| 1109 | </td> | |
| 1110 | <tr><td align='right' colspan='2'><b>$Lang::tr{'remark'}:</b> | |
| 1111 | <td align='center' colspan='6'> $classline[8] | |
| 1112 | <td align='right'><b>Queueing:</b> $classline[9] | |
| 1113 | END | |
| 1114 | ; | |
| 1115 | ||
| 1116 | if (@l7rules) { | |
| 1117 | foreach $l7ruleentry (sort @l7rules) | |
| 1118 | { | |
| 1119 | @l7ruleline = split( /\;/, $l7ruleentry ); | |
| 1120 | if ( $l7ruleline[0] eq $classline[1] ) | |
| 1121 | { | |
| 1122 | print <<END | |
| 1123 | <tr><td align='right' colspan='2'><b>$Lang::tr{'Level7 Protocol'}:</b> | |
| 1124 | <td align='center' colspan='6'>$l7ruleline[2] | |
| 1125 | <td align='right' > | |
| 1126 | <table border='0'><tr> | |
| 1127 | <td><form method='post' action='$ENV{'SCRIPT_NAME'}'> | |
| 1128 | <input type='hidden' name='CLASS' value='$l7ruleline[0]' /> | |
| 1129 | <input type='hidden' name='L7PROT' value='$l7ruleline[2]' /> | |
| 1130 | <input type='hidden' name='DOLEVEL7' value='$Lang::tr{'edit'}' /> | |
| 1131 | <input type='image' alt='$Lang::tr{'edit'}' title='$Lang::tr{'edit'}' src='/images/edit.gif' /> | |
| 1132 | </form> | |
| 1133 | <td><form method='post' action='$ENV{'SCRIPT_NAME'}'> | |
| 1134 | <input type='hidden' name='CLASS' value='$l7ruleline[0]' /> | |
| 1135 | <input type='hidden' name='L7PROT' value='$l7ruleline[2]' /> | |
| 1136 | <input type='hidden' name='DOLEVEL7' value='$Lang::tr{'delete'}' /> | |
| 1137 | <input type='image' alt='$Lang::tr{'delete'}' title='$Lang::tr{'delete'}' src='/images/delete.gif' /> | |
| 1138 | </form> | |
| 1139 | </table> | |
| 1140 | END | |
| 1141 | ; | |
| 1142 | if (($l7ruleline[3] ne "") || ($l7ruleline[4] ne "")){ | |
| 1143 | print <<END | |
| 1144 | <tr><td align='center'> | |
| 1145 | <td align='right' colspan='3'><b>$Lang::tr{'source ip'}:</b> $l7ruleline[3] | |
| 1146 | <td align='right' colspan='3'><b>$Lang::tr{'destination ip'}:</b> $l7ruleline[4] | |
| 1147 | END | |
| 1148 | ; | |
| 1149 | } | |
| 1150 | ||
| 1151 | ||
| 1152 | END | |
| 1153 | ; | |
| 1154 | } | |
| 1155 | } | |
| 1156 | } | |
| 1157 | ||
| 1158 | ||
| 1159 | if (@portrules) { | |
| 1160 | foreach $portruleentry (sort @portrules) | |
| 1161 | { | |
| 1162 | @portruleline = split( /\;/, $portruleentry ); | |
| 1163 | if ( $portruleline[0] eq $classline[1] ) | |
| 1164 | { | |
| 1165 | print <<END | |
| 1166 | <tr><td align='right' colspan='2'><b>$Lang::tr{'Port Rule'}:</b> | |
| 1167 | <td align='center'>($portruleline[2]) | |
| 1168 | <td align='center' colspan='2'> | |
| 1169 | END | |
| 1170 | ; | |
| 1171 | if ($portruleline[4]) { | |
| 1172 | print <<END | |
| 1173 | <i>$Lang::tr{'source port'}:</i> $portruleline[4] | |
| 1174 | END | |
| 1175 | ; | |
| 1176 | } | |
| 1177 | print "<td align='center' colspan='2'>"; | |
| 1178 | if ($portruleline[6]) { | |
| 1179 | print <<END | |
| 1180 | <i>$Lang::tr{'destination port'}:</i> $portruleline[6] | |
| 1181 | END | |
| 1182 | ; | |
| 1183 | } | |
| 1184 | print <<END | |
| 1185 | <td> | |
| 1186 | <td align='right'> | |
| 1187 | <table border='0'><tr> | |
| 1188 | <td><form method='post' action='$ENV{'SCRIPT_NAME'}'> | |
| 1189 | <input type='hidden' name='CLASS' value='$portruleline[0]' /> | |
| 1190 | <input type='hidden' name='PPROT' value='$portruleline[2]' /> | |
| 1191 | <input type='hidden' name='QIP' value='$portruleline[3]' /> | |
| 1192 | <input type='hidden' name='QPORT' value='$portruleline[4]' /> | |
| 1193 | <input type='hidden' name='DIP' value='$portruleline[5]' /> | |
| 1194 | <input type='hidden' name='DPORT' value='$portruleline[6]' /> | |
| 1195 | <input type='hidden' name='DOPORT' value='$Lang::tr{'edit'}' /> | |
| 1196 | <input type='image' alt='$Lang::tr{'edit'}' title='$Lang::tr{'edit'}' src='/images/edit.gif' /> | |
| 1197 | </form> | |
| 1198 | <td><form method='post' action='$ENV{'SCRIPT_NAME'}'> | |
| 1199 | <input type='hidden' name='CLASS' value='$portruleline[0]' /> | |
| 1200 | <input type='hidden' name='PPROT' value='$portruleline[2]' /> | |
| 1201 | <input type='hidden' name='QIP' value='$portruleline[3]' /> | |
| 1202 | <input type='hidden' name='QPORT' value='$portruleline[4]' /> | |
| 1203 | <input type='hidden' name='DIP' value='$portruleline[5]' /> | |
| 1204 | <input type='hidden' name='DPORT' value='$portruleline[6]' /> | |
| 1205 | <input type='hidden' name='DOPORT' value='$Lang::tr{'delete'}' /> | |
| 1206 | <input type='image' alt='$Lang::tr{'delete'}' title='$Lang::tr{'delete'}' src='/images/delete.gif' /> | |
| 1207 | </form> | |
| 1208 | </table> | |
| 1209 | END | |
| 1210 | ; | |
| 1211 | if (($portruleline[3] ne "") || ($portruleline[5] ne "")){ | |
| 1212 | print <<END | |
| 1213 | <tr><td align='center'> | |
| 1214 | <td align='right' colspan='3'><b>$Lang::tr{'source ip'}:</b> $portruleline[3] | |
| 1215 | <td align='right' colspan='3'><b>$Lang::tr{'destination ip'}:</b> $portruleline[5] | |
| 1216 | END | |
| 1217 | ; | |
| 1218 | } | |
| 1219 | } | |
| 1220 | } | |
| 1221 | } | |
| 1222 | ||
| 1223 | if (@tosrules) { | |
| 1224 | foreach $tosruleentry (sort @tosrules) | |
| 1225 | { | |
| 1226 | @tosruleline = split( /\;/, $tosruleentry ); | |
| 1227 | if ( $tosruleline[0] eq $classline[1] ) | |
| 1228 | { | |
| 1229 | print <<END | |
| 1230 | <tr><td align='right' colspan='2'> | |
| 1231 | <b>TOS Bit matches:</b> | |
| 1232 | <td colspan='6' align='center'> | |
| 1233 | END | |
| 1234 | ; | |
| 1235 | if ( $tosruleline[2] eq "8") { | |
| 1236 | print "$Lang::tr{'min delay'}\n"; | |
| 1237 | } elsif ( $tosruleline[2] eq "4") { | |
| 1238 | print "$Lang::tr{'max throughput'}\n"; | |
| 1239 | } elsif ( $tosruleline[2] eq "2") { | |
| 1240 | print "$Lang::tr{'max reliability'}\n"; | |
| 1241 | } elsif ( $tosruleline[2] eq "1") { | |
| 1242 | print "$Lang::tr{'min costs'}\n"; | |
| 1243 | } else { print " \n"; } | |
| 1244 | ||
| 1245 | print <<END | |
| 1246 | ($tosruleline[2]) | |
| 1247 | <td align='right'> | |
| 1248 | <table border='0'><tr> | |
| 1249 | <td><form method='post' action='$ENV{'SCRIPT_NAME'}'> | |
| 1250 | <input type='hidden' name='CLASS' value='$tosruleline[0]' /> | |
| 1251 | <input type='hidden' name='DEV' value='$tosruleline[1]' /> | |
| 1252 | <input type='hidden' name='TOS' value='$tosruleline[2]' /> | |
| 1253 | <input type='hidden' name='DOTOS' value='$Lang::tr{'edit'}' /> | |
| 1254 | <input type='image' alt='$Lang::tr{'edit'}' title='$Lang::tr{'edit'}' src='/images/edit.gif' /> | |
| 1255 | </form> | |
| 1256 | <td><form method='post' action='$ENV{'SCRIPT_NAME'}'> | |
| 1257 | <input type='hidden' name='CLASS' value='$tosruleline[0]' /> | |
| 1258 | <input type='hidden' name='DEV' value='$tosruleline[1]' /> | |
| 1259 | <input type='hidden' name='TOS' value='$tosruleline[2]' /> | |
| 1260 | <input type='hidden' name='DOTOS' value='$Lang::tr{'delete'}' /> | |
| 1261 | <input type='image' alt='$Lang::tr{'delete'}' title='$Lang::tr{'delete'}' src='/images/delete.gif' /> | |
| 1262 | </form> | |
| 1263 | </table> | |
| 1264 | END | |
| 1265 | ; | |
| 1266 | } | |
| 1267 | } | |
| 1268 | } | |
| 1269 | END | |
| 1270 | ; | |
| 1271 | print <<END | |
| 1272 | </table> | |
| 1273 | END | |
| 1274 | ; | |
| 1275 | &Header::closebox(); | |
| 1276 | } | |
| 1277 | } | |
| 1278 | } | |
| 1279 | } | |
| 1280 | sub validminbwdth { | |
| 1281 | if ( $qossettings{'VALID'} eq 'yes' ) { | |
| 1282 | if ( $qossettings{'DEVICE'} eq $qossettings{'RED_DEV'} ) { | |
| 1283 | $qossettings{'SPD'} = $qossettings{'OUT_SPD'}; | |
| 1284 | } elsif ( $qossettings{'DEVICE'} eq $qossettings{'IMQ_DEV'} ) { | |
| 1285 | $qossettings{'SPD'} = $qossettings{'INC_SPD'}; | |
| 1286 | } | |
| 1287 | unless ( ( $qossettings{'MINBWDTH'} >= 1 ) && ( $qossettings{'MINBWDTH'} <= $qossettings{'SPD'} ) ) { | |
| 1288 | $qossettings{'VALID'} = 'no'; | |
| 1289 | $message = "$Lang::tr{'false min bandwidth'}"; | |
| 1290 | } | |
| 1291 | $qossettings{'SPD'} = ''; | |
| 1292 | } | |
| 1293 | } | |
| 1294 | ||
| 1295 | sub validmaxbwdth { | |
| 1296 | if ( $qossettings{'VALID'} eq 'yes' ) { | |
| 1297 | if ( $qossettings{'DEVICE'} eq $qossettings{'RED_DEV'} ) { | |
| 1298 | $qossettings{'SPD'} = $qossettings{'OUT_SPD'}; | |
| 1299 | } elsif ( $qossettings{'DEVICE'} eq $qossettings{'IMQ_DEV'} ) { | |
| 1300 | $qossettings{'SPD'} = $qossettings{'INC_SPD'}; | |
| 1301 | } | |
| 1302 | unless ( ( $qossettings{'MAXBDWTH'} >= 0 ) && ($qossettings{'MAXBDWTH'} >= $qossettings{'MINBDWTH'}) &&( $qossettings{'MAXBDWTH'} <= $qossettings{'SPD'} ) ) { | |
| 1303 | $qossettings{'VALID'} = 'no'; | |
| 1304 | $message = "$Lang::tr{'false max bandwidth'}"; | |
| 1305 | } | |
| 1306 | $qossettings{'SPD'} = ''; | |
| 1307 | } | |
| 1308 | } | |
| 1309 | ||
| 1310 | sub validclass { | |
| 1311 | if ( $qossettings{'VALID'} eq 'yes' ) { | |
| 1312 | if ( $qossettings{'DEVICE'} eq $qossettings{'RED_DEV'} ) { | |
| 1313 | if ($qossettings{'CLASS'} lt 100 || $qossettings{'CLASS'} ge 121) { | |
| 1314 | $qossettings{'VALID'} = 'no'; | |
| 1315 | $message = "$Lang::tr{'false classnumber'}"; | |
| 1316 | } | |
| 1317 | } elsif ( $qossettings{'DEVICE'} eq $qossettings{'IMQ_DEV'} ) { | |
| 1318 | if ($qossettings{'CLASS'} lt 200 || $qossettings{'CLASS'} ge 221) { | |
| 1319 | $qossettings{'VALID'} = 'no'; | |
| 1320 | $message = "$Lang::tr{'The class number does not match the specified interface.'}"; | |
| 1321 | } | |
| 1322 | } | |
| 1323 | open( FILE, "< $classfile" ) or die "Unable to read $classfile"; | |
| 1324 | @tmp = <FILE>; | |
| 1325 | close FILE; | |
| 1326 | foreach $classentry (sort @tmp) | |
| 1327 | { | |
| 1328 | @tmpline = split( /\;/, $classentry ); | |
| 1329 | if ( $tmpline[1] eq $qossettings{'CLASS'} ) | |
| 1330 | { | |
| 1331 | $qossettings{'VALID'} = 'no'; | |
| 1332 | $message = "$Lang::tr{'false classnumber'}"; | |
| 1333 | last | |
| 1334 | } | |
| 1335 | } | |
| 1336 | } | |
| 1337 | } |