diff --git a/ahcpd/Makefile b/ahcpd/Makefile new file mode 100644 index 0000000..38c3dac --- /dev/null +++ b/ahcpd/Makefile @@ -0,0 +1,53 @@ +# +# Copyright (C) 2007-2011 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:=ahcpd +PKG_VERSION:=0.53 +PKG_RELEASE:=2 + +PKG_SOURCE:=$(PKG_NAME)-$(PKG_VERSION).tar.gz +PKG_SOURCE_URL:=http://www.pps.univ-paris-diderot.fr/~jch/software/files/ +PKG_MD5SUM:=a1a610bf20965aa522cd766bf3d5829a + + +include $(INCLUDE_DIR)/package.mk + +define Package/ahcpd + SECTION:=net + CATEGORY:=Network + TITLE:=Ad-Hoc Configuration Protocol daemon + URL:=http://www.pps.univ-paris-diderot.fr/~jch/software/ahcp/ + MAINTAINER:=Gabriel Kerneis + DEPENDS:=+kmod-ipv6 +ip +librt +endef + +define Package/ahcpd/description + Ahcpd is a daemon for configuring an IPv6 network using the Ad-Hoc + Configuration Protocol (AHCP). AHCP is designed for wireless mesh + networks, where IPv6 autoconfiguration and DHCPv6 do not work, but may + also be used on wired networks. +endef + +define Package/ahcpd/conffiles +/etc/config/ahcpd +endef + +define Package/ahcpd/install + $(INSTALL_DIR) $(1)/usr/bin + $(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_CONF) ./files/ahcpd.config $(1)/etc/config/ahcpd + $(INSTALL_DIR) $(1)/etc/init.d + $(INSTALL_BIN) ./files/ahcpd.init $(1)/etc/init.d/ahcpd +endef + +$(eval $(call BuildPackage,ahcpd)) diff --git a/ahcpd/files/ahcpd.config b/ahcpd/files/ahcpd.config new file mode 100644 index 0000000..0996251 --- /dev/null +++ b/ahcpd/files/ahcpd.config @@ -0,0 +1,32 @@ +package ahcpd + +config ahcpd + # 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' + ## 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 'lease_time' '3666' + # option 'debug' '1' + diff --git a/ahcpd/files/ahcpd.init b/ahcpd/files/ahcpd.init new file mode 100644 index 0000000..dee21c4 --- /dev/null +++ b/ahcpd/files/ahcpd.init @@ -0,0 +1,109 @@ +#!/bin/sh /etc/rc.common +# Copyright (C) 2007-2011 OpenWrt.org + +START=71 + +SERVICE_USE_PID=1 + +EXTRA_COMMANDS="status" +EXTRA_HELP=" status Print ahcpd's status to the log file." + +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 + config_load ahcpd + unset args + unset interfaces + config_foreach ahcp_config ahcpd + config_foreach ahcp_server ahcpd + [ -z "$interfaces" ] && return 0 + eval "service_start /usr/sbin/ahcpd -D $args $interfaces" +} + +stop() { + service_stop /usr/sbin/ahcpd +} + +status() { + SERVICE_SIG="USR1" service_signal /usr/sbin/ahcpd +}