ntopng/include/ServerPortsBitmap.h
Ivan Nardi 6e2a1de985
Limit the server ports of the assets saved to redis/DB (#11107)
Save at most MAX_NUM_ASSET_SERVER_PORTS (128) server ports per L4
protocol of a local host, keeping the lowest ports, in the server ports
bitmap saved to redis and in the asset info. A warning (once per host)
reports the number of ports and the host IP when the limit is exceeded.
2026-10-21 11:46:23 +02:00

25 lines
689 B
C++

#ifndef _SERVER_PORTS_BITMAP_H_
#define _SERVER_PORTS_BITMAP_H_
#include "ntop_includes.h"
class ServerPortsBitmap {
private:
ndpi_bitmap *tcp_bitmap, *udp_bitmap;
const char* bitmap_serialize(ndpi_bitmap* bitmap);
void bitmap_deserialize(const char* tcp_str, const char* udp_str);
ndpi_bitmap* bitmap_limit(ndpi_bitmap* bitmap, u_int32_t max_ports);
public:
ServerPortsBitmap();
~ServerPortsBitmap();
inline void addPort(bool isTCP, u_int16_t port) {
ndpi_bitmap_set((isTCP ? tcp_bitmap : udp_bitmap), port);
};
void limitPorts(u_int32_t max_ports);
const char* serializer();
bool deserializer(const char* json_str);
};
#endif /*_SERVER_PORTS_BITMAP_H_*/