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