3 * Structures that most TVB users should not be accessing directly.
5 * Wireshark - Network traffic analyzer
6 * By Gerald Combs <gerald@wireshark.org>
7 * Copyright 1998 Gerald Combs
9 * SPDX-License-Identifier: GPL-2.0-or-later
12 #ifndef __TVBUFF_INT_H__
13 #define __TVBUFF_INT_H__
19 void (*tvb_free
)(struct tvbuff
*tvb
);
20 guint (*tvb_offset
)(const struct tvbuff
*tvb
, guint counter
);
21 const guint8
*(*tvb_get_ptr
)(struct tvbuff
*tvb
, guint abs_offset
, guint abs_length
);
22 void *(*tvb_memcpy
)(struct tvbuff
*tvb
, void *target
, guint offset
, guint length
);
24 gint (*tvb_find_guint8
)(tvbuff_t
*tvb
, guint abs_offset
, guint limit
, guint8 needle
);
25 gint (*tvb_ws_mempbrk_pattern_guint8
)(tvbuff_t
*tvb
, guint abs_offset
, guint limit
, const ws_mempbrk_pattern
* pattern
, guchar
*found_needle
);
27 tvbuff_t
*(*tvb_clone
)(tvbuff_t
*tvb
, guint abs_offset
, guint abs_length
);
33 #define TVBUFF_FRAGMENT 0x00000001 /* this is a fragment */
36 /* Doubly linked list pointers */
40 const struct tvb_ops
*ops
;
43 struct tvbuff
*ds_tvb
; /**< data source top-level tvbuff */
45 /** Pointer to the data for this tvbuff.
46 * It might be null, which either means that 1) it's a
47 * zero-length tvbuff or 2) the tvbuff was lazily
48 * constructed, so that we don't allocate a buffer of
49 * backing data and fill it in unless we need that
50 * data, e.g. when tvb_get_ptr() is called.
52 const guint8
*real_data
;
54 /** Amount of data that's available from the capture
55 * file. This is the length of virtual buffer (and/or
56 * real_data). It may be less than the reported
57 * length if this is from a packet that was cut short
58 * by the capture process.
60 * This must never be > reported_length or contained_length. */
63 /** Amount of data that was reported as being in
64 * the packet or other data that this represents.
65 * As indicated above, it may be greater than the
66 * amount of data that's available. */
67 guint reported_length
;
69 /** If this was extracted from a parent tvbuff,
70 * this is the amount of extracted data that
71 * was reported as being in the parent tvbuff;
72 * if this represents a blob of data in that
73 * tvbuff that has a length specified by data
74 * in that tvbuff, it might be greater than
75 * the amount of data that was actually there
76 * to extract, so it could be greater than
79 * If this wasn't extracted from a parent tvbuff,
80 * this is the same as reported_length.
82 * This must never be > reported_length. */
83 guint contained_length
;
85 /* Offset from beginning of first "real" tvbuff. */
89 WS_DLL_PUBLIC tvbuff_t
*tvb_new(const struct tvb_ops
*ops
);
91 tvbuff_t
*tvb_new_proxy(tvbuff_t
*backing
);
93 void tvb_add_to_chain(tvbuff_t
*parent
, tvbuff_t
*child
);
95 guint
tvb_offset_from_real_beginning_counter(const tvbuff_t
*tvb
, const guint counter
);
97 void tvb_check_offset_length(const tvbuff_t
*tvb
, const gint offset
, gint
const length_val
, guint
*offset_ptr
, guint
*length_ptr
);