Wireshark 4.7.0
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
50typedef enum {
51 CBOR_CTRL_NONE = 0,
52 CBOR_CTRL_FALSE = 20,
53 CBOR_CTRL_TRUE = 21,
54 CBOR_CTRL_NULL = 22,
55 CBOR_CTRL_UNDEF = 23
57
59typedef struct {
63 const char *msg;
65
73WS_DLL_PUBLIC
74wscbor_error_t * wscbor_error_new(wmem_allocator_t *alloc, expert_field *ei, const char *format, ...) G_GNUC_PRINTF(3,4);
75
77typedef struct {
79 int start;
81 int length;
83 uint64_t value;
85
112
126WS_DLL_PUBLIC
127wscbor_chunk_t * wscbor_chunk_read(wmem_allocator_t *alloc, tvbuff_t *tvb, int *offset);
128
131WS_DLL_PUBLIC
133
140WS_DLL_PUBLIC
141uint64_t wscbor_chunk_mark_errors(packet_info *pinfo, proto_item *item, const wscbor_chunk_t *chunk);
142
147WS_DLL_PUBLIC
148unsigned wscbor_has_errors(const wscbor_chunk_t *chunk);
149
155WS_DLL_PUBLIC
157
168WS_DLL_PUBLIC
169bool wscbor_skip_next_item(wmem_allocator_t *alloc, tvbuff_t *tvb, int *offset);
170
181WS_DLL_PUBLIC
182bool wscbor_skip_if_errors(wmem_allocator_t *alloc, tvbuff_t *tvb, int *offset, const wscbor_chunk_t *chunk);
183
184
191WS_DLL_PUBLIC
193
199WS_DLL_PUBLIC
201
209WS_DLL_PUBLIC
210bool wscbor_require_array_size(wscbor_chunk_t *chunk, uint64_t count_min, uint64_t count_max);
211
217WS_DLL_PUBLIC
219
227WS_DLL_PUBLIC
229
238WS_DLL_PUBLIC
239uint64_t * wscbor_require_uint64(wmem_allocator_t *alloc, wscbor_chunk_t *chunk);
240
249WS_DLL_PUBLIC
251
264WS_DLL_PUBLIC
266
275WS_DLL_PUBLIC
277
282WS_DLL_PUBLIC
283proto_item * proto_tree_add_cbor_container(proto_tree *tree, int hfindex, packet_info *pinfo, tvbuff_t *tvb, const wscbor_chunk_t *chunk);
284
287WS_DLL_PUBLIC
288proto_item * proto_tree_add_cbor_ctrl(proto_tree *tree, int hfindex, packet_info *pinfo, tvbuff_t *tvb, const wscbor_chunk_t *chunk);
289
301WS_DLL_PUBLIC
302proto_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);
303
315WS_DLL_PUBLIC
316proto_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);
317
329WS_DLL_PUBLIC
330proto_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);
331
345WS_DLL_PUBLIC
346proto_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);
347
358WS_DLL_PUBLIC
359proto_item * proto_tree_add_cbor_tstr(proto_tree *tree, int hfindex, packet_info *pinfo, tvbuff_t *tvb, const wscbor_chunk_t *chunk);
360
371WS_DLL_PUBLIC
372proto_item * proto_tree_add_cbor_bstr(proto_tree *tree, int hfindex, packet_info *pinfo, tvbuff_t *tvb, const wscbor_chunk_t *chunk);
373
383WS_DLL_PUBLIC
384proto_item * proto_tree_add_cbor_strlen(proto_tree *tree, int hfindex, packet_info *pinfo, tvbuff_t *tvb, const wscbor_chunk_t *chunk);
385
386#ifdef __cplusplus
387}
388#endif
Definition packet_info.h:40
Definition proto.h:902
Internal memory allocator interface used by the wmem subsystem.
Definition wmem_allocator.h:34
Definition wmem_list.c:23
Definition wscbor.c:143
Definition expert.h:65
Definition expert.h:36
Definition tvbuff-int.h:33
A data-containing, optionally-tagged chunk of CBOR.
Definition wscbor.h:89
int data_length
The length of this chunk and its immediate definite data (i.e. strings)
Definition wscbor.h:98
uint8_t type_minor
Minor type of this item.
Definition wscbor.h:108
wmem_list_t * tags
Tags on this chunk, in encoded order (type wscbor_tag_t*)
Definition wscbor.h:102
uint64_t head_value
The header-encoded value.
Definition wscbor.h:110
cbor_type type_major
Definition wscbor.h:106
int start
The start offset of this chunk.
Definition wscbor.h:94
int head_length
The length of just this header and any preceding tags.
Definition wscbor.h:96
wmem_list_t * errors
Errors processing this chunk (type wscbor_error_t*)
Definition wscbor.h:100
wscbor_chunk_priv_t * _priv
Internal private data.
Definition wscbor.h:91
Decoding or require_* error.
Definition wscbor.h:59
expert_field * ei
The associated expert info.
Definition wscbor.h:61
const char * msg
Optional specific text.
Definition wscbor.h:63
Tag metadata and value.
Definition wscbor.h:77
uint64_t value
The tag value.
Definition wscbor.h:83
int start
The start offset of this tag head.
Definition wscbor.h:79
int length
The length of just this tag head.
Definition wscbor.h:81
WS_DLL_PUBLIC uint64_t * wscbor_require_uint64(wmem_allocator_t *alloc, wscbor_chunk_t *chunk)
Definition wscbor.c:549
WS_DLL_PUBLIC char * wscbor_require_tstr(wmem_allocator_t *alloc, wscbor_chunk_t *chunk)
Definition wscbor.c:596
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:652
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:634
WS_DLL_PUBLIC const ei_register_info * wscbor_expert_items(int *size)
Definition wscbor.c:483
WS_DLL_PUBLIC bool wscbor_require_map(wscbor_chunk_t *chunk)
Definition wscbor.c:521
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:646
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_MAP
maps
Definition wscbor.h:44
@ 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
@ CBOR_TYPE_ARRAY
arrays
Definition wscbor.h:43
WS_DLL_PUBLIC bool wscbor_require_major_type(wscbor_chunk_t *chunk, cbor_type major)
Definition wscbor.c:490
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:640
WS_DLL_PUBLIC bool wscbor_is_indefinite_break(const wscbor_chunk_t *chunk)
Definition wscbor.c:366
WS_DLL_PUBLIC bool * wscbor_require_boolean(wmem_allocator_t *alloc, wscbor_chunk_t *chunk)
Definition wscbor.c:525
WS_DLL_PUBLIC bool wscbor_skip_next_item(wmem_allocator_t *alloc, tvbuff_t *tvb, int *offset)
Definition wscbor.c:458
WS_DLL_PUBLIC int64_t * wscbor_require_int64(wmem_allocator_t *alloc, wscbor_chunk_t *chunk)
Definition wscbor.c:559
_cbor_ctrl
The same enumeration from libcbor-0.5.
Definition wscbor.h:50
WS_DLL_PUBLIC bool wscbor_require_array_size(wscbor_chunk_t *chunk, uint64_t count_min, uint64_t count_max)
Definition wscbor.c:506
WS_DLL_PUBLIC bool wscbor_require_array(wscbor_chunk_t *chunk)
Definition wscbor.c:502
WS_DLL_PUBLIC unsigned wscbor_has_errors(const wscbor_chunk_t *chunk)
Definition wscbor.c:362
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)
Definition wscbor.c:628
WS_DLL_PUBLIC void wscbor_init(void)
Definition wscbor.c:472
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:462
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:672
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)
Definition wscbor.c:354
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:685
WS_DLL_PUBLIC void wscbor_chunk_free(wscbor_chunk_t *chunk)
Definition wscbor.c:323
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)
Definition wscbor.c:612
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