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

Functions to encode DHCP options. More...

#include <stdint.h>
#include <stddef.h>
#include <freeradius-devel/io/test_point.h>
#include <freeradius-devel/util/dbuff.h>
#include <freeradius-devel/util/dns.h>
#include <freeradius-devel/util/proto.h>
#include <freeradius-devel/util/struct.h>
#include <freeradius-devel/util/encode.h>
#include "dhcpv6.h"
#include "attrs.h"
+ Include dependency graph for encode.c:

Go to the source code of this file.

Functions

static ssize_t encode_child (fr_dbuff_t *dbuff, fr_da_stack_t *da_stack, unsigned int depth, fr_dcursor_t *cursor, void *encode_ctx)
 
static ssize_t encode_option_hdr (fr_dbuff_marker_t *m, uint16_t option, size_t data_len)
 Macro-like function for encoding an option header. More...
 
static ssize_t encode_relay_message (fr_dbuff_t *dbuff, fr_da_stack_t *da_stack, unsigned int depth, fr_dcursor_t *cursor, UNUSED void *encode_ctx)
 Encode a Relay-Message. More...
 
static ssize_t encode_rfc (fr_dbuff_t *dbuff, fr_da_stack_t *da_stack, unsigned int depth, fr_dcursor_t *cursor, void *encode_ctx)
 Encode an RFC format TLV. More...
 
static int encode_test_ctx (void **out, TALLOC_CTX *ctx)
 
static ssize_t encode_tlv (fr_dbuff_t *dbuff, fr_da_stack_t *da_stack, unsigned int depth, fr_dcursor_t *cursor, void *encode_ctx)
 
static ssize_t encode_value (fr_dbuff_t *dbuff, fr_da_stack_t *da_stack, unsigned int depth, fr_dcursor_t *cursor, void *encode_ctx)
 
static ssize_t encode_vsio (fr_dbuff_t *dbuff, fr_da_stack_t *da_stack, unsigned int depth, fr_dcursor_t *cursor, void *encode_ctx)
 Encode a Vendor-Specific Information Option. 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 ssize_t fr_dhcpv6_encode_proto (UNUSED TALLOC_CTX *ctx, fr_pair_list_t *vps, uint8_t *data, size_t data_len, UNUSED void *proto_ctx)
 

Variables

fr_test_point_pair_encode_t dhcpv6_tp_encode_pair
 
fr_test_point_proto_encode_t dhcpv6_tp_encode_proto
 

Detailed Description

Functions to encode DHCP options.

Id
c78dd365d22d6a42b65ac26c007fe230372df3dc
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 encode.c.

Function Documentation

◆ encode_child()

static ssize_t encode_child ( fr_dbuff_t dbuff,
fr_da_stack_t da_stack,
unsigned int  depth,
fr_dcursor_t cursor,
void *  encode_ctx 
)
static

Definition at line 373 of file encode.c.

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

◆ encode_option_hdr()

static ssize_t encode_option_hdr ( fr_dbuff_marker_t m,
uint16_t  option,
size_t  data_len 
)
inlinestatic

Macro-like function for encoding an option header.

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 | +-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+

Parameters
[out]mWhere to write the 4 byte option header.
[in]optionThe option number (host byte order).
[in]data_lenThe length of the option (host byte order).
Returns
  • <0 How much data would have been required as a negative value.
  • 4 The length of data written.

Definition at line 71 of file encode.c.

+ Here is the caller graph for this function:

◆ encode_relay_message()

static ssize_t encode_relay_message ( fr_dbuff_t dbuff,
fr_da_stack_t da_stack,
unsigned int  depth,
fr_dcursor_t cursor,
UNUSED void *  encode_ctx 
)
static

Encode a Relay-Message.

Header + stuff

Definition at line 615 of file encode.c.

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

◆ encode_rfc()

static ssize_t encode_rfc ( fr_dbuff_t dbuff,
fr_da_stack_t da_stack,
unsigned int  depth,
fr_dcursor_t cursor,
void *  encode_ctx 
)
static

Encode an RFC format TLV.

This could be a standard attribute, or a TLV data type. If it's a standard attribute, then vp->da->attr == attribute. Otherwise, attribute may be something else.

Definition at line 446 of file encode.c.

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

◆ encode_test_ctx()

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

Definition at line 743 of file encode.c.

+ Here is the call graph for this function:

◆ encode_tlv()

static ssize_t encode_tlv ( fr_dbuff_t dbuff,
fr_da_stack_t da_stack,
unsigned int  depth,
fr_dcursor_t cursor,
void *  encode_ctx 
)
static

Definition at line 484 of file encode.c.

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

◆ encode_value()

static ssize_t encode_value ( fr_dbuff_t dbuff,
fr_da_stack_t da_stack,
unsigned int  depth,
fr_dcursor_t cursor,
void *  encode_ctx 
)
static

Definition at line 80 of file encode.c.

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

◆ encode_vsio()

static ssize_t encode_vsio ( fr_dbuff_t dbuff,
fr_da_stack_t da_stack,
unsigned int  depth,
fr_dcursor_t cursor,
void *  encode_ctx 
)
static

Encode a Vendor-Specific Information Option.

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_VENDOR_OPTS | option-len | +-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+ | enterprise-number | +-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+ . . . option-data . . . +-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+

Definition at line 540 of file encode.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_encode_proto()

static ssize_t fr_dhcpv6_encode_proto ( UNUSED TALLOC_CTX *  ctx,
fr_pair_list_t vps,
uint8_t data,
size_t  data_len,
UNUSED void *  proto_ctx 
)
static

Definition at line 757 of file encode.c.

+ Here is the call graph for this function:

Variable Documentation

◆ dhcpv6_tp_encode_pair

fr_test_point_pair_encode_t dhcpv6_tp_encode_pair
Initial value:
= {
.test_ctx = encode_test_ctx,
.next_encodable = fr_dhcpv6_next_encodable,
}
void * fr_dhcpv6_next_encodable(fr_dlist_head_t *list, void *current, void *uctx)
DHCPV6-specific iterator.
Definition: base.c:701
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.
Definition: encode.c:670
static int encode_test_ctx(void **out, TALLOC_CTX *ctx)
Definition: encode.c:743

Definition at line 778 of file encode.c.

◆ dhcpv6_tp_encode_proto

fr_test_point_proto_encode_t dhcpv6_tp_encode_proto
Initial value:
= {
.test_ctx = encode_test_ctx,
}
static ssize_t fr_dhcpv6_encode_proto(UNUSED TALLOC_CTX *ctx, fr_pair_list_t *vps, uint8_t *data, size_t data_len, UNUSED void *proto_ctx)
Definition: encode.c:757

Definition at line 785 of file encode.c.