/src/ntopng/include/AlertableEntity.h
Line | Count | Source |
1 | | /* |
2 | | * |
3 | | * (C) 2021-26 - ntop.org |
4 | | * |
5 | | * |
6 | | * This program is free software; you can redistribute it and/or modify |
7 | | * it under the terms of the GNU General Public License as published by |
8 | | * the Free Software Foundation; either version 3 of the License, or |
9 | | * (at your option) any later version. |
10 | | * |
11 | | * This program is distributed in the hope that it will be useful, |
12 | | * but WITHOUT ANY WARRANTY; without even the implied warranty of |
13 | | * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the |
14 | | * GNU General Public License for more details. |
15 | | * |
16 | | * You should have received a copy of the GNU General Public License |
17 | | * along with this program; if not, write to the Free Software Foundation, |
18 | | * Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA. |
19 | | * |
20 | | */ |
21 | | |
22 | | #ifndef _ALERTABLE_ENTITY_H_ |
23 | | #define _ALERTABLE_ENTITY_H_ |
24 | | |
25 | | #include "ntop_includes.h" |
26 | | |
27 | | class NetworkInterface; |
28 | | |
29 | | class AlertableEntity { |
30 | | private: |
31 | | AlertEntity entity_type; |
32 | | std::string entity_val; |
33 | | NetworkInterface* alert_iface; |
34 | | u_int num_engaged_alerts; |
35 | | |
36 | | protected: |
37 | | RwLock |
38 | | engaged_alerts_lock; /* Lock to handle concurrent access from the GUI */ |
39 | | |
40 | | void incNumAlertsEngaged(AlertLevel alert_severity); |
41 | | void decNumAlertsEngaged(AlertLevel alert_severity); |
42 | | |
43 | | public: |
44 | | AlertableEntity(NetworkInterface* alert_iface, AlertEntity entity); |
45 | | virtual ~AlertableEntity(); |
46 | | |
47 | 0 | inline NetworkInterface* getAlertInterface() { return alert_iface; } |
48 | | |
49 | 18.4k | inline void setEntityValue(const char* ent_val) { entity_val = ent_val; } |
50 | 0 | inline std::string getEntityValue() const { return (entity_val); } |
51 | | |
52 | 0 | inline AlertEntity getEntityType() const { return (entity_type); } |
53 | | |
54 | 39.5k | inline u_int getNumEngagedAlerts() const { return (num_engaged_alerts); } |
55 | | |
56 | 0 | virtual void countAlerts(grouped_alerts_counters* counters) {}; |
57 | | virtual void getAlerts(lua_State* vm, ScriptPeriodicity p, |
58 | | AlertType type_filter, AlertLevel severity_filter, |
59 | 0 | AlertRole role_filter, u_int* idx) {}; |
60 | | |
61 | | bool matchesAllowedNetworks(AddressTree* allowed_nets); |
62 | | |
63 | | static int parseEntityValueIp(const char* alert_entity_value, |
64 | | struct in6_addr* ip_raw); |
65 | | }; |
66 | | |
67 | | #endif |