33#include <qcbor/qcbor_spiffy_decode.h>
39 assert(eid->
handle != NULL);
49 QCBORDecode_EnterArray(dec, NULL);
51 QCBORDecode_GetUInt64(dec, &(obj->
scheme));
52 if (QCBOR_SUCCESS != QCBORDecode_GetError(dec))
63 QCBORDecode_EnterArray(dec, &decitem);
64 if (decitem.val.uCount == 2)
68 QCBORDecode_GetUInt64(dec, &qnode);
71 QCBORDecode_GetUInt64(dec, &(ipn->
svc_num));
73 else if (decitem.val.uCount == 3)
76 QCBORDecode_GetUInt64(dec, &(ipn->
auth_num));
77 QCBORDecode_GetUInt64(dec, &(ipn->
node_num));
78 QCBORDecode_GetUInt64(dec, &(ipn->
svc_num));
90 QCBORDecode_ExitArray(dec);
96 const size_t begin = QCBORDecode_Tell(dec);
97 QCBORDecode_VGetNextConsume(dec, &decitem);
98 const size_t end = QCBORDecode_Tell(dec);
111 QCBORDecode_ExitArray(dec);
120 const size_t begin = QCBORDecode_Tell(dec);
121 QCBORDecode_EnterArray(dec, NULL);
123 QCBORDecode_GetUInt64(dec, &(blk->version));
124 if ((QCBOR_SUCCESS != QCBORDecode_GetError(dec)) || (blk->version != 7))
129 QCBORDecode_GetUInt64(dec, &(blk->flags));
130 QCBORDecode_GetUInt64(dec, &(blk->crc_type));
141 QCBORDecode_EnterArray(dec, NULL);
142 QCBORDecode_GetUInt64(dec, &(blk->timestamp.bundle_creation_time));
143 QCBORDecode_GetUInt64(dec, &(blk->timestamp.seq_num));
144 QCBORDecode_ExitArray(dec);
146 QCBORDecode_GetUInt64(dec, &(blk->lifetime));
150 QCBORDecode_GetUInt64(dec, &(blk->frag_offset));
151 QCBORDecode_GetUInt64(dec, &(blk->adu_length));
155 blk->frag_offset = blk->adu_length = 0;
159 switch (blk->crc_type)
164 QCBORDecode_GetByteString(dec, &view);
171 QCBORDecode_ExitArray(dec);
172 const size_t end = QCBORDecode_Tell(dec);
174 if (!
mock_bpa_crc_check(QCBORDecode_RetrieveUndecodedInput(dec), begin, end, blk->crc_type))
179 blk->cbor_len = end - begin;
180 blk->cbor = calloc(1, blk->cbor_len);
181 memcpy(blk->cbor, &((uint8_t *)dec->InBuf.UB.ptr)[begin], blk->cbor_len);
191 const size_t begin = QCBORDecode_Tell(dec);
192 QCBORDecode_EnterArray(dec, NULL);
194 QCBORDecode_GetUInt64(dec, &(blk->blk_type));
195 QCBORDecode_GetUInt64(dec, &(blk->blk_num));
196 QCBORDecode_GetUInt64(dec, &(blk->flags));
197 QCBORDecode_GetUInt64(dec, &(blk->crc_type));
200 QCBORDecode_GetByteString(dec, &view);
201 if (QCBOR_SUCCESS == QCBORDecode_GetError(dec))
203 if (blk->btsd == NULL)
205 blk->btsd = calloc(1, view.len);
206 blk->btsd_len = view.len;
208 assert(blk->btsd != NULL);
209 assert(blk->btsd_len > 0);
210 memcpy(blk->btsd, view.ptr, view.len);
213 switch (blk->crc_type)
218 QCBORDecode_GetByteString(dec, &view);
225 QCBORDecode_ExitArray(dec);
226 const size_t end = QCBORDecode_Tell(dec);
228 if (!
mock_bpa_crc_check(QCBORDecode_RetrieveUndecodedInput(dec), begin, end, blk->crc_type))
242 QCBORDecode_EnterArray(dec, &decitem);
243 if (decitem.val.uCount != QCBOR_COUNT_INDICATES_INDEFINITE_LENGTH)
254 while (QCBOR_SUCCESS == QCBORDecode_PeekNext(dec, &decitem))
263 bundle->blocks[bundle->block_count++] = blk;
266 QCBORDecode_ExitArray(dec);
Single entry-point include file for all of the BPSec Lib (BSL) frontend API.
@ BSL_BUNDLE_IS_FRAGMENT
Set if this bundle is a fragment.
#define CHKERR1(cond)
Return the error value 1 if condition fails.
Single entry-point include file for all of the "Public" BPSec Lib (BSL) frontend API.
@ BSL_BUNDLECRCTYPE_16
CRC-16.
@ BSL_BUNDLECRCTYPE_32
CRC-32C.
int BSL_Data_CopyFrom(BSL_Data_t *data, size_t len, BSL_DataConstPtr_t src)
Set an initialized data struct to a given size.
int BSL_Data_Init(BSL_Data_t *data)
Initialize an empty data struct.
Declarations for Agent initialization.
bool mock_bpa_crc_check(UsefulBufC buf, size_t begin, size_t end, BSL_BundleCRCType_e crc_type)
Check the CRC of an encoded block.
Declarations for BPv7 block CRC handling.
int bsl_mock_decode_primary(QCBORDecodeContext *dec, MockBPA_PrimaryBlock_t *blk)
Encode primary block to a CBOR bytestring.
int bsl_mock_decode_eid(QCBORDecodeContext *dec, BSL_HostEID_t *eid)
Encode a single EID.
int bsl_mock_decode_bundle(QCBORDecodeContext *dec, MockBPA_Bundle_t *bundle)
This is an overloaded member function, provided for convenience. It differs from the above function o...
int bsl_mock_decode_canonical(QCBORDecodeContext *dec, MockBPA_CanonicalBlock_t *blk)
This is an overloaded member function, provided for convenience. It differs from the above function o...
Declarations for bundle and block decoding.
void bsl_mock_eid_deinit(bsl_mock_eid_t *eid)
Internal struct de-initializer.
int MockBPA_EID_Init(void *user_data, BSL_HostEID_t *eid)
Interface for BSL_HostDescriptors_t::eid_init.
void bsl_mock_eid_init(bsl_mock_eid_t *eid)
Internal struct initializer.
@ BSL_MOCK_EID_IPN
The "ipn" scheme.
Heap data storage and views.
BSL_DataPtr_t ptr
Pointer to the front of the buffer.
Opaque pointer to BPA-specific Endpoint ID storage.
void * handle
Opaque pointer for BPA backend to use.
Scheme-specific part for IPN scheme.
int ncomp
The number of components when encoded, either 2 or 3.
uint64_t svc_num
The service number component.
uint64_t node_num
The node number component.
uint64_t auth_num
The authority number component.
Struct to be used as a BSL_HostEID_t::handle.
union bsl_mock_eid_t::@0 ssp
Interpreted according to scheme code.
bsl_eid_ipn_ssp_t as_ipn
Used when scheme is BSL_MOCK_EID_IPN.
uint64_t scheme
Code point for EID schemes from .
BSL_Data_t as_raw
Used in all other cases, copied from source.