<?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$ */
/* ========================================================================== */
/*
    ifbwstats.xml
    part of pfSense (http://www.pfSense.com)
    Copyright (C) 2010 to whom it may belong
    All rights reserved.

    Based on m0n0wall (http://m0n0.ch/wall)
    Copyright (C) 2003-2006 Manuel Kasper <mk@neon1.net>.
    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>

	<description>Interface Bandwidth Stats</description>
	<name>ifbwstats</name>
	<requirements>None</requirements>
	<faq>Currently there are no FAQ items provided.</faq>
	<version>1.0</version>
	<title>ifBWStats: if Bandwidth Stats Settings</title>
	<include_file>/usr/local/pkg/ifbwstats.inc</include_file>
<!--	<service>
		<name>ifBWStats</name>
		<rcfile>ifbwstats.sh</rcfile>
		<description>ifBWStats daemon</description>
	</service>	-->
	<menu>
		<name>ifBWStats</name>
		<tooltiptext></tooltiptext>
		<section>Status</section>
		<url>/ifbwstats_cur.php</url>
	</menu>
	<tabs>
		<tab>
			<text>Daily</text>
			<url>/ifbwstats_cur.php</url>
		</tab>
		<tab>
			<text>Monthly</text>
			<url>/ifbwstats_disp.php</url>
		</tab>
		<tab>
			<text>Settings</text>
			<url>/pkg_edit.php?xml=ifbwstats.xml&amp;id=0</url>
			<active/>
		</tab>
	</tabs>
	<additional_files_needed>
		<prefix>/usr/local/www/</prefix>
		<chmod>0755</chmod>
		<item>http://files.pfsense.org/packages/config/ifbwstats/ifbwstats_daily.php</item>
	</additional_files_needed>
	<additional_files_needed>
		<prefix>/usr/local/www/</prefix>
		<chmod>0755</chmod>
		<item>http://files.pfsense.org/packages/config/ifbwstats/ifbwstats_disp.php</item>
	</additional_files_needed>
	<additional_files_needed>
		<prefix>/usr/local/www/</prefix>
		<chmod>0755</chmod>
		<item>http://files.pfsense.org/packages/config/ifbwstats/ifbwstats_cur.php</item>
	</additional_files_needed>
	<additional_files_needed>
		<prefix>/usr/local/www/</prefix>
		<chmod>0777</chmod>
		<item>http://files.pfsense.org/packages/config/ifbwstats/ifbwstats_daemon.php</item>
	</additional_files_needed>
	<additional_files_needed>
		<prefix>/usr/local/pkg/</prefix>
		<chmod>0755</chmod>
		<item>http://files.pfsense.org/packages/config/ifbwstats/ifbwstats.inc</item>
	</additional_files_needed>
	<additional_files_needed>
	    <prefix>/usr/local/etc/rc.d/</prefix>
	    <chmod>0755</chmod>
		<item>http://files.pfsense.org/packages/config/ifbwstats/ifbwstats.sh</item>
	</additional_files_needed>
	<fields>
		<field>
			<fieldname>firstday</fieldname>
			<fielddescr>First Day:</fielddescr>
			<description>This is the first day of your billing period.  It can be changed at anytime with no impact on the recorded data.</description>
			<required/>
			<type>select</type>
			<options>
				<option>
					<value>1</value>
					<name>1</name>
				</option>	
				<option>
					<value>2</value>
					<name>2</name>
				</option>
				<option>
					<value>3</value>
					<name>3</name>
				</option>
				<option>
					<value>4</value>
					<name>4</name>
				</option>
				<option>
					<value>5</value>
					<name>5</name>
				</option>
				<option>
					<value>6</value>
					<name>6</name>
				</option>
				<option>
					<value>7</value>
					<name>7</name>
				</option>
				<option>
					<value>8</value>
					<name>8</name>
				</option>
				<option>
					<value>9</value>
					<name>9</name>
				</option>
				<option>
					<value>10</value>
					<name>10</name>
				</option>
				<option>
					<value>11</value>
					<name>11</name>
				</option>
				<option>
					<value>12</value>
					<name>12</name>
				</option>
				<option>
					<value>13</value>
					<name>13</name>
				</option>
				<option>
					<value>14</value>
					<name>14</name>
				</option>
				<option>
					<value>15</value>
					<name>15</name>
				</option>
				<option>
					<value>16</value>
					<name>16</name>
				</option>
				<option>
					<value>17</value>
					<name>17</name>
				</option>
				<option>
					<value>18</value>
					<name>18</name>
				</option>
				<option>
					<value>19</value>
					<name>19</name>
				</option>
				<option>
					<value>20</value>
					<name>20</name>
				</option>
				<option>
					<value>21</value>
					<name>21</name>
				</option>
				<option>
					<value>22</value>
					<name>22</name>
				</option>
				<option>
					<value>23</value>
					<name>23</name>
				</option>
				<option>
					<value>24</value>
					<name>24</name>
				</option>
				<option>
					<value>25</value>
					<name>25</name>
				</option>
				<option>
					<value>26</value>
					<name>26</name>
				</option>
				<option>
					<value>27</value>
					<name>27</name>
				</option>
				<option>
					<value>28</value>
					<name>28</name>
				</option>
			</options>
		</field>
		<field>
			<fieldname>intervalrun</fieldname>
			<fielddescr>Connection Speed:</fielddescr>
			<description>Select the maximum speed your connection is capable of in either the up or down direction.  This insure the connection is monitored appropriately.</description>
			<required/>
			<type>select</type>
			<!--
			2mbit: 16384sec
			5mbit: 6553.6sec
			10mbit: 3276.8sec
			20mbit: 1638.4sec
			50mbit: 655.36sec
			100mbit: 327.68sec
			200mbit: 163.84sec
			500mbit: 65.536sec
			1gbit: 32sec
			-->
			<options>
				<option>
					<value>3000</value>
					<name>10mbit</name>
				</option>
				<option>
					<value>600</value>
					<name>50mbit</name>
				</option>
				<option>
					<value>280</value>
					<name>100mbit</name>
				</option>
				<option>
					<value>60</value>
					<name>500mbit</name>
				</option>
				<option>
					<value>30</value>
					<name>1gbit</name>
				</option>
			</options>
		</field>
		<field>
			<fieldname>ifmon</fieldname>
			<fielddescr>Interface to Monitor:</fielddescr>
			<description>Monitor all interfaces or only the WAN(internet) interfaces.  When this is set to WAN, no stats are recorded for any other interfaces.</description>
			<required/>
			<type>select</type>
			<options>
				<option>
					<value>wan</value>
					<name>WAN</name>
				</option>
				<option>
					<value>lan</value>
					<name>LAN</name>
				</option>
				<option>
					<value>all</value>
					<name>All</name>
				</option>
			</options>
		</field>	
		<field>
			<fieldname>logging</fieldname>
			<fielddescr>Debug Daemon:</fielddescr>
			<description>Logging of the Daemon's actions to /tmp/ifbwstats.log.  Warning, file is not managed and can become very large.</description>
			<required/>
			<type>select</type>
			<options>
				<option>
					<value>yes</value>
					<name>Yes</name>
				</option>
				<option>
					<value>no</value>
					<name>No</name>
				</option>
			</options>
		</field>
	</fields>
	<custom_add_php_command_late>
		kill_php_script();
		start_php_script();
	</custom_add_php_command_late>
	<custom_php_install_command>
		update_status ("Adding RC entries...");
		ifbwstats_add_rc();
		update_status ("Setting default values...");
		ifbwstats_set_var();
		update_status ("Adding CRON entry...");
		ifbwstats_add_cron();
		update_status ("Starting php script...");
		start_php_script();
	</custom_php_install_command>
	<custom_php_deinstall_command>
		update_status ("Kill php script...");
		kill_php_script();
		update_status ("Backup data files and remove tmp files...");
		<![CDATA[
			exec ('cp /tmp/ifbwstats-*.data /cf/conf/');
			exec ('rm /tmp/ifbwstats*');
		]]>
		update_status ("Removing RC entries...");
		ifbwstats_remove_rc();
		update_status ("Removing CRON entry...");
		ifbwstats_remove_cron();
		update_status ("Removing files...");
		<![CDATA[
			unlink_if_exists("/usr/local/www/ifbwstats_daily.php");
			unlink_if_exists("/usr/local/www/ifbwstats_disp.php");
			unlink_if_exists("/usr/local/www/ifbwstats_daemon.php");
			unlink_if_exists("/usr/local/www/ifbwstats_cur.php");
			unlink_if_exists("/usr/local/etc/rc.d/ifbwstats.sh");
		]]>
		update_status ("Remove settings...");
		ifbwstats_remove_var();
	</custom_php_deinstall_command>
</packagegui>