Wireshark 4.7.0
The Wireshark network protocol analyzer
Loading...
Searching...
No Matches
tap-tcp-stream.h
Go to the documentation of this file.
1
14#ifndef __TAP_TCP_STREAM_H__
15#define __TAP_TCP_STREAM_H__
16
17#ifdef __cplusplus
18extern "C" {
19#endif /* __cplusplus */
20
21typedef enum tcp_graph_type_ {
22 GRAPH_TSEQ_STEVENS,
23 GRAPH_TSEQ_TCPTRACE,
24 GRAPH_THROUGHPUT,
25 GRAPH_RTT,
26 GRAPH_WSCALE,
27 GRAPH_UNDEFINED
28} tcp_graph_type;
29
30#define RTT_ALL 0x0001
31#define RTT_SAK 0x0002
32#define RTT_RTT 0x0004
33#define RTT_KRN 0x0008
34
35typedef enum rtt_sampling_method_ {
36 SAMPLING_ALL,
37 SAMPLING_ALL_SACK,
38 SAMPLING_RTT,
39 SAMPLING_KARN,
40 SAMPLING_UNDEFINED
41} rtt_sampling_method;
42
43struct segment {
44 struct segment *next;
45 uint32_t num;
46 uint32_t rel_secs;
47 uint32_t rel_usecs;
48 /* Currently unused.
49 time_t abs_secs;
50 uint32_t abs_usecs;
51 */
52
53 uint32_t th_seq;
54 uint32_t th_ack;
55 uint32_t th_rawseq;
56 uint32_t th_rawack;
57 uint16_t th_flags;
58 uint32_t th_win; /* make it 32 bits so we can handle some scaling */
59 uint32_t th_seglen;
60 uint16_t th_sport;
61 uint16_t th_dport;
62 address ip_src;
63 address ip_dst;
64
65 bool ack_karn; /* true when ambiguous according to Karn's algo */
66
67 uint8_t num_sack_ranges;
68 uint32_t sack_left_edge[MAX_TCP_SACK_RANGES];
69 uint32_t sack_right_edge[MAX_TCP_SACK_RANGES];
70};
71
72struct tcp_graph {
73 tcp_graph_type type;
74
75 /* RTT sampling method (for RTT graphs only) */
76 uint8_t rtt_sampling;
77
78 /* The stream this graph will show */
79 address src_address;
80 uint16_t src_port;
81 address dst_address;
82 uint16_t dst_port;
83 uint32_t stream;
84 /* Should this be a map or tree instead? */
85 struct segment *segments;
86 struct segment *last;
87};
88
99
108void graph_segment_list_free(struct tcp_graph *tg);
109
110/* for compare_headers() */
111/* segment went the same direction as the currently selected one */
112#define COMPARE_CURR_DIR 0
113#define COMPARE_ANY_DIR 1
114
128int compare_headers(address *saddr1, address *daddr1, uint16_t sport1, uint16_t dport1, const address *saddr2, const address *daddr2, uint16_t sport2, uint16_t dport2, int dir);
129
135int get_num_dsegs(struct tcp_graph *tg);
136
143int get_num_acks(struct tcp_graph *tg, int *num_sack_ranges);
144
154
155/* This is used by rtt module only */
156struct rtt_unack {
157 struct rtt_unack *next;
158 double time;
159 unsigned int seqno;
160 unsigned int end_seqno;
161};
162
173bool rtt_is_retrans(struct rtt_unack *list, unsigned int seqno);
174
183struct rtt_unack *rtt_get_new_unack(double time_val, unsigned int seqno, unsigned int seglen);
184
191void rtt_put_unack_on_list(struct rtt_unack **l, struct rtt_unack *new_unack);
192
199void rtt_delete_unack_from_list(struct rtt_unack **l, struct rtt_unack *dead);
200
206void rtt_destroy_unack_list(struct rtt_unack **l);
207
215static inline int
216tcp_seq_eq(uint32_t s1, uint32_t s2) {
217 return (int32_t)(s1 - s2) == 0;
218}
219
227static inline int
228tcp_seq_before(uint32_t s1, uint32_t s2) {
229 return (int32_t)(s1 - s2) < 0;
230}
231
239static inline int
240tcp_seq_eq_or_after(uint32_t s1, uint32_t s2) {
241 return !tcp_seq_before(s1, s2);
242}
243
251static inline int
252tcp_seq_after(uint32_t s1, uint32_t s2) {
253 return (int32_t)(s1 - s2) > 0;
254}
255
264static inline int
265tcp_seq_before_or_eq(uint32_t s1, uint32_t s2) {
266 return !tcp_seq_after(s1, s2);
267}
268
269#ifdef __cplusplus
270}
271#endif /* __cplusplus */
272
273#endif /* __TAP_TCP_STREAM_H__ */
Definition address.h:55
Definition cfile.h:68
Definition tap-tcp-stream.h:156
Definition tap-tcp-stream.h:43
Definition stream.c:41
Definition tap-tcp-stream.h:72
bool rtt_is_retrans(struct rtt_unack *list, unsigned int seqno)
Definition tap-tcp-stream.c:360
int compare_headers(address *saddr1, address *daddr1, uint16_t sport1, uint16_t dport1, const address *saddr2, const address *daddr2, uint16_t sport2, uint16_t dport2, int dir)
Compares the headers of two TCP segments.
Definition tap-tcp-stream.c:180
void rtt_put_unack_on_list(struct rtt_unack **l, struct rtt_unack *new_unack)
Adds a new unacknowledged packet to the list.
Definition tap-tcp-stream.c:386
uint32_t select_tcpip_session(capture_file *cf)
Selects a TCP/IP session based on capture file.
Definition tap-tcp-stream.c:285
int get_num_dsegs(struct tcp_graph *tg)
Gets the number of data segments in a TCP graph.
Definition tap-tcp-stream.c:201
void graph_segment_list_get(capture_file *cf, struct tcp_graph *tg)
Fill in the segment list for a TCP graph.
Definition tap-tcp-stream.c:138
int get_num_acks(struct tcp_graph *tg, int *num_sack_ranges)
Gets the number of ACKs in a TCP graph.
Definition tap-tcp-stream.c:219
void rtt_destroy_unack_list(struct rtt_unack **l)
Destroys the unacknowledged list of TCP sequences.
Definition tap-tcp-stream.c:424
struct rtt_unack * rtt_get_new_unack(double time_val, unsigned int seqno, unsigned int seglen)
Creates a new RTT unacknowledged packet structure.
Definition tap-tcp-stream.c:374
void graph_segment_list_free(struct tcp_graph *tg)
Frees the memory allocated for a TCP graph segment list.
Definition tap-tcp-stream.c:162
void rtt_delete_unack_from_list(struct rtt_unack **l, struct rtt_unack *dead)
Removes a specific RTT unacknowledged packet from the list.
Definition tap-tcp-stream.c:402