Define the Custom Effect
To define a custom effect, you must write C/C++ code that processes cyber interrupts and implements the effect and any related actions (such as cancelling the effect). These functions can be added to the process model’s function block or included as an external file.
Every file involved with cyber effects must have the line
#include "cyber_effects.h"
You will need to include your additions to the Cyber Effects model in cyber_effects.h, including:
- Effect and argument names
- Argument structures
Any new categories, effects, and arguments you create must be included in the appropriate data structures in cyber_effects.h. For example, for a new effect in the IP category, a new member must be added to the enumeration type CyberT_Effects_IP. You should add new members before the “count” variable in each structure. You might need to override the default index in the structure to match the symbol map values you will assign in the configure node; refer to the discussions in Update the Cyber Effects Configuration Node for details.
You should implement the effect and related actions as callbacks that follow the prototype
typedef void (*CyberT_Effect_Proc_Ptr) (CyberT_Cmd_Iface* cmd_iface_ptr, void* effect_args_vptr, void* model_data_vptr);
Each callback will make changes in the process model to cause the desired behavior, as described in the CyberT_Effect_Proc_Ptr prototype details.
Processes that support cyber modeling will have a function that processes cyber event interrupts. When an interrupt from the CEM is received, the client module can execute the corresponding effect by calling the function cyber_effects_cmd_process(). This function requires three arguments: a handle to the CEM, a pointer to a data structure local to the client that provides the client’s current information and memory related to the effect (client_mem_vptr), and the interrupt code. You will need to add code that sets up the client_mem_vptr appropriately.
The cyber_effects_cmd_process() function will internally obtain further information from the interrupt event and execute the CyberT_Effect_Proc_Ptr callback defined for the corresponding event. client_mem_vptr will be passed to the effect callback as model_data_vptr. An example of this can be found in the function ip_rte_central_cpu_cyber_effect_cmd_process(), located in the function block of the ip_rte_central_cpu process model.