📄 prism2mgmt.c
字号:
/*----------------------------------------------------------------* prism2mgmt_deauthenticate** Send a deauthenticate notification.** Arguments:* wlandev wlan device structure* msgp ptr to msg buffer** Returns: * 0 success and done* <0 success, but we're waiting for something to finish.* >0 an error occurred while handling the message.* Side effects:** Call context:* process thread (usually)* interrupt----------------------------------------------------------------*/int prism2mgmt_deauthenticate(wlandevice_t *wlandev, void *msgp){ int result = 0; hfa384x_t *hw = wlandev->priv; p80211msg_dot11req_deauthenticate_t *msg = msgp; DBFENTER; if (!hw->ap) { /*** STATION ***/ /* TODO: Decide how we're going to handle this one w/ Prism2 */ /* It could be entertaining since Prism2 doesn't have */ /* an explicit way to control this */ msg->resultcode.status = P80211ENUM_msgitem_status_data_ok; msg->resultcode.data = P80211ENUM_resultcode_not_supported; } else { /*** ACCESS POINT ***/ hfa384x_drvr_handover(hw, msg->peerstaaddress.data.data); msg->resultcode.status = P80211ENUM_msgitem_status_data_ok; msg->resultcode.data = P80211ENUM_resultcode_success; } DBFEXIT; return result;}/*----------------------------------------------------------------* prism2mgmt_associate** Associate with an ESS.** Arguments:* wlandev wlan device structure* msgp ptr to msg buffer** Returns: * 0 success and done* <0 success, but we're waiting for something to finish.* >0 an error occurred while handling the message.* Side effects:** Call context:* process thread (usually)* interrupt----------------------------------------------------------------*/int prism2mgmt_associate(wlandevice_t *wlandev, void *msgp){ hfa384x_t *hw = wlandev->priv; int result = 0; p80211msg_dot11req_associate_t *msg = msgp; DBFENTER; if (!hw->ap) { /*** STATION ***/#if 0 /* Set the TxRates */ reg = 0x000f; hfa384x_drvr_setconfig16(hw, HFA384x_RID_TXRATECNTL, reg);#endif /* Set the PortType */ /* ess port */ hfa384x_drvr_setconfig16(hw, HFA384x_RID_CNFPORTTYPE, 1); /* Enable the Port */ hfa384x_drvr_enable(hw, 0); /* Set the resultcode */ msg->resultcode.status = P80211ENUM_msgitem_status_data_ok; msg->resultcode.data = P80211ENUM_resultcode_success; } else { /*** ACCESS POINT ***/ /* Never supported on AP */ msg->resultcode.status = P80211ENUM_msgitem_status_data_ok; msg->resultcode.data = P80211ENUM_resultcode_not_supported; } DBFEXIT; return result;}/*----------------------------------------------------------------* prism2mgmt_reassociate** Renew association because of a BSS change.** Arguments:* wlandev wlan device structure* msgp ptr to msg buffer** Returns: * 0 success and done* <0 success, but we're waiting for something to finish.* >0 an error occurred while handling the message.* Side effects:** Call context:* process thread (usually)* interrupt----------------------------------------------------------------*/int prism2mgmt_reassociate(wlandevice_t *wlandev, void *msgp){ int result = 0; hfa384x_t *hw = wlandev->priv; p80211msg_dot11req_reassociate_t *msg = msgp; DBFENTER; if (!hw->ap) { /*** STATION ***/ /* TODO: Not supported yet...not sure how we're going to do it */ msg->resultcode.status = P80211ENUM_msgitem_status_data_ok; msg->resultcode.data = P80211ENUM_resultcode_not_supported; } else { /*** ACCESS POINT ***/ /* Never supported on AP */ msg->resultcode.status = P80211ENUM_msgitem_status_data_ok; msg->resultcode.data = P80211ENUM_resultcode_not_supported; } DBFEXIT; return result;}/*----------------------------------------------------------------* prism2mgmt_disassociate** Send a disassociation notification.** Arguments:* wlandev wlan device structure* msgp ptr to msg buffer** Returns: * 0 success and done* <0 success, but we're waiting for something to finish.* >0 an error occurred while handling the message.* Side effects:** Call context:* process thread (usually)* interrupt----------------------------------------------------------------*/int prism2mgmt_disassociate(wlandevice_t *wlandev, void *msgp){ int result = 0; hfa384x_t *hw = wlandev->priv; p80211msg_dot11req_disassociate_t *msg = msgp; DBFENTER; if (!hw->ap) { /*** STATION ***/ /* TODO: Not supported yet...not sure how to do it */ msg->resultcode.status = P80211ENUM_msgitem_status_data_ok; msg->resultcode.data = P80211ENUM_resultcode_not_supported; } else { /*** ACCESS POINT ***/ hfa384x_drvr_handover(hw, msg->peerstaaddress.data.data); msg->resultcode.status = P80211ENUM_msgitem_status_data_ok; msg->resultcode.data = P80211ENUM_resultcode_success; } DBFEXIT; return result;}/*----------------------------------------------------------------* prism2mgmt_reset** Reset the MAC and MSD. The p80211 layer has it's own handling* that should be done before and after this function.* Procedure:* - disable system interrupts ??* - disable MAC interrupts* - restore system interrupts* - issue the MAC initialize command * - clear any MSD level state (including timers, queued events,* etc.). Note that if we're removing timer'd/queue events, we may * need to have remained in the system interrupt disabled state.* We should be left in the same state that we're in following* driver initialization.** Arguments:* wlandev wlan device structure* msgp ptr to msg buffer, MAY BE NULL! for a driver local* call.** Returns: * 0 success and done* <0 success, but we're waiting for something to finish.* >0 an error occurred while handling the message.* Side effects:** Call context:* process thread, commonly wlanctl, but might be rmmod/pci_close.----------------------------------------------------------------*/int prism2mgmt_reset(wlandevice_t *wlandev, void *msgp){ int result = 0; hfa384x_t *hw = wlandev->priv; p80211msg_dot11req_reset_t *msg = msgp; DBFENTER; /* * This is supported on both AP and STA and it's not allowed * to fail. */ if ( msgp ) { msg->resultcode.status = P80211ENUM_msgitem_status_data_ok; msg->resultcode.data = P80211ENUM_resultcode_success; WLAN_LOG_INFO("dot11req_reset: the macaddress and " "setdefaultmib arguments are currently unsupported.\n"); } /* * If we got this far, the MSD must be in the MSDRUNNING state * therefore, we must stop and then restart the hw/MAC combo. */ hfa384x_drvr_stop(hw); result = hfa384x_drvr_start(hw); if (result != 0) { WLAN_LOG_ERROR("dot11req_reset: Initialize command failed," " bad things will happen from here.\n"); return 0; } DBFEXIT; return 0;}/*----------------------------------------------------------------* prism2mgmt_start** Start a BSS. Any station can do this for IBSS, only AP for ESS.** Arguments:* wlandev wlan device structure* msgp ptr to msg buffer** Returns: * 0 success and done* <0 success, but we're waiting for something to finish.* >0 an error occurred while handling the message.* Side effects:** Call context:* process thread (usually)* interrupt----------------------------------------------------------------*/int prism2mgmt_start(wlandevice_t *wlandev, void *msgp){ int result = 0; hfa384x_t *hw = wlandev->priv; p80211msg_dot11req_start_t *msg = msgp; p80211pstrd_t *pstr; UINT8 bytebuf[80]; hfa384x_bytestr_t *p2bytestr = (hfa384x_bytestr_t*)bytebuf; hfa384x_PCFInfo_data_t *pcfinfo = (hfa384x_PCFInfo_data_t*)bytebuf; UINT16 word; DBFENTER; wlandev->macmode = WLAN_MACMODE_NONE; /* Set the SSID */ memcpy(&wlandev->ssid, &msg->ssid.data, sizeof(msg->ssid.data)); if (!hw->ap) { /*** ADHOC IBSS ***/ /* see if current f/w is less than 8c3 */ if (HFA384x_FIRMWARE_VERSION(hw->ident_sta_fw.major, hw->ident_sta_fw.minor, hw->ident_sta_fw.variant) < HFA384x_FIRMWARE_VERSION(0,8,3)) { /* Ad-Hoc not quite supported on Prism2 */ msg->resultcode.status = P80211ENUM_msgitem_status_data_ok; msg->resultcode.data = P80211ENUM_resultcode_not_supported; goto done; } msg->resultcode.status = P80211ENUM_msgitem_status_data_ok; /*** STATION ***/ /* Set the REQUIRED config items */ /* SSID */ pstr = (p80211pstrd_t*)&(msg->ssid.data); prism2mgmt_pstr2bytestr(p2bytestr, pstr); result = hfa384x_drvr_setconfig( hw, HFA384x_RID_CNFOWNSSID, bytebuf, HFA384x_RID_CNFOWNSSID_LEN); if ( result ) { WLAN_LOG_ERROR("Failed to set CnfOwnSSID\n"); goto failed; } result = hfa384x_drvr_setconfig( hw, HFA384x_RID_CNFDESIREDSSID, bytebuf, HFA384x_RID_CNFDESIREDSSID_LEN); if ( result ) { WLAN_LOG_ERROR("Failed to set CnfDesiredSSID\n"); goto failed; } /* bsstype - we use the default in the ap firmware */ /* IBSS port */ hfa384x_drvr_setconfig16(hw, HFA384x_RID_CNFPORTTYPE, 0); /* beacon period */ word = msg->beaconperiod.data; result = hfa384x_drvr_setconfig16(hw, HFA384x_RID_CNFAPBCNINT, word); if ( result ) { WLAN_LOG_ERROR("Failed to set beacon period=%d.\n", word); goto failed; } /* dschannel */ word = msg->dschannel.data; result = hfa384x_drvr_setconfig16(hw, HFA384x_RID_CNFOWNCHANNEL, word); if ( result ) { WLAN_LOG_ERROR("Failed to set channel=%d.\n", word); goto failed; } /* Basic rates */ word = p80211rate_to_p2bit(msg->basicrate1.data); if ( msg->basicrate2.status == P80211ENUM_msgitem_status_data_ok ) { word |= p80211rate_to_p2bit(msg->basicrate2.data); } if ( msg->basicrate3.status == P80211ENUM_msgitem_status_data_ok ) { word |= p80211rate_to_p2bit(msg->basicrate3.data); } if ( msg->basicrate4.status == P80211ENUM_msgitem_status_data_ok ) { word |= p80211rate_to_p2bit(msg->basicrate4.data); } if ( msg->basicrate5.status == P80211ENUM_msgitem_status_data_ok ) { word |= p80211rate_to_p2bit(msg->basicrate5.data); } if ( msg->basicrate6.status == P80211ENUM_msgitem_status_data_ok ) { word |= p80211rate_to_p2bit(msg->basicrate6.data); } if ( msg->basicrate7.status == P80211ENUM_msgitem_status_data_ok ) { word |= p80211rate_to_p2bit(msg->basicrate7.data); } if ( msg->basicrate8.status == P80211ENUM_msgitem_status_data_ok ) { word |= p80211rate_to_p2bit(msg->basicrate8.data); } result = hfa384x_drvr_setconfig16(hw, HFA384x_RID_CNFBASICRATES, word); if ( result ) { WLAN_LOG_ERROR("Failed to set basicrates=%d.\n", word); goto failed; } /* Operational rates (supprates and txratecontrol) */ word = p80211rate_to_p2bit(msg->operationalrate1.data); if ( msg->operationalrate2.status == P80211ENUM_msgitem_status_data_ok ) { word |= p80211rate_to_p2bit(msg->operationalrate2.data); } if ( msg->operationalrate3.status == P80211ENUM_msgitem_status_data_ok ) { word |= p80211rate_to_p2bit(msg->operationalrate3.data); } if ( msg->operationalrate4.status == P80211ENUM_msgitem_status_data_ok ) { word |= p80211rate_to_p2bit(msg->operationalrate4.data); } if ( msg->operationalrate5.status == P80211ENUM_msgitem_status_data_ok ) { word |= p80211rate_to_p2bit(msg->operationalrate5.data); } if ( msg->operationalrate6.status == P80211ENUM_msgitem_status_data_ok ) { word |= p80211rate_to_p2bit(msg->operationalrate6.data); } if ( msg->operationalrate7.status == P80211ENUM_msgitem_status_data_ok ) { word |= p80211rate_to_p2bit(msg->operationalrate7.data); } if ( msg->operationalrate8.status == P80211ENUM_msgitem_status_data_ok ) { word |= p80211rate_to_p2bit(msg->operationalrate8.data); } result = hfa384x_drvr_setconfig16(hw, HFA384x_RID_CNFSUPPRATES, word); if ( result ) { WLAN_LOG_ERROR("Failed to set supprates=%d.\n", word); goto failed; } result = hfa384x_drvr_setconfig16(hw, HFA384x_RID_TXRATECNTL, word); if ( result ) { WLAN_LOG_ERROR("Failed to set txrates=%d.\n", word); goto failed; } /* Set the macmode so the frame setup code knows what to do */ if ( msg->bsstype.data == P80211ENUM_bsstype_independent ) { wlandev->macmode = WLAN_MACMODE_IBSS_STA; /* lets extend the data length a bit */ hfa384x_drvr_setconfig16(hw, HFA384x_RID_CNFMAXDATALEN, 2304); } /* Enable the Port */ result = hfa384x_drvr_enable(hw, 0); if ( result ) { WLAN_LOG_ERROR("Enable macport failed, result=%d.\n", result); goto failed; } msg->resultcode.data = P80211ENUM_resultcode_success; goto done; } /*** ACCESS POINT ***/ msg->resultcode.status = P80211ENUM_msgitem_status_data_ok; /* Validate the command, if BSStype=infra is the tertiary loaded? */ if ( msg->bsstype.data == P80211ENUM_bsstype_independent ) { WLAN_LOG_ERROR("AP driver cannot create IBSS.\n"); goto failed; } else if ( hw->cap_sup_sta.id != 5) { WLAN_LOG_ERROR("AP driver failed to detect AP firmware.\n"); goto failed; } /* Set the REQUIRED config items */ /* SSID */
⌨️ 快捷键说明
复制代码
Ctrl + C
搜索代码
Ctrl + F
全屏模式
F11
切换主题
Ctrl + Shift + D
显示快捷键
?
增大字号
Ctrl + =
减小字号
Ctrl + -