The FreeRADIUS server $Id: 15bac2a4c627c01d1aa2047687b3418955ac7f00 $
Loading...
Searching...
No Matches
test_point.h
Go to the documentation of this file.
1#pragma once
2/*
3 * This program is free software; you can redistribute it and/or modify
4 * it under the terms of the GNU General Public License as published by
5 * the Free Software Foundation; either version 2 of the License, or
6 * (at your option) any later version.
7 *
8 * This program is distributed in the hope that it will be useful,
9 * but WITHOUT ANY WARRANTY; without even the implied warranty of
10 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
11 * GNU General Public License for more details.
12 *
13 * You should have received a copy of the GNU General Public License
14 * along with this program; if not, write to the Free Software
15 * Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301, USA
16 */
17#include <freeradius-devel/util/dcursor.h>
18#include <freeradius-devel/util/pair.h>
19#include "proto.h"
20#include "pair.h"
21
22/** Allocate an encoder/decoder ctx
23 *
24 * @param[out] out Where the decoder context should be written.
25 * @param[in] ctx to allocate the test point context in.
26 * @param[in] dict the default dictionary context for the test point
27 * @param[in] root_da Optional root DA for the encoder/decoder ctx.
28 * @return proto or pair encoder or decoder ctx.
29 */
30typedef int (*fr_test_point_ctx_alloc_t)(void **out, TALLOC_CTX *ctx, fr_dict_t const *dict, fr_dict_attr_t const *root_da);
31
32/** A generic interface for decoding packets to fr_pair_ts
33 *
34 * A decoding function should decode a single top level packet from wire format.
35 *
36 * @param[in] ctx to allocate new pairs in.
37 * @param[in] list where new VPs will be added
38 * @param[in] data to decode.
39 * @param[in] data_len The length of the incoming data.
40 * @param[in] decode_ctx Any decode specific data such as secrets or configurable.
41 * @return
42 * - <= 0 on error. May be the offset (as a negative value) where the error occurred.
43 * - > 0 on success. How many bytes were decoded.
44 */
45typedef ssize_t (*fr_tp_proto_decode_t)(TALLOC_CTX *ctx, fr_pair_list_t *list,
46 uint8_t const *data, size_t data_len, void *decode_ctx);
47
48/** A generic interface for encoding fr_pair_ts to packets
49 *
50 * An encoding function should encode multiple VPs to a wire format packet
51 *
52 * @param[in] ctx to allocate any data in
53 * @param[in] vps vps to encode
54 * @param[in] data buffer where data can be written
55 * @param[in] data_len The length of the buffer, i.e. maximum packet length
56 * @param[in] encode_ctx Any enccode specific data such as secrets or configurable.
57 * @return
58 * - <= 0 on error. May be the offset (as a negative value) where the error occurred.
59 * - > 0 on success. How many bytes were encoded
60 */
61typedef ssize_t (*fr_tp_proto_encode_t)(TALLOC_CTX *ctx, fr_pair_list_t *vps,
62 uint8_t *data, size_t data_len, void *encode_ctx);
63
64/** Entry point for protocol decoders
65 *
66 */
67typedef struct {
68 fr_test_point_ctx_alloc_t test_ctx; //!< Allocate a test ctx for the encoder.
69 fr_tp_proto_decode_t func; //!< Decoder for proto layer.
71
72/** Entry point for protocol encoders
73 *
74 */
75typedef struct {
76 fr_test_point_ctx_alloc_t test_ctx; //!< Allocate a test ctx for the encoder.
77 fr_tp_proto_encode_t func; //!< Encoder for proto layer.
78 fr_dcursor_eval_t eval; //!< Evaluation function to filter
79 ///< attributes to encode.
81
82/** Entry point for pair decoders
83 *
84 */
85typedef struct {
86 fr_test_point_ctx_alloc_t test_ctx; //!< Allocate a test ctx for the encoder.
87 fr_pair_decode_t func; //!< Decoder for pairs.
89
90/** Entry point for pair encoders
91 *
92 */
93typedef struct {
94 fr_test_point_ctx_alloc_t test_ctx; //!< Allocate a test ctx for the encoder.
95 fr_pair_encode_t func; //!< Encoder for pairs.
96 fr_dcursor_iter_t next_encodable; //!< Iterator to use to select attributes
97 ///< to encode.
98 fr_dcursor_eval_t eval; //!< Evaluation function to filter
99 ///< attributes to encode.
bool(* fr_dcursor_eval_t)(void const *item, void const *uctx)
Type of evaluation functions to pass to the fr_dcursor_filter_*() functions.
Definition dcursor.h:91
void *(* fr_dcursor_iter_t)(fr_dcursor_t *cursor, void *to_eval, void *uctx)
Callback for implementing custom iterators.
Definition dcursor.h:51
ssize_t(* fr_pair_encode_t)(fr_dbuff_t *out, fr_dcursor_t *cursor, void *encode_ctx)
Generic interface for encoding one or more fr_pair_ts.
Definition pair.h:112
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)
A generic interface for decoding fr_pair_ts.
Definition pair.h:129
long int ssize_t
unsigned char uint8_t
static fr_internal_encode_ctx_t encode_ctx
fr_test_point_ctx_alloc_t test_ctx
Allocate a test ctx for the encoder.
Definition test_point.h:86
fr_tp_proto_decode_t func
Decoder for proto layer.
Definition test_point.h:69
int(* fr_test_point_ctx_alloc_t)(void **out, TALLOC_CTX *ctx, fr_dict_t const *dict, fr_dict_attr_t const *root_da)
Allocate an encoder/decoder ctx.
Definition test_point.h:30
fr_dcursor_eval_t eval
Evaluation function to filter attributes to encode.
Definition test_point.h:78
fr_dcursor_eval_t eval
Evaluation function to filter attributes to encode.
Definition test_point.h:98
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)
A generic interface for encoding fr_pair_ts to packets.
Definition test_point.h:61
fr_test_point_ctx_alloc_t test_ctx
Allocate a test ctx for the encoder.
Definition test_point.h:94
fr_dcursor_iter_t next_encodable
Iterator to use to select attributes to encode.
Definition test_point.h:96
ssize_t(* fr_tp_proto_decode_t)(TALLOC_CTX *ctx, fr_pair_list_t *list, uint8_t const *data, size_t data_len, void *decode_ctx)
A generic interface for decoding packets to fr_pair_ts.
Definition test_point.h:45
fr_tp_proto_encode_t func
Encoder for proto layer.
Definition test_point.h:77
fr_test_point_ctx_alloc_t test_ctx
Allocate a test ctx for the encoder.
Definition test_point.h:76
fr_pair_decode_t func
Decoder for pairs.
Definition test_point.h:87
fr_pair_encode_t func
Encoder for pairs.
Definition test_point.h:95
fr_test_point_ctx_alloc_t test_ctx
Allocate a test ctx for the encoder.
Definition test_point.h:68
Entry point for pair decoders.
Definition test_point.h:85
Entry point for pair encoders.
Definition test_point.h:93
Entry point for protocol decoders.
Definition test_point.h:67
Entry point for protocol encoders.
Definition test_point.h:75
AVP manipulation and search API.
Protocol encoder/decoder support functions.
static fr_slen_t data
Definition value.h:1293
static size_t char ** out
Definition value.h:1023