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/unlang/function.h>
#include <ctype.h>
Go to the source code of this file.
|
static int | call_env_query_parse (TALLOC_CTX *ctx, void *out, tmpl_rules_t const *t_rules, CONF_ITEM *ci, UNUSED char const *section_name1, UNUSED char const *section_name2, void const *data, 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
- c73cb6ef67fff33c92915852423b299554a1bbb3
- 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 62 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 104 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
◆ ATTR_CHECK
#define ATTR_CHECK |
( |
|
_tmpl, |
|
|
|
_name |
|
) |
| |
Value:
cf_log_perr(
conf,
"Failed defining %s attribute", _name); \
return -1; \
} \
return -1; \
} \
}
fr_dict_attr_t const * fr_dict_root(fr_dict_t const *dict)
Return the root attribute of a dictionary.
fr_dict_t * fr_dict_unconst(fr_dict_t const *dict)
Coerce to non-const.
int fr_dict_attr_add(fr_dict_t *dict, fr_dict_attr_t const *parent, char const *name, int attr, fr_type_t type, fr_dict_attr_flags_t const *flags))
Add an attribute to the dictionary.
@ FR_TYPE_UINT64
64 Bit unsigned integer.
static fr_dict_t const * dict_freeradius
#define tmpl_is_attr_unresolved(vpt)
static fr_dict_attr_t const * tmpl_attr_tail_da(tmpl_t const *vpt)
Return the last attribute reference da.
#define tmpl_is_attr(vpt)
static char const * tmpl_attr_tail_unresolved(tmpl_t const *vpt)
Return the last attribute reference unresolved da.
eap_aka_sim_process_conf_t * inst
Definition at line 480 of file rlm_sqlcounter.c.
◆ LOG_PREFIX
#define LOG_PREFIX "sqlcounter" |
◆ call_env_query_parse()
Custom call_env parser to tokenize the SQL query xlat used for counter retrieval.
Definition at line 520 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 384 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 265 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 81 of file rlm_sqlcounter.c.
◆ rlm_sqlcounter
Initial value:= {
.common = {
.name = "sqlcounter",
},
}
}
#define MODULE_MAGIC_INIT
Stop people using different module/library/server versions together.
Specifies a module method identifier.
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)
@ MODULE_TYPE_THREAD_SAFE
Module is threadsafe.
#define MODULE_NAME_TERMINATOR
Definition at line 578 of file rlm_sqlcounter.c.
◆ rlm_sqlcounter_dict
◆ 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, UNUSED char const *section_name1, UNUSED char const *section_name2, void const *data, UNUSED call_env_parser_t const *rule)
Custom call_env parser to tokenize the SQL query xlat used for counter retrieval.
Definition at line 557 of file rlm_sqlcounter.c.