Wireshark  4.3.0
The Wireshark network protocol analyzer
ptvcursor.h
Go to the documentation of this file.
1 
13 #ifndef __PTVCURSOR_H__
14 #define __PTVCURSOR_H__
15 
16 #include <glib.h>
17 #include <epan/packet.h>
18 #include "ws_symbol_export.h"
19 
20 #define SUBTREE_UNDEFINED_LENGTH -1
21 
22 typedef struct ptvcursor ptvcursor_t;
23 
24 /* Allocates an initializes a ptvcursor_t with 3 variables:
25  * proto_tree, tvbuff, and offset. */
26 WS_DLL_PUBLIC
28 ptvcursor_new(wmem_allocator_t *scope, proto_tree* tree, tvbuff_t* tvb, gint offset);
29 
30 /* Gets data from tvbuff, adds it to proto_tree, increments offset,
31  * and returns proto_item* */
32 WS_DLL_PUBLIC
34 ptvcursor_add(ptvcursor_t* ptvc, int hf, gint length, const guint encoding);
35 
36 /* Gets data from tvbuff, adds it to proto_tree, increments offset,
37  * and returns proto_item* and uint value retreived*/
38 WS_DLL_PUBLIC
40 ptvcursor_add_ret_uint(ptvcursor_t* ptvc, int hf, gint length, const guint encoding, guint32 *retval);
41 
42 /* Gets data from tvbuff, adds it to proto_tree, increments offset,
43  * and returns proto_item* and int value retreived */
44 WS_DLL_PUBLIC
46 ptvcursor_add_ret_int(ptvcursor_t* ptvc, int hf, gint length, const guint encoding, gint32 *retval);
47 
48 /* Gets data from tvbuff, adds it to proto_tree, increments offset,
49  * and returns proto_item* and string value retreived */
50 WS_DLL_PUBLIC
52 ptvcursor_add_ret_string(ptvcursor_t* ptvc, int hf, gint length, const guint encoding, wmem_allocator_t *scope, const guint8 **retval);
53 
54 /* Gets data from tvbuff, adds it to proto_tree, increments offset,
55  * and returns proto_item* and boolean value retreived */
56 WS_DLL_PUBLIC
58 ptvcursor_add_ret_boolean(ptvcursor_t* ptvc, int hf, gint length, const guint encoding, bool *retval);
59 
60 /* Gets data from tvbuff, adds it to proto_tree, *DOES NOT* increment
61  * offset, and returns proto_item* */
62 WS_DLL_PUBLIC
64 ptvcursor_add_no_advance(ptvcursor_t* ptvc, int hf, gint length, const guint encoding);
65 
66 /* Advance the ptvcursor's offset within its tvbuff without
67  * adding anything to the proto_tree. */
68 WS_DLL_PUBLIC
69 void
70 ptvcursor_advance(ptvcursor_t* ptvc, gint length);
71 
72 /* Frees memory for ptvcursor_t, but nothing deeper than that. */
73 WS_DLL_PUBLIC
74 void
75 ptvcursor_free(ptvcursor_t* ptvc);
76 
77 /* Returns tvbuff. */
78 WS_DLL_PUBLIC
79 tvbuff_t*
80 ptvcursor_tvbuff(ptvcursor_t* ptvc);
81 
82 /* Returns current offset. */
83 WS_DLL_PUBLIC
84 gint
85 ptvcursor_current_offset(ptvcursor_t* ptvc);
86 
87 /* Returns the proto_tree* */
88 WS_DLL_PUBLIC
90 ptvcursor_tree(ptvcursor_t* ptvc);
91 
92 /* Sets a new proto_tree* for the ptvcursor_t */
93 WS_DLL_PUBLIC
94 void
95 ptvcursor_set_tree(ptvcursor_t* ptvc, proto_tree* tree);
96 
97 /* push a subtree in the tree stack of the cursor */
98 WS_DLL_PUBLIC
100 ptvcursor_push_subtree(ptvcursor_t* ptvc, proto_item* it, gint ett_subtree);
101 
102 /* pop a subtree in the tree stack of the cursor */
103 WS_DLL_PUBLIC
104 void
105 ptvcursor_pop_subtree(ptvcursor_t* ptvc);
106 
107 /* Add an item to the tree and create a subtree
108  * If the length is unknown, length may be defined as SUBTREE_UNDEFINED_LENGTH.
109  * In this case, when the subtree will be closed, the parent item length will
110  * be equal to the advancement of the cursor since the creation of the subtree.
111  */
112 WS_DLL_PUBLIC
113 proto_tree*
114 ptvcursor_add_with_subtree(ptvcursor_t* ptvc, int hfindex, gint length,
115  const guint encoding, gint ett_subtree);
116 
117 /* Add a text node to the tree and create a subtree
118  * If the length is unknown, length may be defined as SUBTREE_UNDEFINED_LENGTH.
119  * In this case, when the subtree will be closed, the item length will be equal
120  * to the advancement of the cursor since the creation of the subtree.
121  */
122 WS_DLL_PUBLIC
123 proto_tree*
124 ptvcursor_add_text_with_subtree(ptvcursor_t* ptvc, gint length,
125  gint ett_subtree, const char* format, ...)
126  G_GNUC_PRINTF(4, 5);
127 
128 /* Creates a subtree and adds it to the cursor as the working tree but does not
129  * save the old working tree */
130 WS_DLL_PUBLIC
131 proto_tree*
132 ptvcursor_set_subtree(ptvcursor_t* ptvc, proto_item* it, gint ett_subtree);
133 
134 #endif /* __PTVCURSOR_H__ */
Definition: proto.h:904
Definition: wmem_allocator.h:27
Definition: proto.c:67
Definition: tvbuff-int.h:35