expiredflowshash.h 1.68 KB
Newer Older
's avatar
committed
1
#define EXFL_HASH_SIZE 262144 //4128
2 3 4

#include "protocols.h"

's avatar
committed
5
typedef struct eflow_data {
6 7 8 9
	unsigned long long timestamp_first;
	unsigned long long timestamp_last;
	unsigned long long packets_count;
	unsigned long long bytes_count;
's avatar
committed
10 11 12 13 14
	ip_addr saddr, daddr;
	u_short sport, dport;
	u_char ptcl;
	u_char ttl_pkt1;
	unsigned long long epoch;
's avatar
committed
15
	unsigned int valid;
's avatar
committed
16 17
} eflow_data;

18
typedef struct flow_data {
19 20 21 22
	unsigned long long timestamp_first;
	unsigned long long timestamp_last;
	unsigned long long packets_count;
	unsigned long long bytes_count;
23 24
	ip_addr saddr, daddr;
	u_short sport, dport;
25 26
	u_char ptcl;
	u_char ttl_pkt1;
's avatar
committed
27
} flow_data;
28

29 30
typedef struct flows_stat {
	unsigned int sent;
31 32 33 34
	unsigned int received;
	unsigned int expired;
	unsigned int ignored;
	unsigned int dropped;
35 36 37 38 39 40 41
	struct {
		unsigned int sent;
		unsigned int received;
		unsigned int expired;
		unsigned int ignored;
		unsigned int dropped;
	} packets;
42 43
} flows_stat;

44 45 46
struct exfl_list_node {

	unsigned int value;
's avatar
committed
47

48
	/* info that define a flow */
's avatar
committed
49
	struct eflow_data flow;
50 51 52 53 54 55 56 57 58 59

	struct exfl_list_node *next;
	struct exfl_list_node *previous;
};


struct exfl_hash_node {
	unsigned int value;
	struct exfl_list_node *node;
	struct exfl_hash_node *next;
's avatar
committed
60 61
	struct exfl_hash_node *prev;

62 63 64 65
};

struct exfl_data {
	int list_size;
66 67
	unsigned int expired_flows_list_size;
	unsigned int expired_flows_list_size_max;
68 69 70 71 72 73 74 75
	struct exfl_list_node *list_head;
	struct exfl_list_node *list_tail;
	struct exfl_hash_node *hashtable[EXFL_HASH_SIZE];
	struct exfl_list_node *expired_flows_head;
	struct exfl_list_node *expired_flows_tail;
	pthread_mutex_t mutex;
	pthread_t pthread;
	unsigned int run;
's avatar
committed
76
	unsigned long long epoch;
77
	unsigned int packets_count_min;
78
	unsigned int shm_flows;
79
};