[PATCH 2/2] [package] ahcpd: update to 0.51, fix scripts
Gabriel Kerneis
kerneis at pps.jussieu.fr
Wed Feb 17 13:43:05 UTC 2010
- Full-featured UCI configuration file (including server mode).
- Client mode configuration in /etc/config/network (proto ahcp).
- Launch at most one instance in server/forwarder mode, and as many
instance as interfaces in client mode.
- Add status and reload options to init script.
- Make /etc/config/ahcpd a config file, simplify Makefile.
- Do not check the pid file (useless).
- 29 January 2010: ahcpd 0.51
* Servers are now configured with a plain-text configuration file.
* Implemented client-side support for prefix delegation (-P).
* Made requesting state more persistent, to deal with packet loss.
* Fixed a typo that prevented the -I option from working.
* Fixed compilation on BSD systems.
* Fixed a bug that could cause an expired lease to be discarded when
older ones are available.
Signed-off-by: Gabriel Kerneis <kerneis at pps.jussieu.fr>
---
ipv6/ahcpd/Makefile | 30 +++++---------
ipv6/ahcpd/files/ahcp.sh | 87 +++++++++++++++++++++++++++++++++++++++++
ipv6/ahcpd/files/ahcpd.config | 52 ++++++++++++++++++++++--
ipv6/ahcpd/files/ahcpd.init | 63 +++++++++--------------------
4 files changed, 165 insertions(+), 67 deletions(-)
create mode 100644 ipv6/ahcpd/files/ahcp.sh
diff --git a/ipv6/ahcpd/Makefile b/ipv6/ahcpd/Makefile
index a273e44..b1ca537 100644
--- a/ipv6/ahcpd/Makefile
+++ b/ipv6/ahcpd/Makefile
@@ -8,12 +8,13 @@
include $(TOPDIR)/rules.mk
PKG_NAME:=ahcpd
-PKG_VERSION:=0.50
-PKG_RELEASE:=3
+PKG_VERSION:=0.51
+PKG_RELEASE:=1
PKG_SOURCE:=$(PKG_NAME)-$(PKG_VERSION).tar.gz
PKG_SOURCE_URL:=http://www.pps.jussieu.fr/~jch/software/files/
-PKG_MD5SUM:=627ec199784c60e5250651f82511fff2
+PKG_MD5SUM:=86b70d278dfb5a1e33cd1a1ceae9e715
+
include $(INCLUDE_DIR)/package.mk
@@ -22,6 +23,7 @@ define Package/ahcpd
CATEGORY:=IPv6
TITLE:=Ad-Hoc Configuration Protocol daemon
URL:=http://www.pps.jussieu.fr/~jch/software/ahcp/
+ MAINTAINER:=Gabriel Kerneis <kerneis at pps.jussieu.fr>
DEPENDS:=+kmod-ipv6 +ip +librt
endef
@@ -32,32 +34,20 @@ define Package/ahcpd/description
also be used on wired networks.
endef
-define Build/Configure
- ( cd $(PKG_BUILD_DIR); \
- $(SED) 's,/usr/local/bin/,/usr/lib/ahcp/,g' ahcpd.c ; \
- $(SED) 's,/usr/local/lib/ahcp/,/usr/lib/ahcp/,g' ahcp-config.sh ; \
- )
-endef
-
-define Build/Compile
- $(MAKE) -C $(PKG_BUILD_DIR) \
- CC="$(TARGET_CC)" \
- CFLAGS="$(TARGET_CFLAGS)" \
- all
-endef
-
define Package/ahcpd/conffiles
/etc/config/ahcpd
endef
define Package/ahcpd/install
$(INSTALL_DIR) $(1)/usr/bin
- $(INSTALL_DIR) $(1)/usr/lib/ahcp
- $(INSTALL_BIN) $(PKG_BUILD_DIR)/ahcp-config.sh $(1)/usr/lib/ahcp/
+ $(INSTALL_DIR) $(1)/etc/ahcp
+ $(INSTALL_BIN) $(PKG_BUILD_DIR)/ahcp-config.sh $(1)/etc/ahcp/
$(INSTALL_DIR) $(1)/usr/sbin
$(INSTALL_BIN) $(PKG_BUILD_DIR)/ahcpd $(1)/usr/sbin/
$(INSTALL_DIR) $(1)/etc/config
- $(INSTALL_DATA) ./files/ahcpd.config $(1)/etc/config/ahcpd
+ $(INSTALL_CONF) ./files/ahcpd.config $(1)/etc/config/ahcpd
+ $(INSTALL_DIR) $(1)/lib/network
+ $(INSTALL_BIN) ./files/ahcp.sh $(1)/lib/network/
$(INSTALL_DIR) $(1)/etc/init.d
$(INSTALL_BIN) ./files/ahcpd.init $(1)/etc/init.d/ahcpd
endef
diff --git a/ipv6/ahcpd/files/ahcp.sh b/ipv6/ahcpd/files/ahcp.sh
new file mode 100644
index 0000000..4b4f7ab
--- /dev/null
+++ b/ipv6/ahcpd/files/ahcp.sh
@@ -0,0 +1,87 @@
+append_bool() {
+ local section="$1"
+ local option="$2"
+ local value="$3"
+ local _loctmp
+ config_get_bool _loctmp "$section" "$option"
+ [ "$_loctmp" -gt 0 ] && append args "$value"
+}
+
+append_parm() {
+ local section="$1"
+ local option="$2"
+ local switch="$3"
+ local _loctmp
+ config_get _loctmp "$section" "$option"
+ [ -z "$_loctmp" ] && return 0
+ append args "$switch $_loctmp"
+}
+
+append_args() {
+ local name="$1"
+ local switch="$2"
+ append args "$switch $name"
+}
+
+ahcp_addif() {
+ local name="$1"
+ local _uciname=`uci get -q -P /var/state network.$name.ifname`
+ append interfaces "${_uciname:-$name}"
+}
+
+ahcp_server() {
+ local cfg="$1"
+
+ append args "-C '"
+
+ append_parm "$cfg" 'mode' 'mode'
+ append_parm "$cfg" 'lease_dir' 'lease-dir'
+ config_list_foreach "$cfg" 'prefix' append_args 'prefix'
+ config_list_foreach "$cfg" 'name_server' append_args 'name-server'
+ config_list_foreach "$cfg" 'ntp_server' append_args 'ntp-server'
+
+ append args ' ' "'"
+
+ append_parm "$cfg" 'id_file' '-i'
+ append_parm "$cfg" 'log_file' '-L'
+}
+
+ahcp_config() {
+ local cfg="$1"
+
+ config_list_foreach "$cfg" 'interface' ahcp_addif
+
+ append_bool "$cfg" 'ipv4_only' '-4'
+ append_bool "$cfg" 'ipv6_only' '-6'
+ append_bool "$cfg" 'no_dns' '-N'
+
+ append_parm "$cfg" 'multicast_address' '-m'
+ append_parm "$cfg" 'port' '-p'
+ append_parm "$cfg" 'lease_time' '-t'
+ append_parm "$cfg" 'debug' '-d'
+ append_parm "$cfg" 'conf_file' '-c'
+ append_parm "$cfg" 'script' '-s'
+}
+
+setup_interface_ahcp() {
+ local interface="$1"
+ local config="$2"
+ local pid_file="/var/run/ahcpd-$interface.pid"
+ local id_file="/var/lib/ahcp-unique-id-$interface"
+ local log_file="/var/log/ahcpd-$interface.log"
+ unset args
+
+ mkdir -p /var/lib
+
+ ahcp_config "$config"
+ eval "/usr/sbin/ahcpd -D -I $pid_file -i $id_file -L $log_file $args $interface"
+}
+
+stop_interface_ahcp() {
+ local cfg="$1"
+ local interface
+ config_get interface "$cfg" device
+ local pid_file="/var/run/ahcpd-$interface.pid"
+ [ -f "$pid_file" ] && kill $(cat "$pid_file")
+}
+
diff --git a/ipv6/ahcpd/files/ahcpd.config b/ipv6/ahcpd/files/ahcpd.config
index c70b71d..ebf6ddc 100644
--- a/ipv6/ahcpd/files/ahcpd.config
+++ b/ipv6/ahcpd/files/ahcpd.config
@@ -1,6 +1,50 @@
-config 'ahcpd'
- option 'no_dns' 'false'
+package ahcpd
+
+# This configuration file is used to set up ahcpd in server or forwarder
+# mode. To use ahcpd in client mode, use 'proto' 'ahcp' in
+# /etc/config/network (see example below).
+
+config ahcpd
+ option 'mode' 'server' # or 'forwarder' but NOT 'client'
+ # Uncomment the following lines to enable ahcpd on the desired
+ # interfaces.
+ ## list 'interface' 'lan'
+ ## list 'interface' 'wlan'
+
+ # The following only makes sense in 'server' mode.
+ # Tweak to suit your needs.
+ ## list 'prefix ' 'fde6:20f5:c9ac:358::/64'
+ ## list 'prefix' '192.168.4.128/25'
+ ## list 'name_server' 'fde6:20f5:c9ac:358::1'
+ ## list 'name_server' '192.168.4.1'
+ ## list 'ntp_server' '192.168.4.2'
+ ## option 'lease_dir' '/var/lib/leases'
+
+ option 'id_file' '/var/lib/ahcp-unique-id'
+ option 'log_file' '/var/log/ahcpd.log'
+ # The configuration file is not necessary since you can configure
+ # everything from this file. But still, you might prefer using it.
+ ## option 'conf_file' '/etc/ahcp/ahcp.conf'
+
+ option 'multicast_address' 'ff02::cca6:c0f9:e182:5359'
+ option 'port' '5359'
option 'ipv4_only' 'false'
option 'ipv6_only' 'false'
- option 'no_config' 'false'
- #list 'interface' 'wlan'
+ option 'lease_time' '3666'
+ option 'debug' '1'
+
+# Sample client mode configuration
+# THIS MUST BE COPIED IN /etc/config/network. Ahcpd will ignore it
+# otherwise.
+## config 'interface' 'wlan'
+## option 'ifname' 'ath0'
+## option 'proto' 'ahcp'
+## # The following lines are optional
+## option 'multicast_address' 'ff02::cca6:c0f9:e182:5359'
+## option 'port' '5359'
+## option 'ipv4_only' 'false'
+## option 'ipv6_only' 'false'
+## option 'no_dns' 'false'
+## option 'lease_time' '3666'
+## option 'debug' '1'
+## option 'script' '/etc/ahcp/ahcp-config.sh'
diff --git a/ipv6/ahcpd/files/ahcpd.init b/ipv6/ahcpd/files/ahcpd.init
index 12a8452..4bf651e 100644
--- a/ipv6/ahcpd/files/ahcpd.init
+++ b/ipv6/ahcpd/files/ahcpd.init
@@ -1,54 +1,31 @@
#!/bin/sh /etc/rc.common
START=71
+PID_F="/var/run/ahcpd.pid"
+EXTRA_COMMANDS="status"
+EXTRA_HELP=" status Print ahcpd's status to the log file."
-pidfile=/var/run/ahcpd.pid
-addif() {
- config_get ifname $1 ifname
- append interfaces "$ifname"
-}
-
-ahcpd_config() {
- local cfg="$1"
- interfaces=
- config_list_foreach $cfg interface addif
- [ -z "$interfaces" ] && return 0
- config_get_bool no_config "$cfg" no_config 0
- config_get_bool ipv4_only "$cfg" ipv4_only 0
- config_get_bool ipv6_only "$cfg" ipv6_only 0
- config_get_bool no_dns "$cfg" no_dns 0
- if [ "$no_config" -eq 0 ]; then
- unset no_config
- fi
- if [ "$ipv4_only" -eq 0 ]; then
- unset ipv4_only
- fi
- if [ "$ipv6_only" -eq 0 ]; then
- unset ipv6_only
- fi
- if [ "$no_dns" -eq 0 ]; then
- unset no_dns
- fi
- if [ -e $pidfile ] ; then
- echo "$pidfile exists -- not starting ahcpd." >&2
- else
- /usr/sbin/ahcpd -s /usr/lib/ahcp/ahcp-config.sh -D -I $pidfile \
- ${ipv4_only:+-4} ${ipv6_only:+-6} ${no_dns:+-N} ${no_config:+-n} \
- $interfaces
- fi
-}
+. /lib/network/ahcp.sh
start() {
- include /lib/network
- scan_interfaces
- config_load ahcpd
mkdir -p /var/lib
- config_foreach ahcpd_config ahcpd
+ config_load ahcpd
+ unset args
+ unset interfaces
+ config_foreach ahcp_config ahcpd
+ config_foreach ahcp_server ahcpd
+ [ -z "$interfaces" ] && return 0
+ eval "/usr/sbin/ahcpd -D -I $PID_F $args $interfaces"
}
stop() {
- [ -e $pidfile ] && kill $(cat $pidfile)
- [ -e $pidfile ] && sleep 2
- [ -e $pidfile ] && sleep 4
- [ -e $pidfile ] && echo "Failed to stop ahcpd ($pidfile still exists)."
+ [ -f "$PID_F" ] && kill $(cat "$PID_F")
+}
+
+status() {
+ [ -f $PID_F ] && kill -USR1 $(cat $PID_F)
+}
+
+reload() {
+ [ -f $PID_F ] && kill -USR2 $(cat $PID_F)
}
--
1.6.6
--k+w/mQv8wyuph6w0--
More information about the Babel-users
mailing list