📄 jigb_wlan_support.ex.c
字号:
wlan_mac_pk_dhstruct_destroy (WlanT_Data_Header_Fields* pk_dhstruct_ptr)
{
/** Deallocate the packet structure memory. **/
FIN (wlan_mac_pk_dhstruct_destroy (pk_dhstruct_ptr));
/* Destroy frame control field structure */
op_prg_mem_free (pk_dhstruct_ptr);
FOUT;
}
void
wlan_mac_pk_chstruct_destroy (WlanT_Control_Header_Fields* pk_chstruct_ptr)
{
/* Deallocate the packet structure memory. */
FIN (wlan_mac_pk_chstruct_destroy (pk_chstruct_ptr));
/* Destroy frame control field structure */
op_prg_mem_free (pk_chstruct_ptr);
FOUT;
}
void
wlan_mac_pk_rhstruct_destroy (WlanT_Req_Header_Fields* pk_rhstruct_ptr)
{
/* Deallocate the packet structure memory. */
FIN (wlan_mac_pk_rhstruct_destroy (pk_rhstruct_ptr));
/* Destroy frame control field structure */
op_prg_mem_free (pk_rhstruct_ptr);
FOUT;
}
void
wlan_mac_pk_bbstruct_destroy (WlanT_Beacon_Body_Fields* pk_bbstruct_ptr)
{
/** Deallocate the packet structure memory. **/
FIN (wlan_mac_pk_bbstruct_destroy (pk_bbstruct_ptr));
/* Destroy frame control field structure */
op_prg_mem_free (pk_bbstruct_ptr);
FOUT;
}
void
wlan_mac_pk_data_header_pkprint (void* structure_ptr, PrgT_List* output_list)
{
char temp_str[128];
char* alloc_str;
WlanT_Data_Header_Fields* pk_dh_ptr;
/** Called as part of a packet print, this procedure will **/
/** place the contents of the "fields" structure into a **/
/** printed list. **/
FIN (wlan_mac_pk_data_header_pkprint (structure_ptr, output_list));
pk_dh_ptr = (WlanT_Data_Header_Fields *) structure_ptr;
sprintf(temp_str, " more_frag int %-16d(1)", pk_dh_ptr->more_frag);
PKPRINT_STRING_INSERT (alloc_str, temp_str, output_list)
sprintf(temp_str, " retry int %-16d(1)", pk_dh_ptr->retry);
PKPRINT_STRING_INSERT (alloc_str, temp_str, output_list)
sprintf(temp_str, " order int %-16d(1)", pk_dh_ptr->order);
PKPRINT_STRING_INSERT (alloc_str, temp_str, output_list)
sprintf(temp_str, " tods int %-16d(1)", pk_dh_ptr->tods);
PKPRINT_STRING_INSERT (alloc_str, temp_str, output_list)
sprintf(temp_str, " fromds int %-16d(1)", pk_dh_ptr->fromds);
PKPRINT_STRING_INSERT (alloc_str, temp_str, output_list)
sprintf(temp_str, " duration double %-16.6f(16)", pk_dh_ptr->duration);
PKPRINT_STRING_INSERT (alloc_str, temp_str, output_list)
sprintf(temp_str, " address1 int %-16d(48)", pk_dh_ptr->address1);
PKPRINT_STRING_INSERT (alloc_str, temp_str, output_list)
sprintf(temp_str, " address2 int %-16d(48)", pk_dh_ptr->address2);
PKPRINT_STRING_INSERT (alloc_str, temp_str, output_list)
sprintf(temp_str, " address3 int %-16d(48)", pk_dh_ptr->address3);
PKPRINT_STRING_INSERT (alloc_str, temp_str, output_list)
sprintf(temp_str, " fragment_number int %-16d(32)", pk_dh_ptr->fragment_number);
PKPRINT_STRING_INSERT (alloc_str, temp_str, output_list)
sprintf(temp_str, " sequence_number int %-16d(96)", pk_dh_ptr->sequence_number);
PKPRINT_STRING_INSERT (alloc_str, temp_str, output_list)
sprintf(temp_str, " address4 (omitted) int %-16d(0)", pk_dh_ptr->address4);
PKPRINT_STRING_INSERT (alloc_str, temp_str, output_list)
sprintf(temp_str, " more_data int %-16d(1)", pk_dh_ptr->more_data);
PKPRINT_STRING_INSERT (alloc_str, temp_str, output_list)
FOUT;
}
void
wlan_mac_pk_control_header_pkprint (void* structure_ptr, PrgT_List* output_list)
{
char temp_str[128];
char* alloc_str;
WlanT_Control_Header_Fields* pk_ch_ptr;
/** Called as part of a packet print, this procedure will **/
/** place the contents of the "fields" structure into a **/
/** printed list. **/
FIN (wlan_mac_pk_control_header_pkprint (structure_ptr, output_list));
pk_ch_ptr = (WlanT_Control_Header_Fields* ) structure_ptr;
sprintf(temp_str, " more_frag int %-16d(1)", pk_ch_ptr->more_frag);
PKPRINT_STRING_INSERT (alloc_str, temp_str, output_list)
sprintf(temp_str, " retry int %-16d(1)", pk_ch_ptr->retry);
PKPRINT_STRING_INSERT (alloc_str, temp_str, output_list)
sprintf(temp_str, " order int %-16d(1)", pk_ch_ptr->order);
PKPRINT_STRING_INSERT (alloc_str, temp_str, output_list)
sprintf(temp_str, " duration double %-16.6f(16)", pk_ch_ptr->duration);
PKPRINT_STRING_INSERT (alloc_str, temp_str, output_list)
sprintf(temp_str, " rx_addr int %-16d(48)", pk_ch_ptr->rx_addr);
PKPRINT_STRING_INSERT (alloc_str, temp_str, output_list)
sprintf(temp_str, " tx_addr int %-16d(48)", pk_ch_ptr->tx_addr);
PKPRINT_STRING_INSERT (alloc_str, temp_str, output_list)
FOUT;
}
void
wlan_mac_pk_req_header_pkprint (void* structure_ptr, PrgT_List* output_list)
{
char temp_str[128];
char* alloc_str;
WlanT_Req_Header_Fields* pk_rh_ptr;
/** Called as part of a packet print, this procedure will **/
/** place the contents of the "fields" structure into a **/
/** printed list. **/
FIN (wlan_mac_pk_req_header_pkprint (structure_ptr, output_list));
pk_rh_ptr = (WlanT_Req_Header_Fields* ) structure_ptr;
sprintf(temp_str, " more_frag int %-16d(1)", pk_rh_ptr->more_frag);
PKPRINT_STRING_INSERT (alloc_str, temp_str, output_list)
sprintf(temp_str, " retry int %-16d(1)", pk_rh_ptr->retry);
PKPRINT_STRING_INSERT (alloc_str, temp_str, output_list)
sprintf(temp_str, " order int %-16d(1)", pk_rh_ptr->order);
PKPRINT_STRING_INSERT (alloc_str, temp_str, output_list)
sprintf(temp_str, " duration double %-16.6f(16)", pk_rh_ptr->duration);
PKPRINT_STRING_INSERT (alloc_str, temp_str, output_list)
sprintf(temp_str, " rx_addr int %-16d(48)", pk_rh_ptr->rx_addr);
PKPRINT_STRING_INSERT (alloc_str, temp_str, output_list)
sprintf(temp_str, " tx_addr int %-16d(48)", pk_rh_ptr->tx_addr);
PKPRINT_STRING_INSERT (alloc_str, temp_str, output_list)
sprintf(temp_str, " P int %-16d(3)", pk_rh_ptr->P);
PKPRINT_STRING_INSERT (alloc_str, temp_str, output_list)
sprintf(temp_str, " Lm int %-16d(16)", pk_rh_ptr->Lm);
PKPRINT_STRING_INSERT (alloc_str, temp_str, output_list)
sprintf(temp_str, " lm int %-16d(16)", pk_rh_ptr->lm);
PKPRINT_STRING_INSERT (alloc_str, temp_str, output_list)
sprintf(temp_str, " Nm int %-16d(16)", pk_rh_ptr->Nm);
PKPRINT_STRING_INSERT (alloc_str, temp_str, output_list)
sprintf(temp_str, " flagm int %-16d(2)", pk_rh_ptr->flagm);
PKPRINT_STRING_INSERT (alloc_str, temp_str, output_list)
FOUT;
}
void
wlan_mac_pk_beacon_body_pkprint (void* structure_ptr, Prg_List* output_list)
{
char temp_str[128];
char* alloc_str;
WlanT_Beacon_Body_Fields* pk_bb_ptr;
/** Called as part of a packet print, this procedure will **/
/** place the contents of the "fields" structure into a **/
/** printed list. **/
FIN (wlan_mac_pk_beacon_body_pkprint (structure_ptr, output_list));
pk_bb_ptr = (WlanT_Beacon_Body_Fields* ) structure_ptr;
sprintf(temp_str, " timestamp double %-16.6f(16)", pk_bb_ptr->timestamp);
PKPRINT_STRING_INSERT (alloc_str, temp_str, output_list)
sprintf(temp_str, " beacon interval double %-16.6f(16)", pk_bb_ptr->beacon_intv);
PKPRINT_STRING_INSERT (alloc_str, temp_str, output_list)
sprintf(temp_str, " CFP count int %-16d(1)", pk_bb_ptr->cf_par.cfp_count);
PKPRINT_STRING_INSERT (alloc_str, temp_str, output_list)
sprintf(temp_str, " CFP period int %-16d(1)", pk_bb_ptr->cf_par.cfp_period);
PKPRINT_STRING_INSERT (alloc_str, temp_str, output_list)
sprintf(temp_str, " CFP Max Duration double %-16.6f(16)", pk_bb_ptr->cf_par.cfp_maxduration);
PKPRINT_STRING_INSERT (alloc_str, temp_str, output_list)
sprintf(temp_str, " CFP Duration Remaining double %-16.6f(16)", pk_bb_ptr->cf_par.cfp_durremaining);
PKPRINT_STRING_INSERT (alloc_str, temp_str, output_list)
FOUT;
}
void
wlan_ap_reliability_eval (Packet *beacon_pkptr, int accepted, WlanT_Roam_State_Info *roam_state_ptr)
{
WlanT_Data_Header_Fields* pk_dhstruct_ptr;
Objid tx_ch_objid;
/** Evaluate the reliability of the AP from which a Beacon has been received **/
/** The evaluation criteria depends on whether the STA is currently connected **/
/** to the AP or not. **/
FIN (wlan_ap_reliability_eval (Packet *beacon_pkptr, int accepted, WlanT_Roam_State_Info *roam_state_ptr));
/* Skip if distance based scan is used. */
if (roam_state_ptr->scan_type == WlanC_Scan_Type_Distance)
{
FOUT;
}
/* If the STA is connected to an AP (it is not in scan mode), then the criteria */
/* for evaluating the whether the connection still exists is the weighted prob. */
/* of Beacon reception. */
if (roam_state_ptr->scan_mode == OPC_FALSE)
{
/* See if this is a Beacon coming from the current AP. In the Beacon */
/* frames, the "address3" field of the frame header contains the BSS ID of */
/* the sending Access Point. */
op_pk_nfd_access (beacon_pkptr, "Wlan Header", &pk_dhstruct_ptr);
if (roam_state_ptr->current_bss_id != pk_dhstruct_ptr->address3)
{
FOUT;
}
/* Update the reliability figure based on the status of the Beacon. */
if (accepted)
{
roam_state_ptr->ap_reliability = WLANC_AP_RELIABILITY_COEFF * roam_state_ptr->ap_reliability + (1 - WLANC_AP_RELIABILITY_COEFF);
}
else
{
roam_state_ptr->ap_reliability = WLANC_AP_RELIABILITY_COEFF * roam_state_ptr->ap_reliability;
}
/* If the reliability drops below a threshold, the STA will start scanning */
/* for a new AP. */
if (roam_state_ptr->ap_reliability < WLANC_AP_SCAN_START_THRESHOLD)
{
roam_state_ptr->scan_mode = OPC_TRUE;
}
}
else
{
/* If the STA is in scan mode, then it is not connected to any AP. In this */
/* case, the criteria for an AP to be acceptable is that all Beacons in the */
/* scan period are received without error. */
if (roam_state_ptr->ap_reliability == WLANC_AP_RELIABILITY_UNKNOWN)
{
if (accepted)
{
/* This is first accepted Beacon in this scan period. Record the */
/* ch_id for next Beacon. */
roam_state_ptr->ap_reliability = WLANC_AP_UNRELIABLE;
roam_state_ptr->last_accepted_ap_ch_objid = op_td_get_int (beacon_pkptr, OPC_TDA_RA_TX_CH_OBJID);
}
}
else
{
/* Second time around. */
if (accepted)
{
tx_ch_objid = op_td_get_int (beacon_pkptr, OPC_TDA_RA_TX_CH_OBJID);
if (tx_ch_objid == roam_state_ptr->last_accepted_ap_ch_objid)
{
/* Second packet is also good. */
roam_state_ptr->ap_reliability = WLANC_AP_RELIABLE;
}
}
}
}
FOUT;
}
⌨️ 快捷键说明
复制代码
Ctrl + C
搜索代码
Ctrl + F
全屏模式
F11
切换主题
Ctrl + Shift + D
显示快捷键
?
增大字号
Ctrl + =
减小字号
Ctrl + -