diff options
author | Simon Kelley <simon@thekelleys.org.uk> | 2022-07-31 11:04:12 +0100 |
---|---|---|
committer | Simon Kelley <simon@thekelleys.org.uk> | 2022-07-31 11:04:12 +0100 |
commit | 6578acd668c0231df00135d0007d355466e21bfe (patch) | |
tree | f85c8ce16616a808646a72bff7b9b89957cda384 | |
parent | b5581ed1735649ca30ca970a80495330ec184fae (diff) | |
download | dnsmasq-6578acd668c0231df00135d0007d355466e21bfe.tar.gz |
Tidy last two commits.
-rw-r--r-- | src/rfc2131.c | 10 | ||||
-rw-r--r-- | src/rfc3315.c | 29 |
2 files changed, 14 insertions, 25 deletions
diff --git a/src/rfc2131.c b/src/rfc2131.c index 692293e..0053909 100644 --- a/src/rfc2131.c +++ b/src/rfc2131.c @@ -1418,14 +1418,8 @@ size_t dhcp_reply(struct dhcp_context *context, char *iface_name, int int_index, } if ((opt = option_find(mess, sz, OPTION_MUD_URL_V4, 1))) - { - add_extradata_opt(lease, opt); - } - else - { - add_extradata_opt(lease, NULL); - } - + add_extradata_opt(lease, opt); + /* DNSMASQ_REQUESTED_OPTIONS */ if ((opt = option_find(mess, sz, OPTION_REQUESTED_OPTIONS, 1))) { diff --git a/src/rfc3315.c b/src/rfc3315.c index 8d601c4..c055718 100644 --- a/src/rfc3315.c +++ b/src/rfc3315.c @@ -1879,23 +1879,23 @@ static void update_leases(struct state *state, struct dhcp_context *context, str #ifdef HAVE_SCRIPT if (daemon->lease_change_command) { - void *class_opt; + void *opt; lease->flags |= LEASE_CHANGED; free(lease->extradata); lease->extradata = NULL; lease->extradata_size = lease->extradata_len = 0; lease->vendorclass_count = 0; - if ((class_opt = opt6_find(state->packet_options, state->end, OPTION6_VENDOR_CLASS, 4))) + if ((opt = opt6_find(state->packet_options, state->end, OPTION6_VENDOR_CLASS, 4))) { - void *enc_opt, *enc_end = opt6_ptr(class_opt, opt6_len(class_opt)); + void *enc_opt, *enc_end = opt6_ptr(opt, opt6_len(opt)); lease->vendorclass_count++; /* send enterprise number first */ - sprintf(daemon->dhcp_buff2, "%u", opt6_uint(class_opt, 0, 4)); + sprintf(daemon->dhcp_buff2, "%u", opt6_uint(opt, 0, 4)); lease_add_extradata(lease, (unsigned char *)daemon->dhcp_buff2, strlen(daemon->dhcp_buff2), 0); - if (opt6_len(class_opt) >= 6) - for (enc_opt = opt6_ptr(class_opt, 4); enc_opt; enc_opt = opt6_next(enc_opt, enc_end)) + if (opt6_len(opt) >= 6) + for (enc_opt = opt6_ptr(opt, 4); enc_opt; enc_opt = opt6_next(enc_opt, enc_end)) { lease->vendorclass_count++; lease_add_extradata(lease, opt6_ptr(enc_opt, 0), opt6_len(enc_opt), 0); @@ -1934,20 +1934,15 @@ 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); - } + 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 - { - lease_add_extradata(lease, NULL, 0, 0); - } + lease_add_extradata(lease, NULL, 0, 0); - if ((class_opt = opt6_find(state->packet_options, state->end, OPTION6_USER_CLASS, 2))) + if ((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)); - for (enc_opt = opt6_ptr(class_opt, 0); enc_opt; enc_opt = opt6_next(enc_opt, enc_end)) + void *enc_opt, *enc_end = opt6_ptr(opt, opt6_len(opt)); + for (enc_opt = opt6_ptr(opt, 0); enc_opt; enc_opt = opt6_next(enc_opt, enc_end)) lease_add_extradata(lease, opt6_ptr(enc_opt, 0), opt6_len(enc_opt), 0); } } |