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

📄 prism2sta.c

📁 这是基于hfa3841、hfa3842的无线网卡linux驱动程序源代码
💻 C
📖 第 1 页 / 共 5 页
字号:
		 * Block Transmits, Ignore receives of data frames		 */		if(hw->join_ap == 2)		{			hfa384x_JoinRequest_data_t      joinreq;			joinreq = hw->joinreq;			/* Send the join request */			hfa384x_drvr_setconfig( hw, 				HFA384x_RID_JOINREQUEST,				&joinreq, HFA384x_RID_JOINREQUEST_LEN);			WLAN_LOG_INFO("linkstatus=DISCONNECTED (re-submitting join)\n");		}		else		{		  if (wlandev->netdev->type == ARPHRD_ETHER)		    WLAN_LOG_INFO("linkstatus=DISCONNECTED (unhandled)\n");		}		wlandev->macmode = WLAN_MACMODE_NONE;		break;	case HFA384x_LINK_AP_CHANGE:		/* This one indicates that the MAC has decided to and 		 * successfully completed a change to another AP.  We		 * should probably implement a reassociation indication 		 * in response to this one.  I'm thinking that the the 		 * p80211 layer needs to be notified in case of 		 * buffering/queueing issues.  User mode also needs to be		 * notified so that any BSS dependent elements can be 		 * updated.		 * associated state.  We * should send a deauth indication 		 * (implying disassoc) up * to the MLME.		 * Response:		 * Indicate Reassociation		 * Enable Transmits, Receives and pass up data frames		 */		WLAN_LOG_INFO("linkstatus=AP_CHANGE (unhandled)\n");		break;	case HFA384x_LINK_AP_OUTOFRANGE:		/* This one indicates that the MAC has decided that the		 * AP is out of range, but hasn't found a better candidate		 * so the MAC maintains its "associated" state in case		 * we get back in range.  We should block transmits and 		 * receives in this state.  Do we need an indication here?		 * Probably not since a polling user-mode element would 		 * get this status from from p2PortStatus(FD40). What about		 * p80211?		 * Response:		 * Block Transmits, Ignore receives of data frames		 */		WLAN_LOG_INFO("linkstatus=AP_OUTOFRANGE (unhandled)\n");		break;	case HFA384x_LINK_AP_INRANGE:		/* This one indicates that the MAC has decided that the		 * AP is back in range.  We continue working with our 		 * existing association.		 * Response:		 * Enable Transmits, Receives and pass up data frames		 */		WLAN_LOG_INFO("linkstatus=AP_INRANGE (unhandled)\n");		break;	case HFA384x_LINK_ASSOCFAIL:		/* This one is actually a peer to CONNECTED.  We've 		 * requested a join for a given SSID and optionally BSSID.		 * We can use this one to indicate authentication and 		 * association failures.  The trick is going to be 		 * 1) identifying the failure, and 2) state management.		 * Response:		 * Disable Transmits, Ignore receives of data frames		 */		if(hw->join_ap && --hw->join_retries > 0)		{			hfa384x_JoinRequest_data_t      joinreq;			joinreq = hw->joinreq;			/* Send the join request */			hfa384x_drvr_setconfig( hw, 				HFA384x_RID_JOINREQUEST,				&joinreq, HFA384x_RID_JOINREQUEST_LEN);			WLAN_LOG_INFO("linkstatus=ASSOCFAIL (re-submitting join)\n");		}		else		{			WLAN_LOG_INFO("linkstatus=ASSOCFAIL (unhandled)\n");		}		break;	default:		/* This is bad, IO port problems? */		WLAN_LOG_WARNING( 			"unknown linkstatus=0x%02x\n", hw->link_status);		goto failed;		break;	} failed:	DBFEXIT;}/*----------------------------------------------------------------* prism2sta_inf_linkstatus** Handles the receipt of a Link Status 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_linkstatus(wlandevice_t *wlandev, hfa384x_InfFrame_t *inf){        hfa384x_t               *hw = (hfa384x_t *)wlandev->priv;	DBFENTER;	hw->link_status_new = hfa384x2host_16(inf->info.linkstatus.linkstatus);	schedule_work(&hw->link_bh);	DBFEXIT;	return;}/*----------------------------------------------------------------* prism2sta_inf_assocstatus** Handles the receipt of an Association Status info frame. Should * 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_assocstatus(wlandevice_t *wlandev, hfa384x_InfFrame_t *inf){        hfa384x_t               *hw = (hfa384x_t *)wlandev->priv;	hfa384x_AssocStatus_t	rec;	int			i;	DBFENTER;	memcpy(&rec, &inf->info.assocstatus, sizeof(rec));	rec.assocstatus = hfa384x2host_16(rec.assocstatus);	rec.reason      = hfa384x2host_16(rec.reason);	/*	** Find the address in the list of authenticated stations.  If it wasn't	** found, then this address has not been previously authenticated and	** something weird has happened if this is anything other than an	** "authentication failed" message.  If the address was found, then	** set the "associated" flag for that station, based on whether the	** station is associating or losing its association.  Something weird	** has also happened if we find the address in the list of authenticated	** stations but we are getting an "authentication failed" message.	*/	for (i = 0; i < hw->authlist.cnt; i++)		if (memcmp(rec.sta_addr, hw->authlist.addr[i], WLAN_ADDR_LEN) == 0)			break;	if (i >= hw->authlist.cnt) {		if (rec.assocstatus != HFA384x_ASSOCSTATUS_AUTHFAIL)			WLAN_LOG_WARNING("assocstatus info frame received for non-authenticated station.\n");	} else {		hw->authlist.assoc[i] =			(rec.assocstatus == HFA384x_ASSOCSTATUS_STAASSOC ||			 rec.assocstatus == HFA384x_ASSOCSTATUS_REASSOC);		if (rec.assocstatus == HFA384x_ASSOCSTATUS_AUTHFAIL)			WLAN_LOG_WARNING("authfail assocstatus info frame received for authenticated station.\n");	}	DBFEXIT;	return;}/*----------------------------------------------------------------* prism2sta_inf_authreq** Handles the receipt of an Authentication Request info frame. Should * 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_authreq( wlandevice_t *wlandev, hfa384x_InfFrame_t *inf){        hfa384x_t               *hw = (hfa384x_t *)wlandev->priv;	struct sk_buff *skb;		DBFENTER;	skb = dev_alloc_skb(sizeof(*inf));	if (skb) {		skb_put(skb, sizeof(*inf));		memcpy(skb->data, inf, sizeof(*inf));		skb_queue_tail(&hw->authq, skb);		schedule_work(&hw->link_bh);	}			DBFEXIT;}void prism2sta_inf_authreq_defer(wlandevice_t *wlandev, 				 hfa384x_InfFrame_t *inf){        hfa384x_t               *hw = (hfa384x_t *)wlandev->priv;	hfa384x_authenticateStation_data_t  rec;	int    i, added, result, cnt;	UINT8  *addr;	DBFENTER;	/*	** Build the AuthenticateStation record.  Initialize it for denying	** authentication.	*/	memcpy(rec.address, inf->info.authreq.sta_addr, WLAN_ADDR_LEN);	rec.status = P80211ENUM_status_unspec_failure;	/*	** Authenticate based on the access mode.	*/	switch (hw->accessmode) {		case WLAN_ACCESS_NONE:			/*			** Deny all new authentications.  However, if a station			** is ALREADY authenticated, then accept it.			*/			for (i = 0; i < hw->authlist.cnt; i++)				if (memcmp(rec.address, hw->authlist.addr[i],						WLAN_ADDR_LEN) == 0) {					rec.status = P80211ENUM_status_successful;					break;				}			break;		case WLAN_ACCESS_ALL:			/*			** Allow all authentications.			*/			rec.status = P80211ENUM_status_successful;			break;		case WLAN_ACCESS_ALLOW:			/*			** Only allow the authentication if the MAC address			** is in the list of allowed addresses.			**			** Since this is the interrupt handler, we may be here			** while the access list is in the middle of being			** updated.  Choose the list which is currently okay.			** See "prism2mib_priv_accessallow()" for details.			*/			if (hw->allow.modify == 0) {				cnt  = hw->allow.cnt;				addr = hw->allow.addr[0];			} else {				cnt  = hw->allow.cnt1;				addr = hw->allow.addr1[0];			}			for (i = 0; i < cnt; i++, addr += WLAN_ADDR_LEN)				if (memcmp(rec.address, addr, WLAN_ADDR_LEN) == 0) {					rec.status = P80211ENUM_status_successful;					break;				}			break;		case WLAN_ACCESS_DENY:			/*			** Allow the authentication UNLESS the MAC address is			** in the list of denied addresses.			**			** Since this is the interrupt handler, we may be here			** while the access list is in the middle of being			** updated.  Choose the list which is currently okay.			** See "prism2mib_priv_accessdeny()" for details.			*/			if (hw->deny.modify == 0) {				cnt  = hw->deny.cnt;				addr = hw->deny.addr[0];			} else {				cnt  = hw->deny.cnt1;				addr = hw->deny.addr1[0];			}			rec.status = P80211ENUM_status_successful;			for (i = 0; i < cnt; i++, addr += WLAN_ADDR_LEN)				if (memcmp(rec.address, addr, WLAN_ADDR_LEN) == 0) {					rec.status = P80211ENUM_status_unspec_failure;					break;				}			break;	}	/*	** If the authentication is okay, then add the MAC address to the list	** of authenticated stations.  Don't add the address if it is already in	** the list.  (802.11b does not seem to disallow a station from issuing	** an authentication request when the station is already authenticated.	** Does this sort of thing ever happen?  We might as well do the check	** just in case.)	*/	added = 0;	if (rec.status == P80211ENUM_status_successful) {		for (i = 0; i < hw->authlist.cnt; i++)			if (memcmp(rec.address, hw->authlist.addr[i], WLAN_ADDR_LEN) == 0)				break;		if (i >= hw->authlist.cnt) {			if (hw->authlist.cnt >= WLAN_AUTH_MAX) {				rec.status = P80211ENUM_status_ap_full;			} else {				memcpy(hw->authlist.addr[hw->authlist.cnt],					rec.address, WLAN_ADDR_LEN);				hw->authlist.cnt++;				added = 1;			}		}	}	/*	** Send back the results of the authentication.  If this doesn't work,	** then make sure to remove the address from the authenticated list if	** it was added.	*/	rec.status = host2hfa384x_16(rec.status);	rec.algorithm = inf->info.authreq.algorithm;	result = hfa384x_drvr_setconfig(hw, HFA384x_RID_AUTHENTICATESTA,							&rec, sizeof(rec));	if (result) {		if (added) hw->authlist.cnt--;		WLAN_LOG_ERROR("setconfig(authenticatestation) failed, result=%d\n", result);	}	DBFEXIT;	return;}/*----------------------------------------------------------------* prism2sta_inf_psusercnt** Handles the receipt of a PowerSaveUserCount info frame. Should * 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_psusercnt( wlandevice_t *wlandev, hfa384x_InfFrame_t *inf){        hfa384x_t               *hw = (hfa384x_t *)wlandev->priv;	DBFENTER;	hw->psusercount = hfa384x2host_16(inf->info.psusercnt.usercnt);	DBFEXIT;	return;}/*----------------------------------------------------------------* prism2sta_ev_dtim** Handles the DTIM early warning event.** Arguments:*	wlandev		wlan device structure** Returns: *	nothing** Side effects:** Call context:*	interrupt----------------------------------------------------------------*/void prism2sta_ev_dtim(wlandevice_t *wlandev){#if 0        hfa384x_t               *hw = (hfa384x_t *)wlandev->priv;#endif	DBFENTER;	WLAN_LOG_DEBUG(3, "DTIM event, currently unhandled.\n");	DBFEXIT;	return;}/*---------------------

⌨️ 快捷键说明

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