|
BSL v1.0.0 - 4.g1b6a605
AMMOS Bundle Protocol Security Library (BSL)
|
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_s * | MockBPA_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_s * | MockBPA_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. | |
Definitions for Agent initialization.
| void MockBPA_Agent_Deinit | ( | MockBPA_Agent_t * | agent | ) |
Clean up the mock BPA for the current process.
| [out] | agent | The agent to deinitialize. |
References agent, MockBPA_Agent_t::appin, MockBPA_Agent_t::appout, MockBPA_Agent_BSL_Ctx_t::bsl, BSL_API_DeinitLib(), BSL_FREE, BSL_LOG_ERR, MockBPA_Agent_t::clin, MockBPA_Agent_t::clout, MockBPA_Agent_t::deliver, MockBPA_Agent_t::forward, MockBPA_Agent_BSL_Ctx_t::mutex, MockBPA_Agent_t::over_rx, MockBPA_Agent_t::over_tx, MockBPA_Agent_t::tx_notify_r, MockBPA_Agent_t::tx_notify_w, MockBPA_Agent_t::under_rx, and MockBPA_Agent_t::under_tx.
Referenced by main().
| BSL_HostDescriptors_t MockBPA_Agent_Descriptors | ( | MockBPA_Agent_t * | agent | ) |
Get host descriptors without a specific agent.
| [in] | agent | The 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().
| int MockBPA_Agent_Exec | ( | MockBPA_Agent_t * | agent | ) |
Execute the main thread activity while work threads are running.
This will block until MockBPA_Agent_Stop() is called.
| [out] | agent | The agent to work for. |
References agent, MockBPA_Agent_t::app_addr, BSL_Data_AppendFrom(), BSL_LOG_DEBUG, BSL_LOG_ERR, BSL_LOG_INFO, mock_bpa_ctr_t::encoded, BSL_Data_t::len, MockBPA_Agent_t::over_addr, MockBPA_Agent_t::over_rx, MockBPA_Agent_t::over_tx, BSL_Data_t::ptr, MockBPA_Agent_t::router_addr, MockBPA_Agent_t::stop_state, MockBPA_Agent_t::tx_notify_r, MockBPA_Agent_t::under_addr, MockBPA_Agent_t::under_rx, and MockBPA_Agent_t::under_tx.
Referenced by main().
| int MockBPA_Agent_Init | ( | MockBPA_Agent_t * | agent | ) |
Initialize and register this mock BPA for the current process.
| [out] | agent | The agent to initialize. |
References agent, MockBPA_Agent_t::app_addr, MockBPA_Agent_t::appin, MockBPA_Agent_t::appout, MockBPA_Agent_BSL_Ctx_t::bsl, BSL_API_InitLib(), BSL_API_RegisterPolicyProvider(), BSL_API_RegisterSecurityContext(), BSL_CALLOC, BSL_LibCtx_Sizeof(), BSL_LOG_ERR, BSL_SUCCESS, BSLP_QueryPolicy(), MockBPA_Agent_t::clin, MockBPA_Agent_t::clout, MockBPA_Agent_t::deliver, MockBPA_Agent_t::forward, MOCKBPA_DATA_QUEUE_SIZE, MockBPA_Agent_BSL_Ctx_t::mutex, MockBPA_Agent_t::over_addr, MockBPA_Agent_t::over_rx, MockBPA_Agent_t::over_tx, MockBPA_Agent_BSL_Ctx_t::policy, MockBPA_Agent_t::router_addr, MockBPA_Agent_t::stop_state, MockBPA_Agent_t::tx_notify_r, MockBPA_Agent_t::tx_notify_w, MockBPA_Agent_t::under_addr, MockBPA_Agent_t::under_rx, and MockBPA_Agent_t::under_tx.
Referenced by main().
| int MockBPA_Agent_Join | ( | MockBPA_Agent_t * | agent | ) |
Wait for and join worker threads.
| [out] | agent | The agent to start threads for. |
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().
|
static |
Process a single bundle at one of the interaction points.
| [in] | agent | The agent state, which is not locked for the work thread. |
| [in,out] | bsl | The specific BSL instance to process with. |
| loc | The interaction point for policy use. | |
| [in,out] | bundle | The bundle to process. |
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.
| int MockBPA_Agent_Start | ( | MockBPA_Agent_t * | agent | ) |
Start worker threads.
| [out] | agent | The agent to start threads for. |
References agent, and MockBPA_Agent_t::thr_over_rx.
Referenced by main().
| void MockBPA_Agent_Stop | ( | MockBPA_Agent_t * | agent | ) |
Stop an agent from another thread or a signal handler.
| [in,out] | agent | The agent to set the stopping state on. |
References agent, BSL_LOG_ERR, MockBPA_Agent_t::stop_state, and MockBPA_Agent_t::tx_notify_w.