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

📄 aodv_wlan_mac_interface.pr.c

📁 感知无线电有关的仿真
💻 C
📖 第 1 页 / 共 2 页
字号:
						}
					
					}
				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);
				
				}


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


			/** 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, state3_enter_exec, "mac layer arrival", "aodv_wlan_mac_interface () [mac layer arrival enter execs]")
				{
				/* 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");
				}


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


			/** 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, state4_enter_exec, "wait", "aodv_wlan_mac_interface () [wait enter execs]")
				{
				
				}


			/** 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]")
				{
				/* 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;
							}
						}
					}
				}


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



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


			/** 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]")
				{
				/* 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);
				}


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



			}


		FSM_EXIT (0,aodv_wlan_mac_interface)
		}
	}

#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
aodv_wlan_mac_interface_init (void ** gen_state_pptr)
	{
	int _block_origin = 0;
	static VosT_Address	obtype = OPC_NIL;

	FIN (aodv_wlan_mac_interface_init (gen_state_pptr))

	if (obtype == OPC_NIL)
		{
		/* Initialize memory management */
		if (Vos_Catmem_Register ("proc state vars (aodv_wlan_mac_interface)",
			sizeof (aodv_wlan_mac_interface_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 */
		((aodv_wlan_mac_interface_state *)(*gen_state_pptr))->current_block = 0;

		FRET (OPC_COMPCODE_SUCCESS)
		}
	}



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




void
aodv_wlan_mac_interface_terminate (void)
	{
	int _block_origin = __LINE__;

	FIN (aodv_wlan_mac_interface_terminate (void))

	Vos_Catmem_Dealloc (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



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

	FIN (aodv_wlan_mac_interface_svar (gen_ptr, var_name, var_p_ptr))

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

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

	FOUT;
	}

⌨️ 快捷键说明

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