Wireshark 4.7.3
The Wireshark network protocol analyzer
Loading...
Searching...
No Matches
wscbor.h
Go to the documentation of this file.
1
14#pragma once
15#include <ws_symbol_export.h>
16#include <epan/tvbuff.h>
17#include <epan/proto.h>
18#include <epan/expert.h>
20
21#ifdef __cplusplus
22extern "C" {
23#endif
24
27WS_DLL_PUBLIC
28void wscbor_init(void);
29
34WS_DLL_PUBLIC
35const ei_register_info * wscbor_expert_items(int *size);
36
48
59
61typedef struct {
65 const char *msg;
67
75WS_DLL_PUBLIC
76wscbor_error_t * wscbor_error_new(wmem_allocator_t *alloc, expert_field *ei, const char *format, ...) G_GNUC_PRINTF(3,4);
77
79typedef struct {
81 int start;
83 int length;
85 uint64_t value;
87
89typedef struct _wscbor_chunk_priv_t wscbor_chunk_priv_t;
91typedef struct {
93 wscbor_chunk_priv_t *_priv;
94
96 int start;
105
110 uint8_t type_minor;
112 uint64_t head_value;
114
128WS_DLL_PUBLIC
129wscbor_chunk_t * wscbor_chunk_read(wmem_allocator_t *alloc, tvbuff_t *tvb, int *offset);
130
135WS_DLL_PUBLIC
137
145WS_DLL_PUBLIC
146uint64_t wscbor_chunk_mark_errors(packet_info *pinfo, proto_item *item, const wscbor_chunk_t *chunk);
147
153WS_DLL_PUBLIC
154unsigned wscbor_has_errors(const wscbor_chunk_t *chunk);
155
161WS_DLL_PUBLIC
163
175WS_DLL_PUBLIC
176bool wscbor_skip_next_item(wmem_allocator_t *alloc, tvbuff_t *tvb, int *offset);
177
188WS_DLL_PUBLIC
189bool wscbor_skip_if_errors(wmem_allocator_t *alloc, tvbuff_t *tvb, int *offset, const wscbor_chunk_t *chunk);
190
191
198WS_DLL_PUBLIC
200
206WS_DLL_PUBLIC
208
216WS_DLL_PUBLIC
217bool wscbor_require_array_size(wscbor_chunk_t *chunk, uint64_t count_min, uint64_t count_max);
218
224WS_DLL_PUBLIC
226
234WS_DLL_PUBLIC
236
245WS_DLL_PUBLIC
246uint64_t * wscbor_require_uint64(wmem_allocator_t *alloc, wscbor_chunk_t *chunk);
247
256WS_DLL_PUBLIC
258
271WS_DLL_PUBLIC
273
282WS_DLL_PUBLIC
284
298WS_DLL_PUBLIC
299proto_item * proto_tree_add_cbor_container(proto_tree *tree, int hfindex, packet_info *pinfo, tvbuff_t *tvb, const wscbor_chunk_t *chunk);
300
310WS_DLL_PUBLIC
311proto_item * proto_tree_add_cbor_ctrl(proto_tree *tree, int hfindex, packet_info *pinfo, tvbuff_t *tvb, const wscbor_chunk_t *chunk);
312
324WS_DLL_PUBLIC
325proto_item * proto_tree_add_cbor_boolean(proto_tree *tree, int hfindex, packet_info *pinfo, tvbuff_t *tvb, const wscbor_chunk_t *chunk, const bool *value);
326
338WS_DLL_PUBLIC
339proto_item * proto_tree_add_cbor_uint64(proto_tree *tree, int hfindex, packet_info *pinfo, tvbuff_t *tvb, const wscbor_chunk_t *chunk, const uint64_t *value);
340
352WS_DLL_PUBLIC
353proto_item * proto_tree_add_cbor_int64(proto_tree *tree, int hfindex, packet_info *pinfo, tvbuff_t *tvb, const wscbor_chunk_t *chunk, const int64_t *value);
354
368WS_DLL_PUBLIC
369proto_item * proto_tree_add_cbor_bitmask(proto_tree *tree, int hfindex, const int ett, int *const *fields, packet_info *pinfo, tvbuff_t *tvb, const wscbor_chunk_t *chunk, const uint64_t *value);
370
381WS_DLL_PUBLIC
382proto_item * proto_tree_add_cbor_tstr(proto_tree *tree, int hfindex, packet_info *pinfo, tvbuff_t *tvb, const wscbor_chunk_t *chunk);
383
394WS_DLL_PUBLIC
395proto_item * proto_tree_add_cbor_bstr(proto_tree *tree, int hfindex, packet_info *pinfo, tvbuff_t *tvb, const wscbor_chunk_t *chunk);
396
406WS_DLL_PUBLIC
407proto_item * proto_tree_add_cbor_strlen(proto_tree *tree, int hfindex, packet_info *pinfo, tvbuff_t *tvb, const wscbor_chunk_t *chunk);
408
409#ifdef __cplusplus
410}
411#endif
struct _packet_info packet_info
Represents the metadata and indexing information for a single captured frame.
proto_node proto_item
Definition proto.h:927
struct _wmem_list_t wmem_list_t
Opaque type representing a scoped, doubly-linked list in the wmem system.
Definition wmem_list.h:42
struct _wmem_allocator_t wmem_allocator_t
Definition wmem_core.h:44
Definition wscbor.c:143
Bundles an expert_field handle with its expert_field_info for use in bulk registration.
Definition expert.h:77
Pairs an expert info index with its associated header field index for registration and display.
Definition expert.h:41
A data-containing, optionally-tagged chunk of CBOR.
Definition wscbor.h:91
int data_length
The length of this chunk and its immediate definite data (i.e. strings).
Definition wscbor.h:100
uint8_t type_minor
Minor type of this item.
Definition wscbor.h:110
wmem_list_t * tags
Tags on this chunk, in encoded order (type wscbor_tag_t*).
Definition wscbor.h:104
uint64_t head_value
The header-encoded value.
Definition wscbor.h:112
cbor_type type_major
Definition wscbor.h:108
int start
The start offset of this chunk.
Definition wscbor.h:96
int head_length
The length of just this header and any preceding tags.
Definition wscbor.h:98
wmem_list_t * errors
Errors processing this chunk (type wscbor_error_t*).
Definition wscbor.h:102
wscbor_chunk_priv_t * _priv
Internal private data.
Definition wscbor.h:93
Decoding or require_* error.
Definition wscbor.h:61
expert_field * ei
The associated expert info.
Definition wscbor.h:63
const char * msg
Optional specific text.
Definition wscbor.h:65
Tag metadata and value.
Definition wscbor.h:79
uint64_t value
The tag value.
Definition wscbor.h:85
int start
The start offset of this tag head.
Definition wscbor.h:81
int length
The length of just this tag head.
Definition wscbor.h:83
WS_DLL_PUBLIC uint64_t * wscbor_require_uint64(wmem_allocator_t *alloc, wscbor_chunk_t *chunk)
Definition wscbor.c:552
WS_DLL_PUBLIC char * wscbor_require_tstr(wmem_allocator_t *alloc, wscbor_chunk_t *chunk)
Definition wscbor.c:599
WS_DLL_PUBLIC proto_item * proto_tree_add_cbor_bitmask(proto_tree *tree, int hfindex, const int ett, int *const *fields, packet_info *pinfo, tvbuff_t *tvb, const wscbor_chunk_t *chunk, const uint64_t *value)
Add an item representing a bitmask value.
Definition wscbor.c:655
WS_DLL_PUBLIC proto_item * proto_tree_add_cbor_boolean(proto_tree *tree, int hfindex, packet_info *pinfo, tvbuff_t *tvb, const wscbor_chunk_t *chunk, const bool *value)
Adds a CBOR boolean item to the protocol tree.
Definition wscbor.c:637
WS_DLL_PUBLIC const ei_register_info * wscbor_expert_items(int *size)
Definition wscbor.c:486
WS_DLL_PUBLIC bool wscbor_require_map(wscbor_chunk_t *chunk)
Definition wscbor.c:524
WS_DLL_PUBLIC proto_item * proto_tree_add_cbor_int64(proto_tree *tree, int hfindex, packet_info *pinfo, tvbuff_t *tvb, const wscbor_chunk_t *chunk, const int64_t *value)
Adds a CBOR integer item to the protocol tree.
Definition wscbor.c:649
WS_DLL_PUBLIC wscbor_chunk_t * wscbor_chunk_read(wmem_allocator_t *alloc, tvbuff_t *tvb, int *offset)
Definition wscbor.c:197
cbor_type
The same enumeration from libcbor-0.5.
Definition wscbor.h:38
@ CBOR_TYPE_FLOAT_CTRL
decimals and special values (true, false, nil, ...)
Definition wscbor.h:46
@ CBOR_TYPE_TAG
tags
Definition wscbor.h:45
@ CBOR_TYPE_UINT
positive integers
Definition wscbor.h:39
@ CBOR_TYPE_BYTESTRING
byte strings
Definition wscbor.h:41
@ CBOR_TYPE_STRING
text strings
Definition wscbor.h:42
@ CBOR_TYPE_NEGINT
negative integers
Definition wscbor.h:40
WS_DLL_PUBLIC bool wscbor_require_major_type(wscbor_chunk_t *chunk, cbor_type major)
Definition wscbor.c:493
WS_DLL_PUBLIC proto_item * proto_tree_add_cbor_uint64(proto_tree *tree, int hfindex, packet_info *pinfo, tvbuff_t *tvb, const wscbor_chunk_t *chunk, const uint64_t *value)
Adds a CBOR unsigned integer item to the protocol tree.
Definition wscbor.c:643
WS_DLL_PUBLIC bool wscbor_is_indefinite_break(const wscbor_chunk_t *chunk)
Determine if an indefinite break is present.
Definition wscbor.c:369
WS_DLL_PUBLIC bool * wscbor_require_boolean(wmem_allocator_t *alloc, wscbor_chunk_t *chunk)
Definition wscbor.c:528
WS_DLL_PUBLIC bool wscbor_skip_next_item(wmem_allocator_t *alloc, tvbuff_t *tvb, int *offset)
Recursively skip items from a stream.
Definition wscbor.c:461
WS_DLL_PUBLIC int64_t * wscbor_require_int64(wmem_allocator_t *alloc, wscbor_chunk_t *chunk)
Definition wscbor.c:562
_cbor_ctrl
CBOR simple (control) values, mirroring the cbor_ctrl enumeration from libcbor 0.5.
Definition wscbor.h:52
@ CBOR_CTRL_UNDEF
Definition wscbor.h:57
@ CBOR_CTRL_NULL
Definition wscbor.h:56
@ CBOR_CTRL_FALSE
Definition wscbor.h:54
@ CBOR_CTRL_NONE
Definition wscbor.h:53
@ CBOR_CTRL_TRUE
Definition wscbor.h:55
WS_DLL_PUBLIC bool wscbor_require_array_size(wscbor_chunk_t *chunk, uint64_t count_min, uint64_t count_max)
Definition wscbor.c:509
WS_DLL_PUBLIC bool wscbor_require_array(wscbor_chunk_t *chunk)
Definition wscbor.c:505
WS_DLL_PUBLIC unsigned wscbor_has_errors(const wscbor_chunk_t *chunk)
Determine if a chunk has errors.
Definition wscbor.c:365
WS_DLL_PUBLIC proto_item * proto_tree_add_cbor_ctrl(proto_tree *tree, int hfindex, packet_info *pinfo, tvbuff_t *tvb, const wscbor_chunk_t *chunk)
Add an item representing a non-boolean, non-float control value.
Definition wscbor.c:631
WS_DLL_PUBLIC void wscbor_init(void)
Definition wscbor.c:475
WS_DLL_PUBLIC bool wscbor_skip_if_errors(wmem_allocator_t *alloc, tvbuff_t *tvb, int *offset, const wscbor_chunk_t *chunk)
Definition wscbor.c:465
WS_DLL_PUBLIC proto_item * proto_tree_add_cbor_tstr(proto_tree *tree, int hfindex, packet_info *pinfo, tvbuff_t *tvb, const wscbor_chunk_t *chunk)
Add an item representing a CBOR text string (tstr) value.
Definition wscbor.c:675
WS_DLL_PUBLIC tvbuff_t * wscbor_require_bstr(wmem_allocator_t *alloc, wscbor_chunk_t *chunk)
WS_DLL_PUBLIC uint64_t wscbor_chunk_mark_errors(packet_info *pinfo, proto_item *item, const wscbor_chunk_t *chunk)
After both reading and decoding a chunk, report on any errors found.
Definition wscbor.c:357
WS_DLL_PUBLIC proto_item * proto_tree_add_cbor_bstr(proto_tree *tree, int hfindex, packet_info *pinfo, tvbuff_t *tvb, const wscbor_chunk_t *chunk)
Add an item representing a CBOR byte string value.
Definition wscbor.c:688
WS_DLL_PUBLIC void wscbor_chunk_free(wscbor_chunk_t *chunk)
Free a chunk and its lists.
Definition wscbor.c:326
WS_DLL_PUBLIC proto_item * proto_tree_add_cbor_container(proto_tree *tree, int hfindex, packet_info *pinfo, tvbuff_t *tvb, const wscbor_chunk_t *chunk)
Add an item representing an array or map container.
Definition wscbor.c:615
WS_DLL_PUBLIC proto_item * proto_tree_add_cbor_strlen(proto_tree *tree, int hfindex, packet_info *pinfo, tvbuff_t *tvb, const wscbor_chunk_t *chunk)
Add an item representing the length of a bstr or tstr value.
WS_DLL_PUBLIC wscbor_error_t * wscbor_error_new(wmem_allocator_t *alloc, expert_field *ei, const char *format,...)
Definition wscbor.c:181