⭐ 欢迎来到虫虫下载站! | 📦 资源下载 📁 资源专辑 ℹ️ 关于我们
⭐ 虫虫下载站

📄 aodv_wlan_mac_interface.pr.c

📁 opnet ad hoc adov routing
💻 C
📖 第 1 页 / 共 2 页
字号:
/* Process model C form file: aodv_wlan_mac_interface.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 aodv_wlan_mac_interface_pr_c [] = "MIL_3_Tfile_Hdr_ 80C 30A op_runsim 7 3C064A5B 3C064A5B 1 manet.antd.nist.gov lmiller 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" {#endifFSM_EXT_DECS#if defined (__cplusplus)} /* end of 'extern "C"' */#endif/* Header Block *//***** Include Files. *****//* Address assignment definitions.	*/#include "oms_auto_addr_support.h"/* Topology analysis-related definitions. */#include "oms_tan.h"/* Process registry-related definitions. */#include "oms_pr.h"/***** Transition Macros ******/#define MAC_LAYER_PKT_ARVL	(intrpt_type == OPC_INTRPT_STRM && intrpt_strm == instrm_from_mac)#define APPL_LAYER_PKT_ARVL	(intrpt_type == OPC_INTRPT_STRM && intrpt_strm != instrm_from_mac)/***** Functional declaration ******/static void			wlan_mac_higher_layer_intf_sv_init ();static void			wlan_mac_higher_layer_register_as_arp ();/* 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	/* State Variables */	Objid	                  		my_objid;	Objid	                  		my_node_objid;	int	                    		instrm_from_mac;	int	                    		outstrm_to_mac;	int	                    		destination_address;	OmsT_Aa_Address_Handle	 		oms_aa_handle;	int	                    		mac_address;	Ici*	                   		wlan_mac_req_iciptr;	} aodv_wlan_mac_interface_state;#define pr_state_ptr            		((aodv_wlan_mac_interface_state*) SimI_Mod_State_Ptr)#define my_objid                		pr_state_ptr->my_objid#define my_node_objid           		pr_state_ptr->my_node_objid#define instrm_from_mac         		pr_state_ptr->instrm_from_mac#define outstrm_to_mac          		pr_state_ptr->outstrm_to_mac#define destination_address     		pr_state_ptr->destination_address#define oms_aa_handle           		pr_state_ptr->oms_aa_handle#define mac_address             		pr_state_ptr->mac_address#define wlan_mac_req_iciptr     		pr_state_ptr->wlan_mac_req_iciptr/* 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	aodv_wlan_mac_interface_state *op_sv_ptr = pr_state_ptr;/* Function Block */enum { _block_origin = __LINE__ };static voidwlan_mac_higher_layer_intf_sv_init ()	{	int			type_of_service;	/** Initializes all state variables used in this	**/	/** process model.									**/	FIN (wlan_mac_higher_layer_intf_sv_init ());	/* Object identifier for the surrounding module and node.	*/	my_objid = op_id_self ();	my_node_objid = op_topo_parent (my_objid);	/* Stream indices to and from the WLAN MAC process.	*/	/* these will be set in the "exit execs" of "init".	*/	outstrm_to_mac  = OPC_INT_UNDEF;	instrm_from_mac = OPC_INT_UNDEF;	/* Determine the destination to which packet should	*/	/* be sent,and the prioritization to be provided to	*/	/* the transmitted packet.							*/	//printf("init de dest address\n");	//op_ima_obj_attr_get (my_objid, "Destination Address", &destination_address);	op_ima_obj_attr_get (my_objid, "Type of Service", 	  &type_of_service);	/* Some interface control information is needed to	*/	/* indicate to the MAC of the destination to which	*/	/* a given packet needs to be sent. Create it.		*/	wlan_mac_req_iciptr = op_ici_create ("wlan_mac_request");	op_ici_attr_set (wlan_mac_req_iciptr, "type_of_service", type_of_service);	op_ici_attr_set (wlan_mac_req_iciptr, "protocol_type",   0x800);	FOUT;	}static voidwlan_mac_higher_layer_register_as_arp ()	{	char				proc_model_name [128];	OmsT_Pr_Handle		own_process_record_handle;	Prohandle			own_prohandle;	/** Register this process in the model-wide process registry.	**/	FIN (wlan_mac_higher_layer_register_as_arp ());	/* Obtain the process model name and process handle.	*/	op_ima_obj_attr_get (my_objid, "process model", proc_model_name);	own_prohandle = op_pro_self ();	/* Register this process in the model-wide process registry	*/	own_process_record_handle = (OmsT_Pr_Handle) oms_pr_process_register (			my_node_objid, my_objid, own_prohandle, proc_model_name);	/* Register this protocol attribute and the element address	*/	/* of this process into the model-wide registry.			*/	oms_pr_attr_set (own_process_record_handle,		"protocol",		OMSC_PR_STRING,		"arp",		OPC_NIL);	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 aodv_wlan_mac_interface (void);	Compcode aodv_wlan_mac_interface_init (void **);	void aodv_wlan_mac_interface_diag (void);	void aodv_wlan_mac_interface_terminate (void);	void aodv_wlan_mac_interface_svar (void *, const char *, char **);#if defined (__cplusplus)} /* end of 'extern "C"' */#endif/* Process model interrupt handling procedure */voidaodv_wlan_mac_interface (void)	{	int _block_origin = 0;	FIN (aodv_wlan_mac_interface ());	if (1)		{		List*				proc_record_handle_list_ptr;		int					record_handle_list_size;		OmsT_Pr_Handle		process_record_handle;		Objid				mac_module_objid;		Boolean				dest_addr_okay = OPC_FALSE;		double				ne_address = OPC_DBL_UNDEF;		int					curr_dest_addr = OMSC_AA_AUTO_ASSIGN;		Packet*				pkptr;		int					intrpt_type = OPC_INT_UNDEF;		int					intrpt_strm = OPC_INT_UNDEF;		int					i;		OmsT_Aa_Address_Info * ith_address_info_ptr;				Ici* ici_dest_address;		FSM_ENTER (aodv_wlan_mac_interface)		FSM_BLOCK_SWITCH			{			/*---------------------------------------------------------*/			/** state (init) enter executives **/			FSM_STATE_ENTER_UNFORCED_NOLABEL (0, "init", "aodv_wlan_mac_interface () [init enter execs]")				{				/* Initialize the state variables used by this model.	*/				wlan_mac_higher_layer_intf_sv_init ();								/* Register this process as "arp" so that lower layer	*/				/* MAC process can connect to it.						*/				wlan_mac_higher_layer_register_as_arp ();								/* Schedule a self interrupt to wait for lower layer	*/				/* wlan MAC process to initialize and register itself in	*/				/* the model-wide process registry.						*/				op_intrpt_schedule_self (op_sim_time (), 0);								}			/** blocking after enter executives of unforced state. **/			FSM_EXIT (1,aodv_wlan_mac_interface)			/** state (init) exit executives **/			FSM_STATE_EXIT_UNFORCED (0, "init", "aodv_wlan_mac_interface () [init exit execs]")				{				/* Schedule a self interrupt to wait for lower layer	*/				/* wlan MAC process to initialize and register itself in*/				/* the model-wide process registry.						*/				op_intrpt_schedule_self (op_sim_time (), 0);								}			/** state (init) transition processing **/			FSM_TRANSIT_FORCE (5, state5_enter_exec, ;, "default", "", "init", "init2")				/*---------------------------------------------------------*/			/** state (idle) enter executives **/			FSM_STATE_ENTER_UNFORCED (1, state1_enter_exec, "idle", "aodv_wlan_mac_interface () [idle enter execs]")				{								}			/** blocking after enter executives of unforced state. **/			FSM_EXIT (3,aodv_wlan_mac_interface)			/** state (idle) exit executives **/			FSM_STATE_EXIT_UNFORCED (1, "idle", "aodv_wlan_mac_interface () [idle exit execs]")				{				/* The only interrupt expected in this state is a	*/				/* stream interrupt. It can be either from the MAC	*/				/* layer for a packet destined for this node or		*/				/* from the application layer for a packet destined	*/				/* for some other node.								*/				intrpt_type = op_intrpt_type ();				intrpt_strm = op_intrpt_strm ();				pkptr = op_pk_get (intrpt_strm);								}			/** state (idle) transition processing **/			FSM_INIT_COND (APPL_LAYER_PKT_ARVL)			FSM_TEST_COND (MAC_LAYER_PKT_ARVL)			FSM_TEST_LOGIC ("idle")			FSM_TRANSIT_SWITCH				{				FSM_CASE_TRANSIT (0, 2, state2_enter_exec, ;, "APPL_LAYER_PKT_ARVL", "", "idle", "appl layer arrival")				FSM_CASE_TRANSIT (1, 3, state3_enter_exec, ;, "MAC_LAYER_PKT_ARVL", "", "idle", "mac layer arrival")				}				/*---------------------------------------------------------*/			/** state (appl layer arrival) enter executives **/			FSM_STATE_ENTER_FORCED (2, state2_enter_exec, "appl layer arrival", "aodv_wlan_mac_interface () [appl layer arrival enter execs]")				{				/* A packet has arrived from the application layer.	*/				/* If the destination address specified is "Random"	*/				/* then generate a destination and forward the appl	*/				/* packet to the MAC layer with that information.	*/								// take the destination from the ici				ici_dest_address = op_intrpt_ici();				op_ici_attr_get(ici_dest_address,"Packet_Destination",&destination_address);												if (1) op_prg_odb_bkpt("macs")				if (destination_address == OMSC_AA_AUTO_ASSIGN)					// never happens					{					/* Initialize current destination address to the Auto */					/* Assign value										  */					curr_dest_addr = destination_address;									/* Call function to generate a random destination	*/					/* from the pool of available addresses.			*/					oms_aa_dest_addr_get (oms_aa_handle, &curr_dest_addr);									/* Keep on generating the random addresses until source */					/* address is not same as current address.				*/					while (curr_dest_addr == mac_address)						{						/* Initialize current destination address to the Auto */						/* Assign value										  */						curr_dest_addr = destination_address;										/* Call function to generate a random destination	*/						/* from the pool of available addresses.			*/						oms_aa_dest_addr_get (oms_aa_handle, &curr_dest_addr);						}										}				else					{					/* The packet needs to be sent to an explicit	*/					/* destination as specified in the "Destination	*/					/* Address" attribute.							*/					curr_dest_addr = destination_address;					}

⌨️ 快捷键说明

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