aboutsummaryrefslogtreecommitdiffstats
path: root/package/network/services/lldpd
diff options
context:
space:
mode:
authorJames <>2015-11-04 11:49:21 +0000
committerJames <>2015-11-04 11:49:21 +0000
commit716ca530e1c4515d8683c9d5be3d56b301758b66 (patch)
tree700eb5bcc1a462a5f21dcec15ce7c97ecfefa772 /package/network/services/lldpd
downloadtrunk-47381-master.tar.gz
trunk-47381-master.tar.bz2
trunk-47381-master.zip
trunk-47381HEADmaster
Diffstat (limited to 'package/network/services/lldpd')
-rw-r--r--package/network/services/lldpd/Config.in54
-rw-r--r--package/network/services/lldpd/Makefile108
-rw-r--r--package/network/services/lldpd/files/lldpd.config15
-rw-r--r--package/network/services/lldpd/files/lldpd.init93
-rw-r--r--package/network/services/lldpd/patches/100-os-release.patch39
5 files changed, 309 insertions, 0 deletions
diff --git a/package/network/services/lldpd/Config.in b/package/network/services/lldpd/Config.in
new file mode 100644
index 0000000..93d84e2
--- /dev/null
+++ b/package/network/services/lldpd/Config.in
@@ -0,0 +1,54 @@
+menu "Configuration"
+ depends on PACKAGE_lldpd
+
+config LLDPD_WITH_PRIVSEP
+ bool
+ default y
+ prompt "Enable privilege separation (run lldpd with a chrooted 'lldp' user)"
+
+config LLDPD_WITH_CDP
+ bool
+ default y
+ prompt "Enable support for the Cisco Discovery Protocol (CDP) version 1 and 2"
+
+config LLDPD_WITH_FDP
+ bool
+ default y
+ prompt "Enable support for the Foundry Discovery Protocol (FDP)"
+
+config LLDPD_WITH_EDP
+ bool
+ default y
+ prompt "Enable support for the Extreme Discovery Protocol (EDP)"
+
+config LLDPD_WITH_SONMP
+ bool
+ default y
+ prompt "Enable support for the SynOptics Network Management Protocol"
+
+config LLDPD_WITH_LLDPMED
+ bool
+ prompt "Enable LLDP-MED extension"
+ default y
+
+config LLDPD_WITH_DOT1
+ bool
+ prompt "Enable Dot1 extension (VLAN stuff)"
+ default y
+
+config LLDPD_WITH_DOT3
+ bool
+ prompt "Enable Dot3 extension (PHY stuff)"
+ default y
+
+config LLDPD_WITH_CUSTOM
+ bool
+ prompt "Enable Custom TLVs"
+ default y
+
+config LLDPD_WITH_JSON
+ bool
+ prompt "Enable JSON output for the LLDP Command-Line Interface"
+ default n
+
+endmenu
diff --git a/package/network/services/lldpd/Makefile b/package/network/services/lldpd/Makefile
new file mode 100644
index 0000000..81e4a8f
--- /dev/null
+++ b/package/network/services/lldpd/Makefile
@@ -0,0 +1,108 @@
+#
+# Copyright (C) 2008-2015 OpenWrt.org
+#
+# This is free software, licensed under the GNU General Public License v2.
+# See /LICENSE for more information.
+#
+
+include $(TOPDIR)/rules.mk
+
+PKG_NAME:=lldpd
+PKG_VERSION:=0.7.15
+PKG_RELEASE:=1
+
+PKG_SOURCE:=$(PKG_NAME)-$(PKG_VERSION).tar.gz
+PKG_SOURCE_URL:=http://media.luffy.cx/files/lldpd
+PKG_MD5SUM:=46f7ad97fc1d04084ab11b32fc0ed708
+
+PKG_MAINTAINER:=Jo-Philipp Wich <jow@openwrt.org>
+PKG_LICENSE:=ISC
+
+PKG_FIXUP:=autoreconf
+PKG_INSTALL:=1
+
+TARGET_CFLAGS+=--std=c99
+
+include $(INCLUDE_DIR)/package.mk
+
+define Package/lldpd
+ SECTION:=net
+ CATEGORY:=Network
+ SUBMENU:=Routing and Redirection
+ TITLE:=Link Layer Discovery Protocol daemon
+ URL:=https://github.com/vincentbernat/lldpd/wiki
+ DEPENDS:=+libevent2 +USE_GLIBC:libbsd +LLDPD_WITH_JSON:libjson-c
+ USERID:=lldp=121:lldp=129
+ MENU:=1
+endef
+
+define Package/lldpd/config
+source "$(SOURCE)/Config.in"
+endef
+
+define Package/lldpd/description
+ LLDP (Link Layer Discovery Protocol) is an industry standard protocol designed
+ to supplant proprietary Link-Layer protocols such as
+ Extreme's EDP (Extreme Discovery Protocol) and
+ CDP (Cisco Discovery Protocol).
+ The goal of LLDP is to provide an inter-vendor compatible mechanism to deliver
+ Link-Layer notifications to adjacent network devices.
+endef
+
+define Build/InstallDev
+ $(INSTALL_DIR) $(1)/usr/lib
+ $(CP) $(PKG_INSTALL_DIR)/usr/lib/liblldpctl.so* $(1)/usr/lib/
+ $(INSTALL_DIR) $(1)/usr/include
+ $(CP) $(PKG_INSTALL_DIR)/usr/include/lldpctl.h $(1)/usr/include/lldpctl.h
+ $(CP) $(PKG_INSTALL_DIR)/usr/include/lldp-const.h $(1)/usr/include/lldp-const.h
+endef
+
+define Package/lldpd/install
+ $(INSTALL_DIR) $(1)/etc/init.d
+ $(INSTALL_DIR) $(1)/etc/lldpd.d
+ $(INSTALL_DIR) $(1)/etc/config
+ $(INSTALL_DIR) $(1)/usr/lib $(1)/usr/sbin
+ $(CP) $(PKG_INSTALL_DIR)/usr/sbin/lldp{cli,ctl,d} $(1)/usr/sbin/
+ $(CP) $(PKG_INSTALL_DIR)/usr/lib/liblldpctl.so* $(1)/usr/lib/
+ $(INSTALL_BIN) ./files/lldpd.init $(1)/etc/init.d/lldpd
+ $(INSTALL_DATA) ./files/lldpd.config $(1)/etc/config/lldpd
+ifneq ($(CONFIG_LLDPD_WITH_CDP),y)
+ sed -i -e '/cdp/d' $(1)/etc/init.d/lldpd $(1)/etc/config/lldpd
+endif
+ifneq ($(CONFIG_LLDPD_WITH_FDP),y)
+ sed -i -e '/fdp/d' $(1)/etc/init.d/lldpd $(1)/etc/config/lldpd
+endif
+ifneq ($(CONFIG_LLDPD_WITH_EDP),y)
+ sed -i -e '/edp/d' $(1)/etc/init.d/lldpd $(1)/etc/config/lldpd
+endif
+ifneq ($(CONFIG_LLDPD_WITH_SONMP),y)
+ sed -i -e '/sonmp/d' $(1)/etc/init.d/lldpd $(1)/etc/config/lldpd
+endif
+endef
+
+define Package/lldpd/conffiles
+/etc/config/lldpd
+endef
+
+CONFIGURE_ARGS += \
+ $(if $(CONFIG_LLDPD_WITH_PRIVSEP), \
+ --with-privsep-user=lldp \
+ --with-privsep-group=lldp \
+ --with-privsep-chroot=/var/run/lldp \
+ ,--disable-privsep) \
+ --with-readline=no \
+ --with-embedded-libevent=no \
+ --disable-hardening \
+ --without-xml \
+ $(if $(CONFIG_LLDPD_WITH_CDP),,--disable-cdp) \
+ $(if $(CONFIG_LLDPD_WITH_FDP),,--disable-fdp) \
+ $(if $(CONFIG_LLDPD_WITH_EDP),,--disable-edp) \
+ $(if $(CONFIG_LLDPD_WITH_LLDPMED),,--disable-lldpmed) \
+ $(if $(CONFIG_LLDPD_WITH_DOT1),,--disable-dot1) \
+ $(if $(CONFIG_LLDPD_WITH_DOT3),,--disable-dot3) \
+ $(if $(CONFIG_LLDPD_WITH_CUSTOM),,--disable-custom) \
+ $(if $(CONFIG_LLDPD_WITH_SONMP),,--disable-sonmp) \
+ $(if $(CONFIG_LLDPD_WITH_JSON),--with-json=json-c,--with-json=no)
+
+
+$(eval $(call BuildPackage,lldpd))
diff --git a/package/network/services/lldpd/files/lldpd.config b/package/network/services/lldpd/files/lldpd.config
new file mode 100644
index 0000000..48728e0
--- /dev/null
+++ b/package/network/services/lldpd/files/lldpd.config
@@ -0,0 +1,15 @@
+config lldpd config
+ option enable_cdp 1
+ option enable_fdp 1
+ option enable_sonmp 1
+ option enable_edp 1
+
+ option lldp_class 4
+ option lldp_location "2:FR:6:Commercial Rd:3:Roseville:19:4"
+
+ # if empty, the distribution description is sent
+ #option lldp_description "OpenWrt System"
+
+ # interfaces to listen on
+ list interface "loopback"
+ list interface "lan"
diff --git a/package/network/services/lldpd/files/lldpd.init b/package/network/services/lldpd/files/lldpd.init
new file mode 100644
index 0000000..04e5b8c
--- /dev/null
+++ b/package/network/services/lldpd/files/lldpd.init
@@ -0,0 +1,93 @@
+#!/bin/sh /etc/rc.common
+# Copyright (C) 2008-2012 OpenWrt.org
+
+START=90
+
+USE_PROCD=1
+LLDPCLI=/usr/sbin/lldpcli
+LLDPSOCKET=/var/run/lldpd.socket
+
+find_release_info()
+{
+ [ -s /etc/openwrt_release ] && . /etc/openwrt_release
+ [ -z "$DISTRIB_DESCRIPTION" ] && [ -s /etc/openwrt_version ] && \
+ DISTRIB_DESCRIPTION="$(cat /etc/openwrt_version)"
+
+ echo "${DISTRIB_DESCRIPTION:-Unknown OpenWrt release} @ $(cat /proc/sys/kernel/hostname)"
+}
+
+start_service() {
+ . /lib/functions/network.sh
+
+ local enable_cdp
+ local enable_fdp
+ local enable_sonmp
+ local enable_edp
+ local lldp_class
+ local lldp_location
+ local lldp_description
+ local readonly_mode
+
+ config_load 'lldpd'
+ config_get_bool enable_cdp 'config' 'enable_cdp' 0
+ config_get_bool enable_fdp 'config' 'enable_fdp' 0
+ config_get_bool enable_sonmp 'config' 'enable_sonmp' 0
+ config_get_bool enable_edp 'config' 'enable_edp' 0
+ config_get lldp_class 'config' 'lldp_class'
+ config_get lldp_location 'config' 'lldp_location'
+ config_get lldp_description 'config' 'lldp_description' "$(find_release_info)"
+ config_get_bool readonly_mode 'config' 'readonly_mode' 0
+
+ local ifaces
+ config_get ifaces 'config' 'interface'
+
+ local iface ifnames=""
+ for iface in $ifaces; do
+ local ifname=""
+ if network_get_device ifname "$iface" || [ -e "/sys/class/net/$iface" ]; then
+ append ifnames "${ifname:-$iface}" ","
+ fi
+ done
+
+ mkdir -p /var/run/lldp
+ chown lldp:lldp /var/run/lldp
+
+ procd_open_instance
+ procd_set_param command /usr/sbin/lldpd
+ procd_append_param command -d # don't daemonize, procd will handle that for us
+
+ [ -n "$ifnames" ] && procd_append_param command -I "$ifnames"
+ [ $enable_cdp -gt 0 ] && procd_append_param command '-c'
+ [ $enable_fdp -gt 0 ] && procd_append_param command '-f'
+ [ $enable_sonmp -gt 0 ] && procd_append_param command '-s'
+ [ $enable_edp -gt 0 ] && procd_append_param command '-e'
+ [ $readonly_mode -gt 0 ] && procd_append_param command '-r'
+ [ -n "$lldp_class" ] && procd_append_param command -M "$lldp_class"
+ [ -n "$lldp_description" ] && procd_append_param command -S "$lldp_description"
+
+ # set auto respawn behavior
+ procd_set_param respawn
+ procd_append_param respawn 3600
+ procd_append_param respawn 5
+ procd_append_param respawn -1
+ procd_close_instance
+}
+
+service_running() {
+ pgrep -x /usr/sbin/lldpd &> /dev/null
+}
+
+reload_service() {
+ running || return 1
+ # Custom TLVs are special and should be
+ # reloaded from config during lldpd reload
+ $LLDPCLI -u $LLDPSOCKET unconfigure lldp custom-tlv &> /dev/null
+ $LLDPCLI -u $LLDPSOCKET -c /etc/lldpd.conf -c /etc/lldpd.d &> /dev/null
+ # Broadcast update over the wire
+ $LLDPCLI -u $LLDPSOCKET update &> /dev/null
+ return 0
+}
+
+stop_service() {
+ rm -rf /var/run/lldp $LLDPSOCKET
+}
diff --git a/package/network/services/lldpd/patches/100-os-release.patch b/package/network/services/lldpd/patches/100-os-release.patch
new file mode 100644
index 0000000..a906f39
--- /dev/null
+++ b/package/network/services/lldpd/patches/100-os-release.patch
@@ -0,0 +1,39 @@
+Index: lldpd-0.7.15/src/daemon/lldpd.c
+===================================================================
+--- lldpd-0.7.15.orig/src/daemon/lldpd.c
++++ lldpd-0.7.15/src/daemon/lldpd.c
+@@ -736,6 +736,10 @@ lldpd_get_os_release() {
+ fp = fopen("/usr/lib/os-release", "r");
+ }
+ if (!fp) {
++ log_debug("localchassis", "could not open /usr/lib/os-release");
++ fp = fopen("/etc/openwrt_release", "r");
++ }
++ if (!fp) {
+ log_info("localchassis",
+ "could not open either /etc/os-release or /usr/lib/os-release");
+ return NULL;
+@@ -745,7 +749,8 @@ lldpd_get_os_release() {
+ key = strtok(line, "=");
+ val = strtok(NULL, "=");
+
+- if (strncmp(key, "PRETTY_NAME", sizeof(line)) == 0) {
++ if (strncmp(key, "PRETTY_NAME", sizeof(line)) == 0 ||
++ strncmp(key, "DISTRIB_DESCRIPTION", sizeof(line)) == 0) {
+ strlcpy(release, val, sizeof(line));
+ break;
+ }
+@@ -755,11 +760,11 @@ lldpd_get_os_release() {
+ /* Remove trailing newline and all " in the string. */
+ ptr1 = release + strlen(release) - 1;
+ while (ptr1 != release &&
+- ((*ptr1 == '"') || (*ptr1 == '\n'))) {
++ ((*ptr1 == '"') || (*ptr1 == '\n') || (*ptr1 == '\''))) {
+ *ptr1 = '\0';
+ ptr1--;
+ }
+- if (release[0] == '"')
++ if (release[0] == '"' || release[0] == '\'')
+ return release+1;
+ return release;
+ }