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

📄 init exit execs

📁 opnet无线网络编程
💻
字号:
/* Obtain the process's process handle.					*/
own_prohandle = op_pro_self ();

/* Obtain the values assigned to the various attributes.*/
op_ima_obj_attr_get (my_objid, "Wireless LAN Parameters", &wlan_params_comp_attr_objid);
params_attr_objid = op_topo_child (wlan_params_comp_attr_objid, OPC_OBJTYPE_GENERIC, 0);

/* Obtain the name of the process.						*/
op_ima_obj_attr_get (my_objid, "process model", name_str);

/* Determine the assigned MAC address which will be		*/
/* used for address resolution. Note this is not the	*/
/* final MAC address as there may be static assignments	*/
/* in the network.										*/
op_ima_obj_attr_get (my_objid, "Address", &my_address);

/* Perform auto-addressing for the MAC address. Apart	*/
/* from dynamically addressing, if auto-assigned, the	*/
/* address resolution function also detects duplicate	*/
/* static assignments. The function also initializes 	*/
/* every MAC address as a valid destination.			*/
oms_aa_address_resolve (oms_aa_handle, my_objid, &my_address);

/* Register Wlan MAC process in the model wide registry	*/
own_process_record_handle = (OmsT_Pr_Handle) oms_pr_process_register (my_node_objid, my_objid, own_prohandle, name_str);

/* Initialize the channels of our transmitter and		*/
/* receiver.											*/
wlan_transceiver_channel_init ();

/* Initialize a temp variable for station type (AP/STA).*/
if (ap_flag == OPC_BOOLINT_ENABLED) 
	statype = 1.0;
else 
	statype = 0.0;

/* Initialize a temp variable for pcf_usage.			*/
if (pcf_flag == OPC_BOOLINT_ENABLED) 
	pcf_active = 1.0;
else 
	pcf_active = 0.0;

/* If this station is an access point then it has to be registered as an Access Point.	*/
/* This is because the network will be treated as Infrastructure network once AP is		*/
/* detected.																			*/
if (ap_flag == OPC_BOOLINT_ENABLED)
	{
	/* Allocation of record that stores position information for the AP-- STAs obtain a */
	/* pointer to this record to calculate their distance to the AP for "virtual roam". */
	conn_ap_pos_info_ptr = (WlanT_AP_Position_Info*) op_prg_mem_alloc (sizeof (WlanT_AP_Position_Info));

	/* Access and store node position and transmit power. */
	op_ima_obj_pos_get (my_node_objid, &(conn_ap_pos_info_ptr->lat), &(conn_ap_pos_info_ptr->lon),
		&(conn_ap_pos_info_ptr->alt), &x_pos, &y_pos, &z_pos);
	op_ima_obj_attr_get (params_attr_objid, "Transmit Power", &tx_power);
	conn_ap_pos_info_ptr->tx_power = tx_power;

	/* Save the BSS ID & channel number in this record-- used when the STA switches to another AP */
	conn_ap_pos_info_ptr->ap_bss_id = bss_id;
	conn_ap_pos_info_ptr->ap_channel_num = channel_num;

	oms_pr_attr_set (own_process_record_handle,
		"protocol",				OMSC_PR_STRING,			"mac",
		"mac_type",				OMSC_PR_STRING,			"wireless_lan",
		"subprotocol", 			OMSC_PR_NUMBER,			(double) WLAN_AP,
		"domain_id",			OMSC_PR_NUMBER,			(double) bss_id,
		"PHY_type",				OMSC_PR_NUMBER,			(double) phy_type,
		"subnetid",				OMSC_PR_OBJID,		    my_subnet_objid,
		"ratx_objid",			OMSC_PR_OBJID,			tx_objid,
		"rarx_objid",			OMSC_PR_OBJID,			rx_objid,
		"address",			    OMSC_PR_NUMBER,			(double) my_address,
		"auto address handle",  OMSC_PR_POINTER,  	    oms_aa_handle,
		"position record",  	OMSC_PR_POINTER,  	    conn_ap_pos_info_ptr,
		"PCF active",			OMSC_PR_NUMBER,			pcf_active,
		OPC_NIL);                                       
	}
else
	{
   	oms_pr_attr_set (own_process_record_handle,
		"protocol",				OMSC_PR_STRING,			"mac",
		"mac_type",				OMSC_PR_STRING,			"wireless_lan",
		"subprotocol", 			OMSC_PR_NUMBER,			(double) WLAN_STA,
		"domain_id",			OMSC_PR_NUMBER,		    (double) bss_id,
		"PHY_type",				OMSC_PR_NUMBER,			(double) phy_type,
		"subnetid",				OMSC_PR_OBJID,			my_subnet_objid,
		"ratx_objid",			OMSC_PR_OBJID,			tx_objid,
		"rarx_objid",			OMSC_PR_OBJID,			rx_objid,
		"address",				OMSC_PR_NUMBER,			(double) my_address,
		"auto address handle",	OMSC_PR_POINTER,		oms_aa_handle,
		"PCF active",			OMSC_PR_NUMBER,			pcf_active,
		OPC_NIL);                                       
	}

/* Obtain the MAC layer information for the local MAC	*/
/* process from the model-wide registry.				*/
/* This is to check if the node is a gateway or not.	*/
proc_record_handle_list_ptr = op_prg_list_create ();

oms_pr_process_discover (OPC_OBJID_INVALID, proc_record_handle_list_ptr, 
	"node objid",					OMSC_PR_OBJID,			 my_node_objid,
	"protocol", 					OMSC_PR_STRING, 		 "bridge",
 	 OPC_NIL);

/* If the MAC interface process registered 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 != 0)
	{
	wlan_flags->bridge_flag = OPC_TRUE;
	}

/* If the station is not a bridge only then check for arp	*/
if (wlan_flags->bridge_flag == OPC_FALSE)
	{
	/* Deallocate memory used for process discovery	*/
	while (op_prg_list_size (proc_record_handle_list_ptr))
		{
		op_prg_list_remove (proc_record_handle_list_ptr, OPC_LISTPOS_HEAD);
		}
	op_prg_mem_free (proc_record_handle_list_ptr);

	/* 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,			"arp", 
		OPC_NIL);

	/* If the MAC interface process registered 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.						*/
	wlan_mac_error ("Either zero or several WLAN MAC interface processes found in the node.", OPC_NIL, OPC_NIL);
	}
else
	{
	/*	Obtain a handle on the process record	*/
	process_record_handle = (OmsT_Pr_Handle) op_prg_list_access (proc_record_handle_list_ptr, OPC_LISTPOS_HEAD);

	/* Obtain the module objid for the Wlan MAC Interface module	*/
	oms_pr_attr_get (process_record_handle, "module objid", OMSC_PR_OBJID, &mac_if_module_objid);

	/* Obtain the stream numbers connected to and from the	*/
	/* Wlan MAC Interface layer process						*/
	oms_tan_neighbor_streams_find (my_objid, mac_if_module_objid, &instrm_from_mac_if, &outstrm_to_mac_if);
	}
	
/* Deallocate memory used for process discovery	*/
while (op_prg_list_size (proc_record_handle_list_ptr))
	{
	op_prg_list_remove (proc_record_handle_list_ptr, OPC_LISTPOS_HEAD);
	}

op_prg_mem_free (proc_record_handle_list_ptr);

if (wlan_trace_active)
	{
	/* Cache the state name from which this function was	*/
	/* called.												*/
	strcpy (current_state_name, "init");  
	}

⌨️ 快捷键说明

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