ntopng/include/FlowCheck.h
Alfredo Cardigliano 9352d0cdcd Update copyright
2025-01-02 09:09:56 +01:00

71 lines
2.1 KiB
C++

/*
*
* (C) 2013-25 - ntop.org
*
*
* This program is free software; you can redistribute it and/or modify
* it under the terms of the GNU General Public License as published by
* the Free Software Foundation; either version 3 of the License, or
* (at your option) any later version.
*
* This program is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
* GNU General Public License for more details.
*
* You should have received a copy of the GNU General Public License
* along with this program; if not, write to the Free Software Foundation,
* Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA.
*
*/
#ifndef _FLOW_CHECK_H_
#define _FLOW_CHECK_H_
#include "ntop_includes.h"
class FlowCheck : public Check {
private:
bool has_protocol_detected, has_periodic_update, has_flow_end, has_flow_begin;
#ifdef CHECKS_PROFILING
struct {
std::atomic<u_int64_t> execution_time;
} stats;
#endif
public:
FlowCheck(NtopngEdition _edition, bool _packet_interface_only,
bool _nedge_exclude, bool _nedge_only, bool _has_protocok_detected,
bool _has_periodic_update, bool _has_flow_end,
bool _has_flow_begin = false);
virtual ~FlowCheck();
/* Check hooks */
virtual void protocolDetected(Flow *f){};
virtual void periodicUpdate(Flow *f){};
virtual void flowEnd(Flow *f){};
virtual void flowBegin(Flow *f){};
/* Used to build an alert */
virtual FlowAlert *buildAlert(Flow *f) { return NULL; };
void addCheck(std::list<FlowCheck *> *l, NetworkInterface *iface,
FlowChecks check);
virtual bool loadConfiguration(json_object *config);
virtual std::string getName() const = 0;
static void computeCliSrvScore(u_int8_t alert_score,
risk_percentage cli_pctg, u_int8_t *cli_score,
u_int8_t *srv_score);
#ifdef CHECKS_PROFILING
inline void incStats(u_int64_t exec_time) {
stats.execution_time += exec_time;
};
#endif
void lua(lua_State *vm);
};
#endif /* _FLOW_CHECK_H_ */