aboutsummaryrefslogtreecommitdiffstats
path: root/config/ladvd
diff options
context:
space:
mode:
Diffstat (limited to 'config/ladvd')
-rw-r--r--config/ladvd/ladvd.inc104
-rw-r--r--config/ladvd/ladvd.xml149
-rw-r--r--config/ladvd/status_ladvd.php118
3 files changed, 371 insertions, 0 deletions
diff --git a/config/ladvd/ladvd.inc b/config/ladvd/ladvd.inc
new file mode 100644
index 00000000..acf277b3
--- /dev/null
+++ b/config/ladvd/ladvd.inc
@@ -0,0 +1,104 @@
+<?php
+/*
+ ladvd.inc
+ Copyright (C) 2006 Scott Ullrich
+ 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.
+*/
+
+require_once("globals.inc");
+require_once("util.inc");
+require_once("functions.inc");
+require_once("pkg-utils.inc");
+
+function ladvd_resync_config() {
+ global $config;
+
+ conf_mount_rw();
+
+ if (!is_array($config['installedpackages']['ladvd']))
+ return;
+ if (!is_array($config['installedpackages']['ladvd']['config']))
+ return;
+
+ $ladvd_conf = &$config['installedpackages']['ladvd']['config'][0];
+
+ /* ladvd is turned off in package settings */
+ if (empty($ladvd_conf['enable']))
+ return;
+
+ $cmdline = "";
+
+ if (!empty($ladvd_conf['autoenable'])) {
+ $cmdline .= "-a ";
+ }
+
+ if (!empty($ladvd_conf['silent'])) {
+ $cmdline .= "-s ";
+ }
+
+ if (!empty($ladvd_conf['management'])) {
+ $cmdline .= "-m " . escapeshellarg(get_real_interface($ladvd_conf['management'])) . " ";
+ }
+
+ if (!empty($ladvd_conf['location'])) {
+ $cmdline .= "-l '{$ladvd_conf['location']}' ";
+ }
+
+ if (!empty($ladvd_conf['lldp'])) {
+ $cmdline .= "-L ";
+ }
+
+ if (!empty($ladvd_conf['cdp'])) {
+ $cmdline .= "-C ";
+ }
+
+ if (!empty($ladvd_conf['edp'])) {
+ $cmdline .= "-E ";
+ }
+
+ if (!empty($ladvd_conf['fdp'])) {
+ $cmdline .= "-F ";
+ }
+
+ if (!empty($ladvd_conf['ndp'])) {
+ $cmdline .= "-N ";
+ }
+
+ $ifaces = explode(",", $ladvd_conf['iface_array']);
+ $ifaces = array_map('get_real_interface', $ifaces);
+ $cmdline .= implode(" ", $ifaces);
+
+ write_rcfile(array(
+ "file" => "ladvd.sh",
+ "start" => "/usr/local/sbin/ladvd $cmdline",
+ "stop" => "/usr/bin/killall -9 ladvd"
+ )
+ );
+
+ restart_service("ladvd");
+ sleep(1);
+ conf_mount_ro();
+}
+
+?>
diff --git a/config/ladvd/ladvd.xml b/config/ladvd/ladvd.xml
new file mode 100644
index 00000000..d250f16c
--- /dev/null
+++ b/config/ladvd/ladvd.xml
@@ -0,0 +1,149 @@
+<?xml version="1.0" encoding="utf-8" ?>
+<packagegui>
+ <copyright>
+ <![CDATA[
+/*
+ ladvd.xml
+ Copyright (C) 2006 Scott Ullrich
+ 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>Link Layer Discovery Protocol</description>
+ <name>LADVD</name>
+ <version>1.0.2</version>
+ <category>Network Management</category>
+ <title>Services: LADVD</title>
+ <savetext>ladvd</savetext>
+ <include_file>/usr/local/pkg/ladvd.inc</include_file>
+ <aftersaveredirect>/pkg_edit.php?xml=ladvd.xml&amp;id=0</aftersaveredirect>
+ <additional_files_needed>
+ <item>http://www.pfsense.com/packages/config/ladvd/ladvd.inc</item>
+ <prefix>/usr/local/pkg/</prefix>
+ <chmod>0644</chmod>
+ </additional_files_needed>
+ <additional_files_needed>
+ <prefix>/usr/local/www/</prefix>
+ <chmod>0755</chmod>
+ <item>http://www.pfsense.com/packages/config/ladvd/status_ladvd.php</item>
+ </additional_files_needed>
+ <menu>
+ <name>LADVD</name>
+ <tooltiptext>Modify LADVD settings.</tooltiptext>
+ <section>Services</section>
+ <url>/pkg_edit.php?xml=ladvd.xml&amp;id=0</url>
+ </menu>
+ <menu>
+ <name>LADVD Status</name>
+ <tooltiptext></tooltiptext>
+ <section>Status</section>
+ <url>/status_ladvd.php</url>
+ </menu>
+ <service>
+ <name>ladvd</name>
+ <rcfile>ladvd.sh</rcfile>
+ <executable>ladvd</executable>
+ <description>Send and decode link layer advertisements</description>
+ </service>
+ <tabs>
+ <tab>
+ <text>General</text>
+ <url>/pkg_edit.php?xml=ladvd.xml&amp;id=0</url>
+ <active/>
+ </tab>
+ <tab>
+ <text>Status</text>
+ <url>/status_ladvd.php</url>
+ </tab>
+ </tabs>
+ <fields>
+ <field>
+ <fielddescr>Enable ladvd</fielddescr>
+ <fieldname>enable</fieldname>
+ <description>Enable or disable ladvd</description>
+ <enablefields>iface_array[],autoenable,silent,management,location,lldp,cdp,edp,ndp</enablefields>
+ <type>checkbox</type>
+ </field>
+ <field>
+ <fielddescr>Interfaces</fielddescr>
+ <fieldname>iface_array</fieldname>
+ <value>lan</value>
+ <multiple>true</multiple>
+ <size>3</size>
+ <type>interfaces_selection</type>
+ <description>Select the interfaces that LADVD will bind to. You can use the CTRL or COMMAND key to select multiple interfaces.</description>
+ </field>
+ <field>
+ <fielddescr>Auto-enable protocols</fielddescr>
+ <fieldname>autoenable</fieldname>
+ <description>Auto-enable protocols based on received packets (also enables receive mode).</description>
+ <type>checkbox</type>
+ </field>
+ <field>
+ <fielddescr>Silent</fielddescr>
+ <fieldname>silent</fieldname>
+ <description>Silent, don't transmit packets.</description>
+ <type>checkbox</type>
+ </field>
+ <field>
+ <fielddescr>Management interfaces</fielddescr>
+ <fieldname>management</fieldname>
+ <value>lan</value>
+ <type>interfaces_selection</type>
+ <description>The management interface for this host. Addresses on this interface are auto-detected (IPv4 and IPv6).</description>
+ </field>
+ <field>
+ <fielddescr>System Location</fielddescr>
+ <fieldname>location</fieldname>
+ <type>input</type>
+ <size>30</size>
+ <description>Specify the physical location of the host.</description>
+ </field>
+ <field>
+ <fielddescr>Enable LLDP</fielddescr>
+ <fieldname>lldp</fieldname>
+ <description>Enable LLDP (Link Layer Discovery Protocol).</description>
+ <type>checkbox</type>
+ </field>
+ <field>
+ <fielddescr>Enable CDP</fielddescr>
+ <fieldname>cdp</fieldname>
+ <description>Enable CDP (Cisco Discovery Protocol).</description>
+ <type>checkbox</type>
+ </field>
+ <field>
+ <fielddescr>Enable EDP</fielddescr>
+ <fieldname>edp</fieldname>
+ <description>Enable EDP (Extreme Discovery Protocol).</description>
+ <type>checkbox</type>
+ </field>
+ <field>
+ <fielddescr>Enable NDP</fielddescr>
+ <fieldname>ndp</fieldname>
+ <description>Enable NDP (Nortel Discovery Protocol) formerly called SynOptics Network Management Protocol (SONMP).</description>
+ <type>checkbox</type>
+ </field>
+ </fields>
+ <custom_php_resync_config_command>ladvd_resync_config();</custom_php_resync_config_command>
+</packagegui>
diff --git a/config/ladvd/status_ladvd.php b/config/ladvd/status_ladvd.php
new file mode 100644
index 00000000..3333145a
--- /dev/null
+++ b/config/ladvd/status_ladvd.php
@@ -0,0 +1,118 @@
+<?php
+/*
+ status_ladvd.php
+ Copyright (C) 2006 Scott Ullrich
+ 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.
+*/
+
+require("guiconfig.inc");
+
+$pgtitle = "LADVD: Status";
+include("head.inc");
+
+$control_script = "/usr/local/sbin/ladvdc";
+
+/* List all of the commands as an index. */
+function listCmds() {
+ global $commands;
+ echo "<br/>This status page includes the following information:\n";
+ echo "<ul width=\"100%\">\n";
+ for ($i = 0; isset($commands[$i]); $i++ ) {
+ echo "<li><strong><a href=\"#" . $commands[$i][0] . "\">" . $commands[$i][0] . "</a></strong></li>\n";
+ }
+ echo "</ul>\n";
+}
+
+function execCmds() {
+ global $commands;
+ for ($i = 0; isset($commands[$i]); $i++ ) {
+ doCmdT($commands[$i][0], $commands[$i][1]);
+ }
+}
+
+/* Define a command, with a title, to be executed later. */
+function defCmdT($title, $command) {
+ global $commands;
+ $title = htmlspecialchars($title,ENT_NOQUOTES);
+ $commands[] = array($title, $command);
+}
+
+function doCmdT($title, $command) {
+ echo "<p>\n";
+ echo "<a name=\"" . $title . "\">\n";
+ echo "<table width=\"100%\" border=\"0\" cellpadding=\"0\" cellspacing=\"0\">\n";
+ echo "<tr><td class=\"listtopic\">" . $title . "</td></tr>\n";
+ echo "<tr><td class=\"listlr\"><pre>"; /* no newline after pre */
+
+ $execOutput = "";
+ $execStatus = "";
+ $fd = popen("{$command} 2>&1", "r");
+ while (($line = fgets($fd)) !== FALSE) {
+ echo htmlspecialchars($line, ENT_NOQUOTES);
+ }
+ pclose($fd);
+ echo "</pre></tr>\n";
+ echo "</table>\n";
+}
+
+?>
+
+<html>
+ <body link="#0000CC" vlink="#0000CC" alink="#0000CC">
+ <?php include("fbegin.inc"); ?>
+ <?php if ($savemsg) print_info_box($savemsg); ?>
+
+ <table width="100%" border="0" cellpadding="0" cellspacing="0">
+ <tr><td class="tabnavtbl">
+<?php
+ $tab_array = array();
+ $tab_array[] = array(gettext("General"), false, "/pkg_edit.php?xml=ladvd.xml&id=0");
+ $tab_array[] = array(gettext("Status"), true, "/status_ladvd.php");
+ display_top_tabs($tab_array);
+ ?>
+ </td></tr>
+ <tr>
+ <td>
+ <div id="mainarea">
+ <table class="tabcont" width="100%" border="0" cellpadding="6" cellspacing="0">
+ <tr>
+ <td>
+<?php
+ defCmdT("LADVD Devices", "{$control_script}");
+ defCmdT("LADVD Detailed decode", "{$control_script} -f");
+?>
+ <div id="cmdspace" style="width:100%">
+ <?php listCmds(); ?>
+ <?php execCmds(); ?>
+ </div>
+ </td>
+ </tr>
+ </table>
+ </div>
+ </td>
+ </tr>
+ </table>
+ <?php include("fend.inc"); ?>
+ </body>
+</html>