Hi,

I've finished to convert the babeld and ahcpd packages to use UCI.  In
the meantime, I've updated them to latest upstream revision and
integrated ahcp as a protocol in OpenWrt.

The latter means that now, if you want to configure an interface with
ahcp, you just need to put the following in /etc/config/network:

  config 'interface' 'wifi'
    option 'ifname' 'ath0'
    option 'proto' 'ahcp'

The config file (/etc/config/ahcp) is now reserved for forwarder and
server mode configuration.  Nothing prevents you from using ahcp in
client mode on some interfaces, and server mode on some others (but
server and forwarder modes are mutually exclusive).

The babel patch is not very different from what I sent yesterday, only a
few fixes based on feedback I got off-list (thank you all).

This patches have been tested today rather extensively.  I'll commit
them in the trunk very soon, but felt it necessary to make this public
annoucement since they change deeply how the packages are configured.

Please upgrade and provide more feedback if anything looks wrong.
Atheros packages (working on my Fonera 2100) are available here:
http://www.pps.jussieu.fr/~kerneis/software/files/ahcpd_0.51-1_atheros.ipk
http://www.pps.jussieu.fr/~kerneis/software/files/babeld_0.98-1_atheros.ipk

Regards,
-- 
Gabriel Kerneis
>From 86eeb382fef31d07e102d99b63f06cd17e716d9b Mon Sep 17 00:00:00 2001
From: Gabriel Kerneis <kern...@pps.jussieu.fr>
Date: Mon, 15 Feb 2010 19:21:39 +0100
Subject: [PATCH 1/2] [package] babeld: update to 0.98, fix scripts

- Full-featured UCI configuration file (no need for babeld.conf).
- Do not check the pid file (useless) and ahcpd script (harmful).
- Make /etc/config/babeld a config file.
- Launch at most one instance of babeld.
- Add status and reload options to init script.
- 8 February 2010: babeld 0.98:
  * Implement the ability to prefer Babel routes to external routes
    according to the kernel priority (-A).
  * Implement the ability to redistribute "boot" routes when the
    protocol is explicitly specified on the "redistribute" line.
  * Allow trailing whitespace in config file.

Signed-off-by: Gabriel Kerneis <kern...@pps.jussieu.fr>
---
 net/babel/Makefile            |   12 ++--
 net/babel/files/babeld.conf   |   20 +++++-
 net/babel/files/babeld.config |   72 ++++++++++++++++++++-
 net/babel/files/babeld.init   |  142 +++++++++++++++++++++++++++++++++++------
 4 files changed, 212 insertions(+), 34 deletions(-)

diff --git a/net/babel/Makefile b/net/babel/Makefile
index 144bf9e..d26ebba 100644
--- a/net/babel/Makefile
+++ b/net/babel/Makefile
@@ -8,12 +8,12 @@
 include $(TOPDIR)/rules.mk
 
 PKG_NAME:=babeld
-PKG_VERSION:=0.97
+PKG_VERSION:=0.98
 PKG_RELEASE:=1
 
 PKG_SOURCE:=$(PKG_NAME)-$(PKG_VERSION).tar.gz
 PKG_SOURCE_URL:=http://www.pps.jussieu.fr/~jch/software/files/
-PKG_MD5SUM:=be0748c382dfe60bd35aa6b661e6077d
+PKG_MD5SUM:=85af76e90914b82d9ece497e15df252f
 
 include $(INCLUDE_DIR)/package.mk
 
@@ -22,6 +22,7 @@ define Package/babeld
   CATEGORY:=Network
   TITLE:=A loop-free distance-vector routing protocol
   URL:=http://www.pps.jussieu.fr/~jch/software/babel/
+  MAINTAINER:=Gabriel Kerneis <kern...@pps.jussieu.fr>
   DEPENDS:=+kmod-ipv6 +librt
 endef
 
@@ -37,19 +38,16 @@ endef
 
 define Package/babeld/conffiles
 /etc/babeld.conf
+/etc/config/babeld
 endef
 
-MAKE_FLAGS += \
-	CC="$(TARGET_CC)" \
-	CFLAGS="$(TARGET_CFLAGS)" \
-
 define Package/babeld/install
 	$(INSTALL_DIR) $(1)/usr/sbin
 	$(INSTALL_BIN) $(PKG_BUILD_DIR)/babeld $(1)/usr/sbin/
 	$(INSTALL_DIR) $(1)/etc
 	$(INSTALL_CONF) ./files/babeld.conf $(1)/etc/
 	$(INSTALL_DIR) $(1)/etc/config
-	$(INSTALL_DATA) ./files/babeld.config $(1)/etc/config/babeld
+	$(INSTALL_CONF) ./files/babeld.config $(1)/etc/config/babeld
 	$(INSTALL_DIR) $(1)/etc/init.d
 	$(INSTALL_BIN) ./files/babeld.init $(1)/etc/init.d/babeld
 endef
diff --git a/net/babel/files/babeld.conf b/net/babel/files/babeld.conf
index 07fcbe1..fd488f9 100644
--- a/net/babel/files/babeld.conf
+++ b/net/babel/files/babeld.conf
@@ -1,11 +1,15 @@
 # babel config file
-# Copyright (C) 2008 Juliusz Chroboczek, L. Aaron Kaplan
+# Copyright (C) 2008-2010 Juliusz Chroboczek, L. Aaron Kaplan
 #   <j...@pps.jussieu.fr> , <aa...@lo-res.org>
 #
 # This config file simply documents sample entries. 
-# "redistribute" means: redistribute routes from other 
-#  routing protocols into babel. "local" means addresses assigned to local interfaces.
+# "redistribute" means: redistribute routes from other routing protocols
+# into babel. "local" means addresses assigned to local interfaces.
 #
+# You do not need to edit this file: you can use /etc/config/babeld
+# instead (sections "interface" and "filter").  Both files can be used
+# simultaneously (the rules of this file are executed first).
+
 # the default rules are:
 #
 ## redistribute local 
@@ -14,15 +18,23 @@
 # this says, redistribute local addresses but no other routes
 
 
-
 # redistribute IPv4 default route into babel 
 ## redistribute local ip 0.0.0.0/0 le 0 metric 128
 
 # same but for IPv6
 ## redistribute local ip ::/0 le 0 metric 128
 
+
 # don't redistribute all local addresses, only selected ones
 # after the first line, the "deny" rules kicks in. After the "deny"
 # no redistribute local rules are going to match
 ## redistribute local ip 192.160.4.0/24 
 ## redistribute local deny
+
+
+# Babel refuses to redistribute routes with a protocol number of "boot";
+# this is standard practice, and means that you cannot easily
+# redistribute the default route installed by dhcp.  It is however
+# possible to redistribute such route by explicitly specifying "proto 3"
+# on the redistribute line.
+## redistribute ip 0.0.0.0/0 le 0 proto 3 metric 128
diff --git a/net/babel/files/babeld.config b/net/babel/files/babeld.config
index 3b0fb38..ac0cb76 100644
--- a/net/babel/files/babeld.config
+++ b/net/babel/files/babeld.config
@@ -1,2 +1,70 @@
-config babeld
-	#list 'interface' 'wlan'
+package babeld
+
+config general
+	option 'multicast_address' 'ff02::cca6:c0f9:e182:5373'
+	option 'port' '8475'
+	option 'state_file' '/var/lib/babel-state'
+	option 'hello_interval' '4'
+	option 'wired_hello_interval' '20'
+	# Enable  detection of idle networks.  This functonality is
+	# experimental, don't use it unless you know what you are doing.
+	## option 'idle_hello_interval' '0'
+	option 'kernel_priority' '0'
+	# Do not use this option unless you know what you are doing, as it can
+	# cause persistent route flapping.
+	## option 'duplication_priority' '0'
+	option 'carrier_sense' 'false'
+	option 'assume_wireless' 'false'
+	option 'no_split_horizon' 'false'
+	option 'parasitic' 'false'
+	option 'debug' '0'
+	# Listen for connections from a front-end, e.g. on port 33123.
+	## option 'local_server' '33123'
+	# Use the given kernel routing table for routes inserted by babeld.
+	## option 'export_table' '0'
+	# Export routes from the given kernel routing table.
+	## option 'import_table' '0'
+	# The configuration file is not necessary since you can do everything
+	# from this file.
+	option 'conf_file' '/etc/babeld.conf'
+	option 'log_file' '/var/log/babeld.log'
+
+# You can use aliases (like lan, wlan) or real names (like eth0.0).
+# If you use an alias, it must be already defined when babeld starts.
+# Otherwise, the name is taken literally and the interface can be
+# brought up later (useful for tunnels for instance).
+config interface wlan
+	# Change this line to enable babeld on this interface
+	option 'ignore' 'true'
+	option 'wired' 'auto'
+	option 'link_quality' 'auto'
+	option 'split_horizon' 'auto'
+	# The default is 96 for wired interfaces, and 256 for wireless ones
+	## option 'rxcost' '256'
+	# The  default  is  specified with the -h and -H command-line flags.
+	## option 'hello_interval' '4'
+	# This can be set to a  fairly  large  value,  unless significant
+	# packet loss is expected.  The default is four times the hello
+	# interval.
+	## option 'update_interval' '16'
+
+config interface lan
+	option 'ignore' 'true'
+
+# A filter consists in a type ('in', 'out' or 'redistribute'), an action
+# ('allow', 'deny' or 'metric xxx') and a set of selectors ('ip', 'eq',
+# etc.).  See /etc/babeld.conf for more details.
+# Here is a sample filter wich redistributes the default route if its
+# protocol number is "boot", e.g. when it installed by dhcp.  It is
+# disabled by default.
+config filter
+	option 'ignore' 'true'
+	# Type
+	option 'type' 'redistribute'
+	# Selectors: ip, eq, le, ge, neigh, id, proto, local, if
+	option 'ip' '0.0.0.0/0' 
+	option 'le' '0'
+	option 'proto' '3'
+	# Action 
+	option 'action' 'metric 128'
+
diff --git a/net/babel/files/babeld.init b/net/babel/files/babeld.init
index a7e4587..67c78ff 100755
--- a/net/babel/files/babeld.init
+++ b/net/babel/files/babeld.init
@@ -2,37 +2,137 @@
 
 START=70
 
+PID_F='/var/run/babeld.pid'
+EXTRA_COMMANDS="status"
+EXTRA_HELP="        status Dump Babel's table to the log file."
+
+listen_ifname() {
+	local name="$1"
+	local switch="$2"
+	local _uciname=`uci get -q -P /var/state network.$name.ifname`
+	append args "$switch ${_uciname:-$name}"
+	append interfaces "${_uciname:-$name}"
+}
+
+append_ifname() {
+	local section="$1"
+	local option="$2"
+	local switch="$3"
+	local _name
+	config_get _name "$section" "$option"
+	[ -z "$name" ] && return 0
+	local _uciname=`uci get -q -P /var/state network.$_name.ifname`
+	append args "$switch ${_uciname:-$_name}"
+}
+
+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"
+}
+
+babel_filter() {
+	local cfg="$1"
+	local _loctmp
+
+	local _ignored
+	config_get_bool _ignored "$cfg" 'ignore' 0
+	[ "$_ignored" -eq 1 ] && return 0
+	
+	append args "-C '"
+
+	append_parm "$cfg" 'type' ''
+
+	append_parm "$cfg" 'ip' 'ip'
+	append_parm "$cfg" 'le' 'le'
+	append_parm "$cfg" 'ge' 'ge'
+	append_parm "$cfg" 'neigh' 'neigh'
+	append_parm "$cfg" 'id' 'id'
+	append_parm "$cfg" 'proto' 'proto'
+
+	append_ifname "$cfg" 'if' 'if'
+
+	append_bool "$cfg" 'local' 'local'
+
+	append args ' ' "'"
+}
+
 babel_addif() {
-	config_get ifname $1 ifname
-	append interfaces "$ifname"
+	local cfg="$1"
+
+	local _ignored
+	config_get_bool _ignored "$cfg" 'ignore' 0
+	[ "$_ignored" -eq 1 ] && return 0
+	
+	listen_ifname "$cfg" "-C 'interface"
+
+	append_parm "$cfg" 'wired' 'wired'
+	append_parm "$cfg" 'link_quality' 'link-quality'
+	append_parm "$cfg" 'split_horizon' 'split-horizon'
+	append_parm "$cfg" 'rxcost' 'rxcost'
+	append_parm "$cfg" 'hello_interval' 'hello-interval'
+	append_parm "$cfg" 'update_interval' 'update-interval'
+
+	append args ' ' "'"
 }
 
 babel_config() {
 	local cfg="$1"
-	interfaces=
-	config_list_foreach "$cfg" interface babel_addif
-	pidfile=/var/run/babeld-"$cfg".pid
-	[ -z "$interfaces" ] && return 0
-	if [ -e $pidfile ] ; then
-		echo "$pidfile exists -- not starting babel." >&2
-	else
-		/usr/sbin/babeld -D -I $pidfile $interfaces
-	fi
+
+	append_bool "$cfg" 'carrier_sense' '-l'
+	append_bool "$cfg" 'assume_wireless' '-w'
+	append_bool "$cfg" 'no_split_horizon' '-s'
+	append_bool "$cfg" 'parasitic' '-P'
+
+	append_parm "$cfg" 'multicast_address' '-m'
+	append_parm "$cfg" 'port' '-p'
+	append_parm "$cfg" 'state_file' '-S'
+	append_parm "$cfg" 'hello_interval' '-h'
+	append_parm "$cfg" 'wired_hello_interval' '-H'
+	append_parm "$cfg" 'idle_hello_interval' '-i'
+	append_parm "$cfg" 'kernel_priority' '-k'
+	append_parm "$cfg" 'duplication_priority' '-A'
+	append_parm "$cfg" 'debug' '-d'
+	append_parm "$cfg" 'local_server' '-g'
+	append_parm "$cfg" 'export_table' '-t'
+	append_parm "$cfg" 'import_table' '-T'
+	append_parm "$cfg" 'conf_file' '-c'
+	append_parm "$cfg" 'log_file' '-L'
 }
 
 start() {
-	if [ -x /etc/init.d/ahcpd ] && /etc/init.d/ahcpd enabled; then
-		echo 'Not starting babel -- will be started by ahcpd.'
-		exit 0
-	fi
-	include /lib/network
-	scan_interfaces
-	config_load babeld
 	mkdir -p /var/lib
-	config_foreach babel_config babeld
+	config_load babeld
+	unset args
+	unset interfaces
+	config_foreach babel_config general
+	config_foreach babel_addif interface
+	config_foreach babel_filter filter
+	[ -z "$interfaces" ] && return 0
+	eval "/usr/sbin/babeld -D -I $PID_F $args $interfaces"
 }
 
 stop() {
-	kill $(cat /var/run/babeld-*.pid)
-	rm -f /var/run/babeld-*.pid
+	[ -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

>From 553043534bfb17d982bea2e598650c64085d4f37 Mon Sep 17 00:00:00 2001
From: Gabriel Kerneis <kern...@pps.jussieu.fr>
Date: Wed, 17 Feb 2010 14:43:05 +0100
Subject: [PATCH 2/2] [package] ahcpd: update to 0.51, fix scripts

- 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 <kern...@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 <kern...@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

_______________________________________________
Babel-users mailing list
Babel-users@lists.alioth.debian.org
http://lists.alioth.debian.org/mailman/listinfo/babel-users

Reply via email to