From: Moritz Warning Date: Mon, 13 Sep 2021 19:36:47 +0000 (+0200) Subject: uradvd: add new package X-Git-Url: http://git.cdn.openwrt.org/?a=commitdiff_plain;h=1506e40c7810b483cc613ab2db6be0051d667ce6;p=feed%2Fpackages.git uradvd: add new package Send IPv6 router advertisments. Signed-off-by: Moritz Warning Co-authored-by: Matthias Schiffer --- diff --git a/net/uradvd/Makefile b/net/uradvd/Makefile new file mode 100644 index 0000000000..0d6544737d --- /dev/null +++ b/net/uradvd/Makefile @@ -0,0 +1,37 @@ +include $(TOPDIR)/rules.mk + +PKG_NAME:=uradvd +PKG_RELEASE:=1 + +PKG_SOURCE_PROTO:=git +PKG_SOURCE_URL=https://github.com/freifunk-gluon/uradvd.git +PKG_SOURCE_DATE:=2021-09-14 +PKG_SOURCE_VERSION:=9b0da60e27c67305d251b10163e388191d566d7a +PKG_MIRROR_HASH=c3c9cb5d3a7b30503bff64541bbcaffa84b33e0de39560a5efae077df4e9b134 + +PKG_MAINTAINER:=Moritz Warning +PKG_LICENSE:=BSD-2-Clause +PKG_LICENSE_FILES:=LICENSE + +include $(INCLUDE_DIR)/package.mk + +define Package/uradvd + SECTION:=net + CATEGORY:=Network + TITLE:=A tiny radvd +endef + +define Package/uradvd/description + Advertise an IPv6 prefix/route via SLAAC. +endef + +define Package/uradvd/install + $(INSTALL_DIR) $(1)/etc/config/ + $(INSTALL_DATA) ./files/uradvd.config $(1)/etc/config/ + $(INSTALL_DIR) $(1)/etc/init.d/ + $(INSTALL_BIN) ./files/uradvd.init $(1)/etc/init.d/ + $(INSTALL_DIR) $(1)/usr/sbin + $(INSTALL_BIN) $(PKG_BUILD_DIR)/uradvd $(1)/usr/sbin/ +endef + +$(eval $(call BuildPackage,uradvd)) diff --git a/net/uradvd/files/uradvd.config b/net/uradvd/files/uradvd.config new file mode 100644 index 0000000000..aa5486de30 --- /dev/null +++ b/net/uradvd/files/uradvd.config @@ -0,0 +1,11 @@ + +config interface + option enabled '0' + # send router advertisment over this device + # alternative: option device 'lan' + option ifname 'br-lan' + # lifetime of the default route (in seconds) + option default_lifetime '0' + list prefix_on_link '300::/64' + list prefix_off_link '200::/64' + list dns '2001:4860:4860::8888' diff --git a/net/uradvd/files/uradvd.init b/net/uradvd/files/uradvd.init new file mode 100755 index 0000000000..a80b6ed1d5 --- /dev/null +++ b/net/uradvd/files/uradvd.init @@ -0,0 +1,72 @@ +#!/bin/sh /etc/rc.common + +START=50 +USE_PROCD=1 +ARGS="" + +append_prefix_off_link() { + ARGS="$ARGS -a $1" +} + +append_prefix_on_link() { + ARGS="$ARGS -p $1" +} + +append_dns() { + ARGS="$ARGS --rdnss $1" +} + +start_instance() { + local cfg="$1" enabled device ifname default_lifetime + + ARGS="" + + config_get_bool enabled $cfg 'enabled' 1 + config_get device $cfg 'device' + config_get ifname $cfg 'ifname' + config_get default_lifetime $cfg 'default_lifetime' + + if [ "$enabled" != "1" ]; then + exit 0 + fi + + if [ -n "$device" ] && [ -n "$ifname" ]; then + echo "either set device or ifname" >&2 + exit 1 + fi + + if [ -z "$device" ] && [ -z "$ifname" ]; then + echo "either set device or ifname" >&2 + exit 1 + fi + + if [ -z "$ifname" ]; then + network_get_device 'ifname' "$ifname" + fi + + if [ -z "$ifname" ]; then + echo "no valid device or ifname set" >&2 + exit 1 + fi + + if [ -n "$default_lifetime" ]; then + ARGS="$ARGS --default-lifetime $default_lifetime" + fi + + ARGS="$ARGS -i $ifname" + + + config_list_foreach $cfg 'prefix_off_link' append_prefix_off_link + config_list_foreach $cfg 'prefix_on_link' append_prefix_on_link + config_list_foreach $cfg "dns" append_dns + + procd_open_instance + procd_set_param command /usr/sbin/uradvd $ARGS + procd_set_param respawn + procd_close_instance +} + +start_service() { + config_load uradvd + config_foreach start_instance interface +}