From: Travis Kemen Date: Sun, 14 Mar 2010 18:16:29 +0000 (+0000) Subject: Update wide-dhcpv6 package, from #6820 X-Git-Url: http://git.lede-project.org./?a=commitdiff_plain;h=c661461f0a098da8f43400cd4d96122bdf606fae;p=openwrt%2Fsvn-archive%2Fpackages.git Update wide-dhcpv6 package, from #6820 SVN-Revision: 20212 --- diff --git a/ipv6/wide-dhcpv6/Makefile b/ipv6/wide-dhcpv6/Makefile index 30119dfdc..32fae025d 100644 --- a/ipv6/wide-dhcpv6/Makefile +++ b/ipv6/wide-dhcpv6/Makefile @@ -1,15 +1,9 @@ -# -# Copyright (C) 2006-2010 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:=wide-dhcpv6 PKG_VERSION:=20080615 -PKG_RELEASE:=1 +PKG_RELEASE:=3 PKG_SOURCE:=$(PKG_NAME)-$(PKG_VERSION).tar.gz PKG_SOURCE_URL:=@SF/$(PKG_NAME) @@ -20,46 +14,122 @@ include $(INCLUDE_DIR)/package.mk define Package/wide-dhcpv6/Default SECTION:=ipv6 CATEGORY:=IPv6 - TITLE:=IPv6 DHCPv6 implementaion for BSD and Linux - URL:=http://wide-dhcpv6.sourceforge.net/ + TITLE:=WIDE-DHCPv6 + SUBMENU:=wide-dhcpv6 + DEPENDS:=+kmod-ipv6 + URL:=https://sourceforge.net/projects/wide-dhcpv6/ endef -define Package/wide-dhcpv6/description -WIDE-DHCPv6 is an open-source implementation of Dynamic Host Configuration -Protocol for IPv6 (DHCPv6) originally developed by the KAME project. The -implementation mainly conforms to the following standards: RFC3315,3319,3633, -3646,4075,4272,etc. +define Package/wide-dhcpv6-client + $(call Package/wide-dhcpv6/Default) + TITLE+= client endef -define Package/wide-dhcpv6-client - $(call Package/wide-dhcpv6/Default) - TITLE+= client +define Package/wide-dhcpv6-client/description + WIDE-DHCPv6 is an open-source implementation of Dynamic Host Configuration Protocol + for IPv6 (DHCPv6) originally developed by the KAME project. The implementation + mainly conforms to the following standards: RFC3315,3319,3633,3646,4075,4272,etc. + + This package installs the client component. endef define Package/wide-dhcpv6-server - $(call Package/wide-dhcpv6/Default) - TITLE+= server + $(call Package/wide-dhcpv6/Default) + TITLE+= server +endef + +define Package/wide-dhcpv6-server/description + WIDE-DHCPv6 is an open-source implementation of Dynamic Host Configuration Protocol + for IPv6 (DHCPv6) originally developed by the KAME project. The implementation + mainly conforms to the following standards: RFC3315,3319,3633,3646,4075,4272,etc. + + This package installs the server component. endef define Package/wide-dhcpv6-relay - $(call Package/wide-dhcpv6/Default) - TITLE+= relay + $(call Package/wide-dhcpv6/Default) + TITLE+= relay endef -define Package/wide-dhcpv6-ctl - $(call Package/wide-dhcpv6/Default) - TITLE+= ctl +define Package/wide-dhcpv6-relay/description + WIDE-DHCPv6 is an open-source implementation of Dynamic Host Configuration Protocol + for IPv6 (DHCPv6) originally developed by the KAME project. The implementation + mainly conforms to the following standards: RFC3315,3319,3633,3646,4075,4272,etc. + + This package installs the relay component. +endef + +define Package/wide-dhcpv6-control + $(call Package/wide-dhcpv6/Default) + TITLE+= client and server control utility +endef + +define Package/wide-dhcpv6-control/description + WIDE-DHCPv6 is an open-source implementation of Dynamic Host Configuration Protocol + for IPv6 (DHCPv6) originally developed by the KAME project. The implementation + mainly conforms to the following standards: RFC3315,3319,3633,3646,4075,4272,etc. + + This package installs the client and server control utility. +endef + +define Build/Configure + $(call Build/Configure/Default,--with-localdbdir=/var) +endef + +define Build/Compile + $(MAKE) -C $(PKG_BUILD_DIR) \ + DESTDIR="$(PKG_INSTALL_DIR)" \ + all +endef + +define Package/wide-dhcpv6-client/conffiles +/etc/config/dhcp6c endef define Package/wide-dhcpv6-client/install - $(INSTALL_DIR) $(1)/sbin - $(INSTALL_BIN) $(PKG_BUILD_DIR)/dhcp6c $(1)/sbin + $(INSTALL_DIR) $(1)/usr/sbin + $(INSTALL_BIN) $(PKG_BUILD_DIR)/dhcp6c $(1)/usr/sbin + $(INSTALL_DIR) $(1)/etc/config + $(INSTALL_CONF) ./files/dhcp6c.conf $(1)/etc/config/dhcp6c + $(INSTALL_DIR) $(1)/etc/init.d + $(INSTALL_BIN) ./files/dhcp6c.init $(1)/etc/init.d/dhcp6c + $(INSTALL_DIR) $(1)/etc/hotplug.d/iface + $(INSTALL_DATA) ./files/dhcp6c.hotplug $(1)/etc/hotplug.d/iface/40-dhcp6c + $(INSTALL_DIR) $(1)/etc/hotplug.d/dhcp6c + $(INSTALL_DATA) ./files/dhcp6c-dnsmasq.hotplug $(1)/etc/hotplug.d/dhcp6c/10-dnsmasq + $(INSTALL_DATA) ./files/dhcp6c-radvd.hotplug $(1)/etc/hotplug.d/dhcp6c/20-radvd + $(INSTALL_DIR) $(1)/usr/bin + $(INSTALL_BIN) ./files/dhcp6c-state $(1)/usr/bin/dhcp6c-state +endef +define Package/wide-dhcpv6-server/conffiles +/etc/config/dhcp6s +endef + +define Package/wide-dhcpv6-server/install + $(INSTALL_DIR) $(1)/usr/sbin + $(INSTALL_BIN) $(PKG_BUILD_DIR)/dhcp6s $(1)/usr/sbin $(INSTALL_DIR) $(1)/etc - $(INSTALL_DATA) ./files/dhcp6c.config $(1)/etc/dhcp6c.conf + $(INSTALL_CONF) $(PKG_BUILD_DIR)/dhcp6s.conf.sample $(1)/etc + $(INSTALL_DIR) $(1)/etc/config + $(INSTALL_CONF) ./files/dhcp6s.conf $(1)/etc/config/dhcp6s + $(INSTALL_DIR) $(1)/etc/init.d + $(INSTALL_BIN) ./files/dhcp6s.init $(1)/etc/init.d/dhcp6s + $(INSTALL_DIR) $(1)/etc/hotplug.d/iface + $(INSTALL_DATA) ./files/dhcp6s.hotplug $(1)/etc/hotplug.d/iface/50-dhcp6s +endef + +define Package/wide-dhcpv6-relay/install + $(INSTALL_DIR) $(1)/usr/sbin + $(INSTALL_BIN) $(PKG_BUILD_DIR)/dhcp6relay $(1)/usr/sbin +endef + +define Package/wide-dhcpv6-control/install + $(INSTALL_DIR) $(1)/usr/sbin + $(INSTALL_BIN) $(PKG_BUILD_DIR)/dhcp6ctl $(1)/usr/sbin endef $(eval $(call BuildPackage,wide-dhcpv6-client)) $(eval $(call BuildPackage,wide-dhcpv6-server)) $(eval $(call BuildPackage,wide-dhcpv6-relay)) -$(eval $(call BuildPackage,wide-dhcpv6-ctl)) +$(eval $(call BuildPackage,wide-dhcpv6-control)) diff --git a/ipv6/wide-dhcpv6/files/dhcp6c-dnsmasq.hotplug b/ipv6/wide-dhcpv6/files/dhcp6c-dnsmasq.hotplug new file mode 100644 index 000000000..12e18a25c --- /dev/null +++ b/ipv6/wide-dhcpv6/files/dhcp6c-dnsmasq.hotplug @@ -0,0 +1,53 @@ +#!/bin/sh + +. /etc/functions.sh + +getoption() { + local cfg=$1 + config_get resolvfile "$cfg" resolvfile +} + +config_load dhcp6c + +local dns +config_get dns basic dns none +[ $dns != "dnsmasq" ] && return 0 + +if [ "$ACTION" = "start" ]; then + + local domain_name_servers + config_get domain_name_servers state domain_name_servers + + if [ -n "$domain_name_servers" ]; then + + config_load dhcp + + local resolvfile + config_foreach getoption dnsmasq + + if [ -n "$resolvfile" ]; then + + cp -pf $resolvfile "$resolvfile.dhcp6c_backup" + + for nameserver in $domain_name_servers; do + echo nameserver $nameserver >> $resolvfile + done + + fi + + fi + +fi + +if [ "$ACTION" = "stop" ]; then + + config_load dhcp + + local resolvfile + config_foreach getoption dnsmasq + if [ -f "$resolvfile.dhcp6c_backup" ]; then + mv -f "$resolvfile.dhcp6c_backup" $resolvfile + fi + +fi + diff --git a/ipv6/wide-dhcpv6/files/dhcp6c-radvd.hotplug b/ipv6/wide-dhcpv6/files/dhcp6c-radvd.hotplug new file mode 100644 index 000000000..5c08e8c4e --- /dev/null +++ b/ipv6/wide-dhcpv6/files/dhcp6c-radvd.hotplug @@ -0,0 +1,3 @@ +#!/bin/sh + +[ -f /etc/config/radvd ] && /etc/init.d/radvd restart diff --git a/ipv6/wide-dhcpv6/files/dhcp6c-state b/ipv6/wide-dhcpv6/files/dhcp6c-state new file mode 100644 index 000000000..313439761 --- /dev/null +++ b/ipv6/wide-dhcpv6/files/dhcp6c-state @@ -0,0 +1,18 @@ +#!/bin/sh + +. /etc/functions.sh + +uci_revert_state dhcp6c state +uci_set_state dhcp6c state "" dhcp6c_state +uci_set_state dhcp6c state domain_name_servers "$new_domain_name_servers" +uci_set_state dhcp6c state domain_name "$domain_name" +uci_set_state dhcp6c state ntp_servers "$ntp_servers" +uci_set_state dhcp6c state sip_server_address "$sip_server_address" +uci_set_state dhcp6c state sip_domain_name "$sip_domain_name" +uci_set_state dhcp6c state nis_server_address "$nis_server_address" +uci_set_state dhcp6c state nis_domain_name "$nis_domain_name" +uci_set_state dhcp6c state nisp_server_address "$nisp_server_address" +uci_set_state dhcp6c state nisp_domain_name "$nisp_domain_name" +uci_set_state dhcp6c state bcmcs_server_address "$bcmcs_server_address" +uci_set_state dhcp6c state bcmcs_domain_name "$bcmcs_domain_name" + diff --git a/ipv6/wide-dhcpv6/files/dhcp6c.conf b/ipv6/wide-dhcpv6/files/dhcp6c.conf new file mode 100644 index 000000000..9ea543c83 --- /dev/null +++ b/ipv6/wide-dhcpv6/files/dhcp6c.conf @@ -0,0 +1,37 @@ +config 'dhcp6c' 'basic' + option 'enabled' '0' # 1 = enabled; 0 = disabled + option 'interface' 'wan' # This is the interface the DHCPv6 client will run on + option 'dns' 'dnsmasq' # Which DNS server you run (only dnsmasq currently supported) + + # Send options (1 = send; 0 = do not send) + option 'pd' '1' # Prefix Delegation + option 'na' '0' # Non-Temporary Address + option 'rapid_commit' '1' # Rapid Commit + + # Request options (1 = request; 0 = do not request) + option 'domain_name_servers' '1' + option 'domain_name' '0' + option 'ntp_servers' '0' + option 'sip_server_address' '0' + option 'sip_domain_name' '0' + option 'nis_server_address' '0' + option 'nis_domain_name' '0' + option 'nisp_server_address' '0' + option 'nisp_domain_name' '0' + option 'bcmcs_server_address' '0' + option 'bcmcs_domain_name' '0' + + # Script to run when a reply is received + option 'script' '/usr/bin/dhcp6c-state' + +# Define one or more interfaces on which prefixes should be assigned +config 'interface' 'loopback' + option 'enabled' '1' # 1 = enabled; 0 = disabled + option 'sla_id' '0' # Site level aggregator identifier specified in decimal (subnet) + option 'sla_len' '4' # Site level aggregator length (64 - size of prefix being delegated) + # e.g. /60 from ISP -> 64 - 60 = 4 + +config 'interface' 'lan' + option 'enabled' '1' + option 'sla_id' '1' + option 'sla_len' '4' diff --git a/ipv6/wide-dhcpv6/files/dhcp6c.config b/ipv6/wide-dhcpv6/files/dhcp6c.config index d557ad97c..e69de29bb 100644 --- a/ipv6/wide-dhcpv6/files/dhcp6c.config +++ b/ipv6/wide-dhcpv6/files/dhcp6c.config @@ -1,25 +0,0 @@ -# The followings are a sample configuration for requiring the "stateless" -# DHCPv6 service. -# interface eth0 { -# information-only; -#}; - - -# The followings are a sample configuration to be delegated an IPv6 prefix -# from an upstream service provider. With this configuration dhcp6c will -# send solicit messages containing an IA_PD option, with an IAID 0, on to -# an upstream PPP link, ppp0. After receiving some prefixes from a server, -# dhcp6c will then configure derived IPv6 prefixes with the SLA ID 1 on a -# local ethernet interface, ne0. Note that the IAID for the id-assoc -# statement is 0 according to the default. - -interface ppp1 { - send ia-pd 0; -}; - -id-assoc pd { - prefix-interface lan0 { - sla-id 1; - sla-len 8; - }; -}; diff --git a/ipv6/wide-dhcpv6/files/dhcp6c.hotplug b/ipv6/wide-dhcpv6/files/dhcp6c.hotplug new file mode 100644 index 000000000..947c53c0e --- /dev/null +++ b/ipv6/wide-dhcpv6/files/dhcp6c.hotplug @@ -0,0 +1,20 @@ +#!/bin/sh + +include /lib/network + +config_load "dhcp6c" + +local enabled +config_get_bool enabled basic enabled 0 +[ $enabled -eq 0 ] && return 0 + +local client_interface +config_get client_interface basic interface + +if [ "$INTERFACE" = "$client_interface" ] && [ "$ACTION" = "ifup" ]; then + /etc/init.d/dhcp6c start +fi + +if [ "$INTERFACE" = "$client_interface" ] && [ "$ACTION" = "ifdown" ]; then + /etc/init.d/dhcp6c stop +fi diff --git a/ipv6/wide-dhcpv6/files/dhcp6c.init b/ipv6/wide-dhcpv6/files/dhcp6c.init new file mode 100644 index 000000000..4be165d8a --- /dev/null +++ b/ipv6/wide-dhcpv6/files/dhcp6c.init @@ -0,0 +1,131 @@ +#!/bin/sh /etc/rc.common + +DHCP6C_REQUEST_OPTIONS='domain_name_servers domain_name ntp_servers sip_server_address sip_domain_name nis_server_address nis_domain_name nisp_server_address nisp_domain_name bcmcs_server_address bcmcs_domain_name' + +get_ifname() { + local interface=$1 + local ifname + scan_interfaces + config_get ifname "$interface" ifname + printf '%s\n' "$ifname" + return 0 +} + +dhcp6c_write_interface() { + local cfg=$1 + local sla_id + local sla_len + local enabled + + config_get_bool enabled "$cfg" enabled 0 + + if [ $enabled -ne 0 ]; then + + config_get sla_id "$cfg" sla_id + config_get sla_len "$cfg" sla_len + + printf '\tprefix-interface %s {\n' "$(get_ifname $cfg)" + printf '\t\tsla-id %s;\n' "$sla_id" + printf '\t\tsla-len %s;\n' "$sla_len" + printf '\t};\n' + + fi + +} + +dhcp6c_write_request() { + printf '\trequest %s;\n' $1 | sed -e s/_/-/g +} + +dhcp6c_write_config() { + + local pd + local na + config_get_bool pd basic pd 0 + config_get_bool na basic na 0 + + printf 'interface %s {\n' "$client_ifname" + + if [ $pd -ne 0 ]; then + printf '\tsend ia-pd 0;\n' + fi + + if [ $na -ne 0 ]; then + printf '\tsend ia-na 0;\n' + fi + + local rapid_commit + config_get_bool rapid_commit basic rapid_commit 0 + [ $rapid_commit -ne 0 ] && printf '\tsend rapid-commit;\n' + + local script + config_get script basic script + [ "$script" != "" ] && printf '\tscript "%s";\n' "$script" + + local request + local value + for request in $DHCP6C_REQUEST_OPTIONS; do + config_get_bool value basic "$request" 0 + [ $value -ne 0 ] && dhcp6c_write_request "$request" + done + + printf '};\n\n' + + if [ $pd -ne 0 ]; then + printf 'id-assoc pd 0 {\n' + config_foreach dhcp6c_write_interface interface + printf '};\n\n' + fi + + if [ $na -ne 0 ]; then + printf 'id-assoc na 0 {\n' + printf '};\n\n' + fi + + return 0 +} + +start() { + + [ ! -e /etc/dhcp6cctlkey ] && `dd if=/dev/urandom count=1 2> /dev/null | md5sum | cut -d" " -f1 > /etc/dhcp6cctlkey` + + [ -e /var/run/dhcp6c.pid ] && return 0 + + include /lib/network + + config_load "dhcp6c" + + local enabled + config_get_bool enabled basic enabled 0 + [ $enabled -eq 0 ] && return 0 + + logger starting dhcp6c + + local client_interface + config_get client_interface basic interface + local client_ifname=$(get_ifname "$client_interface") + + local config_file="/var/etc/dhcp6c.conf" + mkdir -m 755 -p /var/etc + dhcp6c_write_config > $config_file + + /usr/sbin/dhcp6c -c $config_file $client_ifname + + sleep 3 + ACTION=start /sbin/hotplug-call dhcp6c + + return 0 + +} + +stop() { + + logger stopping dhcp6c + rm -f /var/etc/dhcp6c.conf + kill -TERM `cat /var/run/dhcp6c.pid` + ACTION=stop /sbin/hotplug-call dhcp6c + return 0 + +} + + diff --git a/ipv6/wide-dhcpv6/files/dhcp6s.conf b/ipv6/wide-dhcpv6/files/dhcp6s.conf new file mode 100644 index 000000000..dda53d1f8 --- /dev/null +++ b/ipv6/wide-dhcpv6/files/dhcp6s.conf @@ -0,0 +1,4 @@ +config 'dhcp6s' 'basic' + option 'enabled' '0' # 1 = enabled; 0 = disabled + option 'interface' 'lan' # This is the interface the DHCPv6 server will run on + option 'config_file' '/etc/dhcp6s.conf' # Config file (as this UCI config doesn't fully support all options) diff --git a/ipv6/wide-dhcpv6/files/dhcp6s.hotplug b/ipv6/wide-dhcpv6/files/dhcp6s.hotplug new file mode 100644 index 000000000..726014940 --- /dev/null +++ b/ipv6/wide-dhcpv6/files/dhcp6s.hotplug @@ -0,0 +1,20 @@ +#!/bin/sh + +include /lib/network + +config_load "dhcp6s" + +local enabled +config_get_bool enabled basic enabled 0 +[ $enabled -eq 0 ] && return 0 + +local server_interface +config_get server_interface basic interface + +if [ "$INTERFACE" = "$server_interface" ] && [ "$ACTION" = "ifup" ]; then + /etc/init.d/dhcp6s start +fi + +if [ "$INTERFACE" = "$server_interface" ] && [ "$ACTION" = "ifdown" ]; then + /etc/init.d/dhcp6s stop +fi diff --git a/ipv6/wide-dhcpv6/files/dhcp6s.init b/ipv6/wide-dhcpv6/files/dhcp6s.init new file mode 100644 index 000000000..fc0da52e9 --- /dev/null +++ b/ipv6/wide-dhcpv6/files/dhcp6s.init @@ -0,0 +1,50 @@ +#!/bin/sh /etc/rc.common + +get_ifname() { + local interface=$1 + local ifname + scan_interfaces + config_get ifname "$interface" ifname + printf '%s\n' "$ifname" + return 0 +} + +start() { + + [ ! -e /etc/dhcp6sctlkey ] && `dd if=/dev/urandom count=1 2> /dev/null | md5sum | cut -d" " -f1 > /etc/dhcp6sctlkey` + + [ -e /var/run/dhcp6s.pid ] && return 0 + + include /lib/network + + config_load "dhcp6s" + + local enabled + config_get_bool enabled basic enabled 0 + [ $enabled -eq 0 ] && return 0 + + logger starting dhcp6s + + local server_interface + config_get server_interface basic interface + local server_ifname=$(get_ifname "$server_interface") + + local config_file + config_get config_file basic config_file + + [ ! -e $config_file ] && return 1 + + /usr/sbin/dhcp6s -c $config_file $server_ifname + + return 0 + +} + +stop() { + + logger stopping dhcp6s + kill -TERM `cat /var/run/dhcp6s.pid` + return 0 + +} + diff --git a/ipv6/wide-dhcpv6/patches/001-linux_old_compat.patch b/ipv6/wide-dhcpv6/patches/001-linux_old_compat.patch new file mode 100644 index 000000000..6dca9f3df --- /dev/null +++ b/ipv6/wide-dhcpv6/patches/001-linux_old_compat.patch @@ -0,0 +1,37 @@ +--- wide-dhcpv6-20080615.orig/common.h 2007-03-21 20:52:57.000000000 +1100 ++++ wide-dhcpv6-20080615/common.h 2009-11-29 16:00:02.000000000 +1100 +@@ -187,3 +187,34 @@ + #ifndef HAVE_STRLCPY + extern size_t strlcpy __P((char *, const char *, size_t)); + #endif ++ ++/* ++ * compat hacks in case libc and kernel get out of sync: ++ * ++ * glibc 2.4 and uClibc 0.9.29 introduce IPV6_RECVPKTINFO etc. and change IPV6_PKTINFO ++ * This is only supported in Linux kernel >= 2.6.14 ++ * ++ * This is only an approximation because the kernel version that libc was compiled against ++ * could be older or newer than the one being run. But this should not be a problem -- ++ * we just keep using the old kernel interface. ++ * ++ * these are placed here because they're needed in all of socket.c, recv.c and send.c ++ */ ++#ifdef __linux__ ++# if defined IPV6_RECVHOPLIMIT || defined IPV6_RECVPKTINFO ++# include ++# if LINUX_VERSION_CODE < KERNEL_VERSION(2,6,14) ++# if defined IPV6_RECVHOPLIMIT && defined IPV6_2292HOPLIMIT ++# undef IPV6_RECVHOPLIMIT ++# define IPV6_RECVHOPLIMIT IPV6_2292HOPLIMIT ++# endif ++# if defined IPV6_RECVPKTINFO && defined IPV6_2292PKTINFO ++# undef IPV6_RECVPKTINFO ++# undef IPV6_PKTINFO ++# define IPV6_RECVPKTINFO IPV6_2292PKTINFO ++# define IPV6_PKTINFO IPV6_2292PKTINFO ++# endif ++# endif ++# endif ++#endif ++