diff options
author | Ermal <ermal.luci@gmail.com> | 2014-02-18 19:41:20 +0000 |
---|---|---|
committer | Ermal <ermal.luci@gmail.com> | 2014-02-18 19:41:20 +0000 |
commit | 6c79f4d46a7f3ea42094e33e123001d6fbf0546b (patch) | |
tree | 2a39b6a1f313dc1ba90ca18bb755e625c14c141c /config/ladvd/ladvd.inc | |
parent | 048bb82a0e2c814da90816657ecedf59fedf8dbd (diff) | |
download | pfsense-packages-6c79f4d46a7f3ea42094e33e123001d6fbf0546b.tar.gz pfsense-packages-6c79f4d46a7f3ea42094e33e123001d6fbf0546b.tar.bz2 pfsense-packages-6c79f4d46a7f3ea42094e33e123001d6fbf0546b.zip |
Add ladvd package from Ticket #3456. With modification to bring it to current levels and pfsense urls.
Diffstat (limited to 'config/ladvd/ladvd.inc')
-rw-r--r-- | config/ladvd/ladvd.inc | 104 |
1 files changed, 104 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(); +} + +?> |