30static const char suricata_flowvar_mt[] =
"suricata:flowvar:mt";
36 lua_gettable(luastate, LUA_REGISTRYINDEX);
37 ld = lua_touserdata(luastate, -1);
50static int LuaFlowvarRegister(
lua_State *L)
53 const char *
name = luaL_checkstring(L, 1);
54 uint32_t *flowvar_id = lua_newuserdata(L,
sizeof(*flowvar_id));
56 if (*flowvar_id == 0) {
57 return luaL_error(L,
"failed to register flowvar");
61 luaL_getmetatable(L, suricata_flowvar_mt);
62 lua_setmetatable(L, -2);
69 const char *
name = luaL_checkstring(L, 1);
70 uint32_t *flowvar_id = lua_newuserdata(L,
sizeof(*flowvar_id));
72 if (*flowvar_id == 0) {
73 return luaL_error(L,
"flowvar does not exist");
76 luaL_getmetatable(L, suricata_flowvar_mt);
77 lua_setmetatable(L, -2);
84 uint32_t *flowvar_id = luaL_checkudata(L, 1, suricata_flowvar_mt);
101 const char *value = luaL_checkstring(L, 2);
102 const int len = (int)luaL_checkinteger(L, 3);
103 uint32_t *flowvar_id = luaL_checkudata(L, 1, suricata_flowvar_mt);
106 return luaL_error(L,
"no flow");
111 return luaL_error(L,
"alloc failure");
113 memcpy(buf, value,
len);
120static const luaL_Reg flowvarlib[] = {
122 {
"register", LuaFlowvarRegister, },
123 {
"get", LuaFlowvarGet },
128static const luaL_Reg flowvarmt[] = {
130 {
"value", LuaFlowvarValue, },
131 {
"set", LuaFlowvarSet, },
138 luaL_newmetatable(L, suricata_flowvar_mt);
139 lua_pushvalue(L, -1);
140 lua_setfield(L, -2,
"__index");
141 luaL_setfuncs(L, flowvarmt, 0);
143 luaL_newlib(L, flowvarlib);
const char luaext_key_ld[]
FlowVar * FlowVarGet(Flow *f, uint32_t idx)
get the flowvar with index 'idx' from the flow
void FlowVarAddIdValue(Flow *f, uint32_t idx, uint8_t *value, uint16_t size)
uint32_t flowvar[DETECT_LUA_MAX_FLOWVARS]
union FlowVar_::@124 data
struct lua_State lua_State
int LuaCallbackError(lua_State *luastate, const char *msg)
int LuaLoadFlowvarLib(lua_State *L)
int LuaPushStringBuffer(lua_State *luastate, const uint8_t *input, size_t input_len)
Flow * LuaStateGetFlow(lua_State *luastate)
get flow pointer from lua state
uint32_t VarNameStoreRegister(const char *name, const enum VarTypes type)
uint32_t VarNameStoreLookupByName(const char *name, const enum VarTypes type)
find name for id+type at packet time. As the active store won't be modified, we don't need locks.