The FreeRADIUS server $Id: f3670dba8951ca10eb4948feb3dc3db9423a334f $
Loading...
Searching...
No Matches
Data Structures | Functions | Variables
rlm_rediswho.c File Reference

Session tracking using redis. More...

#include <freeradius-devel/server/base.h>
#include <freeradius-devel/server/module_rlm.h>
#include <freeradius-devel/server/modpriv.h>
#include <freeradius-devel/util/debug.h>
#include <freeradius-devel/redis/base.h>
#include <freeradius-devel/redis/cluster_async.h>
+ Include dependency graph for rlm_rediswho.c:

Go to the source code of this file.

Data Structures

struct  rediswho_call_env_t
 
struct  rediswho_rctx_t
 Resume context for rediswho module calls. More...
 
struct  rlm_rediswho_t
 
struct  rlm_rediswho_thread_t
 

Functions

static int _rediswho_rctx_free (rediswho_rctx_t *rctx)
 
static unlang_action_t mod_accounting (unlang_result_t *p_result, module_ctx_t const *mctx, request_t *request)
 
static void mod_accounting_cancel (module_ctx_t const *mctx, request_t *request, UNUSED fr_signal_t action)
 
static unlang_action_t mod_accounting_expire (unlang_result_t *p_result, module_ctx_t const *mctx, request_t *request)
 
static unlang_action_t mod_accounting_resume (unlang_result_t *p_result, module_ctx_t const *mctx, request_t *request)
 
static unlang_action_t mod_accounting_trim (unlang_result_t *p_result, module_ctx_t const *mctx, request_t *request)
 
static int mod_coord_attach (module_thread_inst_ctx_t const *mctx)
 
static int mod_detach (module_detach_ctx_t const *mctx)
 
static int mod_instantiate (module_inst_ctx_t const *mctx)
 
static int mod_load (void)
 
static int mod_thread_detach (module_thread_inst_ctx_t const *mctx)
 
static int mod_thread_instantiate (module_thread_inst_ctx_t const *mctx)
 
 REDIS_ASYNC_COORD_CALLBACKS (rlm_rediswho_thread_t)
 
static int redis_command_call_env_parse (TALLOC_CTX *ctx, call_env_parsed_head_t *out, tmpl_rules_t const *t_rules, CONF_ITEM *ci, call_env_ctx_t const *cec, UNUSED call_env_parser_t const *rule)
 
static fr_redis_async_rcode_t rediswho_command (rlm_rediswho_thread_t *thread, request_t *request, fr_value_box_t *key, rediswho_rctx_t *rctx, char const *fmt,...)
 
static unlang_action_t rediswho_rcode_check (request_t *request, fr_redis_command_set_t *cmds, fr_redis_async_cmd_t *cmd, module_ctx_t const *mctx, module_method_t resume, unlang_module_signal_t cancel)
 
static void rediswho_results (request_t *request, UNUSED fr_redis_command_t *cmd, redisReply *reply, void *rctx)
 Process redisReply from rediswho command.
 

Variables

static fr_dict_attr_t const * attr_acct_status_type
 
static fr_dict_t const * dict_radius
 
static fr_dict_t const * dict_redis
 
static const call_env_method_t method_env
 
static conf_parser_t module_config []
 
static conf_parser_t redis_config []
 
static call_env_parser_t const rediswho_env_parser []
 
module_rlm_t rlm_rediswho
 
fr_dict_autoload_t rlm_rediswho_dict []
 
fr_dict_attr_autoload_t rlm_rediswho_dict_attr []
 

Detailed Description

Session tracking using redis.

Id
50bd6cacb724a2dc7d475ea4d275fb903c11f23f
Author
Gabriel Blanchard

Definition in file rlm_rediswho.c.


Data Structure Documentation

◆ rediswho_call_env_t

struct rediswho_call_env_t

Definition at line 68 of file rlm_rediswho.c.

+ Collaboration diagram for rediswho_call_env_t:
Data Fields
fr_value_box_t insert_arg Argument to append to insert command.
fr_value_box_t insert_cmd Command to run for insert stage, defaults to LPUSH.
fr_value_box_t key Key value for redis commands.
fr_value_box_t trim_cmd Command to run for trim stage, defaults to LTRIM.

◆ rediswho_rctx_t

struct rediswho_rctx_t

Resume context for rediswho module calls.

Definition at line 61 of file rlm_rediswho.c.

+ Collaboration diagram for rediswho_rctx_t:
Data Fields
fr_redis_async_cmd_t * cmd Async command context.
char * cmd_str Formatted command currently being run.
fr_redis_command_set_t * cmds Command set for module call.
int ret Value returned in Redis reply.

◆ rlm_rediswho_t

struct rlm_rediswho_t

Definition at line 39 of file rlm_rediswho.c.

+ Collaboration diagram for rlm_rediswho_t:
Data Fields
fr_redis_conf_t conf Connection parameters for the Redis server.

Must be first field in this struct.

fr_coord_pair_reg_t * coord_pair_reg Coord pair registration.
fr_coord_reg_t * coord_reg Coordinator registration.
int expiry_time Expiry time in seconds if no updates are received for a user.
CONF_SECTION * tls_conf TLS CONF_SECTION.
int trim_count How many session updates to keep track of per user.

◆ rlm_rediswho_thread_t

struct rlm_rediswho_thread_t

Definition at line 53 of file rlm_rediswho.c.

+ Collaboration diagram for rlm_rediswho_thread_t:
Data Fields
fr_coord_worker_t * cw Coord-worker for fetching cluster map.
rlm_rediswho_t * inst Module instance.
fr_redis_ct_t * rtcluster Per thread Redis cluster.

Function Documentation

◆ _rediswho_rctx_free()

static int _rediswho_rctx_free ( rediswho_rctx_t rctx)
static

Definition at line 296 of file rlm_rediswho.c.

+ Here is the caller graph for this function:

◆ mod_accounting()

static unlang_action_t mod_accounting ( unlang_result_t p_result,
module_ctx_t const *  mctx,
request_t request 
)
static

Definition at line 302 of file rlm_rediswho.c.

+ Here is the call graph for this function:

◆ mod_accounting_cancel()

static void mod_accounting_cancel ( module_ctx_t const *  mctx,
request_t request,
UNUSED fr_signal_t  action 
)
static

Definition at line 177 of file rlm_rediswho.c.

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

◆ mod_accounting_expire()

static unlang_action_t mod_accounting_expire ( unlang_result_t p_result,
module_ctx_t const *  mctx,
request_t request 
)
static

Definition at line 231 of file rlm_rediswho.c.

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

◆ mod_accounting_resume()

static unlang_action_t mod_accounting_resume ( unlang_result_t p_result,
module_ctx_t const *  mctx,
request_t request 
)
static

Definition at line 215 of file rlm_rediswho.c.

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

◆ mod_accounting_trim()

static unlang_action_t mod_accounting_trim ( unlang_result_t p_result,
module_ctx_t const *  mctx,
request_t request 
)
static

Definition at line 258 of file rlm_rediswho.c.

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

◆ mod_coord_attach()

static int mod_coord_attach ( module_thread_inst_ctx_t const *  mctx)
static

Definition at line 349 of file rlm_rediswho.c.

+ Here is the call graph for this function:

◆ mod_detach()

static int mod_detach ( module_detach_ctx_t const *  mctx)
static

Definition at line 428 of file rlm_rediswho.c.

+ Here is the call graph for this function:

◆ mod_instantiate()

static int mod_instantiate ( module_inst_ctx_t const *  mctx)
static

Definition at line 368 of file rlm_rediswho.c.

+ Here is the call graph for this function:

◆ mod_load()

static int mod_load ( void  )
static

Definition at line 437 of file rlm_rediswho.c.

+ Here is the call graph for this function:

◆ mod_thread_detach()

static int mod_thread_detach ( module_thread_inst_ctx_t const *  mctx)
static

Definition at line 417 of file rlm_rediswho.c.

+ Here is the call graph for this function:

◆ mod_thread_instantiate()

static int mod_thread_instantiate ( module_thread_inst_ctx_t const *  mctx)
static

Definition at line 336 of file rlm_rediswho.c.

+ Here is the call graph for this function:

◆ REDIS_ASYNC_COORD_CALLBACKS()

REDIS_ASYNC_COORD_CALLBACKS ( rlm_rediswho_thread_t  )

◆ redis_command_call_env_parse()

static int redis_command_call_env_parse ( TALLOC_CTX *  ctx,
call_env_parsed_head_t *  out,
tmpl_rules_t const *  t_rules,
CONF_ITEM ci,
call_env_ctx_t const *  cec,
UNUSED call_env_parser_t const *  rule 
)
static

Definition at line 452 of file rlm_rediswho.c.

+ Here is the call graph for this function:

◆ rediswho_command()

static fr_redis_async_rcode_t rediswho_command ( rlm_rediswho_thread_t thread,
request_t request,
fr_value_box_t key,
rediswho_rctx_t rctx,
char const *  fmt,
  ... 
)
static

Definition at line 142 of file rlm_rediswho.c.

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

◆ rediswho_rcode_check()

static unlang_action_t rediswho_rcode_check ( request_t request,
fr_redis_command_set_t cmds,
fr_redis_async_cmd_t cmd,
module_ctx_t const *  mctx,
module_method_t  resume,
unlang_module_signal_t  cancel 
)
inlinestatic

Definition at line 186 of file rlm_rediswho.c.

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

◆ rediswho_results()

static void rediswho_results ( request_t request,
UNUSED fr_redis_command_t cmd,
redisReply *  reply,
void *  rctx 
)
static

Process redisReply from rediswho command.

The reply is expected to either be an integer or status.

Definition at line 111 of file rlm_rediswho.c.

+ Here is the caller graph for this function:

Variable Documentation

◆ attr_acct_status_type

fr_dict_attr_t const* attr_acct_status_type
static

Definition at line 99 of file rlm_rediswho.c.

◆ dict_radius

fr_dict_t const* dict_radius
static

Definition at line 89 of file rlm_rediswho.c.

◆ dict_redis

fr_dict_t const* dict_redis
static

Definition at line 90 of file rlm_rediswho.c.

◆ method_env

const call_env_method_t method_env
static
Initial value:
= {
.env = (call_env_parser_t[]) {
}
}
#define CALL_ENV_TERMINATOR
Definition call_env.h:236
#define FR_CALL_ENV_METHOD_OUT(_inst)
Helper macro for populating the size/type fields of a call_env_method_t from the output structure typ...
Definition call_env.h:240
@ CALL_ENV_FLAG_SUBSECTION
This is a subsection.
Definition call_env.h:87
#define FR_CALL_ENV_SUBSECTION_FUNC(_name, _name2, _flags, _func)
Specify a call_env_parser_t which parses a subsection using a callback function.
Definition call_env.h:412
Per method call config.
Definition call_env.h:180
#define CF_IDENT_ANY
Definition cf_util.h:80
static int redis_command_call_env_parse(TALLOC_CTX *ctx, call_env_parsed_head_t *out, tmpl_rules_t const *t_rules, CONF_ITEM *ci, call_env_ctx_t const *cec, UNUSED call_env_parser_t const *rule)

Definition at line 476 of file rlm_rediswho.c.

◆ module_config

conf_parser_t module_config[]
static
Initial value:
= {
{ FR_CONF_OFFSET("trim_count", rlm_rediswho_t, trim_count), .dflt = "-1" },
{ FR_CONF_OFFSET_FLAGS("expiry_time", CONF_FLAG_REQUIRED, rlm_rediswho_t, expiry_time) },
{ FR_CONF_POINTER("redis", 0, CONF_FLAG_SUBSECTION, NULL), .subcs = redis_config },
}
#define CONF_PARSER_TERMINATOR
Definition cf_parse.h:669
#define FR_CONF_OFFSET(_name, _struct, _field)
conf_parser_t which parses a single CONF_PAIR, writing the result to a field in a struct
Definition cf_parse.h:280
#define FR_CONF_POINTER(_name, _type, _flags, _res_p)
conf_parser_t which parses a single CONF_PAIR producing a single global result
Definition cf_parse.h:334
#define FR_CONF_OFFSET_FLAGS(_name, _flags, _struct, _field)
conf_parser_t which parses a single CONF_PAIR, writing the result to a field in a struct
Definition cf_parse.h:268
@ CONF_FLAG_REQUIRED
Error out if no matching CONF_PAIR is found, and no dflt value is set.
Definition cf_parse.h:429
@ CONF_FLAG_SUBSECTION
Instead of putting the information into a configuration structure, the configuration file routines MA...
Definition cf_parse.h:423
static conf_parser_t redis_config[]

Definition at line 80 of file rlm_rediswho.c.

◆ redis_config

conf_parser_t redis_config[]
static
Initial value:
= {
}
#define REDIS_COMMON_CONFIG
Definition base.h:143

Definition at line 75 of file rlm_rediswho.c.

◆ rediswho_env_parser

call_env_parser_t const rediswho_env_parser[]
static
Initial value:
= {
{ FR_CALL_ENV_OFFSET("insert_cmd", FR_TYPE_STRING, CALL_ENV_FLAG_CONCAT, rediswho_call_env_t, insert_cmd), .pair.dflt = "LPUSH", .pair.dflt_quote = T_SINGLE_QUOTED_STRING },
{ FR_CALL_ENV_OFFSET("trim_cmd", FR_TYPE_STRING, CALL_ENV_FLAG_CONCAT , rediswho_call_env_t, trim_cmd), .pair.dflt = "LTRIM", .pair.dflt_quote = T_SINGLE_QUOTED_STRING },
}
@ CALL_ENV_FLAG_CONCAT
If the tmpl produced multiple boxes they should be concatenated.
Definition call_env.h:76
@ CALL_ENV_FLAG_REQUIRED
Associated conf pair or section is required.
Definition call_env.h:75
@ CALL_ENV_FLAG_BARE_WORD_ATTRIBUTE
bare words are treated as an attribute, but strings may be xlats.
Definition call_env.h:92
#define FR_CALL_ENV_OFFSET(_name, _cast_type, _flags, _struct, _field)
Specify a call_env_parser_t which writes out runtime results to the specified field.
Definition call_env.h:340
@ FR_TYPE_STRING
String of printable characters.
@ T_SINGLE_QUOTED_STRING
Definition token.h:120

Definition at line 444 of file rlm_rediswho.c.

◆ rlm_rediswho

module_rlm_t rlm_rediswho
Initial value:
= {
.common = {
.name = "rediswho",
.inst_size = sizeof(rlm_rediswho_t),
.onload = mod_load,
.instantiate = mod_instantiate,
.coord_attach = mod_coord_attach,
.detach = mod_detach,
.thread_instantiate = mod_thread_instantiate,
.thread_detach = mod_thread_detach,
},
.method_group = {
.bindings = (module_method_binding_t[]){
{ .section = SECTION_NAME("accounting", CF_IDENT_ANY), .method = mod_accounting, .method_env = &method_env },
}
}
}
#define MODULE_MAGIC_INIT
Stop people using different module/library/server versions together.
Definition dl_module.h:63
static const conf_parser_t config[]
Definition base.c:162
static int mod_detach(module_detach_ctx_t const *mctx)
static int mod_load(void)
static int mod_coord_attach(module_thread_inst_ctx_t const *mctx)
static const call_env_method_t method_env
static unlang_action_t mod_accounting(unlang_result_t *p_result, module_ctx_t const *mctx, request_t *request)
static int mod_thread_instantiate(module_thread_inst_ctx_t const *mctx)
static int mod_thread_detach(module_thread_inst_ctx_t const *mctx)
static int mod_instantiate(module_inst_ctx_t const *mctx)
static conf_parser_t module_config[]
#define SECTION_NAME(_name1, _name2)
Define a section name consisting of a verb and a noun.
Definition section.h:39
#define MODULE_THREAD_INST(_ctype)
Definition module.h:258
#define MODULE_BINDING_TERMINATOR
Terminate a module binding list.
Definition module.h:152
Named methods exported by a module.
Definition module.h:174

Definition at line 485 of file rlm_rediswho.c.

◆ rlm_rediswho_dict

fr_dict_autoload_t rlm_rediswho_dict
Initial value:
= {
{ .out = &dict_radius, .proto = "radius" },
{ .out = &dict_redis, .proto = "redis" },
}
#define DICT_AUTOLOAD_TERMINATOR
Definition dict.h:311
static fr_dict_t const * dict_radius
static fr_dict_t const * dict_redis

Definition at line 93 of file rlm_rediswho.c.

◆ rlm_rediswho_dict_attr

fr_dict_attr_autoload_t rlm_rediswho_dict_attr
Initial value:
= {
{ .out = &attr_acct_status_type, .name = "Acct-Status-Type", .type = FR_TYPE_UINT32, .dict = &dict_radius },
}
@ FR_TYPE_UINT32
32 Bit unsigned integer.
static fr_dict_attr_t const * attr_acct_status_type

Definition at line 102 of file rlm_rediswho.c.