The FreeRADIUS server  $Id: 15bac2a4c627c01d1aa2047687b3418955ac7f00 $
Data Structures | Macros | Enumerations | Functions | Variables
dhcpv6.h File Reference

Implementation of the DHCPv6 protocol. More...

#include <freeradius-devel/util/dict.h>
#include <freeradius-devel/protocol/dhcpv6/dictionary.h>
+ Include dependency graph for dhcpv6.h:
+ This graph shows which files directly or indirectly include this file:

Go to the source code of this file.

Data Structures

struct  fr_dhcpv6_attr_flags_t
 
struct  fr_dhcpv6_decode_ctx_t
 
struct  fr_dhcpv6_encode_ctx_t
 
struct  fr_dhcpv6_packet_t
 subtype values for DHCPv4 and DHCPv6 More...
 

Macros

#define DHCPV6_DATE_OFFSET   (946684800)
 
#define DHCPV6_GET_OPTION_LEN(_x)   fr_nbo_to_uint16((_x) + 2)
 
#define DHCPV6_GET_OPTION_NUM(_x)   fr_nbo_to_uint16(_x)
 
#define DHCPV6_HDR_LEN   (DHCPV6_MSG_TYPE_LEN + DHCPV6_TRANSACTION_ID_LEN)
 
#define DHCPV6_HOP_COUNT_LEN   1U
 
#define DHCPV6_LINK_ADDRESS_LEN   16U
 
#define DHCPV6_MAX_ATTRIBUTES   1024
 
#define DHCPV6_MAX_RELAY_NESTING   10
 
#define DHCPV6_MSG_TYPE_LEN   1U
 
#define DHCPV6_OPT_HDR_LEN   (sizeof(uint16_t) * 2)
 
#define DHCPV6_PEER_ADDRESS_LEN   16U
 
#define DHCPV6_RELAY_HDR_LEN   (DHCPV6_MSG_TYPE_LEN + DHCPV6_HOP_COUNT_LEN + DHCPV6_LINK_ADDRESS_LEN + DHCPV6_PEER_ADDRESS_LEN)
 
#define DHCPV6_TRANSACTION_ID_LEN   3U
 
#define fr_dhcpv6_flag_dns_label(_da)   (fr_dhcpv6_attr_flags(_da)->dns_label)
 
#define fr_dhcpv6_flag_partial_dns_label(_da)   (fr_dhcpv6_attr_flags(_da)->partial_dns_label)
 
#define FR_DHCPV6_PACKET_CODE_VALID(_code)   (((_code) > 0) && ((_code) < FR_DHCPV6_CODE_MAX))
 
#define IN6ADDR_ALL_DHCP_RELAY_AGENTS_AND_SERVERS   "FF02::1:2"
 
#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}}}
 
#define IN6ADDR_ALL_DHCP_SERVERS   "FF05::1:3"
 
#define IN6ADDR_ALL_DHCP_SERVERS_INIT   {{{ 0xff,0x05,0,0,0,0,0,0,0,0,0,0,0,0,1,3}}}
 

Enumerations

enum  fr_dhcpv6_packet_code_t {
  FR_DHCPV6_INVALID = 0 ,
  FR_DHCPV6_SOLICIT = 1 ,
  FR_DHCPV6_ADVERTISE = 2 ,
  FR_DHCPV6_REQUEST = 3 ,
  FR_DHCPV6_CONFIRM = 4 ,
  FR_DHCPV6_RENEW = 5 ,
  FR_DHCPV6_REBIND = 6 ,
  FR_DHCPV6_REPLY = 7 ,
  FR_DHCPV6_RELEASE = 8 ,
  FR_DHCPV6_DECLINE = 9 ,
  FR_DHCPV6_RECONFIGURE = 10 ,
  FR_DHCPV6_INFORMATION_REQUEST = 11 ,
  FR_DHCPV6_RELAY_FORWARD = 12 ,
  FR_DHCPV6_RELAY_REPLY = 13 ,
  FR_DHCPV6_LEASE_QUERY = 14 ,
  FR_DHCPV6_LEASE_QUERY_REPLY = 15 ,
  FR_DHCPV6_LEASE_QUERY_DONE = 16 ,
  FR_DHCPV6_LEASE_QUERY_DATA = 17 ,
  FR_DHCPV6_RECONFIGURE_REQUEST = 18 ,
  FR_DHCPV6_RECONFIGURE_REPLY = 19 ,
  FR_DHCPV6_DHCPV4_QUERY = 20 ,
  FR_DHCPV6_DHCPV4_RESPONSE = 21 ,
  FR_DHCPV6_ACTIVE_LEASE_QUERY = 22 ,
  FR_DHCPV6_START_TLS = 23 ,
  FR_DHCPV6_BIND_UPDATE = 24 ,
  FR_DHCPV6_BIND_REPLY = 25 ,
  FR_DHCPV6_POOL_REQUEST = 26 ,
  FR_DHCPV6_POOL_RESPONSE = 27 ,
  FR_DHCPV6_UPDATE_REQUEST = 28 ,
  FR_DHCPV6_UPDATE_REQUEST_ALL = 29 ,
  FR_DHCPV6_UPDATE_DONE = 30 ,
  FR_DHCPV6_CONNECT = 31 ,
  FR_DHCPV6_CONNECT_REPLY = 32 ,
  FR_DHCPV6_DISCONNECT = 33 ,
  FR_DHCPV6_STATE = 34 ,
  FR_DHCPV6_CONTACT = 35 ,
  FR_DHCPV6_CODE_MAX = 36 ,
  FR_DHCPV6_DO_NOT_RESPOND = 256
}
 

Functions

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. More...
 
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_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. More...
 
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. More...
 
ssize_t fr_dhcpv6_encode_foreign (fr_dbuff_t *dbuff, fr_pair_list_t const *list)
 
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. More...
 
static bool fr_dhcpv6_flag_any_dns_label (fr_dict_attr_t const *da)
 
void fr_dhcpv6_global_free (void)
 
int fr_dhcpv6_global_init (void)
 
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. More...
 
uint8_t const * fr_dhcpv6_option_find (uint8_t const *start, uint8_t const *end, unsigned int option)
 
void fr_dhcpv6_print_hex (FILE *fp, uint8_t const *packet, size_t packet_len)
 Print a raw DHCP packet as hex. More...
 
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. More...
 

Variables

char const * fr_dhcpv6_packet_names [FR_DHCPV6_CODE_MAX]
 

Detailed Description

Implementation of the DHCPv6 protocol.

Id
c8eb3e6c090bc48d899e1e508608ef5b7f73d408
Author
Arran Cudbard-Bell (a.cud.nosp@m.bard.nosp@m.b@fre.nosp@m.erad.nosp@m.ius.o.nosp@m.rg)

Definition in file dhcpv6.h.


Data Structure Documentation

◆ fr_dhcpv6_attr_flags_t

struct fr_dhcpv6_attr_flags_t

Definition at line 139 of file dhcpv6.h.

Data Fields
bool dns_label
bool partial_dns_label

◆ fr_dhcpv6_decode_ctx_t

struct fr_dhcpv6_decode_ctx_t

Definition at line 132 of file dhcpv6.h.

Data Fields
uint8_t * duid the expected DUID, in wire format
size_t duid_len length of the expected DUID
TALLOC_CTX * tmp_ctx for temporary things cleaned up during decoding
uint32_t transaction_id previous transaction ID

◆ fr_dhcpv6_encode_ctx_t

struct fr_dhcpv6_encode_ctx_t

Definition at line 126 of file dhcpv6.h.

+ Collaboration diagram for fr_dhcpv6_encode_ctx_t:
Data Fields
uint8_t const * original original packet
size_t original_length length of the original packet
fr_dict_attr_t const * root Root attribute of the dictionary.

◆ fr_dhcpv6_packet_t

struct fr_dhcpv6_packet_t

subtype values for DHCPv4 and DHCPv6

Definition at line 114 of file dhcpv6.h.

Data Fields
uint8_t code
uint8_t transaction_id[3]

Macro Definition Documentation

◆ DHCPV6_DATE_OFFSET

#define DHCPV6_DATE_OFFSET   (946684800)

Definition at line 124 of file dhcpv6.h.

◆ DHCPV6_GET_OPTION_LEN

#define DHCPV6_GET_OPTION_LEN (   _x)    fr_nbo_to_uint16((_x) + 2)

Definition at line 48 of file dhcpv6.h.

◆ DHCPV6_GET_OPTION_NUM

#define DHCPV6_GET_OPTION_NUM (   _x)    fr_nbo_to_uint16(_x)

Definition at line 47 of file dhcpv6.h.

◆ DHCPV6_HDR_LEN

Definition at line 43 of file dhcpv6.h.

◆ DHCPV6_HOP_COUNT_LEN

#define DHCPV6_HOP_COUNT_LEN   1U

Definition at line 39 of file dhcpv6.h.

◆ DHCPV6_LINK_ADDRESS_LEN

#define DHCPV6_LINK_ADDRESS_LEN   16U

Definition at line 40 of file dhcpv6.h.

◆ DHCPV6_MAX_ATTRIBUTES

#define DHCPV6_MAX_ATTRIBUTES   1024

Definition at line 52 of file dhcpv6.h.

◆ DHCPV6_MAX_RELAY_NESTING

#define DHCPV6_MAX_RELAY_NESTING   10

Definition at line 50 of file dhcpv6.h.

◆ DHCPV6_MSG_TYPE_LEN

#define DHCPV6_MSG_TYPE_LEN   1U

Definition at line 35 of file dhcpv6.h.

◆ DHCPV6_OPT_HDR_LEN

#define DHCPV6_OPT_HDR_LEN   (sizeof(uint16_t) * 2)

Definition at line 45 of file dhcpv6.h.

◆ DHCPV6_PEER_ADDRESS_LEN

#define DHCPV6_PEER_ADDRESS_LEN   16U

Definition at line 41 of file dhcpv6.h.

◆ DHCPV6_RELAY_HDR_LEN

Definition at line 44 of file dhcpv6.h.

◆ DHCPV6_TRANSACTION_ID_LEN

#define DHCPV6_TRANSACTION_ID_LEN   3U

Definition at line 37 of file dhcpv6.h.

◆ fr_dhcpv6_flag_dns_label

#define fr_dhcpv6_flag_dns_label (   _da)    (fr_dhcpv6_attr_flags(_da)->dns_label)

Definition at line 149 of file dhcpv6.h.

◆ fr_dhcpv6_flag_partial_dns_label

#define fr_dhcpv6_flag_partial_dns_label (   _da)    (fr_dhcpv6_attr_flags(_da)->partial_dns_label)

Definition at line 150 of file dhcpv6.h.

◆ FR_DHCPV6_PACKET_CODE_VALID

#define FR_DHCPV6_PACKET_CODE_VALID (   _code)    (((_code) > 0) && ((_code) < FR_DHCPV6_CODE_MAX))

Definition at line 107 of file dhcpv6.h.

◆ IN6ADDR_ALL_DHCP_RELAY_AGENTS_AND_SERVERS

#define IN6ADDR_ALL_DHCP_RELAY_AGENTS_AND_SERVERS   "FF02::1:2"

Definition at line 57 of file dhcpv6.h.

◆ IN6ADDR_ALL_DHCP_RELAY_AGENTS_AND_SERVERS_INIT

#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}}}

Definition at line 58 of file dhcpv6.h.

◆ IN6ADDR_ALL_DHCP_SERVERS

#define IN6ADDR_ALL_DHCP_SERVERS   "FF05::1:3"

Definition at line 59 of file dhcpv6.h.

◆ IN6ADDR_ALL_DHCP_SERVERS_INIT

#define IN6ADDR_ALL_DHCP_SERVERS_INIT   {{{ 0xff,0x05,0,0,0,0,0,0,0,0,0,0,0,0,1,3}}}

Definition at line 60 of file dhcpv6.h.

Enumeration Type Documentation

◆ fr_dhcpv6_packet_code_t

Enumerator
FR_DHCPV6_INVALID 
FR_DHCPV6_SOLICIT 
FR_DHCPV6_ADVERTISE 
FR_DHCPV6_REQUEST 
FR_DHCPV6_CONFIRM 
FR_DHCPV6_RENEW 
FR_DHCPV6_REBIND 
FR_DHCPV6_REPLY 
FR_DHCPV6_RELEASE 
FR_DHCPV6_DECLINE 
FR_DHCPV6_RECONFIGURE 
FR_DHCPV6_INFORMATION_REQUEST 
FR_DHCPV6_RELAY_FORWARD 
FR_DHCPV6_RELAY_REPLY 
FR_DHCPV6_LEASE_QUERY 
FR_DHCPV6_LEASE_QUERY_REPLY 
FR_DHCPV6_LEASE_QUERY_DONE 
FR_DHCPV6_LEASE_QUERY_DATA 
FR_DHCPV6_RECONFIGURE_REQUEST 
FR_DHCPV6_RECONFIGURE_REPLY 
FR_DHCPV6_DHCPV4_QUERY 
FR_DHCPV6_DHCPV4_RESPONSE 
FR_DHCPV6_ACTIVE_LEASE_QUERY 
FR_DHCPV6_START_TLS 
FR_DHCPV6_BIND_UPDATE 
FR_DHCPV6_BIND_REPLY 
FR_DHCPV6_POOL_REQUEST 
FR_DHCPV6_POOL_RESPONSE 
FR_DHCPV6_UPDATE_REQUEST 
FR_DHCPV6_UPDATE_REQUEST_ALL 
FR_DHCPV6_UPDATE_DONE 
FR_DHCPV6_CONNECT 
FR_DHCPV6_CONNECT_REPLY 
FR_DHCPV6_DISCONNECT 
FR_DHCPV6_STATE 
FR_DHCPV6_CONTACT 
FR_DHCPV6_CODE_MAX 
FR_DHCPV6_DO_NOT_RESPOND 

Definition at line 66 of file dhcpv6.h.

Function Documentation

◆ fr_dhcpv6_attr_flags()

static fr_dhcpv6_attr_flags_t const* fr_dhcpv6_attr_flags ( fr_dict_attr_t const *  da)
inlinestatic

Definition at line 144 of file dhcpv6.h.

+ Here is the call graph for this function:
+ Here is the caller graph for this function:

◆ fr_dhcpv6_decode()

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.

Definition at line 581 of file base.c.

+ Here is the call graph for this function:
+ Here is the caller graph for this function:

◆ fr_dhcpv6_decode_foreign()

ssize_t fr_dhcpv6_decode_foreign ( TALLOC_CTX *  ctx,
fr_pair_list_t out,
uint8_t const *  data,
size_t  data_len 
)

Definition at line 436 of file decode.c.

+ Here is the call graph for this function:

◆ fr_dhcpv6_decode_option()

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.

0 1 2 3 0 1 2 3 4 5 6 7 8 9 0 1 2 3 4 5 6 7 8 9 0 1 2 3 4 5 6 7 8 9 0 1 +-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+ | option-code | option-len | +-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+

Definition at line 421 of file decode.c.

+ Here is the call graph for this function:
+ Here is the caller graph for this function:

◆ fr_dhcpv6_encode()

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.

Definition at line 720 of file base.c.

+ Here is the call graph for this function:
+ Here is the caller graph for this function:

◆ fr_dhcpv6_encode_foreign()

ssize_t fr_dhcpv6_encode_foreign ( fr_dbuff_t dbuff,
fr_pair_list_t const *  list 
)

Definition at line 721 of file encode.c.

+ Here is the call graph for this function:

◆ fr_dhcpv6_encode_option()

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.

Parameters
[out]dbuffWhere to write encoded DHCP attributes.
[in]cursorwith current VP set to the option to be encoded. Will be advanced to the next option to encode.
[in]encode_ctxcontaining parameters for the encoder.
Returns
  • > 0 length of data written.
  • < 0 error.

Definition at line 670 of file encode.c.

+ Here is the call graph for this function:
+ Here is the caller graph for this function:

◆ fr_dhcpv6_flag_any_dns_label()

static bool fr_dhcpv6_flag_any_dns_label ( fr_dict_attr_t const *  da)
inlinestatic

Definition at line 152 of file dhcpv6.h.

+ Here is the call graph for this function:
+ Here is the caller graph for this function:

◆ fr_dhcpv6_global_free()

void fr_dhcpv6_global_free ( void  )

Definition at line 941 of file base.c.

+ Here is the call graph for this function:
+ Here is the caller graph for this function:

◆ fr_dhcpv6_global_init()

int fr_dhcpv6_global_init ( void  )

Definition at line 899 of file base.c.

+ Here is the call graph for this function:
+ Here is the caller graph for this function:

◆ fr_dhcpv6_ok()

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.

Parameters
[in]packetto check.
[in]packet_lenThe size of the packet data.
[in]max_attributesto allow in the packet.
Returns
  • True on success.
  • False on failure.

Definition at line 230 of file base.c.

+ Here is the call graph for this function:
+ Here is the caller graph for this function:

◆ fr_dhcpv6_option_find()

uint8_t const* fr_dhcpv6_option_find ( uint8_t const *  start,
uint8_t const *  end,
unsigned int  option 
)

Definition at line 246 of file base.c.

+ Here is the caller graph for this function:

◆ fr_dhcpv6_print_hex()

void fr_dhcpv6_print_hex ( FILE *  fp,
uint8_t const *  packet,
size_t  packet_len 
)

Print a raw DHCP packet as hex.

Definition at line 894 of file base.c.

+ Here is the call graph for this function:
+ Here is the caller graph for this function:

◆ fr_dhcpv6_verify()

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.

Parameters
[in]packetto check.
[in]packet_lenThe size of the packet data.
[in]packet_ctxThe expected packet_ctx
[in]from_servertrue for packets from a server, false for packets from a client.
Returns
  • True on success.
  • False on failure.

fr_dhcpv6_ok() SHOULD be called before calling this function.

Definition at line 547 of file base.c.

+ Here is the call graph for this function:

Variable Documentation

◆ fr_dhcpv6_packet_names

char const* fr_dhcpv6_packet_names[FR_DHCPV6_CODE_MAX]
extern

Definition at line 71 of file base.c.