29 RCSIDH(dhcpv6_h,
"$Id: c8eb3e6c090bc48d899e1e508608ef5b7f73d408 $")
31 #include <freeradius-devel/util/dict.h>
33 #include <freeradius-devel/protocol/dhcpv6/dictionary.h>
35 #define DHCPV6_MSG_TYPE_LEN 1U
37 #define DHCPV6_TRANSACTION_ID_LEN 3U
39 #define DHCPV6_HOP_COUNT_LEN 1U
40 #define DHCPV6_LINK_ADDRESS_LEN 16U
41 #define DHCPV6_PEER_ADDRESS_LEN 16U
43 #define DHCPV6_HDR_LEN (DHCPV6_MSG_TYPE_LEN + DHCPV6_TRANSACTION_ID_LEN)
44 #define DHCPV6_RELAY_HDR_LEN (DHCPV6_MSG_TYPE_LEN + DHCPV6_HOP_COUNT_LEN + DHCPV6_LINK_ADDRESS_LEN + DHCPV6_PEER_ADDRESS_LEN)
45 #define DHCPV6_OPT_HDR_LEN (sizeof(uint16_t) * 2)
47 #define DHCPV6_GET_OPTION_NUM(_x) fr_nbo_to_uint16(_x)
48 #define DHCPV6_GET_OPTION_LEN(_x) fr_nbo_to_uint16((_x) + 2)
50 #define DHCPV6_MAX_RELAY_NESTING 10
52 #define DHCPV6_MAX_ATTRIBUTES 1024
57 #define IN6ADDR_ALL_DHCP_RELAY_AGENTS_AND_SERVERS "FF02::1:2"
58 #define IN6ADDR_ALL_DHCP_RELAY_AGENTS_AND_SERVERS_INIT {{{ 0xff,0x02,0,0,0,0,0,0,0,0,0,0,0,0,1,2}}}
59 #define IN6ADDR_ALL_DHCP_SERVERS "FF05::1:3"
60 #define IN6ADDR_ALL_DHCP_SERVERS_INIT {{{ 0xff,0x05,0,0,0,0,0,0,0,0,0,0,0,0,1,3}}}
107 #define FR_DHCPV6_PACKET_CODE_VALID(_code) (((_code) > 0) && ((_code) < FR_DHCPV6_CODE_MAX))
114 typedef struct CC_HINT(__packed__) {
124 #define DHCPV6_DATE_OFFSET (946684800)
149 #define fr_dhcpv6_flag_dns_label(_da) (fr_dhcpv6_attr_flags(_da)->dns_label)
150 #define fr_dhcpv6_flag_partial_dns_label(_da) (fr_dhcpv6_attr_flags(_da)->partial_dns_label)
192 uint8_t const *
data,
size_t data_len,
void *decode_ctx);
uint32_t transaction_id
previous transaction ID
@ FR_DHCPV6_ACTIVE_LEASE_QUERY
@ FR_DHCPV6_DO_NOT_RESPOND
@ FR_DHCPV6_LEASE_QUERY_DATA
@ FR_DHCPV6_POOL_RESPONSE
@ FR_DHCPV6_RECONFIGURE_REPLY
@ FR_DHCPV6_DHCPV4_RESPONSE
@ FR_DHCPV6_RECONFIGURE_REQUEST
@ FR_DHCPV6_UPDATE_REQUEST_ALL
@ FR_DHCPV6_CONNECT_REPLY
@ FR_DHCPV6_INFORMATION_REQUEST
@ FR_DHCPV6_LEASE_QUERY_DONE
@ FR_DHCPV6_RELAY_FORWARD
@ FR_DHCPV6_LEASE_QUERY_REPLY
@ FR_DHCPV6_UPDATE_REQUEST
fr_dict_attr_t const * root
Root attribute of the dictionary.
uint8_t const * fr_dhcpv6_option_find(uint8_t const *start, uint8_t const *end, unsigned int option)
void fr_dhcpv6_global_free(void)
ssize_t fr_dhcpv6_decode_option(TALLOC_CTX *ctx, fr_pair_list_t *out, uint8_t const *data, size_t data_len, void *decode_ctx)
Create a "normal" fr_pair_t from the given data.
bool fr_dhcpv6_ok(uint8_t const *packet, size_t packet_len, uint32_t max_attributes)
See if the data pointed to by PTR is a valid DHCPv6 packet.
uint8_t * duid
the expected DUID, in wire format
int fr_dhcpv6_global_init(void)
static fr_dhcpv6_attr_flags_t const * fr_dhcpv6_attr_flags(fr_dict_attr_t const *da)
ssize_t fr_dhcpv6_decode(TALLOC_CTX *ctx, fr_pair_list_t *out, uint8_t const *packet, size_t packet_len)
Decode a DHCPv6 packet.
char const * fr_dhcpv6_packet_names[FR_DHCPV6_CODE_MAX]
static bool fr_dhcpv6_flag_any_dns_label(fr_dict_attr_t const *da)
uint8_t const * original
original packet
ssize_t fr_dhcpv6_encode_option(fr_dbuff_t *dbuff, fr_dcursor_t *cursor, void *encode_ctx)
Encode a DHCPv6 option and any sub-options.
size_t original_length
length of the original packet
bool fr_dhcpv6_verify(uint8_t const *packet, size_t packet_len, fr_dhcpv6_decode_ctx_t const *packet_ctx, bool from_server)
Verify the packet under some various circumstances.
void fr_dhcpv6_print_hex(FILE *fp, uint8_t const *packet, size_t packet_len)
Print a raw DHCP packet as hex.
size_t duid_len
length of the expected DUID
TALLOC_CTX * tmp_ctx
for temporary things cleaned up during decoding
ssize_t fr_dhcpv6_decode_foreign(TALLOC_CTX *ctx, fr_pair_list_t *out, uint8_t const *data, size_t data_len)
ssize_t fr_dhcpv6_encode_foreign(fr_dbuff_t *dbuff, fr_pair_list_t const *list)
ssize_t fr_dhcpv6_encode(fr_dbuff_t *dbuff, uint8_t const *original, size_t length, int msg_type, fr_pair_list_t *vps)
Encode a DHCPv6 packet.
subtype values for DHCPv4 and DHCPv6
@ FR_DICT_ATTR_EXT_PROTOCOL_SPECIFIC
Protocol specific extensions.
static void * fr_dict_attr_ext(fr_dict_attr_t const *da, fr_dict_attr_ext_t ext)
static fr_internal_encode_ctx_t encode_ctx
static size_t char ** out