2 * Netgrind -- The Network Traffic Analyser
4 * (c) 2003--2013 Martin Mares <mj@ucw.cz>
6 * This software may be freely distributed and used according to the terms
7 * of the GNU General Public License.
10 #define IPQUAD(x) ((byte*)&(x))[0], ((byte*)&(x))[1], ((byte*)&(x))[2], ((byte*)&(x))[3]
14 extern struct pkt_stats stat_link_dwarf, stat_link_in, stat_link_unknown, stat_link_arp;
16 void link_eth_got_packet(struct pkt *p);
20 extern struct pkt_stats stat_ip_in, stat_ip_invalid, stat_ip_uninteresting, stat_ip_fragmented, stat_ip_badsum;
21 extern uns accept_broken_checksums;
23 uns tcpip_calc_checksum(void *data, uns len, uns csum);
24 uns tcpip_verify_checksum(uns csum);
25 void ip_got_packet(struct pkt *p);
29 extern struct pkt_stats stat_tcp_in, stat_tcp_invalid, stat_tcp_badsum, stat_tcp_unmatched,
30 stat_tcp_on_closed, stat_tcp_bad_state;
31 extern uns cnt_tcp_flows, cnt_tcp_causes[], tcp_num_flows, tcp_max_flows;
34 extern uns tcp_arrival_times;
35 extern uns tcp_wait_for_ack;
38 list queue; /* incoming packets */
39 u32 last_acked_seq; /* last sequence number for which I sent ACK */
40 u32 syn_or_fin_seq; /* sequence number of SYN/FIN I sent */
41 u32 queue_start_seq; /* sequence number expected at the start of the queue */
42 enum { /* very simplified TCP state machine */
44 FLOW_SYN_SENT, /* sent SYN, waiting for SYN ACK */
45 FLOW_SYN_SENT_ACK, /* sent SYN ACK, waiting for first ACK */
46 FLOW_ESTABLISHED, /* established state including waiting for ACK of SYN ACK */
47 FLOW_FIN_SENT, /* sent FIN, waiting for its ACK */
48 FLOW_FINISHED /* closed, ignoring further packets */
50 struct pkt_stats stat;
54 struct flow *hash_next;
55 u32 saddr, daddr, sport, dport;
58 struct appl_hooks *appl;
61 struct pkt_stats stat_raw;
74 extern byte *flow_state_names[];
75 extern byte *flow_cause_names[], *flow_cause_names_short[];
78 void (*open)(struct flow *f, u64 when);
79 void (*input)(struct flow *f, int dir, struct pkt *p); /* dir0 = sent by initiator, pkt_len(p)==0 for close */
80 void (*close)(struct flow *f, int cause, u64 when);
86 void tcp_cleanup(u64 timestamp);
87 void tcp_got_packet(struct iphdr *iph, struct pkt *p);
89 extern struct appl_hooks *tcp_default_appl;
93 extern struct appl_hooks appl_sink, appl_save, appl_asave, appl_summary;
94 extern uns asave_width;
95 extern byte *save_dir;
97 void sink_open(struct flow *f, u64 when);
98 void sink_close(struct flow *f, int cause, u64 when);
99 void sink_input(struct flow *f, int dir, struct pkt *p);
101 #define TIMESTAMP_LEN 32
102 void format_timestamp(byte *buf, u64 time);
106 extern struct appl_hooks appl_http;
107 extern char *http_log_dir;
111 void histogram_init(byte *name);
112 void histogram_add_stat(byte *name, struct pkt_stats *stat);
113 void histogram_add_int(byte *name, int *var);
114 void histogram_step(uns time);
115 void histogram_cleanup(void);