25 RCSID(
"$Id: 6c8153134cf5e2601198614054bf338b729e2a93 $")
27 #include <freeradius-devel/util/dbuff.h>
28 #include <freeradius-devel/util/struct.h>
29 #include <freeradius-devel/io/test_point.h>
30 #include <freeradius-devel/internal/internal.h>
68 if (da_stack->
da[
depth + 1] != NULL) {
87 if (slen < 0)
return slen;
105 bfd_packet_t *packet;
121 if (slen < 0)
return slen;
136 packet = (bfd_packet_t *)
out;
138 if (!packet->auth_present) {
141 }
else if (!
secret || secret_len == 0) {
157 packet->length = slen;
170 if (!test_ctx)
return -1;
172 test_ctx->
secret = talloc_strdup(test_ctx,
"testing123");
191 if (slen <= 0)
return slen;
194 if (!
vp)
return slen;
198 if (alen <= 0)
return slen;
#define FR_BFD_HEADER_LENGTH
char const * secret
shared secret. MUST be talloc'd
#define fr_dbuff_used(_dbuff_or_marker)
Return the number of bytes remaining between the start of the dbuff or marker and the current positio...
#define fr_dbuff_init(_out, _start, _len_or_end)
Initialise an dbuff for encoding or decoding.
#define fr_dbuff_start(_dbuff_or_marker)
Return the 'start' position of a dbuff or marker.
#define FR_DBUFF(_dbuff_or_marker)
Create a new dbuff pointing to the same underlying buffer.
#define FR_DBUFF_TMP(_start, _len_or_end)
Creates a compound literal to pass into functions which accept a dbuff.
fr_dcursor_eval_t void const * uctx
static void * fr_dcursor_next(fr_dcursor_t *cursor)
Advanced the cursor to the next item.
static void * fr_dcursor_current(fr_dcursor_t *cursor)
Return the item the cursor current points to.
Head of a doubly linked list.
#define PAIR_ENCODE_FATAL_ERROR
Fatal encoding error.
@ FR_TYPE_STRUCT
like TLV, but without T or L, and fixed-width children
static uint8_t depth(fr_minmax_heap_index_t i)
fr_pair_t * fr_pair_find_by_da(fr_pair_list_t const *list, fr_pair_t const *prev, fr_dict_attr_t const *da)
Find the first pair with a matching da.
void fr_proto_da_stack_build(fr_da_stack_t *stack, fr_dict_attr_t const *da)
Build a complete DA stack from the da back to the root.
static fr_dict_attr_t const * attr_bfd_packet
static fr_internal_encode_ctx_t encode_ctx
HIDDEN fr_dict_attr_t const * attr_bfd_additional_data
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)
Encodes the data portion of an attribute.
fr_test_point_proto_encode_t bfd_tp_encode_proto
void * fr_bfd_next_encodable(fr_dlist_head_t *list, void *to_eval, void *uctx)
static int encode_test_ctx(void **out, TALLOC_CTX *ctx)
static ssize_t fr_bfd_encode_proto(UNUSED TALLOC_CTX *ctx, fr_pair_list_t *vps, uint8_t *data, size_t data_len, void *proto_ctx)
ssize_t fr_bfd_encode(uint8_t *out, size_t outlen, UNUSED uint8_t const *original, char const *secret, size_t secret_len, fr_pair_list_t *vps)
Encode VPS into a BFD packet.
ssize_t fr_internal_encode_list(fr_dbuff_t *dbuff, fr_pair_list_t const *list, void *encode_ctx)
Encode a list of pairs using the internal encoder.
ssize_t fr_struct_to_network(fr_dbuff_t *dbuff, fr_da_stack_t *da_stack, unsigned int depth, fr_dcursor_t *parent_cursor, void *encode_ctx, fr_encode_dbuff_t encode_value, fr_encode_dbuff_t encode_pair)
Stores an attribute, a value and various bits of other data.
fr_dict_attr_t const *_CONST da
Dictionary attribute defines the attribute number, vendor and type of the pair.
fr_test_point_ctx_alloc_t test_ctx
Allocate a test ctx for the encoder.
Entry point for protocol encoders.
#define fr_pair_dcursor_by_ancestor_init(_cursor, _list, _da)
Initialise a cursor that will return only attributes descended from the specified fr_dict_attr_t.
#define FR_PROTO_HEX_DUMP(_data, _data_len, _fmt,...)
#define FR_PROTO_STACK_PRINT(_stack, _depth)
fr_dict_attr_t const * da[FR_DICT_MAX_TLV_STACK+1]
The stack.
Structure for holding the stack of dictionary attributes being encoded.
#define fr_strerror_printf(_fmt,...)
Log to thread local error buffer.
#define fr_strerror_const(_msg)
static char const * fr_type_to_str(fr_type_t type)
Return a static string containing the type name.
#define fr_type_is_structural(_x)
return fr_dbuff_set(dbuff, &our_dbuff)
ssize_t fr_value_box_to_network(fr_dbuff_t *dbuff, fr_value_box_t const *value)
Encode a single value box, serializing its contents in generic network format.
static size_t char ** out