prism2mgmt.c

来自「Linux的无线局域网方案是一个Linux设备驱动程序和子系统 一揽子方案的用」· C语言 代码 · 共 2,318 行 · 第 1/5 页

C
2,318
字号
{	int 			result = 0;	prism2sta_priv_t	*priv = wlandev->priv;	hfa384x_t		*hw = priv->hw;	p80211msg_dot11req_deauthenticate_t	*msg = msgp;	DBFENTER;	if (!priv->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){	prism2sta_priv_t	*priv = (prism2sta_priv_t*)wlandev->priv;	hfa384x_t		*hw = priv->hw;	int 			result = 0;	UINT16			port_type;	p80211msg_dot11req_associate_t	*msg = msgp;	DBFENTER;	if (!priv->ap) {		/*** STATION ***/#if 0		/* Set the TxRates */		reg = 0x000f;		hfa384x_drvr_setconfig16(hw, HFA384x_RID_TXRATECNTL, &reg);#endif		/* Set the PortType */		port_type = 1; /* ess port */		hfa384x_drvr_setconfig16(hw, HFA384x_RID_CNFPORTTYPE, &port_type);#if (WLAN_HOSTIF != WLAN_USB)		/* Enable the interrupts */		hfa384x_setreg(hw, 0xffff, HFA384x_EVSTAT);		hfa384x_setreg(hw, 			(HFA384x_INTEN_INFDROP_SET(1) |			 HFA384x_INTEN_INFO_SET(1) |			 HFA384x_INTEN_ALLOC_SET(1) |			 HFA384x_INTEN_TXEXC_SET(1) |			 HFA384x_INTEN_TX_SET(1) |			 HFA384x_INTEN_RX_SET(1)),			HFA384x_INTEN);#endif				/* 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;		priv->state = WLAN_STATE_STARTED;		if (priv->log)			printk(KERN_INFO "%s: %s\n", "wlan-sta", "Station started.\n");	} 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;	prism2sta_priv_t	*priv = (prism2sta_priv_t*)wlandev->priv;	p80211msg_dot11req_reassociate_t	*msg = msgp;	DBFENTER;	if (!priv->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;	prism2sta_priv_t	*priv = wlandev->priv;	hfa384x_t		*hw = priv->hw;	p80211msg_dot11req_disassociate_t	*msg = msgp;	DBFENTER;	if (!priv->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;	prism2sta_priv_t	*priv = (prism2sta_priv_t*)wlandev->priv;	hfa384x_t		*hw = priv->hw;	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_INFO0("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_ERROR0("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;	prism2sta_priv_t	*priv = (prism2sta_priv_t*)wlandev->priv;	hfa384x_t		*hw = priv->hw;	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;	if (!priv->ap) {		/*** ADHOC IBSS ***/		/* see if current f/w is less than 8c3 */		if ( (priv->ident_sta_fw.major == 0 &&			 priv->ident_sta_fw.minor < 8) || // < 0.8			 (priv->ident_sta_fw.major == 0 &&			  priv->ident_sta_fw.minor == 8 &&			  priv->ident_sta_fw.variant < 3) ) {	// < 0.83		  	/* 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_ERROR0("Failed to set SSID\n");			goto failed;		}		/* bsstype - we use the default in the ap firmware */		word = 0; /* IBSS port */		hfa384x_drvr_setconfig16(hw, HFA384x_RID_CNFPORTTYPE, &word);		/* beacon period */		word = msg->beaconperiod.data;		result = hfa384x_drvr_setconfig16(hw, HFA384x_RID_CNFAPBCNINT, &word);		if ( result ) {			WLAN_LOG_ERROR1("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_ERROR1("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_ERROR1("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_ERROR1("Failed to set supprates=%d.\n", word);			goto failed;		} 		result = hfa384x_drvr_setconfig16(hw, HFA384x_RID_TXRATECNTL, &word);		if ( result ) {			WLAN_LOG_ERROR1("Failed to set txrates=%d.\n", word);			goto failed;		}#if (WLAN_HOSTIF != WLAN_USB)		/* Enable the interrupts */		word = HFA384x_INTEN_INFDROP_SET(1) |			HFA384x_INTEN_INFO_SET(1) |			HFA384x_INTEN_ALLOC_SET(1) |			HFA384x_INTEN_TXEXC_SET(1) |			HFA384x_INTEN_DTIM_SET(1) |			HFA384x_INTEN_TX_SET(1) |			HFA384x_INTEN_RX_SET(1);		hfa384x_setreg(hw, 0x0, HFA384x_EVSTAT);		hfa384x_setreg(hw, 0xffff, HFA384x_EVACK);		hfa384x_setreg(hw, word, HFA384x_INTEN);#endif		/* 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;			word=2304;  /* lets extend the data length a bit */			hfa384x_drvr_setconfig16(hw, HFA384x_RID_CNFMAXDATALEN, &word);		}		/* Enable the Port */		result = hfa384x_drvr_enable(hw, 0);		if ( result ) {			WLAN_LOG_ERROR1("Enable macport failed, result=%d.\n", result);			goto failed;		}			msg->resultcode.data = P80211ENUM_resultcode_success;		priv->state = WLAN_STATE_STARTED;		if (priv->log)			printk(KERN_INFO "wlan-sta: IBSS started.\n");		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_ERROR0("AP driver cannot create IBSS.\n");		goto failed;	} else if ( priv->cap_sup_sta.id != 5) {		WLAN_LOG_ERROR0("AP driver failed to detect AP firmware.\n");		goto failed;	}	/* Set the REQUIRED config items */	/* SSID */

⌨️ 快捷键说明

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