prism2mgmt.c

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

C
2,318
字号
/* src/prism2/driver/prism2mgmt.c** Management request handler functions.** Copyright (C) 1999 AbsoluteValue Systems, Inc.  All Rights Reserved.* --------------------------------------------------------------------** linux-wlan**   The contents of this file are subject to the Mozilla Public*   License Version 1.1 (the "License"); you may not use this file*   except in compliance with the License. You may obtain a copy of*   the License at http://www.mozilla.org/MPL/**   Software distributed under the License is distributed on an "AS*   IS" basis, WITHOUT WARRANTY OF ANY KIND, either express or*   implied. See the License for the specific language governing*   rights and limitations under the License.**   Alternatively, the contents of this file may be used under the*   terms of the GNU Public License version 2 (the "GPL"), in which*   case the provisions of the GPL are applicable instead of the*   above.  If you wish to allow the use of your version of this file*   only under the terms of the GPL and not to allow others to use*   your version of this file under the MPL, indicate your decision*   by deleting the provisions above and replace them with the notice*   and other provisions required by the GPL.  If you do not delete*   the provisions above, a recipient may use your version of this*   file under either the MPL or the GPL.** --------------------------------------------------------------------** Inquiries regarding the linux-wlan Open Source project can be* made directly to:** AbsoluteValue Systems Inc.* info@linux-wlan.com* http://www.linux-wlan.com** --------------------------------------------------------------------** Portions of the development of this software were funded by * Intersil Corporation as part of PRISM(R) chipset product development.** --------------------------------------------------------------------** The functions in this file handle management requests sent from* user mode.** Most of these functions have two separate blocks of code that are* conditional on whether this is a station or an AP.  This is used* to separate out the STA and AP responses to these management primitives.* It's a choice (good, bad, indifferent?) to have the code in the same * place so it's clear that the same primitive is implemented in both * cases but has different behavior.** --------------------------------------------------------------------*//*================================================================*//* System Includes */#define __NO_VERSION__#include <linux/config.h>#define WLAN_DBVAR	prism2_debug#include <linux/version.h>#include <wlan/wlan_compat.h>#include <linux/if_arp.h>#include <linux/module.h>#include <linux/kernel.h>#include <linux/sched.h>#include <linux/types.h>#include <linux/slab.h>#include <linux/netdevice.h>#include <asm/io.h>#include <linux/delay.h>#include <asm/byteorder.h>#if (WLAN_HOSTIF == WLAN_PCMCIA)#include <pcmcia/config.h>#include <pcmcia/k_compat.h>#include <pcmcia/version.h>#include <pcmcia/cs_types.h>#include <pcmcia/cs.h>#include <pcmcia/cistpl.h>#include <pcmcia/ds.h>#include <pcmcia/cisreg.h>#include <pcmcia/driver_ops.h>#endif#if ((WLAN_HOSTIF == WLAN_PLX) || (WLAN_HOSTIF == WLAN_PCI))#include <linux/ioport.h>#include <linux/pci.h>#endif#if (WLAN_HOSTIF == WLAN_USB)#include <linux/usb.h>#endif/*================================================================*//* Project Includes */#include <wlan/version.h>#include <wlan/p80211types.h>#include <wlan/p80211hdr.h>#include <wlan/p80211mgmt.h>#include <wlan/p80211conv.h>#include <wlan/p80211msg.h>#include <wlan/p80211netdev.h>#include <wlan/p80211metadef.h>#include <wlan/p80211metastruct.h>#include <prism2/hfa384x.h>#include <prism2/prism2mgmt.h>/*================================================================*//* Local Constants *//*================================================================*//* Local Macros *//* Converts 802.11 format rate specifications to prism2 */#define p80211rate_to_p2bit(n)	((((n)&~BIT7) == 2) ? BIT0 : \				 (((n)&~BIT7) == 4) ? BIT1 : \				 (((n)&~BIT7) == 11) ? BIT2 : \				 (((n)&~BIT7) == 22) ? BIT3 : 0)/*================================================================*//* Local Types *//*================================================================*//* Local Static Definitions *//*================================================================*//* Local Function Declarations *//*================================================================*//* Function Definitions *//*----------------------------------------------------------------* prism2mgmt_powermgmt** Set the power management state of this station's MAC.** 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_powermgmt(wlandevice_t *wlandev, void *msgp){	int 			result = 0;	prism2sta_priv_t	*priv = (prism2sta_priv_t*)wlandev->priv;	p80211msg_dot11req_powermgmt_t	*msg = msgp;	DBFENTER;	if (!priv->ap) {		/*** STATION ***/		/*		 * Set CNFPMENABLED (on or off)		 * Set CNFMULTICASTRX (if PM on, otherwise clear)		 * Spout a notice stating that SleepDuration and		 * HoldoverDuration and PMEPS also have an impact.		 */		/* Powermgmt is currently unsupported for STA */		msg->resultcode.status = P80211ENUM_msgitem_status_data_ok;		msg->resultcode.data = P80211ENUM_resultcode_not_supported;	} else {		/*** ACCESS POINT ***/		/* Powermgmt is never supported for AP */		msg->resultcode.status = P80211ENUM_msgitem_status_data_ok;		msg->resultcode.data = P80211ENUM_resultcode_not_supported;	}	DBFEXIT;	return result;}/*----------------------------------------------------------------* prism2mgmt_scan** Initiate a scan for BSSs.** This function corresponds to MLME-scan.request and part of * MLME-scan.confirm.  As far as I can tell in the standard, there* are no restrictions on when a scan.request may be issued.  We have* to handle in whatever state the driver/MAC happen to be.** 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_scan(wlandevice_t *wlandev, void *msgp){	int 			result = 0;	prism2sta_priv_t	*priv = (prism2sta_priv_t*)wlandev->priv;	p80211msg_dot11req_scan_t	*msg = msgp;	// hfa384x_t		*hw = priv->hw;	// hfa384x_ScanRequest_data_t	scanreq;	// UINT16			word;	DBFENTER;	if (!priv->ap) {		/*** STATION ***/#if 0		/* Check the roaming mode to make sure we can scan, change if necessary */		/* Check the port status, if disabled, then enable */		/* Construct the channel list */		/* Set the rate based on...what? */		if ( !joined )			rate=min(HFA384x_RID_TXRATECNTL) (aka dot11OperationalRates)		else			if ( dot11req_scan.ssid == currssid )				rate=max(HFA384x_RID_CNF_BASICRATES) 				   (if supported on STA..we might need to save 				   this from prior scans)			else				rate=min(HFA384x_RID_TXRATECNTL) (aka dot11OperationalRates)			endif		endif					/* Set the scan command */		/* Issue the Inquire */		/* Sleep until scanresults are in */		/* Build the persistent (filtered) results */		word = 2;		hfa384x_drvr_setconfig16(hw, HFA384x_RID_CNFROAMINGMODE, &word);		/* Issue the scan request */		scanreq.channelList = host2hfa384x_16(0x07ff); /* scan channels 1-11 */		scanreq.txRate = host2hfa384x_16(BIT1);        /* probes @ 2Mb/s */		result = hfa384x_drvr_setconfig( hw, HFA384x_RID_SCANREQUEST,				&scanreq, HFA384x_RID_SCANREQUEST_LEN);		if ( result ) {			WLAN_LOG_ERROR1("setconfig(SCANREQUEST) failed. result=%d\n",					result);			result = 0;		}		/* Issue an async inquire */		hfa384x_drvr_scanresults(hw, HFA384x_IT_SCANRESULTS);		/* sleep until info frame arrives */#endif		result = 0;		msg->resultcode.status = P80211ENUM_msgitem_status_data_ok;		msg->resultcode.data = P80211ENUM_resultcode_not_supported;	} else {		/*** ACCESS POINT ***/		/* Scan is currently unsupported for AP */		/* TODO: Find out if host managed scan is supported in ap f/w */		/*       we might want to use it to allow some "auto config"  */		/*       mode where the AP scans for others and then selects  */		/*       its channel and settings based on what it finds.     */		msg->resultcode.status = P80211ENUM_msgitem_status_data_ok;		msg->resultcode.data = P80211ENUM_resultcode_not_supported;	}	DBFEXIT;	return result;}/*----------------------------------------------------------------* prism2mgmt_scan_results** Retrieve the BSS description for one of the BSSs identified in* a scan.** 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_scan_results(wlandevice_t *wlandev, void *msgp){	int 			result = 0;	prism2sta_priv_t	*priv = (prism2sta_priv_t*)wlandev->priv;	p80211msg_dot11req_scan_results_t	*msg = msgp;	DBFENTER;	if (!priv->ap) {		/*** STATION ***/		/* Same situation as scan */		msg->resultcode.status = P80211ENUM_msgitem_status_data_ok;		msg->resultcode.data = P80211ENUM_resultcode_not_supported;	} else {		/*** ACCESS POINT ***/		/* Same situation as scan */		msg->resultcode.status = P80211ENUM_msgitem_status_data_ok;		msg->resultcode.data = P80211ENUM_resultcode_not_supported;	}	DBFEXIT;	return result;}/*----------------------------------------------------------------* prism2mgmt_join** Join a BSS whose BSS description was previously obtained with* a scan.** 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_join(wlandevice_t *wlandev, void *msgp){	int 			result = 0;	prism2sta_priv_t	*priv = (prism2sta_priv_t*)wlandev->priv;	p80211msg_dot11req_join_t	*msg = msgp;	DBFENTER;	if (!priv->ap) {		/*** STATION ***/		/* TODO: Implement after scan */		msg->resultcode.status = P80211ENUM_msgitem_status_data_ok;		msg->resultcode.data = P80211ENUM_resultcode_not_supported;	} else {		/*** ACCESS POINT ***/		/* Never supported by APs */		msg->resultcode.status = P80211ENUM_msgitem_status_data_ok;		msg->resultcode.data = P80211ENUM_resultcode_not_supported;	}	DBFEXIT;	return result;}/*----------------------------------------------------------------* prism2mgmt_authenticate** Station should be begin an authentication exchange.** 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_authenticate(wlandevice_t *wlandev, void *msgp){	int 			result = 0;	prism2sta_priv_t	*priv = (prism2sta_priv_t*)wlandev->priv;	p80211msg_dot11req_authenticate_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 ***/		/* Never supported by APs */		msg->resultcode.status = P80211ENUM_msgitem_status_data_ok;		msg->resultcode.data = P80211ENUM_resultcode_not_supported;	}	DBFEXIT;	return result;}/*----------------------------------------------------------------* prism2mgmt_deauthenticate** Send a deauthenticate 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_deauthenticate(wlandevice_t *wlandev, void *msgp)

⌨️ 快捷键说明

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