' . gettext('You can add new layer7 protocol patterns by simply uploading the file') . ' ' . gettext('here') . ''; read_layer7_config(); $sform = new Form(false); if ($_GET['reset'] != "") { // kill all ipfw-classifyd processes mwexec("killall -9 ipfw-classifyd"); exit; } if ($_GET) { if ($_GET['container']) { $name = htmlspecialchars(trim($_GET['container'])); } if ($_GET['action']) { $action = htmlspecialchars($_GET['action']); } } if ($_POST) { if ($_POST['container']) { $name = htmlspecialchars(trim($_POST['container'])); } } if ($name) { //Get the object from the 7rules list $container = $layer7_rules_list[$name]; } if ($_GET) { switch ($action) { case "add": $show_proto_form = true; $container = new layer7(); $sform = $container->build_form(); //constructs the graphical interface on the right side unset($container); break; case "show": $show_proto_form = true; if ($container) { $sform = $container->build_form(); } else { $show_proto_form = false; $input_errors[] = gettext("Layer7 Rules Container not found!"); } break; default: echo log_error("Get default"); $show_proto_form = false; $dfltmsg = true; break; } } //add a new l7rules container if ($_POST) { $show_proto_form = true; unset($input_errors); if ($_POST['Submit']) { if (isset($layer7_rules_list[$name])) { $l7r = $layer7_rules_list[$name]; $_POST['divert_port'] = $l7r->GetRPort(); } else { $l7r =& new layer7(); $_POST['divert_port'] = $l7r->gen_divert_port(); } for ($i = 0; $_POST['protocol'][$i] <> ""; $i++) { $_POST['l7rules'][$i]['protocol'] = $_POST['protocol'][$i]; $_POST['l7rules'][$i]['structure'] = $_POST['structure'][$i]; $_POST['l7rules'][$i]['behaviour'] = $_POST['behaviour'][$i]; } $l7r->validate_input($_POST, $input_errors); $l7r->ReadConfig($_POST['container'], $_POST); //Before writing the results, we need to test for repeated protocols $non_dupes = array(); $dupes = array(); for ($j = 0; $j < $i; $j++) { if (!$non_dupes[$_POST['protocol'][$j]]) { $non_dupes[$_POST['protocol'][$j]] = true; } else { $dupes[] = $_POST['protocol'][$j]; } } unset($non_dupes); if (sizeof($dupes) == 0 && !$input_errors) { $l7r->wconfig(); if (write_config()) { mark_subsystem_dirty('shaper'); } read_layer7_config(); } else { if (sizeof($dupes) > 0) { $dupe_error = gettext("Found the following repeated protocol definitions") . ": "; foreach ($dupes as $dupe) { $dupe_error .= "$dupe "; } $input_errors[] .= $dupe_error; } } unset($dupes); unset($dupe_error); //Even if there are repeated protocols, we won't lose any previous values //The user will be able to solve the situation $sform = $l7r->build_form(); //Necessary to correctly build the proto form $container = $layer7_rules_list[$name]; if ($input_errors) { $container =& $l7r; } } else if ($_POST['apply']) { write_config(); $retval = 0; $retval = filter_configure(); $savemsg = get_std_save_message($retval); if (stristr($retval, "error") <> true) { $savemsg = get_std_save_message($retval); } else { $savemsg = $retval; } clear_subsystem_dirty('shaper'); if ($container) { $sform = $container->build_form(); } else { $show_proto_form = false; $dfltmsg = true; } } else if ($_POST['delete']) { $container->delete_l7c(); if (write_config()) { mark_subsystem_dirty('shaper'); } unset($container); header("Location: firewall_shaper_layer7.php"); exit; } else { $show_proto_form = false; } } if (!$_GET && !$_POST) { $show_proto_form = false; $dfltmsg = true; } // Builds the left tree $tree = ""; include("head.inc"); ?> '; // No stripes for this table $tbl .= 'ProtocolStructureBehavior'; $tbl .= ''; if ($container) { foreach ($container->rsets as $l7rule) { $tbl .= ''; $tbl .= ''; $tbl .= ''; $tbl .= ''; endif; if ($l7rule->GetRStructure() == "queue"): foreach ($avail_behaviours_altq as $behaviour): $tbl .= ''; endforeach; $tbl .= ''; endif; if ($l7rule->GetRStructure() == "limiter"): foreach ($avail_behaviours_limiter as $behaviour): $tbl .= ''; endforeach; $tbl .= ''; endif; $tbl .= ''; $tbl .= ''; $tbl .= gettext('Remove') . ''; $tbl .= ''; } //end foreach } //end if $tbl .= ''; $tbl .= '' . gettext('Add row') . ''; return($tbl); } if ($input_errors) print_input_errors($input_errors); if ($savemsg) print_info_box($savemsg, 'success'); if (is_subsystem_dirty('shaper')) print_info_box_np(gettext("The traffic shaper configuration has been changed") . ".
" . gettext("You must apply the changes in order for them to take effect.")); $tab_array = array(); $tab_array[] = array(gettext("By Interface"), false, "firewall_shaper.php"); $tab_array[] = array(gettext("By Queue"), false, "firewall_shaper_queues.php"); $tab_array[] = array(gettext("Limiter"), false, "firewall_shaper_vinterface.php"); $tab_array[] = array(gettext("Layer7"), true, "firewall_shaper_layer7.php"); $tab_array[] = array(gettext("Wizards"), false, "firewall_shaper_wizards.php"); display_top_tabs($tab_array); // Create a StaticText control and populate it with the rules table if (!$dfltmsg) { $section = new Form_Section('Add one (or more) rules'); $section->addInput(new Form_StaticText( 'Rule(s)', build_l7table() )); $sform->add($section); } ?>

Layer 7