packages/net: add lldpd link-layer discovery protocol daemon
authorJo-Philipp Wich <jow@openwrt.org>
Tue, 30 Dec 2008 07:38:11 +0000 (07:38 +0000)
committerJo-Philipp Wich <jow@openwrt.org>
Tue, 30 Dec 2008 07:38:11 +0000 (07:38 +0000)
SVN-Revision: 13770

net/lldpd/Makefile [new file with mode: 0644]
net/lldpd/files/lldpd.config [new file with mode: 0644]
net/lldpd/files/lldpd.init [new file with mode: 0644]
net/lldpd/patches/001-no-multiuser.patch [new file with mode: 0644]

diff --git a/net/lldpd/Makefile b/net/lldpd/Makefile
new file mode 100644 (file)
index 0000000..48cc327
--- /dev/null
@@ -0,0 +1,60 @@
+#
+# Copyright (C) 2008 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.3
+PKG_RELEASE:=1
+
+PKG_SOURCE:=$(PKG_NAME)-$(PKG_VERSION).tar.gz
+PKG_SOURCE_URL:=http://www.luffy.cx/lldpd/
+PKG_MD5SUM:=317e1144ec7d2781ff123ec16845a2fc
+
+PKG_BUILD_DIR:=$(BUILD_DIR)/$(PKG_NAME)-$(PKG_VERSION)
+PKG_INSTALL_DIR:=$(PKG_BUILD_DIR)/ipkg-install
+
+include $(INCLUDE_DIR)/package.mk
+
+define Package/lldpd
+  SECTION:=net
+  CATEGORY:=Network
+  TITLE:=Link Layer Discovery Protocol damon
+  URL:=http://www.bitwizard.nl/lldpd/
+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
+
+CONFIGURE_ARGS += \
+       --enable-cdp \
+       --enable-fdp \
+       --enable-edp \
+       --enable-lldpmed \
+       --enable-dot1 \
+       --enable-dot3 \
+
+CONFIGURE_VARS += \
+       ac_cv_lib_nl_nl_connect=no \
+
+define Package/lldpd/install
+       $(INSTALL_DIR) $(1)/etc/init.d
+       $(INSTALL_DIR) $(1)/etc/config
+       $(INSTALL_DIR) $(1)/usr/sbin
+       $(INSTALL_BIN) $(PKG_BUILD_DIR)/src/lldpd $(1)/usr/sbin/
+       $(INSTALL_BIN) $(PKG_BUILD_DIR)/src/lldpctl $(1)/usr/sbin/
+       $(INSTALL_BIN) ./files/lldpd.init $(1)/etc/init.d/lldpd
+       $(INSTALL_DATA) ./files/lldpd.config $(1)/etc/config/lldpd
+endef
+
+$(eval $(call BuildPackage,lldpd))
diff --git a/net/lldpd/files/lldpd.config b/net/lldpd/files/lldpd.config
new file mode 100644 (file)
index 0000000..14ba02f
--- /dev/null
@@ -0,0 +1,8 @@
+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"
diff --git a/net/lldpd/files/lldpd.init b/net/lldpd/files/lldpd.init
new file mode 100644 (file)
index 0000000..195a027
--- /dev/null
@@ -0,0 +1,35 @@
+#!/bin/sh /etc/rc.common
+
+START=90
+
+start() {
+       local enable_cdp
+       local enable_fdp
+       local enable_sonmp
+       local enable_edp
+       local lldp_class
+       local lldp_location
+       local args="-d"
+       
+       config_load lldpd
+       config_get_bool enable_cdp config enable_cdp
+       config_get_bool enable_fdp config enable_fdp
+       config_get_bool enable_sonmp config enable_sonmp
+       config_get_bool enable_edp config enable_edp
+       config_get lldp_class config lldp_class
+       config_get lldp_location config lldp_location
+       
+       [ "$enable_cdp" == 1 ] && append args "-c"
+       [ "$enable_fdp" == 1 ] && append args "-f"
+       [ "$enable_sonmp" == 1 ] && append args "-s"
+       [ "$enable_edp" == 1 ] && append args "-e"
+       [ -n "$lldp_location" ] && append args "-L '$lldp_location'"
+       append args "-M ${lldp_class:-4}"
+       
+       eval start-stop-daemon -S -x lldpd -b -q -- $args
+}
+
+stop() {
+       start-stop-daemon -K -q -x lldpd
+       rm -f /var/run/lldpd.socket
+}
diff --git a/net/lldpd/patches/001-no-multiuser.patch b/net/lldpd/patches/001-no-multiuser.patch
new file mode 100644 (file)
index 0000000..965dd0d
--- /dev/null
@@ -0,0 +1,41 @@
+diff -urb lldpd-0.3.orig/src/priv.c lldpd-0.3/src/priv.c
+--- lldpd-0.3.orig/src/priv.c  2008-12-30 07:35:28.000000000 +0100
++++ lldpd-0.3/src/priv.c       2008-12-30 07:40:55.000000000 +0100
+@@ -522,12 +522,14 @@
+               fatal("[priv]: unable to create socket pair for privilege separation");
+       /* Get users */
++      /*
+       if ((user = getpwnam(PRIVSEP_USER)) == NULL)
+               fatal("[priv]: no " PRIVSEP_USER " user for privilege separation");
+       uid = user->pw_uid;
+       if ((group = getgrnam(PRIVSEP_GROUP)) == NULL)
+               fatal("[priv]: no " PRIVSEP_GROUP " group for privilege separation");
+       gid = group->gr_gid;
++      */
+       /* Spawn off monitor */
+       if ((monitored = fork()) < 0)
+@@ -535,17 +537,17 @@
+       switch (monitored) {
+       case 0:
+               /* We are in the children, drop privileges */
+-              if (chroot(chrootdir) == -1)
+-                      fatal("[priv]: unable to chroot");
+-              if (chdir("/") != 0)
++              /*if (chroot(chrootdir) == -1)
++                      fatal("[priv]: unable to chroot");*/
++              if (chdir("/tmp") != 0)
+                       fatal("[priv]: unable to chdir");
+               gidset[0] = gid;
+-              if (setresgid(gid, gid, gid) == -1)
++              /*if (setresgid(gid, gid, gid) == -1)
+                       fatal("[priv]: setresgid() failed");
+               if (setgroups(1, gidset) == -1)
+                       fatal("[priv]: setgroups() failed");
+               if (setresuid(uid, uid, uid) == -1)
+-                      fatal("[priv]: setresuid() failed");
++                      fatal("[priv]: setresuid() failed");*/
+               remote = pair[0];
+               close(pair[1]);
+               priv_ping();