The FreeRADIUS server  $Id: 15bac2a4c627c01d1aa2047687b3418955ac7f00 $
Data Structures | Functions
lua.h File Reference

Library function signatures for lua module. More...

#include <lua.h>
#include <lauxlib.h>
#include <freeradius-devel/server/base.h>
+ Include dependency graph for lua.h:
+ This graph shows which files directly or indirectly include this file:

Go to the source code of this file.

Data Structures

struct  rlm_lua_t
 
struct  rlm_lua_thread_t
 

Functions

int fr_lua_init (lua_State **out, module_inst_ctx_t const *mctx)
 Initialise a new Lua/LuaJIT interpreter. More...
 
bool fr_lua_isjit (lua_State *L)
 Check whether the Lua interpreter were actually linked to is LuaJIT. More...
 
unlang_action_t fr_lua_run (rlm_rcode_t *p_result, module_ctx_t const *mctx, request_t *request, char const *funcname)
 
void fr_lua_util_fr_register (lua_State *L)
 
module_ctx_t const * fr_lua_util_get_mctx (void)
 Get the thread local instance. More...
 
request_tfr_lua_util_get_request (void)
 Get the thread local request. More...
 
void fr_lua_util_jit_log_debug (char const *msg)
 Emit a debug log message. More...
 
void fr_lua_util_jit_log_error (char const *msg)
 Emit a error log message. More...
 
void fr_lua_util_jit_log_info (char const *msg)
 Emit an info log message. More...
 
int fr_lua_util_jit_log_register (lua_State *L)
 Insert cdefs into the lua environment. More...
 
void fr_lua_util_jit_log_warn (char const *msg)
 Emit a warning log message. More...
 
int fr_lua_util_log_register (lua_State *L)
 Register utililiary functions in the lua environment. More...
 
void fr_lua_util_set_mctx (module_ctx_t const *mctx)
 Set the thread local instance. More...
 
void fr_lua_util_set_request (request_t *request)
 Set the thread local request. More...
 
char const * fr_lua_version (lua_State *L)
 

Detailed Description

Library function signatures for lua module.

Id
f61ffb1e706c2ae9060d546c63d9cb63667d3541

Definition in file lua.h.


Data Structure Documentation

◆ rlm_lua_t

struct rlm_lua_t

Definition at line 43 of file lua.h.

Data Fields
const char * func_accounting Name of function to run on accounting.
const char * func_authenticate Name of function to run on authentication.
const char * func_authorize Name of function to run on authorization.
const char * func_detach Name of function to run on detach.
const char * func_instantiate Name of function to run on instantiation.
const char * func_post_auth Name of function to run after authentication.
const char * func_preacct Name of function to run on preacct.
const char * func_xlat Name of function to be called for string expansions.
lua_State * interpreter Interpreter used for single threaded mode, and environment tests.
bool jit Whether the linked interpreter is Lua 5.1 or LuaJIT.
const char * module Full path to lua script to load and execute.
bool threads Whether to create new interpreters on a per-instance/per-thread basis, or use a single mutex protected interpreter.

◆ rlm_lua_thread_t

struct rlm_lua_thread_t

Definition at line 62 of file lua.h.

Data Fields
lua_State * interpreter Thread specific interpreter.

Function Documentation

◆ fr_lua_init()

int fr_lua_init ( lua_State **  out,
module_inst_ctx_t const *  mctx 
)

Initialise a new Lua/LuaJIT interpreter.

Creates a new lua_State and verifies all required functions have been loaded correctly.

Parameters
[in]outWhere to write a pointer to the new state.
[in]mctxconfiguration data for the
Returns
0 on success else -1.

Definition at line 893 of file lua.c.

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

◆ fr_lua_isjit()

bool fr_lua_isjit ( lua_State *  L)

Check whether the Lua interpreter were actually linked to is LuaJIT.

Parameters
LLua interpreter.
Returns
true if were running with LuaJIT else false.

Definition at line 591 of file lua.c.

+ Here is the caller graph for this function:

◆ fr_lua_run()

unlang_action_t fr_lua_run ( rlm_rcode_t p_result,
module_ctx_t const *  mctx,
request_t request,
char const *  funcname 
)

Definition at line 754 of file lua.c.

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

◆ fr_lua_util_fr_register()

void fr_lua_util_fr_register ( lua_State *  L)

Definition at line 40 of file util.c.

+ Here is the caller graph for this function:

◆ fr_lua_util_get_mctx()

module_ctx_t const* fr_lua_util_get_mctx ( void  )

Get the thread local instance.

Returns
mctx all helper and C functions callable from Lua should use.

Definition at line 330 of file util.c.

+ Here is the caller graph for this function:

◆ fr_lua_util_get_request()

request_t* fr_lua_util_get_request ( void  )

Get the thread local request.

Returns
request all helper and C functions callable from Lua should use.

Definition at line 348 of file util.c.

+ Here is the caller graph for this function:

◆ fr_lua_util_jit_log_debug()

void fr_lua_util_jit_log_debug ( char const *  msg)

Emit a debug log message.

Parameters
msgto be printed.

Definition at line 154 of file util.c.

◆ fr_lua_util_jit_log_error()

void fr_lua_util_jit_log_error ( char const *  msg)

Emit a error log message.

Parameters
msgto be printed.

Definition at line 187 of file util.c.

◆ fr_lua_util_jit_log_info()

void fr_lua_util_jit_log_info ( char const *  msg)

Emit an info log message.

Parameters
msgto be printed.

Definition at line 165 of file util.c.

◆ fr_lua_util_jit_log_register()

int fr_lua_util_jit_log_register ( lua_State *  L)

Insert cdefs into the lua environment.

For LuaJIT using the FFI is significantly faster than the Lua interface. Help people wishing to use the FFI by inserting cdefs for standard functions.

Parameters
LLua interpreter.
Returns
0 (no arguments).

Definition at line 202 of file util.c.

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

◆ fr_lua_util_jit_log_warn()

void fr_lua_util_jit_log_warn ( char const *  msg)

Emit a warning log message.

Parameters
msgto be printed.

Definition at line 176 of file util.c.

◆ fr_lua_util_log_register()

int fr_lua_util_log_register ( lua_State *  L)

Register utililiary functions in the lua environment.

Parameters
LLua interpreter.
Returns
0 (no arguments).

Definition at line 280 of file util.c.

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

◆ fr_lua_util_set_mctx()

void fr_lua_util_set_mctx ( module_ctx_t const *  mctx)

Set the thread local instance.

Parameters
[in]mctxall helper and C functions callable from Lua should use.

Definition at line 321 of file util.c.

+ Here is the caller graph for this function:

◆ fr_lua_util_set_request()

void fr_lua_util_set_request ( request_t request)

Set the thread local request.

Parameters
[in]requestall helper and C functions callable from Lua should use.

Definition at line 339 of file util.c.

+ Here is the caller graph for this function:

◆ fr_lua_version()

char const* fr_lua_version ( lua_State *  L)

Definition at line 605 of file lua.c.

+ Here is the caller graph for this function: