Wireshark  4.3.0
The Wireshark network protocol analyzer
wscbor.h
Go to the documentation of this file.
1 
15 #ifndef __WSCBOR_H__
16 #define __WSCBOR_H__
17 
18 #include <ws_symbol_export.h>
19 #include <epan/tvbuff.h>
20 #include <epan/proto.h>
21 #include <epan/expert.h>
22 #include <wsutil/wmem/wmem_list.h>
23 
24 #ifdef __cplusplus
25 extern "C" {
26 #endif
27 
30 WS_DLL_PUBLIC
31 void wscbor_init(void);
32 
37 WS_DLL_PUBLIC
38 const ei_register_info * wscbor_expert_items(int *size);
39 
41 typedef enum cbor_type {
51 
53 typedef enum {
54  CBOR_CTRL_NONE = 0,
55  CBOR_CTRL_FALSE = 20,
56  CBOR_CTRL_TRUE = 21,
57  CBOR_CTRL_NULL = 22,
58  CBOR_CTRL_UNDEF = 23
59 } _cbor_ctrl;
60 
62 typedef struct {
66  const char *msg;
68 
76 WS_DLL_PUBLIC
77 wscbor_error_t * wscbor_error_new(wmem_allocator_t *alloc, expert_field *ei, const char *format, ...);
78 
80 typedef struct {
82  gint start;
84  gint length;
86  guint64 value;
87 } wscbor_tag_t;
88 
92 typedef struct {
95 
97  gint start;
106 
111  guint8 type_minor;
113  guint64 head_value;
115 
129 WS_DLL_PUBLIC
130 wscbor_chunk_t * wscbor_chunk_read(wmem_allocator_t *alloc, tvbuff_t *tvb, gint *offset);
131 
134 WS_DLL_PUBLIC
135 void wscbor_chunk_free(wscbor_chunk_t *chunk);
136 
143 WS_DLL_PUBLIC
144 guint64 wscbor_chunk_mark_errors(packet_info *pinfo, proto_item *item, const wscbor_chunk_t *chunk);
145 
150 WS_DLL_PUBLIC
151 guint wscbor_has_errors(const wscbor_chunk_t *chunk);
152 
158 WS_DLL_PUBLIC
159 gboolean wscbor_is_indefinite_break(const wscbor_chunk_t *chunk);
160 
171 WS_DLL_PUBLIC
172 gboolean wscbor_skip_next_item(wmem_allocator_t *alloc, tvbuff_t *tvb, gint *offset);
173 
184 WS_DLL_PUBLIC
185 gboolean wscbor_skip_if_errors(wmem_allocator_t *alloc, tvbuff_t *tvb, gint *offset, const wscbor_chunk_t *chunk);
186 
187 
194 WS_DLL_PUBLIC
195 gboolean wscbor_require_major_type(wscbor_chunk_t *chunk, cbor_type major);
196 
202 WS_DLL_PUBLIC
203 gboolean wscbor_require_array(wscbor_chunk_t *chunk);
204 
212 WS_DLL_PUBLIC
213 gboolean wscbor_require_array_size(wscbor_chunk_t *chunk, guint64 count_min, guint64 count_max);
214 
220 WS_DLL_PUBLIC
221 gboolean wscbor_require_map(wscbor_chunk_t *chunk);
222 
230 WS_DLL_PUBLIC
232 
241 WS_DLL_PUBLIC
242 guint64 * wscbor_require_uint64(wmem_allocator_t *alloc, wscbor_chunk_t *chunk);
243 
252 WS_DLL_PUBLIC
253 gint64 * wscbor_require_int64(wmem_allocator_t *alloc, wscbor_chunk_t *chunk);
254 
267 WS_DLL_PUBLIC
269 
278 WS_DLL_PUBLIC
280 
285 WS_DLL_PUBLIC
286 proto_item * proto_tree_add_cbor_container(proto_tree *tree, int hfindex, packet_info *pinfo, tvbuff_t *tvb, const wscbor_chunk_t *chunk);
287 
290 WS_DLL_PUBLIC
291 proto_item * proto_tree_add_cbor_ctrl(proto_tree *tree, int hfindex, packet_info *pinfo, tvbuff_t *tvb, const wscbor_chunk_t *chunk);
292 
293 WS_DLL_PUBLIC
294 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);
295 
296 WS_DLL_PUBLIC
297 proto_item * proto_tree_add_cbor_uint64(proto_tree *tree, int hfindex, packet_info *pinfo, tvbuff_t *tvb, const wscbor_chunk_t *chunk, const guint64 *value);
298 
299 WS_DLL_PUBLIC
300 proto_item * proto_tree_add_cbor_int64(proto_tree *tree, int hfindex, packet_info *pinfo, tvbuff_t *tvb, const wscbor_chunk_t *chunk, const gint64 *value);
301 
302 WS_DLL_PUBLIC
303 proto_item * proto_tree_add_cbor_bitmask(proto_tree *tree, int hfindex, const gint ett, int *const *fields, packet_info *pinfo, tvbuff_t *tvb, const wscbor_chunk_t *chunk, const guint64 *value);
304 
305 WS_DLL_PUBLIC
306 proto_item * proto_tree_add_cbor_tstr(proto_tree *tree, int hfindex, packet_info *pinfo, tvbuff_t *tvb, const wscbor_chunk_t *chunk);
307 
308 WS_DLL_PUBLIC
309 proto_item * proto_tree_add_cbor_bstr(proto_tree *tree, int hfindex, packet_info *pinfo, tvbuff_t *tvb, const wscbor_chunk_t *chunk);
310 
313 WS_DLL_PUBLIC
314 proto_item * proto_tree_add_cbor_strlen(proto_tree *tree, int hfindex, packet_info *pinfo, tvbuff_t *tvb, const wscbor_chunk_t *chunk);
315 
316 #ifdef __cplusplus
317 }
318 #endif
319 
320 #endif /* __WSCBOR_H__ */
Definition: packet_info.h:44
Definition: proto.h:904
Definition: wmem_allocator.h:27
Definition: wmem_list.c:23
Definition: wscbor.c:140
Definition: expert.h:67
Definition: expert.h:39
Definition: tvbuff-int.h:35
A data-containing, optionally-tagged chunk of CBOR.
Definition: wscbor.h:92
gint start
The start offset of this chunk.
Definition: wscbor.h:97
wmem_list_t * tags
Tags on this chunk, in encoded order (type wscbor_tag_t*)
Definition: wscbor.h:105
cbor_type type_major
Definition: wscbor.h:109
guint64 head_value
The header-encoded value.
Definition: wscbor.h:113
gint head_length
The length of just this header and any preceding tags.
Definition: wscbor.h:99
guint8 type_minor
Minor type of this item.
Definition: wscbor.h:111
wmem_list_t * errors
Errors processing this chunk (type wscbor_error_t*)
Definition: wscbor.h:103
wscbor_chunk_priv_t * _priv
Internal private data.
Definition: wscbor.h:94
gint data_length
The length of this chunk and its immediate definite data (i.e. strings)
Definition: wscbor.h:101
Decoding or require_* error.
Definition: wscbor.h:62
expert_field * ei
The associated expert info.
Definition: wscbor.h:64
const char * msg
Optional specific text.
Definition: wscbor.h:66
Tag metadata and value.
Definition: wscbor.h:80
gint start
The start offset of this tag head.
Definition: wscbor.h:82
gint length
The length of just this tag head.
Definition: wscbor.h:84
guint64 value
The tag value.
Definition: wscbor.h:86
WS_DLL_PUBLIC gboolean wscbor_require_map(wscbor_chunk_t *chunk)
Definition: wscbor.c:507
WS_DLL_PUBLIC bool * wscbor_require_boolean(wmem_allocator_t *alloc, wscbor_chunk_t *chunk)
Definition: wscbor.c:511
WS_DLL_PUBLIC gint64 * wscbor_require_int64(wmem_allocator_t *alloc, wscbor_chunk_t *chunk)
Definition: wscbor.c:545
WS_DLL_PUBLIC gboolean wscbor_skip_if_errors(wmem_allocator_t *alloc, tvbuff_t *tvb, gint *offset, const wscbor_chunk_t *chunk)
Definition: wscbor.c:444
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)
WS_DLL_PUBLIC gboolean wscbor_require_array_size(wscbor_chunk_t *chunk, guint64 count_min, guint64 count_max)
Definition: wscbor.c:492
cbor_type
The same enumeration from libcbor-0.5.
Definition: wscbor.h:41
@ CBOR_TYPE_MAP
maps
Definition: wscbor.h:47
@ CBOR_TYPE_FLOAT_CTRL
decimals and special values (true, false, nil, ...)
Definition: wscbor.h:49
@ CBOR_TYPE_TAG
tags
Definition: wscbor.h:48
@ CBOR_TYPE_UINT
positive integers
Definition: wscbor.h:42
@ CBOR_TYPE_BYTESTRING
byte strings
Definition: wscbor.h:44
@ CBOR_TYPE_STRING
text strings
Definition: wscbor.h:45
@ CBOR_TYPE_NEGINT
negative integers
Definition: wscbor.h:43
@ CBOR_TYPE_ARRAY
arrays
Definition: wscbor.h:46
WS_DLL_PUBLIC gboolean wscbor_skip_next_item(wmem_allocator_t *alloc, tvbuff_t *tvb, gint *offset)
Definition: wscbor.c:440
WS_DLL_PUBLIC char * wscbor_require_tstr(wmem_allocator_t *alloc, wscbor_chunk_t *chunk)
Definition: wscbor.c:582
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:614
WS_DLL_PUBLIC guint64 * wscbor_require_uint64(wmem_allocator_t *alloc, wscbor_chunk_t *chunk)
Definition: wscbor.c:535
WS_DLL_PUBLIC wscbor_error_t * wscbor_error_new(wmem_allocator_t *alloc, expert_field *ei, const char *format,...)
Definition: wscbor.c:170
WS_DLL_PUBLIC wscbor_chunk_t * wscbor_chunk_read(wmem_allocator_t *alloc, tvbuff_t *tvb, gint *offset)
Definition: wscbor.c:186
_cbor_ctrl
The same enumeration from libcbor-0.5.
Definition: wscbor.h:53
WS_DLL_PUBLIC gboolean wscbor_is_indefinite_break(const wscbor_chunk_t *chunk)
Definition: wscbor.c:353
WS_DLL_PUBLIC guint wscbor_has_errors(const wscbor_chunk_t *chunk)
Definition: wscbor.c:349
WS_DLL_PUBLIC tvbuff_t * wscbor_require_bstr(wmem_allocator_t *alloc, wscbor_chunk_t *chunk)
WS_DLL_PUBLIC gboolean wscbor_require_major_type(wscbor_chunk_t *chunk, cbor_type major)
Definition: wscbor.c:476
WS_DLL_PUBLIC const ei_register_info * wscbor_expert_items(int *size)
Definition: wscbor.c:469
WS_DLL_PUBLIC void wscbor_init(void)
Definition: wscbor.c:454
WS_DLL_PUBLIC gboolean wscbor_require_array(wscbor_chunk_t *chunk)
Definition: wscbor.c:488
WS_DLL_PUBLIC void wscbor_chunk_free(wscbor_chunk_t *chunk)
Definition: wscbor.c:310
WS_DLL_PUBLIC guint64 wscbor_chunk_mark_errors(packet_info *pinfo, proto_item *item, const wscbor_chunk_t *chunk)
Definition: wscbor.c:341
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:598