26RCSID(
"$Id: 5a0ba9d9ee23a129b831b492fec70268067a5224 $")
28#define LOG_PREFIX mctx->mi->name
30#include <freeradius-devel/server/base.h>
31#include <freeradius-devel/util/debug.h>
32#include <freeradius-devel/server/module_rlm.h>
72 ret = strcmp(a->
name1, b->name1);
73 if (ret != 0)
return CMP(ret, 0);
74 if (!a->
name2 && !b->name2)
return 0;
75 if (!a->
name2 || !b->name2)
return a->
name2 ? 1 : -1;
76 ret = strcmp(a->
name2, b->name2);
128 if (
inst->interpreter) {
129 if (
inst->func_detach) {
133 .interpreter = inst->interpreter
136 NULL,
inst->func_detach);
138 lua_close(
inst->interpreter);
158 if (!
inst->jit)
WARN(
"Using standard Lua interpreter, performance will be suboptimal");
174 pair_name = talloc_asprintf(func,
"func_%s_%s", func->
name1, func->
name2);
177 if (cp)
goto found_func;
179 pair_name = talloc_asprintf(func,
"func_%s", func->
name1);
192 }
else if (func->
name2) {
210 if (
inst->func_instantiate) {
214 .interpreter = inst->interpreter
217 NULL,
inst->func_instantiate);
232 for (i = 0; i < talloc_array_length(
name); i++) {
234 if (!strchr(
"abcdefghijklmnopqrstuvwxyz1234567890", *p)) *p =
'_';
247 if (!
inst->funcs_init) {
249 inst->funcs_init =
true;
258 .offset = rule->pair.offset,
unlang_action_t
Returned by unlang_op_t calls, determine the next action of the interpreter.
#define CMP(_a, _b)
Same as CMP_PREFER_SMALLER use when you don't really care about ordering, you just want an ordering.
call_env_parsed_t * call_env_parsed_add(TALLOC_CTX *ctx, call_env_parsed_head_t *head, call_env_parser_t const *rule)
Allocate a new call_env_parsed_t structure and add it to the list of parsed call envs.
void call_env_parsed_set_data(call_env_parsed_t *parsed, void const *data)
Assign data to a call_env_parsed_t.
#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_parser_t const * env
Parsing rules for call method env.
section_name_t const * asked
The actual name1/name2 that resolved to a module_method_binding_t.
@ CALL_ENV_FLAG_PARSE_ONLY
The result of parsing will not be evaluated at runtime.
@ CALL_ENV_FLAG_PARSE_MISSING
If this subsection is missing, still parse it.
@ CALL_ENV_PARSE_TYPE_VOID
Output of the parsing phase is undefined (a custom structure).
module_instance_t const * mi
Module instance that the callenv is registered to.
#define FR_CALL_ENV_SUBSECTION_FUNC(_name, _name2, _flags, _func)
Specify a call_env_parser_t which parses a subsection using a callback function.
#define CONF_PARSER_TERMINATOR
#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
#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_FILE_INPUT
File matching value must exist, and must be readable.
Defines a CONF_PAIR to C data type mapping.
Common header for all CONF_* types.
Configuration AVP similar to a fr_pair_t.
CONF_PAIR * cf_pair_find(CONF_SECTION const *cs, char const *attr)
Search for a CONF_PAIR with a specific name.
char const * cf_pair_value(CONF_PAIR const *pair)
Return the value of a CONF_PAIR.
#define cf_log_err(_cf, _fmt,...)
#define MODULE_MAGIC_INIT
Stop people using different module/library/server versions together.
unlang_action_t fr_lua_run(rlm_rcode_t *p_result, module_ctx_t const *mctx, request_t *request, char const *funcname)
char const * fr_lua_version(lua_State *L)
bool fr_lua_isjit(lua_State *L)
Check whether the Lua interpreter were actually linked to is LuaJIT.
int fr_lua_check_func(module_inst_ctx_t const *mctx, lua_State *L, char const *name)
Check if a given function was loaded into an index in the global table.
int fr_lua_init(lua_State **out, module_inst_ctx_t const *mctx)
Initialise a new Lua/LuaJIT interpreter.
Library function signatures for lua module.
lua_State * interpreter
Thread specific interpreter.
void * env_data
Per call environment data.
module_instance_t * mi
Module instance to detach.
void * thread
Thread instance data.
#define MODULE_CTX(_mi, _thread, _env_data, _rctx)
Wrapper to create a module_ctx_t as a compound literal.
module_instance_t * mi
Instance of the module being instantiated.
Temporary structure to hold arguments for module calls.
Temporary structure to hold arguments for detach calls.
Temporary structure to hold arguments for instantiation calls.
Temporary structure to hold arguments for thread_instantiation calls.
module_t common
Common fields presented by all modules.
void * fr_rb_iter_init_inorder(fr_rb_iter_inorder_t *iter, fr_rb_tree_t *tree)
Initialise an in-order iterator.
int fr_rb_find_or_insert(void **found, fr_rb_tree_t *tree, void const *data)
Attempt to find current data in the tree, if it does not exist insert it.
void * fr_rb_iter_next_inorder(fr_rb_iter_inorder_t *iter)
Return the next node.
#define fr_rb_inline_init(_tree, _type, _field, _data_cmp, _data_free)
Initialises a red black tree.
Iterator structure for in-order traversal of an rbtree.
rlm_rcode_t
Return codes indicating the result of the module call.
static int mod_detach(module_detach_ctx_t const *mctx)
Close the global interpreter.
static const call_env_method_t lua_method_env
fr_rb_node_t node
Node in tree of function calls.
char const * function_name
Name of the function being called.
static unlang_action_t mod_lua(rlm_rcode_t *p_result, module_ctx_t const *mctx, request_t *request)
char * name2
Section name2 where this is called.
static void lua_func_name_safe(char *name)
char * name1
Section name1 where this is called.
static int mod_thread_instantiate(module_thread_inst_ctx_t const *mctx)
Create thread-specific connections and buffers.
static int8_t lua_func_def_cmp(void const *one, void const *two)
How to compare two Lua function calls.
static const conf_parser_t module_config[]
static int lua_func_parse(TALLOC_CTX *ctx, call_env_parsed_head_t *out, UNUSED tmpl_rules_t const *t_rules, UNUSED CONF_ITEM *ci, call_env_ctx_t const *cec, UNUSED call_env_parser_t const *rule)
static int mod_thread_detach(module_thread_inst_ctx_t const *mctx)
Free any thread specific interpreters.
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.
char const * name2
Second section name. Usually a packet type like 'access-request', 'access-accept',...
char const * name1
First section name. Usually a verb like 'recv', 'send', etc...
CONF_SECTION * conf
Module's instance configuration.
size_t inst_size
Size of the module's instance data.
void * data
Module's instance data.
#define MODULE_BINDING_TERMINATOR
Terminate a module binding list.
Named methods exported by a module.
Optional arguments passed to vp_tmpl functions.
eap_aka_sim_process_conf_t * inst
static int talloc_const_free(void const *ptr)
Free const'd memory.
static size_t char ** out