htons(DHCPV6_OPT_SIP_SERVER_A),
htons(DHCPV6_OPT_AFTR_NAME),
htons(DHCPV6_OPT_PD_EXCLUDE),
+#ifdef EXT_PREFIX_CLASS
htons(DHCPV6_OPT_PREFIX_CLASS),
+#endif
};
odhcp6c_add_state(STATE_ORO, oro, sizeof(oro));
// Update address IA
dhcpv6_for_each_option(opt, end, otype, olen, odata) {
- struct odhcp6c_entry entry = {IN6ADDR_ANY_INIT,
- 0, 0, IN6ADDR_ANY_INIT, 0, 0, 0};
+ struct odhcp6c_entry entry = {IN6ADDR_ANY_INIT, 0, 0,
+ IN6ADDR_ANY_INIT, 0, 0, 0};
if (otype == DHCPV6_OPT_IA_PREFIX) {
struct dhcpv6_ia_prefix *prefix = (void*)&odata[-4];
uint16_t stype, slen;
uint8_t *sdata;
+#ifdef EXT_PREFIX_CLASS
// Find prefix class, if any
dhcpv6_for_each_option(&prefix[1], odata + olen,
- stype, slen, sdata)
- if (stype == DHCPV6_OPT_PREFIX_CLASS && slen == 2)
- entry.prefix_class = ntohs(*((uint16_t*)sdata));
+ stype, slen, sdata)
+ if (stype == DHCPV6_OPT_PREFIX_CLASS && slen == 2)
+ entry.class = sdata[0] << 8 | sdata[1];
+#endif
// Parse PD-exclude
bool ok = true;
entry.length = 128;
entry.target = addr->addr;
+#ifdef EXT_PREFIX_CLASS
uint16_t stype, slen;
uint8_t *sdata;
-
// Find prefix class, if any
dhcpv6_for_each_option(&addr[1], odata + olen,
- stype, slen, sdata)
- if (stype == DHCPV6_OPT_PREFIX_CLASS && slen == 2)
- entry.prefix_class = ntohs(*((uint16_t*)sdata));
-
+ stype, slen, sdata)
+ if (stype == DHCPV6_OPT_PREFIX_CLASS && slen == 2)
+ entry.class = sdata[0] << 8 | sdata[1];
+#endif
+
odhcp6c_update_entry(STATE_IA_NA, &entry);
}
-
if (entry.valid > 0 && timeout > entry.valid)
timeout = entry.valid;
}
DHCPV6_OPT_SIP_SERVER_A = 22,
DHCPV6_OPT_AFTR_NAME = 64,
DHCPV6_OPT_PD_EXCLUDE = 67,
- /* draft-bhandari-dhc-class-based-prefix */
- DHCPV6_OPT_PREFIX_CLASS = 200, /* NOT STANDARDIZED! */
+#ifdef EXT_PREFIX_CLASS
+ /* draft-bhandari-dhc-class-based-prefix, not yet standardized */
+ DHCPV6_OPT_PREFIX_CLASS = EXT_PREFIX_CLASS,
+#endif
};
enum dhcpv6_opt_npt {
struct in6_addr target;
uint32_t valid;
uint32_t preferred;
- uint32_t prefix_class;
+ uint16_t class;
};
} else {
buf_len += snprintf(&buf[buf_len], 24, ",%u,%u", e[i].preferred, e[i].valid);
}
- if ((type == ENTRY_PREFIX || type == ENTRY_ADDRESS) && e[i].prefix_class) {
- buf_len += snprintf(&buf[buf_len], 12, ",class=%u", e[i].prefix_class);
- }
+
+ if ((type == ENTRY_PREFIX || type == ENTRY_ADDRESS) && e[i].class)
+ buf_len += snprintf(&buf[buf_len], 12, ",class=%u", e[i].class);
if (type == ENTRY_PREFIX && e[i].priority) {
// priority and router are abused for prefix exclusion