[packages] wide-dhcpv6: use network.sh to find devices
authorJo-Philipp Wich <jow@openwrt.org>
Tue, 29 May 2012 00:30:58 +0000 (00:30 +0000)
committerJo-Philipp Wich <jow@openwrt.org>
Tue, 29 May 2012 00:30:58 +0000 (00:30 +0000)
SVN-Revision: 31961

ipv6/wide-dhcpv6/Makefile
ipv6/wide-dhcpv6/files/dhcp6c.init
ipv6/wide-dhcpv6/files/dhcp6s.init

index 04f13264da869e953bb045b04edf056e170b3d4b..d44d0a828adeb91f59a7c731d69d41a738cdd41b 100644 (file)
@@ -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)
index 12248109e96884d73dbd793d0195886915b05997..6e224d61fc95b2b1283cd2f4eb06458a9e9eebeb 100644 (file)
@@ -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"
index c50765974c59b6584d938951ea2a52b6797a8a9a..6141e7284854b1b4dc3918813bae7f4b04705a2f 100644 (file)
@@ -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