* point to produce fr_pair_ts.
*/
while (to_dec < to_dec_end) {
- slen = tp->func(cc->tmp_ctx, &head, cc->tmpl_rules.dict_def ? cc->tmpl_rules.dict_def : cc->config->dict,
+ slen = tp->func(cc->tmp_ctx, &head, fr_dict_root(cc->tmpl_rules.dict_def ? cc->tmpl_rules.dict_def : cc->config->dict),
(uint8_t *)to_dec, (to_dec_end - to_dec), decode_ctx);
cc->last_ret = slen;
if (slen <= 0) {
/*
* decode.c
*/
-ssize_t fr_aka_sim_decode_pair(TALLOC_CTX *ctx, fr_pair_list_t *out, fr_dict_t const *dict,
+ssize_t fr_aka_sim_decode_pair(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);
int fr_aka_sim_decode(TALLOC_CTX *ctx, fr_pair_list_t *out, fr_dict_t const *dict,
*
* @param[in] ctx to allocate attributes in.
* @param[in] out where to insert the attributes.
- * @param[in] dict for looking up attributes.
+ * @param[in] parent for looking up attributes.
* @param[in] data data to parse.
* @param[in] data_len length of data. For top level attributes packet_ctx must be the length
* of the packet (so we can hunt for AT_IV), for Sub-TLVs it should
* - The number of bytes parsed.
* - -1 on error.
*/
-ssize_t fr_aka_sim_decode_pair(TALLOC_CTX *ctx, fr_pair_list_t *out, fr_dict_t const *dict,
- uint8_t const *data, size_t data_len, void *decode_ctx)
+ssize_t fr_aka_sim_decode_pair(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)
{
- return sim_decode_pair_internal(ctx, out, fr_dict_root(dict), data, data_len, decode_ctx);
+ return sim_decode_pair_internal(ctx, out, parent, data, data_len, decode_ctx);
}
/** Decode SIM/AKA/AKA' specific packet data
ssize_t ret;
uint8_t const *p = data;
uint8_t const *end = p + data_len;
+ fr_dict_attr_t const *parent;
/*
* We need at least enough data for the subtype
return -1;
}
p += 3;
+ parent = fr_dict_root(dict);
/*
* Loop over all the attributes decoding
* in the SIM/AKA/AKA' dict.
*/
while (p < end) {
- ret = fr_aka_sim_decode_pair(ctx, out, dict, p, end - p, decode_ctx);
+ ret = fr_aka_sim_decode_pair(ctx, out, parent, p, end - p, decode_ctx);
if (ret <= 0) {
fr_strerror_const_push("Failed decoding AT");
error:
{
fr_pair_t *vp;
- vp = fr_pair_afrom_child_num(ctx, fr_dict_root(dict), FR_SUBTYPE);
+ vp = fr_pair_afrom_child_num(ctx, parent, FR_SUBTYPE);
if (!vp) {
fr_strerror_const("Failed allocating subtype attribute");
goto error;
*
* @param[in] ctx to allocate new pairs in.
* @param[in] out to insert new pairs into.
- * @param[in] dict to use to lookup attributes.
+ * @param[in] parent to use for decoding
* @param[in] data to decode.
* @param[in] data_len The length of the incoming data.
- * @param[in] decode_ctx Any decode specific data such as secrets or configurable.
+ * @param[in] decode_ctx Any decode specific data such as secrets or temporary allocation contexts
* @return
* - <= 0 on error. May be the offset (as a negative value) where the error occurred.
* - > 0 on success. How many bytes were decoded.
*/
-typedef ssize_t (*fr_pair_decode_t)(TALLOC_CTX *ctx, fr_pair_list_t *out, fr_dict_t const *dict,
+typedef ssize_t (*fr_pair_decode_t)(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);
int fr_pair_decode_value_box_list(TALLOC_CTX *ctx, fr_pair_list_t *out,
*/
while (fr_dbuff_remaining(&dbuff) > 0) {
if (fr_internal_decode_pair_dbuff(request->session_state_ctx, &tmp,
- request->dict, &dbuff, NULL) < 0) {
+ fr_dict_root(request->dict), &dbuff, NULL) < 0) {
fr_pair_list_free(&tmp);
RPEDEBUG("Failed decoding session-state");
return -1;
*
* @param[in] ctx to allocate new pairs in.
* @param[in] out the cursor to update
- * @param[in] dict to use to lookup attributes.
+ * @param[in] parent to use as the root
* @param[in] data to decode.
* @param[in] data_len The length of the incoming data.
* @param[in] decode_ctx Any decode specific data such as secrets or configurable.
* - <= 0 on error. May be the offset (as a negative value) where the error occurred.
* - > 0 on success. How many bytes were decoded.
*/
-static ssize_t fr_pair_decode_multi(TALLOC_CTX *ctx, fr_pair_list_t *out, fr_dict_t const *dict,
+static ssize_t fr_pair_decode_multi(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_t decode)
{
uint8_t const *p, *end;
while (p < end) {
ssize_t len;
- len = decode(ctx, &tmp, dict, p, end - p, decode_ctx);
+ len = decode(ctx, &tmp, parent, p, end - p, decode_ctx);
if (len <= 0) {
fr_pair_list_free(&tmp);
return len - (p - data);
int decoded = 0;
fr_value_box_t *vb = NULL;
fr_pair_t *vp = NULL;
+ fr_dict_attr_t const *parent = fr_dict_root(request->dict);
fr_pair_list_t head;
fr_pair_list_init(&head);
continue;
}
- len = fr_pair_decode_multi(ctx, &head, request->dict,
+ len = fr_pair_decode_multi(ctx, &head, parent,
vb->vb_octets, vb->vb_length, decode_ctx, decode);
if (len <= 0) {
fr_pair_list_free(&head);
}
if (RDEBUG_ENABLED2) {
- char const *name = fr_dict_root(request->dict)->name;
+ char const *name = parent->name;
while ((vp = fr_pair_list_next(&head, vp))) {
RDEBUG2("decode %s: &%pP", name, vp);
return data_len;
}
-static ssize_t decode_option(TALLOC_CTX *ctx, fr_pair_list_t *out, NDEBUG_UNUSED fr_dict_t const *dict,
+static ssize_t decode_option(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)
{
- fr_assert(dict == dict_dhcpv4);
+ fr_assert(parent == fr_dict_root(dict_dhcpv4));
return fr_dhcpv4_decode_option(ctx, out, data, data_len, decode_ctx);
}
}
-static ssize_t decode_pair(TALLOC_CTX *ctx, fr_pair_list_t *out, NDEBUG_UNUSED fr_dict_t const *dict,
+static ssize_t decode_pair(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)
{
- fr_assert(dict == dict_dhcpv6);
+ fr_assert(parent == fr_dict_root(dict_dhcpv6));
return decode_option(ctx, out, fr_dict_root(dict_dhcpv6), data, data_len, decode_ctx);
}
*
* @param[in] ctx context to alloc new attributes in.
* @param[in,out] out Where to write the decoded options.
- * @param[in] dict to lookup attributes in.
+ * @param[in] parent to lookup attributes in.
* @param[in] data to parse.
* @param[in] data_len of data to parse.
* @param[in] decode_ctx Unused.
*/
-static ssize_t decode_rr(TALLOC_CTX *ctx, fr_pair_list_t *out,
- UNUSED fr_dict_t const *dict, uint8_t const *data, size_t data_len, void *decode_ctx)
+static ssize_t decode_rr(TALLOC_CTX *ctx, fr_pair_list_t *out, UNUSED fr_dict_attr_t const *parent,
+ uint8_t const *data, size_t data_len, void *decode_ctx)
{
ssize_t slen;
fr_dns_ctx_t *packet_ctx = (fr_dns_ctx_t *) decode_ctx;
/** Create a single fr_pair_t and all its nesting
*
*/
-ssize_t fr_internal_decode_pair(TALLOC_CTX *ctx, fr_pair_list_t *list, fr_dict_t const *dict,
+ssize_t fr_internal_decode_pair(TALLOC_CTX *ctx, fr_pair_list_t *list, fr_dict_attr_t const *parent,
uint8_t const *data, size_t data_len, void *decode_ctx)
{
- return fr_internal_decode_pair_dbuff(ctx, list, dict, &FR_DBUFF_TMP(data, data_len), decode_ctx);
+ return fr_internal_decode_pair_dbuff(ctx, list, parent, &FR_DBUFF_TMP(data, data_len), decode_ctx);
}
-ssize_t fr_internal_decode_pair_dbuff(TALLOC_CTX *ctx, fr_pair_list_t *out, fr_dict_t const *dict,
+ssize_t fr_internal_decode_pair_dbuff(TALLOC_CTX *ctx, fr_pair_list_t *out, fr_dict_attr_t const *parent,
fr_dbuff_t *dbuff, void *decode_ctx)
{
fr_pair_list_t tmp;
fr_pair_list_init(&tmp);
- slen = internal_decode_pair(ctx, &tmp, fr_dict_root(dict), &work_dbuff, decode_ctx);
+ slen = internal_decode_pair(ctx, &tmp, parent, &work_dbuff, decode_ctx);
if (slen <= 0) {
fr_pair_list_free(&tmp);
return slen;
ssize_t fr_internal_encode_pair(fr_dbuff_t *dbuff, fr_dcursor_t *cursor, void *encode_ctx);
-ssize_t fr_internal_decode_pair(TALLOC_CTX *ctx, fr_pair_list_t *out, fr_dict_t const *dict,
+ssize_t fr_internal_decode_pair(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);
-ssize_t fr_internal_decode_pair_dbuff(TALLOC_CTX *ctx, fr_pair_list_t *out, fr_dict_t const *dict,
+ssize_t fr_internal_decode_pair_dbuff(TALLOC_CTX *ctx, fr_pair_list_t *out, fr_dict_attr_t const *parent,
fr_dbuff_t *dbuff, void *decode_ctx);
test_ctx->secret, talloc_array_length(test_ctx->secret) - 1);
}
-static ssize_t decode_pair(TALLOC_CTX *ctx, fr_pair_list_t *out, NDEBUG_UNUSED fr_dict_t const *dict,
+static ssize_t decode_pair(TALLOC_CTX *ctx, fr_pair_list_t *out, NDEBUG_UNUSED fr_dict_attr_t const *parent,
uint8_t const *data, size_t data_len, fr_radius_ctx_t *packet_ctx)
{
- fr_assert(dict == dict_radius);
+ fr_assert(parent == fr_dict_root(dict_radius));
return fr_radius_decode_pair(ctx, out, data, data_len, packet_ctx);
}