The FreeRADIUS server  $Id: 15bac2a4c627c01d1aa2047687b3418955ac7f00 $
encode.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 
18 /** Protocol encoder support functions
19  *
20  * @file src/lib/util/encode.h
21  *
22  * @copyright 2022 Network RADIUS SAS
23  */
24 RCSIDH(encode_h, "$Id: cd61a117e083d42115ad9bb72e64b8f87b81307a $")
25 
26 #ifdef __cplusplus
27 extern "C" {
28 #endif
29 
30 #include <freeradius-devel/util/pair.h>
31 #include <freeradius-devel/util/dbuff.h>
32 #include <freeradius-devel/util/proto.h>
33 
34 /** Typedefs for simplifying the use and declaration of protocol encoders
35  *
36  */
37 typedef ssize_t (*fr_encode_dbuff_t)(fr_dbuff_t *dbuff, fr_da_stack_t *da_stack, unsigned int depth,
38  fr_dcursor_t *cursor, void *encode_ctx);
39 
40 #define PROTO_ENCODE_FUNC(_name) static ssize_t _name(fr_dbuff_t *dbuff, fr_da_stack_t *da_stack, unsigned int depth, \
41  fr_dcursor_t *cursor, void *encode_ctx);
42 
44  fr_dcursor_t *cursor, void *encode_ctx, fr_encode_dbuff_t encode_value) CC_HINT(nonnull(1,2,4,6));
45 
46 ssize_t fr_pair_cursor_to_network(fr_dbuff_t *dbuff, fr_da_stack_t *da_stack, unsigned int depth,
47  fr_dcursor_t *cursor, void *encode_ctx, fr_encode_dbuff_t encode_pair) CC_HINT(nonnull(1,2,4,6));
48 
49 ssize_t fr_pair_ref_to_network(fr_dbuff_t *dbuff, fr_da_stack_t *da_stack, unsigned int depth,
50  fr_dcursor_t *cursor) CC_HINT(nonnull);
51 
52 #ifdef __cplusplus
53 }
54 #endif
#define RCSIDH(h, id)
Definition: build.h:445
ssize_t fr_pair_array_to_network(fr_dbuff_t *dbuff, fr_da_stack_t *da_stack, int depth, fr_dcursor_t *cursor, void *encode_ctx, fr_encode_dbuff_t encode_value))
Encode an array of values from the network.
Definition: encode.c:42
ssize_t(* fr_encode_dbuff_t)(fr_dbuff_t *dbuff, fr_da_stack_t *da_stack, unsigned int depth, fr_dcursor_t *cursor, void *encode_ctx)
Typedefs for simplifying the use and declaration of protocol encoders.
Definition: encode.h:37
ssize_t fr_pair_ref_to_network(fr_dbuff_t *dbuff, fr_da_stack_t *da_stack, unsigned int depth, fr_dcursor_t *cursor)
Encode a foreign reference to the network.
Definition: encode.c:123
ssize_t fr_pair_cursor_to_network(fr_dbuff_t *dbuff, fr_da_stack_t *da_stack, unsigned int depth, fr_dcursor_t *cursor, void *encode_ctx, fr_encode_dbuff_t encode_pair))
Definition: encode.c:71
static ssize_t encode_value(fr_dbuff_t *dbuff, fr_da_stack_t *da_stack, int depth, fr_dcursor_t *cursor, void *encode_ctx)
Encodes the data portion of an attribute.
Definition: encode.c:272
long int ssize_t
Definition: merged_model.c:24
static uint8_t depth(fr_minmax_heap_index_t i)
Definition: minmax_heap.c:83
static fr_internal_encode_ctx_t encode_ctx
Structure for holding the stack of dictionary attributes being encoded.
Definition: proto.h:54
int nonnull(2, 5))