/* Process model C form file: z_flood_node_proc.pr.c */
/* Portions of this file copyright 1986-2008 by OPNET Technologies, Inc. */
/* This variable carries the header into the object file */
const char z_flood_node_proc_pr_c [] = "MIL_3_Tfile_Hdr_ 145A 30A modeler 7 528A2B8F 528A2B8F 1 yanhc yanhongcheng 0 0 none none 0 0 none 0 0 0 0 0 0 0 0 1bcc 1 ";
#include <string.h>
/* OPNET system definitions */
#include <opnet.h>
/* Header Block */
#define APP_STRM 4
#define ARV (op_intrpt_type()==OPC_INTRPT_STRM && \
op_intrpt_strm()==APP_STRM)
#define RCV (op_intrpt_type()==OPC_INTRPT_STRM && \
op_intrpt_strm()!=APP_STRM)
#define SRV (op_intrpt_type()==OPC_INTRPT_SELF)
#define MAX_SEQ 255
// routing table entry definition
typedef struct{
int seq_number;
int in_strm[4]; //1 means in, 0 means no in
}structseq;
typedef struct{
int srcaddr;
structseq seq_num[MAX_SEQ];
int seq_it; // iterator
}rttable_entry;
/* End of Header Block */
#if !defined (VOSD_NO_FIN)
#undef BIN
#undef BOUT
#define BIN FIN_LOCAL_FIELD(_op_last_line_passed) = __LINE__ - _op_block_origin;
#define BOUT BIN
#define BINIT FIN_LOCAL_FIELD(_op_last_line_passed) = 0; _op_block_origin = __LINE__;
#else
#define BINIT
#endif /* #if !defined (VOSD_NO_FIN) */
/* State variable definitions */
typedef struct
{
/* Internal state tracking for FSM */
FSM_SYS_STATE
/* State Variables */
Objid node_id ;
int seq_no_self ; /* self sequence increment */
List * list_rttable ;
} z_flood_node_proc_state;
#define node_id op_sv_ptr->node_id
#define seq_no_self op_sv_ptr->seq_no_self
#define list_rttable op_sv_ptr->list_rttable
/* These macro definitions will define a local variable called */
/* "op_sv_ptr" in each function containing a FIN statement. */
/* This variable points to the state variable data structure, */
/* and can be used from a C debugger to display their values. */
#undef FIN_PREAMBLE_DEC
#undef FIN_PREAMBLE_CODE
#define FIN_PREAMBLE_DEC z_flood_node_proc_state *op_sv_ptr;
#define FIN_PREAMBLE_CODE \
op_sv_ptr = ((z_flood_node_proc_state *)(OP_SIM_CONTEXT_PTR->_op_mod_state_ptr));
/* Function Block */
#if !defined (VOSD_NO_FIN)
enum { _op_block_origin = __LINE__ + 2};
#endif
// Routing table manipulating functions
rttable_entry * rttable_lookup(int src_addr)
{
int rt_size, i;
rttable_entry * rt_entry;
FIN(rttable_lookup(src_addr));
rt_size = op_prg_list_size(list_rttable);
for(i=0; i<rt_size; i++)
{
rt_entry = op_prg_list_access(list_rttable, i);
if(rt_entry->srcaddr == src_addr)
{
FRET(rt_entry);
}
}
FRET(OPC_NIL);
}
void rttable_addEntry(int src_addr, int seq, int instrm)
{
rttable_entry * rt_entry;
int i;
FIN(rttable_addEntry(src_addr, seq, instrm));
rt_entry = (rttable_entry *)op_prg_mem_alloc(sizeof(rttable_entry));
rt_entry->srcaddr = src_addr;
rt_entry->seq_it = 1;
for(i=0; i<MAX_SEQ; i++)
{
rt_entry->seq_num[i].seq_number = 0xFFFF;
}
rt_entry->seq_num[0].seq_number = seq;
rt_entry->seq_num[0].in_strm[instrm] = 1;
op_prg_list_insert(list_rttable, rt_entry, OPC_LISTPOS_TAIL);
FOUT;
}
int rttable_isnewSeq(rttable_entry * rt_entry, int seq)
{
int i;
FIN(rttable_isnewSeq(rt_entry, seq));
for(i=0; i<MAX_SEQ; i++)
{
if(rt_entry->seq_num[i].seq_number == seq)
FRET(0);
}
FRET(1);
}
void rttable_addSeq(rttable_entry * rt_entry, int seq, int instrm)
{
FIN(rttable_addSeq(rt_entry, seq, instrm));
rt_entry->seq_num[rt_entry->seq_it].seq_number = seq;
rt_entry->seq_num[rt_entry->seq_it].in_strm[instrm] = 1;
rt_entry->seq_it = (rt_entry->seq_it + 1) % 0xFFFF;
FOUT;
}
void rttable_addinstrm(rttable_entry * rt_entry, int seq, int instrm)
{
int i;
FIN(rttable_addinstrm(rt_entry, seq, instrm));
for(i=0; i<MAX_SEQ; i++)
{
if(rt_entry->seq_num[i].seq_number == seq)
rt_entry->seq_num[i].in_strm[instrm] = 1;
}
FOUT;
}
void rttable_getstrm(int src_addr, int seq, int in_strm[])
{
int i;
rttable_entry * rt_entry;
FIN(rttable_getstrm(src_addr, seq, in_strm));
rt_entry = rttable_lookup(src_addr);
for(i=0; i<MAX_SEQ; i++)
{
if(rt_entry->seq_num[i].seq_number == seq)
{
in_strm[0] = rt_entry->seq_num[i].in_strm[0];
in_strm[1] = rt_entry->seq_num[i].in_strm[1];
in_strm[2] = rt_entry->seq_num[i].in_strm[2];
in_strm[3] = rt_entry->seq_num[i].in_strm[3];
}
}
FOUT;
}
/* End of Function Block */
/* Undefine optional tracing in FIN/FOUT/FRET */
/* The FSM has its own tracing code and the other */
/* functions should not have any tracing. */
#undef FIN_TRACING
#define FIN_TRACING
#undef FOUTRET_TRACING
#define FOUTRET_TRACING
#if defined (__cplusplus)
extern "C" {
#endif
void z_flood_node_proc (OP_SIM_CONTEXT_ARG_OPT);
VosT_Obtype _op_z_flood_node_proc_init (int * init_block_ptr);
void _op_z_flood_node_proc_diag (OP_SIM_CONTEXT_ARG_OPT);
void _op_z_flood_node_proc_terminate (OP_SIM_CONTEXT_ARG_OPT);
VosT_Address _op_z_flood_node_proc_alloc (VosT_Obtype, int);
void _op_z_flood_node_proc_svar (void *, const char *, void **);
#if defined (__cplusplus)
} /* end of 'extern "C"' */
#endif
/* Process model interrupt handling procedure */
void
z_flood_node_proc (OP_SIM_CONTEXT_ARG_OPT)
{
#if !defined (VOSD_NO_FIN)
int _op_block_origin = 0;
#endif
FIN_MT (z_flood_node_proc ());
{
FSM_ENTER ("z_flood_node_proc")
FSM_BLOCK_SWITCH
{
/*---------------------------------------------------------*/
/** state (INIT) enter executives **/
FSM_STATE_ENTER_FORCED_NOLABEL (0, "INIT", "z_flood_node_proc [INIT enter execs]")
FSM_PROFILE_SECTION_IN ("z_flood_node_proc [INIT enter execs]", state0_enter_exec)
{
// get node id, init the seq
node_id = op_topo_parent(op_id_self()) - 2;
seq_no_self = 0;
list_rttable = op_prg_list_create();
op_intrpt_schedule_self(op_sim_time()+0.5, 0);
}
FSM_PROFILE_SECTION_OUT (state0_enter_exec)
/** state (INIT) exit executives **/
FSM_STATE_EXIT_FORCED (0, "INIT", "z_flood_node_proc [INIT exit execs]")
/** state (INIT) transition processing **/
FSM_TRANSIT_FORCE (1, state1_enter_exec, ;, "default", "", "INIT", "BRANCH", "tr_0", "z_flood_node_proc [INIT -> BRANCH : default / ]")
/*---------------------------------------------------------*/
/** state (BRANCH) enter executives **/
FSM_STATE_ENTER_UNFORCED (1, "BRANCH", state1_enter_exec, "z_flood_node_proc [BRANCH enter execs]")
/** blocking after enter executives of unforced state. **/
FSM_EXIT (3,"z_flood_node_proc")
/** state (BRANCH) exit executives **/
FSM_STATE_EXIT_UNFORCED (1, "BRANCH", "z_flood_node_proc [BRANCH exit execs]")
/** state (BRANCH) transition processing **/
FSM_PROFILE_SECTION_IN ("z_flood_node_proc [BRANCH trans conditions]", state1_trans_conds)
FSM_INIT_COND (SRV)
FSM_TEST_COND (ARV)
FSM_TEST_COND (RCV)
FSM_DFLT_COND
FSM_TEST_LOGIC ("BRANCH")
FSM_PROFILE_SECTION_OUT (state1_trans_conds)
FSM_TRANSIT_SWITCH
{
FSM_CASE_TRANSIT (0, 2, state2_enter_exec, ;, "SRV", "", "BRANCH", "Foward_Slot", "tr_1", "z_flood_node_proc [BRANCH -> Foward_Slot : SRV /
yanhc519
- 粉丝: 108
- 资源: 19
最新资源
- 基于Java的民宿管理系统-springboot毕业项目,适合计算机毕-设、实训项目、大作业学习.rar
- 基于html5的民谣网站的设计与实现-springboot毕业项目,适合计算机毕-设、实训项目、大作业学习.zip
- 3b020汽车配件销售管理系统_springboot+vue.zip
- 3b022投票系统_springboot+vue.zip
- 3b021投稿和稿件处理系统_springboot+vue.zip
- 3b024校园运动会管理系统_springboot+vue0.zip
- 基于html5的网上团购系统设计与实现-springboot毕业项目,适合计算机毕-设、实训项目、大作业学习.rar
- APP论坛社区软件源码网站源码APP封装
- 3b023小区疫苗接种管理系统_springboot+vue.zip
- 基于javaEE的校园二手书交易平台的设计与实现-springboot毕业项目,适合计算机毕-设、实训项目、大作业学习.rar
- 基于BS的老年人体检管理系统-springboot毕业项目,适合计算机毕-设、实训项目、大作业学习.rar
- 3b025医院挂号系统_springboot+vue.zip
- 3b027自习室座位预约系统_springboot+vue.zip
- 3b028《升学日》日本大学信息及院校推荐网站_springboot+vue0.zip
- 3b026在线学习网站_springboot+vue.zip
- 基于Java的家政服务平台的设计与实现-springboot毕业项目,适合计算机毕-设、实训项目、大作业学习.rar
资源上传下载、课程学习等过程中有任何疑问或建议,欢迎提出宝贵意见哦~我们会及时处理!
点击此处反馈
- 1
- 2
前往页