BSL v1.0.0 - 16.g9d98179
AMMOS Bundle Protocol Security Library (BSL)
Loading...
Searching...
No Matches
SamplePolicyProvider.h File Reference

Spec of locally-defined data structures. More...

#include <stdint.h>
#include <BPSecLib_Private.h>
#include <backend/SecParam.h>
+ Include dependency graph for SamplePolicyProvider.h:
+ This graph shows which files directly or indirectly include this file:

Data Structures

struct  BSLP_PolicyPredicate_t
 THE key function that matches a bundle against a rule to provide the output action and specific parameters to use for the security operation. More...
 
struct  BSLP_PolicyRule_t
 Represents a policy rule. More...
 
struct  BSLP_PolicyProvider_t
 Concrete definition of a policy provider. More...
 

Macros

#define BSLP_POLICY_RULE_DESCRIPTION_MAX_STRLEN   100
 Maximum string length of a policy rule description; Affects BSLP_PolicyRule_Init desc parameter.
 
#define BSLP_POLICYPREDICATE_ARRAY_CAPACITY   (100)
 

Functions

void BSLP_PolicyPredicate_Init (BSLP_PolicyPredicate_t *self, BSL_PolicyLocation_e location, BSL_HostEIDPattern_t src_eid_pattern, BSL_HostEIDPattern_t secsrc_eid_pattern, BSL_HostEIDPattern_t dst_eid_pattern)
 Initialize this policy predicate.
 
void BSLP_PolicyPredicate_Deinit (BSLP_PolicyPredicate_t *self)
 
bool BSLP_PolicyPredicate_IsMatch (const BSLP_PolicyPredicate_t *self, BSL_PolicyLocation_e location, BSL_HostEID_t src_eid, BSL_HostEID_t dst_eid)
 Returns true if the given predicate matches the arguments.
 
int BSLP_PolicyRule_Init (BSLP_PolicyRule_t *self, const char *desc, BSLP_PolicyPredicate_t *predicate, int64_t context_id, BSL_SecRole_e role, BSL_SecBlockType_e sec_block_type, BSL_BundleBlockTypeCode_e target_block_type, BSL_PolicyAction_e failure_action_code)
 Initialize this policy rule.
 
void BSLP_PolicyRule_Deinit (BSLP_PolicyRule_t *self)
 De-initialize, release any resources, and zero this struct.
 
void BSLP_PolicyRule_CopyParam (BSLP_PolicyRule_t *self, const BSL_SecParam_t *param)
 Include a BPSec parameter to this rule.
 
void BSLP_PolicyRule_MoveParam (BSLP_PolicyRule_t *self, BSL_SecParam_t *param)
 Include a BPSec parameter to this rule.
 
int BSLP_PolicyRule_EvaluateAsSecOper (const BSLP_PolicyRule_t *self, BSL_SecOper_t *sec_oper, const BSL_BundleRef_t *bundle, BSL_PolicyLocation_e location)
 Critical function creating a security operation from a bundle and location.
 
void BSLP_Deinit (void *user_data)
 
int BSLP_QueryPolicy (const void *user_data, BSL_SecurityActionSet_t *output_action_set, const BSL_BundleRef_t *bundle, BSL_PolicyLocation_e location)
 Note that criticality is HIGH.
 
int BSLP_FinalizePolicy (const void *user_data, const BSL_SecurityActionSet_t *output_action_set, const BSL_BundleRef_t *bundle, const BSL_SecurityResponseSet_t *response_output)
 

Detailed Description

Spec of locally-defined data structures.

Macro Definition Documentation

◆ BSLP_POLICY_RULE_DESCRIPTION_MAX_STRLEN

#define BSLP_POLICY_RULE_DESCRIPTION_MAX_STRLEN   100

Maximum string length of a policy rule description; Affects BSLP_PolicyRule_Init desc parameter.

◆ BSLP_POLICYPREDICATE_ARRAY_CAPACITY

#define BSLP_POLICYPREDICATE_ARRAY_CAPACITY   (100)

Function Documentation

◆ BSLP_Deinit()

◆ BSLP_FinalizePolicy()

◆ BSLP_PolicyPredicate_Deinit()

◆ BSLP_PolicyPredicate_Init()

void BSLP_PolicyPredicate_Init ( BSLP_PolicyPredicate_t self,
BSL_PolicyLocation_e  location,
BSL_HostEIDPattern_t  src_eid_pattern,
BSL_HostEIDPattern_t  secsrc_eid_pattern,
BSL_HostEIDPattern_t  dst_eid_pattern 
)

Initialize this policy predicate.

A policy predicate represents a way to match whether a rule applies to a bundle.

Parameters
[in]selfThis predicate
[in]locationThe BSL_PolicyLocation_e location in the BPA
[in]src_eid_patternHost-defined EID pattern to match for
[in]srcsrc_eid_patternHost-defined EID pattern for SECURITY SOURCE in security block
[in]dst_eid_patternHost-defined EID pattern for DESTINATION EID
Returns
Nothing

References ASSERT_ARG_NONNULL, ASSERT_POSTCONDITION, BSLP_PolicyPredicate_IsConsistent(), BSLP_PolicyPredicate_t::dst_eid_pattern, BSLP_PolicyPredicate_t::location, BSLP_PolicyPredicate_t::secsrc_eid_pattern, and BSLP_PolicyPredicate_t::src_eid_pattern.

Referenced by _setUp(), mock_bpa_register_policy(), mock_bpa_register_policy_from_json(), setUp(), TEST_CASE(), test_MultiplePolicyProviders(), test_PolicyProvider_Inspect_RFC9173_BIB(), test_PolicyProvider_InspectSingleBIBRuleset(), and test_SamplePolicyProvider_WildcardPolicyRuleVerifiesBIB().

◆ BSLP_PolicyPredicate_IsMatch()

bool BSLP_PolicyPredicate_IsMatch ( const BSLP_PolicyPredicate_t self,
BSL_PolicyLocation_e  location,
BSL_HostEID_t  src_eid,
BSL_HostEID_t  dst_eid 
)

Returns true if the given predicate matches the arguments.

Parameters
[in]selfThis predicate
[in]locationLocation in the BPA
[in]src_eidSource EID
[in]dst_eidDestination EID

References ASSERT_ARG_EXPR, BSL_HostEIDPattern_IsMatch(), BSL_LOG_DEBUG, BSLP_PolicyPredicate_IsConsistent(), BSLP_PolicyPredicate_t::dst_eid_pattern, BSLP_PolicyPredicate_t::location, and BSLP_PolicyPredicate_t::src_eid_pattern.

Referenced by BSLP_PolicyRule_EvaluateAsSecOper(), and BSLP_QueryPolicy().

◆ BSLP_PolicyRule_CopyParam()

void BSLP_PolicyRule_CopyParam ( BSLP_PolicyRule_t self,
const BSL_SecParam_t *  param 
)

Include a BPSec parameter to this rule.

Used immediately after Init.

Parameters
[in]selfThis rule
[in,out]paramPointer to the Parameter to move from.

References ASSERT_ARG_EXPR, ASSERT_POSTCONDITION, BSL_SecParam_IsConsistent(), BSLP_PolicyRule_IsConsistent(), and BSLP_PolicyRule_t::params.

Referenced by _setUp(), mock_bpa_register_policy(), mock_bpa_register_policy_from_json(), and setUp().

◆ BSLP_PolicyRule_Deinit()

void BSLP_PolicyRule_Deinit ( BSLP_PolicyRule_t self)

De-initialize, release any resources, and zero this struct.

Parameters
[in]selfThis rule

References ASSERT_ARG_EXPR, BSL_free(), BSL_LOG_INFO, BSLP_PolicyRule_IsConsistent(), BSLP_PolicyRule_t::description, and BSLP_PolicyRule_t::params.

Referenced by BSLP_Deinit(), TEST_CASE(), and test_SamplePolicyProvider_WildcardPolicyRuleVerifiesBIB().

◆ BSLP_PolicyRule_EvaluateAsSecOper()

int BSLP_PolicyRule_EvaluateAsSecOper ( const BSLP_PolicyRule_t self,
BSL_SecOper_t *  sec_oper,
const BSL_BundleRef_t bundle,
BSL_PolicyLocation_e  location 
)

◆ BSLP_PolicyRule_Init()

int BSLP_PolicyRule_Init ( BSLP_PolicyRule_t self,
const char *  desc,
BSLP_PolicyPredicate_t predicate,
int64_t  context_id,
BSL_SecRole_e  role,
BSL_SecBlockType_e  sec_block_type,
BSL_BundleBlockTypeCode_e  target_block_type,
BSL_PolicyAction_e  failure_action_code 
)

Initialize this policy rule.

Parameters
[in]selfThis policy rule
[in]destDescription of this rule (C-string). Will copy characters of parameter from index 0 to BSLP_POLICY_RULE_DESCRIPTION_MAX_STRLEN - 1.
[in]predicatePredicate used to identify which bundles apply
[in]context_idSecurity context ID
[in]roleSuch as source, acceptor, etc
[in]sec_block_typeBlock type (BIB or BCB)
[in]target_block_typeTarget block type (anything, such as primary or payload)
[in]failure_action_codeCode to indicate fate of security block/bundle if error occurs
Returns
Zero on success

References ASSERT_ARG_NONNULL, ASSERT_POSTCONDITION, BSL_malloc(), BSL_SUCCESS, BSLP_POLICYPREDICATE_ARRAY_CAPACITY, BSLP_PolicyRule_IsConsistent(), BSLP_PolicyRule_t::context_id, BSLP_PolicyRule_t::description, BSLP_PolicyRule_t::failure_action_code, BSLP_PolicyRule_t::params, BSLP_PolicyRule_t::predicate, BSLP_PolicyRule_t::role, BSLP_PolicyRule_t::sec_block_type, and BSLP_PolicyRule_t::target_block_type.

Referenced by _setUp(), mock_bpa_register_policy(), mock_bpa_register_policy_from_json(), setUp(), TEST_CASE(), test_MultiplePolicyProviders(), test_PolicyProvider_Inspect_RFC9173_BIB(), test_PolicyProvider_InspectSingleBIBRuleset(), and test_SamplePolicyProvider_WildcardPolicyRuleVerifiesBIB().

◆ BSLP_PolicyRule_MoveParam()

void BSLP_PolicyRule_MoveParam ( BSLP_PolicyRule_t self,
BSL_SecParam_t *  param 
)

Include a BPSec parameter to this rule.

Used immediately after Init.

Parameters
[in]selfThis rule
[in,out]paramPointer to the Parameter to move from.

References ASSERT_ARG_EXPR, ASSERT_POSTCONDITION, BSL_SecParam_IsConsistent(), BSLP_PolicyRule_IsConsistent(), and BSLP_PolicyRule_t::params.

Referenced by test_MultiplePolicyProviders(), and test_PolicyProvider_Inspect_RFC9173_BIB().

◆ BSLP_QueryPolicy()