68 while (lua_gettop(s) > 0) {
105 lua_gettable(luastate, LUA_REGISTRYINDEX);
106 void *
tv = lua_touserdata(luastate, -1);
113 lua_pushlightuserdata(luastate, (
void *)
tv);
114 lua_settable(luastate, LUA_REGISTRYINDEX);
121 lua_gettable(luastate, LUA_REGISTRYINDEX);
122 void *p = lua_touserdata(luastate, -1);
129 lua_pushlightuserdata(luastate, (
void *)p);
130 lua_settable(luastate, LUA_REGISTRYINDEX);
137 lua_gettable(luastate, LUA_REGISTRYINDEX);
138 void *tx = lua_touserdata(luastate, -1);
146 lua_gettable(luastate, LUA_REGISTRYINDEX);
147 uint64_t tx_id = lua_tointeger(luastate, -1);
153 lua_pushlightuserdata(luastate, (
void *)txptr);
154 lua_settable(luastate, LUA_REGISTRYINDEX);
157 lua_pushinteger(luastate, tx_id);
158 lua_settable(luastate, LUA_REGISTRYINDEX);
166 lua_gettable(luastate, LUA_REGISTRYINDEX);
167 f = lua_touserdata(luastate, -1);
171 lua_gettable(luastate, LUA_REGISTRYINDEX);
180 lua_pushlightuserdata(luastate, (
void *)f);
181 lua_settable(luastate, LUA_REGISTRYINDEX);
186 lua_pushboolean(luastate, 0);
187 lua_settable(luastate, LUA_REGISTRYINDEX);
194 lua_gettable(luastate, LUA_REGISTRYINDEX);
195 void *pa = lua_touserdata(luastate, -1);
202 lua_pushlightuserdata(luastate, (
void *)pa);
203 lua_settable(luastate, LUA_REGISTRYINDEX);
210 lua_gettable(luastate, LUA_REGISTRYINDEX);
211 void *s = lua_touserdata(luastate, -1);
218 lua_pushlightuserdata(luastate, (
void *)s);
219 lua_settable(luastate, LUA_REGISTRYINDEX);
226 lua_gettable(luastate, LUA_REGISTRYINDEX);
227 void *file = lua_touserdata(luastate, -1);
234 lua_pushlightuserdata(luastate, (
void *)file);
235 lua_settable(luastate, LUA_REGISTRYINDEX);
242 lua_gettable(luastate, LUA_REGISTRYINDEX);
243 void *det_ctx = lua_touserdata(luastate, -1);
250 lua_pushlightuserdata(luastate, (
void *)det_ctx);
251 lua_settable(luastate, LUA_REGISTRYINDEX);
257 lua_gettable(luastate, LUA_REGISTRYINDEX);
258 void *b = lua_touserdata(luastate, -1);
265 lua_pushlightuserdata(luastate, (
void *)b);
266 lua_settable(luastate, LUA_REGISTRYINDEX);
273 lua_gettable(luastate, LUA_REGISTRYINDEX);
274 int dir = lua_toboolean(luastate, -1);
281 lua_pushboolean(luastate, direction);
282 lua_settable(luastate, LUA_REGISTRYINDEX);
287 int size = lua_gettop(state);
290 for (i = 1; i <= size; i++) {
291 int type = lua_type(state, i);
292 printf(
"Stack size=%d, level=%d, type=%d, ", size, i,
type);
296 printf(
"function %s", lua_tostring(state, i) ?
"true" :
"false");
299 printf(
"bool %s", lua_toboolean(state, i) ?
"true" :
"false");
302 printf(
"number %g", lua_tonumber(state, i));
305 printf(
"string `%s'", lua_tostring(state, i));
308 printf(
"table `%s'", lua_tostring(state, i));
311 printf(
"other %s", lua_typename(state,
type));
321 if (input_len % 4 != 0) {
326 size_t buflen = input_len + 1 + ((input_len + 1) % 4);
328 memset(buf, 0x00, buflen);
329 memcpy(buf, input, input_len);
330 buf[input_len] =
'\0';
333 lua_pushlstring(luastate, (
char *)buf, input_len);
335 lua_pushlstring(luastate, (
char *)input, input_len);
342 lua_pushinteger(luastate, n);
Per thread variable structure.
struct lua_State lua_State
void LuaStateSetStreamingBuffer(lua_State *luastate, LuaStreamingBuffer *b)
const char lua_ext_key_file[]
const char lua_ext_key_flow_lock_hint[]
const char lua_ext_key_tv[]
File * LuaStateGetFile(lua_State *luastate)
get file pointer from the lua state
PacketAlert * LuaStateGetPacketAlert(lua_State *luastate)
get packet alert pointer from the lua state
Signature * LuaStateGetSignature(lua_State *luastate)
get signature pointer from the lua state
void LuaStateSetFlow(lua_State *luastate, Flow *f)
set a flow pointer in the lua state
void LuaPrintStack(lua_State *state)
dump stack from lua state to screen
int LuaStateGetDirection(lua_State *luastate)
get packet pointer from the lua state
uint64_t LuaStateGetTxId(lua_State *luastate)
get tx id from the lua state
const char lua_ext_key_s[]
void LuaStateSetDirection(lua_State *luastate, int direction)
int LuaPushStringBuffer(lua_State *luastate, const uint8_t *input, size_t input_len)
const char lua_ext_key_p[]
DetectEngineThreadCtx * LuaStateGetDetCtx(lua_State *luastate)
get DetectEngineThreadCtx pointer from the lua state
lua_State * LuaGetState(void)
int LuaPushInteger(lua_State *luastate, lua_Integer n)
Flow * LuaStateGetFlow(lua_State *luastate)
get flow pointer from lua state
Packet * LuaStateGetPacket(lua_State *luastate)
get packet pointer from the lua state
const char lua_ext_key_streaming_buffer[]
const char lua_ext_key_tx_id[]
void LuaStateSetSignature(lua_State *luastate, const Signature *s)
void * LuaStateGetTX(lua_State *luastate)
get tx pointer from the lua state
void LuaStateSetPacketAlert(lua_State *luastate, PacketAlert *pa)
void LuaReturnState(lua_State *s)
const char lua_ext_key_tx[]
const char lua_ext_key_direction[]
LuaStreamingBuffer * LuaStateGetStreamingBuffer(lua_State *luastate)
const char lua_ext_key_det_ctx[]
void LuaStateSetPacket(lua_State *luastate, Packet *p)
void LuaStateSetDetCtx(lua_State *luastate, DetectEngineThreadCtx *det_ctx)
void LuaStateSetFile(lua_State *luastate, File *file)
void LuaStateSetTX(lua_State *luastate, void *txptr, const uint64_t tx_id)
const char lua_ext_key_flow[]
ThreadVars * LuaStateGetThreadVars(lua_State *luastate)
get tv pointer from the lua state
const char lua_ext_key_pa[]
void LuaStateSetThreadVars(lua_State *luastate, ThreadVars *tv)