From 524b8d36327c156a3e9b98afe0907089fbf4137a Mon Sep 17 00:00:00 2001 From: jow Date: Tue, 29 May 2012 00:30:58 +0000 Subject: [PATCH] [packages] wide-dhcpv6: use network.sh to find devices git-svn-id: svn://svn.openwrt.org/openwrt/packages@31961 3c298f89-4303-0410-b956-a3cf2f4a3e73 --- ipv6/wide-dhcpv6/Makefile | 4 ++-- ipv6/wide-dhcpv6/files/dhcp6c.init | 40 +++++++++++--------------------------- ipv6/wide-dhcpv6/files/dhcp6s.init | 19 +++++------------- 3 files changed, 18 insertions(+), 45 deletions(-) diff --git a/ipv6/wide-dhcpv6/Makefile b/ipv6/wide-dhcpv6/Makefile index 04f13264d..d44d0a828 100644 --- a/ipv6/wide-dhcpv6/Makefile +++ b/ipv6/wide-dhcpv6/Makefile @@ -1,5 +1,5 @@ # -# Copyright (C) 2010-2011 OpenWrt.org +# Copyright (C) 2010-2012 OpenWrt.org # # This is free software, licensed under the GNU General Public License v2. # See /LICENSE for more information. @@ -9,7 +9,7 @@ include $(TOPDIR)/rules.mk PKG_NAME:=wide-dhcpv6 PKG_VERSION:=20080615 -PKG_RELEASE:=10 +PKG_RELEASE:=11 PKG_SOURCE:=$(PKG_NAME)-$(PKG_VERSION).tar.gz PKG_SOURCE_URL:=@SF/$(PKG_NAME) diff --git a/ipv6/wide-dhcpv6/files/dhcp6c.init b/ipv6/wide-dhcpv6/files/dhcp6c.init index 12248109e..6e224d61f 100644 --- a/ipv6/wide-dhcpv6/files/dhcp6c.init +++ b/ipv6/wide-dhcpv6/files/dhcp6c.init @@ -2,27 +2,6 @@ DHCP6C_REQUEST_OPTIONS='domain_name_servers domain_name ntp_servers sip_server_address sip_domain_name nis_server_address nis_domain_name nisp_server_address nisp_domain_name bcmcs_server_address bcmcs_domain_name' -get_ifname() { - local interface=$1 - local ifname - scan_interfaces - config_get ifname "$interface" ifname - printf '%s\n' "$ifname" - return 0 -} - -get_device() { - local interface=$1 - local ifname=$2 - local device - scan_interfaces - config_get device "$interface" device - grep -qE "^ *$device:" /proc/net/dev && \ - printf '%s\n' "$device" || \ - printf '%s\n' "$ifname" - return 0 -} - dhcp6c_write_duid() { local mac="${1:-$(ifconfig "$client_device" | sed -ne 's/[[:space:]]*$//; s/.*HWaddr //p')}" local pat="[0-9A-F][0-9A-F]" @@ -73,6 +52,7 @@ dhcp6c_write_interface() { local sla_id local sla_len local enabled + local device config_get_bool enabled "$cfg" enabled 0 @@ -80,10 +60,12 @@ dhcp6c_write_interface() { config_get sla_id "$cfg" sla_id config_get sla_len "$cfg" sla_len - printf '\tprefix-interface %s {\n' "$(get_ifname $cfg)" - printf '\t\tsla-id %s;\n' "$sla_id" - printf '\t\tsla-len %s;\n' "$sla_len" - printf '\t};\n' + network_get_device device "$cfg" && { + printf '\tprefix-interface %s {\n' "$device" + printf '\t\tsla-id %s;\n' "$sla_id" + printf '\t\tsla-len %s;\n' "$sla_len" + printf '\t};\n' + } fi } @@ -143,7 +125,7 @@ start() { [ -e /var/run/dhcp6c.pid ] && return 0 - include /lib/network + . /lib/functions/network.sh config_load "dhcp6c" @@ -156,10 +138,10 @@ start() { logger -t dhcp6c starting dhcp6c - local client_interface + local client_interface client_ifname client_device config_get client_interface basic interface - local client_ifname=$(get_ifname "$client_interface") - local client_device=$(get_device "$client_interface" "$client_ifname") + network_get_device client_ifname "$client_interface" + network_get_physdev client_device "$client_interface" || client_device="$client_ifname" local config_file="/var/etc/dhcp6c.conf" local duid_file="/var/dhcp6c_duid" diff --git a/ipv6/wide-dhcpv6/files/dhcp6s.init b/ipv6/wide-dhcpv6/files/dhcp6s.init index c50765974..6141e7284 100644 --- a/ipv6/wide-dhcpv6/files/dhcp6s.init +++ b/ipv6/wide-dhcpv6/files/dhcp6s.init @@ -1,23 +1,14 @@ -#!/bin/sh /etc/rc.common -# Copyright (C) 2010-2011 OpenWrt.org +#!/bin/sh /etc/rc.common +# Copyright (C) 2010-2012 OpenWrt.org SERVICE_USE_PID=1 -get_ifname() { - local interface=$1 - local ifname - scan_interfaces - config_get ifname "$interface" ifname - printf '%s\n' "$ifname" - return 0 -} - start() { [ ! -e /etc/dhcp6sctlkey ] && `dd if=/dev/urandom count=1 2> /dev/null | md5sum | cut -d" " -f1 > /etc/dhcp6sctlkey` [ -e /var/run/dhcp6s.pid ] && return 0 - include /lib/network + . /lib/functions/network.sh config_load "dhcp6s" @@ -27,9 +18,9 @@ start() { logger starting dhcp6s - local server_interface + local server_interface server_ifname config_get server_interface basic interface - local server_ifname=$(get_ifname "$server_interface") + network_get_device server_ifname "$server_interface" || return 1 local config_file config_get config_file basic config_file -- 2.11.0