diff --git a/src/util-lua-common.c b/src/util-lua-common.c index f1c13a8a95..cb3d2dac4d 100644 --- a/src/util-lua-common.c +++ b/src/util-lua-common.c @@ -247,6 +247,37 @@ static int LuaCallbackFlowTimeString(lua_State *luastate) return r; } +/** \internal + * \brief fill lua stack with flow has alerts + * \param luastate the lua state + * \param flow flow + * \retval cnt number of data items placed on the stack + * + * Places alerts (bool) + */ +static int LuaCallbackHasAlertsPushToStackFromFlow(lua_State *luastate, const Flow *flow) +{ + lua_pushboolean(luastate, FlowHasAlerts(flow)); + + return 1; +} + +/** \internal + * \brief Wrapper for getting flow has alerts info into a lua script + * \retval cnt number of items placed on the stack + */ +static int LuaCallbackFlowHasAlerts(lua_State *luastate) +{ + int r = 0; + Flow *flow = LuaStateGetFlow(luastate); + if (flow == NULL) + return LuaCallbackError(luastate, "internal error: no flow"); + + r = LuaCallbackHasAlertsPushToStackFromFlow(luastate, flow); + + return r; +} + /** \internal * \brief fill lua stack with header info * \param luastate the lua state @@ -768,6 +799,8 @@ int LuaRegisterFunctions(lua_State *luastate) lua_setglobal(luastate, "SCFlowAppLayerProto"); lua_pushcfunction(luastate, LuaCallbackStatsFlow); lua_setglobal(luastate, "SCFlowStats"); + lua_pushcfunction(luastate, LuaCallbackFlowHasAlerts); + lua_setglobal(luastate, "SCFlowHasAlerts"); lua_pushcfunction(luastate, LuaCallbackStreamingBuffer); lua_setglobal(luastate, "SCStreamingBuffer");