#
-# Copyright (C) 2006 OpenWrt.org
+# Copyright (C) 2006-2011 OpenWrt.org
#
# This is free software, licensed under the GNU General Public License v2.
# See /LICENSE for more information.
PKG_NAME:=rarpd
PKG_VERSION:=1.1
-PKG_RELEASE:=1
+PKG_RELEASE:=3
PKG_SOURCE:=$(PKG_NAME)-$(PKG_VERSION).tar.gz
PKG_SOURCE_URL:=ftp://ftp.dementia.org/pub/net-tools
database.
endef
-define Build/Configure
- $(call Build/Configure/Default, \
- --with-libnet="$(STAGING_DIR)/usr/lib/libnet-1.0.x" \
- --with-pcap="$(STAGING_DIR)/usr" \
- , \
- CFLAGS="$$$$CFLAGS -DNEW_LIBNET_INTERFACE" \
- )
-endef
+CONFIGURE_ARGS+= \
+ --with-libnet="$(STAGING_DIR)/usr/lib/libnet-1.0.x" \
+ --with-pcap="$(STAGING_DIR)/usr" \
+
+CONFIGURE_VARS+= \
+ CFLAGS="$$$$CFLAGS -DNEW_LIBNET_INTERFACE" \
define Package/rarpd/install
$(INSTALL_DIR) $(1)/usr/sbin
- $(INSTALL_BIN) $(PKG_INSTALL_DIR)/usr/sbin/rarpd $(1)/usr/sbin/
- $(INSTALL_DIR) $(1)/etc/default
- install -m644 ./files/rarpd.default $(1)/etc/default/rarpd
+ $(CP) $(PKG_INSTALL_DIR)/usr/sbin/rarpd $(1)/usr/sbin/
+ $(INSTALL_DIR) $(1)/etc/config
+ $(INSTALL_DATA) ./files/rarpd.config $(1)/etc/config/rarpd
$(INSTALL_DIR) $(1)/etc/init.d
- install -m755 ./files/rarpd.init $(1)/etc/init.d/rarpd
+ $(INSTALL_BIN) ./files/rarpd.init $(1)/etc/init.d/rarpd
+endef
+
+define Package/rarpd/conffiles
+/etc/config/rarpd
endef
$(eval $(call BuildPackage,rarpd))
--- /dev/null
+package 'rarpd'
+
+config 'rarpd'
+ option enabled 0
+
+ # listen on the specified interface (default: lan)
+# option interface 'lan'
+
+ # use the specified 'ethers' file (default: /etc/ethers)
+# option ethers '/etc/ethers'
+
+ # be verbose (default: false)
+# option verbose 0
#!/bin/sh /etc/rc.common
-# Copyright (C) 2006 OpenWrt.org
+# Copyright (C) 2006-2011 OpenWrt.org
+
START=50
-RARPD=/usr/sbin/rarpd
-DEFAULT=/etc/default/rarpd
+SERVICE_DAEMONIZE=1
+SERVICE_WRITE_PID=1
+
+append_bool() {
+ local var="$1"
+ local section="$2"
+ local option="$3"
+ local value="$4"
+ local _val
+ config_get_bool _val "$section" "$option" 0
+ [ $_val -gt 0 ] && append "$var" "$value"
+}
+
+append_string() {
+ local var="$1"
+ local section="$2"
+ local option="$3"
+ local val="$4"
+ local _val
+ config_get _val "$section" "$option"
+ [ -n "$_val" ] && append "$var" "$val $_val"
+}
+
+config_get_ifname() {
+ local var="$1"
+ local section="$2"
+ local option="$3"
+ local val="$4"
+ local _val
+ config_get _val "$section" "$option" "$val"
+ [ -n "$_val" ] && config_get "$var" "$_val" 'ifname' "$_val"
+}
+
+section_enabled() {
+ local enabled
+ config_get_bool enabled "$1" 'enabled' 0
+ [ $enabled -gt 0 ]
+}
+
+start_instance() {
+ local section="$1"
+ local if
+ local args
+
+ section_enabled "$section" || return 1
+
+ config_get_ifname if "$section" 'interface' 'lan'
+ args="-n -i $if"
+ append_string args "$section" 'ethers' '-e'
+ append_bool args "$section" 'verbose' '-v'
+
+ SERVICE_PID_FILE="/var/run/rarpd-${if}.pid"
+ service_start /usr/sbin/rarpd $args
+}
+
+stop_instance() {
+ local section="$1"
+ local id
+ local if
+
+ section_enabled "$section" || return 1
+
+ config_get_ifname if "$section" 'interface' 'lan'
+
+ SERVICE_PID_FILE="/var/run/rarpd-${if}.pid"
+ service_stop /usr/sbin/rarpd
+}
start() {
- [ -f $DEFAULT ] && . $DEFAULT
- $RARPD $OPTIONS
+ include /lib/network
+ scan_interfaces
+ config_load 'rarpd'
+ config_foreach start_instance 'rarpd'
}
+
stop() {
- killall rarpd
+ include /lib/network
+ scan_interfaces
+ config_load 'rarpd'
+ config_foreach stop_instance 'rarpd'
}