blob: 0f401a5ca8844b75c98b382b7d9e5222284928bc (
plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
|
#!/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
config_get interfaces ipv4 upstream_interfaces
for net in $interfaces; do
if network_get_device ifname "$net"; then
append args "-iu $ifname"
fi
done
config_get interfaces ipv4 downstream_interfaces
for net in $interfaces; do
if network_get_device ifname "$net"; then
append args "-id $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 "-U $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
}
|