TLS13: update pre_shared_key lengths for draft -19
[metze/wireshark/wip.git] / epan / ptvcursor.h
1 /* ptvcursor.h
2  *
3  * Proto Tree TVBuff cursor
4  * Gilbert Ramirez <gram@alumni.rice.edu>
5  *
6  * Wireshark - Network traffic analyzer
7  * By Gerald Combs <gerald@wireshark.org>
8  * Copyright 2000 Gerald Combs
9  *
10  * This program is free software; you can redistribute it and/or
11  * modify it under the terms of the GNU General Public License
12  * as published by the Free Software Foundation; either version 2
13  * of the License, or (at your option) any later version.
14  *
15  * This program is distributed in the hope that it will be useful,
16  * but WITHOUT ANY WARRANTY; without even the implied warranty of
17  * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
18  * GNU General Public License for more details.
19  *
20  * You should have received a copy of the GNU General Public License
21  * along with this program; if not, write to the Free Software
22  * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA.
23  */
24
25 #ifndef __PTVCURSOR_H__
26 #define __PTVCURSOR_H__
27
28 #include <glib.h>
29 #include <epan/packet.h>
30 #include "ws_symbol_export.h"
31
32 #define SUBTREE_UNDEFINED_LENGTH -1
33
34 typedef struct ptvcursor ptvcursor_t;
35
36 /* Allocates an initializes a ptvcursor_t with 3 variables:
37  * proto_tree, tvbuff, and offset. */
38 WS_DLL_PUBLIC
39 ptvcursor_t*
40 ptvcursor_new(proto_tree* tree, tvbuff_t* tvb, gint offset);
41
42 /* Gets data from tvbuff, adds it to proto_tree, increments offset,
43  * and returns proto_item* */
44 WS_DLL_PUBLIC
45 proto_item*
46 ptvcursor_add(ptvcursor_t* ptvc, int hf, gint length, const guint encoding);
47
48
49 /* Gets data from tvbuff, adds it to proto_tree, *DOES NOT* increment
50  * offset, and returns proto_item* */
51 WS_DLL_PUBLIC
52 proto_item*
53 ptvcursor_add_no_advance(ptvcursor_t* ptvc, int hf, gint length, const guint encoding);
54
55 /* Advance the ptvcursor's offset within its tvbuff without
56  * adding anything to the proto_tree. */
57 WS_DLL_PUBLIC
58 void
59 ptvcursor_advance(ptvcursor_t* ptvc, gint length);
60
61 /* Frees memory for ptvcursor_t, but nothing deeper than that. */
62 WS_DLL_PUBLIC
63 void
64 ptvcursor_free(ptvcursor_t* ptvc);
65
66 /* Returns tvbuff. */
67 WS_DLL_PUBLIC
68 tvbuff_t*
69 ptvcursor_tvbuff(ptvcursor_t* ptvc);
70
71 /* Returns current offset. */
72 WS_DLL_PUBLIC
73 gint
74 ptvcursor_current_offset(ptvcursor_t* ptvc);
75
76 /* Returns the proto_tree* */
77 WS_DLL_PUBLIC
78 proto_tree*
79 ptvcursor_tree(ptvcursor_t* ptvc);
80
81 /* Sets a new proto_tree* for the ptvcursor_t */
82 WS_DLL_PUBLIC
83 void
84 ptvcursor_set_tree(ptvcursor_t* ptvc, proto_tree* tree);
85
86 /* push a subtree in the tree stack of the cursor */
87 WS_DLL_PUBLIC
88 proto_tree*
89 ptvcursor_push_subtree(ptvcursor_t* ptvc, proto_item* it, gint ett_subtree);
90
91 /* pop a subtree in the tree stack of the cursor */
92 WS_DLL_PUBLIC
93 void
94 ptvcursor_pop_subtree(ptvcursor_t* ptvc);
95
96 /* Add an item to the tree and create a subtree
97  * If the length is unknown, length may be defined as SUBTREE_UNDEFINED_LENGTH.
98  * In this case, when the subtree will be closed, the parent item length will
99  * be equal to the advancement of the cursor since the creation of the subtree.
100  */
101 WS_DLL_PUBLIC
102 proto_tree*
103 ptvcursor_add_with_subtree(ptvcursor_t* ptvc, int hfindex, gint length,
104     const guint encoding, gint ett_subtree);
105
106 /* Add a text node to the tree and create a subtree
107  * If the length is unknown, length may be defined as SUBTREE_UNDEFINED_LENGTH.
108  * In this case, when the subtree will be closed, the item length will be equal
109  * to the advancement of the cursor since the creation of the subtree.
110  */
111 WS_DLL_PUBLIC
112 proto_tree*
113 ptvcursor_add_text_with_subtree(ptvcursor_t* ptvc, gint length,
114     gint ett_subtree, const char* format, ...)
115     G_GNUC_PRINTF(4, 5);
116
117 /* Creates a subtree and adds it to the cursor as the working tree but does not
118  * save the old working tree */
119 WS_DLL_PUBLIC
120 proto_tree*
121 ptvcursor_set_subtree(ptvcursor_t* ptvc, proto_item* it, gint ett_subtree);
122
123 #endif /* __PTVCURSOR_H__ */