[packages] wide-dhcpv6: use network.sh to find devices
git-svn-id: svn://svn.openwrt.org/openwrt/packages@31961 3c298f89-4303-0410-b956-a3cf2f4a3e73
This commit is contained in:
parent
3e9cc1fa6a
commit
524b8d3632
@ -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.
|
# This is free software, licensed under the GNU General Public License v2.
|
||||||
# See /LICENSE for more information.
|
# See /LICENSE for more information.
|
||||||
@ -9,7 +9,7 @@ include $(TOPDIR)/rules.mk
|
|||||||
|
|
||||||
PKG_NAME:=wide-dhcpv6
|
PKG_NAME:=wide-dhcpv6
|
||||||
PKG_VERSION:=20080615
|
PKG_VERSION:=20080615
|
||||||
PKG_RELEASE:=10
|
PKG_RELEASE:=11
|
||||||
|
|
||||||
PKG_SOURCE:=$(PKG_NAME)-$(PKG_VERSION).tar.gz
|
PKG_SOURCE:=$(PKG_NAME)-$(PKG_VERSION).tar.gz
|
||||||
PKG_SOURCE_URL:=@SF/$(PKG_NAME)
|
PKG_SOURCE_URL:=@SF/$(PKG_NAME)
|
||||||
|
@ -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'
|
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() {
|
dhcp6c_write_duid() {
|
||||||
local mac="${1:-$(ifconfig "$client_device" | sed -ne 's/[[:space:]]*$//; s/.*HWaddr //p')}"
|
local mac="${1:-$(ifconfig "$client_device" | sed -ne 's/[[:space:]]*$//; s/.*HWaddr //p')}"
|
||||||
local pat="[0-9A-F][0-9A-F]"
|
local pat="[0-9A-F][0-9A-F]"
|
||||||
@ -73,6 +52,7 @@ dhcp6c_write_interface() {
|
|||||||
local sla_id
|
local sla_id
|
||||||
local sla_len
|
local sla_len
|
||||||
local enabled
|
local enabled
|
||||||
|
local device
|
||||||
|
|
||||||
config_get_bool enabled "$cfg" enabled 0
|
config_get_bool enabled "$cfg" enabled 0
|
||||||
|
|
||||||
@ -80,10 +60,12 @@ dhcp6c_write_interface() {
|
|||||||
config_get sla_id "$cfg" sla_id
|
config_get sla_id "$cfg" sla_id
|
||||||
config_get sla_len "$cfg" sla_len
|
config_get sla_len "$cfg" sla_len
|
||||||
|
|
||||||
printf '\tprefix-interface %s {\n' "$(get_ifname $cfg)"
|
network_get_device device "$cfg" && {
|
||||||
printf '\t\tsla-id %s;\n' "$sla_id"
|
printf '\tprefix-interface %s {\n' "$device"
|
||||||
printf '\t\tsla-len %s;\n' "$sla_len"
|
printf '\t\tsla-id %s;\n' "$sla_id"
|
||||||
printf '\t};\n'
|
printf '\t\tsla-len %s;\n' "$sla_len"
|
||||||
|
printf '\t};\n'
|
||||||
|
}
|
||||||
fi
|
fi
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -143,7 +125,7 @@ start() {
|
|||||||
|
|
||||||
[ -e /var/run/dhcp6c.pid ] && return 0
|
[ -e /var/run/dhcp6c.pid ] && return 0
|
||||||
|
|
||||||
include /lib/network
|
. /lib/functions/network.sh
|
||||||
|
|
||||||
config_load "dhcp6c"
|
config_load "dhcp6c"
|
||||||
|
|
||||||
@ -156,10 +138,10 @@ start() {
|
|||||||
|
|
||||||
logger -t dhcp6c starting dhcp6c
|
logger -t dhcp6c starting dhcp6c
|
||||||
|
|
||||||
local client_interface
|
local client_interface client_ifname client_device
|
||||||
config_get client_interface basic interface
|
config_get client_interface basic interface
|
||||||
local client_ifname=$(get_ifname "$client_interface")
|
network_get_device client_ifname "$client_interface"
|
||||||
local client_device=$(get_device "$client_interface" "$client_ifname")
|
network_get_physdev client_device "$client_interface" || client_device="$client_ifname"
|
||||||
|
|
||||||
local config_file="/var/etc/dhcp6c.conf"
|
local config_file="/var/etc/dhcp6c.conf"
|
||||||
local duid_file="/var/dhcp6c_duid"
|
local duid_file="/var/dhcp6c_duid"
|
||||||
|
@ -1,23 +1,14 @@
|
|||||||
#!/bin/sh /etc/rc.common
|
#!/bin/sh /etc/rc.common
|
||||||
# Copyright (C) 2010-2011 OpenWrt.org
|
# Copyright (C) 2010-2012 OpenWrt.org
|
||||||
|
|
||||||
SERVICE_USE_PID=1
|
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() {
|
start() {
|
||||||
[ ! -e /etc/dhcp6sctlkey ] && `dd if=/dev/urandom count=1 2> /dev/null | md5sum | cut -d" " -f1 > /etc/dhcp6sctlkey`
|
[ ! -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
|
[ -e /var/run/dhcp6s.pid ] && return 0
|
||||||
|
|
||||||
include /lib/network
|
. /lib/functions/network.sh
|
||||||
|
|
||||||
config_load "dhcp6s"
|
config_load "dhcp6s"
|
||||||
|
|
||||||
@ -27,9 +18,9 @@ start() {
|
|||||||
|
|
||||||
logger starting dhcp6s
|
logger starting dhcp6s
|
||||||
|
|
||||||
local server_interface
|
local server_interface server_ifname
|
||||||
config_get server_interface basic interface
|
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
|
local config_file
|
||||||
config_get config_file basic config_file
|
config_get config_file basic config_file
|
||||||
|
Loading…
x
Reference in New Issue
Block a user