MAX_MCS_INDEX is a valid array index.
[metze/wireshark/wip.git] / epan / tvbuff-int.h
1 /* tvbuff-int.h
2  *
3  * Structures that most TVB users should not be accessing directly.
4  *
5  * Wireshark - Network traffic analyzer
6  * By Gerald Combs <gerald@wireshark.org>
7  * Copyright 1998 Gerald Combs
8  *
9  * This program is free software; you can redistribute it and/or
10  * modify it under the terms of the GNU General Public License
11  * as published by the Free Software Foundation; either version 2
12  * of the License, or (at your option) any later version.
13  *
14  * This program is distributed in the hope that it will be useful,
15  * but WITHOUT ANY WARRANTY; without even the implied warranty of
16  * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
17  * GNU General Public License for more details.
18  *
19  * You should have received a copy of the GNU General Public License
20  * along with this program; if not, write to the Free Software
21  * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA.
22  */
23
24 #ifndef __TVBUFF_INT_H__
25 #define __TVBUFF_INT_H__
26
27 struct tvbuff;
28
29 struct tvb_ops {
30         gsize tvb_size;
31         void (*tvb_free)(struct tvbuff *tvb);
32         guint (*tvb_offset)(const struct tvbuff *tvb, guint counter);
33         const guint8 *(*tvb_get_ptr)(struct tvbuff *tvb, guint abs_offset, guint abs_length);
34         void *(*tvb_memcpy)(struct tvbuff *tvb, void *target, guint offset, guint length);
35
36         gint (*tvb_find_guint8)(tvbuff_t *tvb, guint abs_offset, guint limit, guint8 needle);
37         gint (*tvb_ws_mempbrk_pattern_guint8)(tvbuff_t *tvb, guint abs_offset, guint limit, const ws_mempbrk_pattern* pattern, guchar *found_needle);
38
39         tvbuff_t *(*tvb_clone)(tvbuff_t *tvb, guint abs_offset, guint abs_length);
40 };
41
42 /*
43  * Tvbuff flags.
44  */
45 #define TVBUFF_FRAGMENT         0x00000001      /* this is a fragment */
46
47 struct tvbuff {
48         /* Doubly linked list pointers */
49         tvbuff_t                *next;
50
51         /* Record-keeping */
52         const struct tvb_ops   *ops;
53         gboolean                initialized;
54         guint                   flags;
55         struct tvbuff           *ds_tvb;  /**< data source top-level tvbuff */
56
57         /** We're either a TVBUFF_REAL_DATA or a
58          * TVBUFF_SUBSET that has a backing buffer that
59          * has real_data != NULL, or a TVBUFF_COMPOSITE
60          * which has flattened its data due to a call
61          * to tvb_get_ptr().
62          */
63         const guint8            *real_data;
64
65         /** Length of virtual buffer (and/or real_data). */
66         guint                   length;
67
68         /** Reported length. */
69         guint                   reported_length;
70
71         /* Offset from beginning of first TVBUFF_REAL. */
72         gint                    raw_offset;
73 };
74
75 WS_DLL_PUBLIC tvbuff_t *tvb_new(const struct tvb_ops *ops);
76
77 tvbuff_t *tvb_new_proxy(tvbuff_t *backing);
78
79 void tvb_add_to_chain(tvbuff_t *parent, tvbuff_t *child);
80
81 guint tvb_offset_from_real_beginning_counter(const tvbuff_t *tvb, const guint counter);
82
83 void tvb_check_offset_length(const tvbuff_t *tvb, const gint offset, gint const length_val, guint *offset_ptr, guint *length_ptr);
84 #endif