fr_pair_list_init(&vps);
if (!init) LLVMFuzzerInitialize(NULL, NULL);
- if (tp->test_ctx && (tp->test_ctx(&decode_ctx, NULL) < 0)) {
+ if (tp->test_ctx && (tp->test_ctx(&decode_ctx, NULL, dict) < 0)) {
fr_perror("fuzzer: Failed initializing test point decode_ctx");
fr_exit_now(EXIT_FAILURE);
}
p += slen;
fr_skip_whitespace(p);
- if (tp->test_ctx && (tp->test_ctx(&decode_ctx, cc->tmp_ctx) < 0)) {
+ if (tp->test_ctx && (tp->test_ctx(&decode_ctx, cc->tmp_ctx, dictionary_current(cc)) < 0)) {
fr_strerror_const_push("Failed initialising decoder testpoint");
RETURN_COMMAND_ERROR();
}
p += slen;
fr_skip_whitespace(p);
- if (tp->test_ctx && (tp->test_ctx(&decode_ctx, cc->tmp_ctx) < 0)) {
+ if (tp->test_ctx && (tp->test_ctx(&decode_ctx, cc->tmp_ctx, dictionary_current(cc)) < 0)) {
fr_strerror_const_push("Failed initialising decoder testpoint");
RETURN_COMMAND_ERROR();
}
fr_skip_whitespace(p);
}
- if (tp->test_ctx && (tp->test_ctx(&encode_ctx, cc->tmp_ctx) < 0)) {
+ if (tp->test_ctx && (tp->test_ctx(&encode_ctx, cc->tmp_ctx, dictionary_current(cc)) < 0)) {
fr_strerror_const_push("Failed initialising encoder testpoint");
CLEAR_TEST_POINT(cc);
RETURN_COMMAND_ERROR();
p += ((size_t)slen);
fr_skip_whitespace(p);
- if (tp->test_ctx && (tp->test_ctx(&encode_ctx, cc->tmp_ctx) < 0)) {
+ if (tp->test_ctx && (tp->test_ctx(&encode_ctx, cc->tmp_ctx, dictionary_current(cc)) < 0)) {
fr_strerror_const_push("Failed initialising encoder testpoint");
CLEAR_TEST_POINT(cc);
RETURN_COMMAND_ERROR();
/*
* Test ctx data
*/
-static int decode_test_ctx_sim(void **out, TALLOC_CTX *ctx)
+static int decode_test_ctx_sim(void **out, TALLOC_CTX *ctx, UNUSED fr_dict_t const *dict)
{
fr_aka_sim_ctx_t *test_ctx;
static uint8_t k_encr[] = { 0x00, 0x01, 0x02, 0x03, 0x04 ,0x05, 0x06, 0x07,
}
-static int decode_test_ctx_aka(void **out, TALLOC_CTX *ctx)
+static int decode_test_ctx_aka(void **out, TALLOC_CTX *ctx, UNUSED fr_dict_t const *dict)
{
fr_aka_sim_ctx_t *test_ctx;
static uint8_t k_encr[] = { 0x00, 0x01, 0x02, 0x03, 0x04 ,0x05, 0x06, 0x07,
return 0;
}
-static int decode_test_ctx_sim_rfc4186(void **out, TALLOC_CTX *ctx)
+static int decode_test_ctx_sim_rfc4186(void **out, TALLOC_CTX *ctx, UNUSED fr_dict_t const *dict)
{
fr_aka_sim_ctx_t *test_ctx;
static uint8_t k_encr[] = { 0x53, 0x6e, 0x5e, 0xbc, 0x44 ,0x65, 0x58, 0x2a,
/*
* Test ctx data
*/
-static int encode_test_ctx_sim(void **out, TALLOC_CTX *ctx)
+static int encode_test_ctx_sim(void **out, TALLOC_CTX *ctx, UNUSED fr_dict_t const *dict)
{
fr_aka_sim_ctx_t *test_ctx;
static uint8_t k_encr[] = { 0x00, 0x01, 0x02, 0x03, 0x04 ,0x05, 0x06, 0x07,
return 0;
}
-static int encode_test_ctx_aka(void **out, TALLOC_CTX *ctx)
+static int encode_test_ctx_aka(void **out, TALLOC_CTX *ctx, UNUSED fr_dict_t const *dict)
{
fr_aka_sim_ctx_t *test_ctx;
static uint8_t k_encr[] = { 0x00, 0x01, 0x02, 0x03, 0x04 ,0x05, 0x06, 0x07,
return 0;
}
-static int encode_test_ctx_sim_rfc4186(void **out, TALLOC_CTX *ctx)
+static int encode_test_ctx_sim_rfc4186(void **out, TALLOC_CTX *ctx, UNUSED fr_dict_t const *dict)
{
fr_aka_sim_ctx_t *test_ctx;
static uint8_t k_encr[] = { 0x53, 0x6e, 0x5e, 0xbc, 0x44 ,0x65, 0x58, 0x2a,
*
* @param[out] out Where the decoder context should be written.
* @param[in] ctx to allocate the test point context in.
+ * @param[in] dict the default dictionary context for the test point
* @return proto or pair encoder or decoder ctx.
*/
-typedef int (*fr_test_point_ctx_alloc_t)(void **out, TALLOC_CTX *ctx);
+typedef int (*fr_test_point_ctx_alloc_t)(void **out, TALLOC_CTX *ctx, fr_dict_t const *dict);
/** A generic interface for decoding packets to fr_pair_ts
*
fr_test_point_pair_decode_t const *tp_decode = *(void * const *)xctx->inst;
if (tp_decode->test_ctx) {
- if (tp_decode->test_ctx(&decode_ctx, ctx) < 0) {
+ if (tp_decode->test_ctx(&decode_ctx, ctx, request->dict) < 0) {
return XLAT_ACTION_FAIL;
}
}
* Create the encoding context.
*/
if (tp_encode->test_ctx) {
- if (tp_encode->test_ctx(&encode_ctx, vpt) < 0) {
+ if (tp_encode->test_ctx(&encode_ctx, vpt, request->dict) < 0) {
talloc_free(vpt);
return XLAT_ACTION_FAIL;
}
#include <freeradius-devel/io/test_point.h>
-static int decode_test_ctx(void **out, UNUSED TALLOC_CTX *ctx)
+static int decode_test_ctx(void **out, UNUSED TALLOC_CTX *ctx, UNUSED fr_dict_t const *dict)
{
*out = NULL;
return 0;
bool tmp;
} fr_arp_ctx_t;
-static int encode_test_ctx(void **out, TALLOC_CTX *ctx)
+static int encode_test_ctx(void **out, TALLOC_CTX *ctx, UNUSED fr_dict_t const *dict)
{
fr_arp_ctx_t *test_ctx;
return slen;
}
-static int decode_test_ctx(void **out, TALLOC_CTX *ctx)
+static int decode_test_ctx(void **out, TALLOC_CTX *ctx, UNUSED fr_dict_t const *dict)
{
fr_bfd_ctx_t *test_ctx;
}
-static int encode_test_ctx(void **out, TALLOC_CTX *ctx)
+static int encode_test_ctx(void **out, TALLOC_CTX *ctx, UNUSED fr_dict_t const *dict)
{
fr_bfd_ctx_t *test_ctx;
fr_test_point_pair_decode_t cbor_tp_decode_pair = {
.func = decode_pair
};
+
+static int decode_test_ctx(void **out, UNUSED TALLOC_CTX *ctx, fr_dict_t const *dict)
+{
+ *out = UNCONST(fr_dict_t *, dict);
+
+ return 0;
+}
+
+static ssize_t encode_proto(UNUSED TALLOC_CTX *ctx, fr_pair_list_t *vps, uint8_t *data, size_t data_len, UNUSED void *proto_ctx)
+{
+ fr_dbuff_t dbuff;
+ fr_dcursor_t cursor;
+
+ FR_DBUFF_INIT(&dbuff, data, data_len);
+
+ fr_pair_dcursor_init(&cursor, vps);
+ return encode_pair(&dbuff, &cursor, NULL);
+}
+
+static ssize_t decode_proto(TALLOC_CTX *ctx, fr_pair_list_t *out, uint8_t const *data, size_t data_len, void *proto_ctx)
+{
+ fr_dict_t *dict = proto_ctx;
+
+ return decode_pair(ctx, out, fr_dict_root(dict), data, data_len, proto_ctx);
+}
+
+extern fr_test_point_proto_encode_t cbor_tp_encode_proto;
+fr_test_point_proto_encode_t cbor_tp_encode_proto = {
+ .func = encode_proto
+};
+
+extern fr_test_point_proto_decode_t cbor_tp_decode_proto;
+fr_test_point_proto_decode_t cbor_tp_decode_proto = {
+ .test_ctx = decode_test_ctx,
+ .func = decode_proto
+};
}
-static int decode_test_ctx(void **out, TALLOC_CTX *ctx)
+static int decode_test_ctx(void **out, TALLOC_CTX *ctx, UNUSED fr_dict_t const *dict)
{
fr_dhcpv4_ctx_t *test_ctx;
return fr_dhcpv4_encode_dbuff(&FR_DBUFF_TMP(data, data_len), NULL, 0, 0, vps);
}
-static int encode_test_ctx(void **out, TALLOC_CTX *ctx)
+static int encode_test_ctx(void **out, TALLOC_CTX *ctx, UNUSED fr_dict_t const *dict)
{
fr_dhcpv4_ctx_t *test_ctx;
return data_len;
}
-static int decode_test_ctx(void **out, TALLOC_CTX *ctx)
+static int decode_test_ctx(void **out, TALLOC_CTX *ctx, UNUSED fr_dict_t const *dict)
{
fr_dhcpv6_decode_ctx_t *test_ctx;
}
-static int encode_test_ctx(void **out, TALLOC_CTX *ctx)
+static int encode_test_ctx(void **out, TALLOC_CTX *ctx, UNUSED fr_dict_t const *dict)
{
fr_dhcpv6_encode_ctx_t *test_ctx;
/*
* Test points
*/
-static int decode_test_ctx(void **out, TALLOC_CTX *ctx)
+static int decode_test_ctx(void **out, TALLOC_CTX *ctx, UNUSED fr_dict_t const *dict)
{
fr_dns_ctx_t *test_ctx;
return fr_dbuff_set(dbuff, &work_dbuff);
}
-static int encode_test_ctx(void **out, TALLOC_CTX *ctx)
+static int encode_test_ctx(void **out, TALLOC_CTX *ctx, UNUSED fr_dict_t const *dict)
{
fr_dns_ctx_t *test_ctx;
return 0;
}
-static int decode_test_ctx(void **out, TALLOC_CTX *ctx)
+static int decode_test_ctx(void **out, TALLOC_CTX *ctx, UNUSED fr_dict_t const *dict)
{
static uint8_t vector[RADIUS_AUTH_VECTOR_LENGTH] = {
0x00, 0x01, 0x02, 0x03, 0x04, 0x05, 0x06, 0x07,
}
-static int encode_test_ctx(void **out, TALLOC_CTX *ctx)
+static int encode_test_ctx(void **out, TALLOC_CTX *ctx, UNUSED fr_dict_t const *dict)
{
static uint8_t vector[RADIUS_AUTH_VECTOR_LENGTH] = {
0x00, 0x01, 0x02, 0x03, 0x04, 0x05, 0x06, 0x07,
return 0;
}
-static int decode_test_ctx(void **out, TALLOC_CTX *ctx)
+static int decode_test_ctx(void **out, TALLOC_CTX *ctx, UNUSED fr_dict_t const *dict)
{
fr_tacacs_ctx_t *test_ctx;
return 0;
}
-static int encode_test_ctx(void **out, TALLOC_CTX *ctx)
+static int encode_test_ctx(void **out, TALLOC_CTX *ctx, UNUSED fr_dict_t const *dict)
{
fr_tacacs_ctx_t *test_ctx;
return 0;
}
-static int decode_test_ctx(void **out, TALLOC_CTX *ctx)
+static int decode_test_ctx(void **out, TALLOC_CTX *ctx, UNUSED fr_dict_t const *dict)
{
fr_tftp_ctx_t *test_ctx;
return 0;
}
-static int encode_test_ctx(void **out, TALLOC_CTX *ctx)
+static int encode_test_ctx(void **out, TALLOC_CTX *ctx, UNUSED fr_dict_t const *dict)
{
fr_tftp_ctx_t *test_ctx;
return 0;
}
-static int decode_test_ctx(void **out, TALLOC_CTX *ctx)
+static int decode_test_ctx(void **out, TALLOC_CTX *ctx, UNUSED fr_dict_t const *dict)
{
fr_vmps_ctx_t *test_ctx;
return 0;
}
-static int encode_test_ctx(void **out, TALLOC_CTX *ctx)
+static int encode_test_ctx(void **out, TALLOC_CTX *ctx, UNUSED fr_dict_t const *dict)
{
fr_vmps_ctx_t *test_ctx;