<?xml version="1.0" encoding="utf-8" ?> <!DOCTYPE packagegui SYSTEM "./schema/packages.dtd"> <?xml-stylesheet type="text/xsl" href="./xsl/package.xsl"?> <packagegui> <copyright> <![CDATA[ /* $Id$ */ /* ========================================================================== */ /* softflowd.xml part of pfSense (https://www.pfSense.org/) Copyright (C) 2013-2015 ESF, LLC All rights reserved. */ /* ========================================================================== */ /* Redistribution and use in source and binary forms, with or without modification, are permitted provided that the following conditions are met: 1. Redistributions of source code must retain the above copyright notice, this list of conditions and the following disclaimer. 2. Redistributions in binary form must reproduce the above copyright notice, this list of conditions and the following disclaimer in the documentation and/or other materials provided with the distribution. THIS SOFTWARE IS PROVIDED ``AS IS'' AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE AUTHOR BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. */ /* ========================================================================== */ ]]> </copyright> <name>softflowd</name> <version>1.2</version> <title>softflowd: Settings</title> <aftersaveredirect>pkg_edit.php?xml=softflowd.xml&id=0</aftersaveredirect> <menu> <name>softflowd</name> <tooltiptext>Modify softflowd settings.</tooltiptext> <section>Services</section> <configfile>softflowd.xml</configfile> <url>/pkg_edit.php?xml=softflowd.xml&id=0</url> </menu> <service> <name>softflowd</name> <rcfile>softflowd.sh</rcfile> <executable>softflowd</executable> <description>Netflow export daemon</description> </service> <configpath>installedpackages->package->$packagename->configuration->settings</configpath> <fields> <field> <name>General Settings</name> <type>listtopic</type> </field> <field> <fielddescr>Interface</fielddescr> <fieldname>interface</fieldname> <type>interfaces_selection</type> <description>Pick an interface from which to collect netflow data. A separate instance of softflowd will be launched for each interface.</description> <multiple/> </field> <field> <fielddescr>Host</fielddescr> <fieldname>host</fieldname> <description>Specify the host to which datagrams will be sent.</description> <type>input</type> </field> <field> <fielddescr>Port</fielddescr> <fieldname>port</fieldname> <description>Enter the port to which datagrams will be sent.</description> <type>input</type> </field> <field> <fielddescr>Max Flows</fielddescr> <fieldname>maxflows</fieldname> <description>Specify the maximum number of flows to concurrently track before older flows are expired. Default: 8192.</description> <type>input</type> </field> <field> <fielddescr>Hop Limit</fielddescr> <fieldname>hoplimit</fieldname> <description>Set the IPv4 TTL or the IPv6 hop limit to hoplimit. softflowd will use the default system TTL when exporting flows to a unicast host. When exporting to a multicast group, the default TTL will be 1 (i.e. link-local).</description> <type>input</type> </field> <field> <fielddescr>Netflow version</fielddescr> <fieldname>version</fieldname> <description>Select the desired version of the NetFlow protocol.</description> <type>select</type> <options> <option> <name>9</name> <value>9</value> </option> <option> <name>5</name> <value>5</value> </option> <option> <name>1</name> <value>1</value> </option> </options> </field> <field> <fielddescr>Flow Tracking Level</fielddescr> <fieldname>flowtracking</fieldname> <description>Specify which flow elements softflowd should be used to define a flow. track_level may be one of: "full" (track everything in the flow, the default), "proto" (track source and destination addresses and protocol), or "ip" (only track source and destination addresses). Selecting either of the latter options will produce flows with less information in them (e.g. TCP/UDP ports will not be recorded). This will cause flows to be consolidated, reducing the quantity of output and CPU load that softflowd will place on the system at the cost of some detail being lost.</description> <type>select</type> <options> <option> <name>Full</name> <value>full</value> </option> <option> <name>Proto</name> <value>proto</value> </option> <option> <name>IP</name> <value>ip</value> </option> </options> </field> <field> <name>Timeout Values</name> <type>listtopic</type> </field> <field> <fielddescr>General</fielddescr> <fieldname>timeout-general</fieldname> <description>(Seconds) This is the general timeout applied to all traffic unless overridden by one of the other timeouts.</description> <type>input</type> </field> <field> <fielddescr>Maximum Lifetime</fielddescr> <fieldname>timeout-maxlife</fieldname> <description>(Seconds) This is the maximum lifetime that a flow may exist for. All flows are forcibly expired when they pass maxlife seconds. To disable this feature, specify a maxlife of 0.</description> <type>input</type> </field> <field> <fielddescr>Expire Interval</fielddescr> <fieldname>timeout-expint</fieldname> <description>(Seconds) Specify the interval between expiry checks. Increase this to group more flows into a NetFlow packet. To disable this feature, specify a expint of 0.</description> <type>input</type> </field> <field> <fielddescr>TCP</fielddescr> <fieldname>timeout-tcp</fieldname> <description>(Seconds) This is the general TCP timeout, applied to open TCP connections.</description> <type>input</type> </field> <field> <fielddescr>TCP RST</fielddescr> <fieldname>timeout-tcp-rst</fieldname> <description>(Seconds) This timeout is applied to a TCP connection when a RST packet has been sent by one or both endpoints.</description> <type>input</type> </field> <field> <fielddescr>TCP FIN</fielddescr> <fieldname>timeout-tcp-fin</fieldname> <description>(Seconds) This timeout is applied to a TCP connection when a FIN packet has been sent by both endpoints.</description> <type>input</type> </field> <field> <fielddescr>UDP</fielddescr> <fieldname>timeout-udp</fieldname> <description>(Seconds) This is the general UDP timeout, applied to all UDP connections.</description> <type>input</type> </field> </fields> <custom_php_global_functions> <![CDATA[ function sync_package_softflowd() { conf_mount_rw(); global $config; $cf = $config['installedpackages']['softflowd']['config'][0]; $interface_list = explode(",", $cf['interface']); if (!empty($cf['host']) && !empty($interface_list)) { $cf['host'] = is_ipaddrv6($cf['host']) ? "[{$cf['host']}]" : $cf['host']; $start = "/usr/bin/killall -9 softflowd"; foreach ($interface_list as $interface_friendly) { if (empty($interface_friendly)) { continue; } $interface = get_real_interface($interface_friendly); if (empty($interface)) { continue; } $start .= "\n\t/usr/local/sbin/softflowd "; $start .= " -i " . escapeshellarg($interface); $start .= " -n " . escapeshellarg("{$cf['host']}:{$cf['port']}"); if (is_numeric($cf['maxflows'])) { $start .= " -m " . escapeshellarg($cf['maxflows']); } if (is_numeric($cf['hoplimit'])) { $start .= " -L " . escapeshellarg($cf['hoplimit']); } if ($cf['version'] != "") { $start .= " -v " . escapeshellarg($cf['version']); } if ($cf['flowtracking'] != "") { $start .= " -T " . escapeshellarg($cf['flowtracking']); } if (is_numeric($cf['timeout-general'])) { $start .= " -t " . escapeshellarg("general={$cf['timeout-general']}"); } if (is_numeric($cf['timeout-maxlife'])) { $start .= " -t " . escapeshellarg("maxlife={$cf['timeout-maxlife']}"); } if (is_numeric($cf['timeout-expint'])) { $start .= " -t " . escapeshellarg("expint={$cf['timeout-expint']}"); } if (is_numeric($cf['timeout-tcp'])) { $start .= " -t " . escapeshellarg("tcp={$cf['timeout-tcp']}"); } if (is_numeric($cf['timeout-tcp-rst'])) { $start .= " -t " . escapeshellarg("tcp.rst={$cf['timeout-tcp-rst']}"); } if (is_numeric($cf['timeout-tcp-fin'])) { $start .= " -t " . escapeshellarg("tcp.fin={$cf['timeout-tcp-fin']}"); } if (is_numeric($cf['timeout-udp'])) { $start .= " -t " . escapeshellarg("udp={$cf['timeout-udp']}"); } $start .= " -p " . escapeshellarg("/var/run/softflowd.{$interface}.pid"); $start .= " -c " . escapeshellarg("/var/run/softflowd.{$interface}.ctl"); } write_rcfile(array( "file" => "softflowd.sh", "start" => $start, "stop" => "/usr/bin/killall -9 softflowd" ) ); /* Only try to restart if not booting */ if (!platform_booting()) { restart_service("softflowd"); } } conf_mount_ro(); } function validate_form_softflowd($post, &$input_errors) { if (($post['host'] == "") || !is_ipaddr($post['host'])) { $input_errors[] = 'You must specify a valid ip address in the \'Host\' field'; } if (($post['port'] == "") || !is_port($post['port'])) { $input_errors[] = 'You must specify a valid port number in the \'Port\' field'; } if (($post['version'] == "" || !in_array($post['version'], array(1, 5, 9)))) { $input_errors[] = 'You must specify a netflow version'; } if (($post['flowtracking'] == "" || !in_array($post['flowtracking'], array("full", "proto", "ip")))) { $input_errors[] = 'You must specify a valid flow tracking selection'; } if (!empty($post['hoplimit']) && (!is_numeric($post['hoplimit']) || ($post['hoplimit'] < 1) || ($post['hoplimit'] > 255))) { $input_errors[] = 'You must specify a valid hop limit'; } if (!empty($post['timeout-general']) && (!is_numeric($post['timeout-general']) || ($post['timeout-general'] < 0))) { $input_errors[] = 'You must specify a valid General Timeout'; } if (!empty($post['timeout-maxlife']) && (!is_numeric($post['timeout-maxlife']) || ($post['timeout-maxlife'] < 0))) { $input_errors[] = 'You must specify a valid Maximum Lifetime Timeout'; } if (!empty($post['timeout-expint']) && (!is_numeric($post['timeout-expint']) || ($post['timeout-expint'] < 0))) { $input_errors[] = 'You must specify a valid Expire Interval'; } if (!empty($post['timeout-tcp']) && (!is_numeric($post['timeout-tcp']) || ($post['timeout-tcp'] < 0))) { $input_errors[] = 'You must specify a valid TCP Timeout'; } if (!empty($post['timeout-tcp-rst']) && (!is_numeric($post['timeout-tcp-rst']) || ($post['timeout-tcp-rst'] < 0))) { $input_errors[] = 'You must specify a valid TCP RST Timeout'; } if (!empty($post['timeout-tcp-fin']) && (!is_numeric($post['timeout-tcp-fin']) || ($post['timeout-tcp-fin'] < 0))) { $input_errors[] = 'You must specify a valid TCP FIN Timeout'; } if (!empty($post['timeout-udp']) && (!is_numeric($post['timeout-udp']) || ($post['timeout-udp'] < 0))) { $input_errors[] = 'You must specify a valid UDP Timeout'; } } function cleanup_config_softflowd() { global $a_pkg; $pffconf = array(); if (is_array($a_pkg)) { foreach($a_pkg as $cf) { if ($cf['host'] != "") { $pffconf = $cf; } } } $a_pkg = array(); $a_pkg[0] = $pffconf; } ]]> </custom_php_global_functions> <custom_php_resync_config_command> sync_package_softflowd(); </custom_php_resync_config_command> <custom_php_validation_command> validate_form_softflowd($_POST, $input_errors); </custom_php_validation_command> <custom_php_command_before_form> cleanup_config_softflowd(); </custom_php_command_before_form> </packagegui>