The FreeRADIUS server  $Id: 15bac2a4c627c01d1aa2047687b3418955ac7f00 $
Typedefs | Functions
state.h File Reference

Track overarching 'state' of the authentication session over multiple packets. More...

#include <freeradius-devel/util/dict.h>
#include <freeradius-devel/server/request.h>
+ Include dependency graph for state.h:

Go to the source code of this file.

Typedefs

typedef struct fr_state_tree_s fr_state_tree_t
 

Functions

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. More...
 
void fr_state_discard (fr_state_tree_t *state, request_t *request)
 Called when sending an Access-Accept/Access-Reject to discard state information. More...
 
void fr_state_discard_child (request_t *parent, void const *unique_ptr, int unique_int)
 Remove state from a child. More...
 
uint64_t fr_state_entries_created (fr_state_tree_t *state)
 Return number of entries created. More...
 
uint64_t fr_state_entries_timeout (fr_state_tree_t *state)
 Return number of entries that timed out. More...
 
uint64_t fr_state_entries_tracked (fr_state_tree_t *state)
 Return number of entries we're currently tracking. More...
 
void fr_state_restore_to_child (request_t *child, void const *unique_ptr, int unique_int)
 Restore subrequest data from a parent request. More...
 
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. More...
 
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. More...
 
fr_state_tree_tfr_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. More...
 

Detailed Description

Track overarching 'state' of the authentication session over multiple packets.

Id
367b70ec104f22fa472d67f4d1e2fd1affcd64fb

Definition in file state.h.

Typedef Documentation

◆ fr_state_tree_t

Definition at line 1 of file state.h.

Function Documentation

◆ fr_request_to_state()

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.

Put request->session_state_pairs into the State attribute. Put the State attribute into the vps list. Delete the original entry, if it exists

Also creates a new state entry.

Definition at line 737 of file state.c.

+ Here is the call graph for this function:
+ Here is the caller graph for this function:

◆ fr_state_discard()

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 at line 606 of file state.c.

+ Here is the call graph for this function:
+ Here is the caller graph for this function:

◆ fr_state_discard_child()

void fr_state_discard_child ( request_t parent,
void const *  unique_ptr,
int  unique_int 
)

Remove state from a child.

This is useful for modules like EAP, where we keep a persistent eap_session but may call multiple EAP method modules during negotiation, and need to discard the state between each module call.

Parameters
[in]parentHolding the child's state.
[in]unique_ptrA parent may have multiple subrequests spawned by different modules. This identifies the module or other facility that spawned the subrequest.
[in]unique_intFurther identification.

Definition at line 908 of file state.c.

+ Here is the call graph for this function:
+ Here is the caller graph for this function:

◆ fr_state_entries_created()

uint64_t fr_state_entries_created ( fr_state_tree_t state)

Return number of entries created.

Definition at line 925 of file state.c.

◆ fr_state_entries_timeout()

uint64_t fr_state_entries_timeout ( fr_state_tree_t state)

Return number of entries that timed out.

Definition at line 933 of file state.c.

◆ fr_state_entries_tracked()

uint64_t fr_state_entries_tracked ( fr_state_tree_t state)

Return number of entries we're currently tracking.

Definition at line 941 of file state.c.

+ Here is the call graph for this function:

◆ fr_state_restore_to_child()

void fr_state_restore_to_child ( request_t child,
void const *  unique_ptr,
int  unique_int 
)

Restore subrequest data from a parent request.

Parameters
[in]childThe child request to restore state to.
[in]unique_ptrA parent may have multiple subrequests spawned by different modules. This identifies the module or other facility that spawned the subrequest.
[in]unique_intFurther identification.

Definition at line 858 of file state.c.

+ Here is the call graph for this function:
+ Here is the caller graph for this function:

◆ fr_state_store_in_parent()

void fr_state_store_in_parent ( request_t child,
void const *  unique_ptr,
int  unique_int 
)

Store subrequest's session-state list and persistable request data in its parent.

Parameters
[in]childThe child request to retrieve state from.
[in]unique_ptrA parent may have multiple subrequests spawned by different modules. This identifies the module or other facility that spawned the subrequest.
[in]unique_intFurther identification.

Definition at line 812 of file state.c.

+ Here is the call graph for this function:
+ Here is the caller graph for this function:

◆ fr_state_to_request()

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.

Note
Does not copy the actual fr_pair_ts. The fr_pair_ts and their context are transferred between state entries as the conversation progresses.
Called with the mutex free.
Parameters
[in]statetree to lookup state in.
[in]requestto restore state for.
Returns
  • 2 if the state attribute didn't match any known states.
  • 1 if no state attribute existed.
  • 0 on success (state restored)
  • -1 if a state entry has already been thawed by a another request.

Definition at line 660 of file state.c.

+ Here is the call graph for this function:
+ Here is the caller graph for this function:

◆ fr_state_tree_init()

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.

Parameters
[in]ctxto link the lifecycle of the state tree to.
[in]daAttribute used to store and retrieve state from.
[in]thread_safeWhether we should mutex protect the state tree.
[in]max_sessionswe track state for.
[in]timeoutHow long to wait before cleaning up entries.
[in]server_idID byte to use in load-balancing operations.
[in]context_idSpecifies a unique ctx id to prevent states being used in contexts for which they weren't intended.
Returns
  • A new state tree.
  • NULL on failure.

Definition at line 222 of file state.c.

+ Here is the call graph for this function:
+ Here is the caller graph for this function: