prism2mgmt.c

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

C
2,318
字号
			"in the fwload state.\n");		msg->resultcode.data = 			P80211ENUM_resultcode_implementation_failure;		msg->resultcode.status = P80211ENUM_msgitem_status_data_ok;		DBFEXIT;		return 0;	}	/*	** Note: Interrupts are locked out if this is an AP and are NOT	** locked out if this is a station.	*/	msg->resultcode.status = P80211ENUM_msgitem_status_data_ok;	if  ( msg->enable.data == P80211ENUM_truth_true ) {		if ( hfa384x_drvr_flashdl_enable(hw) ) {			msg->resultcode.data = P80211ENUM_resultcode_implementation_failure;		} else {			msg->resultcode.data = P80211ENUM_resultcode_success;		}	} else {		hfa384x_drvr_flashdl_disable(hw);		msg->resultcode.data = P80211ENUM_resultcode_success;#if 0		/*TODO: Reset everything....the MAC just restarted */		udelay(1000);		prism2sta_initmac(wlandev);#endif	}	DBFEXIT;	return 0;}/*----------------------------------------------------------------* prism2mgmt_flashdl_write** ** 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_flashdl_write(wlandevice_t *wlandev, void *msgp){	prism2sta_priv_t	*priv = (prism2sta_priv_t*)wlandev->priv;	hfa384x_t		*hw = priv->hw;	p80211msg_p2req_flashdl_write_t	*msg = msgp;	UINT32			addr;	UINT32			len;	UINT8			*buf;	DBFENTER;	if (wlandev->msdstate != WLAN_MSD_FWLOAD) {		WLAN_LOG_ERROR0(			"flashdl_write(): may only be called "			"in the fwload state.\n");		msg->resultcode.data = 			P80211ENUM_resultcode_implementation_failure;		msg->resultcode.status = P80211ENUM_msgitem_status_data_ok;		DBFEXIT;		return 0;	}	/*	** Note: Interrupts are locked out if this is an AP and are NOT	** locked out if this is a station.	*/	msg->resultcode.status = P80211ENUM_msgitem_status_data_ok;	/* first validate the length */	if  ( msg->len.data > sizeof(msg->data.data) ) {		msg->resultcode.status = 			P80211ENUM_resultcode_invalid_parameters;		return 0;	}	/* call the hfa384x function to do the write */	addr = msg->addr.data;	len = msg->len.data;	buf = msg->data.data;	if ( hfa384x_drvr_flashdl_write(hw, addr, buf, len) ) {		msg->resultcode.data = P80211ENUM_resultcode_refused;			}	msg->resultcode.data = P80211ENUM_resultcode_success;	DBFEXIT;	return 0;}/*----------------------------------------------------------------* prism2mgmt_dump_state** Dumps the driver's and hardware's current state via the kernel * log at KERN_NOTICE level.** 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_dump_state(wlandevice_t *wlandev, void *msgp){	p80211msg_p2req_dump_state_t	*msg = msgp;	int				result = 0;#if (WLAN_HOSTIF != WLAN_USB)	prism2sta_priv_t		*priv = wlandev->priv;	hfa384x_t			*hw = priv->hw;	UINT16				auxbuf[15];	DBFENTER;	WLAN_LOG_NOTICE0("prism2 driver and hardware state:\n");	if  ( (result = hfa384x_cmd_aux_enable(hw)) ) {		WLAN_LOG_ERROR1("aux_enable failed, result=%d\n", result);		goto failed;	}	hfa384x_copy_from_aux(hw, 		0x01e2, 		HFA384x_AUX_CTL_EXTDS, 		auxbuf, 		sizeof(auxbuf));	hfa384x_cmd_aux_disable(hw);	WLAN_LOG_NOTICE1("  cmac: FreeBlocks=%d\n", auxbuf[5]);	WLAN_LOG_NOTICE2("  cmac: IntEn=0x%02x EvStat=0x%02x\n", 		hfa384x_getreg(hw, HFA384x_INTEN),		hfa384x_getreg(hw, HFA384x_EVSTAT));	#ifdef USE_FID_STACK	WLAN_LOG_NOTICE2("  drvr: txfid_top=%d stacksize=%d\n",		hw->txfid_top,HFA384x_DRVR_FIDSTACKLEN_MAX);	#else	WLAN_LOG_NOTICE3("  drvr: txfid_head=%d txfid_tail=%d txfid_N=%d\n",		hw->txfid_head, hw->txfid_tail, hw->txfid_N);	#endif	msg->resultcode.status = P80211ENUM_msgitem_status_data_ok;	msg->resultcode.data = P80211ENUM_resultcode_success;#else /* (WLAN_HOSTIF == WLAN_USB) */	DBFENTER;	msg->resultcode.status = P80211ENUM_msgitem_status_data_ok;	msg->resultcode.data = P80211ENUM_resultcode_not_supported;	goto failed;#endif /* (WLAN_HOSTIF != WLAN_USB) */failed:		DBFEXIT;	return result;}/*----------------------------------------------------------------* prism2mgmt_channel_info** Issues a ChannelInfoRequest.** 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_channel_info(wlandevice_t *wlandev, void *msgp){	p80211msg_p2req_channel_info_t	*msg=msgp;	prism2sta_priv_t		*priv = (prism2sta_priv_t*)wlandev->priv;	hfa384x_t			*hw = priv->hw;	int				result, i, n=0;	UINT16				channel_mask=0;	hfa384x_ChannelInfoRequest_data_t	chinforeq;	// unsigned long 			now;	DBFENTER;	if (!priv->ap) {		/*** STATION ***/		/* Not supported in STA f/w */		P80211_SET_INT(msg->resultcode, P80211ENUM_resultcode_not_supported);		goto done;	}	/*** ACCESS POINT ***/#define CHINFO_TIMEOUT 2	P80211_SET_INT(msg->resultcode, P80211ENUM_resultcode_success);	/* setting default value for channellist = all channels */	if (!msg->channellist.data) {		P80211_SET_INT(msg->channellist, 0x00007FFE);	}	/* setting default value for channeldwelltime = 100 ms */	if (!msg->channeldwelltime.data) {		P80211_SET_INT(msg->channeldwelltime, 100);	}	channel_mask = (UINT16) (msg->channellist.data >> 1);	for (i=0, n=0; i < 14; i++) {		if (channel_mask & (1<<i)) {			n++;		}	}	P80211_SET_INT(msg->numchinfo, n);	chinforeq.channelList = host2hfa384x_16(channel_mask);	chinforeq.channelDwellTime = host2hfa384x_16(msg->channeldwelltime.data);	atomic_set(&priv->channel_info.done, 1);	result = hfa384x_drvr_setconfig( hw, HFA384x_RID_CHANNELINFOREQUEST,					 &chinforeq, HFA384x_RID_CHANNELINFOREQUEST_LEN);	if ( result ) {		WLAN_LOG_ERROR1("setconfig(CHANNELINFOREQUEST) failed. result=%d\n",				result);		msg->resultcode.data = P80211ENUM_resultcode_not_supported;		goto done;	}	/*	now = jiffies;	while (atomic_read(&priv->channel_info.done) != 1) {		if ((jiffies - now) > CHINFO_TIMEOUT*HZ) {			WLAN_LOG_NOTICE1("ChannelInfo results not received in %d seconds, aborting.\n", 					CHINFO_TIMEOUT);			msg->resultcode.data = P80211ENUM_resultcode_timeout;			goto done;		}		current->state = TASK_INTERRUPTIBLE;		schedule_timeout(HZ/4);		current->state = TASK_RUNNING;	} 	*/done:	DBFEXIT;	return 0;}/*----------------------------------------------------------------* prism2mgmt_channel_info_results** Returns required ChannelInfo result.** 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_channel_info_results(wlandevice_t *wlandev, void *msgp){	prism2sta_priv_t		*priv = (prism2sta_priv_t*)wlandev->priv;	p80211msg_p2req_channel_info_results_t	*msg=msgp;	int				result=0;	int		channel;	DBFENTER;	if (!priv->ap) {		/*** STATION ***/		/* Not supported in STA f/w */		P80211_SET_INT(msg->resultcode, P80211ENUM_resultcode_not_supported);		goto done;	}	/*** ACCESS POINT ***/	switch (atomic_read(&priv->channel_info.done)) {	case 0: msg->resultcode.status = P80211ENUM_msgitem_status_no_value;		goto done;	case 1: msg->resultcode.status = P80211ENUM_msgitem_status_incomplete_itemdata;		goto done;	}	P80211_SET_INT(msg->resultcode, P80211ENUM_resultcode_success);	channel=msg->channel.data-1;		if (channel < 0 || ! (priv->channel_info.results.scanchannels & 1<<channel) ) {		msg->resultcode.data = P80211ENUM_resultcode_invalid_parameters;		goto done;	}	WLAN_LOG_DEBUG4(2, "chinfo_results: channel %d, avg/peak level=%d/%d dB, active=%d\n",			channel+1, 			priv->channel_info.results.result[channel].anl,			priv->channel_info.results.result[channel].pnl, 			priv->channel_info.results.result[channel].active		);	P80211_SET_INT(msg->avgnoiselevel, priv->channel_info.results.result[channel].anl);	P80211_SET_INT(msg->peaknoiselevel, priv->channel_info.results.result[channel].pnl);	P80211_SET_INT(msg->bssactive, priv->channel_info.results.result[channel].active & 		HFA384x_CHINFORESULT_BSSACTIVE                 ? P80211ENUM_truth_true                : P80211ENUM_truth_false) ;	P80211_SET_INT(msg->pcfactive, priv->channel_info.results.result[channel].active & 		HFA384x_CHINFORESULT_PCFACTIVE                ? P80211ENUM_truth_true                : P80211ENUM_truth_false) ;done:	DBFEXIT;	return result;}/*----------------------------------------------------------------* prism2mgmt_autojoin** 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_autojoin(wlandevice_t *wlandev, void *msgp){	prism2sta_priv_t	*priv = (prism2sta_priv_t*)wlandev->priv;	hfa384x_t		*hw = priv->hw;	int 			result = 0;	UINT16			reg;	UINT16			port_type;	p80211msg_lnxreq_autojoin_t	*msg = msgp;	p80211pstrd_t		*pstr;		UINT8			bytebuf[256];	hfa384x_bytestr_t	*p2bytestr = (hfa384x_bytestr_t*)bytebuf;	DBFENTER;	if (priv->ap) {		/*** ACCESS POINT ***/		/* Never supported on AP */		msg->resultcode.status = P80211ENUM_msgitem_status_data_ok;		msg->resultcode.data = P80211ENUM_resultcode_not_supported;		goto done;	}	/*** STATION ***/	/* Set the TxRates */	reg = 0x000f;	hfa384x_drvr_setconfig16(hw, HFA384x_RID_TXRATECNTL, &reg);	/* Set the auth type */	if ( msg->authtype.data == P80211ENUM_authalg_sharedkey ) {		reg = HFA384x_CNFAUTHENTICATION_SHAREDKEY;	} else {		reg = HFA384x_CNFAUTHENTICATION_OPENSYSTEM;	}	hfa384x_drvr_setconfig16(hw, HFA384x_RID_CNFAUTHENTICATION, &reg);	/* Set the ssid */	memset(bytebuf, 0, 256);	pstr = (p80211pstrd_t*)&(msg->ssid.data);	prism2mgmt_pstr2bytestr(p2bytestr, pstr);        result = hfa384x_drvr_setconfig( 			hw, HFA384x_RID_CNFDESIREDSSID,			bytebuf, HFA384x_RID_CNFDESIREDSSID_LEN);				        	/* 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 */	reg = 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_setreg(hw, 0xffff, HFA384x_EVSTAT);	hfa384x_setreg(hw, reg, 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;done:	DBFEXIT;	return result;}/*----------------------------------------------------------------* prism2mgmt_wlansniff** Start or stop sniffing.** 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_wlansniff(wlandevice_t *wlandev, void *msgp){	int 			result = 0;	p80211msg_lnxreq_wlansniff_t	*msg = msgp;#ifndef CONFIG_PACKET#warning "CONFIG_PACKET not enabled, not compiling sniffing/indication code"	DBFENTER;	msg->resultcode.status = P80211ENUM_msgitem_status_data_ok;	msg->resultcode.data = 

⌨️ 快捷键说明

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