suricata
util-lua-common.h File Reference
#include "app-layer-protos.h"
Include dependency graph for util-lua-common.h:
This graph shows which files directly or indirectly include this file:

Go to the source code of this file.

Data Structures

struct  SCLuaUserDataHeader_
 
struct  SCLuaTxRef_
 

Macros

#define DEFAULT_LUA_ALLOC_LIMIT   500000
 
#define DEFAULT_LUA_INSTRUCTION_LIMIT   500000
 
#define SCLUA_UD_MAGIC   0x534C5541u /* "SLUA" */
 
#define SCLUA_RESOLVE_TX(L, refp, txvar)
 
#define LUA_ERROR(msg)
 

Typedefs

typedef struct SCLuaUserDataHeader_ SCLuaUserDataHeader
 
typedef struct SCLuaTxRef_ SCLuaTxRef
 

Enumerations

enum  SCLuaUserDataTypes {
  SCLUA_TUD_INVALID = 0, SCLUA_TUD_SHA256 = 1, SCLUA_TUD_SHA1, SCLUA_TUD_MD5,
  SCLUA_TUD_FLOWVAR, SCLUA_TUD_FLOWINT, SCLUA_TUD_BYTEVAR, SCLUA_TUD_DATASET,
  SCLUA_TUD_RULE, SCLUA_TUD_FILE, SCLUA_TUD_FLOW, SCLUA_TUD_PACKET,
  SCLUA_TUD_TLS_STATE, SCLUA_TUD_HTTP_TX, SCLUA_TUD_DNS_TX, SCLUA_TUD_SMTP_TX,
  SCLUA_TUD_SSH_TX, SCLUA_TUD_NTP_TX, SCLUA_TUD_JA3_TX, SCLUA_TUD_DNP3_POINTS
}
 

Functions

void SCLuaTxRefInit (lua_State *L, SCLuaTxRef *ref, uint64_t tx_id)
 
int SCLuaTxRefResolve (lua_State *L, const SCLuaTxRef *ref, void **tx)
 
void * SCLuaNewUserData (lua_State *L, uint32_t type_id, size_t size)
 
void * SCLuaCheckUserData (lua_State *L, int idx, const char *mt, uint32_t type_id)
 
void * SCLuaCheckUserDataPayload (lua_State *L, int idx, const char *mt, uint32_t type_id)
 
void * SCLuaCheckUserDataSoft (lua_State *L, int idx, const char *mt, uint32_t type_id)
 
void * SCLuaTestUserData (lua_State *L, int idx, const char *mt, uint32_t type_id)
 
int LuaCallbackError (lua_State *luastate, const char *msg)
 
const char * LuaGetStringArgument (lua_State *luastate, int argc)
 
void LuaPushTableKeyValueInt (lua_State *luastate, const char *key, int value)
 
void LuaPushTableKeyValueBoolean (lua_State *luastate, const char *key, bool value)
 
void LuaPushTableKeyValueString (lua_State *luastate, const char *key, const char *value)
 Push a key plus string value to the stack. More...
 
void LuaPushTableKeyValueLString (lua_State *luastate, const char *key, const char *value, size_t len)
 Push a key plus string value with length to the stack. More...
 
void LuaPushTableKeyValueArray (lua_State *luastate, const char *key, const uint8_t *value, size_t len)
 
int LuaStateNeedProto (lua_State *luastate, AppProto alproto)
 
void SCLuaCommonRegisterTests (void)
 

Detailed Description

Macro Definition Documentation

◆ DEFAULT_LUA_ALLOC_LIMIT

#define DEFAULT_LUA_ALLOC_LIMIT   500000

Definition at line 30 of file util-lua-common.h.

◆ DEFAULT_LUA_INSTRUCTION_LIMIT

#define DEFAULT_LUA_INSTRUCTION_LIMIT   500000

Definition at line 31 of file util-lua-common.h.

◆ LUA_ERROR

#define LUA_ERROR (   msg)
Value:
LuaCallbackError(luastate, (msg)); \
return 2

Definition at line 196 of file util-lua-common.h.

◆ SCLUA_RESOLVE_TX

#define SCLUA_RESOLVE_TX (   L,
  refp,
  txvar 
)
Value:
void *txvar = NULL; \
if (!SCLuaTxRefResolve(L, (refp), &(txvar))) { \
lua_pushnil(L); \
return 1; \
}

Definition at line 129 of file util-lua-common.h.

◆ SCLUA_UD_MAGIC

#define SCLUA_UD_MAGIC   0x534C5541u /* "SLUA" */

Definition at line 42 of file util-lua-common.h.

Typedef Documentation

◆ SCLuaTxRef

typedef struct SCLuaTxRef_ SCLuaTxRef

◆ SCLuaUserDataHeader

Enumeration Type Documentation

◆ SCLuaUserDataTypes

Enumerator
SCLUA_TUD_INVALID 
SCLUA_TUD_SHA256 
SCLUA_TUD_SHA1 
SCLUA_TUD_MD5 
SCLUA_TUD_FLOWVAR 
SCLUA_TUD_FLOWINT 
SCLUA_TUD_BYTEVAR 
SCLUA_TUD_DATASET 
SCLUA_TUD_RULE 
SCLUA_TUD_FILE 
SCLUA_TUD_FLOW 
SCLUA_TUD_PACKET 
SCLUA_TUD_TLS_STATE 
SCLUA_TUD_HTTP_TX 
SCLUA_TUD_DNS_TX 
SCLUA_TUD_SMTP_TX 
SCLUA_TUD_SSH_TX 
SCLUA_TUD_NTP_TX 
SCLUA_TUD_JA3_TX 
SCLUA_TUD_DNP3_POINTS 

Definition at line 48 of file util-lua-common.h.

Function Documentation

◆ LuaCallbackError()

int LuaCallbackError ( lua_State *  luastate,
const char *  msg 
)

Definition at line 218 of file util-lua-common.c.

◆ LuaGetStringArgument()

const char* LuaGetStringArgument ( lua_State *  luastate,
int  argc 
)

Definition at line 225 of file util-lua-common.c.

◆ LuaPushTableKeyValueArray()

void LuaPushTableKeyValueArray ( lua_State *  luastate,
const char *  key,
const uint8_t *  value,
size_t  len 
)

Definition at line 273 of file util-lua-common.c.

References len, and LuaPushStringBuffer().

Here is the call graph for this function:

◆ LuaPushTableKeyValueBoolean()

void LuaPushTableKeyValueBoolean ( lua_State *  luastate,
const char *  key,
bool  value 
)

Definition at line 245 of file util-lua-common.c.

◆ LuaPushTableKeyValueInt()

void LuaPushTableKeyValueInt ( lua_State *  luastate,
const char *  key,
int  value 
)

Definition at line 238 of file util-lua-common.c.

◆ LuaPushTableKeyValueLString()

void LuaPushTableKeyValueLString ( lua_State *  luastate,
const char *  key,
const char *  value,
size_t  len 
)

Push a key plus string value with length to the stack.

Definition at line 265 of file util-lua-common.c.

References len.

◆ LuaPushTableKeyValueString()

void LuaPushTableKeyValueString ( lua_State *  luastate,
const char *  key,
const char *  value 
)

Push a key plus string value to the stack.

If value is NULL, string "(null")" will be put on the stack.

Definition at line 256 of file util-lua-common.c.

◆ LuaStateNeedProto()

int LuaStateNeedProto ( lua_State *  luastate,
AppProto  alproto 
)

Definition at line 289 of file util-lua-common.c.

References Flow_::alproto, and LuaStateGetFlow().

Here is the call graph for this function:

◆ SCLuaCheckUserData()

void* SCLuaCheckUserData ( lua_State *  L,
int  idx,
const char *  mt,
uint32_t  type_id 
)

◆ SCLuaCheckUserDataPayload()

void* SCLuaCheckUserDataPayload ( lua_State *  L,
int  idx,
const char *  mt,
uint32_t  type_id 
)

Definition at line 137 of file util-lua-common.c.

References SCLuaUserDataHeader_::magic, SCLUA_UD_MAGIC, and SCLuaUserDataHeader_::type_id.

Referenced by SCLuaCheckUserDataSoft().

Here is the caller graph for this function:

◆ SCLuaCheckUserDataSoft()

void* SCLuaCheckUserDataSoft ( lua_State *  L,
int  idx,
const char *  mt,
uint32_t  type_id 
)

Definition at line 151 of file util-lua-common.c.

References SCLuaCheckUserDataPayload().

Here is the call graph for this function:

◆ SCLuaCommonRegisterTests()

void SCLuaCommonRegisterTests ( void  )

Definition at line 504 of file util-lua-common.c.

References UtRegisterTest().

Here is the call graph for this function:

◆ SCLuaNewUserData()

void* SCLuaNewUserData ( lua_State *  L,
uint32_t  type_id,
size_t  size 
)

◆ SCLuaTestUserData()

void* SCLuaTestUserData ( lua_State *  L,
int  idx,
const char *  mt,
uint32_t  type_id 
)

Definition at line 123 of file util-lua-common.c.

◆ SCLuaTxRefInit()

void SCLuaTxRefInit ( lua_State *  L,
SCLuaTxRef *  ref,
uint64_t  tx_id 
)

◆ SCLuaTxRefResolve()

SCLuaTxRefResolve
int SCLuaTxRefResolve(lua_State *L, const SCLuaTxRef *ref, void **tx)
Definition: util-lua-common.c:182
LuaCallbackError
int LuaCallbackError(lua_State *luastate, const char *msg)
Definition: util-lua-common.c:218