The FreeRADIUS server $Id: 15bac2a4c627c01d1aa2047687b3418955ac7f00 $
Loading...
Searching...
No Matches
proto.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/decoder support functions
19 *
20 * @file src/lib/util/proto.h
21 *
22 * @copyright 2015 The FreeRADIUS server project
23 */
24RCSIDH(proto_h, "$Id: f3b78b9d2d6c5b7d1e76be6b7278e2699745d6b6 $")
25
26#ifdef __cplusplus
27extern "C" {
28#endif
29
30#include <freeradius-devel/build.h>
31#include <freeradius-devel/missing.h>
32#include <freeradius-devel/util/dict.h>
33#include <freeradius-devel/util/dcursor.h>
34
35#define CHECK_FREESPACE(_have, _need) \
36do { \
37 if (unlikely((size_t)(_have) < (size_t)(_need))) return -((size_t)(_need) - (size_t)(_have)); \
38} while (0);
39
40#ifndef NDEBUG
41# define FR_PROTO_TRACE(_fmt, ...) if (fr_debug_lvl >= L_DBG_LVL_4) fr_proto_print(__FILE__, __LINE__, _fmt, ## __VA_ARGS__)
42# define FR_PROTO_HEX_DUMP(_data, _data_len, _fmt, ...) if (fr_debug_lvl >= L_DBG_LVL_4) fr_proto_print_hex_data(__FILE__, __LINE__, _data, _data_len, _fmt, ## __VA_ARGS__)
43# define FR_PROTO_HEX_MARKER(_data, _data_len, _slen, _fmt, ...) if (fr_debug_lvl >= L_DBG_LVL_4) fr_proto_print_hex_marker(__FILE__, __LINE__, _data, _data_len, _slen, _fmt, ## __VA_ARGS__)
44# define FR_PROTO_STACK_PRINT(_stack, _depth) if (fr_debug_lvl >= L_DBG_LVL_4) fr_proto_da_stack_print(__FILE__, __LINE__, __FUNCTION__, _stack, _depth)
45#else
46# define FR_PROTO_TRACE(_fmt, ...)
47# define FR_PROTO_HEX_DUMP(_data, _data_len, _fmt, ...)
48# define FR_PROTO_HEX_MARKER(_data, _data_len, _slen, _fmt, ...)
49# define FR_PROTO_STACK_PRINT(_x, _y)
50#endif
51
52/** Structure for holding the stack of dictionary attributes being encoded
53 *
54 */
55typedef struct {
56 uint8_t depth; //!< Deepest attribute in the stack.
57 fr_dict_attr_t const *da[FR_DICT_MAX_TLV_STACK + 1]; //!< The stack.
59
60void fr_proto_print(char const *file, int line, char const *fmt, ...) CC_HINT(format (printf, 3, 4));
61
62void fr_proto_print_hex_data(char const *file, int line, uint8_t const *data, size_t data_len, char const *fmt, ...);
63
64void fr_proto_print_hex_marker(char const *file, int line, uint8_t const *data, size_t data_len, ssize_t slen, char const *fmt, ...);
65
66void *fr_proto_next_encodable(fr_dcursor_t *cursor, void *current, void *uctx);
67
68void fr_proto_da_stack_print(char const *file, int line, char const *func, fr_da_stack_t *da_stack, unsigned int depth);
69
71
73
74#ifdef __cplusplus
75}
76#endif
int const char * file
Definition acutest.h:702
static int const char * fmt
Definition acutest.h:573
int const char int line
Definition acutest.h:702
#define RCSIDH(h, id)
Definition build.h:486
#define FR_DICT_MAX_TLV_STACK
Maximum TLV stack size.
Definition dict.h:499
static char * stack[MAX_STACK]
Definition radmin.c:159
long int ssize_t
unsigned char uint8_t
static uint8_t depth(fr_minmax_heap_index_t i)
Definition minmax_heap.c:83
static rc_request_t * current
static fr_slen_t parent
Definition pair.h:839
void fr_proto_da_stack_build(fr_da_stack_t *stack, fr_dict_attr_t const *da)
Build a complete DA stack from the da back to the root.
Definition proto.c:118
void fr_proto_print(char const *file, int line, char const *fmt,...))
Definition proto.c:27
void fr_proto_da_stack_print(char const *file, int line, char const *func, fr_da_stack_t *da_stack, unsigned int depth)
Definition proto.c:73
uint8_t depth
Deepest attribute in the stack.
Definition proto.h:56
void fr_proto_print_hex_data(char const *file, int line, uint8_t const *data, size_t data_len, char const *fmt,...)
Definition proto.c:42
void * fr_proto_next_encodable(fr_dcursor_t *cursor, void *current, void *uctx)
Implements the default iterator to encode pairs belonging to a specific dictionary that are not inter...
Definition proto.c:100
void fr_proto_da_stack_build_partial(fr_da_stack_t *stack, fr_dict_attr_t const *parent, fr_dict_attr_t const *da)
Complete the DA stack for a child attribute.
Definition proto.c:159
void fr_proto_print_hex_marker(char const *file, int line, uint8_t const *data, size_t data_len, ssize_t slen, char const *fmt,...)
Definition proto.c:57
Structure for holding the stack of dictionary attributes being encoded.
Definition proto.h:55
static fr_slen_t data
Definition value.h:1288