Wireshark 4.7.0
The Wireshark network protocol analyzer
Loading...
Searching...
No Matches
Macros | Typedefs | Functions
ptvcursor.h File Reference
#include <epan/packet.h>
#include "ws_symbol_export.h"

Go to the source code of this file.

Macros

#define SUBTREE_UNDEFINED_LENGTH   -1
 

Typedefs

typedef struct ptvcursor ptvcursor_t
 

Functions

WS_DLL_PUBLIC ptvcursor_tptvcursor_new (wmem_allocator_t *scope, proto_tree *tree, tvbuff_t *tvb, unsigned offset)
 Creates a new protocol tree cursor.
 
WS_DLL_PUBLIC proto_itemptvcursor_add (ptvcursor_t *ptvc, int hf, int length, const unsigned encoding)
 Adds data from tvbuff to proto_tree and increments offset.
 
WS_DLL_PUBLIC proto_itemptvcursor_add_ret_uint (ptvcursor_t *ptvc, int hf, unsigned length, const unsigned encoding, uint32_t *retval)
 Adds a uint32_t value to the protocol tree and returns it.
 
WS_DLL_PUBLIC proto_itemptvcursor_add_ret_int (ptvcursor_t *ptvc, int hf, unsigned length, const unsigned encoding, int32_t *retval)
 Adds an integer value to the protocol tree and returns it.
 
WS_DLL_PUBLIC proto_itemptvcursor_add_ret_string (ptvcursor_t *ptvc, int hf, int length, const unsigned encoding, wmem_allocator_t *scope, const uint8_t **retval)
 Adds a string to the protocol tree and returns the proto_item* and the retrieved string value.
 
WS_DLL_PUBLIC proto_itemptvcursor_add_ret_boolean (ptvcursor_t *ptvc, int hf, unsigned length, const unsigned encoding, bool *retval)
 Adds a boolean value to the protocol tree and returns it.
 
WS_DLL_PUBLIC proto_itemptvcursor_add_no_advance (ptvcursor_t *ptvc, int hf, int length, const unsigned encoding)
 Adds a new item to the protocol tree without advancing the cursor.
 
WS_DLL_PUBLIC void ptvcursor_advance (ptvcursor_t *ptvc, unsigned length)
 Advances the ptvcursor's offset within its tvbuff without adding anything to the proto_tree.
 
WS_DLL_PUBLIC void ptvcursor_free (ptvcursor_t *ptvc)
 Frees a ptvcursor_t structure.
 
WS_DLL_PUBLIC tvbuff_tptvcursor_tvbuff (ptvcursor_t *ptvc)
 Retrieves the tvbuff associated with the protocol tree cursor.
 
WS_DLL_PUBLIC unsigned ptvcursor_current_offset (ptvcursor_t *ptvc)
 Returns the current offset in the protocol tree cursor.
 
WS_DLL_PUBLIC proto_treeptvcursor_tree (ptvcursor_t *ptvc)
 Returns the current proto_tree associated with the ptvcursor.
 
WS_DLL_PUBLIC void ptvcursor_set_tree (ptvcursor_t *ptvc, proto_tree *tree)
 Sets a new proto_tree* for the ptvcursor_t.
 
WS_DLL_PUBLIC proto_treeptvcursor_push_subtree (ptvcursor_t *ptvc, proto_item *it, int ett_subtree)
 Pushes a subtree onto the tree stack of the cursor.
 
WS_DLL_PUBLIC void ptvcursor_pop_subtree (ptvcursor_t *ptvc)
 Pops a subtree from the protocol tree cursor.
 
WS_DLL_PUBLIC proto_treeptvcursor_add_with_subtree (ptvcursor_t *ptvc, int hfindex, int length, const unsigned encoding, int ett_subtree)
 
WS_DLL_PUBLIC proto_treeptvcursor_add_text_with_subtree (ptvcursor_t *ptvc, int length, int ett_subtree, const char *format,...)
 Adds text with a subtree to the cursor.
 
WS_DLL_PUBLIC proto_treeptvcursor_set_subtree (ptvcursor_t *ptvc, proto_item *it, int ett_subtree)
 Sets a new subtree for the protocol tree cursor.
 

Detailed Description

Proto Tree TVBuff cursor Gilbert Ramirez gram@.nosp@m.alum.nosp@m.ni.ri.nosp@m.ce.e.nosp@m.du

Wireshark - Network traffic analyzer By Gerald Combs geral.nosp@m.d@wi.nosp@m.resha.nosp@m.rk.o.nosp@m.rg Copyright 2000 Gerald Combs

SPDX-License-Identifier: GPL-2.0-or-later

Function Documentation

◆ ptvcursor_add()

WS_DLL_PUBLIC proto_item * ptvcursor_add ( ptvcursor_t ptvc,
int  hf,
int  length,
const unsigned  encoding 
)

Adds data from tvbuff to proto_tree and increments offset.

Gets data from tvbuff, adds it to proto_tree, increments offset, and returns proto_item*

Parameters
ptvcPointer to ptvcursor_t structure.
hfIndex of header field to use for adding data.
lengthLength of data to add.
encodingEncoding of the data.
Returns
proto_item* Pointer to the newly added proto_item.

◆ ptvcursor_add_no_advance()

WS_DLL_PUBLIC proto_item * ptvcursor_add_no_advance ( ptvcursor_t ptvc,
int  hf,
int  length,
const unsigned  encoding 
)

Adds a new item to the protocol tree without advancing the cursor.

Gets data from tvbuff, adds it to proto_tree, DOES NOT increment offset, and returns proto_item

Parameters
ptvcPointer to the protocol tree cursor.
hfField identifier for the new item.
lengthLength of the data to be added.
encodingEncoding type for the data.

◆ ptvcursor_add_ret_boolean()

WS_DLL_PUBLIC proto_item * ptvcursor_add_ret_boolean ( ptvcursor_t ptvc,
int  hf,
unsigned  length,
const unsigned  encoding,
bool *  retval 
)

Adds a boolean value to the protocol tree and returns it.

Gets data from tvbuff, adds it to proto_tree, increments offset, and returns proto_item* and boolean value retrieved

Parameters
ptvcPointer to the protocol tree cursor.
hfThe header field index for the item.
lengthThe length of the data to be added.
encodingThe encoding type of the data.
retvalPointer to store the retrieved boolean value.
Returns
proto_item* Pointer to the newly created protocol item.

◆ ptvcursor_add_ret_int()

WS_DLL_PUBLIC proto_item * ptvcursor_add_ret_int ( ptvcursor_t ptvc,
int  hf,
unsigned  length,
const unsigned  encoding,
int32_t *  retval 
)

Adds an integer value to the protocol tree and returns it.

Gets data from tvbuff, adds it to proto_tree, increments offset, and returns proto_item* and int value retrieved

Parameters
ptvcPointer to the protocol tree cursor.
hfThe field index for the new item.
lengthThe length of the data to be added.
encodingThe encoding type for the data.
retvalPointer to store the retrieved integer value.
Returns
proto_item* Pointer to the newly created protocol item.

◆ ptvcursor_add_ret_string()

WS_DLL_PUBLIC proto_item * ptvcursor_add_ret_string ( ptvcursor_t ptvc,
int  hf,
int  length,
const unsigned  encoding,
wmem_allocator_t scope,
const uint8_t **  retval 
)

Adds a string to the protocol tree and returns the proto_item* and the retrieved string value.

Gets data from tvbuff, adds it to proto_tree, increments offset, and returns proto_item* and string value retrieved

Parameters
ptvcPointer to the protocol tree cursor.
hfThe field ID for the new item.
lengthThe length of the data to be added.
encodingThe encoding type of the data.
scopeThe memory allocator scope for the returned string.
retvalPointer to store the retrieved string value.
Returns
proto_item* Pointer to the newly created protocol tree item.

◆ ptvcursor_add_ret_uint()

WS_DLL_PUBLIC proto_item * ptvcursor_add_ret_uint ( ptvcursor_t ptvc,
int  hf,
unsigned  length,
const unsigned  encoding,
uint32_t *  retval 
)

Adds a uint32_t value to the protocol tree and returns it.

Gets data from tvbuff, adds it to proto_tree, increments offset, and returns proto_item* and uint value retrieved

Parameters
ptvcPointer to the protocol tree cursor.
hfField ID for the new item.
lengthLength of the data to be added.
encodingEncoding type for the data.
retvalPointer to store the retrieved uint32_t value.
Returns
proto_item* Pointer to the newly created protocol item.

◆ ptvcursor_add_text_with_subtree()

WS_DLL_PUBLIC proto_tree * ptvcursor_add_text_with_subtree ( ptvcursor_t ptvc,
int  length,
int  ett_subtree,
const char *  format,
  ... 
)

Adds text with a subtree to the cursor.

Add a text node to the tree and create a subtree If the length is unknown, length may be defined as SUBTREE_UNDEFINED_LENGTH. In this case, when the subtree will be closed, the item length will be equal to the advancement of the cursor since the creation of the subtree.

Parameters
ptvcPointer to the protocol tree cursor.
lengthLength of the text, or SUBTREE_UNDEFINED_LENGTH if unknown.
ett_subtreeThe ETT (Expert Tree Tag) for the subtree.
formatFormat string for the text.
Returns
proto_tree* Pointer to the created subtree.

◆ ptvcursor_advance()

WS_DLL_PUBLIC void ptvcursor_advance ( ptvcursor_t ptvc,
unsigned  length 
)

Advances the ptvcursor's offset within its tvbuff without adding anything to the proto_tree.

Parameters
ptvcPointer to the protocol tree cursor.
lengthThe amount to advance the offset.

◆ ptvcursor_current_offset()

WS_DLL_PUBLIC unsigned ptvcursor_current_offset ( ptvcursor_t ptvc)

Returns the current offset in the protocol tree cursor.

Parameters
ptvcPointer to the protocol tree cursor.
Returns
The current offset as a size_t value.

◆ ptvcursor_free()

WS_DLL_PUBLIC void ptvcursor_free ( ptvcursor_t ptvc)

Frees a ptvcursor_t structure.

Frees memory for ptvcursor_t, but nothing deeper than that.

Parameters
ptvcPointer to the ptvcursor_t structure to be freed.

◆ ptvcursor_new()

WS_DLL_PUBLIC ptvcursor_t * ptvcursor_new ( wmem_allocator_t scope,
proto_tree tree,
tvbuff_t tvb,
unsigned  offset 
)

Creates a new protocol tree cursor.

Allocates and initializes a ptvcursor_t with the given proto_tree, tvbuff, and offset.

Parameters
scopeMemory allocation scope for the cursor.
treeProtocol tree to which data will be added.
tvbBuffer containing the data to be dissected.
offsetInitial offset within the buffer.
Returns
Pointer to the newly created ptvcursor_t.

◆ ptvcursor_pop_subtree()

WS_DLL_PUBLIC void ptvcursor_pop_subtree ( ptvcursor_t ptvc)

Pops a subtree from the protocol tree cursor.

This function removes the most recently added subtree from the protocol tree cursor, effectively closing it and returning to the parent context.

Parameters
ptvcPointer to the protocol tree cursor.

◆ ptvcursor_push_subtree()

WS_DLL_PUBLIC proto_tree * ptvcursor_push_subtree ( ptvcursor_t ptvc,
proto_item it,
int  ett_subtree 
)

Pushes a subtree onto the tree stack of the cursor.

Parameters
ptvcPointer to the protocol tree cursor.
itProtocol item for the subtree.
ett_subtreeExpert Tree ID for the subtree.

◆ ptvcursor_set_subtree()

WS_DLL_PUBLIC proto_tree * ptvcursor_set_subtree ( ptvcursor_t ptvc,
proto_item it,
int  ett_subtree 
)

Sets a new subtree for the protocol tree cursor.

Creates a subtree and adds it to the cursor as the working tree but does not save the old working tree

Parameters
ptvcPointer to the protocol tree cursor.
itProtocol item representing the subtree.
ett_subtreeExpert Tree ID for the subtree.

◆ ptvcursor_set_tree()

WS_DLL_PUBLIC void ptvcursor_set_tree ( ptvcursor_t ptvc,
proto_tree tree 
)

Sets a new proto_tree* for the ptvcursor_t.

Parameters
ptvcPointer to the ptvcursor_t structure.
treePointer to the proto_tree to be set.

◆ ptvcursor_tree()

WS_DLL_PUBLIC proto_tree * ptvcursor_tree ( ptvcursor_t ptvc)

Returns the current proto_tree associated with the ptvcursor.

Parameters
ptvcPointer to the ptvcursor_t structure.
Returns
The current proto_tree*.

◆ ptvcursor_tvbuff()

WS_DLL_PUBLIC tvbuff_t * ptvcursor_tvbuff ( ptvcursor_t ptvc)

Retrieves the tvbuff associated with the protocol tree cursor.

Parameters
ptvcPointer to the protocol tree cursor.
Returns
Pointer to the tvbuff associated with the cursor.