Wireshark 4.7.0
The Wireshark network protocol analyzer
Loading...
Searching...
No Matches
stream.h
Go to the documentation of this file.
1
13#pragma once
14#include <epan/tvbuff.h>
15#include <epan/reassemble.h>
16#include "ws_symbol_export.h"
17
18struct _fragment_items;
19
20/* A stream represents the concept of an arbitrary stream of data,
21 divided up into frames for transmission, where the frames have
22 little or no correspondence to the PDUs of the protocol being
23 streamed, and those PDUs are just delineated by a magic number.
24
25 For example, we stream H.223 over IAX2. IAX2 has no concept of
26 H.223 PDUs and just divides the H.223 stream into 160-byte
27 frames. H.223 PDUs are delineated by two-byte magic numbers (which
28 may, of course, straddle an IAX2 frame boundary).
29
30 Essentially we act as a wrapper to reassemble.h, by making up
31 PDU ids and keeping some additional data on fragments to allow the
32 PDUs to be defragmented again.
33*/
34
35
36/* A stream_t represents a stream. There might be one or two streams
37 in a circuit, depending on whether that circuit is mono- or bi-directional.
38*/
39typedef struct stream stream_t;
40
41/* Fragments in a PDU are represented using a stream_pdu_fragment_t,
42 and placed in a linked-list with other fragments in the PDU.
43
44 (They're also placed in a hash so we can find them again later)
45*/
47
48
49struct conversation;
50
51/* initialise a new stream. Call this when you first identify a distinct
52 * stream. The conversation pointer is just used as a key to look up the stream.
53 */
54WS_DLL_PUBLIC stream_t *stream_new ( const struct conversation *conv, int p2p_dir );
55
56/* retrieve a previously-created stream.
57 *
58 * Returns null if no matching stream was found.
59 */
60WS_DLL_PUBLIC stream_t *find_stream ( const struct conversation *conv, int p2p_dir );
61
62
63
64/* see if we've seen this fragment before.
65
66 The framenum and offset are just hash keys, so can be any values unique
67 to this frame, but the idea is that you use the number of the frame being
68 disassembled, and the byte-offset within that frame.
69*/
70WS_DLL_PUBLIC stream_pdu_fragment_t *stream_find_frag( stream_t *stream, uint32_t framenum, uint32_t offset );
71
72/* add a new fragment to the fragment tables for the stream. The framenum and
73 * offset are keys allowing future access with stream_find_frag(), tvb is the
74 * fragment to be added, and pinfo is the information for the frame containing
75 * this fragment. more_frags should be set if this is the final fragment in the
76 * PDU.
77 *
78 * * the fragment must be later in the stream than any previous fragment
79 * (ie, framenum.offset must be greater than those passed on the previous
80 * call)
81 *
82 * This essentially means that you can only add fragments on the first pass
83 * through the stream.
84 */
85WS_DLL_PUBLIC stream_pdu_fragment_t *stream_add_frag( stream_t *stream, uint32_t framenum, uint32_t offset,
86 tvbuff_t *tvb, packet_info *pinfo, bool more_frags );
87
93extern uint32_t stream_get_frag_length( const stream_pdu_fragment_t *frag);
94
95/* Get a handle on the top of the chain of fragment_datas underlying this PDU
96 * frag can be any fragment within a PDU, and it will always return the head of
97 * the chain
98 *
99 * Returns NULL until the last fragment is added.
100 */
101WS_DLL_PUBLIC fragment_head *stream_get_frag_data( const stream_pdu_fragment_t *frag);
102
103/*
104 * Process reassembled data; if this is the last fragment, put the fragment
105 * information into the protocol tree, and construct a tvbuff with the
106 * reassembled data, otherwise just put a "reassembled in" item into the
107 * protocol tree.
108 */
109WS_DLL_PUBLIC tvbuff_t *stream_process_reassembled(
110 tvbuff_t *tvb, int offset, packet_info *pinfo,
111 const char *name, const stream_pdu_fragment_t *frag,
112 const struct _fragment_items *fit,
113 bool *update_col_infop, proto_tree *tree);
114
120extern uint32_t stream_get_pdu_no( const stream_pdu_fragment_t *frag);
121
122/* initialise the stream routines */
123
127void stream_init( void );
128
132void stream_cleanup( void );
void stream_init(void)
Initializes stream-related data structures and reassembly tables.
Definition stream.c:311
uint32_t stream_get_frag_length(const stream_pdu_fragment_t *frag)
Get the length of a fragment previously found by stream_find_frag().
Definition stream.c:400
void stream_cleanup(void)
Cleans up stream-related data structures and reassembly tables.
Definition stream.c:302
uint32_t stream_get_pdu_no(const stream_pdu_fragment_t *frag)
Get the PDU number. PDUs are numbered from zero within a stream.
Definition stream.c:412
Definition reassemble.h:73
Definition reassemble.h:625
Definition packet_info.h:40
Definition proto.h:902
Definition conversation.h:227
Definition stream.c:35
Definition stream.c:41
Definition tvbuff-int.h:33