summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorKevin Yeich <kyeich@gmail.com>2022-07-09 19:46:36 +0000
committerSimon Kelley <simon@thekelleys.org.uk>2022-07-29 13:01:47 +0100
commitb5581ed1735649ca30ca970a80495330ec184fae (patch)
tree2b80a679e52ea4066906301ac26912730ae518db
parent508d6b4885c908c255de4cc742253fc567b4198c (diff)
downloaddnsmasq-b5581ed1735649ca30ca970a80495330ec184fae.tar.gz
Pass MUD URLs (RFC 8520) supplied via DHCPv4 to DHCP scripts
Extract Manufacturer Usage Description (MUD) URL from DHCP Option 161 and make it available to DHCP scripts as DNSMASQ_MUD_URL. See https://datatracker.ietf.org/doc/html/rfc8520#section-17.3 and https://datatracker.ietf.org/doc/html/rfc8520#section-10 Co-authored-by: Jasper Wiegratz <wiegratz@uni-bremen.de>
-rw-r--r--src/dhcp-protocol.h1
-rw-r--r--src/helper.c1
-rw-r--r--src/rfc2131.c9
3 files changed, 11 insertions, 0 deletions
diff --git a/src/dhcp-protocol.h b/src/dhcp-protocol.h
index 75c9cd3..e281143 100644
--- a/src/dhcp-protocol.h
+++ b/src/dhcp-protocol.h
@@ -64,6 +64,7 @@
#define OPTION_SIP_SERVER 120
#define OPTION_VENDOR_IDENT 124
#define OPTION_VENDOR_IDENT_OPT 125
+#define OPTION_MUD_URL_V4 161
#define OPTION_END 255
#define SUBOPT_CIRCUIT_ID 1
diff --git a/src/helper.c b/src/helper.c
index 749e8cc..771a3e9 100644
--- a/src/helper.c
+++ b/src/helper.c
@@ -633,6 +633,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_MUD_URL", &err);
buf = grab_extradata(buf, end, "DNSMASQ_REQUESTED_OPTIONS", &err);
}
diff --git a/src/rfc2131.c b/src/rfc2131.c
index ecda2d3..692293e 100644
--- a/src/rfc2131.c
+++ b/src/rfc2131.c
@@ -1417,6 +1417,15 @@ size_t dhcp_reply(struct dhcp_context *context, char *iface_name, int int_index,
add_extradata_opt(lease, NULL);
}
+ if ((opt = option_find(mess, sz, OPTION_MUD_URL_V4, 1)))
+ {
+ add_extradata_opt(lease, opt);
+ }
+ else
+ {
+ add_extradata_opt(lease, NULL);
+ }
+
/* DNSMASQ_REQUESTED_OPTIONS */
if ((opt = option_find(mess, sz, OPTION_REQUESTED_OPTIONS, 1)))
{