25 RCSID(
"$Id: debfba70d724937aadc27efb3cee01d330223bfc $")
27 #include <freeradius-devel/util/struct.h>
28 #include <freeradius-devel/io/test_point.h>
29 #include <freeradius-devel/internal/internal.h>
54 vp->vp_tainted =
true;
65 uint8_t const *packet,
size_t packet_len,
70 bfd_packet_t
const *bfd;
76 bfd = (bfd_packet_t
const *) packet;
80 if (slen < 0)
return slen;
82 if (bfd->length == packet_len)
return packet_len;
88 if (!
vp)
return packet_len;
107 test_ctx->
secret = talloc_strdup(test_ctx,
"testing123");
116 uint8_t const *
data,
size_t data_len,
void *proto_ctx)
119 bfd_packet_t
const *packet;
127 packet = (bfd_packet_t
const *)
data;
129 if (packet->length > data_len) {
139 if (packet->version != 1) {
144 if (packet->detect_multi == 0) {
149 if (packet->detect_multi == 0) {
154 if (packet->multipoint != 0) {
159 if (packet->my_disc == 0) {
164 if ((packet->your_disc == 0) &&
180 vp->vp_uint32 = packet->state;
197 test_ctx->
secret, talloc_array_length(test_ctx->
secret) - 1);
TALLOC_CTX * tmp_ctx
for temporary things cleaned up during decoding
#define FR_BFD_HEADER_LENGTH
char const * secret
shared secret. MUST be talloc'd
#define fr_dbuff_init(_out, _start, _len_or_end)
Initialise an dbuff for encoding or decoding.
#define FR_DBUFF_TMP(_start, _len_or_end)
Creates a compound literal to pass into functions which accept a dbuff.
static fr_dict_attr_t const * attr_packet_type
fr_dict_attr_t const * fr_dict_root(fr_dict_t const *dict)
Return the root attribute of a dictionary.
#define PAIR_DECODE_OOM
Fatal error - Out of memory.
fr_pair_t * fr_pair_afrom_da(TALLOC_CTX *ctx, fr_dict_attr_t const *da)
Dynamically allocate a new attribute and assign a fr_dict_attr_t.
int fr_pair_append(fr_pair_list_t *list, fr_pair_t *to_add)
Add a VP to the end of the list.
static fr_dict_attr_t const * attr_bfd_packet
static fr_dict_t const * dict_bfd
HIDDEN fr_dict_attr_t const * attr_bfd_additional_data
ssize_t fr_bfd_decode(TALLOC_CTX *ctx, fr_pair_list_t *out, uint8_t const *packet, size_t packet_len, char const *secret, UNUSED size_t secret_len)
Decode a raw BFD packet into VPs.
static int decode_test_ctx(void **out, TALLOC_CTX *ctx)
static ssize_t fr_bfd_decode_proto(TALLOC_CTX *ctx, fr_pair_list_t *out, uint8_t const *data, size_t data_len, void *proto_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 const data_len, UNUSED void *decode_ctx)
fr_test_point_proto_decode_t bfd_tp_decode_proto
ssize_t fr_internal_decode_list_dbuff(TALLOC_CTX *ctx, fr_pair_list_t *out, fr_dict_attr_t const *parent, fr_dbuff_t *dbuff, void *decode_ctx)
Retrieve all pairs from the dbuff.
ssize_t fr_struct_from_network(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, fr_pair_decode_value_t decode_value, fr_pair_decode_value_t decode_tlv)
Convert a STRUCT to one or more VPs.
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 decoders.
size_t fr_pair_list_num_elements(fr_pair_list_t const *list)
Get the length of a list of fr_pair_t.
#define FR_PROTO_HEX_DUMP(_data, _data_len, _fmt,...)
#define fr_strerror_const(_msg)
ssize_t fr_value_box_from_network(TALLOC_CTX *ctx, fr_value_box_t *dst, fr_type_t type, fr_dict_attr_t const *enumv, fr_dbuff_t *dbuff, size_t len, bool tainted)
Decode a fr_value_box_t from serialized binary data.
static size_t char ** out