The FreeRADIUS server $Id: 15bac2a4c627c01d1aa2047687b3418955ac7f00 $
Loading...
Searching...
No Matches
Functions | Variables
base.c File Reference

Functions to encode DHCP options. More...

#include <freeradius-devel/io/pair.h>
#include <freeradius-devel/protocol/dhcpv6/freeradius.internal.h>
#include <freeradius-devel/protocol/dhcpv6/rfc3315.h>
#include <freeradius-devel/protocol/dhcpv6/rfc5007.h>
#include <freeradius-devel/util/proto.h>
#include <freeradius-devel/util/rand.h>
#include "dhcpv6.h"
#include "attrs.h"
+ Include dependency graph for base.c:

Go to the source code of this file.

Functions

static bool attr_valid (fr_dict_attr_t *da)
 
static void dhcpv6_print_hex (FILE *fp, uint8_t const *packet, size_t packet_len, int depth)
 
static bool duid_match (uint8_t const *option, fr_dhcpv6_decode_ctx_t const *packet_ctx)
 
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.
 
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.
 
void fr_dhcpv6_global_free (void)
 
int fr_dhcpv6_global_init (void)
 
void * fr_dhcpv6_next_encodable (fr_dlist_head_t *list, void *current, void *uctx)
 DHCPV6-specific iterator.
 
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.
 
static ssize_t fr_dhcpv6_ok_internal (uint8_t const *packet, uint8_t const *end, size_t max_attributes, int depth)
 
uint8_t const * fr_dhcpv6_option_find (uint8_t const *start, uint8_t const *end, unsigned int option)
 
static ssize_t fr_dhcpv6_options_ok (uint8_t const *packet, uint8_t const *end, size_t max_attributes, bool allow_relay, int depth)
 
void fr_dhcpv6_print_hex (FILE *fp, uint8_t const *packet, size_t packet_len)
 Print a raw DHCP packet as hex.
 
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.
 
static void print_hex_data (FILE *fp, uint8_t const *ptr, int attrlen, int depth)
 
static bool verify_from_client (uint8_t const *packet, size_t packet_len, fr_dhcpv6_decode_ctx_t const *packet_ctx)
 Verify a packet from a client to a server.
 
static bool verify_to_client (uint8_t const *packet, size_t packet_len, fr_dhcpv6_decode_ctx_t const *packet_ctx)
 Verify a reply packet from a server to a client.
 

Variables

fr_dict_attr_t const * attr_hop_count
 
fr_dict_attr_t const * attr_option_request
 
fr_dict_attr_t const * attr_packet_type
 
fr_dict_attr_t const * attr_relay_link_address
 
fr_dict_attr_t const * attr_relay_message
 
fr_dict_attr_t const * attr_relay_peer_address
 
fr_dict_attr_t const * attr_transaction_id
 
static fr_dict_flag_parser_t const dhcpv6_flags []
 
fr_dict_t const * dict_dhcpv6
 
char const * fr_dhcpv6_packet_names [FR_DHCPV6_CODE_MAX]
 
static uint32_t instance_count = 0
 
fr_dict_autoload_t libfreeradius_dhcpv6_dict []
 
fr_dict_attr_autoload_t libfreeradius_dhcpv6_dict_attr []
 
fr_dict_protocol_t libfreeradius_dhcpv6_dict_protocol
 
static char const tabs [] = "\t\t\t\t\t\t\t\t\t\t\t\t\t\t\t\t\t\t\t\t\t\t\t\t\t"
 

Detailed Description

Functions to encode DHCP options.

Id
e2f2cfac4e92dd723ba4c253220537df8a7e9dfd
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 base.c.

Function Documentation

◆ attr_valid()

static bool attr_valid ( fr_dict_attr_t da)
static

Definition at line 950 of file base.c.

+ Here is the call graph for this function:

◆ dhcpv6_print_hex()

static void dhcpv6_print_hex ( FILE *  fp,
uint8_t const *  packet,
size_t  packet_len,
int  depth 
)
static

Definition at line 815 of file base.c.

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

◆ duid_match()

static bool duid_match ( uint8_t const *  option,
fr_dhcpv6_decode_ctx_t const *  packet_ctx 
)
static

Definition at line 269 of file base.c.

+ 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_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_global_free()

void fr_dhcpv6_global_free ( void  )

Definition at line 941 of file base.c.

+ 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_next_encodable()

void * fr_dhcpv6_next_encodable ( fr_dlist_head_t list,
void *  current,
void *  uctx 
)

DHCPV6-specific iterator.

Definition at line 701 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_ok_internal()

static ssize_t fr_dhcpv6_ok_internal ( uint8_t const *  packet,
uint8_t const *  end,
size_t  max_attributes,
int  depth 
)
static

Definition at line 171 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_options_ok()

static ssize_t fr_dhcpv6_options_ok ( uint8_t const *  packet,
uint8_t const *  end,
size_t  max_attributes,
bool  allow_relay,
int  depth 
)
static

Definition at line 120 of file base.c.

+ Here is the call graph for this function:
+ 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:

◆ print_hex_data()

static void print_hex_data ( FILE *  fp,
uint8_t const *  ptr,
int  attrlen,
int  depth 
)
static

Definition at line 802 of file base.c.

+ Here is the call graph for this function:

◆ verify_from_client()

static bool verify_from_client ( uint8_t const *  packet,
size_t  packet_len,
fr_dhcpv6_decode_ctx_t const *  packet_ctx 
)
static

Verify a packet from a client to a server.

Definition at line 423 of file base.c.

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

◆ verify_to_client()

static bool verify_to_client ( uint8_t const *  packet,
size_t  packet_len,
fr_dhcpv6_decode_ctx_t const *  packet_ctx 
)
static

Verify a reply packet from a server to a client.

Definition at line 283 of file base.c.

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

Variable Documentation

◆ attr_hop_count

fr_dict_attr_t const* attr_hop_count

Definition at line 50 of file base.c.

◆ attr_option_request

fr_dict_attr_t const* attr_option_request

Definition at line 54 of file base.c.

◆ attr_packet_type

fr_dict_attr_t const* attr_packet_type

Definition at line 48 of file base.c.

◆ attr_relay_link_address

fr_dict_attr_t const* attr_relay_link_address

Definition at line 51 of file base.c.

◆ attr_relay_message

fr_dict_attr_t const* attr_relay_message

Definition at line 53 of file base.c.

◆ attr_relay_peer_address

fr_dict_attr_t const* attr_relay_peer_address

Definition at line 52 of file base.c.

◆ attr_transaction_id

fr_dict_attr_t const* attr_transaction_id

Definition at line 49 of file base.c.

◆ dhcpv6_flags

fr_dict_flag_parser_t const dhcpv6_flags[]
static
Initial value:
= {
{ L("dns_label"), { .func = dict_flag_dns_label } },
{ L("partial_dns_label"), { .func = dict_flag_partial_dns_label } }
}
#define L(_str)
Helper for initialising arrays of string literals.
Definition build.h:209

Definition at line 113 of file base.c.

◆ dict_dhcpv6

fr_dict_t const* dict_dhcpv6

Definition at line 40 of file base.c.

◆ fr_dhcpv6_packet_names

char const* fr_dhcpv6_packet_names[FR_DHCPV6_CODE_MAX]

Definition at line 71 of file base.c.

◆ instance_count

uint32_t instance_count = 0
static

Definition at line 38 of file base.c.

◆ libfreeradius_dhcpv6_dict

fr_dict_autoload_t libfreeradius_dhcpv6_dict
Initial value:
= {
{ .out = &dict_dhcpv6, .proto = "dhcpv6" },
{ NULL }
}
static fr_dict_t const * dict_dhcpv6
Definition base.c:117

Definition at line 43 of file base.c.

◆ libfreeradius_dhcpv6_dict_attr

fr_dict_attr_autoload_t libfreeradius_dhcpv6_dict_attr
Initial value:
= {
{ .out = &attr_packet_type, .name = "Packet-Type", .type = FR_TYPE_UINT32, .dict = &dict_dhcpv6 },
{ .out = &attr_transaction_id, .name = "Transaction-Id", .type = FR_TYPE_OCTETS, .dict = &dict_dhcpv6 },
{ .out = &attr_hop_count, .name = "Hop-Count", .type = FR_TYPE_UINT8, .dict = &dict_dhcpv6 },
{ .out = &attr_relay_link_address, .name = "Relay-Link-Address", .type = FR_TYPE_IPV6_ADDR, .dict = &dict_dhcpv6 },
{ .out = &attr_relay_peer_address, .name = "Relay-Peer-Address", .type = FR_TYPE_IPV6_ADDR, .dict = &dict_dhcpv6 },
{ .out = &attr_relay_message, .name = "Relay-Message", .type = FR_TYPE_GROUP, .dict = &dict_dhcpv6 },
{ .out = &attr_option_request, .name = "Option-Request", .type = FR_TYPE_UINT16, .dict = &dict_dhcpv6 },
{ NULL }
}
fr_dict_attr_t const * attr_packet_type
Definition base.c:93
@ FR_TYPE_UINT16
16 Bit unsigned integer.
@ FR_TYPE_UINT8
8 Bit unsigned integer.
@ FR_TYPE_UINT32
32 Bit unsigned integer.
@ FR_TYPE_IPV6_ADDR
128 Bit IPv6 Address.
@ FR_TYPE_OCTETS
Raw octets.
@ FR_TYPE_GROUP
A grouping of other attributes.
static fr_dict_attr_t const * attr_hop_count
Definition base.c:129
static fr_dict_attr_t const * attr_relay_link_address
Definition base.c:132
static fr_dict_attr_t const * attr_transaction_id
Definition base.c:134
static fr_dict_attr_t const * attr_relay_peer_address
Definition base.c:133
fr_dict_attr_t const * attr_option_request
Definition base.c:54
fr_dict_attr_t const * attr_relay_message
Definition base.c:53

Definition at line 57 of file base.c.

◆ libfreeradius_dhcpv6_dict_protocol

fr_dict_protocol_t libfreeradius_dhcpv6_dict_protocol
Initial value:
= {
.name = "dhcpv6",
.default_type_size = 2,
.default_type_length = 2,
.attr = {
.valid = attr_valid,
.flags = {
.table = dhcpv6_flags,
.table_len = NUM_ELEMENTS(dhcpv6_flags),
.len = sizeof(fr_dhcpv6_attr_flags_t)
}
},
}
#define NUM_ELEMENTS(_t)
Definition build.h:337
ssize_t fr_dhcpv6_encode_foreign(fr_dbuff_t *dbuff, fr_pair_list_t const *list)
Definition encode.c:726
void fr_dhcpv6_global_free(void)
Definition base.c:941
int fr_dhcpv6_global_init(void)
Definition base.c:899
static fr_dict_flag_parser_t const dhcpv6_flags[]
Definition base.c:113
ssize_t fr_dhcpv6_decode_foreign(TALLOC_CTX *ctx, fr_pair_list_t *out, uint8_t const *data, size_t data_len)
Definition decode.c:438
static bool attr_valid(fr_dict_attr_t *da)
Definition base.c:443

Definition at line 987 of file base.c.

◆ tabs

char const tabs[] = "\t\t\t\t\t\t\t\t\t\t\t\t\t\t\t\t\t\t\t\t\t\t\t\t\t"
static

Definition at line 800 of file base.c.