BSL v0.0.0 - 0.g33cf081
AMMOS Bundle Protocol Security Library (BSL)
Loading...
Searching...
No Matches
agent.c File Reference

Definitions for Agent initialization. More...

#include <BPSecLib_Public.h>
#include <BPSecLib_Private.h>
#include <backend/UtilDefs_SeqReadWrite.h>
#include <security_context/DefaultSecContext.h>
#include <policy_provider/SamplePolicyProvider.h>
#include <assert.h>
#include <errno.h>
#include <poll.h>
#include "agent.h"
#include "eid.h"
#include "eidpat.h"
#include "encode.h"
#include "decode.h"
#include "policy_config.h"
#include "policy_registry.h"
+ Include dependency graph for agent.c:

Data Structures

struct  MockBPA_BTSD_Data_s
 Internal state for reader and writer. More...
 

Macros

#define TLM_COUNTER_FMT   "7" PRIu64
 Display form for counters.
 

Functions

static int MockBPA_GetEid (void *user_data, BSL_HostEID_t *result_eid)
 
int MockBPA_GetBundleMetadata (const BSL_BundleRef_t *bundle_ref, BSL_PrimaryBlock_t *result_primary_block)
 
int MockBPA_GetBlockMetadata (const BSL_BundleRef_t *bundle_ref, uint64_t block_num, BSL_CanonicalBlock_t *result_canonical_block)
 
int MockBPA_ReallocBTSD (BSL_BundleRef_t *bundle_ref, uint64_t block_num, size_t bytesize)
 
static int MockBPA_ReadBTSD_Read (void *user_data, void *buf, size_t *bufsize)
 
static void MockBPA_ReadBTSD_Deinit (void *user_data)
 
static struct BSL_SeqReader_sMockBPA_ReadBTSD (const BSL_BundleRef_t *bundle_ref, uint64_t block_num)
 
static int MockBPA_WriteBTSD_Write (void *user_data, const void *buf, size_t size)
 
static void MockBPA_WriteBTSD_Deinit (void *user_data)
 
static struct BSL_SeqWriter_sMockBPA_WriteBTSD (BSL_BundleRef_t *bundle_ref, uint64_t block_num, size_t total_size)
 
int MockBPA_CreateBlock (BSL_BundleRef_t *bundle_ref, uint64_t block_type_code, uint64_t *result_block_num)
 
int MockBPA_RemoveBlock (BSL_BundleRef_t *bundle_ref, uint64_t block_num)
 
int MockBPA_DeleteBundle (BSL_BundleRef_t *bundle_ref, BSL_ReasonCode_t reason)
 
BSL_HostDescriptors_t MockBPA_Agent_Descriptors (MockBPA_Agent_t *agent)
 Get host descriptors without a specific agent.
 
int MockBPA_Agent_Init (MockBPA_Agent_t *agent)
 Initialize and register this mock BPA for the current process.
 
void MockBPA_Agent_Deinit (MockBPA_Agent_t *agent)
 Clean up the mock BPA for the current process.
 
static int bind_udp (int *sock, const struct sockaddr_in *addr)
 
static void MockBPA_Agent_DumpTelemetry (MockBPA_Agent_t *agent)
 Aggregate and log telemetry from all BSL contexts.
 
static int MockBPA_Agent_process (MockBPA_Agent_t *agent, MockBPA_Agent_BSL_Ctx_t *ctx, BSL_PolicyLocation_e loc, MockBPA_Bundle_t *bundle)
 Process a single bundle at one of the interaction points.
 
static void * MockBPA_Agent_work_over_rx (void *arg)
 
static void * MockBPA_Agent_work_under_rx (void *arg)
 
static void * MockBPA_Agent_work_deliver (void *arg)
 
static void * MockBPA_Agent_work_forward (void *arg)
 
int MockBPA_Agent_Start (MockBPA_Agent_t *agent)
 Start worker threads.
 
void MockBPA_Agent_Stop (MockBPA_Agent_t *agent)
 Stop an agent from another thread or a signal handler.
 
int MockBPA_Agent_Exec (MockBPA_Agent_t *agent)
 Execute the main thread activity while work threads are running.
 
int MockBPA_Agent_Join (MockBPA_Agent_t *agent)
 Wait for and join worker threads.
 

Detailed Description

Definitions for Agent initialization.

Function Documentation

◆ MockBPA_Agent_Deinit()

◆ MockBPA_Agent_Descriptors()

BSL_HostDescriptors_t MockBPA_Agent_Descriptors ( MockBPA_Agent_t agent)

Get host descriptors without a specific agent.

Parameters
[in]agentThe agent to associate as user data.

References agent, bsl_mock_decode_eid(), bsl_mock_encode_eid(), mock_bpa_eid_from_text(), MockBPA_EID_Deinit(), MockBPA_EID_Init(), and BSL_HostDescriptors_t::user_data.

Referenced by main().

◆ MockBPA_Agent_Exec()

◆ MockBPA_Agent_Init()

◆ MockBPA_Agent_Join()

int MockBPA_Agent_Join ( MockBPA_Agent_t agent)

Wait for and join worker threads.

Parameters
[out]agentThe agent to start threads for.
Returns
Zero if successful.
See also
MockBPA_Agent_Start()

References agent, BSL_LOG_ERR, BSL_LOG_INFO, MockBPA_Agent_t::deliver, MockBPA_Agent_t::forward, MockBPA_Agent_t::over_rx, MockBPA_Agent_t::thr_over_rx, and MockBPA_Agent_t::under_rx.

Referenced by main().

◆ MockBPA_Agent_process()

static int MockBPA_Agent_process ( MockBPA_Agent_t agent,
MockBPA_Agent_BSL_Ctx_t ctx,
BSL_PolicyLocation_e  loc,
MockBPA_Bundle_t bundle 
)
static

Process a single bundle at one of the interaction points.

Parameters
[in]agentThe agent state, which is not locked for the work thread.
[in,out]bslThe specific BSL instance to process with.
locThe interaction point for policy use.
[in,out]bundleThe bundle to process.
Returns
Zero if successful.

References agent, MockBPA_Agent_BSL_Ctx_t::bsl, BSL_API_ApplySecurity(), BSL_API_QuerySecurity(), BSL_CALLOC, BSL_FREE, BSL_LOG_CRIT, BSL_LOG_ERR, BSL_LOG_INFO, BSL_SecurityActionSet_Deinit(), BSL_SecurityActionSet_Sizeof(), BSL_SecurityResponseSet_Sizeof(), BSL_BundleRef_t::data, MockBPA_Agent_DumpTelemetry(), and MockBPA_Agent_BSL_Ctx_t::mutex.

◆ MockBPA_Agent_Start()

int MockBPA_Agent_Start ( MockBPA_Agent_t agent)

Start worker threads.

Parameters
[out]agentThe agent to start threads for.
Returns
Zero if successful.
See also
MockBPA_Agent_Join()

References agent, and MockBPA_Agent_t::thr_over_rx.

Referenced by main().

◆ MockBPA_Agent_Stop()

void MockBPA_Agent_Stop ( MockBPA_Agent_t agent)

Stop an agent from another thread or a signal handler.

Parameters
[in,out]agentThe agent to set the stopping state on.

References agent, BSL_LOG_ERR, MockBPA_Agent_t::stop_state, and MockBPA_Agent_t::tx_notify_w.