DTNMA Reference Tools v2.1.0 - 13.gc5c0bac
Delay-Tolerant Networking Management Architecture (DTNMA) Tool Suite
Loading...
Searching...
No Matches
exec.c File Reference
#include "exec.h"
#include "exec_proc.h"
#include "eval.h"
#include "ctrl_exec_ctx.h"
#include "valprod.h"
#include "reporting.h"
#include "amm/ctrl.h"
#include <cace/ari/text.h>
#include <cace/ari/text_util.h>
#include <cace/amm/lookup.h>
#include <cace/util/logging.h>
#include <cace/util/defs.h>
#include <timespec.h>
+ Include dependency graph for exec.c:

Functions

int refda_exec_add_target (refda_runctx_ptr_t *runctxp, const cace_ari_t *target, refda_exec_status_t *status)
 From outside the exec worker thread, inject a single execution target and allow its sequence to be tracked to its finish.
 
static int refda_exec_add_execset (refda_agent_t *agent, const refda_msgdata_t *msg)
 
int refda_exec_waiting (refda_agent_t *agent)
 Execute any waiting sequences as part of normal worker iteration.
 
void * refda_exec_worker (void *arg)
 Work thread function for the Agent execution manager.
 
bool refda_exec_worker_iteration (refda_agent_t *agent)
 Helper function to run a single iteration of the exec worker thread.
 
static int refda_exec_rule_action (refda_agent_t *agent, const cace_ari_t *action)
 Expand a rule's action that has already been verified.
 
static int refda_exec_schedule_tbr (refda_agent_t *agent, refda_amm_tbr_desc_t *tbr, bool starting)
 Schedule execution of a time based rule.
 
static void refda_exec_run_tbr (refda_agent_t *agent, refda_amm_tbr_desc_t *tbr)
 Begin a single execution of a time based rule.
 
static int refda_exec_tbr_next_scheduled_time (struct timespec *schedtime, const refda_amm_tbr_desc_t *tbr, bool starting)
 Compute the next scheduled time at which to run the TBR.
 
int refda_exec_tbr_enable (refda_agent_t *agent, refda_amm_tbr_desc_t *tbr)
 Begin periodic execution of a time based rule.
 
int refda_exec_tbr_disable (refda_agent_t *agent, refda_amm_tbr_desc_t *tbr)
 Cease periodic execution of a time based rule.
 
static int refda_exec_schedule_sbr (refda_agent_t *agent, refda_amm_sbr_desc_t *sbr)
 Schedule execution of a state based rule.
 
static int refda_exec_check_sbr_condition (refda_agent_t *agent, const refda_amm_sbr_desc_t *sbr, cace_ari_t *result)
 
static void refda_exec_run_sbr (refda_agent_t *agent, refda_amm_sbr_desc_t *sbr)
 Begin a single run of a state based rule, evaluating its condition and executing its action if necessary.
 
static int refda_exec_sbr_next_scheduled_time (struct timespec *schedtime, const refda_amm_sbr_desc_t *sbr)
 Compute the next scheduled time at which to run the SBR.
 
int refda_exec_sbr_enable (refda_agent_t *agent, refda_amm_sbr_desc_t *sbr)
 Begin periodic execution of a state based rule.
 
int refda_exec_sbr_disable (refda_agent_t *agent, refda_amm_sbr_desc_t *sbr)
 Cease periodic execution of a state based rule.
 
int refda_exec_next (refda_exec_seq_t *seq, const cace_ari_t *target)
 Setup an ARI to execute next in the sequence.
 

Function Documentation

◆ refda_exec_add_execset()

◆ refda_exec_add_target()

int refda_exec_add_target ( refda_runctx_ptr_t runctxp,
const cace_ari_t target,
refda_exec_status_t finish 
)

From outside the exec worker thread, inject a single execution target and allow its sequence to be tracked to its finish.

This function is thread safe on the agent.

Parameters
[in]runctxpThe run context, which includes the agent pointer.
[in]targetThe execution target (CTRL ref or macro).
[in]finishAn optional execution-finished state for the whole target, or a null pointer to not track this state.

References agent, refda_runctx_t::agent, CACE_LOG_CRIT, CACE_LOG_ERR, CHKERR1, refda_agent_t::exec_next_pid, refda_agent_t::exec_state, refda_agent_t::exec_state_mutex, refda_agent_t::execs_sem, refda_exec_status_t::failed, refda_exec_status_t::finished, refda_exec_seq_t::pid, refda_exec_proc_expand(), refda_exec_seq_t::runctx, and refda_exec_seq_t::status.

Referenced by refda_agent_startup_exec(), and refda_exec_add_execset().

◆ refda_exec_check_sbr_condition()

static int refda_exec_check_sbr_condition ( refda_agent_t agent,
const refda_amm_sbr_desc_t sbr,
cace_ari_t result 
)
static

◆ refda_exec_next()

int refda_exec_next ( refda_exec_seq_t seq,
const cace_ari_t target 
)

Setup an ARI to execute next in the sequence.

The front of the execution sequence, the current item, is not modified.

Parameters
[in]agentThe agent context pointer
[in]seqThe sequence within which to inject the ARI target(s)
[in]targetThe ARI to execute
Returns
Non-zero if the ARI could not be queued for execution

References CHKERR1, and refda_exec_proc_expand().

Referenced by refda_adm_ietf_dtnma_agent_ctrl_catch(), and refda_adm_ietf_dtnma_agent_ctrl_if_then_else().

◆ refda_exec_rule_action()

static int refda_exec_rule_action ( refda_agent_t agent,
const cace_ari_t action 
)
static

Expand a rule's action that has already been verified.

Based on code from refda_exec_exp_execset

References agent, refda_agent_t::exec_next_pid, refda_agent_t::exec_state, refda_exec_seq_t::pid, refda_exec_proc_expand(), refda_runctx_from(), and refda_exec_seq_t::runctx.

Referenced by refda_exec_run_sbr(), and refda_exec_run_tbr().

◆ refda_exec_run_sbr()

◆ refda_exec_run_tbr()

◆ refda_exec_sbr_disable()

int refda_exec_sbr_disable ( refda_agent_t agent,
refda_amm_sbr_desc_t sbr 
)

Cease periodic execution of a state based rule.

Parameters
[in]agentThe agent context pointer
[in]sbrThe rule to disable
Returns
Non-zero if the rule could not be stopped

References agent, CHKERR1, refda_amm_sbr_desc_t::enabled, refda_agent_t::instr, and refda_instr_t::num_sbrs.

Referenced by refda_adm_ietf_dtnma_agent_ctrl_ensure_rule_enabled(), refda_adm_ietf_dtnma_agent_ctrl_obsolete_rule(), refda_adm_ietf_dtnma_agent_ctrl_reset_rule_enabled(), and refda_exec_run_sbr().

◆ refda_exec_sbr_enable()

◆ refda_exec_sbr_next_scheduled_time()

static int refda_exec_sbr_next_scheduled_time ( struct timespec *  schedtime,
const refda_amm_sbr_desc_t sbr 
)
static

Compute the next scheduled time at which to run the SBR.

References cace_ari_get_td(), cace_ari_is_lit_typed(), CACE_ARI_TYPE_TD, CACE_LOG_ERR, and refda_amm_sbr_desc_t::min_interval.

Referenced by refda_exec_schedule_sbr().

◆ refda_exec_schedule_sbr()

◆ refda_exec_schedule_tbr()

◆ refda_exec_tbr_disable()

int refda_exec_tbr_disable ( refda_agent_t agent,
refda_amm_tbr_desc_t tbr 
)

Cease periodic execution of a time based rule.

Parameters
[in]agentThe agent context pointer
[in]tbrThe rule to disable
Returns
Non-zero if the rule could not be stopped

References agent, CHKERR1, refda_amm_tbr_desc_t::enabled, refda_agent_t::instr, and refda_instr_t::num_tbrs.

Referenced by refda_adm_ietf_dtnma_agent_ctrl_ensure_rule_enabled(), refda_adm_ietf_dtnma_agent_ctrl_obsolete_rule(), refda_adm_ietf_dtnma_agent_ctrl_reset_rule_enabled(), refda_exec_run_tbr(), and refda_exec_schedule_tbr().

◆ refda_exec_tbr_enable()

◆ refda_exec_tbr_next_scheduled_time()

static int refda_exec_tbr_next_scheduled_time ( struct timespec *  schedtime,
const refda_amm_tbr_desc_t tbr,
bool  starting 
)
static

◆ refda_exec_waiting()

int refda_exec_waiting ( refda_agent_t agent)

Execute any waiting sequences as part of normal worker iteration.

Note
This is for unit testing only, not used by agent directly.
Parameters
[in]agentThe agent state.
Returns
Zero if successful.

References agent, CACE_LOG_CRIT, CACE_LOG_DEBUG, CACE_LOG_ERR, CACE_LOG_WARNING, refda_agent_t::exec_state, refda_agent_t::exec_state_mutex, refda_exec_item_t::execution_stage, refda_exec_seq_t::items, refda_exec_seq_t::pid, refda_exec_proc_run(), and REFDA_EXEC_WAITING.

Referenced by refda_exec_worker_iteration(), test_refda_exec_state_based_rule(), test_refda_exec_state_based_rule_cond_false_then_true(), and test_refda_exec_time_based_rule().

◆ refda_exec_worker()

void * refda_exec_worker ( void *  arg)

Work thread function for the Agent execution manager.

Parameters
[in]argThe context refda_agent_t pointer.
Returns
Always NULL pointer.

References agent, CACE_LOG_INFO, and refda_exec_worker_iteration().

Referenced by refda_agent_start().

◆ refda_exec_worker_iteration()

bool refda_exec_worker_iteration ( refda_agent_t agent)

Helper function to run a single iteration of the exec worker thread.

Note
This is for unit testing only, not used by agent directly.
Parameters
[in]agentThe agent state.
Returns
True to continue the loop, false to stop

References agent, refda_runctx_t::agent, refda_timeline_sbr_event_t::agent, refda_timeline_tbr_event_t::agent, cace_ari_is_undefined(), CACE_LOG_DEBUG, CACE_LOG_ERR, CACE_LOG_INFO, cace_log_is_enabled_for(), cace_timeperiod_encode(), refda_timeline_sbr_event_t::callback, refda_timeline_tbr_event_t::callback, refda_timeline_exec_event_t::callback, refda_timeline_event_t::exec, refda_agent_t::exec_end, refda_agent_t::exec_timeline, refda_agent_t::execs, refda_agent_t::execs_enable, refda_agent_t::execs_sem, refda_exec_item_t::execution_stage, refda_agent_t::instr, refda_timeline_exec_event_t::item, refda_instr_t::num_ctrls_run, refda_timeline_event_t::purpose, refda_ctrl_exec_ctx_deinit(), refda_ctrl_exec_ctx_init(), refda_exec_add_execset(), refda_exec_proc_ctrl_finish(), refda_exec_waiting(), REFDA_EXEC_WAITING, refda_msgdata_deinit(), refda_msgdata_init(), refda_agent_t::rptgs, refda_agent_t::rptgs_sem, refda_ctrl_exec_ctx_t::runctx, refda_timeline_sbr_event_t::sbr, refda_timeline_event_t::sbr, refda_timeline_tbr_event_t::tbr, refda_timeline_event_t::tbr, refda_timeline_event_t::ts, and refda_msgdata_t::value.

Referenced by refda_exec_worker(), test_refda_exec_state_based_rule(), test_refda_exec_state_based_rule_cond_false_then_true(), and test_refda_exec_time_based_rule().