As suggested by Michael in https://bugs.wireshark.org/bugzilla/show_bug.cgi?id=4605 :
[metze/wireshark/wip.git] / ui / tap-tcp-stream.h
1 /* tap-tcp-stream.h
2  * TCP stream statistics
3  * Originally from tcp_graph.c by Pavel Mores <pvl@uh.cz>
4  * Win32 port:  rwh@unifiedtech.com
5  *
6  * $Id$
7  *
8  * Wireshark - Network traffic analyzer
9  * By Gerald Combs <gerald@wireshark.org>
10  * Copyright 1998 Gerald Combs
11  *
12  * This program is free software; you can redistribute it and/or
13  * modify it under the terms of the GNU General Public License
14  * as published by the Free Software Foundation; either version 2
15  * of the License, or (at your option) any later version.
16  *
17  * This program is distributed in the hope that it will be useful,
18  * but WITHOUT ANY WARRANTY; without even the implied warranty of
19  * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
20  * GNU General Public License for more details.
21  *
22  * You should have received a copy of the GNU General Public License
23  * along with this program; if not, write to the Free Software
24  * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA.
25  */
26
27 #ifndef __TAP_TCP_STREAM_H__
28 #define __TAP_TCP_STREAM_H__
29
30 #ifdef __cplusplus
31 extern "C" {
32 #endif /* __cplusplus */
33
34 typedef enum tcp_graph_type_ {
35     GRAPH_TSEQ_STEVENS,
36     GRAPH_TSEQ_TCPTRACE,
37     GRAPH_THROUGHPUT,
38     GRAPH_RTT,
39     GRAPH_WSCALE
40 } tcp_graph_type;
41
42 struct segment {
43     struct segment *next;
44     guint32 num;
45     guint32 rel_secs;
46     guint32 rel_usecs;
47     /* Currently unused.
48     guint32 abs_secs;
49     guint32 abs_usecs;
50     */
51
52     guint32 th_seq;
53     guint32 th_ack;
54     guint16 th_flags;
55     guint32 th_win;   /* make it 32 bits so we can handle some scaling */
56     guint32 th_seglen;
57     guint16 th_sport;
58     guint16 th_dport;
59     address ip_src;
60     address ip_dst;
61
62     guint8  num_sack_ranges;
63     guint32 sack_left_edge[MAX_TCP_SACK_RANGES];
64     guint32 sack_right_edge[MAX_TCP_SACK_RANGES];
65 };
66
67 struct tcp_graph {
68     tcp_graph_type   type;
69
70     /* The stream this graph will show */
71     address          src_address;
72     guint16          src_port;
73     address          dst_address;
74     guint16          dst_port;
75     guint32          stream;
76     /* Should this be a map or tree instead? */
77     struct segment  *segments;
78 };
79
80 /** Fill in the segment list for a TCP graph
81  *
82  * @param cf Capture file to scan
83  * @param tg TCP graph. A valid stream must be set. If either the source or
84  *        destination address types are AT_NONE the address and port
85  *        information will be filled in using the first packet in the
86  *        specified stream.
87  * @param stream_known If FALSE, session information will be filled in using
88  *        the currently selected packet. If FALSE, session information will
89  *        be matched against tg.
90  */
91 void graph_segment_list_get(capture_file *cf, struct tcp_graph *tg, gboolean stream_known );
92 void graph_segment_list_free(struct tcp_graph * );
93
94 /* for compare_headers() */
95 /* segment went the same direction as the currently selected one */
96 #define COMPARE_CURR_DIR    0
97 #define COMPARE_ANY_DIR     1
98
99 int compare_headers(address *saddr1, address *daddr1, guint16 sport1, guint16 dport1, const address *saddr2, const address *daddr2, guint16 sport2, guint16 dport2, int dir);
100
101 int get_num_dsegs(struct tcp_graph * );
102 int get_num_acks(struct tcp_graph *, int * );
103
104 struct tcpheader *select_tcpip_session(capture_file *, struct segment * );
105
106 /* This is used by rtt module only */
107 struct unack {
108     struct unack *next;
109     double        time;
110     unsigned int  seqno;
111 };
112
113 int rtt_is_retrans(struct unack * , unsigned int );
114 struct unack *rtt_get_new_unack(double , unsigned int );
115 void rtt_put_unack_on_list(struct unack ** , struct unack * );
116 void rtt_delete_unack_from_list(struct unack ** , struct unack * );
117
118
119 #ifdef __cplusplus
120 }
121 #endif /* __cplusplus */
122
123 #endif /* __TAP_TCP_STREAM_H__ */
124
125 /*
126  * Editor modelines
127  *
128  * Local Variables:
129  * c-basic-offset: 4
130  * tab-width: 8
131  * indent-tabs-mode: nil
132  * End:
133  *
134  * ex: set shiftwidth=4 tabstop=8 expandtab:
135  * :indentSize=4:tabSize=8:noTabs=true:
136  */