BSL v0.0.0
AMMOS Bundle Protocol Security Library (BSL)
Loading...
Searching...
No Matches
HostInterface.c File Reference

Implementation of the host BPA and its callback functions. More...

#include <BPSecLib_Private.h>
+ Include dependency graph for HostInterface.c:

Go to the source code of this file.

Functions

int BSL_HostDescriptors_Set (BSL_HostDescriptors_t desc)
 Set the BPA descriptor (callbacks) for this process.
 
int BSL_BundleCtx_GetBundleMetadata (const BSL_BundleRef_t *bundle, BSL_PrimaryBlock_t *result_primary_block)
 Calls the host interface to get a bundle primary block information.abort.
 
int BSL_BundleCtx_GetBlockMetadata (const BSL_BundleRef_t *bundle, uint64_t block_num, BSL_CanonicalBlock_t *result_block)
 Returns information about the bundle Canonical block.
 
int BSL_BundleCtx_GetBlockIds (const BSL_BundleRef_t *bundle, size_t array_count, uint64_t block_ids_array[array_count], size_t *result_count)
 Returns an array in which each element contains the id of the corresponding block.abort.
 
int BSL_BundleCtx_CreateBlock (BSL_BundleRef_t *bundle, uint64_t block_type_code, uint64_t *block_num)
 Request the creation of a new block of a given type in the bundle.
 
int BSL_BundleCtx_RemoveBlock (BSL_BundleRef_t *bundle, uint64_t block_num)
 Requests the removal of a block from a bundle.
 
int BSL_BundleCtx_ReallocBTSD (BSL_BundleRef_t *bundle, uint64_t block_num, size_t bytesize)
 Requests the re-allocation of a block's BTSD, useful for BCB.
 
void BSL_HostDescriptors_Get (BSL_HostDescriptors_t *desc)
 Copy the BPA descriptor for this process.
 
int BSL_HostEID_Init (BSL_HostEID_t *eid)
 Initialize an abstract EID.
 
void BSL_HostEID_Deinit (BSL_HostEID_t *eid)
 De-initialize an abstract EID.
 
int BSL_Host_GetSecSrcEID (BSL_HostEID_t *eid)
 Get the local EID used when this node is a security source.
 
int BSL_HostEID_EncodeToCBOR (const BSL_HostEID_t *eid, void *user_data)
 Encode a EID into a CBOR sequence.
 
int BSL_HostEID_DecodeFromCBOR (BSL_HostEID_t *eid, void *decoder)
 Load an EID from CBOR.
 
int BSL_HostEID_DecodeFromText (BSL_HostEID_t *eid, const char *text)
 Decode an EID from its text form.
 
int BSL_HostEIDPattern_Init (BSL_HostEIDPattern_t *pat)
 Initialize an abstract EID Pattern.
 
void BSL_HostEIDPattern_Deinit (BSL_HostEIDPattern_t *pat)
 De-initialize an abstract EID Pattern.
 
int BSL_HostEIDPattern_DecodeFromText (BSL_HostEIDPattern_t *pat, const char *text)
 Decode an EID Pattern from its text form.
 
bool BSL_HostEIDPattern_IsMatch (const BSL_HostEIDPattern_t *pat, const BSL_HostEID_t *eid)
 Determine if an EID Pattern matches a specific EID.
 

Variables

static BSL_HostDescriptors_t HostDescriptorTable = { 0 }
 

Detailed Description

Implementation of the host BPA and its callback functions.

Definition in file HostInterface.c.

Function Documentation

◆ BSL_BundleCtx_CreateBlock()

int BSL_BundleCtx_CreateBlock ( BSL_BundleRef_t bundle,
uint64_t  block_type_code,
uint64_t *  block_num 
)

Request the creation of a new block of a given type in the bundle.

Parameters
[in]bundleContext bundle
[in]block_type_codeThe type of block to be created (e.g, 1 means payload)
[out]block_numPointer to integer containing the number of the block just created.abort
Returns
0 on success, negative on error

Definition at line 96 of file HostInterface.c.

References BSL_HostDescriptors_t::block_create_fn, BSL_ERR_HOST_CALLBACK_FAILED, and BSL_SUCCESS.

◆ BSL_BundleCtx_GetBlockIds()

int BSL_BundleCtx_GetBlockIds ( const BSL_BundleRef_t bundle,
size_t  array_count,
uint64_t  block_ids_array[array_count],
size_t *  result_count 
)

Returns an array in which each element contains the id of the corresponding block.abort.

Parameters
[in]bundleBundle context
[in]array_countNumber of elements in block_id_index_array
[out]block_id_index_arrayArray of array_count elements for results
[out]result_countContains the number of elements put into the array

Definition at line 82 of file HostInterface.c.

References BSL_ERR_HOST_CALLBACK_FAILED, BSL_SUCCESS, and BSL_HostDescriptors_t::bundle_get_block_ids.

Referenced by BSL_API_QuerySecurity().

◆ BSL_BundleCtx_GetBlockMetadata()

int BSL_BundleCtx_GetBlockMetadata ( const BSL_BundleRef_t bundle,
uint64_t  block_num,
BSL_CanonicalBlock_t result_block 
)

Returns information about the bundle Canonical block.

Parameters
[in]bundleContext bundle
[in]block_numThe number of the bundle canonical block we seek information on
[out]result_blockPointer to allocated memory which contains the results of the query.

Definition at line 69 of file HostInterface.c.

References BSL_HostDescriptors_t::block_metadata_fn, BSL_ERR_HOST_CALLBACK_FAILED, and BSL_SUCCESS.

Referenced by BSL_API_QuerySecurity().

◆ BSL_BundleCtx_GetBundleMetadata()

int BSL_BundleCtx_GetBundleMetadata ( const BSL_BundleRef_t bundle,
BSL_PrimaryBlock_t result_primary_block 
)

Calls the host interface to get a bundle primary block information.abort.

Parameters
[in]bundleBundle context
[out]result_primary_blockNon-null pointer to result which gets populated on a zero return code.
Returns
0 on success, negative on error

Definition at line 57 of file HostInterface.c.

References BSL_ERR_HOST_CALLBACK_FAILED, BSL_SUCCESS, and BSL_HostDescriptors_t::bundle_metadata_fn.

Referenced by BSL_API_ApplySecurity(), BSL_API_QuerySecurity(), BSLP_PolicyRule_EvaluateAsSecOper(), and BSLP_QueryPolicy().

◆ BSL_BundleCtx_ReallocBTSD()

int BSL_BundleCtx_ReallocBTSD ( BSL_BundleRef_t bundle,
uint64_t  block_num,
size_t  bytesize 
)

Requests the re-allocation of a block's BTSD, useful for BCB.

Note
Uses semantics similar to memcpy.
Parameters
[in]bundleContext bundle
[in]block_numNumber of block requesting re-allocated of BTSD
[in]bytesizeSize of new BTSD
Returns
0 on success, negative on failure.

Definition at line 117 of file HostInterface.c.

References BSL_HostDescriptors_t::block_realloc_btsd_fn, BSL_HostDescriptors_t::block_remove_fn, BSL_ERR_HOST_CALLBACK_FAILED, and BSL_SUCCESS.

◆ BSL_BundleCtx_RemoveBlock()

int BSL_BundleCtx_RemoveBlock ( BSL_BundleRef_t bundle,
uint64_t  block_num 
)

Requests the removal of a block from a bundle.

Parameters
[in]bundleContext bundle
[in]block_numBlock number to be removed
Returns
0 on success, negative on failure.

Definition at line 108 of file HostInterface.c.

References BSL_HostDescriptors_t::block_remove_fn, BSL_ERR_HOST_CALLBACK_FAILED, and BSL_SUCCESS.

Referenced by BSL_API_ApplySecurity().

◆ BSL_Host_GetSecSrcEID()

int BSL_Host_GetSecSrcEID ( BSL_HostEID_t eid)

Get the local EID used when this node is a security source.

Parameters
[out]eidThe EID to write into. This must already be initialized.
Returns
Zero if successful.
See also
BSL_ROLE_SOURCE

Definition at line 147 of file HostInterface.c.

References BSL_HostDescriptors_t::get_host_eid_fn, and BSL_HostDescriptors_t::user_data.

◆ BSL_HostDescriptors_Get()

void BSL_HostDescriptors_Get ( BSL_HostDescriptors_t desc)

Copy the BPA descriptor for this process.

Parameters
[out]descThe descriptor to copy into.

Definition at line 127 of file HostInterface.c.

Referenced by bsl_mock_bpa_deinit().

◆ BSL_HostDescriptors_Set()

◆ BSL_HostEID_DecodeFromCBOR()

int BSL_HostEID_DecodeFromCBOR ( BSL_HostEID_t eid,
void *  decoder 
)

Load an EID from CBOR.

Parameters
[in,out]eidThis eid
[in]CBORdecoder context
Returns
0 on success

Definition at line 161 of file HostInterface.c.

References BSL_HostDescriptors_t::eid_from_cbor, and BSL_HostEID_s::handle.

◆ BSL_HostEID_DecodeFromText()

int BSL_HostEID_DecodeFromText ( BSL_HostEID_t eid,
const char *  text 
)

Decode an EID from its text form.

Parameters
[out]eidThe EID to write into. This must already be initialized.
[in]textThe text to read from, which must be non-null.
Returns
Zero if successful.

Definition at line 171 of file HostInterface.c.

References BSL_HostDescriptors_t::eid_from_text, and BSL_HostDescriptors_t::user_data.

◆ BSL_HostEID_Deinit()

void BSL_HostEID_Deinit ( BSL_HostEID_t eid)

De-initialize an abstract EID.

Parameters
[in,out]eidThe object to de-initialize.

Definition at line 140 of file HostInterface.c.

References BSL_HostDescriptors_t::eid_deinit, and BSL_HostDescriptors_t::user_data.

◆ BSL_HostEID_EncodeToCBOR()

int BSL_HostEID_EncodeToCBOR ( const BSL_HostEID_t eid,
void *  user_data 
)

Encode a EID into a CBOR sequence.

Definition at line 154 of file HostInterface.c.

References BSL_HostDescriptors_t::eid_to_cbor.

◆ BSL_HostEID_Init()

int BSL_HostEID_Init ( BSL_HostEID_t eid)

Initialize an abstract EID.

Parameters
[out]eidThe object to initialize.
Returns
Zero if successful.

Definition at line 133 of file HostInterface.c.

References BSL_HostDescriptors_t::eid_init, and BSL_HostDescriptors_t::user_data.

◆ BSL_HostEIDPattern_DecodeFromText()

int BSL_HostEIDPattern_DecodeFromText ( BSL_HostEIDPattern_t pat,
const char *  text 
)

Decode an EID Pattern from its text form.

Parameters
[out]patThe pattern to write into. This must already be initialized.
[in]textThe text to read from, which must be non-null.
Returns
Zero if successful.

Definition at line 196 of file HostInterface.c.

References BSL_HostDescriptors_t::eidpat_from_text, and BSL_HostDescriptors_t::user_data.

◆ BSL_HostEIDPattern_Deinit()

void BSL_HostEIDPattern_Deinit ( BSL_HostEIDPattern_t pat)

De-initialize an abstract EID Pattern.

Parameters
[in,out]patThe object to de-initialize.

Definition at line 190 of file HostInterface.c.

References BSL_HostDescriptors_t::eidpat_deinit, and BSL_HostDescriptors_t::user_data.

◆ BSL_HostEIDPattern_Init()

int BSL_HostEIDPattern_Init ( BSL_HostEIDPattern_t pat)

Initialize an abstract EID Pattern.

Parameters
[out]patThe object to initialize.
Returns
Zero if successful.

Definition at line 183 of file HostInterface.c.

References BSL_HostDescriptors_t::eidpat_init, and BSL_HostDescriptors_t::user_data.

◆ BSL_HostEIDPattern_IsMatch()

bool BSL_HostEIDPattern_IsMatch ( const BSL_HostEIDPattern_t pat,
const BSL_HostEID_t eid 
)

Determine if an EID Pattern matches a specific EID.

Parameters
[in]patThe pattern to compare.
[in]eidThe EID to compare.
Returns
True if the EID is a match to the pattern.

Definition at line 205 of file HostInterface.c.

References BSL_HostDescriptors_t::eidpat_match, and BSL_HostDescriptors_t::user_data.

Referenced by BSLP_PolicyPredicate_IsMatch().

Variable Documentation

◆ HostDescriptorTable

BSL_HostDescriptors_t HostDescriptorTable = { 0 }
static

Definition at line 29 of file HostInterface.c.