suricata
util-lua.h
Go to the documentation of this file.
1/* Copyright (C) 2014-2022 Open Information Security Foundation
2 *
3 * You can copy, redistribute or modify this Program under the terms of
4 * the GNU General Public License version 2 as published by the Free
5 * Software Foundation.
6 *
7 * This program is distributed in the hope that it will be useful,
8 * but WITHOUT ANY WARRANTY; without even the implied warranty of
9 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
10 * GNU General Public License for more details.
11 *
12 * You should have received a copy of the GNU General Public License
13 * version 2 along with this program; if not, write to the Free Software
14 * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA
15 * 02110-1301, USA.
16 */
17
18/**
19 * \file
20 *
21 * \author Victor Julien <victor@inliniac.net>
22 */
23
24#ifndef SURICATA_UTIL_LUA_H
25#define SURICATA_UTIL_LUA_H
26
27#include "lua.h"
28#include "lualib.h"
29#include "lauxlib.h"
30
31#include "threadvars.h"
32#include "detect.h"
33
34typedef struct LuaStreamingBuffer_ {
35 const uint8_t *data;
36 uint32_t data_len;
37 uint8_t flags;
39
42
43/* gets */
44
45/** \brief get tv pointer from the lua state */
47
49void *LuaStateGetTX(lua_State *luastate);
50uint64_t LuaStateGetTxId(lua_State *luastate);
51
52/** \brief get flow pointer from lua state
53 *
54 * \retval f flow pointer or NULL if it was not set
55 */
57
59
61
62/** \brief get file pointer from the lua state */
64
65/** \brief get detect engine thread context pointer from the lua state */
67
69
70int LuaStateGetDirection(lua_State *luastate);
71
72/* sets */
73
74void LuaStateSetPacket(lua_State *luastate, Packet *p);
75void LuaStateSetTX(lua_State *luastate, void *tx, const uint64_t tx_id);
76
77/** \brief set a flow pointer in the lua state
78 *
79 * \param f flow pointer
80 */
81void LuaStateSetFlow(lua_State *luastate, Flow *f);
82
84
85void LuaStateSetSignature(lua_State *luastate, const Signature *s);
86
87void LuaStateSetFile(lua_State *luastate, File *file);
88
89void LuaStateSetDetCtx(lua_State *luastate, DetectEngineThreadCtx *det_ctx);
90
92
94
95void LuaStateSetDirection(lua_State *luastate, int direction);
96
97void LuaPrintStack(lua_State *state);
98
99int LuaPushStringBuffer(lua_State *luastate, const uint8_t *input, size_t input_len);
100
101int LuaPushInteger(lua_State *luastate, lua_Integer n);
102
103#endif /* SURICATA_UTIL_LUA_H */
ThreadVars * tv
Flow data structure.
Definition flow.h:356
const uint8_t * data
Definition util-lua.h:35
uint32_t data_len
Definition util-lua.h:36
Signature container.
Definition detect.h:668
Per thread variable structure.
Definition threadvars.h:58
struct lua_State lua_State
void LuaStateSetStreamingBuffer(lua_State *luastate, LuaStreamingBuffer *b)
Definition util-lua.c:262
File * LuaStateGetFile(lua_State *luastate)
get file pointer from the lua state
Definition util-lua.c:223
PacketAlert * LuaStateGetPacketAlert(lua_State *luastate)
get packet alert pointer from the lua state
Definition util-lua.c:191
Signature * LuaStateGetSignature(lua_State *luastate)
get signature pointer from the lua state
Definition util-lua.c:207
void LuaStateSetFlow(lua_State *luastate, Flow *f)
set a flow pointer in the lua state
Definition util-lua.c:176
void LuaPrintStack(lua_State *state)
dump stack from lua state to screen
Definition util-lua.c:286
void LuaStateSetTX(lua_State *luastate, void *tx, const uint64_t tx_id)
Definition util-lua.c:150
int LuaStateGetDirection(lua_State *luastate)
get packet pointer from the lua state
Definition util-lua.c:270
uint64_t LuaStateGetTxId(lua_State *luastate)
get tx id from the lua state
Definition util-lua.c:143
void LuaStateSetDirection(lua_State *luastate, int direction)
Definition util-lua.c:278
int LuaPushStringBuffer(lua_State *luastate, const uint8_t *input, size_t input_len)
Definition util-lua.c:319
DetectEngineThreadCtx * LuaStateGetDetCtx(lua_State *luastate)
get detect engine thread context pointer from the lua state
Definition util-lua.c:239
lua_State * LuaGetState(void)
Definition util-lua.c:57
int LuaPushInteger(lua_State *luastate, lua_Integer n)
Definition util-lua.c:340
Flow * LuaStateGetFlow(lua_State *luastate)
get flow pointer from lua state
Definition util-lua.c:161
Packet * LuaStateGetPacket(lua_State *luastate)
get packet pointer from the lua state
Definition util-lua.c:118
void LuaStateSetSignature(lua_State *luastate, const Signature *s)
Definition util-lua.c:215
void * LuaStateGetTX(lua_State *luastate)
get tx pointer from the lua state
Definition util-lua.c:134
void LuaStateSetPacketAlert(lua_State *luastate, PacketAlert *pa)
Definition util-lua.c:199
void LuaReturnState(lua_State *s)
Definition util-lua.c:64
LuaStreamingBuffer * LuaStateGetStreamingBuffer(lua_State *luastate)
Definition util-lua.c:254
void LuaStateSetPacket(lua_State *luastate, Packet *p)
Definition util-lua.c:126
struct LuaStreamingBuffer_ LuaStreamingBuffer
void LuaStateSetDetCtx(lua_State *luastate, DetectEngineThreadCtx *det_ctx)
Definition util-lua.c:247
void LuaStateSetFile(lua_State *luastate, File *file)
Definition util-lua.c:231
ThreadVars * LuaStateGetThreadVars(lua_State *luastate)
get tv pointer from the lua state
Definition util-lua.c:102
void LuaStateSetThreadVars(lua_State *luastate, ThreadVars *tv)
Definition util-lua.c:110