]> mj.ucw.cz Git - netgrind.git/blob - netgrind/netgrind.h
... splitting ...
[netgrind.git] / netgrind / netgrind.h
1 /*
2  *      Netgrind -- The Network Traffic Analyser
3  *
4  *      (c) 2003 Martin Mares <mj@ucw.cz>
5  *
6  *      This software may be freely distributed and used according to the terms
7  *      of the GNU General Public License.
8  */
9
10 /* link.c */
11
12 extern struct pkt_stats stat_link_dwarf, stat_link_in, stat_link_unknown, stat_link_arp;
13
14 void link_eth_got_packet(struct pkt *p);
15
16 /* ip.c */
17
18 extern struct pkt_stats stat_ip_in, stat_ip_invalid, stat_ip_uninteresting, stat_ip_fragmented, stat_ip_badsum;
19
20 uns tcpip_calc_checksum(void *data, uns len, uns csum);
21 uns tcpip_verify_checksum(uns csum);
22 void ip_got_packet(struct pkt *p);
23
24 /* tcp.c */
25
26 extern struct pkt_stats stat_tcp_in, stat_tcp_invalid, stat_tcp_badsum, stat_tcp_unmatched,
27   stat_tcp_on_closed;
28
29 struct pipe {
30   list queue;                           /* incoming packets */
31   u32 last_acked_seq;                   /* last sequence number for which I sent ACK */
32   u32 syn_or_fin_seq;                   /* sequence number of SYN/FIN I sent */
33   enum {                                /* very simplified TCP state machine */
34     FLOW_IDLE,
35     FLOW_SYN_SENT,                      /* sent SYN, waiting for SYN ACK */
36     FLOW_SYN_SENT_ACK,                  /* sent SYN ACK, waiting for first ACK */
37     FLOW_ESTABLISHED,                   /* established state including waiting for ACK of SYN ACK */
38     FLOW_FIN_SENT,                      /* sent FIN, waiting for its ACK */
39     FLOW_FINISHED                       /* closed, ignoring further packets */
40   } state;
41   struct pkt_stats stat_in;
42 };
43
44 struct flow {
45   struct flow *hash_next;
46   u32 saddr, daddr, sport, dport;
47   u32 timeout;
48   uns heap_pos;
49   struct appl_hooks *appl;
50   void *appl_data;
51   struct pipe pipe[2];
52 };
53
54 enum close_cause {
55   CAUSE_CLOSE,
56   CAUSE_RESET,
57   CAUSE_TIMEOUT,
58   CAUSE_DOOMSDAY
59 };
60
61 struct appl_hooks {
62   void (*open)(struct flow *f, u64 when);
63   void (*input)(struct flow *f, int dir, struct pkt *p); /* dir0 = sent by initiator */
64   void (*close)(struct flow *f, int cause, u64 when);
65 };
66
67 struct iphdr;
68
69 void tcp_init(void);
70 void tcp_cleanup(void);
71 void tcp_got_packet(struct iphdr *iph, struct pkt *p);
72
73 /* save.c */
74
75 extern struct appl_hooks appl_save, appl_asave;
76 extern uns asave_width;