The FreeRADIUS server  $Id: 15bac2a4c627c01d1aa2047687b3418955ac7f00 $
state.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: 367b70ec104f22fa472d67f4d1e2fd1affcd64fb $
20  *
21  * @file lib/server/state.h
22  * @brief Track overarching 'state' of the authentication session over multiple packets.
23  *
24  * @copyright 2014 The FreeRADIUS server project
25  * @copyright 2014 Alan DeKok (aland@deployingradius.com)
26  */
27 RCSIDH(state_h, "$Id: 367b70ec104f22fa472d67f4d1e2fd1affcd64fb $")
28 
29 #ifdef __cplusplus
30 extern "C" {
31 #endif
32 
33 #include <freeradius-devel/util/dict.h>
34 #include <freeradius-devel/server/request.h>
35 
36 typedef struct fr_state_tree_s fr_state_tree_t;
37 
38 fr_state_tree_t *fr_state_tree_init(TALLOC_CTX *ctx, fr_dict_attr_t const *da, bool thread_safe,
41 
42 void fr_state_discard(fr_state_tree_t *state, request_t *request);
43 
44 int fr_state_to_request(fr_state_tree_t *state, request_t *request);
45 int fr_request_to_state(fr_state_tree_t *state, request_t *request);
46 
47 void fr_state_store_in_parent(request_t *request, void const *unique_ptr, int unique_int);
48 void fr_state_restore_to_child(request_t *child, void const *unique_ptr, int unique_int);
49 void fr_state_discard_child(request_t *parent, void const *unique_ptr, int unique_int);
50 
51 /*
52  * Stats
53  */
57 
58 #ifdef __cplusplus
59 }
60 #endif
#define RCSIDH(h, id)
Definition: build.h:482
static fr_time_delta_t timeout
Definition: dhcpclient.c:54
unsigned int uint32_t
Definition: merged_model.c:33
unsigned char uint8_t
Definition: merged_model.c:30
uint32_t max_sessions
Maximum number of sessions we track.
Definition: state.c:149
uint8_t server_id
ID to use for load balancing.
Definition: state.c:159
fr_dict_attr_t const * da
State attribute used.
Definition: state.c:163
bool thread_safe
Whether we lock the tree whilst modifying it.
Definition: state.c:156
uint32_t context_id
ID binding state values to a context such as a virtual server.
Definition: state.c:160
void fr_state_discard_child(request_t *parent, void const *unique_ptr, int unique_int)
Remove state from a child.
Definition: state.c:908
fr_state_tree_t * fr_state_tree_init(TALLOC_CTX *ctx, fr_dict_attr_t const *da, bool thread_safe, uint32_t max_sessions, fr_time_delta_t timeout, uint8_t server_id, uint32_t context_id)
Initialise a new state tree.
Definition: state.c:222
void fr_state_discard(fr_state_tree_t *state, request_t *request)
Called when sending an Access-Accept/Access-Reject to discard state information.
Definition: state.c:606
void fr_state_store_in_parent(request_t *request, void const *unique_ptr, int unique_int)
Store subrequest's session-state list and persistable request data in its parent.
Definition: state.c:812
int fr_request_to_state(fr_state_tree_t *state, request_t *request)
Transfer ownership of the state fr_pair_ts and ctx, back to a state entry.
Definition: state.c:737
int fr_state_to_request(fr_state_tree_t *state, request_t *request)
Copy a pointer to the head of the list of state fr_pair_ts (and their ctx) into the request.
Definition: state.c:660
uint64_t fr_state_entries_tracked(fr_state_tree_t *state)
Return number of entries we're currently tracking.
Definition: state.c:941
uint64_t fr_state_entries_created(fr_state_tree_t *state)
Return number of entries created.
Definition: state.c:925
uint64_t fr_state_entries_timeout(fr_state_tree_t *state)
Return number of entries that timed out.
Definition: state.c:933
void fr_state_restore_to_child(request_t *child, void const *unique_ptr, int unique_int)
Restore subrequest data from a parent request.
Definition: state.c:858
A time delta, a difference in time measured in nanoseconds.
Definition: time.h:80
static fr_slen_t parent
Definition: pair.h:851