/** Decode an array of values from the network
*
* @param[in] ctx context to alloc new attributes in.
- * @param[out] out Where to write the decoded options.
+ * @param[out] out Where to write the decoded #fr_pair_t
* @param[in] parent dictionary entry, must have parent->flags.array set
* @param[in] data to parse.
* @param[in] data_len of data to parse.
return data_len;
}
+
+/** Create a "raw" pair from the network data
+ *
+ * @param[in] ctx context to alloc new attributes in.
+ * @param[in] parent dictionary entry
+ * @param[in] data to parse.
+ * @param[in] data_len of data to parse.
+ */
+fr_pair_t *fr_pair_raw_from_network(TALLOC_CTX *ctx, fr_dict_attr_t const *parent, uint8_t const *data, size_t data_len)
+{
+ fr_pair_t *vp;
+ fr_dict_attr_t *unknown;
+ fr_dict_attr_t const *child;
+
+#if defined(__clang_analyzer__) || !defined(NDEBUG)
+ if (!parent->parent) return NULL; /* stupid static analyzers */
+#endif
+
+ /*
+ * Build an unknown attr of the entire data.
+ */
+ unknown = fr_dict_unknown_attr_afrom_da(ctx, parent);
+ if (!unknown) return NULL;
+ unknown->flags.is_raw = 1;
+
+ vp = fr_pair_afrom_da(ctx, unknown); /* makes a copy of 'child' */
+ child = unknown;
+ fr_dict_unknown_free(&child);
+ if (!vp) return NULL;
+
+ if (fr_value_box_from_network(vp, &vp->data, vp->da->type, vp->da,
+ &FR_DBUFF_TMP(data, data_len), data_len, true) < 0) {
+ talloc_free(vp);
+ return NULL;
+ }
+
+ return vp;
+}
uint8_t const *data, size_t const data_len, fr_proto_decode_ctx_t *decode_ctx); \
ssize_t fr_pair_array_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);
+ uint8_t const *data, size_t data_len, void *decode_ctx, fr_pair_decode_value_t decode_value) CC_HINT(nonnull(1,2,3,4,6));
+
+fr_pair_t *fr_pair_raw_from_network(TALLOC_CTX *ctx, fr_dict_attr_t const *parent,
+ uint8_t const *data, size_t data_len) CC_HINT(nonnull);
+
#ifdef __cplusplus
}
#include <freeradius-devel/util/struct.h>
-fr_pair_t *fr_raw_from_network(TALLOC_CTX *ctx, fr_dict_attr_t const *parent, uint8_t const *data, size_t data_len)
-{
- fr_pair_t *vp;
- fr_dict_attr_t *unknown;
- fr_dict_attr_t const *child;
-
-#if defined(__clang_analyzer__) || !defined(NDEBUG)
- if (!parent->parent) return NULL; /* stupid static analyzers */
-#endif
-
- /*
- * Build an unknown attr of the entire data.
- */
- unknown = fr_dict_unknown_attr_afrom_da(ctx, parent);
- if (!unknown) return NULL;
- unknown->flags.is_raw = 1;
-
- vp = fr_pair_afrom_da(ctx, unknown); /* makes a copy of 'child' */
- child = unknown;
- fr_dict_unknown_free(&child);
- if (!vp) return NULL;
-
- if (fr_value_box_from_network(vp, &vp->data, vp->da->type, vp->da,
- &FR_DBUFF_TMP(data, data_len), data_len, true) < 0) {
- talloc_free(vp);
- return NULL;
- }
-
- return vp;
-}
-
-
-
/** Convert a STRUCT to one or more VPs
*
*/
fr_pair_list_free(child_list);
}
- vp = fr_raw_from_network(ctx, parent, data, data_len);
+ vp = fr_pair_raw_from_network(ctx, parent, data, data_len);
if (!vp) goto oom;
/*
goto unknown;
}
- vp = fr_raw_from_network(child_ctx, child, p, end - p);
+ vp = fr_pair_raw_from_network(child_ctx, child, p, end - p);
if (!vp) {
FR_PROTO_TRACE("Failed creating raw VP from malformed or unknown substruct");
fr_dict_unknown_free(&child);
fr_dcursor_t *cursor, void *encode_ctx,
fr_encode_dbuff_t encode_value, fr_encode_dbuff_t encode_tlv) CC_HINT(nonnull(1,2,4));
-fr_pair_t *fr_raw_from_network(TALLOC_CTX *ctx, fr_dict_attr_t const *parent,
- uint8_t const *data, size_t data_len) CC_HINT(nonnull);
-
#ifdef __cplusplus
}
#endif
if (data_len < 3) {
fr_pair_t *vp;
- vp = fr_raw_from_network(ctx, parent, data, data_len);
+ vp = fr_pair_raw_from_network(ctx, parent, data, data_len);
if (!vp) return -1;
fr_pair_append(out, vp);
return data_len;
raw:
if (vp) talloc_free(vp);
- vp = fr_raw_from_network(ctx, parent, data, attr_len);
+ vp = fr_pair_raw_from_network(ctx, parent, data, attr_len);
if (!vp) return -1;
tag = 0;