]>
Commit | Line | Data |
---|---|---|
599ec36b VJ |
1 | /* Copyright (C) 2014 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 __UTIL_LUA_H__ | |
25 | #define __UTIL_LUA_H__ | |
26 | ||
102f0c74 JI |
27 | #ifndef HAVE_LUA |
28 | ||
29 | /* If we don't have Lua, create a typedef for lua_State so the | |
30 | * exported Lua functions don't fail the build. */ | |
31 | typedef void lua_State; | |
32 | ||
33 | #else | |
34 | ||
35 | #include <lua.h> | |
36 | #include <lualib.h> | |
37 | #include <lauxlib.h> | |
599ec36b | 38 | |
3da7dad5 VJ |
39 | #include "util-luajit.h" |
40 | ||
f7d890fe VJ |
41 | typedef struct LuaStreamingBuffer_ { |
42 | const uint8_t *data; | |
43 | uint32_t data_len; | |
44 | uint8_t flags; | |
45 | } LuaStreamingBuffer; | |
46 | ||
3da7dad5 VJ |
47 | lua_State *LuaGetState(void); |
48 | void LuaReturnState(lua_State *s); | |
49 | ||
affbd697 VJ |
50 | /* gets */ |
51 | ||
22dd14d5 VJ |
52 | /** \brief get tv pointer from the lua state */ |
53 | ThreadVars *LuaStateGetThreadVars(lua_State *luastate); | |
54 | ||
599ec36b VJ |
55 | Packet *LuaStateGetPacket(lua_State *luastate); |
56 | void *LuaStateGetTX(lua_State *luastate); | |
57 | ||
affbd697 | 58 | /** \brief get flow pointer from lua state |
affbd697 VJ |
59 | * |
60 | * \retval f flow poiner or NULL if it was not set | |
61 | */ | |
8865009f | 62 | Flow *LuaStateGetFlow(lua_State *luastate); |
affbd697 | 63 | |
b3dfd3cd VJ |
64 | PacketAlert *LuaStateGetPacketAlert(lua_State *luastate); |
65 | ||
07ff85a4 VJ |
66 | /** \brief get file pointer from the lua state */ |
67 | File *LuaStateGetFile(lua_State *luastate); | |
68 | ||
f7d890fe VJ |
69 | LuaStreamingBuffer *LuaStateGetStreamingBuffer(lua_State *luastate); |
70 | ||
8b3afb69 VJ |
71 | int LuaStateGetDirection(lua_State *luastate); |
72 | ||
affbd697 VJ |
73 | /* sets */ |
74 | ||
599ec36b VJ |
75 | void LuaStateSetPacket(lua_State *luastate, Packet *p); |
76 | void LuaStateSetTX(lua_State *luastate, void *tx); | |
77 | ||
affbd697 VJ |
78 | /** \brief set a flow pointer in the lua state |
79 | * | |
80 | * \param f flow pointer | |
affbd697 | 81 | */ |
8865009f | 82 | void LuaStateSetFlow(lua_State *luastate, Flow *f); |
affbd697 | 83 | |
b3dfd3cd VJ |
84 | void LuaStateSetPacketAlert(lua_State *luastate, PacketAlert *pa); |
85 | ||
07ff85a4 VJ |
86 | void LuaStateSetFile(lua_State *luastate, File *file); |
87 | ||
22dd14d5 VJ |
88 | void LuaStateSetThreadVars(lua_State *luastate, ThreadVars *tv); |
89 | ||
f7d890fe VJ |
90 | void LuaStateSetStreamingBuffer(lua_State *luastate, LuaStreamingBuffer *b); |
91 | ||
8b3afb69 VJ |
92 | void LuaStateSetDirection(lua_State *luastate, int direction); |
93 | ||
599ec36b VJ |
94 | void LuaPrintStack(lua_State *state); |
95 | ||
307ce405 VJ |
96 | int LuaPushStringBuffer(lua_State *luastate, const uint8_t *input, size_t input_len); |
97 | ||
67ea8215 MK |
98 | int LuaPushInteger(lua_State *luastate, lua_Integer n); |
99 | ||
599ec36b VJ |
100 | #endif /* HAVE_LUA */ |
101 | ||
102 | #endif /* __UTIL_LUA_H__ */ |