The FreeRADIUS server $Id: 15bac2a4c627c01d1aa2047687b3418955ac7f00 $
Loading...
Searching...
No Matches
track.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/*
19 * $Id: 327361129818344534d2a79e43ea8cd0ce916050 $
20 *
21 * @file track.h
22 * @brief RADIUS client packet tracking
23 *
24 * @copyright 2017 Alan DeKok (aland@freeradius.org)
25 */
26
27#include "rlm_radius.h"
28#include <freeradius-devel/util/dlist.h>
29
32
33/** Track one request to a response
34 *
35 */
37 fr_rb_node_t node; //!< Entry in the tracking tree.
38
40
41 radius_track_entry_t ***binding; //!< Binding chunk we use to release the entry
42 ///< when its parent is freed. We also zero
43 ///< out the tracking entry field in the parent.
44
45 request_t *request; //!< as always...
46
47 void *uctx; //!< Result/resumption context.
48
49 uint8_t code; //!< packet code (sigh)
50 uint8_t id; //!< our ID
51
52 union {
53 fr_dlist_t entry; //!< For free list.
54 uint8_t vector[RADIUS_AUTH_VECTOR_LENGTH]; //!< copy of the request authenticator.
55 };
56
57#ifndef NDEBUG
58 uint64_t operation; //!< Used to give an idea of the alloc/free timeline.
59 char const *file; //!< Where the entry was allocated.
60 int line; //!< Where the entry was freed.
61#endif
62};
63
65 unsigned int num_requests; //!< number of requests in the allocation
66
67 fr_dlist_head_t free_list; //!< so we allocate by least recently used
68
69 radius_track_entry_t id[UINT8_MAX + 1]; //!< which ID was used
70
71#ifndef NDEBUG
72 uint64_t operation; //!< Incremented each alloc and de-alloc
73#endif
74};
75
76radius_track_t *radius_track_alloc(TALLOC_CTX *ctx);
77
78/*
79 * Debug functions which track allocations and frees
80 */
81#ifndef NDEBUG
82# define radius_track_entry_reserve(_te_out, _ctx, _tt, _request, _code, _uctx) \
83 _radius_track_entry_reserve( __FILE__, __LINE__, _te_out, _ctx, _tt, _request, _code, _uctx)
84int _radius_track_entry_reserve(char const *file, int line,
85 radius_track_entry_t **te_out,
86 TALLOC_CTX *ctx, radius_track_t *tt, request_t *request,
87 uint8_t code, void *uctx)
88 CC_HINT(nonnull(3,5,6));
89
90# define radius_track_entry_release(_te) \
91 _radius_track_entry_release( __FILE__, __LINE__, _te)
93 CC_HINT(nonnull);
94
95typedef void (*radius_track_log_extra_t)(fr_log_t const *log, fr_log_type_t log_type, char const *file, int line,
97
98void radius_track_state_log(fr_log_t const *log, fr_log_type_t log_type, char const *file, int line,
100/*
101 * Non-debug functions
102 */
103#else
105 TALLOC_CTX *ctx, radius_track_t *tt, request_t *request,
106 uint8_t code, void *uctx)
107 CC_HINT(nonnull(1,3,4));
108
110#endif
111
113 uint8_t const *vector) CC_HINT(nonnull);
114
116 uint8_t const *vector) CC_HINT(nonnull(1));
int const char * file
Definition acutest.h:702
int const char int line
Definition acutest.h:702
Head of a doubly linked list.
Definition dlist.h:51
Entry in a doubly linked list.
Definition dlist.h:41
fr_log_type_t
Definition log.h:54
unsigned char uint8_t
#define UINT8_MAX
#define RADIUS_AUTH_VECTOR_LENGTH
Definition net.h:89
Definition log.h:96
char const * file
Where the entry was allocated.
Definition track.h:59
void radius_track_state_log(fr_log_t const *log, fr_log_type_t log_type, char const *file, int line, radius_track_t *tt, radius_track_log_extra_t extra)
Print out the state of every tracking entry.
Definition track.c:294
fr_dlist_head_t free_list
so we allocate by least recently used
Definition track.h:67
int _radius_track_entry_release(char const *file, int line, radius_track_entry_t **te)
Release a tracking entry.
Definition track.c:170
radius_track_t * tt
Definition track.h:39
int radius_track_entry_update(radius_track_entry_t *te, uint8_t const *vector)
Update a tracking entry with the authentication vector.
Definition track.c:219
radius_track_entry_t * radius_track_entry_find(radius_track_t *tt, uint8_t packet_id, uint8_t const *vector))
Find a tracking entry from a request authenticator.
Definition track.c:248
#define radius_track_entry_release(_te)
Definition track.h:90
void * uctx
Result/resumption context.
Definition track.h:47
int line
Where the entry was freed.
Definition track.h:60
uint8_t id
our ID
Definition track.h:50
uint64_t operation
Incremented each alloc and de-alloc.
Definition track.h:72
unsigned int num_requests
number of requests in the allocation
Definition track.h:65
fr_rb_node_t node
Entry in the tracking tree.
Definition track.h:37
uint8_t code
packet code (sigh)
Definition track.h:49
int _radius_track_entry_reserve(char const *file, int line, radius_track_entry_t **te_out, TALLOC_CTX *ctx, radius_track_t *tt, request_t *request, uint8_t code, void *uctx))
Allocate a tracking entry.
Definition track.c:93
#define radius_track_entry_reserve(_te_out, _ctx, _tt, _request, _code, _uctx)
Definition track.h:82
radius_track_t * radius_track_alloc(TALLOC_CTX *ctx)
Create an radius_track_t.
Definition track.c:41
void(* radius_track_log_extra_t)(fr_log_t const *log, fr_log_type_t log_type, char const *file, int line, radius_track_entry_t *te)
Definition track.h:95
uint64_t operation
Used to give an idea of the alloc/free timeline.
Definition track.h:58
request_t * request
as always...
Definition track.h:45
radius_track_entry_t *** binding
Binding chunk we use to release the entry when its parent is freed.
Definition track.h:41
Track one request to a response.
Definition track.h:36
int nonnull(2, 5))