1
0
Fork 0
mirror of https://github.com/pavel-odintsov/fastnetmon synced 2024-06-01 18:06:25 +02:00

Explicitly set all fields in simple_packet_t to zeroes

This commit is contained in:
Pavel Odintsov 2022-05-05 23:59:19 +01:00
parent 6ece82da31
commit 98bfac9c9b

View File

@ -10,50 +10,48 @@ enum source_t { UNKNOWN = 0, MIRROR = 1, SFLOW = 2, NETFLOW = 3, TERAFLOW = 4 };
// simplified packet struct for lightweight save into memory
class simple_packet_t {
public:
simple_packet_t()
: sample_ratio(1), src_ip(0), dst_ip(0), source_port(0), destination_port(0), protocol(0), length(0), flags(0),
number_of_packets(1), ip_fragmented(false), ip_protocol_version(4), ttl(0), packet_payload_pointer(NULL),
packet_payload_length(0), packet_direction(OTHER) {
ts.tv_usec = 0;
ts.tv_sec = 0;
}
// Source plugin for this traffic type
source_t source = UNKNOWN;
uint32_t sample_ratio;
/* IPv4 */
uint32_t src_ip;
uint32_t dst_ip;
uint32_t sample_ratio = 1;
/* IPv4 in big endian, network byte order */
uint32_t src_ip = 0;
uint32_t dst_ip = 0;
/* IPv6 */
struct in6_addr src_ipv6;
struct in6_addr dst_ipv6;
in6_addr src_ipv6{};
in6_addr dst_ipv6{};
/* ASN's */
uint32_t src_asn = 0;
uint32_t dst_asn = 0;
/* Physical port numbers from network equipment */
/* Added after 2.0.71 */
uint32_t input_interface = 0;
uint32_t output_interface = 0;
uint8_t ip_protocol_version; /* IPv4 or IPv6 */
uint8_t ttl;
uint16_t source_port;
uint16_t destination_port;
unsigned int protocol;
uint64_t length;
uint8_t ip_protocol_version = 4; /* IPv4 or IPv6 */
uint8_t ttl = 0;
uint16_t source_port = 0;
uint16_t destination_port = 0;
uint32_t protocol = 0;
uint64_t length = 0;
uint64_t ip_length = 0; /* IP packet total length. We use it in addition to length because flow spec rule need this length */
uint64_t number_of_packets = 1; /* for netflow */
uint8_t flags = 0; /* tcp flags */
bool ip_fragmented = false; /* If IP packet fragmented */
bool ip_dont_fragment = false; /* If IP has don't fragment flag */
uint64_t number_of_packets; /* for netflow */
uint8_t flags; /* tcp flags */
// Time when we actually received this packet, we use quite rough and inaccurate but very fast time source for it
time_t arrival_time = 0;
bool ip_fragmented; /* If IP packet fragmented */
bool ip_dont_fragment = false; /* If IP has don't fragment flag */
// Timestamp of packet as reported by Netflow or IPFIX agent on device, it may be very inaccurate as nobody cares about time on equipment
struct timeval ts = { 0, 0 };
struct timeval ts;
void* packet_payload_pointer;
int packet_payload_length;
void* packet_payload_pointer = nullptr;
int32_t packet_payload_length = 0;
uint32_t packet_payload_full_length = 0; // In case of cropped packets we use this
// vlan tag if we can extract it
@ -64,7 +62,9 @@ class simple_packet_t {
// Device uptime when flow fnishes
int64_t flow_end = 0;
// We store packet direction here because direction calculation is very difficult task for cpu
// field too
// We store packet direction here because direction calculation is very
// difficult task for cpu
direction_t packet_direction = OTHER;
// IP address of device which send this flow