DTNMA Reference Tools v2.1.0 - 13.gc5c0bac
Delay-Tolerant Networking Management Architecture (DTNMA) Tool Suite
Loading...
Searching...
No Matches
agent.h File Reference
#include "instr.h"
#include "msgdata.h"
#include "exec_seq.h"
#include "rpt_agg.h"
#include "timeline.h"
#include "acl.h"
#include "alarms.h"
#include <cace/util/daemon_run.h>
#include <cace/util/threadset.h>
#include <cace/amm/obj_ns.h>
#include <cace/amm/obj_store.h>
#include <cace/amm/msg_if.h>
#include <m-buffer.h>
#include <pthread.h>
+ Include dependency graph for agent.h:
+ This graph shows which files directly or indirectly include this file:

Data Structures

struct  refda_agent_t
 State of a DTNMA Agent. More...
 

Macros

#define REFDA_AGENT_ERR_LOCK_FAILED   2
 Error result when agent locking fails.
 
#define AGENT_QUEUE_SIZE   1024
 Size of agent hand-off queues.
 
#define REFDA_AGENT_LOCK(agent, err)
 Lock the object mutex on an agent and return if failed.
 
#define REFDA_AGENT_UNLOCK(agent, err)
 Unlock the object mutex on an agent and return if failed.
 

Functions

void refda_agent_init (refda_agent_t *agent)
 
void refda_agent_deinit (refda_agent_t *agent)
 
int refda_agent_nowtime (refda_agent_t *agent, cace_ari_t *val)
 Store the current timestamp in an ARI.
 
cace_amm_obj_desc_trefda_agent_get_object (refda_agent_t *agent, cace_ari_int_id_t org_id, cace_ari_int_id_t model_id, cace_ari_type_t type_id, cace_ari_int_id_t obj_id)
 Lookup a specific registered object by reference.
 
cace_amm_type_t * refda_agent_get_typedef (refda_agent_t *agent, cace_ari_int_id_t org_id, cace_ari_int_id_t model_id, cace_ari_int_id_t obj_id)
 Lookup a specific known TYPEDEF by reference.
 
int refda_agent_bindrefs (refda_agent_t *agent)
 After all ADMs are registered, bind cross-references between them.
 
int refda_agent_init_objs (refda_agent_t *agent)
 After all ADMs are registered, finish object initialization.
 
int refda_agent_start (refda_agent_t *agent)
 Called to start worker threads.
 
int refda_agent_stop (refda_agent_t *agent)
 Called to join worker threads.
 
int refda_agent_startup_exec (refda_agent_t *agent, cace_ari_t *target)
 Queue a startup macro to be executed after worker threads are running.
 
void refda_agent_enable_exec (refda_agent_t *agent)
 Enable ingress processing after work threads are started and all startup is completed.
 

Macro Definition Documentation

◆ AGENT_QUEUE_SIZE

#define AGENT_QUEUE_SIZE   1024

Size of agent hand-off queues.

◆ REFDA_AGENT_ERR_LOCK_FAILED

#define REFDA_AGENT_ERR_LOCK_FAILED   2

Error result when agent locking fails.

◆ REFDA_AGENT_LOCK

#define REFDA_AGENT_LOCK (   agent,
  err 
)
Value:
if (pthread_mutex_lock(&(agent->objs_mutex))) \
{ \
CACE_LOG_CRIT("failed to lock agent objects"); \
return err; \
}
static refda_agent_t agent
Per-process state.
Definition main.c:36
pthread_mutex_t objs_mutex
Mutex for the state of objs, its object sub-trees, and odm_names.
Definition agent.h:84

Lock the object mutex on an agent and return if failed.

◆ REFDA_AGENT_UNLOCK

#define REFDA_AGENT_UNLOCK (   agent,
  err 
)
Value:
if (pthread_mutex_unlock(&(agent->objs_mutex))) \
{ \
CACE_LOG_CRIT("failed to unlock agent objects"); \
return err; \
}

Unlock the object mutex on an agent and return if failed.

Function Documentation

◆ refda_agent_bindrefs()

◆ refda_agent_deinit()

◆ refda_agent_enable_exec()

void refda_agent_enable_exec ( refda_agent_t agent)

Enable ingress processing after work threads are started and all startup is completed.

Precondition
This is called after all refda_agent_startup_exec() uses.
Parameters
[in]agentThe agent to send from.
[in]targetThe target to execute. This object is moved from.

References agent, CACE_LOG_INFO, refda_agent_t::execs_enable, and refda_agent_t::execs_sem.

Referenced by main().

◆ refda_agent_get_object()

cace_amm_obj_desc_t * refda_agent_get_object ( refda_agent_t agent,
cace_ari_int_id_t  org_id,
cace_ari_int_id_t  model_id,
cace_ari_type_t  type_id,
cace_ari_int_id_t  obj_id 
)

Lookup a specific registered object by reference.

Precondition
The agent object store must already be locked.
Parameters
[in]agentThe agent to search within.
org_idThe namespace organization enumeration.
model_idThe namespace model enumeration.
type_idThe object type.
obj_idThe object enumeration.
Returns
The object descriptor or NULL if not found.

References agent, cace_amm_lookup_deinit(), cace_amm_lookup_deref(), cace_amm_lookup_init(), cace_ari_deinit(), CACE_ARI_INIT_UNDEFINED, cace_ari_set_objref_path_intid(), CACE_ARI_TEXT_ENC_OPTS_DEFAULT, cace_ari_text_encode(), CACE_LOG_WARNING, cace_amm_lookup_t::obj, and refda_agent_t::objs.

Referenced by refda_agent_bindrefs(), and refda_agent_get_typedef().

◆ refda_agent_get_typedef()

cace_amm_type_t * refda_agent_get_typedef ( refda_agent_t agent,
cace_ari_int_id_t  org_id,
cace_ari_int_id_t  model_id,
cace_ari_int_id_t  obj_id 
)

Lookup a specific known TYPEDEF by reference.

Precondition
The agent object store must already be locked.
Parameters
[in]agentThe agent to search within.
org_idThe namespace organization enumeration.
model_idThe namespace model enumeration.
obj_idThe object enumeration.
Returns
The typing object or NULL if not found.

References agent, cace_amm_obj_desc_t::app_data, CACE_ARI_TYPE_TYPEDEF, cace_amm_user_data_t::ptr, refda_agent_get_object(), and refda_amm_typedef_desc_t::typeobj.

Referenced by refda_agent_bindrefs().

◆ refda_agent_init()

◆ refda_agent_init_objs()

int refda_agent_init_objs ( refda_agent_t agent)

After all ADMs are registered, finish object initialization.

Parameters
[in,out]agentThe agent state to update.
Returns
The number of failed object initializations, or zero if successful.

References agent, cace_amm_obj_store_t::ns_list, refda_agent_t::objs, REFDA_AGENT_ERR_LOCK_FAILED, refda_agent_init_sbr(), refda_agent_init_tbr(), REFDA_AGENT_LOCK, and REFDA_AGENT_UNLOCK.

Referenced by main().

◆ refda_agent_nowtime()

int refda_agent_nowtime ( refda_agent_t agent,
cace_ari_t val 
)

Store the current timestamp in an ARI.

Parameters
[in]agentThe agent context.
[in,out]valThe value to set. This ARI must already be initialized.
Returns
Zero if successful, or 2 if the clock is not available.

References cace_ari_set_tp(), CACE_LOG_ERR, CHKERR1, and DTN_EPOCH_IN_POSIX.

Referenced by refda_reporting_ctrl(), and refda_reporting_gen().

◆ refda_agent_start()

int refda_agent_start ( refda_agent_t agent)

◆ refda_agent_startup_exec()

int refda_agent_startup_exec ( refda_agent_t agent,
cace_ari_t target 
)

Queue a startup macro to be executed after worker threads are running.

Precondition
This must be called after refda_agent_start().
Parameters
[in]agentThe agent to send from.
[in]targetThe target to execute. This object is moved from.
Returns
Zero if successful.

References agent, cace_ari_deinit(), CACE_LOG_DEBUG, CACE_LOG_ERR, CACE_LOG_INFO, CHKERR1, refda_exec_add_target(), refda_exec_status_deinit(), refda_exec_status_init(), refda_exec_status_wait(), and refda_runctx_from().

Referenced by main().

◆ refda_agent_stop()

int refda_agent_stop ( refda_agent_t agent)

Called to join worker threads.

This should be called after refda_agent_start().

Parameters
[in]agentThe agent state.
Returns
Zero if successful.

References agent, cace_daemon_run_stop(), CACE_LOG_INFO, cace_threadset_join(), CHKERR1, refda_agent_t::execs, refda_agent_t::execs_enable, refda_agent_t::execs_sem, refda_agent_t::mif, cace_amm_msg_if_t::recv, refda_msgdata_init(), refda_agent_t::running, and refda_agent_t::threads.

Referenced by main().