📄 bss_init exit execs
字号:
{
if (op_id_to_type (parent_subnet_objid) != OPC_OBJTYPE_SUBNET_FIX)
roam_state_ptr->enable_roaming = OPC_TRUE;
/* Move to the parent subnet. */
parent_subnet_objid = op_topo_parent (parent_subnet_objid);
}
while (!roam_state_ptr->enable_roaming && parent_subnet_objid != OPC_OBJID_NULL);
}
/* Record the count of the PCF enabled stations. */
/* The beacon interval will be transmitted, only */
/* if there has been a PCF enabled station */
pcf_enabled_stations = poll_list_size;
/* If PCF functionality has been enabled on any of the nodes */
/* if yes, it is required to have an Access Point in the network */
if (pcf_enabled_stations > 0)
{
/* Indicates the type of network (DCF only or PCF and DCF enabled nodes */
/* If pcf_network = 1, network contains either only PCF nodes or combination */
/* If pcf_network = 0, network contains only DCF enabled nodes */
pcf_network = 1;
/* The network has PCF enabled nodes, but no AP. */
if (ap_count == 0)
{
sprintf (msg1,"PCF functionality has been enabled on %d station(s)", pcf_enabled_stations);
wlan_mac_error (msg1,"An Access Point is required in the network to support PCF functionality.",
"Check your network configuration");
}
/* PCF enabled nodes present in the network, but */
/* AP does not support PCF. Raise an error. */
else if (pcf_enabled_on_AP == OPC_FALSE)
{
sprintf (msg1,"PCF functionality has been enabled on %d station(s)", pcf_enabled_stations);
wlan_mac_error (msg1,"The node configured as Access Point does not support PCF functionality.",
"Check your network configuration");
}
}
/* Create polling list, only if the station is an Access Point */
/* and has then PCF functionality enabled */
if ((ap_flag == OPC_BOOLINT_ENABLED) && (pcf_flag == OPC_BOOLINT_ENABLED))
{
/* Since the current station is a AP, exclude this */
/* station from the polling list */
poll_list_size--;
/* Need not allocate memory for the polling list if no nodes in */
/* the network support PCF. Also it is not necessary to create */
/* the polling list for the same case. */
if (poll_list_size > 0)
{
/* Allocate memory for the polling list based on the number of PCF users. */
polling_list = (int *) op_prg_mem_alloc (poll_list_size * sizeof(int));
/* Initialize polling list entries. */
j_cnt = 0;
/* Loop through all the stations in the current subnet */
/* which were shortlisted in the discovery process. */
for (i_cnt = 0; i_cnt < record_handle_list_size; i_cnt++ )
{
/* Obtain a handle to the ith station from the list of processes */
process_record_handle = (OmsT_Pr_Handle) op_prg_list_access (proc_record_handle_list_ptr, i_cnt);
/* Obtain the PCF functionality status */
oms_pr_attr_get (process_record_handle, "PCF active", OMSC_PR_NUMBER, &pcf_active);
/* Check if PCF functionality has been enabled on this station */
if (pcf_active != 0.0)
{
/* Obtain the address of the station */
oms_pr_attr_get (process_record_handle, "address", OMSC_PR_NUMBER, &sta_addr);
/* Check if the address of station selected from the process */
/* registry is not that of the current station */
if (sta_addr != (double) my_address)
{
/* Store the selected station address in the polling list */
polling_list[j_cnt] = (int) sta_addr;
/*Increment the polling list index */
j_cnt++;
}
}
}
/* Sorting has been implemented below to sort and store the */
/* address of stations in the ascending order */
/* Sorting needs to be done only if there are more than one */
/* entry in the polling list */
if (poll_list_size > 1)
{
/* Loop through all the elements in the polling list */
for (i_cnt = 0; i_cnt < poll_list_size; i_cnt++ )
{
/* Store the index of the ith element */
k_cnt = i_cnt;
/* Loop through all the elements from starting from i+1 */
for (j_cnt = (i_cnt + 1); j_cnt < poll_list_size; j_cnt++ )
{
if (polling_list[j_cnt] < polling_list[k_cnt])
k_cnt = j_cnt;
}
address= polling_list[i_cnt];
polling_list[i_cnt] = polling_list[k_cnt];
polling_list[k_cnt] = address;
}
}
}
}
else
poll_list_size = 0;
/* Printing out information to ODB. */
if (wlan_trace_active == OPC_TRUE)
{
sprintf (msg1, "%d stations have been polled by the AP", poll_list_size);
op_prg_odb_print_major (msg1, OPC_NIL);
}
/* 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. */
/* 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,
"gateway node", OMSC_PR_STRING, "gateway",
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->gateway_flag = OPC_TRUE;
}
/* 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);
/* To enable roaming, all APs must send Beacons. */
if ((ap_flag == OPC_BOOLINT_ENABLED) && (beacon_eff_mode == OPC_BOOLINT_DISABLED || pcf_enabled_stations > 0))
{
/* Schedule a self interrupt to kick off the Beacon timer */
/* All terminals need this to set NAV for PCF and other */
/* house keeping functions. */
beacon_evh = op_intrpt_schedule_self (beacon_int, WlanC_Beacon_Tx_Time);
}
/* If the beacon efficiency mode is on, we will scan the best AP based on the distance. */
if (beacon_eff_mode == OPC_BOOLINT_ENABLED)
{
if (roam_state_ptr->enable_roaming == OPC_TRUE)
{
/* Set the scan_type to distance based since beacon efficiency is on. */
roam_state_ptr->scan_type = WlanC_Scan_Type_Distance;
if (op_ima_sim_attr_exists ("WLAN AP Connectivity Check Interval"))
{
op_ima_sim_attr_get (OPC_IMA_DOUBLE, "WLAN AP Connectivity Check Interval", &ap_connectivity_check_interval);
}
else
{
/* Use the default for now and issue a warning. */
ap_connectivity_check_interval = WLANC_CONN_CHK_DIST_INTERVAL;
op_sim_message ("WLAN MAC Roaming", "Cannot access sim attribute \"WLAN AP Connectivity Check Interval\".");
}
ap_connectivity_check_time = ap_connectivity_check_interval;
}
if (ap_flag == OPC_BOOLINT_ENABLED)
{
/* Insert the AP location information in the global list. */
wlan_ap_position_publish ();
}
}
/* Create the mutex that will be used to serialize the accessing of roaming */
/* information between the receiver's power stage and MAC. Since each MAC- */
/* receiver pair will have its own mutex, include the MAC's address in the */
/* name of the mutex. */
sprintf (name_str, "MAC %d Roaming Info Mutex", my_address);
roam_state_ptr->roam_info_mutex = op_prg_mt_mutex_create (OPC_MT_MUTEX_NO_OPTIONS, 0, name_str);
/* Lock the mutex. It will be locked at the beginning of exit execs, and */
/* unlocked at the end of enter execs, of each unforced state excluding the */
/* initialization states. */
op_prg_mt_mutex_lock (roam_state_ptr->roam_info_mutex, 0);
// initialize WSN State Variables (occure after the regular wlan_sv_init() )
wsn_sv_init ();
⌨️ 快捷键说明
复制代码
Ctrl + C
搜索代码
Ctrl + F
全屏模式
F11
切换主题
Ctrl + Shift + D
显示快捷键
?
增大字号
Ctrl + =
减小字号
Ctrl + -