In some dialogs, have *no* auto-default buttons on macOS.
[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  * SPDX-License-Identifier: GPL-2.0-or-later*/
11
12 #ifndef __TAP_TCP_STREAM_H__
13 #define __TAP_TCP_STREAM_H__
14
15 #ifdef __cplusplus
16 extern "C" {
17 #endif /* __cplusplus */
18
19 typedef enum tcp_graph_type_ {
20     GRAPH_TSEQ_STEVENS,
21     GRAPH_TSEQ_TCPTRACE,
22     GRAPH_THROUGHPUT,
23     GRAPH_RTT,
24     GRAPH_WSCALE,
25     GRAPH_UNDEFINED
26 } tcp_graph_type;
27
28 struct segment {
29     struct segment *next;
30     guint32 num;
31     guint32 rel_secs;
32     guint32 rel_usecs;
33     /* Currently unused.
34     guint32 abs_secs;
35     guint32 abs_usecs;
36     */
37
38     guint32 th_seq;
39     guint32 th_ack;
40     guint16 th_flags;
41     guint32 th_win;   /* make it 32 bits so we can handle some scaling */
42     guint32 th_seglen;
43     guint16 th_sport;
44     guint16 th_dport;
45     address ip_src;
46     address ip_dst;
47
48     guint8  num_sack_ranges;
49     guint32 sack_left_edge[MAX_TCP_SACK_RANGES];
50     guint32 sack_right_edge[MAX_TCP_SACK_RANGES];
51 };
52
53 struct tcp_graph {
54     tcp_graph_type   type;
55
56     /* The stream this graph will show */
57     address          src_address;
58     guint16          src_port;
59     address          dst_address;
60     guint16          dst_port;
61     guint32          stream;
62     /* Should this be a map or tree instead? */
63     struct segment  *segments;
64 };
65
66 /** Fill in the segment list for a TCP graph
67  *
68  * @param cf Capture file to scan
69  * @param tg TCP graph. A valid stream must be set. If either the source or
70  *        destination address types are AT_NONE the address and port
71  *        information will be filled in using the first packet in the
72  *        specified stream.
73  * @param stream_known If FALSE, session information will be filled in using
74  *        the currently selected packet. If FALSE, session information will
75  *        be matched against tg.
76  */
77 void graph_segment_list_get(capture_file *cf, struct tcp_graph *tg, gboolean stream_known );
78 void graph_segment_list_free(struct tcp_graph * );
79
80 /* for compare_headers() */
81 /* segment went the same direction as the currently selected one */
82 #define COMPARE_CURR_DIR    0
83 #define COMPARE_ANY_DIR     1
84
85 int compare_headers(address *saddr1, address *daddr1, guint16 sport1, guint16 dport1, const address *saddr2, const address *daddr2, guint16 sport2, guint16 dport2, int dir);
86
87 int get_num_dsegs(struct tcp_graph * );
88 int get_num_acks(struct tcp_graph *, int * );
89
90 struct tcpheader *select_tcpip_session(capture_file *, struct segment * );
91
92 /* This is used by rtt module only */
93 struct rtt_unack {
94     struct rtt_unack *next;
95     double        time;
96     unsigned int  seqno;
97     unsigned int  end_seqno;
98 };
99
100 int rtt_is_retrans(struct rtt_unack * , unsigned int );
101 struct rtt_unack *rtt_get_new_unack(double , unsigned int , unsigned int );
102 void rtt_put_unack_on_list(struct rtt_unack ** , struct rtt_unack * );
103 void rtt_delete_unack_from_list(struct rtt_unack ** , struct rtt_unack * );
104 void rtt_destroy_unack_list(struct rtt_unack ** );
105
106 static inline int
107 tcp_seq_before(guint32 s1, guint32 s2) {
108     return (gint32)(s1 - s2) < 0;
109 }
110
111 static inline int
112 tcp_seq_eq_or_after(guint32 s1, guint32 s2) {
113     return !tcp_seq_before(s1, s2);
114 }
115
116 static inline int
117 tcp_seq_after(guint32 s1, guint32 s2) {
118     return (gint32)(s1 - s2) > 0;
119 }
120
121 static inline int tcp_seq_before_or_eq(guint32 s1, guint32 s2) {
122     return !tcp_seq_after(s1, s2);
123 }
124
125 #ifdef __cplusplus
126 }
127 #endif /* __cplusplus */
128
129 #endif /* __TAP_TCP_STREAM_H__ */
130
131 /*
132  * Editor modelines
133  *
134  * Local Variables:
135  * c-basic-offset: 4
136  * tab-width: 8
137  * indent-tabs-mode: nil
138  * End:
139  *
140  * ex: set shiftwidth=4 tabstop=8 expandtab:
141  * :indentSize=4:tabSize=8:noTabs=true:
142  */