lua: convert dnp3 to suricata.dnp3 lib

This is an initial 1:1 conversion which is rather simple, as DNP3 only
had one function which converted the whole transaction to a DNP3
table.

Ticket: #7601
pull/12847/head
Jason Ish 4 months ago
parent 4b8ef41df8
commit 9b7cab1f21

@ -556,6 +556,5 @@ int LuaRegisterExtensions(lua_State *lua_state)
LuaRegisterSshFunctions(lua_state);
LuaRegisterHasshFunctions(lua_state);
LuaRegisterSmtpFunctions(lua_state);
LuaRegisterDNP3Functions(lua_state);
return 0;
}

@ -19,6 +19,7 @@
#include "util-lua-builtins.h"
#include "util-lua-base64lib.h"
#include "util-lua-dataset.h"
#include "util-lua-dnp3.h"
#include "util-lua-dns.h"
#include "util-lua-hashlib.h"
#include "util-lua-packetlib.h"
@ -28,6 +29,7 @@
static const luaL_Reg builtins[] = {
{ "suricata.base64", SCLuaLoadBase64Lib },
{ "suricata.dataset", LuaLoadDatasetLib },
{ "suricata.dnp3", SCLuaLoadDnp3Lib },
{ "suricata.dns", SCLuaLoadDnsLib },
{ "suricata.hashlib", SCLuaLoadHashlib },
{ "suricata.packet", LuaLoadPacketLib },

@ -188,10 +188,15 @@ static int DNP3GetTx(lua_State *luastate)
return 1;
}
int LuaRegisterDNP3Functions(lua_State *luastate)
static const struct luaL_Reg dnp3lib[] = {
// clang-format off
{ "get_tx", DNP3GetTx, },
{ NULL, NULL, }
// clang-format on
};
int SCLuaLoadDnp3Lib(lua_State *L)
{
lua_pushcfunction(luastate, DNP3GetTx);
lua_setglobal(luastate, "DNP3GetTx");
return 0;
luaL_newlib(L, dnp3lib);
return 1;
}

@ -18,6 +18,6 @@
#ifndef SURICATA_UTIL_LUA_DNP3_H
#define SURICATA_UTIL_LUA_DNP3_H
int LuaRegisterDNP3Functions(lua_State *);
int SCLuaLoadDnp3Lib(lua_State *L);
#endif /* !SURICATA_UTIL_LUA_DNP3_H */

Loading…
Cancel
Save