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