123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227 |
- #ifndef _SOFTFLOWD_H
- #define _SOFTFLOWD_H
- #include "common.h"
- #include "sys-tree.h"
- #include "freelist.h"
- #include "treetype.h"
- #ifndef PRIVDROP_USER
- # define PRIVDROP_USER "nobody"
- #endif
- #ifndef PRIVDROP_CHROOT_DIR
- # define PRIVDROP_CHROOT_DIR "/var/empty"
- #endif
- #define LIBPCAP_SNAPLEN_V4 96
- #define LIBPCAP_SNAPLEN_V6 160
- #define DEFAULT_TCP_TIMEOUT 3600
- #define DEFAULT_TCP_RST_TIMEOUT 120
- #define DEFAULT_TCP_FIN_TIMEOUT 300
- #define DEFAULT_UDP_TIMEOUT 300
- #define DEFAULT_ICMP_TIMEOUT 300
- #define DEFAULT_GENERAL_TIMEOUT 3600
- #define DEFAULT_MAXIMUM_LIFETIME (3600*24*7)
- #define DEFAULT_EXPIRY_INTERVAL 60
- #define DEFAULT_MAX_FLOWS 8192
- struct STATISTIC {
- double min, mean, max;
- };
- #define TRACK_FULL 1
- #define TRACK_IP_PROTO 2
- #define TRACK_IP_ONLY 3
- struct OPTION {
- uint32_t sample;
- };
- struct FLOWTRACK {
-
- FLOW_HEAD(FLOWS, FLOW) flows;
- EXPIRY_HEAD(EXPIRIES, EXPIRY) expiries;
- struct freelist flow_freelist;
- struct freelist expiry_freelist;
- unsigned int num_flows;
- unsigned int max_flows;
- u_int64_t next_flow_seq;
-
- struct timeval system_boot_time;
- int track_level;
-
- int tcp_timeout;
- int tcp_rst_timeout;
- int tcp_fin_timeout;
- int udp_timeout;
- int icmp_timeout;
- int general_timeout;
- int maximum_lifetime;
- int expiry_interval;
-
- u_int64_t total_packets;
- u_int64_t non_sampled_packets;
- u_int64_t frag_packets;
- u_int64_t non_ip_packets;
- u_int64_t bad_packets;
- u_int64_t flows_expired;
- u_int64_t flows_exported;
- u_int64_t flows_dropped;
- u_int64_t flows_force_expired;
- u_int64_t packets_sent;
- struct STATISTIC duration;
- struct STATISTIC octets;
- struct STATISTIC packets;
-
- u_int64_t flows_pp[256];
- u_int64_t octets_pp[256];
- u_int64_t packets_pp[256];
- struct STATISTIC duration_pp[256];
-
- u_int64_t expired_general;
- u_int64_t expired_tcp;
- u_int64_t expired_tcp_rst;
- u_int64_t expired_tcp_fin;
- u_int64_t expired_udp;
- u_int64_t expired_icmp;
- u_int64_t expired_maxlife;
- u_int64_t expired_overbytes;
- u_int64_t expired_maxflows;
- u_int64_t expired_flush;
-
- struct OPTION option;
- };
- struct FLOW {
-
- struct EXPIRY *expiry;
- FLOW_ENTRY(FLOW) trp;
-
- int af;
- u_int32_t ip6_flowlabel[2];
- union {
- struct in_addr v4;
- struct in6_addr v6;
- } addr[2];
- u_int16_t port[2];
- u_int8_t tcp_flags[2];
- u_int8_t protocol;
-
- u_int64_t flow_seq;
- struct timeval flow_start;
- struct timeval flow_last;
-
- u_int32_t octets[2];
- u_int32_t packets[2];
- };
- struct EXPIRY {
- EXPIRY_ENTRY(EXPIRY) trp;
- struct FLOW *flow;
- u_int32_t expires_at;
- enum {
- R_GENERAL, R_TCP, R_TCP_RST, R_TCP_FIN, R_UDP, R_ICMP,
- R_MAXLIFE, R_OVERBYTES, R_OVERFLOWS, R_FLUSH
- } reason;
- };
- u_int32_t timeval_sub_ms(const struct timeval *t1, const struct timeval *t2);
- int send_netflow_v1(struct FLOW **flows, int num_flows, int nfsock,
- u_int16_t ifidx, u_int64_t *flows_exported, struct timeval *system_boot_time,
- int verbose_flag, struct OPTION *option);
- int send_netflow_v5(struct FLOW **flows, int num_flows, int nfsock,
- u_int16_t ifidx, u_int64_t *flows_exported, struct timeval *system_boot_time,
- int verbose_flag, struct OPTION *option);
- int send_netflow_v9(struct FLOW **flows, int num_flows, int nfsock,
- u_int16_t ifidx, u_int64_t *flows_exported, struct timeval *system_boot_time,
- int verbose_flag, struct OPTION *option);
- void netflow9_resend_template(void);
- #endif
|