packet-ldap: fix regression for SASL handling
[wireshark-sm.git] / epan / stream.h
blobfd36b046eacd447823c3d02c43fcbeeb0d1168b9
1 /* stream.h
3 * Definititions for handling circuit-switched protocols
4 * which are handled as streams, and don't have lengths
5 * and IDs such as are required for reassemble.h
7 * Wireshark - Network traffic analyzer
8 * By Gerald Combs <gerald@wireshark.org>
9 * Copyright 1998 Gerald Combs
11 * SPDX-License-Identifier: GPL-2.0-or-later
14 #ifndef STREAM_H
15 #define STREAM_H
17 #include <epan/tvbuff.h>
18 #include <epan/reassemble.h>
19 #include "ws_symbol_export.h"
21 struct _fragment_items;
23 /* A stream represents the concept of an arbitrary stream of data,
24 divided up into frames for transmission, where the frames have
25 little or no correspondence to the PDUs of the protocol being
26 streamed, and those PDUs are just delineated by a magic number.
28 For example, we stream H.223 over IAX2. IAX2 has no concept of
29 H.223 PDUs and just divides the H.223 stream into 160-byte
30 frames. H.223 PDUs are delineated by two-byte magic numbers (which
31 may, of course, straddle an IAX2 frame boundary).
33 Essentially we act as a wrapper to reassemble.h, by making up
34 PDU ids and keeping some additional data on fragments to allow the
35 PDUs to be defragmented again.
39 /* A stream_t represents a stream. There might be one or two streams
40 in a circuit, depending on whether that circuit is mono- or bi-directional.
42 typedef struct stream stream_t;
44 /* Fragments in a PDU are represented using a stream_pdu_fragment_t,
45 and placed in a linked-list with other fragments in the PDU.
47 (They're also placed in a hash so we can find them again later)
49 typedef struct stream_pdu_fragment stream_pdu_fragment_t;
53 struct circuit;
54 struct conversation;
56 /* initialise a new stream. Call this when you first identify a distinct
57 * stream. The circit pointer is just used as a key to look up the stream. */
58 WS_DLL_PUBLIC stream_t *stream_new_circ ( const struct circuit *circuit, int p2p_dir );
59 extern stream_t *stream_new_conv ( const struct conversation *conv, int p2p_dir );
61 /* retrieve a previously-created stream.
63 * Returns null if no matching stream was found.
65 WS_DLL_PUBLIC stream_t *find_stream_circ ( const struct circuit *circuit, int p2p_dir );
66 extern stream_t *find_stream_conv ( const struct conversation *conv, int p2p_dir );
70 /* see if we've seen this fragment before.
72 The framenum and offset are just hash keys, so can be any values unique
73 to this frame, but the idea is that you use the number of the frame being
74 disassembled, and the byte-offset within that frame.
76 WS_DLL_PUBLIC stream_pdu_fragment_t *stream_find_frag( stream_t *stream, guint32 framenum, guint32 offset );
78 /* add a new fragment to the fragment tables for the stream. The framenum and
79 * offset are keys allowing future access with stream_find_frag(), tvb is the
80 * fragment to be added, and pinfo is the information for the frame containing
81 * this fragment. more_frags should be set if this is the final fragment in the
82 * PDU.
84 * * the fragment must be later in the stream than any previous fragment
85 * (ie, framenum.offset must be greater than those passed on the previous
86 * call)
88 * This essentially means that you can only add fragments on the first pass
89 * through the stream.
91 WS_DLL_PUBLIC stream_pdu_fragment_t *stream_add_frag( stream_t *stream, guint32 framenum, guint32 offset,
92 tvbuff_t *tvb, packet_info *pinfo, gboolean more_frags );
94 /* Get the length of a fragment previously found by stream_find_frag().
96 extern guint32 stream_get_frag_length( const stream_pdu_fragment_t *frag);
98 /* Get a handle on the top of the chain of fragment_datas underlying this PDU
99 * frag can be any fragment within a PDU, and it will always return the head of
100 * the chain
102 * Returns NULL until the last fragment is added.
104 extern fragment_head *stream_get_frag_data( const stream_pdu_fragment_t *frag);
107 * Process reassembled data; if this is the last fragment, put the fragment
108 * information into the protocol tree, and construct a tvbuff with the
109 * reassembled data, otherwise just put a "reassembled in" item into the
110 * protocol tree.
112 WS_DLL_PUBLIC tvbuff_t *stream_process_reassembled(
113 tvbuff_t *tvb, int offset, packet_info *pinfo,
114 const char *name, const stream_pdu_fragment_t *frag,
115 const struct _fragment_items *fit,
116 gboolean *update_col_infop, proto_tree *tree);
118 /* Get the PDU number. PDUs are numbered from zero within a stream.
119 * frag can be any fragment within a PDU.
121 extern guint32 stream_get_pdu_no( const stream_pdu_fragment_t *frag);
123 /* initialise the stream routines */
124 void stream_init( void );
125 void stream_cleanup( void );
127 #endif /* STREAM_H */