📄 prism2sta.c
字号:
} else { WLAN_LOG_ERROR("Failed to retrieve Prism2 Card SN\n"); goto failed; } /* Collect the MAC address */ result = hfa384x_drvr_getconfig(hw, HFA384x_RID_CNFOWNMACADDR, wlandev->netdev->dev_addr, WLAN_ADDR_LEN); if ( result != 0 ) { WLAN_LOG_ERROR("Failed to retrieve mac address\n"); goto failed; } /* short preamble is always implemented */ wlandev->nsdcaps |= P80211_NSDCAP_SHORT_PREAMBLE; /* find out if hardware wep is implemented */ hfa384x_drvr_getconfig16(hw, HFA384x_RID_PRIVACYOPTIMP, &temp); if (temp) wlandev->nsdcaps |= P80211_NSDCAP_HARDWAREWEP; /* Only enable scan by default on newer firmware */ if (HFA384x_FIRMWARE_VERSION(hw->ident_sta_fw.major, hw->ident_sta_fw.minor, hw->ident_sta_fw.variant) < HFA384x_FIRMWARE_VERSION(1,5,5)) { wlandev->nsdcaps |= P80211_NSDCAP_NOSCAN; } /* TODO: Set any internally managed config items */ goto done;failed: WLAN_LOG_ERROR("Failed, result=%d\n", result);done: DBFEXIT; return result;}/*----------------------------------------------------------------* prism2sta_globalsetup** Set any global RIDs that we want to set at device activation.** Arguments:* wlandev wlan device structure** Returns: * 0 success* >0 f/w reported error* <0 driver reported error** Side effects:** Call context:* process thread----------------------------------------------------------------*/int prism2sta_globalsetup(wlandevice_t *wlandev){ hfa384x_t *hw = (hfa384x_t *)wlandev->priv; /* Set the maximum frame size */ return hfa384x_drvr_setconfig16(hw, HFA384x_RID_CNFMAXDATALEN, WLAN_DATA_MAXLEN);}int prism2sta_setmulticast(wlandevice_t *wlandev, netdevice_t *dev){ int result = 0; hfa384x_t *hw = (hfa384x_t *)wlandev->priv; UINT16 promisc; DBFENTER; /* If we're not ready, what's the point? */ if ( hw->state != HFA384x_STATE_RUNNING ) goto exit; /* If we're an AP, do nothing here */ if (hw->ap) goto exit; if ( (dev->flags & (IFF_PROMISC | IFF_ALLMULTI)) != 0 ) promisc = P80211ENUM_truth_true; else promisc = P80211ENUM_truth_false; result = hfa384x_drvr_setconfig16_async( hw, HFA384x_RID_PROMISCMODE, promisc); /* XXX TODO: configure the multicast list */ // CLEAR_HW_MULTICAST_LIST // struct dev_mc_list element = dev->mc_list; // while (element != null) { // HW_ADD_MULTICAST_ADDR(element->dmi_addr, dmi_addrlen) // element = element->next; // } exit: DBFEXIT; return result;}/*----------------------------------------------------------------* prism2sta_inf_handover** Handles the receipt of a Handover info frame. Should only be present* in APs only.** Arguments:* wlandev wlan device structure* inf ptr to info frame (contents in hfa384x order)** Returns: * nothing** Side effects:** Call context:* interrupt----------------------------------------------------------------*/void prism2sta_inf_handover(wlandevice_t *wlandev, hfa384x_InfFrame_t *inf){ DBFENTER; WLAN_LOG_DEBUG(2,"received infoframe:HANDOVER (unhandled)\n"); DBFEXIT; return;}/*----------------------------------------------------------------* prism2sta_inf_tallies** Handles the receipt of a CommTallies info frame. ** Arguments:* wlandev wlan device structure* inf ptr to info frame (contents in hfa384x order)** Returns: * nothing** Side effects:** Call context:* interrupt----------------------------------------------------------------*/void prism2sta_inf_tallies(wlandevice_t *wlandev, hfa384x_InfFrame_t *inf){ hfa384x_t *hw = (hfa384x_t *)wlandev->priv; UINT16 *src16; UINT32 *dst; UINT32 *src32; int i; int cnt; DBFENTER; /* ** Determine if these are 16-bit or 32-bit tallies, based on the ** record length of the info record. */ cnt = sizeof(hfa384x_CommTallies32_t) / sizeof(UINT32); if (inf->framelen > 22) { dst = (UINT32 *) &hw->tallies; src32 = (UINT32 *) &inf->info.commtallies32; for (i = 0; i < cnt; i++, dst++, src32++) *dst += hfa384x2host_32(*src32); } else { dst = (UINT32 *) &hw->tallies; src16 = (UINT16 *) &inf->info.commtallies16; for (i = 0; i < cnt; i++, dst++, src16++) *dst += hfa384x2host_16(*src16); } DBFEXIT; return;}/*----------------------------------------------------------------* prism2sta_inf_scanresults** Handles the receipt of a Scan Results info frame.** Arguments:* wlandev wlan device structure* inf ptr to info frame (contents in hfa384x order)** Returns: * nothing** Side effects:** Call context:* interrupt----------------------------------------------------------------*/void prism2sta_inf_scanresults(wlandevice_t *wlandev, hfa384x_InfFrame_t *inf){ hfa384x_t *hw = (hfa384x_t *)wlandev->priv; int nbss; hfa384x_ScanResult_t *sr = &(inf->info.scanresult); int i; hfa384x_JoinRequest_data_t joinreq; int result; DBFENTER; /* Get the number of results, first in bytes, then in results */ nbss = (inf->framelen * sizeof(UINT16)) - sizeof(inf->infotype) - sizeof(inf->info.scanresult.scanreason); nbss /= sizeof(hfa384x_ScanResultSub_t); /* Print em */ WLAN_LOG_DEBUG(1,"rx scanresults, reason=%d, nbss=%d:\n", inf->info.scanresult.scanreason, nbss); for ( i = 0; i < nbss; i++) { WLAN_LOG_DEBUG(1, "chid=%d anl=%d sl=%d bcnint=%d\n", sr->result[i].chid, sr->result[i].anl, sr->result[i].sl, sr->result[i].bcnint); WLAN_LOG_DEBUG(1, " capinfo=0x%04x proberesp_rate=%d\n", sr->result[i].capinfo, sr->result[i].proberesp_rate); } /* issue a join request */ joinreq.channel = sr->result[0].chid; memcpy( joinreq.bssid, sr->result[0].bssid, WLAN_BSSID_LEN); result = hfa384x_drvr_setconfig( hw, HFA384x_RID_JOINREQUEST, &joinreq, HFA384x_RID_JOINREQUEST_LEN); if (result) { WLAN_LOG_ERROR("setconfig(joinreq) failed, result=%d\n", result); } DBFEXIT; return;}/*----------------------------------------------------------------* prism2sta_inf_hostscanresults** Handles the receipt of a Scan Results info frame.** Arguments:* wlandev wlan device structure* inf ptr to info frame (contents in hfa384x order)** Returns: * nothing** Side effects:** Call context:* interrupt----------------------------------------------------------------*/void prism2sta_inf_hostscanresults(wlandevice_t *wlandev, hfa384x_InfFrame_t *inf){ hfa384x_t *hw = (hfa384x_t *)wlandev->priv; int nbss; DBFENTER; nbss = (inf->framelen - 3) / 32; WLAN_LOG_DEBUG(2, "Received %d hostscan results\n", nbss); if (hw->scanresults) kfree(hw->scanresults); hw->scanresults = kmalloc(sizeof(hfa384x_InfFrame_t), GFP_ATOMIC); memcpy(hw->scanresults, inf, sizeof(hfa384x_InfFrame_t)); if (nbss == 0) nbss = -1; /* Notify/wake the sleeping caller. */ hw->scanflag = nbss; wake_up_interruptible(&hw->cmdq); DBFEXIT;};/*----------------------------------------------------------------* prism2sta_inf_chinforesults** Handles the receipt of a Channel Info Results info frame.** Arguments:* wlandev wlan device structure* inf ptr to info frame (contents in hfa384x order)** Returns: * nothing** Side effects:** Call context:* interrupt----------------------------------------------------------------*/void prism2sta_inf_chinforesults(wlandevice_t *wlandev, hfa384x_InfFrame_t *inf){ hfa384x_t *hw = (hfa384x_t *)wlandev->priv; unsigned int i, n; DBFENTER; hw->channel_info.results.scanchannels = hfa384x2host_16(inf->info.chinforesult.scanchannels);#if 0 memcpy(&inf->info.chinforesult, &hw->channel_info.results, sizeof(hfa384x_ChInfoResult_t));#endif for (i=0, n=0; i<HFA384x_CHINFORESULT_MAX; i++) { if (hw->channel_info.results.scanchannels & (1<<i)) { int channel=hfa384x2host_16(inf->info.chinforesult.result[n].chid)-1; hfa384x_ChInfoResultSub_t *chinforesult=&hw->channel_info.results.result[channel]; chinforesult->chid = channel; chinforesult->anl = hfa384x2host_16(inf->info.chinforesult.result[n].anl); chinforesult->pnl = hfa384x2host_16(inf->info.chinforesult.result[n].pnl); chinforesult->active = hfa384x2host_16(inf->info.chinforesult.result[n].active); WLAN_LOG_DEBUG(2, "chinfo: channel %d, %s level (avg/peak)=%d/%d dB, pcf %d\n", channel+1, chinforesult->active & HFA384x_CHINFORESULT_BSSACTIVE ? "signal" : "noise", chinforesult->anl, chinforesult->pnl, chinforesult->active & HFA384x_CHINFORESULT_PCFACTIVE ? 1 : 0 ); n++; } } atomic_set(&hw->channel_info.done, 2); hw->channel_info.count = n; DBFEXIT; return;}void prism2sta_processing_defer(void *data){ hfa384x_t *hw = (hfa384x_t *) data; wlandevice_t *wlandev = hw->wlandev; hfa384x_bytestr32_t ssid; DBFENTER; /* First let's process the auth frames */ { struct sk_buff *skb; hfa384x_InfFrame_t *inf; while ( (skb = skb_dequeue(&hw->authq)) ) { inf = (hfa384x_InfFrame_t *) skb->data; prism2sta_inf_authreq_defer(wlandev, inf); } } /* Now let's handle the linkstatus stuff */ if (hw->link_status == hw->link_status_new) goto failed; hw->link_status = hw->link_status_new; switch(hw->link_status) { case HFA384x_LINK_NOTCONNECTED: /* I'm currently assuming that this is the initial link * state. It should only be possible immediately * following an Enable command. * Response: * Block Transmits, Ignore receives of data frames */ WLAN_LOG_INFO("linkstatus=NOTCONNECTED (unhandled)\n"); break; case HFA384x_LINK_CONNECTED: /* This one indicates a successful scan/join/auth/assoc. * When we have the full MLME complement, this event will * signify successful completion of both mlme_authenticate * and mlme_associate. State management will get a little * ugly here. * Response: * Indicate authentication and/or association * Enable Transmits, Receives and pass up data frames */ /* If we are joining a specific AP, set our state and reset retries */ if(hw->join_ap == 1) hw->join_ap = 2; hw->join_retries = 60; /* Don't call this in monitor mode */ if ( wlandev->netdev->type == ARPHRD_ETHER ) { UINT16 portstatus; int result; WLAN_LOG_INFO("linkstatus=CONNECTED\n"); /* For non-usb devices, we can use the sync versions */ /* Collect the BSSID, and set state to allow tx */ result = hfa384x_drvr_getconfig(hw, HFA384x_RID_CURRENTBSSID, wlandev->bssid, WLAN_BSSID_LEN); if ( result ) { WLAN_LOG_DEBUG(1, "getconfig(0x%02x) failed, result = %d\n", HFA384x_RID_CURRENTBSSID, result); goto failed; } result = hfa384x_drvr_getconfig(hw, HFA384x_RID_CURRENTSSID, &ssid, sizeof(ssid)); if ( result ) { WLAN_LOG_DEBUG(1, "getconfig(0x%02x) failed, result = %d\n", HFA384x_RID_CURRENTSSID, result); goto failed; } prism2mgmt_bytestr2pstr((hfa384x_bytestr_t *)&ssid, (p80211pstrd_t *) &wlandev->ssid); /* Collect the port status */ result = hfa384x_drvr_getconfig16(hw, HFA384x_RID_PORTSTATUS, &portstatus); if ( result ) { WLAN_LOG_DEBUG(1, "getconfig(0x%02x) failed, result = %d\n", HFA384x_RID_PORTSTATUS, result); goto failed; } portstatus = hfa384x2host_16(portstatus); wlandev->macmode = (portstatus == HFA384x_PSTATUS_CONN_IBSS) ? WLAN_MACMODE_IBSS_STA : WLAN_MACMODE_ESS_STA; } break; case HFA384x_LINK_DISCONNECTED: /* This one indicates that our association is gone. We've * lost connection with the AP and/or been disassociated. * This indicates that the MAC has completely cleared it's * associated state. We * should send a deauth indication * (implying disassoc) up * to the MLME. * Response: * Indicate Deauthentication
⌨️ 快捷键说明
复制代码
Ctrl + C
搜索代码
Ctrl + F
全屏模式
F11
切换主题
Ctrl + Shift + D
显示快捷键
?
增大字号
Ctrl + =
减小字号
Ctrl + -