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 * @return proto or pair encoder or decoder ctx.
28 */
29typedef int (*fr_test_point_ctx_alloc_t)(void **out, TALLOC_CTX *ctx, fr_dict_t const *dict);
30
31/** A generic interface for decoding packets to fr_pair_ts
32 *
33 * A decoding function should decode a single top level packet from wire format.
34 *
35 * @param[in] ctx to allocate new pairs in.
36 * @param[in] list where new VPs will be added
37 * @param[in] data to decode.
38 * @param[in] data_len The length of the incoming data.
39 * @param[in] decode_ctx Any decode specific data such as secrets or configurable.
40 * @return
41 * - <= 0 on error. May be the offset (as a negative value) where the error occurred.
42 * - > 0 on success. How many bytes were decoded.
43 */
44typedef ssize_t (*fr_tp_proto_decode_t)(TALLOC_CTX *ctx, fr_pair_list_t *list,
45 uint8_t const *data, size_t data_len, void *decode_ctx);
46
47/** A generic interface for encoding fr_pair_ts to packets
48 *
49 * An encoding function should encode multiple VPs to a wire format packet
50 *
51 * @param[in] ctx to allocate any data in
52 * @param[in] vps vps to encode
53 * @param[in] data buffer where data can be written
54 * @param[in] data_len The length of the buffer, i.e. maximum packet length
55 * @param[in] encode_ctx Any enccode specific data such as secrets or configurable.
56 * @return
57 * - <= 0 on error. May be the offset (as a negative value) where the error occurred.
58 * - > 0 on success. How many bytes were encoded
59 */
60typedef ssize_t (*fr_tp_proto_encode_t)(TALLOC_CTX *ctx, fr_pair_list_t *vps,
61 uint8_t *data, size_t data_len, void *encode_ctx);
62
63/** Entry point for protocol decoders
64 *
65 */
66typedef struct {
67 fr_test_point_ctx_alloc_t test_ctx; //!< Allocate a test ctx for the encoder.
68 fr_tp_proto_decode_t func; //!< Decoder for proto layer.
70
71/** Entry point for protocol encoders
72 *
73 */
74typedef struct {
75 fr_test_point_ctx_alloc_t test_ctx; //!< Allocate a test ctx for the encoder.
76 fr_tp_proto_encode_t func; //!< Encoder for proto layer.
77 fr_dcursor_eval_t eval; //!< Evaluation function to filter
78 ///< attributes to encode.
80
81/** Entry point for pair decoders
82 *
83 */
84typedef struct {
85 fr_test_point_ctx_alloc_t test_ctx; //!< Allocate a test ctx for the encoder.
86 fr_pair_decode_t func; //!< Decoder for pairs.
88
89/** Entry point for pair encoders
90 *
91 */
92typedef struct {
93 fr_test_point_ctx_alloc_t test_ctx; //!< Allocate a test ctx for the encoder.
94 fr_pair_encode_t func; //!< Encoder for pairs.
95 fr_dcursor_iter_t next_encodable; //!< Iterator to use to select attributes
96 ///< to encode.
97 fr_dcursor_eval_t eval; //!< Evaluation function to filter
98 ///< 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_dlist_head_t *list, 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:85
fr_tp_proto_decode_t func
Decoder for proto layer.
Definition test_point.h:68
fr_dcursor_eval_t eval
Evaluation function to filter attributes to encode.
Definition test_point.h:77
int(* fr_test_point_ctx_alloc_t)(void **out, TALLOC_CTX *ctx, fr_dict_t const *dict)
Allocate an encoder/decoder ctx.
Definition test_point.h:29
fr_dcursor_eval_t eval
Evaluation function to filter attributes to encode.
Definition test_point.h:97
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:60
fr_test_point_ctx_alloc_t test_ctx
Allocate a test ctx for the encoder.
Definition test_point.h:93
fr_dcursor_iter_t next_encodable
Iterator to use to select attributes to encode.
Definition test_point.h:95
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:44
fr_tp_proto_encode_t func
Encoder for proto layer.
Definition test_point.h:76
fr_test_point_ctx_alloc_t test_ctx
Allocate a test ctx for the encoder.
Definition test_point.h:75
fr_pair_decode_t func
Decoder for pairs.
Definition test_point.h:86
fr_pair_encode_t func
Encoder for pairs.
Definition test_point.h:94
fr_test_point_ctx_alloc_t test_ctx
Allocate a test ctx for the encoder.
Definition test_point.h:67
Entry point for pair decoders.
Definition test_point.h:84
Entry point for pair encoders.
Definition test_point.h:92
Entry point for protocol decoders.
Definition test_point.h:66
Entry point for protocol encoders.
Definition test_point.h:74
AVP manipulation and search API.
Protocol encoder/decoder support functions.
static fr_slen_t data
Definition value.h:1265
static size_t char ** out
Definition value.h:997