BSL v1.0.0 - 3.g740079a
AMMOS Bundle Protocol Security Library (BSL)
Loading...
Searching...
No Matches
encode.c File Reference

Definitions for bundle and block encoding. More...

#include <BPSecLib_Private.h>
#include "encode.h"
#include "agent.h"
#include "crc.h"
+ Include dependency graph for encode.c:

Functions

int bsl_mock_encode_eid (const BSL_HostEID_t *eid, BSL_Data_t *encoded_bytes)
 Encode a single EID.
 
int bsl_mock_encode_eid_from_ctx (QCBOREncodeContext *enc, const BSL_HostEID_t *eid)
 Encode a single EID from a QCBOR Encode Context.
 
int bsl_mock_encode_primary (QCBOREncodeContext *enc, const MockBPA_PrimaryBlock_t *blk)
 Encode primary block to a CBOR data.
 
int bsl_mock_encode_canonical (QCBOREncodeContext *enc, const MockBPA_CanonicalBlock_t *blk)
 This is an overloaded member function, provided for convenience. It differs from the above function only in what argument(s) it accepts.
 
int bsl_mock_encode_bundle (QCBOREncodeContext *enc, const MockBPA_Bundle_t *bundle)
 This is an overloaded member function, provided for convenience. It differs from the above function only in what argument(s) it accepts.
 

Variables

static const uint8_t zero_crc [] = { 0, 0, 0, 0 }
 

Detailed Description

Definitions for bundle and block encoding.

Function Documentation

◆ bsl_mock_encode_eid()

int bsl_mock_encode_eid ( const BSL_HostEID_t eid,
BSL_Data_t encoded_bytes 
)

Encode a single EID.

Matches the signature for the BSL_HostDescriptors_t::eid_to_cbor function.

Parameters
[in]eidThe EID value.
[in,out]encoded_bytesResulting encoded bytes. NULL if checking for required CBOR length.

References bsl_mock_eid_t::as_ipn, bsl_mock_eid_t::as_raw, bsl_eid_ipn_ssp_t::auth_num, BSL_ERR_ENCODING, BSL_LOG_DEBUG, BSL_LOG_ERR, BSL_MOCK_EID_IPN, CHKERR1, BSL_HostEID_t::handle, BSL_Data_t::len, bsl_eid_ipn_ssp_t::ncomp, bsl_eid_ipn_ssp_t::node_num, BSL_Data_t::ptr, bsl_mock_eid_t::scheme, bsl_mock_eid_t::ssp, and bsl_eid_ipn_ssp_t::svc_num.

Referenced by MockBPA_Agent_Descriptors().

◆ bsl_mock_encode_eid_from_ctx()

int bsl_mock_encode_eid_from_ctx ( QCBOREncodeContext *  enc,
const BSL_HostEID_t eid 
)

Encode a single EID from a QCBOR Encode Context.

Parameters
[in,out]encQCBOR Encode Context.
[in]eidThe EID Value.

References BSL_Data_Deinit(), BSL_Data_InitBuffer(), BSL_ERR_ENCODING, BSL_HostEID_EncodeToCBOR(), BSL_LOG_ERR, BSL_SUCCESS, BSL_Data_t::len, and BSL_Data_t::ptr.

Referenced by bsl_mock_encode_primary().

◆ bsl_mock_encode_primary()

int bsl_mock_encode_primary ( QCBOREncodeContext *  enc,
const MockBPA_PrimaryBlock_t blk 
)

Encode primary block to a CBOR data.

Parameters
[in]encThe encoder.
[in]blkprimary block information to be encoded
Returns
0 if successful

References BSL_BUNDLE_IS_FRAGMENT, BSL_BUNDLECRCTYPE_16, BSL_BUNDLECRCTYPE_32, bsl_mock_encode_eid_from_ctx(), and mock_bpa_crc_apply().

Referenced by bsl_mock_encode_bundle().