diff mbox

[OpenWrt-Devel] dnsmasq: add dhcp relay option

Message ID 1454050362-7175-1-git-send-email-dnbugnar@ocedo.com
State Accepted
Headers show

Commit Message

dbugnar Jan. 29, 2016, 6:52 a.m. UTC
From: dbugnar <dnbugnar@ocedo.com>

Signed-off-by: dbugnar <dnbugnar@ocedo.com>
---
 package/network/services/dnsmasq/files/dnsmasq.init | 19 +++++++++++++++++++
 1 file changed, 19 insertions(+)
diff mbox

Patch

diff --git a/package/network/services/dnsmasq/files/dnsmasq.init b/package/network/services/dnsmasq/files/dnsmasq.init
index 3ef2b3d..ac45d1b 100644
--- a/package/network/services/dnsmasq/files/dnsmasq.init
+++ b/package/network/services/dnsmasq/files/dnsmasq.init
@@ -538,6 +538,24 @@  dhcp_hostrecord_add() {
 	xappend "--host-record=$record"
 }
 
+dhcp_relay_add() {
+	local cfg="$1"
+	local local_addr server_addr interface
+
+	config_get local_addr "$cfg" local_addr
+	[ -n "$local_addr" ] || return 0
+
+	config_get server_addr "$cfg" server_addr
+	[ -n "$server_addr" ] || return 0
+
+	config_get interface "$cfg" interface
+	if [ -z "$interface" ]; then
+		xappend "--dhcp-relay=$local_addr,$server_addr"
+	else
+		xappend "--dhcp-relay=$local_addr,$server_addr,$interface"
+	fi
+}
+
 service_triggers()
 {
 	procd_add_reload_trigger "dhcp"
@@ -597,6 +615,7 @@  start_service() {
 	config_foreach dhcp_subscrid_add subscrid
 	config_foreach dhcp_domain_add domain
 	config_foreach dhcp_hostrecord_add hostrecord
+	config_foreach dhcp_relay_add relay
 
 	# add own hostname
 	local lanaddr