summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorHugo Hakim Damer <hdamer@uni-bremen.de>2022-07-09 19:45:51 +0000
committerSimon Kelley <simon@thekelleys.org.uk>2022-07-29 12:57:27 +0100
commit508d6b4885c908c255de4cc742253fc567b4198c (patch)
treeba548e415b06fb4f65e9685d110f61a670b62137
parentef6efd69edfc87b7a00aaa3b59d8516ab3947ca1 (diff)
downloaddnsmasq-508d6b4885c908c255de4cc742253fc567b4198c.tar.gz
Pass MUD URLs (RFC 8520) supplied via DHCPv6 to DHCP scripts
Extract Manufacturer Usage Description (MUD) URL from DHCP Option 112 and make it available to DHCP scripts as DNSMASQ_MUD_URL. This expands on the initial support for Manufacturer Usage Description URLs that has been added in the previous commit for DHCPv4 by also supporting MUD URLs supplied using DHCPv6. 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/dhcp6-protocol.h1
-rw-r--r--src/helper.c6
-rw-r--r--src/rfc3315.c10
3 files changed, 15 insertions, 2 deletions
diff --git a/src/dhcp6-protocol.h b/src/dhcp6-protocol.h
index 332d536..ce16603 100644
--- a/src/dhcp6-protocol.h
+++ b/src/dhcp6-protocol.h
@@ -63,6 +63,7 @@
#define OPTION6_FQDN 39
#define OPTION6_NTP_SERVER 56
#define OPTION6_CLIENT_MAC 79
+#define OPTION6_MUD_URL 112
#define NTP_SUBOPTION_SRV_ADDR 1
#define NTP_SUBOPTION_MC_ADDR 2
diff --git a/src/helper.c b/src/helper.c
index 14330f3..749e8cc 100644
--- a/src/helper.c
+++ b/src/helper.c
@@ -638,8 +638,10 @@ int create_helper(int event_fd, int err_fd, uid_t uid, gid_t gid, long max_fd)
buf = grab_extradata(buf, end, "DNSMASQ_TAGS", &err);
- if (is6)
- buf = grab_extradata(buf, end, "DNSMASQ_RELAY_ADDRESS", &err);
+ if (is6) {
+ buf = grab_extradata(buf, end, "DNSMASQ_RELAY_ADDRESS", &err);
+ buf = grab_extradata(buf, end, "DNSMASQ_MUD_URL", &err);
+ }
else
{
const char *giaddr = NULL;
diff --git a/src/rfc3315.c b/src/rfc3315.c
index 6533197..8d601c4 100644
--- a/src/rfc3315.c
+++ b/src/rfc3315.c
@@ -1934,6 +1934,16 @@ static void update_leases(struct state *state, struct dhcp_context *context, str
lease_add_extradata(lease, (unsigned char *)daemon->addrbuff, state->link_address ? strlen(daemon->addrbuff) : 0, 0);
+ void *mud_opt;
+ if ((mud_opt = opt6_find(state->packet_options, state->end, OPTION6_MUD_URL, 1)))
+ {
+ lease_add_extradata(lease, opt6_ptr(mud_opt, 0), opt6_len(mud_opt), NULL);
+ }
+ else
+ {
+ lease_add_extradata(lease, NULL, 0, 0);
+ }
+
if ((class_opt = opt6_find(state->packet_options, state->end, OPTION6_USER_CLASS, 2)))
{
void *enc_opt, *enc_end = opt6_ptr(class_opt, opt6_len(class_opt));