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

📄 aodv_wlan_mac_interface.pr.c

📁 opnet环境中实现aodv路由协议建模
💻 C
📖 第 1 页 / 共 2 页
字号:
						/* 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;
					}
				/* Set this information in the interface control	*/
				/* information to be sent to the MAC layer.			*/
				op_ici_attr_set (wlan_mac_req_iciptr, "dest_addr", curr_dest_addr);
				
				/* Install the control informationand send it to	*/
				/* the MAC layer.									*/
				op_ici_install (wlan_mac_req_iciptr);
				op_pk_send (pkptr, outstrm_to_mac);
				
				}

				FSM_PROFILE_SECTION_OUT (aodv_wlan_mac_interface [appl layer arrival enter execs], state2_enter_exec)

			/** state (appl layer arrival) exit executives **/
			FSM_STATE_EXIT_FORCED (2, "appl layer arrival", "aodv_wlan_mac_interface [appl layer arrival exit execs]")
				FSM_PROFILE_SECTION_IN (aodv_wlan_mac_interface [appl layer arrival exit execs], state2_exit_exec)
				{
				}
				FSM_PROFILE_SECTION_OUT (aodv_wlan_mac_interface [appl layer arrival exit execs], state2_exit_exec)


			/** state (appl layer arrival) transition processing **/
			FSM_TRANSIT_FORCE (1, state1_enter_exec, ;, "default", "", "appl layer arrival", "idle")
				/*---------------------------------------------------------*/



			/** state (mac layer arrival) enter executives **/
			FSM_STATE_ENTER_FORCED (3, "mac layer arrival", state3_enter_exec, "aodv_wlan_mac_interface [mac layer arrival enter execs]")
				FSM_PROFILE_SECTION_IN (aodv_wlan_mac_interface [mac layer arrival enter execs], state3_enter_exec)
				{
				/* A packet arrived from the MAC layer. Since the MAC	*/
				/* layer would have forwarded this only if it were		*/
				/* destined for this node, forward this packet to the	*/
				/* sink module.	*/
				op_pk_send (pkptr, 0);
				//op_sim_end("reception packet couche mac at node\n","","","");
				if (1)
					op_prg_odb_bkpt("macr");
				}

				FSM_PROFILE_SECTION_OUT (aodv_wlan_mac_interface [mac layer arrival enter execs], state3_enter_exec)

			/** state (mac layer arrival) exit executives **/
			FSM_STATE_EXIT_FORCED (3, "mac layer arrival", "aodv_wlan_mac_interface [mac layer arrival exit execs]")
				FSM_PROFILE_SECTION_IN (aodv_wlan_mac_interface [mac layer arrival exit execs], state3_exit_exec)
				{
				}
				FSM_PROFILE_SECTION_OUT (aodv_wlan_mac_interface [mac layer arrival exit execs], state3_exit_exec)


			/** state (mac layer arrival) transition processing **/
			FSM_TRANSIT_FORCE (1, state1_enter_exec, ;, "default", "", "mac layer arrival", "idle")
				/*---------------------------------------------------------*/



			/** state (wait) enter executives **/
			FSM_STATE_ENTER_UNFORCED (4, "wait", state4_enter_exec, "aodv_wlan_mac_interface [wait enter execs]")
				FSM_PROFILE_SECTION_IN (aodv_wlan_mac_interface [wait enter execs], state4_enter_exec)
				{
				
				}

				FSM_PROFILE_SECTION_OUT (aodv_wlan_mac_interface [wait enter execs], state4_enter_exec)

			/** blocking after enter executives of unforced state. **/
			FSM_EXIT (9,"aodv_wlan_mac_interface")


			/** state (wait) exit executives **/
			FSM_STATE_EXIT_UNFORCED (4, "wait", "aodv_wlan_mac_interface [wait exit execs]")
				FSM_PROFILE_SECTION_IN (aodv_wlan_mac_interface [wait exit execs], state4_exit_exec)
				{
				/* Obtain the MAC layer information for the local MAC	*/
				/* process from the model-wide registry.				*/
				proc_record_handle_list_ptr = op_prg_list_create ();
				oms_pr_process_discover (my_objid, proc_record_handle_list_ptr,
					"node objid",	OMSC_PR_OBJID,		my_node_objid,
					"protocol", 	OMSC_PR_STRING,		"mac",
					OPC_NIL);
				 
				/* If the MAC process regostered itself, then there	*/
				/* must be a valid match							*/
				record_handle_list_size = op_prg_list_size (proc_record_handle_list_ptr);
					
				if (record_handle_list_size !=  1)
					{
					/* An error should be created if there are more	*/
					/* than one WLAN-MAC process in the local node,	*/
					/* or if no match is found.						*/
					op_sim_end ("Error: either zero or several WLAN MAC processes found in the interface", "", "", "");
					}
				else
					{
					/*	Obtain a handle on the process record.	*/
					process_record_handle = (OmsT_Pr_Handle) op_prg_list_access (proc_record_handle_list_ptr, 0);
				 
					/* Obtain the module objid for the WLAN MAC module. 		*/
					oms_pr_attr_get (process_record_handle, "module objid", OMSC_PR_OBJID, &mac_module_objid);
				 
					/* Obtain the stream numbers connected to and from the	*/
					/* WLAN MAC layer process.								*/
					oms_tan_neighbor_streams_find (my_objid, mac_module_objid, &instrm_from_mac, &outstrm_to_mac);
				 
					/* Obtain the address handle maintained by the MAC process.	*/
					oms_pr_attr_get (process_record_handle, "address",             OMSC_PR_NUMBER,  &ne_address);
					oms_pr_attr_get (process_record_handle, "auto address handle", OMSC_PR_ADDRESS, &oms_aa_handle);
				 
					/* Set the variable to indicate the MAC address of the	*/
					/* associated MAC layer process.						*/
					mac_address = (int) ne_address;
					}
				
				/* Check if the specified destination address (via the "Destination	*/
				/* Address" attribute) is valid or not.								*/
				if (destination_address != OMSC_AA_AUTO_ASSIGN)
					{
					/* An explicit destination address has been specified. Check if	*/
					/* it is a valid address.										*/
					if (destination_address == (int) mac_address)
						{
						/* Write a log stating that source node can not be a destination. */
						//printf ("\n\nInvalid destination address specification. Changing\n");
						//printf ("the specification from its own MAC address (%d) to \"Random\"\n\n", destination_address);
				
						/* The destination address is set same as the lower layer MAC	*/
						/* address of this node. Ignore the original specification and	*/
						/* and set it to random.										*/
						destination_address = OMSC_AA_AUTO_ASSIGN;
						}
					else
						{
						/* Checks if this is a valid address from the pool of addresses	*/
						/* available.													*/
				
						dest_addr_okay = oms_aa_dest_addr_check (oms_aa_handle, destination_address);
						if (dest_addr_okay != OPC_TRUE)
							{
							/* Write a log stating that source node can not be a destination. */
							printf ("\n\nInvalid destination address specification. Changing\n");
							printf ("the specification from %d, to \"Random\"\n\n", destination_address);
				
							/* The specified destination address is invalid. Set it to	*/
							/* random.													*/
							destination_address = OMSC_AA_AUTO_ASSIGN;
							}
						}
					}
				}
				FSM_PROFILE_SECTION_OUT (aodv_wlan_mac_interface [wait exit execs], state4_exit_exec)


			/** state (wait) transition processing **/
			FSM_TRANSIT_FORCE (1, state1_enter_exec, ;, "default", "", "wait", "idle")
				/*---------------------------------------------------------*/



			/** state (init2) enter executives **/
			FSM_STATE_ENTER_UNFORCED (5, "init2", state5_enter_exec, "aodv_wlan_mac_interface [init2 enter execs]")
				FSM_PROFILE_SECTION_IN (aodv_wlan_mac_interface [init2 enter execs], state5_enter_exec)
				{
				}

				FSM_PROFILE_SECTION_OUT (aodv_wlan_mac_interface [init2 enter execs], state5_enter_exec)

			/** blocking after enter executives of unforced state. **/
			FSM_EXIT (11,"aodv_wlan_mac_interface")


			/** state (init2) exit executives **/
			FSM_STATE_EXIT_UNFORCED (5, "init2", "aodv_wlan_mac_interface [init2 exit execs]")
				FSM_PROFILE_SECTION_IN (aodv_wlan_mac_interface [init2 exit execs], state5_exit_exec)
				{
				/* Schedule a self interrupt to wait for lower layer	*/
				/* Wlan MAC process to finalize the MAC address			*/
				/* registration and resolution.							*/
				op_intrpt_schedule_self (op_sim_time (), 0);
				}
				FSM_PROFILE_SECTION_OUT (aodv_wlan_mac_interface [init2 exit execs], state5_exit_exec)


			/** state (init2) transition processing **/
			FSM_TRANSIT_FORCE (4, state4_enter_exec, ;, "default", "", "init2", "wait")
				/*---------------------------------------------------------*/



			}


		FSM_EXIT (0,"aodv_wlan_mac_interface")
		}
	}




void
aodv_wlan_mac_interface_diag (OP_SIM_CONTEXT_ARG_OPT)
	{
	/* No Diagnostic Block */
	}




void
aodv_wlan_mac_interface_terminate (OP_SIM_CONTEXT_ARG_OPT)
	{

#if !defined (VOSD_NO_FIN)
	int _op_block_origin = __LINE__;
#endif

	FIN_MT (aodv_wlan_mac_interface_terminate ())

	Vos_Poolmem_Dealloc_MT (OP_SIM_CONTEXT_THREAD_INDEX_COMMA pr_state_ptr);

	FOUT
	}


/* Undefine shortcuts to state variables to avoid */
/* syntax error in direct access to fields of */
/* local variable prs_ptr in aodv_wlan_mac_interface_svar function. */
#undef my_objid
#undef my_node_objid
#undef instrm_from_mac
#undef outstrm_to_mac
#undef destination_address
#undef oms_aa_handle
#undef mac_address
#undef wlan_mac_req_iciptr

#undef FIN_PREAMBLE_DEC
#undef FIN_PREAMBLE_CODE

#define FIN_PREAMBLE_DEC
#define FIN_PREAMBLE_CODE

VosT_Obtype
aodv_wlan_mac_interface_init (int * init_block_ptr)
	{

#if !defined (VOSD_NO_FIN)
	int _op_block_origin = 0;
#endif
	VosT_Obtype obtype = OPC_NIL;
	FIN_MT (aodv_wlan_mac_interface_init (init_block_ptr))

	Vos_Define_Object (&obtype, "proc state vars (aodv_wlan_mac_interface)",
		sizeof (aodv_wlan_mac_interface_state), 0, 20);
	*init_block_ptr = 0;

	FRET (obtype)
	}

VosT_Address
aodv_wlan_mac_interface_alloc (VOS_THREAD_INDEX_ARG_COMMA VosT_Obtype obtype, int init_block)
	{

#if !defined (VOSD_NO_FIN)
	int _op_block_origin = 0;
#endif
	aodv_wlan_mac_interface_state * ptr;
	FIN_MT (aodv_wlan_mac_interface_alloc (obtype))

	ptr = (aodv_wlan_mac_interface_state *)Vos_Alloc_Object_MT (VOS_THREAD_INDEX_COMMA obtype);
	if (ptr != OPC_NIL)
		ptr->_op_current_block = init_block;
	FRET ((VosT_Address)ptr)
	}



void
aodv_wlan_mac_interface_svar (void * gen_ptr, const char * var_name, void ** var_p_ptr)
	{
	aodv_wlan_mac_interface_state		*prs_ptr;

	FIN_MT (aodv_wlan_mac_interface_svar (gen_ptr, var_name, var_p_ptr))

	if (var_name == OPC_NIL)
		{
		*var_p_ptr = (void *)OPC_NIL;
		FOUT
		}
	prs_ptr = (aodv_wlan_mac_interface_state *)gen_ptr;

	if (strcmp ("my_objid" , var_name) == 0)
		{
		*var_p_ptr = (void *) (&prs_ptr->my_objid);
		FOUT
		}
	if (strcmp ("my_node_objid" , var_name) == 0)
		{
		*var_p_ptr = (void *) (&prs_ptr->my_node_objid);
		FOUT
		}
	if (strcmp ("instrm_from_mac" , var_name) == 0)
		{
		*var_p_ptr = (void *) (&prs_ptr->instrm_from_mac);
		FOUT
		}
	if (strcmp ("outstrm_to_mac" , var_name) == 0)
		{
		*var_p_ptr = (void *) (&prs_ptr->outstrm_to_mac);
		FOUT
		}
	if (strcmp ("destination_address" , var_name) == 0)
		{
		*var_p_ptr = (void *) (&prs_ptr->destination_address);
		FOUT
		}
	if (strcmp ("oms_aa_handle" , var_name) == 0)
		{
		*var_p_ptr = (void *) (&prs_ptr->oms_aa_handle);
		FOUT
		}
	if (strcmp ("mac_address" , var_name) == 0)
		{
		*var_p_ptr = (void *) (&prs_ptr->mac_address);
		FOUT
		}
	if (strcmp ("wlan_mac_req_iciptr" , var_name) == 0)
		{
		*var_p_ptr = (void *) (&prs_ptr->wlan_mac_req_iciptr);
		FOUT
		}
	*var_p_ptr = (void *)OPC_NIL;

	FOUT
	}

⌨️ 快捷键说明

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