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 
34 typedef struct LuaStreamingBuffer_ {
35  const uint8_t *data;
36  uint32_t data_len;
37  uint8_t flags;
39 
40 lua_State *LuaGetState(void);
41 void LuaReturnState(lua_State *s);
42 
43 /* gets */
44 
45 /** \brief get tv pointer from the lua state */
47 
49 void *LuaStateGetTX(lua_State *luastate);
50 uint64_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  */
56 Flow *LuaStateGetFlow(lua_State *luastate);
57 
59 
61 
62 /** \brief get file pointer from the lua state */
63 File *LuaStateGetFile(lua_State *luastate);
64 
65 /** \brief get detect engine thread context pointer from the lua state */
67 
69 
70 int LuaStateGetDirection(lua_State *luastate);
71 
72 /* sets */
73 
74 void LuaStateSetPacket(lua_State *luastate, Packet *p);
75 void 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  */
81 void LuaStateSetFlow(lua_State *luastate, Flow *f);
82 
83 void LuaStateSetPacketAlert(lua_State *luastate, PacketAlert *pa);
84 
85 void LuaStateSetSignature(lua_State *luastate, const Signature *s);
86 
87 void LuaStateSetFile(lua_State *luastate, File *file);
88 
89 void LuaStateSetDetCtx(lua_State *luastate, DetectEngineThreadCtx *det_ctx);
90 
92 
94 
95 void LuaStateSetDirection(lua_State *luastate, int direction);
96 
97 void LuaPrintStack(lua_State *state);
98 
99 int LuaPushStringBuffer(lua_State *luastate, const uint8_t *input, size_t input_len);
100 
101 int LuaPushInteger(lua_State *luastate, lua_Integer n);
102 
103 #endif /* SURICATA_UTIL_LUA_H */
LuaStateSetDirection
void LuaStateSetDirection(lua_State *luastate, int direction)
Definition: util-lua.c:278
LuaStreamingBuffer_
Definition: util-lua.h:34
LuaStateGetDirection
int LuaStateGetDirection(lua_State *luastate)
get packet pointer from the lua state
Definition: util-lua.c:270
LuaStateSetDetCtx
void LuaStateSetDetCtx(lua_State *luastate, DetectEngineThreadCtx *det_ctx)
Definition: util-lua.c:247
Flow_
Flow data structure.
Definition: flow.h:360
LuaStateSetSignature
void LuaStateSetSignature(lua_State *luastate, const Signature *s)
Definition: util-lua.c:215
LuaStateSetFile
void LuaStateSetFile(lua_State *luastate, File *file)
Definition: util-lua.c:231
LuaReturnState
void LuaReturnState(lua_State *s)
Definition: util-lua.c:64
LuaStateGetFlow
Flow * LuaStateGetFlow(lua_State *luastate)
get flow pointer from lua state
Definition: util-lua.c:161
LuaStateSetPacket
void LuaStateSetPacket(lua_State *luastate, Packet *p)
Definition: util-lua.c:126
LuaStateGetPacketAlert
PacketAlert * LuaStateGetPacketAlert(lua_State *luastate)
get packet alert pointer from the lua state
Definition: util-lua.c:191
lua_State
struct lua_State lua_State
Definition: suricata-common.h:500
LuaStreamingBuffer
struct LuaStreamingBuffer_ LuaStreamingBuffer
LuaStateGetFile
File * LuaStateGetFile(lua_State *luastate)
get file pointer from the lua state
Definition: util-lua.c:223
LuaStateSetTX
void LuaStateSetTX(lua_State *luastate, void *tx, const uint64_t tx_id)
Definition: util-lua.c:150
LuaPushStringBuffer
int LuaPushStringBuffer(lua_State *luastate, const uint8_t *input, size_t input_len)
Definition: util-lua.c:319
LuaStateGetTX
void * LuaStateGetTX(lua_State *luastate)
get tx pointer from the lua state
Definition: util-lua.c:134
DetectEngineThreadCtx_
Definition: detect.h:1090
detect.h
ThreadVars_
Per thread variable structure.
Definition: threadvars.h:57
Packet_
Definition: decode.h:479
LuaStateGetPacket
Packet * LuaStateGetPacket(lua_State *luastate)
get packet pointer from the lua state
Definition: util-lua.c:118
LuaStateSetStreamingBuffer
void LuaStateSetStreamingBuffer(lua_State *luastate, LuaStreamingBuffer *b)
Definition: util-lua.c:262
LuaGetState
lua_State * LuaGetState(void)
Definition: util-lua.c:57
LuaPushInteger
int LuaPushInteger(lua_State *luastate, lua_Integer n)
Definition: util-lua.c:340
LuaPrintStack
void LuaPrintStack(lua_State *state)
dump stack from lua state to screen
Definition: util-lua.c:286
LuaStateGetThreadVars
ThreadVars * LuaStateGetThreadVars(lua_State *luastate)
get tv pointer from the lua state
Definition: util-lua.c:102
File_
Definition: util-file.h:79
LuaStreamingBuffer_::data_len
uint32_t data_len
Definition: util-lua.h:36
LuaStreamingBuffer_::data
const uint8_t * data
Definition: util-lua.h:35
LuaStateGetSignature
Signature * LuaStateGetSignature(lua_State *luastate)
get signature pointer from the lua state
Definition: util-lua.c:207
tv
ThreadVars * tv
Definition: fuzz_decodepcapfile.c:32
threadvars.h
Signature_
Signature container.
Definition: detect.h:601
LuaStateGetStreamingBuffer
LuaStreamingBuffer * LuaStateGetStreamingBuffer(lua_State *luastate)
Definition: util-lua.c:254
LuaStateSetThreadVars
void LuaStateSetThreadVars(lua_State *luastate, ThreadVars *tv)
Definition: util-lua.c:110
LuaStateSetFlow
void LuaStateSetFlow(lua_State *luastate, Flow *f)
set a flow pointer in the lua state
Definition: util-lua.c:176
PacketAlert_
Definition: decode.h:245
LuaStateGetDetCtx
DetectEngineThreadCtx * LuaStateGetDetCtx(lua_State *luastate)
get detect engine thread context pointer from the lua state
Definition: util-lua.c:239
LuaStateGetTxId
uint64_t LuaStateGetTxId(lua_State *luastate)
get tx id from the lua state
Definition: util-lua.c:143
LuaStateSetPacketAlert
void LuaStateSetPacketAlert(lua_State *luastate, PacketAlert *pa)
Definition: util-lua.c:199
LuaStreamingBuffer_::flags
uint8_t flags
Definition: util-lua.h:37