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

📄 prism2mgmt.c

📁 uClinux2.6上兼容PRISM2.0芯片组的USB设备驱动程序.
💻 C
📖 第 1 页 / 共 5 页
字号:
	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 SSID, result=0x%04x\n", result);		goto failed;	}	/* bsstype - we use the default in the ap firmware */	/* 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_TXRATECNTL0, word);	if ( result ) {		WLAN_LOG_ERROR("Failed to set txrates=%d.\n", word);		goto failed;	}	/* ibssatimwindow */	if (msg->ibssatimwindow.status == P80211ENUM_msgitem_status_data_ok) {		WLAN_LOG_INFO("prism2mgmt_start: atimwindow not used in "			       "Infrastructure mode, ignored.\n");	}	/* DTIM period */	word = msg->dtimperiod.data;	result = hfa384x_drvr_setconfig16(hw, HFA384x_RID_CNFOWNDTIMPER, word);	if ( result ) {		WLAN_LOG_ERROR("Failed to set dtim period=%d.\n", word);		goto failed;	}	/* probedelay */	if (msg->probedelay.status == P80211ENUM_msgitem_status_data_ok) {		WLAN_LOG_INFO("prism2mgmt_start: probedelay not "			       "supported in prism2, ignored.\n");	}	/* cfpollable, cfpollreq, cfpperiod, cfpmaxduration */	if (msg->cfpollable.data == P80211ENUM_truth_true && 	    msg->cfpollreq.data == P80211ENUM_truth_true ) {		WLAN_LOG_ERROR("cfpollable=cfpollreq=true is illegal.\n");		result = -1;		goto failed;	}	/* read the PCFInfo and update */	result = hfa384x_drvr_getconfig(hw, HFA384x_RID_CNFAPPCFINFO, 					pcfinfo, HFA384x_RID_CNFAPPCFINFO_LEN);	if ( result ) {		WLAN_LOG_INFO("prism2mgmt_start: read(pcfinfo) failed, "				"assume it's "				"not supported, pcf settings ignored.\n");		goto pcf_skip;	}	if ((msg->cfpollable.data == P80211ENUM_truth_false && 	     msg->cfpollreq.data == P80211ENUM_truth_false) ) {	    	pcfinfo->MediumOccupancyLimit = 0;		pcfinfo->CFPPeriod = 0;		pcfinfo->CFPMaxDuration = 0;		pcfinfo->CFPFlags &= host2hfa384x_16((UINT16)~BIT0);				if ( msg->cfpperiod.status == P80211ENUM_msgitem_status_data_ok ||		     msg->cfpmaxduration.status == P80211ENUM_msgitem_status_data_ok ) {			WLAN_LOG_WARNING(				"Setting cfpperiod or cfpmaxduration when "				"cfpollable and cfreq are false is pointless.\n");		}	}	if ((msg->cfpollable.data == P80211ENUM_truth_true ||	     msg->cfpollreq.data == P80211ENUM_truth_true) ) {		if ( msg->cfpollable.data == P80211ENUM_truth_true) {			pcfinfo->CFPFlags |= host2hfa384x_16((UINT16)BIT0);		}		if ( msg->cfpperiod.status == P80211ENUM_msgitem_status_data_ok) {			pcfinfo->CFPPeriod = msg->cfpperiod.data;			pcfinfo->CFPPeriod = host2hfa384x_16(pcfinfo->CFPPeriod);		}		if ( msg->cfpmaxduration.status == P80211ENUM_msgitem_status_data_ok) {			pcfinfo->CFPMaxDuration = msg->cfpmaxduration.data;			pcfinfo->CFPMaxDuration = host2hfa384x_16(pcfinfo->CFPMaxDuration); 			pcfinfo->MediumOccupancyLimit = pcfinfo->CFPMaxDuration;		}	}	result = hfa384x_drvr_setconfig(hw, HFA384x_RID_CNFAPPCFINFO, 					pcfinfo, HFA384x_RID_CNFAPPCFINFO_LEN);	if ( result ) {		WLAN_LOG_ERROR("write(pcfinfo) failed.\n");		goto failed;	}pcf_skip:	/* Set the macmode so the frame setup code knows what to do */	if ( msg->bsstype.data == P80211ENUM_bsstype_infrastructure ) {		wlandev->macmode = WLAN_MACMODE_ESS_AP;		/* lets extend the data length a bit */		hfa384x_drvr_setconfig16(hw, HFA384x_RID_CNFMAXDATALEN, 2304);	}	/* Set the BSSID to the same as our MAC */	memcpy( wlandev->bssid, wlandev->netdev->dev_addr, WLAN_BSSID_LEN);	/* 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;failed:	WLAN_LOG_DEBUG(1, "Failed to set a config option, result=%d\n", result);	msg->resultcode.data = P80211ENUM_resultcode_invalid_parameters;done:	result = 0;	DBFEXIT;	return result;}/*----------------------------------------------------------------* prism2mgmt_enable** 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_enable(wlandevice_t *wlandev, void *msgp){	int			result = 0;	hfa384x_t		*hw = wlandev->priv;	p80211msg_p2req_enable_t	*msg = msgp;	DBFENTER;	if (!hw->ap) {		/*** STATION ***/		/* Ad-Hoc not quite supported on Prism2 */		msg->resultcode.status = P80211ENUM_msgitem_status_data_ok;		msg->resultcode.data = P80211ENUM_resultcode_not_supported;		goto done;	}	/*** ACCESS POINT ***/	msg->resultcode.status = P80211ENUM_msgitem_status_data_ok;	/* Is the tertiary loaded? */	if ( hw->cap_sup_sta.id != 5) {		WLAN_LOG_ERROR("AP driver failed to detect AP firmware.\n");		goto failed;	}	/* Set the macmode so the frame setup code knows what to do */	wlandev->macmode = WLAN_MACMODE_ESS_AP;	/* Set the BSSID to the same as our MAC */	memcpy( wlandev->bssid, wlandev->netdev->dev_addr, WLAN_BSSID_LEN);	/* 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;failed:	msg->resultcode.data = P80211ENUM_resultcode_invalid_parameters;done:	result = 0;	DBFEXIT;	return result;}/*----------------------------------------------------------------* prism2mgmt_readpda** Collect the PDA data and put it in the message.** 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)----------------------------------------------------------------*/int prism2mgmt_readpda(wlandevice_t *wlandev, void *msgp){	hfa384x_t		*hw = wlandev->priv;	p80211msg_p2req_readpda_t	*msg = msgp;	int				result;	DBFENTER;	/* We only support collecting the PDA when in the FWLOAD	 * state.	 */	if (wlandev->msdstate != WLAN_MSD_FWLOAD) {		WLAN_LOG_ERROR(			"PDA may only be read "			"in the fwload state.\n");		msg->resultcode.data = 			P80211ENUM_resultcode_implementation_failure;		msg->resultcode.status = P80211ENUM_msgitem_status_data_ok;	} else {		/*  Call drvr_readpda(), it handles the auxport enable		 *  and validating the returned PDA.		 */		result = hfa384x_drvr_readpda(			hw, 			msg->pda.data, 			HFA384x_PDA_LEN_MAX);		if (result) {			WLAN_LOG_ERROR(				"hfa384x_drvr_readpda() failed, "				"result=%d\n",				result);						msg->resultcode.data = 				P80211ENUM_resultcode_implementation_failure;			msg->resultcode.status = 				P80211ENUM_msgitem_status_data_ok;			DBFEXIT;			return 0;		}		msg->pda.status = P80211ENUM_msgitem_status_data_ok;		msg->resultcode.data = P80211ENUM_resultcode_success;		msg->resultcode.status = P80211ENUM_msgitem_status_data_ok;	}	DBFEXIT;	return 0;}/*----------------------------------------------------------------* prism2mgmt_readcis** Collect the CIS data and put it in the message.** 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)----------------------------------------------------------------*/int prism2mgmt_readcis(wlandevice_t *wlandev, void *msgp){	int			result;	hfa384x_t		*hw = wlandev->priv;	p80211msg_p2req_readcis_t	*msg = msgp;	DBFENTER;        memset(msg->cis.data, 0, sizeof(msg->cis.data));	result = hfa384x_drvr_getconfig(hw, HFA384x_RID_CIS, 					msg->cis.data, HFA384x_RID_CIS_LEN);	if ( result ) {		WLAN_LOG_INFO("prism2mgmt_readcis: read(cis) failed.\n");		msg->cis.status = P80211ENUM_msgitem_status_no_value;		msg->resultcode.data = P80211ENUM_resultcode_implementation_failure;				}	else {		msg->cis.status = P80211ENUM_msgitem_status_data_ok;		msg->resultcode.data = P80211ENUM_resultcode_success;		}	msg->resultcode.status = P80211ENUM_msgitem_status_data_ok;	DBFEXIT;	return 0;}/*----------------------------------------------------------------* prism2mgmt_auxport_state** Enables/Disables the card's auxiliary port.  Should be called * before and after a sequence of auxport_read()/auxport_write() * calls.** 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)----------------------------------------------------------------*/int prism2mgmt_auxport_state(wlandevice_t *wlandev, void *msgp){	p80211msg_p2req_auxport_state_t	*msg = msgp;#if (WLAN_HOSTIF != WLAN_USB)	hfa384x_t		*hw = wlandev->priv;	DBFENTER;	msg->resultcode.status = P80211ENUM_msgitem_status_data_ok;	if (msg->enable.data == P80211ENUM_truth_true) {		if ( hfa384x_cmd_aux_enable(hw, 0) ) {			msg->resultcode.data = P80211ENUM_resultcode_implementation_failure;		} else {			msg->resultcode.data = P80211ENUM_resultcode_success;		}	} else {		hfa384x_cmd_aux_disable(hw);		msg->resultcode.data = P80211ENUM_resultcode_success;	}#else /* !USB */	DBFENTER;	msg->resultcode.status = P80211ENUM_msgitem_status_data_ok;	msg->resultcode.data = P80211ENUM_resultcode_not_supported;#endif /* WLAN_HOSTIF != WLAN_USB */	DBFEXIT;	return 0;}/*----------------------------------------------------------------* prism2mgmt_auxport_read** Copies data from the card using the auxport.  The auxport must* have previously been enabled.  Note: this is not the way to * do downloads, see the [ram|flash]dl functions.** 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)

⌨️ 快捷键说明

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