From 844ea95f9857c841c92ffab8f4a815d0fa28d8fa Mon Sep 17 00:00:00 2001 From: Victor Julien Date: Wed, 22 Jan 2025 14:30:11 +0100 Subject: [PATCH] SQUASH lua legacy packet removal --- src/util-lua-common.c | 127 ------------------------------------------ 1 file changed, 127 deletions(-) diff --git a/src/util-lua-common.c b/src/util-lua-common.c index 7a769988c9dc..94d562e0ad9d 100644 --- a/src/util-lua-common.c +++ b/src/util-lua-common.c @@ -133,63 +133,6 @@ static int LuaCallbackStreamingBuffer(lua_State *luastate) return LuaCallbackStreamingBufferPushToStack(luastate, b); } -/** \internal - * \brief fill lua stack with packet timestamp - * \param luastate the lua state - * \param p packet - * \retval cnt number of data items placed on the stack - * - * Places: seconds (number), microseconds (number) - */ -static int LuaCallbackTimestampPushToStack(lua_State *luastate, const SCTime_t ts) -{ - lua_pushnumber(luastate, (double)SCTIME_SECS(ts)); - lua_pushnumber(luastate, (double)SCTIME_USECS(ts)); - return 2; -} - -/** \internal - * \brief fill lua stack with header info - * \param luastate the lua state - * \param p packet - * \retval cnt number of data items placed on the stack - * - * Places: ts (string) - */ -static int LuaCallbackTimeStringPushToStackFromPacket(lua_State *luastate, const Packet *p) -{ - char timebuf[64]; - CreateTimeString(p->ts, timebuf, sizeof(timebuf)); - lua_pushstring (luastate, timebuf); - return 1; -} - -/** \internal - * \brief Wrapper for getting packet timestamp (as numbers) into a lua script - * \retval cnt number of items placed on the stack - */ -static int LuaCallbackPacketTimestamp(lua_State *luastate) -{ - const Packet *p = LuaStateGetPacket(luastate); - if (p == NULL) - return LuaCallbackError(luastate, "internal error: no packet"); - - return LuaCallbackTimestampPushToStack(luastate, p->ts); -} - -/** \internal - * \brief Wrapper for getting tuple info into a lua script - * \retval cnt number of items placed on the stack - */ -static int LuaCallbackPacketTimeString(lua_State *luastate) -{ - const Packet *p = LuaStateGetPacket(luastate); - if (p == NULL) - return LuaCallbackError(luastate, "internal error: no packet"); - - return LuaCallbackTimeStringPushToStackFromPacket(luastate, p); -} - /** \internal * \brief fill lua stack with flow timestamps * \param luastate the lua state @@ -287,69 +230,6 @@ static int LuaCallbackFlowHasAlerts(lua_State *luastate) return r; } -/** \internal - * \brief fill lua stack with header info - * \param luastate the lua state - * \param p packet - * \retval cnt number of data items placed on the stack - * - * Places: ipver (number), src ip (string), dst ip (string), protocol (number), - * sp or icmp type (number), dp or icmp code (number). - */ -static int LuaCallbackTuplePushToStackFromPacket(lua_State *luastate, const Packet *p) -{ - int ipver = 0; - if (PacketIsIPv4(p)) { - ipver = 4; - } else if (PacketIsIPv6(p)) { - ipver = 6; - } - lua_pushinteger(luastate, ipver); - if (ipver == 0) - return 1; - - char srcip[46] = "", dstip[46] = ""; - if (PacketIsIPv4(p)) { - PrintInet(AF_INET, (const void *)GET_IPV4_SRC_ADDR_PTR(p), srcip, sizeof(srcip)); - PrintInet(AF_INET, (const void *)GET_IPV4_DST_ADDR_PTR(p), dstip, sizeof(dstip)); - } else if (PacketIsIPv6(p)) { - PrintInet(AF_INET6, (const void *)GET_IPV6_SRC_ADDR(p), srcip, sizeof(srcip)); - PrintInet(AF_INET6, (const void *)GET_IPV6_DST_ADDR(p), dstip, sizeof(dstip)); - } - - lua_pushstring (luastate, srcip); - lua_pushstring (luastate, dstip); - - /* proto and ports (or type/code) */ - lua_pushinteger(luastate, p->proto); - if (p->proto == IPPROTO_TCP || p->proto == IPPROTO_UDP) { - lua_pushinteger(luastate, p->sp); - lua_pushinteger(luastate, p->dp); - - } else if (p->proto == IPPROTO_ICMP || p->proto == IPPROTO_ICMPV6) { - lua_pushinteger(luastate, p->icmp_s.type); - lua_pushinteger(luastate, p->icmp_s.code); - } else { - lua_pushinteger(luastate, 0); - lua_pushinteger(luastate, 0); - } - - return 6; -} - -/** \internal - * \brief Wrapper for getting tuple info into a lua script - * \retval cnt number of items placed on the stack - */ -static int LuaCallbackTuple(lua_State *luastate) -{ - const Packet *p = LuaStateGetPacket(luastate); - if (p == NULL) - return LuaCallbackError(luastate, "internal error: no packet"); - - return LuaCallbackTuplePushToStackFromPacket(luastate, p); -} - /** \internal * \brief fill lua stack with header info * \param luastate the lua state @@ -904,13 +784,6 @@ static int LuaCallbackThreadInfo(lua_State *luastate) int LuaRegisterFunctions(lua_State *luastate) { /* registration of the callbacks */ - lua_pushcfunction(luastate, LuaCallbackPacketTimestamp); - lua_setglobal(luastate, "SCPacketTimestamp"); - lua_pushcfunction(luastate, LuaCallbackPacketTimeString); - lua_setglobal(luastate, "SCPacketTimeString"); - lua_pushcfunction(luastate, LuaCallbackTuple); - lua_setglobal(luastate, "SCPacketTuple"); - lua_pushcfunction(luastate, LuaCallbackFlowTimestamps); lua_setglobal(luastate, "SCFlowTimestamps"); lua_pushcfunction(luastate, LuaCallbackFlowTimeString);