From 783b48763f85dee99cf19a64a219db9b17b58051 Mon Sep 17 00:00:00 2001 From: Jo-Philipp Wich Date: Sun, 5 Feb 2012 03:25:06 +0000 Subject: [PATCH] [packages_10.03.2] ahcpd: merge r27932, r27987, r28337, r28351, r28922, r29511 SVN-Revision: 30172 --- ipv6/ahcpd/Makefile | 8 +- ipv6/ahcpd/files/ahcp.sh | 93 ++----------------- ipv6/ahcpd/files/ahcpd.config | 22 +---- ipv6/ahcpd/files/ahcpd.init | 92 +++++++++++++++++- .../ahcpd/patches/001-autoconf-prefixes.patch | 14 --- 5 files changed, 101 insertions(+), 128 deletions(-) delete mode 100644 ipv6/ahcpd/patches/001-autoconf-prefixes.patch diff --git a/ipv6/ahcpd/Makefile b/ipv6/ahcpd/Makefile index b417c60147..4d41bdf1fa 100644 --- a/ipv6/ahcpd/Makefile +++ b/ipv6/ahcpd/Makefile @@ -1,5 +1,5 @@ # -# Copyright (C) 2007 OpenWrt.org +# Copyright (C) 2007-2011 OpenWrt.org # # This is free software, licensed under the GNU General Public License v2. # See /LICENSE for more information. @@ -8,12 +8,12 @@ include $(TOPDIR)/rules.mk PKG_NAME:=ahcpd -PKG_VERSION:=0.51 -PKG_RELEASE:=4 +PKG_VERSION:=0.53 +PKG_RELEASE:=1 PKG_SOURCE:=$(PKG_NAME)-$(PKG_VERSION).tar.gz PKG_SOURCE_URL:=http://www.pps.jussieu.fr/~jch/software/files/ -PKG_MD5SUM:=86b70d278dfb5a1e33cd1a1ceae9e715 +PKG_MD5SUM:=a1a610bf20965aa522cd766bf3d5829a include $(INCLUDE_DIR)/package.mk diff --git a/ipv6/ahcpd/files/ahcp.sh b/ipv6/ahcpd/files/ahcp.sh index 805013c4c2..11788e29fa 100644 --- a/ipv6/ahcpd/files/ahcp.sh +++ b/ipv6/ahcpd/files/ahcp.sh @@ -1,91 +1,14 @@ -append_bool() { - local section="$1" - local option="$2" - local value="$3" - local _loctmp - config_get_bool _loctmp "$section" "$option" 0 - [ "$_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_stmt() { - local name="$1" - local switch="$2" - append args "-C '$switch $name'" -} - -append_opt_stmt() { - local section="$1" - local option="$2" - local switch="$3" - local _loctmp - config_get _loctmp "$section" "$option" - [ -z "$_loctmp" ] && return 0 - append args "-C '$switch $_loctmp'" -} - -ahcp_addif() { - local ifname=$(uci_get_state network "$1" ifname "$1") - append interfaces "$ifname" -} - -ahcp_server() { - local cfg="$1" - - append_opt_stmt "$cfg" 'mode' 'mode' - append_opt_stmt "$cfg" 'lease_dir' 'lease-dir' - config_list_foreach "$cfg" 'prefix' append_stmt 'prefix' - config_list_foreach "$cfg" 'name_server' append_stmt 'name-server' - config_list_foreach "$cfg" 'ntp_server' append_stmt 'ntp-server' - - 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" -} + setup_interface_none "$interface" "$config" -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") + local mode=$(uci_get_state ahcpd "@ahcpd[0]" mode "client") + if [ "$mode" != "client" ]; then + echo "Warning: ahcp ignored for $interface (mode is $mode, should be client)." + echo "Fix ahcp mode in /etc/config/ahcpd." + else + /etc/init.d/ahcpd restart + fi } diff --git a/ipv6/ahcpd/files/ahcpd.config b/ipv6/ahcpd/files/ahcpd.config index b2187f2836..0996251cb2 100644 --- a/ipv6/ahcpd/files/ahcpd.config +++ b/ipv6/ahcpd/files/ahcpd.config @@ -1,11 +1,8 @@ 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' + # Choose ahcp mode: client (default), server or forwarder + ## option 'mode' 'client' # Uncomment the following lines to enable ahcpd on the desired # interfaces. ## list 'interface' 'lan' @@ -33,18 +30,3 @@ config ahcpd # 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 38b520891d..6654b00626 100644 --- a/ipv6/ahcpd/files/ahcpd.init +++ b/ipv6/ahcpd/files/ahcpd.init @@ -1,11 +1,93 @@ #!/bin/sh /etc/rc.common +# Copyright (C) 2007-2011 OpenWrt.org START=71 -PID_F="/var/run/ahcpd.pid" + +SERVICE_USE_PID=1 + EXTRA_COMMANDS="status" EXTRA_HELP=" status Print ahcpd's status to the log file." -. /lib/network/ahcp.sh +append_bool() { + local section="$1" + local option="$2" + local value="$3" + local _loctmp + config_get_bool _loctmp "$section" "$option" 0 + [ "$_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_stmt() { + local name="$1" + local switch="$2" + append args "-C '$switch $name'" +} + +append_opt_stmt() { + local section="$1" + local option="$2" + local switch="$3" + local _loctmp + config_get _loctmp "$section" "$option" + [ -z "$_loctmp" ] && return 0 + append args "-C '$switch $_loctmp'" +} + +ahcp_addif() { + local ifname=$(uci_get_state network "$1" ifname "$1") + append interfaces "$ifname" +} + +ahcp_server() { + local cfg="$1" + + append_opt_stmt "$cfg" 'mode' 'mode' + append_opt_stmt "$cfg" 'lease_dir' 'lease-dir' + config_list_foreach "$cfg" 'prefix' append_stmt 'prefix' + config_list_foreach "$cfg" 'name_server' append_stmt 'name-server' + config_list_foreach "$cfg" 'ntp_server' append_stmt 'ntp-server' + + append_parm "$cfg" 'id_file' '-i' + append_parm "$cfg" 'log_file' '-L' +} + +ahcp_config() { + local cfg="$1" + local interface + local _loctmp + + config_list_foreach "$cfg" 'interface' ahcp_addif + + # Add interfaces with "option proto ahcp" in /etc/config/network + # (only for client mode) + config_get _loctmp "$cfg" "mode" + if [ -z "$_loctmp" -o "$_loctmp" = "client" ]; then + for interface in $(uci -P /var/state show network|grep proto=ahcp|cut -d. -f2); do + ahcp_addif $interface + done + fi + + 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' +} start() { mkdir -p /var/lib @@ -15,13 +97,13 @@ start() { config_foreach ahcp_config ahcpd config_foreach ahcp_server ahcpd [ -z "$interfaces" ] && return 0 - eval "/usr/sbin/ahcpd -D -I $PID_F $args $interfaces" + service_start /usr/sbin/ahcpd -D $args $interfaces } stop() { - [ -f "$PID_F" ] && kill $(cat "$PID_F") + service_stop /usr/sbin/ahcpd } status() { - [ -f $PID_F ] && kill -USR1 $(cat $PID_F) + SERVICE_SIG="USR1" service_signal /usr/sbin/ahcpd } diff --git a/ipv6/ahcpd/patches/001-autoconf-prefixes.patch b/ipv6/ahcpd/patches/001-autoconf-prefixes.patch deleted file mode 100644 index e29dcf142c..0000000000 --- a/ipv6/ahcpd/patches/001-autoconf-prefixes.patch +++ /dev/null @@ -1,14 +0,0 @@ -Tue Jul 20 00:25:27 CEST 2010 Juliusz Chroboczek - * Fix typo -- ignore autoconf prefixes for plen > 64. - Thanks to Gabriel Kerneis. ---- old-ahcpd/configure.c 2010-07-20 09:31:19.000000000 +0200 -+++ new-ahcpd/configure.c 2010-07-20 09:31:19.000000000 +0200 -@@ -505,7 +505,7 @@ - if(config->ipv6_address) { - config->our_ipv6_address = copy_prefix_list(config->ipv6_address); - } else if(config->ipv6_prefix && config->ipv6_prefix->n > 0 && -- config->ipv6_prefix->l[0].plen >= 64) { -+ config->ipv6_prefix->l[0].plen <= 64) { - unsigned char address[16]; - int have_address = 0; - -- 2.30.2