lua: add SCFlowHasAlerts function

Add SCFlowHasAlerts() to check if a flow has alerts. Returns true
on alerts, false otherwise.

Example:

  has_alerts = SCFlowHasAlerts()
  if has_alerts then
    -- do something
  end
pull/2516/head
Mats Klepsland 8 years ago committed by Victor Julien
parent d9b87e502d
commit c531e8f77c

@ -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");

Loading…
Cancel
Save