BSL v1.0.0 - 16.g9d98179
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 "log.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.

Macro Definition Documentation

◆ TLM_COUNTER_FMT

#define TLM_COUNTER_FMT   "7" PRIu64

Display form for counters.

Function Documentation

◆ bind_udp()

static int bind_udp ( int *  sock,
const struct sockaddr_in *  addr 
)
static

References BSL_LOG_DEBUG, and BSL_LOG_ERR.

Referenced by MockBPA_Agent_Exec().

◆ MockBPA_Agent_Deinit()

◆ MockBPA_Agent_Descriptors()

◆ MockBPA_Agent_DumpTelemetry()

◆ MockBPA_Agent_Exec()

◆ MockBPA_Agent_Init()

◆ MockBPA_Agent_Join()

int MockBPA_Agent_Join ( MockBPA_Agent_t agent)

◆ 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, 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(), ctx, BSL_BundleRef_t::data, and MockBPA_Agent_DumpTelemetry().

Referenced by MockBPA_Agent_work_deliver(), MockBPA_Agent_work_forward(), MockBPA_Agent_work_over_rx(), and MockBPA_Agent_work_under_rx().

◆ MockBPA_Agent_Start()

int MockBPA_Agent_Start ( MockBPA_Agent_t agent)

◆ 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, buf, MockBPA_Agent_t::stop_state, and MockBPA_Agent_t::tx_notify_w.

Referenced by sig_stop().

◆ MockBPA_Agent_work_deliver()

◆ MockBPA_Agent_work_forward()

◆ MockBPA_Agent_work_over_rx()

◆ MockBPA_Agent_work_under_rx()

◆ MockBPA_CreateBlock()

◆ MockBPA_DeleteBundle()

int MockBPA_DeleteBundle ( BSL_BundleRef_t bundle_ref,
BSL_ReasonCode_t  reason 
)

◆ MockBPA_GetBlockMetadata()

◆ MockBPA_GetBundleMetadata()

◆ MockBPA_GetEid()

static int MockBPA_GetEid ( void *  user_data,
BSL_HostEID_t result_eid 
)
static

◆ MockBPA_ReadBTSD()

◆ MockBPA_ReadBTSD_Deinit()

static void MockBPA_ReadBTSD_Deinit ( void *  user_data)
static

◆ MockBPA_ReadBTSD_Read()

static int MockBPA_ReadBTSD_Read ( void *  user_data,
void *  buf,
size_t *  bufsize 
)
static

◆ MockBPA_ReallocBTSD()

int MockBPA_ReallocBTSD ( BSL_BundleRef_t bundle_ref,
uint64_t  block_num,
size_t  bytesize 
)

◆ MockBPA_RemoveBlock()

◆ MockBPA_WriteBTSD()

◆ MockBPA_WriteBTSD_Deinit()

◆ MockBPA_WriteBTSD_Write()

static int MockBPA_WriteBTSD_Write ( void *  user_data,
const void *  buf,
size_t  size 
)
static