suricata
util-lua.c File Reference
#include "suricata-common.h"
#include "detect.h"
#include "pkt-var.h"
#include "conf.h"
#include "threads.h"
#include "threadvars.h"
#include "tm-threads.h"
#include "util-print.h"
#include "util-unittest.h"
#include "util-debug.h"
#include "output.h"
#include "app-layer-htp.h"
#include "app-layer.h"
#include "app-layer-parser.h"
#include "util-privs.h"
#include "util-buffer.h"
#include "util-proto-name.h"
#include "util-logopenfile.h"
#include "util-time.h"
#include "lua.h"
#include "lualib.h"
#include "lauxlib.h"
#include "util-lua.h"
#include "util-lua-sandbox.h"
Include dependency graph for util-lua.c:

Go to the source code of this file.

Functions

lua_StateLuaGetState (void)
 
void LuaReturnState (lua_State *s)
 
ThreadVarsLuaStateGetThreadVars (lua_State *luastate)
 get tv pointer from the lua state More...
 
void LuaStateSetThreadVars (lua_State *luastate, ThreadVars *tv)
 
PacketLuaStateGetPacket (lua_State *luastate)
 get packet pointer from the lua state More...
 
void LuaStateSetPacket (lua_State *luastate, Packet *p)
 
void * LuaStateGetTX (lua_State *luastate)
 get tx pointer from the lua state More...
 
uint64_t LuaStateGetTxId (lua_State *luastate)
 get tx id from the lua state More...
 
void LuaStateSetTX (lua_State *luastate, void *txptr, const uint64_t tx_id)
 
FlowLuaStateGetFlow (lua_State *luastate)
 get flow pointer from lua state More...
 
void LuaStateSetFlow (lua_State *luastate, Flow *f)
 set a flow pointer in the lua state More...
 
PacketAlertLuaStateGetPacketAlert (lua_State *luastate)
 get packet alert pointer from the lua state More...
 
void LuaStateSetPacketAlert (lua_State *luastate, PacketAlert *pa)
 
SignatureLuaStateGetSignature (lua_State *luastate)
 get signature pointer from the lua state More...
 
void LuaStateSetSignature (lua_State *luastate, const Signature *s)
 
FileLuaStateGetFile (lua_State *luastate)
 get file pointer from the lua state More...
 
void LuaStateSetFile (lua_State *luastate, File *file)
 
DetectEngineThreadCtxLuaStateGetDetCtx (lua_State *luastate)
 get DetectEngineThreadCtx pointer from the lua state More...
 
void LuaStateSetDetCtx (lua_State *luastate, DetectEngineThreadCtx *det_ctx)
 
LuaStreamingBufferLuaStateGetStreamingBuffer (lua_State *luastate)
 
void LuaStateSetStreamingBuffer (lua_State *luastate, LuaStreamingBuffer *b)
 
int LuaStateGetDirection (lua_State *luastate)
 get packet pointer from the lua state More...
 
void LuaStateSetDirection (lua_State *luastate, int direction)
 
void LuaPrintStack (lua_State *state)
 dump stack from lua state to screen More...
 
int LuaPushStringBuffer (lua_State *luastate, const uint8_t *input, size_t input_len)
 
int LuaPushInteger (lua_State *luastate, lua_Integer n)
 

Variables

const char lua_ext_key_tv [] = "suricata:lua:tv:ptr"
 
const char lua_ext_key_tx [] = "suricata:lua:tx:ptr"
 
const char lua_ext_key_tx_id [] = "suricata:lua:tx_id"
 
const char lua_ext_key_p [] = "suricata:lua:pkt:ptr"
 
const char lua_ext_key_flow [] = "suricata:lua:flow:ptr"
 
const char lua_ext_key_flow_lock_hint [] = "suricata:lua:flow:lock_hint"
 
const char lua_ext_key_direction [] = "suricata:lua:direction"
 
const char lua_ext_key_pa [] = "suricata:lua:pkt:alert:ptr"
 
const char lua_ext_key_s [] = "suricata:lua:signature:ptr"
 
const char lua_ext_key_file [] = "suricata:lua:file:ptr"
 
const char lua_ext_key_det_ctx [] = "suricata:lua:det_ctx:ptr"
 
const char lua_ext_key_streaming_buffer [] = "suricata:lua:streaming_buffer:ptr"
 

Detailed Description

Author
Victor Julien victo.nosp@m.r@in.nosp@m.linia.nosp@m.c.ne.nosp@m.t

Common function for Lua

Definition in file util-lua.c.

Function Documentation

◆ LuaGetState()

lua_State* LuaGetState ( void  )

Definition at line 57 of file util-lua.c.

◆ LuaPrintStack()

void LuaPrintStack ( lua_State state)

dump stack from lua state to screen

Definition at line 286 of file util-lua.c.

References type.

◆ LuaPushInteger()

int LuaPushInteger ( lua_State luastate,
lua_Integer  n 
)

Definition at line 340 of file util-lua.c.

◆ LuaPushStringBuffer()

int LuaPushStringBuffer ( lua_State luastate,
const uint8_t *  input,
size_t  input_len 
)

Definition at line 319 of file util-lua.c.

Referenced by DetectLuaMatchBuffer(), DNP3PushPoint(), and LuaPushTableKeyValueArray().

Here is the caller graph for this function:

◆ LuaReturnState()

void LuaReturnState ( lua_State s)

Definition at line 64 of file util-lua.c.

◆ LuaStateGetDetCtx()

DetectEngineThreadCtx* LuaStateGetDetCtx ( lua_State luastate)

get DetectEngineThreadCtx pointer from the lua state

get detect engine thread context pointer from the lua state

Definition at line 239 of file util-lua.c.

References lua_ext_key_det_ctx.

◆ LuaStateGetDirection()

int LuaStateGetDirection ( lua_State luastate)

get packet pointer from the lua state

Definition at line 270 of file util-lua.c.

References lua_ext_key_direction.

◆ LuaStateGetFile()

File* LuaStateGetFile ( lua_State luastate)

get file pointer from the lua state

Definition at line 223 of file util-lua.c.

References lua_ext_key_file.

◆ LuaStateGetFlow()

Flow* LuaStateGetFlow ( lua_State luastate)

get flow pointer from lua state

Return values
fflow pointer or NULL if it was not set

Definition at line 161 of file util-lua.c.

References lua_ext_key_flow, and lua_ext_key_flow_lock_hint.

Referenced by LuaStateNeedProto().

Here is the caller graph for this function:

◆ LuaStateGetPacket()

Packet* LuaStateGetPacket ( lua_State luastate)

get packet pointer from the lua state

Definition at line 118 of file util-lua.c.

References lua_ext_key_p.

◆ LuaStateGetPacketAlert()

PacketAlert* LuaStateGetPacketAlert ( lua_State luastate)

get packet alert pointer from the lua state

Definition at line 191 of file util-lua.c.

References lua_ext_key_pa.

◆ LuaStateGetSignature()

Signature* LuaStateGetSignature ( lua_State luastate)

get signature pointer from the lua state

Definition at line 207 of file util-lua.c.

References lua_ext_key_s.

◆ LuaStateGetStreamingBuffer()

LuaStreamingBuffer* LuaStateGetStreamingBuffer ( lua_State luastate)

Definition at line 254 of file util-lua.c.

References lua_ext_key_streaming_buffer.

◆ LuaStateGetThreadVars()

ThreadVars* LuaStateGetThreadVars ( lua_State luastate)

get tv pointer from the lua state

Definition at line 102 of file util-lua.c.

References lua_ext_key_tv, and tv.

◆ LuaStateGetTX()

void* LuaStateGetTX ( lua_State luastate)

get tx pointer from the lua state

Definition at line 134 of file util-lua.c.

References lua_ext_key_tx.

◆ LuaStateGetTxId()

uint64_t LuaStateGetTxId ( lua_State luastate)

get tx id from the lua state

Definition at line 143 of file util-lua.c.

References lua_ext_key_tx_id.

◆ LuaStateSetDetCtx()

void LuaStateSetDetCtx ( lua_State luastate,
DetectEngineThreadCtx det_ctx 
)

Definition at line 247 of file util-lua.c.

References lua_ext_key_det_ctx.

◆ LuaStateSetDirection()

void LuaStateSetDirection ( lua_State luastate,
int  direction 
)

Definition at line 278 of file util-lua.c.

References lua_ext_key_direction.

◆ LuaStateSetFile()

void LuaStateSetFile ( lua_State luastate,
File file 
)

Definition at line 231 of file util-lua.c.

References lua_ext_key_file.

◆ LuaStateSetFlow()

void LuaStateSetFlow ( lua_State luastate,
Flow f 
)

set a flow pointer in the lua state

Parameters
fflow pointer

Definition at line 176 of file util-lua.c.

References lua_ext_key_flow, and lua_ext_key_flow_lock_hint.

◆ LuaStateSetPacket()

void LuaStateSetPacket ( lua_State luastate,
Packet p 
)

Definition at line 126 of file util-lua.c.

References lua_ext_key_p.

◆ LuaStateSetPacketAlert()

void LuaStateSetPacketAlert ( lua_State luastate,
PacketAlert pa 
)

Definition at line 199 of file util-lua.c.

References lua_ext_key_pa.

◆ LuaStateSetSignature()

void LuaStateSetSignature ( lua_State luastate,
const Signature s 
)

Definition at line 215 of file util-lua.c.

References lua_ext_key_s.

◆ LuaStateSetStreamingBuffer()

void LuaStateSetStreamingBuffer ( lua_State luastate,
LuaStreamingBuffer b 
)

Definition at line 262 of file util-lua.c.

References lua_ext_key_streaming_buffer.

◆ LuaStateSetThreadVars()

void LuaStateSetThreadVars ( lua_State luastate,
ThreadVars tv 
)

Definition at line 110 of file util-lua.c.

References lua_ext_key_tv, and tv.

◆ LuaStateSetTX()

void LuaStateSetTX ( lua_State luastate,
void *  txptr,
const uint64_t  tx_id 
)

Definition at line 150 of file util-lua.c.

References lua_ext_key_tx, and lua_ext_key_tx_id.

Variable Documentation

◆ lua_ext_key_det_ctx

const char lua_ext_key_det_ctx[] = "suricata:lua:det_ctx:ptr"

Definition at line 97 of file util-lua.c.

Referenced by LuaStateGetDetCtx(), and LuaStateSetDetCtx().

◆ lua_ext_key_direction

const char lua_ext_key_direction[] = "suricata:lua:direction"

Definition at line 88 of file util-lua.c.

Referenced by LuaStateGetDirection(), and LuaStateSetDirection().

◆ lua_ext_key_file

const char lua_ext_key_file[] = "suricata:lua:file:ptr"

Definition at line 95 of file util-lua.c.

Referenced by LuaStateGetFile(), and LuaStateSetFile().

◆ lua_ext_key_flow

const char lua_ext_key_flow[] = "suricata:lua:flow:ptr"

Definition at line 84 of file util-lua.c.

Referenced by LuaStateGetFlow(), and LuaStateSetFlow().

◆ lua_ext_key_flow_lock_hint

const char lua_ext_key_flow_lock_hint[] = "suricata:lua:flow:lock_hint"

Definition at line 86 of file util-lua.c.

Referenced by LuaStateGetFlow(), and LuaStateSetFlow().

◆ lua_ext_key_p

const char lua_ext_key_p[] = "suricata:lua:pkt:ptr"

Definition at line 82 of file util-lua.c.

Referenced by LuaStateGetPacket(), and LuaStateSetPacket().

◆ lua_ext_key_pa

const char lua_ext_key_pa[] = "suricata:lua:pkt:alert:ptr"

Definition at line 91 of file util-lua.c.

Referenced by LuaStateGetPacketAlert(), and LuaStateSetPacketAlert().

◆ lua_ext_key_s

const char lua_ext_key_s[] = "suricata:lua:signature:ptr"

Definition at line 93 of file util-lua.c.

Referenced by LuaStateGetSignature(), and LuaStateSetSignature().

◆ lua_ext_key_streaming_buffer

const char lua_ext_key_streaming_buffer[] = "suricata:lua:streaming_buffer:ptr"

Definition at line 99 of file util-lua.c.

Referenced by LuaStateGetStreamingBuffer(), and LuaStateSetStreamingBuffer().

◆ lua_ext_key_tv

const char lua_ext_key_tv[] = "suricata:lua:tv:ptr"

Definition at line 76 of file util-lua.c.

Referenced by LuaStateGetThreadVars(), and LuaStateSetThreadVars().

◆ lua_ext_key_tx

const char lua_ext_key_tx[] = "suricata:lua:tx:ptr"

Definition at line 78 of file util-lua.c.

Referenced by LuaStateGetTX(), and LuaStateSetTX().

◆ lua_ext_key_tx_id

const char lua_ext_key_tx_id[] = "suricata:lua:tx_id"

Definition at line 80 of file util-lua.c.

Referenced by LuaStateGetTxId(), and LuaStateSetTX().