Tracks data usage and other counters using SQL.
More...
#include <rlm_sql.h>
#include <freeradius-devel/server/base.h>
#include <freeradius-devel/server/module_rlm.h>
#include <freeradius-devel/util/debug.h>
#include <freeradius-devel/util/dict.h>
#include <freeradius-devel/unlang/function.h>
#include <ctype.h>
Go to the source code of this file.
|
static int | attr_check (CONF_SECTION *conf, tmpl_t *tmpl, char const *name, fr_dict_attr_flags_t *flags) |
|
static int | call_env_query_parse (TALLOC_CTX *ctx, void *out, tmpl_rules_t const *t_rules, CONF_ITEM *ci, call_env_ctx_t const *cec, UNUSED call_env_parser_t const *rule) |
| Custom call_env parser to tokenize the SQL query xlat used for counter retrieval. More...
|
|
static int | find_next_reset (rlm_sqlcounter_t *inst, fr_time_t now) |
|
static int | find_prev_reset (rlm_sqlcounter_t *inst, fr_time_t now) |
|
static unlang_action_t | mod_authorize (rlm_rcode_t *p_result, module_ctx_t const *mctx, request_t *request) |
| Check the value of a counter retrieved from an SQL query with a limit More...
|
|
static unlang_action_t | mod_authorize_resume (rlm_rcode_t *p_result, UNUSED int *priority, request_t *request, void *uctx) |
| Handle the result of calling the SQL query to retrieve the counter value. More...
|
|
static int | mod_bootstrap (module_inst_ctx_t const *mctx) |
|
static int | mod_instantiate (module_inst_ctx_t const *mctx) |
|
Tracks data usage and other counters using SQL.
- Id
- c0f1a6590cd92cd855d5d20af8818d2377042da0
- Copyright
- 2001,2006 The FreeRADIUS server project
-
2001 Alan DeKok (aland.nosp@m.@fre.nosp@m.eradi.nosp@m.us.o.nosp@m.rg)
Definition in file rlm_sqlcounter.c.
◆ rlm_sqlcounter_t
Definition at line 63 of file rlm_sqlcounter.c.
Data Fields |
bool |
auto_extend |
If the remaining allowance is sufficient to reach the next period allow for that in setting the reply attribute. |
tmpl_t * |
counter_attr |
Daily-Session-Time. |
tmpl_t * |
end_attr |
&control.${.:instance}-End |
tmpl_t * |
key |
User-Name. |
fr_time_t |
last_reset |
|
tmpl_t * |
limit_attr |
Max-Daily-Session. |
char const * |
query |
SQL query to retrieve current session time. |
char const * |
reset |
Daily, weekly, monthly, never or user defined. |
fr_time_t |
reset_time |
|
char const * |
sql_name |
Instance of SQL module to use, usually just 'sql'. |
tmpl_t * |
start_attr |
&control.${.:instance}-Start |
bool |
utc |
Use UTC time. |
◆ sqlcounter_call_env_t
struct sqlcounter_call_env_t |
Definition at line 105 of file rlm_sqlcounter.c.
Data Fields |
xlat_exp_head_t * |
query_xlat |
Tokenized xlat to run query. |
tmpl_t * |
reply_attr |
Attribute to write timeout to. |
tmpl_t * |
reply_msg_attr |
Attribute to write reply message to. |
◆ sqlcounter_rctx_t
◆ LOG_PREFIX
#define LOG_PREFIX "sqlcounter" |
◆ attr_check()
◆ call_env_query_parse()
Custom call_env parser to tokenize the SQL query xlat used for counter retrieval.
Definition at line 446 of file rlm_sqlcounter.c.
◆ find_next_reset()
◆ find_prev_reset()
◆ mod_authorize()
Check the value of a counter
retrieved from an SQL query with a limit
Module specific attributes containing the start / end times are created / updated, the query is tokenized as an xlat call to the relevant SQL module and then pushed on the stack for evaluation.
Definition at line 385 of file rlm_sqlcounter.c.
◆ mod_authorize_resume()
Handle the result of calling the SQL query to retrieve the counter
value.
Create / update the counter
attribute in the control list If counter
> limit
, optionally populate a reply message and return RLM_MODULE_REJECT. Otherwise, optionally populate a reply attribute with the value of limit
- counter
and return RLM_MODULE_UPDATED. If no reply attribute is set, return RLM_MODULE_OK.
Definition at line 266 of file rlm_sqlcounter.c.
◆ mod_bootstrap()
◆ mod_instantiate()
◆ dict_freeradius
◆ module_config
Initial value:= {
.dflt =
"&control.${.:instance}-Reset-Start", .quote =
T_BARE_WORD },
.dflt =
"&control.${.:instance}-Reset-End", .quote =
T_BARE_WORD },
}
#define CONF_PARSER_TERMINATOR
#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
@ CONF_FLAG_REQUIRED
Error out if no matching CONF_PAIR is found, and no dflt value is set.
@ CONF_FLAG_ATTRIBUTE
Value must resolve to attribute in dict (deprecated, use CONF_FLAG_TMPL).
@ CONF_FLAG_NOT_EMPTY
CONF_PAIR is required to have a non zero length value.
@ CONF_FLAG_XLAT
string will be dynamically expanded.
@ CONF_FLAG_OK_MISSING
OK if it's missing.
Definition at line 82 of file rlm_sqlcounter.c.
◆ rlm_sqlcounter
Initial value:= {
.common = {
.name = "sqlcounter",
},
.method_group = {
}
}
}
#define MODULE_MAGIC_INIT
Stop people using different module/library/server versions together.
static const conf_parser_t config[]
static int instantiate(module_inst_ctx_t const *mctx)
static int mod_bootstrap(module_inst_ctx_t const *mctx)
static unlang_action_t mod_authorize(rlm_rcode_t *p_result, module_ctx_t const *mctx, request_t *request)
Check the value of a counter retrieved from an SQL query with a limit
static const call_env_method_t sqlcounter_call_env
static const conf_parser_t module_config[]
static int mod_instantiate(module_inst_ctx_t const *mctx)
#define SECTION_NAME(_name1, _name2)
Define a section name consisting of a verb and a noun.
#define MODULE_BINDING_TERMINATOR
Terminate a module binding list.
Named methods exported by a module.
Definition at line 584 of file rlm_sqlcounter.c.
◆ rlm_sqlcounter_dict
Initial value:= {
{ NULL }
}
static fr_dict_t const * dict_freeradius
Definition at line 114 of file rlm_sqlcounter.c.
◆ sqlcounter_call_env
Initial value:= {
}
}
#define CALL_ENV_TERMINATOR
#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...
@ CALL_ENV_FLAG_PARSE_ONLY
The result of parsing will not be evaluated at runtime.
@ CALL_ENV_FLAG_REQUIRED
Associated conf pair or section is required.
#define FR_CALL_ENV_PARSE_ONLY_OFFSET(_name, _cast_type, _flags, _struct, _parse_field)
Specify a call_env_parser_t which writes out the result of the parsing phase to the field specified.
static int call_env_query_parse(TALLOC_CTX *ctx, void *out, tmpl_rules_t const *t_rules, CONF_ITEM *ci, call_env_ctx_t const *cec, UNUSED call_env_parser_t const *rule)
Custom call_env parser to tokenize the SQL query xlat used for counter retrieval.
Definition at line 482 of file rlm_sqlcounter.c.