Wireshark 4.5.0
The Wireshark network protocol analyzer
All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Macros Modules Pages
Functions
wscbor_enc.c File Reference
#include <epan/wscbor.h>
#include "wscbor_enc.h"

Functions

void wscbor_enc_undefined (GByteArray *buf)
 
void wscbor_enc_null (GByteArray *buf)
 
void wscbor_enc_boolean (GByteArray *buf, bool value)
 
void wscbor_enc_uint64 (GByteArray *buf, uint64_t value)
 
void wscbor_enc_int64 (GByteArray *buf, int64_t value)
 
void wscbor_enc_bstr (GByteArray *buf, const uint8_t *ptr, size_t len)
 
void wscbor_enc_bstr_bytearray (GByteArray *buf, GByteArray *src)
 
void wscbor_enc_tstr (GByteArray *buf, const char *ptr)
 
void wscbor_enc_array_head (GByteArray *buf, size_t len)
 
void wscbor_enc_map_head (GByteArray *buf, size_t len)
 

Detailed Description

Wireshark CBOR item encoding API. References: RFC 8949: https://tools.ietf.org/html/rfc8949

Copyright 2017, Malisa Vucinic malis.nosp@m.hav@.nosp@m.gmail.nosp@m..com Copyright 2019-2025, Brian Sipos brian.nosp@m..sip.nosp@m.os@gm.nosp@m.ail..nosp@m.com

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

SPDX-License-Identifier: LGPL-2.1-or-later

Function Documentation

◆ wscbor_enc_array_head()

void wscbor_enc_array_head ( GByteArray *  buf,
size_t  len 
)

Add an array header with a definite length.

Note
The items which follow this header must agree with the definite length.
Parameters
[in,out]bufThe buffer to append to.
lenThe number of items of the array.

◆ wscbor_enc_boolean()

void wscbor_enc_boolean ( GByteArray *  buf,
bool  value 
)

Add an item containing a bool value.

Parameters
[in,out]bufThe buffer to append to.
valueThe value to write.

◆ wscbor_enc_bstr()

void wscbor_enc_bstr ( GByteArray *  buf,
const uint8_t *  ptr,
size_t  len 
)

Add an item containing a definite length byte string.

Parameters
[in,out]bufThe buffer to append to.
[in]ptrThe data to write.
lenThe length of the data to write. This MUST be no longer than the actual size of data.

◆ wscbor_enc_bstr_bytearray()

void wscbor_enc_bstr_bytearray ( GByteArray *  buf,
GByteArray *  src 
)

This is an overloaded member function, provided for convenience. It differs from the above function only in what argument(s) it accepts. This is a shortcut to adding a byte string stolen from an existing array. This can be useful to embed encoded CBOR into a byte string (see CDDL operators ".cbor" and ".cborseq" from Section 3.8.4 of RFC 8610).

Parameters
[in,out]bufThe buffer to append to.
[in,out]srcThe buffer to steal from.

◆ wscbor_enc_int64()

void wscbor_enc_int64 ( GByteArray *  buf,
int64_t  value 
)

Add an item containing an unsigned or negative int.

Parameters
[in,out]bufThe buffer to append to.
valueThe value to write.

◆ wscbor_enc_map_head()

void wscbor_enc_map_head ( GByteArray *  buf,
size_t  len 
)

Add a map header with a definite length.

Note
The items which follow this header must agree with the definite length.
Parameters
[in,out]bufThe buffer to append to.
lenThe number of pairs in the map.

◆ wscbor_enc_null()

void wscbor_enc_null ( GByteArray *  buf)

Add an item containing a null value.

Parameters
[in,out]bufThe buffer to append to.

◆ wscbor_enc_tstr()

void wscbor_enc_tstr ( GByteArray *  buf,
const char *  ptr 
)

Add an item containing a definite length text string.

Parameters
[in,out]bufThe buffer to append to.
[in]ptrThe null-terminated text to write.

◆ wscbor_enc_uint64()

void wscbor_enc_uint64 ( GByteArray *  buf,
uint64_t  value 
)

Add an item containing an unsigned int.

Parameters
[in,out]bufThe buffer to append to.
valueThe value to write.

◆ wscbor_enc_undefined()

void wscbor_enc_undefined ( GByteArray *  buf)

Add an item containing an undefined value.

Parameters
[in,out]bufThe buffer to append to.