Wireshark 4.7.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#ifdef __cplusplus
20extern "C" {
21#endif
22
23#define SUBTREE_UNDEFINED_LENGTH -1
24
25typedef struct ptvcursor ptvcursor_t;
26
27/* Allocates an initializes a ptvcursor_t with 3 variables:
28 * proto_tree, tvbuff, and offset. */
29WS_DLL_PUBLIC
31ptvcursor_new(wmem_allocator_t *scope, proto_tree* tree, tvbuff_t* tvb, int offset);
32
33/* Gets data from tvbuff, adds it to proto_tree, increments offset,
34 * and returns proto_item* */
35WS_DLL_PUBLIC
37ptvcursor_add(ptvcursor_t* ptvc, int hf, int length, const unsigned encoding);
38
39/* Gets data from tvbuff, adds it to proto_tree, increments offset,
40 * and returns proto_item* and uint value retrieved*/
41WS_DLL_PUBLIC
43ptvcursor_add_ret_uint(ptvcursor_t* ptvc, int hf, int length, const unsigned encoding, uint32_t *retval);
44
45/* Gets data from tvbuff, adds it to proto_tree, increments offset,
46 * and returns proto_item* and int value retrieved */
47WS_DLL_PUBLIC
49ptvcursor_add_ret_int(ptvcursor_t* ptvc, int hf, int length, const unsigned encoding, int32_t *retval);
50
51/* Gets data from tvbuff, adds it to proto_tree, increments offset,
52 * and returns proto_item* and string value retrieved */
53WS_DLL_PUBLIC
55ptvcursor_add_ret_string(ptvcursor_t* ptvc, int hf, int length, const unsigned encoding, wmem_allocator_t *scope, const uint8_t **retval);
56
57/* Gets data from tvbuff, adds it to proto_tree, increments offset,
58 * and returns proto_item* and boolean value retrieved */
59WS_DLL_PUBLIC
61ptvcursor_add_ret_boolean(ptvcursor_t* ptvc, int hf, int length, const unsigned encoding, bool *retval);
62
63/* Gets data from tvbuff, adds it to proto_tree, *DOES NOT* increment
64 * offset, and returns proto_item* */
65WS_DLL_PUBLIC
67ptvcursor_add_no_advance(ptvcursor_t* ptvc, int hf, int length, const unsigned encoding);
68
69/* Advance the ptvcursor's offset within its tvbuff without
70 * adding anything to the proto_tree. */
71WS_DLL_PUBLIC
72void
73ptvcursor_advance(ptvcursor_t* ptvc, int length);
74
75/* Frees memory for ptvcursor_t, but nothing deeper than that. */
76WS_DLL_PUBLIC
77void
78ptvcursor_free(ptvcursor_t* ptvc);
79
80/* Returns tvbuff. */
81WS_DLL_PUBLIC
83ptvcursor_tvbuff(ptvcursor_t* ptvc);
84
85/* Returns current offset. */
86WS_DLL_PUBLIC
87int
88ptvcursor_current_offset(ptvcursor_t* ptvc);
89
90/* Returns the proto_tree* */
91WS_DLL_PUBLIC
93ptvcursor_tree(ptvcursor_t* ptvc);
94
95/* Sets a new proto_tree* for the ptvcursor_t */
96WS_DLL_PUBLIC
97void
98ptvcursor_set_tree(ptvcursor_t* ptvc, proto_tree* tree);
99
100/* push a subtree in the tree stack of the cursor */
101WS_DLL_PUBLIC
103ptvcursor_push_subtree(ptvcursor_t* ptvc, proto_item* it, int ett_subtree);
104
105/* pop a subtree in the tree stack of the cursor */
106WS_DLL_PUBLIC
107void
108ptvcursor_pop_subtree(ptvcursor_t* ptvc);
109
110/* Add an item to the tree and create a subtree
111 * If the length is unknown, length may be defined as SUBTREE_UNDEFINED_LENGTH.
112 * In this case, when the subtree will be closed, the parent item length will
113 * be equal to the advancement of the cursor since the creation of the subtree.
114 */
115WS_DLL_PUBLIC
117ptvcursor_add_with_subtree(ptvcursor_t* ptvc, int hfindex, int length,
118 const unsigned encoding, int ett_subtree);
119
120/* Add a text node to the tree and create a subtree
121 * If the length is unknown, length may be defined as SUBTREE_UNDEFINED_LENGTH.
122 * In this case, when the subtree will be closed, the item length will be equal
123 * to the advancement of the cursor since the creation of the subtree.
124 */
125WS_DLL_PUBLIC
127ptvcursor_add_text_with_subtree(ptvcursor_t* ptvc, int length,
128 int ett_subtree, const char* format, ...)
129 G_GNUC_PRINTF(4, 5);
130
131/* Creates a subtree and adds it to the cursor as the working tree but does not
132 * save the old working tree */
133WS_DLL_PUBLIC
135ptvcursor_set_subtree(ptvcursor_t* ptvc, proto_item* it, int ett_subtree);
136
137#ifdef __cplusplus
138}
139#endif
140
141#endif /* __PTVCURSOR_H__ */
Definition proto.h:907
Internal memory allocator interface used by the wmem subsystem.
Definition wmem_allocator.h:34
Definition proto.c:70
Definition tvbuff-int.h:35