diff options
author | Simon Kelley <simon@thekelleys.org.uk> | 2022-07-31 12:15:38 +0100 |
---|---|---|
committer | Simon Kelley <simon@thekelleys.org.uk> | 2022-07-31 12:15:38 +0100 |
commit | 6134b94c021afa3e90258fff13b301a058503df7 (patch) | |
tree | d20b4ecb34736c9bed4b9efdbf5d01b3b332b996 | |
parent | 05e6728e9874ab748c4c6629ff869af43533a16d (diff) | |
download | dnsmasq-6134b94c021afa3e90258fff13b301a058503df7.tar.gz |
Update man page on DHCP data provided to scripts. Provide requested options for DHCPv6 also.
-rw-r--r-- | man/dnsmasq.8 | 7 | ||||
-rw-r--r-- | src/helper.c | 6 | ||||
-rw-r--r-- | src/rfc2131.c | 15 | ||||
-rw-r--r-- | src/rfc3315.c | 14 |
4 files changed, 27 insertions, 15 deletions
diff --git a/man/dnsmasq.8 b/man/dnsmasq.8 index f084757..adb10a4 100644 --- a/man/dnsmasq.8 +++ b/man/dnsmasq.8 @@ -1743,6 +1743,11 @@ DNSMASQ_LOG_DHCP is set if .B --log-dhcp is in effect. +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. + +DNSMASQ_MUD_URL the Manufacturer Usage Description URL if provided by the client. (See RFC8520 for details.) + + For IPv4 only: DNSMASQ_CLIENT_ID if the host provided a client-id. @@ -1752,8 +1757,6 @@ 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 8504aca..ee2cab3 100644 --- a/src/helper.c +++ b/src/helper.c @@ -450,9 +450,9 @@ int create_helper(int event_fd, int err_fd, uid_t uid, gid_t gid, long max_fd) buf = grab_extradata_lua(buf, end, "circuit_id"); buf = grab_extradata_lua(buf, end, "subscriber_id"); buf = grab_extradata_lua(buf, end, "remote_id"); - buf = grab_extradata_lua(buf, end, "requested_options"); } - + + buf = grab_extradata_lua(buf, end, "requested_options"); buf = grab_extradata_lua(buf, end, "mud_url"); buf = grab_extradata_lua(buf, end, "tags"); @@ -635,9 +635,9 @@ 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_REQUESTED_OPTIONS", &err); buf = grab_extradata(buf, end, "DNSMASQ_MUD_URL", &err); buf = grab_extradata(buf, end, "DNSMASQ_TAGS", &err); diff --git a/src/rfc2131.c b/src/rfc2131.c index 7e7c1a5..2056cba 100644 --- a/src/rfc2131.c +++ b/src/rfc2131.c @@ -1420,20 +1420,15 @@ size_t dhcp_reply(struct dhcp_context *context, char *iface_name, int int_index, /* DNSMASQ_REQUESTED_OPTIONS */ if ((opt = option_find(mess, sz, OPTION_REQUESTED_OPTIONS, 1))) { - int len = option_len(opt); + int i, 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); + lease_add_extradata(lease, (unsigned char *)daemon->namebuff, + sprintf(daemon->namebuff, "%u", rop[i]), (i + 1) == len ? 0 : ','); } else - { - add_extradata_opt(lease, NULL); - } + lease_add_extradata(lease, NULL, 0, 0); add_extradata_opt(lease, option_find(mess, sz, OPTION_MUD_URL_V4, 1)); diff --git a/src/rfc3315.c b/src/rfc3315.c index 31260df..866b8b8 100644 --- a/src/rfc3315.c +++ b/src/rfc3315.c @@ -1880,6 +1880,7 @@ static void update_leases(struct state *state, struct dhcp_context *context, str if (daemon->lease_change_command) { void *opt; + lease->flags |= LEASE_CHANGED; free(lease->extradata); lease->extradata = NULL; @@ -1905,6 +1906,19 @@ static void update_leases(struct state *state, struct dhcp_context *context, str lease_add_extradata(lease, (unsigned char *)state->client_hostname, state->client_hostname ? strlen(state->client_hostname) : 0, 0); + /* DNSMASQ_REQUESTED_OPTIONS */ + if ((opt = opt6_find(state->packet_options, state->end, OPTION6_ORO, 2))) + { + int i, len = opt6_len(opt)/2; + u16 *rop = opt6_ptr(opt, 0); + + for (i = 0; i < len; i++) + lease_add_extradata(lease, (unsigned char *)daemon->namebuff, + sprintf(daemon->namebuff, "%u", ntohs(rop[i])), (i + 1) == len ? 0 : ','); + } + else + lease_add_extradata(lease, NULL, 0, 0); + if ((opt = opt6_find(state->packet_options, state->end, OPTION6_MUD_URL, 1))) lease_add_extradata(lease, opt6_ptr(opt, 0), opt6_len(opt), 0); else |