Update man page on DHCP data provided to scripts. Provide requested options for DHCPv6 also.

This commit is contained in:
Simon Kelley
2022-07-31 12:15:38 +01:00
parent 05e6728e98
commit 6134b94c02
4 changed files with 27 additions and 15 deletions

View File

@@ -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);

View File

@@ -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));

View File

@@ -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