HACK: pinfo->private_data points to smb_info again
[wireshark-wip.git] / epan / stream.h
blobe26eddfb6de36e33d3e66ee75ea60725ed767122
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 * $Id$
9 * Wireshark - Network traffic analyzer
10 * By Gerald Combs <gerald@wireshark.org>
11 * Copyright 1998 Gerald Combs
13 * This program is free software; you can redistribute it and/or
14 * modify it under the terms of the GNU General Public License
15 * as published by the Free Software Foundation; either version 2
16 * of the License, or (at your option) any later version.
18 * This program is distributed in the hope that it will be useful,
19 * but WITHOUT ANY WARRANTY; without even the implied warranty of
20 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
21 * GNU General Public License for more details.
23 * You should have received a copy of the GNU General Public License
24 * along with this program; if not, write to the Free Software
25 * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA.
28 #ifndef STREAM_H
29 #define STREAM_H
31 #include <epan/tvbuff.h>
32 #include <epan/reassemble.h>
33 #include "ws_symbol_export.h"
35 struct _fragment_items;
37 /* A stream represents the concept of an arbitrary stream of data,
38 divided up into frames for transmission, where the frames have
39 little or no correspondence to the PDUs of the protocol being
40 streamed, and those PDUs are just delineated by a magic number.
42 For example, we stream H.223 over IAX2. IAX2 has no concept of
43 H.223 PDUs and just divides the H.223 stream into 160-byte
44 frames. H.223 PDUs are delineated by two-byte magic numbers (which
45 may, of course, straddle an IAX2 frame boundary).
47 Essentially we act as a wrapper to reassemble.h, by making up
48 PDU ids and keeping some additional data on fragments to allow the
49 PDUs to be defragmented again.
53 /* A stream_t represents a stream. There might be one or two streams
54 in a circuit, depending on whether that circuit is mono- or bi-directional.
56 typedef struct stream stream_t;
58 /* Fragments in a PDU are represented using a stream_pdu_fragment_t,
59 and placed in a linked-list with other fragments in the PDU.
61 (They're also placed in a hash so we can find them again later)
63 typedef struct stream_pdu_fragment stream_pdu_fragment_t;
67 struct circuit;
68 struct conversation;
70 /* initialise a new stream. Call this when you first identify a distinct
71 * stream. The circit pointer is just used as a key to look up the stream. */
72 WS_DLL_PUBLIC stream_t *stream_new_circ ( const struct circuit *circuit, int p2p_dir );
73 extern stream_t *stream_new_conv ( const struct conversation *conv, int p2p_dir );
75 /* retrieve a previously-created stream.
77 * Returns null if no matching stream was found.
79 WS_DLL_PUBLIC stream_t *find_stream_circ ( const struct circuit *circuit, int p2p_dir );
80 extern stream_t *find_stream_conv ( const struct conversation *conv, int p2p_dir );
84 /* see if we've seen this fragment before.
86 The framenum and offset are just hash keys, so can be any values unique
87 to this frame, but the idea is that you use the number of the frame being
88 disassembled, and the byte-offset within that frame.
90 WS_DLL_PUBLIC stream_pdu_fragment_t *stream_find_frag( stream_t *stream, guint32 framenum, guint32 offset );
92 /* add a new fragment to the fragment tables for the stream. The framenum and
93 * offset are keys allowing future access with stream_find_frag(), tvb is the
94 * fragment to be added, and pinfo is the information for the frame containing
95 * this fragment. more_frags should be set if this is the final fragment in the
96 * PDU.
98 * * the fragment must be later in the stream than any previous fragment
99 * (ie, framenum.offset must be greater than those passed on the previous
100 * call)
102 * This essentially means that you can only add fragments on the first pass
103 * through the stream.
105 WS_DLL_PUBLIC stream_pdu_fragment_t *stream_add_frag( stream_t *stream, guint32 framenum, guint32 offset,
106 tvbuff_t *tvb, packet_info *pinfo, gboolean more_frags );
108 /* Get the length of a fragment previously found by stream_find_frag().
110 extern guint32 stream_get_frag_length( const stream_pdu_fragment_t *frag);
112 /* Get a handle on the top of the chain of fragment_datas underlying this PDU
113 * frag can be any fragment within a PDU, and it will always return the head of
114 * the chain
116 * Returns NULL until the last fragment is added.
118 extern fragment_head *stream_get_frag_data( const stream_pdu_fragment_t *frag);
121 * Process reassembled data; if this is the last fragment, put the fragment
122 * information into the protocol tree, and construct a tvbuff with the
123 * reassembled data, otherwise just put a "reassembled in" item into the
124 * protocol tree.
126 WS_DLL_PUBLIC tvbuff_t *stream_process_reassembled(
127 tvbuff_t *tvb, int offset, packet_info *pinfo,
128 const char *name, const stream_pdu_fragment_t *frag,
129 const struct _fragment_items *fit,
130 gboolean *update_col_infop, proto_tree *tree);
132 /* Get the PDU number. PDUs are numbered from zero within a stream.
133 * frag can be any fragment within a PDU.
135 extern guint32 stream_get_pdu_no( const stream_pdu_fragment_t *frag);
137 /* initialise the stream routines */
138 void stream_init( void );
139 void stream_cleanup( void );
141 #endif /* STREAM_H */