#define OT_BITFLAG (1 << 27)
#define OT_RESERVED (1 << 28)
+#define DHC_REQOPT(o, r, n) \
+ (!((o)->type & OT_NOREQ) && \
+ ((o)->type & OT_REQUEST || has_option_mask((r), (o)->option)) && \
+ !has_option_mask((n), (o)->option))
+
struct dhcp_opt {
uint32_t option; /* Also used for IANA Enterpise Number */
int type;
i < ifp->ctx->dhcp_opts_len;
i++, opt++)
{
- if (!(opt->type & OT_REQUEST ||
- has_option_mask(ifo->requestmask, opt->option)))
- continue;
- if (opt->type & OT_NOREQ)
+ if (!DHC_REQOPT(opt, ifo->requestmask, ifo->nomask))
continue;
if (type == DHCP_INFORM &&
(opt->option == DHO_RENEWALTIME ||
break;
if (lp < p)
continue;
- if (!(opt->type & OT_REQUEST ||
- has_option_mask(ifo->requestmask, opt->option)))
- continue;
- if (opt->type & OT_NOREQ)
+ if (!DHC_REQOPT(opt, ifo->requestmask, ifo->nomask))
continue;
if (type == DHCP_INFORM &&
(opt->option == DHO_RENEWALTIME ||
break;
}
if (n < ifo->dhcp6_override_len)
- continue;
- if (!(opt->type & OT_NOREQ) &&
- (opt->type & OT_REQUEST ||
- has_option_mask(ifo->requestmask6, opt->option)))
- {
- n_options++;
- len += sizeof(o.len);
- }
+ continue;
+ if (!DHC_REQOPT(opt, ifo->requestmask6, ifo->nomask6))
+ continue;
+ n_options++;
+ len += sizeof(o.len);
}
#ifndef SMALL
for (l = 0, opt = ifo->dhcp6_override;
l < ifo->dhcp6_override_len;
l++, opt++)
{
- if (!(opt->type & OT_NOREQ) &&
- (opt->type & OT_REQUEST ||
- has_option_mask(ifo->requestmask6, opt->option)))
- {
- n_options++;
- len += sizeof(o.len);
- }
+ if (!DHC_REQOPT(opt, ifo->requestmask6, ifo->nomask6))
+ continue;
+ n_options++;
+ len += sizeof(o.len);
}
if (dhcp6_findselfsla(ifp)) {
n_options++;
if (n < ifo->dhcp6_override_len)
continue;
#endif
- if (!(opt->type & OT_NOREQ) &&
- (opt->type & OT_REQUEST ||
- has_option_mask(ifo->requestmask6,
- opt->option)))
- {
- o.code = htons((uint16_t)opt->option);
- memcpy(p, &o.code, sizeof(o.code));
- p += sizeof(o.code);
- o.len = (uint16_t)
- (o.len + sizeof(o.code));
- }
+ if (!DHC_REQOPT(opt, ifo->requestmask6,
+ ifo->nomask6))
+ continue;
+ o.code = htons((uint16_t)opt->option);
+ memcpy(p, &o.code, sizeof(o.code));
+ p += sizeof(o.code);
+ o.len = (uint16_t)(o.len + sizeof(o.code));
}
#ifndef SMALL
for (l = 0, opt = ifo->dhcp6_override;
l < ifo->dhcp6_override_len;
l++, opt++)
{
- if (!(opt->type & OT_NOREQ) &&
- (opt->type & OT_REQUEST ||
- has_option_mask(ifo->requestmask6,
- opt->option)))
- {
- o.code = htons((uint16_t)opt->option);
- memcpy(p, &o.code, sizeof(o.code));
- p += sizeof(o.code);
- o.len = (uint16_t)
- (o.len + sizeof(o.code));
- }
+ if (!DHC_REQOPT(opt, ifo->requestmask6,
+ ifo->nomask6))
+ continue;
+ o.code = htons((uint16_t)opt->option);
+ memcpy(p, &o.code, sizeof(o.code));
+ p += sizeof(o.code);
+ o.len = (uint16_t)(o.len + sizeof(o.code));
}
if (dhcp6_findselfsla(ifp)) {
o.code = htons(D6_OPTION_PD_EXCLUDE);