From f89cae3ecf6b931b960772eb2b4cc1a56ccee8a9 Mon Sep 17 00:00:00 2001 From: ZHAO Yu Date: Thu, 22 Dec 2016 22:32:31 +0000 Subject: [PATCH] Add DNSMASQ_REQUESTED_OPTIONS env-var to lease change script. --- CHANGELOG | 3 +++ man/dnsmasq.8 | 2 ++ src/helper.c | 1 + src/rfc2131.c | 18 ++++++++++++++++++ 4 files changed, 24 insertions(+) diff --git a/CHANGELOG b/CHANGELOG index 5a3a35e..851612b 100644 --- a/CHANGELOG +++ b/CHANGELOG @@ -44,7 +44,10 @@ version 2.77 to Donatas Abraitis for diagnosing this as a potential problem. + Add DNSMASQ_REQUESTED_OPTIONS environment variable to the + lease-change script. Thanks to ZHAO Yu for the patch. + version 2.76 Include 0.0.0.0/8 in DNS rebind checks. This range translates to hosts on the local network, or, at diff --git a/man/dnsmasq.8 b/man/dnsmasq.8 index 5bad224..2b46098 100644 --- a/man/dnsmasq.8 +++ b/man/dnsmasq.8 @@ -1543,6 +1543,8 @@ DHCP relay-agent added any of these options. If the client provides vendor-class, DNSMASQ_VENDOR_CLASS. +DNSMASQ_REQUESTED_OPTIONS a string containing the decimal values in the Parameter Request List option, comma separated, if the parameter request list option is provided by the client. + For IPv6 only: If the client provides vendor-class, DNSMASQ_VENDOR_CLASS_ID, diff --git a/src/helper.c b/src/helper.c index 9c37e37..34a1c8f 100644 --- a/src/helper.c +++ b/src/helper.c @@ -556,6 +556,7 @@ int create_helper(int event_fd, int err_fd, uid_t uid, gid_t gid, long max_fd) buf = grab_extradata(buf, end, "DNSMASQ_CIRCUIT_ID", &err); buf = grab_extradata(buf, end, "DNSMASQ_SUBSCRIBER_ID", &err); buf = grab_extradata(buf, end, "DNSMASQ_REMOTE_ID", &err); + buf = grab_extradata(buf, end, "DNSMASQ_REQUESTED_OPTIONS", &err); } buf = grab_extradata(buf, end, "DNSMASQ_TAGS", &err); diff --git a/src/rfc2131.c b/src/rfc2131.c index 8b99d4b..491c3ca 100644 --- a/src/rfc2131.c +++ b/src/rfc2131.c @@ -1304,6 +1304,24 @@ size_t dhcp_reply(struct dhcp_context *context, char *iface_name, int int_index, add_extradata_opt(lease, NULL); } + /* DNSMASQ_REQUESTED_OPTIONS */ + if ((opt = option_find(mess, sz, OPTION_REQUESTED_OPTIONS, 1))) + { + int len = option_len(opt); + unsigned char *rop = option_ptr(opt, 0); + char *q = daemon->namebuff; + int i; + for (i = 0; i < len; i++) + { + q += snprintf(q, MAXDNAME - (q - daemon->namebuff), "%d%s", rop[i], i + 1 == len ? "" : ","); + } + lease_add_extradata(lease, (unsigned char *)daemon->namebuff, (q - daemon->namebuff), 0); + } + else + { + add_extradata_opt(lease, NULL); + } + /* space-concat tag set */ if (!tagif_netid) add_extradata_opt(lease, NULL);