Wireshark 4.7.0
The Wireshark network protocol analyzer
Loading...
Searching...
No Matches
tvbuff-int.h
Go to the documentation of this file.
1
11#pragma once
12struct tvbuff;
13
17struct tvb_ops {
18 size_t tvb_size;
24 void (*tvb_free)(struct tvbuff *tvb);
25
32 unsigned (*tvb_offset)(const struct tvbuff *tvb, unsigned counter);
33
41 const uint8_t *(*tvb_get_ptr)(struct tvbuff *tvb, unsigned abs_offset, unsigned abs_length);
42
51 void *(*tvb_memcpy)(struct tvbuff *tvb, void *target, unsigned offset, unsigned length);
52
62 bool (*tvb_find_uint8)(tvbuff_t *tvb, unsigned abs_offset, unsigned limit, uint8_t needle, unsigned *found_offset);
63
74 bool (*tvb_ws_mempbrk_pattern_uint8)(tvbuff_t *tvb, unsigned abs_offset, unsigned limit, const ws_mempbrk_pattern* pattern, unsigned *found_offset, unsigned char *found_needle);
75
83 tvbuff_t *(*tvb_clone)(tvbuff_t *tvb, unsigned abs_offset, unsigned abs_length);
84};
85
86/*
87 * Tvbuff flags.
88 */
89#define TVBUFF_FRAGMENT 0x00000001
90#define TVBUFF_RAW_OFFSET 0x00000002
95struct tvbuff {
96 /* Doubly linked list pointers */
99 /* Record-keeping */
100 const struct tvb_ops* ops;
102 unsigned flags;
103 struct tvbuff* ds_tvb;
109 const uint8_t* real_data;
110
115 unsigned length;
116
121
129
132 unsigned raw_offset;
133};
134
141tvbuff_t *tvb_new(const struct tvb_ops *ops);
142
150
157void tvb_add_to_chain(tvbuff_t *parent, tvbuff_t *child);
158
166unsigned tvb_offset_from_real_beginning_counter(const tvbuff_t *tvb, const unsigned counter);
167
175void tvb_validate_offset_length(const tvbuff_t *tvb, const unsigned offset, const unsigned length);
176
184void tvb_validate_offset_and_remaining(const tvbuff_t *tvb, const unsigned offset, unsigned *rem_len);
185
195void tvb_check_offset_length(const tvbuff_t *tvb, const int offset, int const length_val, unsigned *offset_ptr, unsigned *length_ptr);
Vtable of low-level operations implementing a specific tvbuff backing type.
Definition tvbuff-int.h:17
unsigned(* tvb_offset)(const struct tvbuff *tvb, unsigned counter)
Translates a logical counter value to a physical byte offset within the tvbuff's backing data.
Definition tvbuff-int.h:32
size_t tvb_size
Definition tvbuff-int.h:18
void(* tvb_free)(struct tvbuff *tvb)
Releases any resources owned by the tvbuff when it is freed.
Definition tvbuff-int.h:24
bool(* tvb_find_uint8)(tvbuff_t *tvb, unsigned abs_offset, unsigned limit, uint8_t needle, unsigned *found_offset)
Searches for the first occurrence of a single byte value within a region of the tvbuff.
Definition tvbuff-int.h:62
bool(* tvb_ws_mempbrk_pattern_uint8)(tvbuff_t *tvb, unsigned abs_offset, unsigned limit, const ws_mempbrk_pattern *pattern, unsigned *found_offset, unsigned char *found_needle)
Searches for the first byte within a region that matches any byte in a pre-compiled pattern.
Definition tvbuff-int.h:74
Core tvbuff (testy virtual buffer) structure representing a region of packet data,...
Definition tvbuff-int.h:95
bool initialized
Definition tvbuff-int.h:101
unsigned length
Definition tvbuff-int.h:115
unsigned raw_offset
Definition tvbuff-int.h:132
tvbuff_t * next
Definition tvbuff-int.h:97
unsigned reported_length
Definition tvbuff-int.h:120
unsigned flags
Definition tvbuff-int.h:102
const uint8_t * real_data
Definition tvbuff-int.h:109
const struct tvb_ops * ops
Definition tvbuff-int.h:100
unsigned contained_length
Definition tvbuff-int.h:128
struct tvbuff * ds_tvb
Definition tvbuff-int.h:103
Definition ws_mempbrk.h:21
void tvb_validate_offset_length(const tvbuff_t *tvb, const unsigned offset, const unsigned length)
Validates that an offset and length are within the bounds of a TVBuffer.
Definition tvbuff.c:302
void tvb_validate_offset_and_remaining(const tvbuff_t *tvb, const unsigned offset, unsigned *rem_len)
Validates that an offset and remaining length are within the bounds of a TVBuffer.
Definition tvbuff.c:312
tvbuff_t * tvb_new(const struct tvb_ops *ops)
Creates a new TVB (Packet Buffer) with the specified operations.
Definition tvbuff.c:70
unsigned tvb_offset_from_real_beginning_counter(const tvbuff_t *tvb, const unsigned counter)
Calculates the offset from the real beginning of a TVBuffer using a counter.
Definition tvbuff.c:881
tvbuff_t * tvb_new_proxy(tvbuff_t *backing)
Creates a new TVBuffer that is a proxy for an existing TVBuffer.
Definition tvbuff_subset.c:234
void tvb_check_offset_length(const tvbuff_t *tvb, const int offset, int const length_val, unsigned *offset_ptr, unsigned *length_ptr)
Validates that an offset and length are within the bounds of a tvbuff.
Definition tvbuff.c:442
void tvb_add_to_chain(tvbuff_t *parent, tvbuff_t *child)
Adds a child tvbuff to the parent tvbuff chain.
Definition tvbuff.c:141