]> git.ipfire.org Git - thirdparty/freeradius-server.git/commitdiff
these encode/decode funcs are only used for test points
authorAlan T. DeKok <aland@freeradius.org>
Tue, 8 Jun 2021 18:55:35 +0000 (14:55 -0400)
committerAlan T. DeKok <aland@freeradius.org>
Tue, 8 Jun 2021 19:07:21 +0000 (15:07 -0400)
we'll gradually move everything to a new API

src/lib/io/pair.h
src/lib/io/test_point.h
src/protocols/radius/decode.c

index 7a78f2342c5c8a70de55cab417cd9274fe28f7b6..00d1c50b5054184e05242a13064ff81a9db34234 100644 (file)
@@ -86,49 +86,3 @@ static inline bool fr_pair_encode_is_error(ssize_t slen)
 #define FR_PAIR_ENCODE_HAVE_SPACE(_p, _end, _num) if (((_p) + (_num)) > (_end)) return (_end) - ((_p) + (_num));
 
 /** @} */
-
-/** Generic interface for encoding one or more fr_pair_ts
- *
- * An encoding function should consume at most, one top level fr_pair_t and encode
- * it in the appropriate wire format for the protocol, writing the encoded data to
- * out, and returning the encoded length.
- *
- * The exception to processing one fr_pair_t is if multiple fr_pair_ts can be aggregated
- * into a single TLV, in which case the encoder may consume as many fr_pair_ts as will
- * fit into that TLV.
- *
- * Outlen provides the length of the buffer to write the encoded data to.  The return
- * value must not be greater than outlen.
- *
- * The cursor is used to track how many pairs there are remaining.
- *
- * @param[out] out             Where to write the encoded data.
- * @param[in] cursor           Cursor containing the list of attributes to process.
- * @param[in] encode_ctx       Any encoder specific data such as secrets or configurables.
- * @return
- *     - PAIR_ENCODE_SKIPPED - The current pair is not valid for encoding and should be skipped.
- *     - PAIR_ENCODE_FATAL_ERROR - Encoding failed in a fatal way. Encoding the packet should be
- *       aborted in its entirety.
- *     - <0 - The encoder ran out of space and returned the number of bytes as a negative
- *       integer that would be required to encode the attribute.
- *     - >0 - The number of bytes written to out.
- */
-typedef ssize_t (*fr_pair_encode_t)(fr_dbuff_t *out, fr_dcursor_t *cursor, void *encode_ctx);
-
-/** A generic interface for decoding fr_pair_ts
- *
- * A decoding function should decode a single top level fr_pair_t from wire format.
- * If this top level fr_pair_t is a TLV, multiple child attributes may also be decoded.
- *
- * @param[in] ctx              to allocate new pairs in.
- * @param[in] cursor           to insert new pairs into.
- * @param[in] dict             to use to lookup attributes.
- * @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.
- * @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_dcursor_t *cursor, fr_dict_t const *dict,
-                                   uint8_t const *data, size_t data_len, void *decode_ctx);
index e58105972adf3d1b2988106f77f460b5c514ec0d..e0ea033df29ba76d242a002793ad71fa6b9b6d6d 100644 (file)
@@ -59,6 +59,52 @@ typedef ssize_t (*fr_tp_proto_decode_t)(TALLOC_CTX *ctx, fr_pair_list_t *list,
 typedef ssize_t (*fr_tp_proto_encode_t)(TALLOC_CTX *ctx, fr_pair_list_t *vps,
                                        uint8_t *data, size_t data_len, void *encode_ctx);
 
+/** Generic interface for encoding one or more fr_pair_ts
+ *
+ * An encoding function should consume at most, one top level fr_pair_t and encode
+ * it in the appropriate wire format for the protocol, writing the encoded data to
+ * out, and returning the encoded length.
+ *
+ * The exception to processing one fr_pair_t is if multiple fr_pair_ts can be aggregated
+ * into a single TLV, in which case the encoder may consume as many fr_pair_ts as will
+ * fit into that TLV.
+ *
+ * Outlen provides the length of the buffer to write the encoded data to.  The return
+ * value must not be greater than outlen.
+ *
+ * The cursor is used to track how many pairs there are remaining.
+ *
+ * @param[out] out             Where to write the encoded data.
+ * @param[in] cursor           Cursor containing the list of attributes to process.
+ * @param[in] encode_ctx       Any encoder specific data such as secrets or configurables.
+ * @return
+ *     - PAIR_ENCODE_SKIPPED - The current pair is not valid for encoding and should be skipped.
+ *     - PAIR_ENCODE_FATAL_ERROR - Encoding failed in a fatal way. Encoding the packet should be
+ *       aborted in its entirety.
+ *     - <0 - The encoder ran out of space and returned the number of bytes as a negative
+ *       integer that would be required to encode the attribute.
+ *     - >0 - The number of bytes written to out.
+ */
+typedef ssize_t (*fr_tp_pair_encode_t)(fr_dbuff_t *out, fr_dcursor_t *cursor, void *encode_ctx);
+
+/** A generic interface for decoding fr_pair_ts
+ *
+ * A decoding function should decode a single top level fr_pair_t from wire format.
+ * If this top level fr_pair_t is a TLV, multiple child attributes may also be decoded.
+ *
+ * @param[in] ctx              to allocate new pairs in.
+ * @param[in] cursor           to insert new pairs into.
+ * @param[in] dict             to use to lookup attributes.
+ * @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.
+ * @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_tp_pair_decode_t)(TALLOC_CTX *ctx, fr_dcursor_t *cursor, fr_dict_t const *dict,
+                                      uint8_t const *data, size_t data_len, void *decode_ctx);
+
 /** Entry point for protocol decoders
  *
  */
@@ -82,7 +128,7 @@ typedef struct {
  */
 typedef struct {
        fr_test_point_ctx_alloc_t       test_ctx;       //!< Allocate a test ctx for the encoder.
-       fr_pair_decode_t                func;           //!< Decoder for pairs.
+       fr_tp_pair_decode_t             func;           //!< Decoder for pairs.
 } fr_test_point_pair_decode_t;
 
 /** Entry point for pair encoders
@@ -90,7 +136,7 @@ typedef struct {
  */
 typedef struct {
        fr_test_point_ctx_alloc_t       test_ctx;       //!< Allocate a test ctx for the encoder.
-       fr_pair_encode_t                func;           //!< Encoder for pairs.
+       fr_tp_pair_encode_t             func;           //!< Encoder for pairs.
        fr_dcursor_iter_t               next_encodable; //!< Iterator to use to select attributes
                                                        ///< to encode.
        fr_dcursor_eval_t               eval;           //!< Evaluation function to filter
index d6976a0dd7c3ec74306cb8b0f0cacbe5eced9d53..6fb3d0afb2b8ad6ba5c00621226ba884e1b26dca 100644 (file)
@@ -1869,7 +1869,7 @@ static ssize_t fr_radius_decode_proto(TALLOC_CTX *ctx, fr_pair_list_t *list, uin
 extern fr_test_point_pair_decode_t radius_tp_decode_pair;
 fr_test_point_pair_decode_t radius_tp_decode_pair = {
        .test_ctx       = decode_test_ctx,
-       .func           = (fr_pair_decode_t) fr_radius_decode_pair
+       .func           = (fr_tp_pair_decode_t) fr_radius_decode_pair
 };
 
 extern fr_test_point_proto_decode_t radius_tp_decode_proto;