The FreeRADIUS server  $Id: 15bac2a4c627c01d1aa2047687b3418955ac7f00 $
Functions | Variables
decode.c File Reference

Functions to decode DHCP options. More...

#include <freeradius-devel/io/test_point.h>
#include <freeradius-devel/util/proto.h>
#include <freeradius-devel/util/struct.h>
#include <freeradius-devel/util/dns.h>
#include "dhcpv4.h"
#include "attrs.h"
+ Include dependency graph for decode.c:

Go to the source code of this file.

Functions

static ssize_t decode_option (TALLOC_CTX *ctx, fr_pair_list_t *out, fr_dict_attr_t const *parent, uint8_t const *data, size_t const data_len, void *decode_ctx)
 
static ssize_t decode_option_wrapper (TALLOC_CTX *ctx, fr_pair_list_t *out, NDEBUG_UNUSED fr_dict_attr_t const *parent, uint8_t const *data, size_t data_len, void *decode_ctx)
 
static int decode_test_ctx (void **out, TALLOC_CTX *ctx)
 
static ssize_t decode_tlv_trampoline (TALLOC_CTX *ctx, fr_pair_list_t *out, fr_dict_attr_t const *parent, uint8_t const *data, size_t const data_len, void *decode_ctx)
 
static ssize_t decode_value (TALLOC_CTX *ctx, fr_pair_list_t *out, fr_dict_attr_t const *parent, uint8_t const *data, size_t data_len, void *decode_ctx)
 
static ssize_t decode_value_trampoline (TALLOC_CTX *ctx, fr_pair_list_t *out, fr_dict_attr_t const *parent, uint8_t const *data, size_t const data_len, void *decode_ctx)
 Handle arrays of DNS labels for fr_struct_from_network() More...
 
static ssize_t decode_vsa (TALLOC_CTX *ctx, fr_pair_list_t *out, fr_dict_attr_t const *parent, uint8_t const *data, size_t const data_len, void *decode_ctx)
 RFC 4243 Vendor Specific Suboptions. More...
 
ssize_t fr_dhcpv4_decode_foreign (TALLOC_CTX *ctx, fr_pair_list_t *out, uint8_t const *data, size_t data_len)
 
ssize_t fr_dhcpv4_decode_option (TALLOC_CTX *ctx, fr_pair_list_t *out, uint8_t const *data, size_t data_len, void *decode_ctx)
 Decode DHCP option. More...
 
static ssize_t fr_dhcpv4_decode_proto (TALLOC_CTX *ctx, fr_pair_list_t *out, uint8_t const *data, size_t data_len, UNUSED void *proto_ctx)
 
static bool verify_tlvs (uint8_t const *data, size_t data_len)
 

Variables

static _Thread_local uint8_t concat_buffer [1500]
 
fr_test_point_pair_decode_t dhcpv4_tp_decode_pair
 
fr_test_point_proto_decode_t dhcpv4_tp_decode_proto
 

Detailed Description

Functions to decode DHCP options.

Id
7fdc866393aad090c39079752be0b1dfdc2e2e95

Definition in file decode.c.

Function Documentation

◆ decode_option()

static ssize_t decode_option ( TALLOC_CTX *  ctx,
fr_pair_list_t out,
fr_dict_attr_t const *  parent,
uint8_t const *  data,
size_t const  data_len,
void *  decode_ctx 
)
static

Definition at line 433 of file decode.c.

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

◆ decode_option_wrapper()

static ssize_t decode_option_wrapper ( TALLOC_CTX *  ctx,
fr_pair_list_t out,
NDEBUG_UNUSED fr_dict_attr_t const *  parent,
uint8_t const *  data,
size_t  data_len,
void *  decode_ctx 
)
static

Definition at line 705 of file decode.c.

+ Here is the call graph for this function:

◆ decode_test_ctx()

static int decode_test_ctx ( void **  out,
TALLOC_CTX *  ctx 
)
static

Definition at line 680 of file decode.c.

◆ decode_tlv_trampoline()

static ssize_t decode_tlv_trampoline ( TALLOC_CTX *  ctx,
fr_pair_list_t out,
fr_dict_attr_t const *  parent,
uint8_t const *  data,
size_t const  data_len,
void *  decode_ctx 
)
static

Definition at line 57 of file decode.c.

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

◆ decode_value()

static ssize_t decode_value ( TALLOC_CTX *  ctx,
fr_pair_list_t out,
fr_dict_attr_t const *  parent,
uint8_t const *  data,
size_t  data_len,
void *  decode_ctx 
)
static

Definition at line 89 of file decode.c.

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

◆ decode_value_trampoline()

static ssize_t decode_value_trampoline ( TALLOC_CTX *  ctx,
fr_pair_list_t out,
fr_dict_attr_t const *  parent,
uint8_t const *  data,
size_t const  data_len,
void *  decode_ctx 
)
static

Handle arrays of DNS labels for fr_struct_from_network()

Definition at line 70 of file decode.c.

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

◆ decode_vsa()

static ssize_t decode_vsa ( TALLOC_CTX *  ctx,
fr_pair_list_t out,
fr_dict_attr_t const *  parent,
uint8_t const *  data,
size_t const  data_len,
void *  decode_ctx 
)
static

RFC 4243 Vendor Specific Suboptions.

Vendor specific suboptions are in the format.

     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
    +-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+
    |                     Enterprise Number 0                       |
    +-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+
    |    Len 0      |                                               /
    +-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+
    /                      Suboption Data 0                         /
    +-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+
    |                     Enterprise Number n                       |
    +-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+
    |    Len n      |                                               /
    +-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+
    /                      Suboption Data n                         /
    +-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+

So although the vendor is identified, the format of the data isn't specified so we can't actually resolve the suboption to an attribute. For now, we just convert it to an attribute of Vendor-Specific-Information with raw octets contents.

Definition at line 349 of file decode.c.

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

◆ fr_dhcpv4_decode_foreign()

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

Definition at line 640 of file decode.c.

+ Here is the call graph for this function:

◆ fr_dhcpv4_decode_option()

ssize_t fr_dhcpv4_decode_option ( TALLOC_CTX *  ctx,
fr_pair_list_t out,
uint8_t const *  data,
size_t  data_len,
void *  decode_ctx 
)

Decode DHCP option.

Parameters
[in]ctxcontext to alloc new attributes in.
[out]outWhere to write the decoded options.
[in]datato parse.
[in]data_lenof data to parse.
[in]decode_ctxUnused.

Definition at line 538 of file decode.c.

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

◆ fr_dhcpv4_decode_proto()

static ssize_t fr_dhcpv4_decode_proto ( TALLOC_CTX *  ctx,
fr_pair_list_t out,
uint8_t const *  data,
size_t  data_len,
UNUSED void *  proto_ctx 
)
static

Definition at line 693 of file decode.c.

+ Here is the call graph for this function:

◆ verify_tlvs()

static bool verify_tlvs ( uint8_t const *  data,
size_t  data_len 
)
static

Definition at line 41 of file decode.c.

+ Here is the caller graph for this function:

Variable Documentation

◆ concat_buffer

_Thread_local uint8_t concat_buffer[1500]
static

Definition at line 35 of file decode.c.

◆ dhcpv4_tp_decode_pair

fr_test_point_pair_decode_t dhcpv4_tp_decode_pair
Initial value:
= {
.test_ctx = decode_test_ctx,
}
static int decode_test_ctx(void **out, TALLOC_CTX *ctx)
Definition: decode.c:680
static ssize_t decode_option_wrapper(TALLOC_CTX *ctx, fr_pair_list_t *out, NDEBUG_UNUSED fr_dict_attr_t const *parent, uint8_t const *data, size_t data_len, void *decode_ctx)
Definition: decode.c:705

Definition at line 717 of file decode.c.

◆ dhcpv4_tp_decode_proto

fr_test_point_proto_decode_t dhcpv4_tp_decode_proto
Initial value:
= {
.test_ctx = decode_test_ctx,
}
static ssize_t fr_dhcpv4_decode_proto(TALLOC_CTX *ctx, fr_pair_list_t *out, uint8_t const *data, size_t data_len, UNUSED void *proto_ctx)
Definition: decode.c:693

Definition at line 723 of file decode.c.