6ca07c5c90
RFC3527 link selection sub-option is used to select the "uplink" interface of dhcrelay in cases where the DHCP server does not know how to reach the dhcrelay based on the DHCP range. This can happen in weird network configurations like Mesh networks. Signed-off-by: Bruno Randolf <br1@einfach.org> git-svn-id: svn://svn.openwrt.org/openwrt/packages@38447 3c298f89-4303-0410-b956-a3cf2f4a3e73
54 lines
1.1 KiB
Bash
54 lines
1.1 KiB
Bash
#!/bin/sh /etc/rc.common
|
|
# Copyright (C) 2012 OpenWrt.org
|
|
|
|
START=91
|
|
|
|
SERVICE_SIG="KILL"
|
|
SERVICE_PID_FILE="/var/run/dhcrelay4.pid"
|
|
SERVICE_USE_PID=1
|
|
|
|
start() {
|
|
. /lib/functions/network.sh
|
|
config_load dhcrelay
|
|
local args=""
|
|
|
|
local enabled
|
|
config_get_bool enabled ipv4 enabled 0
|
|
[ "$enabled" -eq 0 ] && return 0
|
|
|
|
# listen interfaces
|
|
local interfaces
|
|
local ifname
|
|
config_get interfaces ipv4 interfaces
|
|
for net in $interfaces; do
|
|
if network_get_device ifname "$net"; then
|
|
append args "-i $ifname"
|
|
fi
|
|
done
|
|
|
|
# link selection sub-option (RFC3527)
|
|
local link_selection
|
|
config_get link_selection ipv4 link_selection
|
|
if network_get_device ifname "$link_selection"; then
|
|
append args "-l $ifname"
|
|
fi
|
|
|
|
# relay mode
|
|
local relay_mode
|
|
config_get relay_mode ipv4 relay_mode
|
|
[ -n "$relay_mode" ] && append args "-m $relay_mode"
|
|
|
|
# dhcp server address
|
|
local server
|
|
config_get server ipv4 dhcpserver
|
|
[ -n "$server" ] || return 0
|
|
append args "$server"
|
|
|
|
service_start /usr/sbin/dhcrelay -4 -q \
|
|
-pf $SERVICE_PID_FILE $args
|
|
}
|
|
|
|
stop() {
|
|
service_stop /usr/sbin/dhcrelay
|
|
}
|