]> git.ipfire.org Git - people/ms/suricata.git/blame - src/util-lua.h
core: Remove unneeded consts
[people/ms/suricata.git] / src / util-lua.h
CommitLineData
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. */
31typedef 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
41typedef struct LuaStreamingBuffer_ {
42 const uint8_t *data;
43 uint32_t data_len;
44 uint8_t flags;
45} LuaStreamingBuffer;
46
3da7dad5
VJ
47lua_State *LuaGetState(void);
48void LuaReturnState(lua_State *s);
49
affbd697
VJ
50/* gets */
51
22dd14d5
VJ
52/** \brief get tv pointer from the lua state */
53ThreadVars *LuaStateGetThreadVars(lua_State *luastate);
54
599ec36b
VJ
55Packet *LuaStateGetPacket(lua_State *luastate);
56void *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 62Flow *LuaStateGetFlow(lua_State *luastate);
affbd697 63
b3dfd3cd
VJ
64PacketAlert *LuaStateGetPacketAlert(lua_State *luastate);
65
07ff85a4
VJ
66/** \brief get file pointer from the lua state */
67File *LuaStateGetFile(lua_State *luastate);
68
f7d890fe
VJ
69LuaStreamingBuffer *LuaStateGetStreamingBuffer(lua_State *luastate);
70
8b3afb69
VJ
71int LuaStateGetDirection(lua_State *luastate);
72
affbd697
VJ
73/* sets */
74
599ec36b
VJ
75void LuaStateSetPacket(lua_State *luastate, Packet *p);
76void 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 82void LuaStateSetFlow(lua_State *luastate, Flow *f);
affbd697 83
b3dfd3cd
VJ
84void LuaStateSetPacketAlert(lua_State *luastate, PacketAlert *pa);
85
07ff85a4
VJ
86void LuaStateSetFile(lua_State *luastate, File *file);
87
22dd14d5
VJ
88void LuaStateSetThreadVars(lua_State *luastate, ThreadVars *tv);
89
f7d890fe
VJ
90void LuaStateSetStreamingBuffer(lua_State *luastate, LuaStreamingBuffer *b);
91
8b3afb69
VJ
92void LuaStateSetDirection(lua_State *luastate, int direction);
93
599ec36b
VJ
94void LuaPrintStack(lua_State *state);
95
307ce405
VJ
96int LuaPushStringBuffer(lua_State *luastate, const uint8_t *input, size_t input_len);
97
67ea8215
MK
98int LuaPushInteger(lua_State *luastate, lua_Integer n);
99
599ec36b
VJ
100#endif /* HAVE_LUA */
101
102#endif /* __UTIL_LUA_H__ */