dsr_sink.pr.c

来自「afit的ad hoc路由协议源码」· C语言 代码 · 共 287 行

C
287
字号
/* Process model C form file: dsr_sink.pr.c */
/* Portions of this file copyright 1992-2001 by OPNET Technologies, Inc. */



/* This variable carries the header into the object file */
static const char dsr_sink_pr_c [] = "MIL_3_Tfile_Hdr_ 80C 30A op_runsim 7 3C8784AF 3C8784AF 1 jballah Jason@Ballah 0 0 none none 0 0 none 0 0 0 0 0 0                                                                                                                                                                                                                                                                                                                                                                                                               ";
#include <string.h>



/* OPNET system definitions */
#include <opnet.h>

#if defined (__cplusplus)
extern "C" {
#endif
FSM_EXT_DECS
#if defined (__cplusplus)
} /* end of 'extern "C"' */
#endif


/* Header Block */

///////////////////////////////////////////////////////////////
// DSR RECEIVER HEADER BLOCK
//
// Declaration of every constant, type, lybrary, glabal 
// variables... used by the dsr receiver process
///////////////////////////////////////////////////////////////

///////////////////////////////////////////////////////////////
///////////////// CONSTANTS DEFINITION ////////////////////////
///////////////////////////////////////////////////////////////

// stream number definition
#define FROM_DSR_INTERFACE_STRM		0

///////////////////////////////////////////////////////////////
///////////// TRANSITION MACROS DEFINITION ////////////////////
///////////////////////////////////////////////////////////////

#define PKT_ARRIVAL	(op_intrpt_type ()==OPC_INTRPT_STRM)

/* End of Header Block */


#if !defined (VOSD_NO_FIN)
#undef	BIN
#undef	BOUT
#define	BIN		FIN_LOCAL_FIELD(last_line_passed) = __LINE__ - _block_origin;
#define	BOUT	BIN
#define	BINIT	FIN_LOCAL_FIELD(last_line_passed) = 0; _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
	} dsr_sink_state;

#define pr_state_ptr            		((dsr_sink_state*) SimI_Mod_State_Ptr)

/* This macro definition 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
#define FIN_PREAMBLE	dsr_sink_state *op_sv_ptr = pr_state_ptr;


/* No Function Block */

enum { _block_origin = __LINE__ };

/* 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 dsr_sink (void);
	Compcode dsr_sink_init (void **);
	void dsr_sink_diag (void);
	void dsr_sink_terminate (void);
	void dsr_sink_svar (void *, const char *, char **);
#if defined (__cplusplus)
} /* end of 'extern "C"' */
#endif




/* Process model interrupt handling procedure */


void
dsr_sink (void)
	{
	int _block_origin = 0;
	FIN (dsr_sink ());
	if (1)
		{
		///////////////////////////////////////////////////////////////
		// DSR SINK TEMPORARY VARIABLES BLOCK
		//
		// Declaration of the temporary variables
		///////////////////////////////////////////////////////////////
		
		Packet* pk_ptr;


		FSM_ENTER (dsr_sink)

		FSM_BLOCK_SWITCH
			{
			/*---------------------------------------------------------*/
			/** state (idle) enter executives **/
			FSM_STATE_ENTER_UNFORCED (0, state0_enter_exec, "idle", "dsr_sink () [idle enter execs]")
				{
				}


			/** blocking after enter executives of unforced state. **/
			FSM_EXIT (1,dsr_sink)


			/** state (idle) exit executives **/
			FSM_STATE_EXIT_UNFORCED (0, "idle", "dsr_sink () [idle exit execs]")
				{
				}


			/** state (idle) transition processing **/
			FSM_INIT_COND (PKT_ARRIVAL)
			FSM_DFLT_COND
			FSM_TEST_LOGIC ("idle")

			FSM_TRANSIT_SWITCH
				{
				FSM_CASE_TRANSIT (0, 1, state1_enter_exec, ;, "PKT_ARRIVAL", "", "idle", "sink")
				FSM_CASE_TRANSIT (1, 0, state0_enter_exec, ;, "default", "", "idle", "idle")
				}
				/*---------------------------------------------------------*/



			/** state (sink) enter executives **/
			FSM_STATE_ENTER_FORCED (1, state1_enter_exec, "sink", "dsr_sink () [sink enter execs]")
				{
				///////////////////////////////////////////////////////////////
				// SINK STATE
				//
				// Just destroyed the received packets
				///////////////////////////////////////////////////////////////
				
				// just extract and destroy the packet received from the dsr interface (as a sink)
				pk_ptr=op_pk_get(FROM_DSR_INTERFACE_STRM);
				op_pk_destroy(pk_ptr);
				}


			/** state (sink) exit executives **/
			FSM_STATE_EXIT_FORCED (1, "sink", "dsr_sink () [sink exit execs]")
				{
				}


			/** state (sink) transition processing **/
			FSM_TRANSIT_FORCE (0, state0_enter_exec, ;, "default", "", "sink", "idle")
				/*---------------------------------------------------------*/



			}


		FSM_EXIT (0,dsr_sink)
		}
	}

#if defined (__cplusplus)
	extern "C" { 
#endif
	extern VosT_Fun_Status Vos_Catmem_Register (const char * , int , VosT_Void_Null_Proc, VosT_Address *);
	extern VosT_Address Vos_Catmem_Alloc (VosT_Address, size_t);
	extern VosT_Fun_Status Vos_Catmem_Dealloc (VosT_Address);
#if defined (__cplusplus)
	}
#endif


Compcode
dsr_sink_init (void ** gen_state_pptr)
	{
	int _block_origin = 0;
	static VosT_Address	obtype = OPC_NIL;

	FIN (dsr_sink_init (gen_state_pptr))

	if (obtype == OPC_NIL)
		{
		/* Initialize memory management */
		if (Vos_Catmem_Register ("proc state vars (dsr_sink)",
			sizeof (dsr_sink_state), Vos_Vnop, &obtype) == VOSC_FAILURE)
			{
			FRET (OPC_COMPCODE_FAILURE)
			}
		}

	*gen_state_pptr = Vos_Catmem_Alloc (obtype, 1);
	if (*gen_state_pptr == OPC_NIL)
		{
		FRET (OPC_COMPCODE_FAILURE)
		}
	else
		{
		/* Initialize FSM handling */
		((dsr_sink_state *)(*gen_state_pptr))->current_block = 0;

		FRET (OPC_COMPCODE_SUCCESS)
		}
	}



void
dsr_sink_diag (void)
	{
	/* No Diagnostic Block */
	}




void
dsr_sink_terminate (void)
	{
	int _block_origin = __LINE__;

	FIN (dsr_sink_terminate (void))

	if (1)
		{
		///////////////////////////////////////////////////////////////
		// DSR SINK TEMPORARY VARIABLES BLOCK
		//
		// Declaration of the temporary variables
		///////////////////////////////////////////////////////////////
		
		Packet* pk_ptr;

		/* No Termination Block */

		}
	Vos_Catmem_Dealloc (pr_state_ptr);

	FOUT;
	}




void
dsr_sink_svar (void * gen_ptr, const char * var_name, char ** var_p_ptr)
	{

	FIN (dsr_sink_svar (gen_ptr, var_name, var_p_ptr))

	*var_p_ptr = (char *)OPC_NIL;

	FOUT;
	}

⌨️ 快捷键说明

复制代码Ctrl + C
搜索代码Ctrl + F
全屏模式F11
增大字号Ctrl + =
减小字号Ctrl + -
显示快捷键?