2012-10-10 13:17:14 +00:00
|
|
|
#!/bin/sh /etc/rc.common
|
2015-12-05 09:57:19 +00:00
|
|
|
# Copyright (C) 2008-2015 OpenWrt.org
|
2024-03-11 22:33:47 +00:00
|
|
|
# shellcheck disable=1091,2034,3037,3043,3045
|
2012-10-10 13:17:14 +00:00
|
|
|
|
|
|
|
START=90
|
2015-12-05 09:57:19 +00:00
|
|
|
STOP=01
|
2012-10-10 13:17:14 +00:00
|
|
|
|
2023-12-17 00:21:12 +00:00
|
|
|
CONFIG_LLDPD_WITH_CDP=y
|
2024-02-03 14:16:09 +00:00
|
|
|
CONFIG_LLDPD_WITH_EDP=y
|
2023-12-17 00:26:21 +00:00
|
|
|
CONFIG_LLDPD_WITH_FDP=y
|
2023-12-16 23:08:08 +00:00
|
|
|
CONFIG_LLDPD_WITH_LLDPMED=y
|
2024-02-03 13:51:49 +00:00
|
|
|
CONFIG_LLDPD_WITH_SNMP=y
|
2023-12-17 00:28:43 +00:00
|
|
|
CONFIG_LLDPD_WITH_SONMP=y
|
2023-12-16 23:08:08 +00:00
|
|
|
|
2015-09-16 08:32:33 +00:00
|
|
|
USE_PROCD=1
|
2023-12-16 22:32:19 +00:00
|
|
|
LLDPDBIN=/usr/sbin/lldpd
|
2015-11-03 11:59:09 +00:00
|
|
|
LLDPCLI=/usr/sbin/lldpcli
|
|
|
|
LLDPSOCKET=/var/run/lldpd.socket
|
2015-10-21 13:11:09 +00:00
|
|
|
LLDPD_CONF=/tmp/lldpd.conf
|
|
|
|
LLDPD_CONFS_DIR=/tmp/lldpd.d
|
2012-10-10 13:17:14 +00:00
|
|
|
|
2023-12-16 22:32:19 +00:00
|
|
|
LLDPD_RUN=/var/run/lldpd
|
|
|
|
LLDPD_RESTART_HASH=${LLDPD_RUN}/lldpd.restart_hash
|
|
|
|
|
|
|
|
. "$IPKG_INSTROOT/lib/functions/network.sh"
|
|
|
|
|
2013-01-02 14:35:43 +00:00
|
|
|
find_release_info()
|
|
|
|
{
|
2016-05-18 07:05:42 +00:00
|
|
|
[ -s /etc/os-release ] && . /etc/os-release
|
|
|
|
[ -z "$PRETTY_NAME" ] && [ -s /etc/openwrt_version ] && \
|
|
|
|
PRETTY_NAME="$(cat /etc/openwrt_version)"
|
2013-01-02 14:35:43 +00:00
|
|
|
|
2017-11-07 08:45:54 +00:00
|
|
|
echo "${PRETTY_NAME:-Unknown OpenWrt release} @ $(cat /proc/sys/kernel/hostname)"
|
2013-01-02 14:35:43 +00:00
|
|
|
}
|
|
|
|
|
2023-12-16 22:32:19 +00:00
|
|
|
get_config_restart_hash() {
|
|
|
|
local var="$1"
|
|
|
|
local _string _hash v
|
|
|
|
|
|
|
|
config_load 'lldpd'
|
|
|
|
|
|
|
|
config_get v 'config' 'lldp_class'; append _string "$v" ","
|
2024-03-11 22:33:47 +00:00
|
|
|
if [ "$CONFIG_LLDPD_WITH_SNMP" = "y" ]; then
|
2024-02-03 13:51:49 +00:00
|
|
|
config_get v 'config' 'agentxsocket'; append _string "$v" ","
|
|
|
|
fi
|
2023-12-16 22:41:22 +00:00
|
|
|
config_get v 'config' 'cid_interface'; append _string "$v" ","
|
2023-12-16 22:52:10 +00:00
|
|
|
config_get v 'config' 'filter'; append _string "$v" ","
|
2023-12-16 22:32:19 +00:00
|
|
|
config_get_bool v 'config' 'readonly_mode'; append _string "$v" ","
|
2023-12-16 22:57:18 +00:00
|
|
|
config_get_bool v 'config' 'lldp_no_version'; append _string "$v" ","
|
2024-03-11 22:33:47 +00:00
|
|
|
if [ "$CONFIG_LLDPD_WITH_LLDPMED" = "y" ]; then
|
2023-12-16 23:08:08 +00:00
|
|
|
config_get_bool v 'config' 'lldpmed_no_inventory'; append _string "$v" ","
|
|
|
|
fi
|
2023-12-16 22:32:19 +00:00
|
|
|
config_get_bool v 'config' 'enable_lldp' 1; append _string "$v" ","
|
2023-12-17 00:17:14 +00:00
|
|
|
config_get_bool v 'config' 'force_lldp'; append _string "$v" ","
|
2024-03-11 22:33:47 +00:00
|
|
|
if [ "$CONFIG_LLDPD_WITH_CDP" = "y" ]; then
|
2023-12-17 00:21:12 +00:00
|
|
|
config_get_bool v 'config' 'enable_cdp'; append _string "$v" ","
|
|
|
|
config_get v 'config' 'cdp_version'; append _string "$v" ","
|
|
|
|
config_get_bool v 'config' 'force_cdp'; append _string "$v" ","
|
|
|
|
config_get_bool v 'config' 'force_cdpv2'; append _string "$v" ","
|
|
|
|
fi
|
2024-03-11 22:33:47 +00:00
|
|
|
if [ "$CONFIG_LLDPD_WITH_EDP" = "y" ]; then
|
2024-02-03 14:16:09 +00:00
|
|
|
config_get_bool v 'config' 'enable_edp'; append _string "$v" ","
|
|
|
|
config_get_bool v 'config' 'force_edp'; append _string "$v" ","
|
|
|
|
fi
|
2024-03-11 22:33:47 +00:00
|
|
|
if [ "$CONFIG_LLDPD_WITH_FDP" = "y" ]; then
|
2023-12-17 00:26:21 +00:00
|
|
|
config_get_bool v 'config' 'enable_fdp'; append _string "$v" ","
|
|
|
|
config_get_bool v 'config' 'force_fdp'; append _string "$v" ","
|
|
|
|
fi
|
2024-03-11 22:33:47 +00:00
|
|
|
if [ "$CONFIG_LLDPD_WITH_SONMP" = "y" ]; then
|
2023-12-17 00:28:43 +00:00
|
|
|
config_get_bool v 'config' 'enable_sonmp'; append _string "$v" ","
|
|
|
|
config_get_bool v 'config' 'force_sonmp'; append _string "$v" ","
|
|
|
|
fi
|
2023-12-16 22:32:19 +00:00
|
|
|
|
2024-03-11 22:33:47 +00:00
|
|
|
_hash=$(echo -n "${_string}" | md5sum | awk '{ print $1 }')
|
2023-12-16 22:32:19 +00:00
|
|
|
export -n "$var=$_hash"
|
|
|
|
}
|
|
|
|
|
2023-12-16 22:41:22 +00:00
|
|
|
get_config_cid_ifaces() {
|
2024-02-08 19:26:13 +00:00
|
|
|
local _ifaces
|
2024-02-08 21:05:11 +00:00
|
|
|
config_get _ifaces 'config' "$2"
|
2023-12-16 22:41:22 +00:00
|
|
|
|
|
|
|
local _iface _ifnames=""
|
2024-04-12 19:27:56 +00:00
|
|
|
# Set noglob to prevent '*' capturing diverse file names in the for ... in
|
|
|
|
set -o noglob
|
2023-12-16 22:41:22 +00:00
|
|
|
for _iface in $_ifaces; do
|
2024-04-12 19:27:56 +00:00
|
|
|
|
|
|
|
local _l2device=""
|
|
|
|
if network_get_physdev _l2device "$_iface" || [ -e "/sys/class/net/$_iface" ]; then
|
|
|
|
append _ifnames "${_l2device:-$_iface}" ","
|
|
|
|
else
|
|
|
|
# Glob case (interface is e.g. '!eth1' or 'eth*' or '*')
|
|
|
|
append _ifnames "$_iface" ","
|
2023-12-16 22:41:22 +00:00
|
|
|
fi
|
|
|
|
done
|
2024-04-12 19:27:56 +00:00
|
|
|
# Turn noglob off i.e. enable glob again
|
|
|
|
set +o noglob
|
2023-12-16 22:41:22 +00:00
|
|
|
|
|
|
|
export -n "${1}=$_ifnames"
|
|
|
|
}
|
|
|
|
|
2015-10-21 13:11:09 +00:00
|
|
|
write_lldpd_conf()
|
|
|
|
{
|
|
|
|
local lldp_description
|
|
|
|
|
|
|
|
config_load 'lldpd'
|
|
|
|
config_get lldp_description 'config' 'lldp_description' "$(find_release_info)"
|
|
|
|
|
2019-05-09 21:19:07 +00:00
|
|
|
local lldp_hostname
|
|
|
|
config_get lldp_hostname 'config' 'lldp_hostname' "$(cat /proc/sys/kernel/hostname)"
|
|
|
|
|
2024-02-08 21:05:11 +00:00
|
|
|
local ifnames
|
|
|
|
get_config_cid_ifaces ifnames "interface"
|
2015-10-21 13:11:09 +00:00
|
|
|
|
2020-02-26 20:44:45 +00:00
|
|
|
local lldp_mgmt_ip
|
|
|
|
config_get lldp_mgmt_ip 'config' 'lldp_mgmt_ip'
|
|
|
|
|
2024-04-22 13:17:33 +00:00
|
|
|
# Configurable capabilities in lldpd >= v1.0.15: defaults to 'unconfigured' i.e. kernel info
|
2023-09-20 18:13:14 +00:00
|
|
|
local lldp_syscapabilities
|
|
|
|
config_get lldp_syscapabilities 'config' 'lldp_syscapabilities'
|
|
|
|
|
2024-04-22 13:17:33 +00:00
|
|
|
# Configurable capabilities in lldpd >= v1.0.15: defaults to on in lldpd
|
2024-04-03 12:06:29 +00:00
|
|
|
local lldp_capability_advertisements
|
2024-04-22 13:17:33 +00:00
|
|
|
config_get_bool lldp_capability_advertisements 'config' 'lldp_capability_advertisements' 1
|
2024-04-03 12:06:29 +00:00
|
|
|
|
2024-04-22 13:17:33 +00:00
|
|
|
# Broadcast management address in lldpd >= 0.7.15: defaults to on in lldpd
|
2024-04-02 11:43:03 +00:00
|
|
|
local lldp_mgmt_addr_advertisements
|
2024-04-22 13:17:33 +00:00
|
|
|
config_get_bool lldp_mgmt_addr_advertisements 'config' 'lldp_mgmt_addr_advertisements' 1
|
2024-04-02 11:43:03 +00:00
|
|
|
|
2024-03-11 22:33:47 +00:00
|
|
|
if [ "$CONFIG_LLDPD_WITH_LLDPMED" = "y" ]; then
|
2023-12-16 23:46:53 +00:00
|
|
|
local lldpmed_fast_start
|
|
|
|
config_get_bool lldpmed_fast_start 'config' 'lldpmed_fast_start' 0
|
|
|
|
|
|
|
|
local lldpmed_fast_start_tx_interval
|
|
|
|
config_get lldpmed_fast_start_tx_interval 'config' 'lldpmed_fast_start_tx_interval' 0
|
2024-02-08 18:15:55 +00:00
|
|
|
|
|
|
|
local lldp_location
|
|
|
|
config_get lldp_location 'config' 'lldp_location'
|
|
|
|
|
2024-02-08 19:35:31 +00:00
|
|
|
local lldp_class
|
|
|
|
config_get lldp_class 'config' 'lldp_class'
|
|
|
|
|
|
|
|
local lldp_policy
|
|
|
|
config_get lldp_policy 'config' 'lldp_policy'
|
|
|
|
|
2023-12-16 23:46:53 +00:00
|
|
|
fi
|
|
|
|
|
2023-12-16 23:49:21 +00:00
|
|
|
local lldp_agenttype
|
|
|
|
config_get lldp_agenttype 'config' 'lldp_agenttype' 'nearest-bridge'
|
|
|
|
|
2023-12-16 23:49:44 +00:00
|
|
|
local lldp_portidsubtype
|
|
|
|
config_get lldp_portidsubtype 'config' 'lldp_portidsubtype' 'macaddress'
|
|
|
|
|
2023-12-17 00:34:37 +00:00
|
|
|
local lldp_platform
|
|
|
|
config_get lldp_platform 'config' 'lldp_platform' ""
|
|
|
|
|
2023-12-17 00:39:48 +00:00
|
|
|
local lldp_tx_interval
|
|
|
|
config_get lldp_tx_interval 'config' 'lldp_tx_interval' 0
|
|
|
|
|
|
|
|
local lldp_tx_hold
|
|
|
|
config_get lldp_tx_hold 'config' 'lldp_tx_hold' 0
|
|
|
|
|
2015-10-21 13:11:09 +00:00
|
|
|
# Clear out the config file first
|
|
|
|
echo -n > "$LLDPD_CONF"
|
2024-02-08 21:05:11 +00:00
|
|
|
[ -n "$ifnames" ] && echo "configure system interface pattern $ifnames" >> "$LLDPD_CONF"
|
2015-10-21 13:11:09 +00:00
|
|
|
[ -n "$lldp_description" ] && echo "configure system description" "\"$lldp_description\"" >> "$LLDPD_CONF"
|
2019-05-09 21:19:07 +00:00
|
|
|
[ -n "$lldp_hostname" ] && echo "configure system hostname" "\"$lldp_hostname\"" >> "$LLDPD_CONF"
|
2020-02-26 20:44:45 +00:00
|
|
|
[ -n "$lldp_mgmt_ip" ] && echo "configure system ip management pattern" "\"$lldp_mgmt_ip\"" >> "$LLDPD_CONF"
|
2024-02-08 20:29:37 +00:00
|
|
|
[ -n "$lldp_syscapabilities" ] && echo "configure system capabilities enabled $lldp_syscapabilities" >> "$LLDPD_CONF"
|
2024-04-03 12:06:29 +00:00
|
|
|
|
2024-03-11 22:33:47 +00:00
|
|
|
if [ "$CONFIG_LLDPD_WITH_LLDPMED" = "y" ] && [ "$lldpmed_fast_start" -gt 0 ]; then
|
|
|
|
if [ "$lldpmed_fast_start_tx_interval" -gt 0 ]; then
|
2024-02-08 20:31:57 +00:00
|
|
|
echo "configure med fast-start tx-interval $lldpmed_fast_start_tx_interval" >> "$LLDPD_CONF"
|
2023-12-16 23:46:53 +00:00
|
|
|
else
|
2024-02-08 20:31:29 +00:00
|
|
|
echo "configure med fast-start enable" >> "$LLDPD_CONF"
|
2023-12-16 23:46:53 +00:00
|
|
|
fi
|
|
|
|
fi
|
2024-03-11 22:33:47 +00:00
|
|
|
if [ "$CONFIG_LLDPD_WITH_LLDPMED" = "y" ]; then
|
2024-02-08 18:15:55 +00:00
|
|
|
# other 'configure med xxx' statements go here
|
|
|
|
|
|
|
|
[ -n "$lldp_location" ] && echo "configure med location" "$lldp_location" >> "$LLDPD_CONF"
|
|
|
|
|
2024-02-08 19:35:31 +00:00
|
|
|
# Manual states that if Class (-M) is 2 or 3, at least one network policy must be defined
|
|
|
|
case "$lldp_class" in
|
|
|
|
2 | 3 ) [ -n "$lldp_policy" ] && echo "configure med policy $lldp_policy" >> "$LLDPD_CONF"
|
|
|
|
;;
|
|
|
|
esac
|
|
|
|
|
2024-02-08 18:15:55 +00:00
|
|
|
fi
|
|
|
|
|
|
|
|
[ -n "$lldp_agenttype" ] && echo "configure lldp agent-type" "\"$lldp_agenttype\"" >> "$LLDPD_CONF"
|
|
|
|
[ -n "$lldp_portidsubtype" ] && echo "configure lldp portidsubtype" "\"$lldp_portidsubtype\"" >> "$LLDPD_CONF"
|
2023-12-17 00:34:37 +00:00
|
|
|
[ -n "$lldp_platform" ] && echo "configure system platform" "\"$lldp_platform\"" >> "$LLDPD_CONF"
|
2024-03-11 22:33:47 +00:00
|
|
|
[ -n "$lldp_tx_interval" ] && echo "configure lldp tx-interval $lldp_tx_interval" >> "$LLDPD_CONF"
|
|
|
|
[ "$lldp_tx_hold" -gt 0 ] && echo "configure lldp tx-hold $lldp_tx_hold" >> "$LLDPD_CONF"
|
2024-04-22 13:17:33 +00:00
|
|
|
[ "$lldp_capability_advertisements" -gt 0 ] && echo "configure lldp capabilities-advertisements" >> "$LLDPD_CONF" ||\
|
|
|
|
echo "unconfigure lldp capabilities-advertisements" >> "$LLDPD_CONF"
|
|
|
|
[ "$lldp_mgmt_addr_advertisements" -gt 0 ] && echo "configure lldp management-addresses-advertisements" >> "$LLDPD_CONF" ||\
|
|
|
|
echo "unconfigure lldp management-addresses-advertisements" >> "$LLDPD_CONF"
|
2015-10-21 13:11:09 +00:00
|
|
|
|
|
|
|
# Since lldpd's sysconfdir is /tmp, we'll symlink /etc/lldpd.d to /tmp/$LLDPD_CONFS_DIR
|
2024-03-11 22:33:47 +00:00
|
|
|
[ -e "$LLDPD_CONFS_DIR" ] || ln -s /etc/lldpd.d "$LLDPD_CONFS_DIR"
|
2015-10-21 13:11:09 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
start_service() {
|
|
|
|
|
2023-12-17 00:17:14 +00:00
|
|
|
local enable_lldp
|
|
|
|
local force_lldp
|
2012-10-10 13:17:14 +00:00
|
|
|
local enable_cdp
|
2023-12-17 00:21:12 +00:00
|
|
|
local cdp_version
|
|
|
|
local force_cdp
|
|
|
|
local force_cdpv2
|
2012-10-10 13:17:14 +00:00
|
|
|
local enable_fdp
|
2023-12-17 00:26:21 +00:00
|
|
|
local force_fdp
|
2012-10-10 13:17:14 +00:00
|
|
|
local enable_sonmp
|
2023-12-17 00:28:43 +00:00
|
|
|
local force_sonmp
|
2012-10-10 13:17:14 +00:00
|
|
|
local enable_edp
|
2024-02-03 14:16:09 +00:00
|
|
|
local force_edp
|
2012-10-10 13:17:14 +00:00
|
|
|
local lldp_class
|
2023-12-16 22:57:18 +00:00
|
|
|
local lldp_no_version
|
2023-12-16 23:08:08 +00:00
|
|
|
local lldpmed_no_inventory
|
2015-03-12 10:06:08 +00:00
|
|
|
local readonly_mode
|
2017-01-05 12:05:57 +00:00
|
|
|
local agentxsocket
|
2023-12-16 22:52:10 +00:00
|
|
|
local filter
|
2012-10-10 13:17:14 +00:00
|
|
|
|
|
|
|
config_load 'lldpd'
|
2023-12-17 00:17:14 +00:00
|
|
|
config_get_bool enable_lldp 'config' 'enable_lldp' 1
|
|
|
|
config_get_bool force_lldp 'config' 'force_lldp' 0
|
2024-03-11 22:33:47 +00:00
|
|
|
if [ "$CONFIG_LLDPD_WITH_CDP" = "y" ]; then
|
2023-12-17 00:21:12 +00:00
|
|
|
config_get_bool enable_cdp 'config' 'enable_cdp' 0
|
|
|
|
config_get cdp_version 'config' 'cdp_version' 'cdpv1v2'
|
|
|
|
config_get_bool force_cdp 'config' 'force_cdp' 0
|
|
|
|
config_get_bool force_cdpv2 'config' 'force_cdpv2' 0
|
|
|
|
fi
|
2024-03-11 22:33:47 +00:00
|
|
|
if [ "$CONFIG_LLDPD_WITH_FDP" = "y" ]; then
|
2023-12-17 00:26:21 +00:00
|
|
|
config_get_bool enable_fdp 'config' 'enable_fdp' 0
|
|
|
|
config_get_bool force_fdp 'config' 'force_fdp' 0
|
|
|
|
fi
|
2024-03-11 22:33:47 +00:00
|
|
|
if [ "$CONFIG_LLDPD_WITH_SONMP" = "y" ]; then
|
2023-12-17 00:28:43 +00:00
|
|
|
config_get_bool enable_sonmp 'config' 'enable_sonmp' 0
|
|
|
|
config_get_bool force_sonmp 'config' 'force_sonmp' 0
|
|
|
|
fi
|
2024-03-11 22:33:47 +00:00
|
|
|
if [ "$CONFIG_LLDPD_WITH_EDP" = "y" ]; then
|
2024-02-03 14:16:09 +00:00
|
|
|
config_get_bool enable_edp 'config' 'enable_edp' 0
|
|
|
|
config_get_bool force_edp 'config' 'force_edp' 0
|
|
|
|
fi
|
2012-10-10 13:17:14 +00:00
|
|
|
config_get lldp_class 'config' 'lldp_class'
|
2023-12-16 22:57:18 +00:00
|
|
|
config_get_bool lldp_no_version 'config' 'lldp_no_version' 0
|
2024-03-11 22:33:47 +00:00
|
|
|
if [ "$CONFIG_LLDPD_WITH_LLDPMED" = "y" ]; then
|
2023-12-16 23:08:08 +00:00
|
|
|
config_get_bool lldpmed_no_inventory 'config' 'lldpmed_no_inventory' 0
|
|
|
|
fi
|
2015-03-12 10:06:08 +00:00
|
|
|
config_get_bool readonly_mode 'config' 'readonly_mode' 0
|
2024-03-11 22:33:47 +00:00
|
|
|
if [ "$CONFIG_LLDPD_WITH_SNMP" = "y" ]; then
|
2024-02-03 13:51:49 +00:00
|
|
|
config_get agentxsocket 'config' 'agentxsocket'
|
|
|
|
fi
|
2023-12-16 22:52:10 +00:00
|
|
|
config_get filter 'config' 'filter' 15
|
2013-01-02 14:35:43 +00:00
|
|
|
|
2023-12-16 22:32:19 +00:00
|
|
|
mkdir -p ${LLDPD_RUN}
|
|
|
|
chown lldp:lldp ${LLDPD_RUN}
|
2015-09-16 08:32:27 +00:00
|
|
|
|
2015-10-21 13:11:09 +00:00
|
|
|
# When lldpd starts, it also loads up what we write in this config file
|
|
|
|
write_lldpd_conf
|
|
|
|
|
2015-09-16 08:32:33 +00:00
|
|
|
procd_open_instance
|
2023-12-16 22:32:19 +00:00
|
|
|
procd_set_param command ${LLDPDBIN}
|
|
|
|
procd_append_param command -d
|
2012-10-10 13:17:14 +00:00
|
|
|
|
2024-03-11 22:33:47 +00:00
|
|
|
if [ "$enable_lldp" -gt 0 ]; then
|
|
|
|
if [ "$force_lldp" -gt 0 ]; then
|
2023-12-17 00:17:14 +00:00
|
|
|
procd_append_param command '-l'
|
|
|
|
fi
|
|
|
|
else
|
|
|
|
# Disable LLDP
|
|
|
|
procd_append_param command '-ll'
|
|
|
|
fi
|
|
|
|
|
2024-03-11 22:33:47 +00:00
|
|
|
if [ "$CONFIG_LLDPD_WITH_CDP" = "y" ] && [ "$enable_cdp" -gt 0 ]; then
|
|
|
|
if [ "$cdp_version" = "cdpv2" ]; then
|
|
|
|
if [ "$force_cdp" -gt 0 ]; then
|
2023-12-17 00:21:12 +00:00
|
|
|
# CDPv1 disabled, CDPv2 forced
|
|
|
|
procd_append_param command '-ccccc'
|
|
|
|
else
|
|
|
|
# CDPv1 disabled, CDPv2 enabled
|
|
|
|
procd_append_param command '-cccc'
|
|
|
|
fi
|
2024-03-11 22:33:47 +00:00
|
|
|
elif [ "$cdp_version" = "cdpv1v2" ]; then
|
|
|
|
if [ "$force_cdp" -gt 0 ] && [ "$force_cdpv2" -gt 0 ]; then
|
2023-12-17 00:21:12 +00:00
|
|
|
# CDPv1 enabled, CDPv2 forced
|
|
|
|
procd_append_param command '-ccc'
|
2024-03-11 22:33:47 +00:00
|
|
|
elif [ "$force_cdp" -gt 0 ]; then
|
2023-12-17 00:21:12 +00:00
|
|
|
# CDPv1 forced, CDPv2 enabled
|
|
|
|
procd_append_param command '-cc'
|
|
|
|
else
|
|
|
|
# CDPv1 and CDPv2 enabled
|
|
|
|
procd_append_param command '-c'
|
|
|
|
fi
|
|
|
|
fi
|
|
|
|
fi
|
|
|
|
|
2024-03-11 22:33:47 +00:00
|
|
|
if [ "$CONFIG_LLDPD_WITH_FDP" = "y" ] && [ "$enable_fdp" -gt 0 ]; then
|
|
|
|
if [ "$force_fdp" -gt 0 ]; then
|
2024-02-08 14:59:27 +00:00
|
|
|
# FDP enabled and forced
|
2023-12-17 00:26:21 +00:00
|
|
|
procd_append_param command '-ff'
|
|
|
|
else
|
|
|
|
# FDP enabled
|
|
|
|
procd_append_param command '-f'
|
|
|
|
fi
|
|
|
|
fi
|
|
|
|
|
2024-03-11 22:33:47 +00:00
|
|
|
if [ "$CONFIG_LLDPD_WITH_SONMP" = "y" ] && [ "$enable_sonmp" -gt 0 ]; then
|
|
|
|
if [ "$force_sonmp" -gt 0 ]; then
|
2023-12-17 00:28:43 +00:00
|
|
|
# SONMP enabled and forced
|
|
|
|
procd_append_param command '-ss'
|
|
|
|
else
|
|
|
|
# SONMP enabled
|
|
|
|
procd_append_param command '-s'
|
|
|
|
fi
|
|
|
|
fi
|
|
|
|
|
2024-03-11 22:33:47 +00:00
|
|
|
if [ "$CONFIG_LLDPD_WITH_EDP" = "y" ] && [ "$enable_edp" -gt 0 ]; then
|
|
|
|
if [ "$force_edp" -gt 0 ]; then
|
2024-02-08 14:59:27 +00:00
|
|
|
# EDP enabled and forced
|
2024-02-03 14:16:09 +00:00
|
|
|
procd_append_param command '-ee'
|
|
|
|
else
|
2024-02-08 14:59:27 +00:00
|
|
|
# EDP enabled
|
2024-02-03 14:16:09 +00:00
|
|
|
procd_append_param command '-e'
|
|
|
|
fi
|
|
|
|
fi
|
2023-12-17 00:28:43 +00:00
|
|
|
|
2024-03-11 22:33:47 +00:00
|
|
|
[ "$readonly_mode" -gt 0 ] && procd_append_param command '-r'
|
|
|
|
[ "$lldp_no_version" -gt 0 ] && procd_append_param command '-k'
|
|
|
|
[ "$CONFIG_LLDPD_WITH_LLDPMED" = "y" ] && [ "$lldpmed_no_inventory" -gt 0 ] && procd_append_param command '-i'
|
2015-10-05 10:29:01 +00:00
|
|
|
[ -n "$lldp_class" ] && procd_append_param command -M "$lldp_class"
|
2024-03-11 22:33:47 +00:00
|
|
|
[ "$CONFIG_LLDPD_WITH_SNMP" = "y" ] && [ -n "$agentxsocket" ] && procd_append_param command -x -X "$agentxsocket"
|
2023-12-16 22:52:10 +00:00
|
|
|
[ -n "$filter" ] && procd_append_param command -H "$filter"
|
2015-09-16 08:32:33 +00:00
|
|
|
|
2023-12-16 22:41:22 +00:00
|
|
|
# ChassisID interfaces
|
|
|
|
local ifnames
|
2024-02-08 21:05:11 +00:00
|
|
|
get_config_cid_ifaces ifnames "cid_interface"
|
|
|
|
|
2023-12-16 22:41:22 +00:00
|
|
|
[ -n "$ifnames" ] && procd_append_param command -C "$ifnames"
|
|
|
|
|
2023-12-16 22:32:19 +00:00
|
|
|
# Overwrite default configuration locations processed by lldpcli at start
|
|
|
|
procd_append_param command -O "$LLDPD_CONF"
|
|
|
|
|
|
|
|
local restart_hash
|
|
|
|
get_config_restart_hash restart_hash
|
2024-03-11 22:33:47 +00:00
|
|
|
echo -n "$restart_hash" > "$LLDPD_RESTART_HASH"
|
2023-12-16 22:32:19 +00:00
|
|
|
|
2015-09-16 08:32:33 +00:00
|
|
|
# set auto respawn behavior
|
|
|
|
procd_set_param respawn
|
|
|
|
procd_close_instance
|
2012-10-10 13:17:14 +00:00
|
|
|
}
|
|
|
|
|
2023-12-16 22:32:19 +00:00
|
|
|
service_triggers() {
|
|
|
|
procd_add_config_trigger "config.change" "lldpd" /etc/init.d/lldpd reload
|
|
|
|
}
|
|
|
|
|
2015-11-03 11:59:09 +00:00
|
|
|
reload_service() {
|
|
|
|
running || return 1
|
2023-12-16 22:32:19 +00:00
|
|
|
|
|
|
|
local running_hash=""
|
|
|
|
local config_hash=""
|
|
|
|
|
|
|
|
get_config_restart_hash config_hash
|
2024-03-11 22:33:47 +00:00
|
|
|
[ -f ${LLDPD_RESTART_HASH} ] && running_hash=$(cat "$LLDPD_RESTART_HASH")
|
2023-12-16 22:32:19 +00:00
|
|
|
|
|
|
|
if [ "x$running_hash" != "x$config_hash" ]; then
|
|
|
|
# Restart LLDPd
|
|
|
|
# Some parameters can't be configured at runtime
|
|
|
|
restart
|
|
|
|
return 0
|
|
|
|
fi
|
2023-12-16 23:46:53 +00:00
|
|
|
|
2024-04-02 11:42:20 +00:00
|
|
|
$LLDPCLI -u "$LLDPSOCKET" >/dev/null 2>&1 <<-EOF
|
2016-01-05 07:40:22 +00:00
|
|
|
pause
|
2015-10-21 13:11:09 +00:00
|
|
|
unconfigure lldp custom-tlv
|
2024-04-03 12:06:29 +00:00
|
|
|
unconfigure lldp capabilities-advertisements
|
2024-04-02 11:43:03 +00:00
|
|
|
unconfigure lldp management-addresses-advertisements
|
2024-04-22 13:17:33 +00:00
|
|
|
# unconfigures user-configured system capabilities, and instead uses the kernel information:
|
|
|
|
unconfigure system capabilities enabled
|
2015-10-21 13:11:09 +00:00
|
|
|
unconfigure system interface pattern
|
|
|
|
unconfigure system description
|
2020-02-26 20:44:45 +00:00
|
|
|
unconfigure system hostname
|
|
|
|
unconfigure system ip management pattern
|
2023-12-17 00:34:37 +00:00
|
|
|
unconfigure system platform
|
2015-10-21 13:11:09 +00:00
|
|
|
EOF
|
2024-03-11 22:33:47 +00:00
|
|
|
if [ "$CONFIG_LLDPD_WITH_LLDPMED" = "y" ]; then
|
2024-04-02 11:42:20 +00:00
|
|
|
$LLDPCLI -u "$LLDPSOCKET" >/dev/null 2>&1 <<-EOF
|
2023-12-16 23:46:53 +00:00
|
|
|
unconfigure med fast-start
|
|
|
|
EOF
|
2023-12-17 00:26:21 +00:00
|
|
|
|
2023-12-16 23:46:53 +00:00
|
|
|
fi
|
2015-10-21 13:11:09 +00:00
|
|
|
# Rewrite lldpd.conf
|
|
|
|
# If something changed it should be included by the lldpcli call
|
|
|
|
write_lldpd_conf
|
2024-04-02 11:42:20 +00:00
|
|
|
$LLDPCLI -u "$LLDPSOCKET" -c "$LLDPD_CONF" -c "$LLDPD_CONFS_DIR" >/dev/null 2>&1
|
2015-11-03 11:59:09 +00:00
|
|
|
# Broadcast update over the wire
|
2024-04-02 11:42:20 +00:00
|
|
|
$LLDPCLI -u "$LLDPSOCKET" >/dev/null 2>&1 <<-EOF
|
2016-01-05 07:40:22 +00:00
|
|
|
resume
|
|
|
|
update
|
|
|
|
EOF
|
2015-11-03 11:59:09 +00:00
|
|
|
return 0
|
|
|
|
}
|
|
|
|
|
2015-09-16 08:32:33 +00:00
|
|
|
stop_service() {
|
2024-04-02 11:42:20 +00:00
|
|
|
rm -rf ${LLDPD_RUN} "$LLDPSOCKET" >/dev/null 2>&1
|
2012-10-10 13:17:14 +00:00
|
|
|
}
|
2023-12-16 22:32:19 +00:00
|
|
|
|