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

📄 airo.c

📁 Linux下的PCMCIA接口的无线网卡驱动程序
💻 C
📖 第 1 页 / 共 5 页
字号:
        u16 probeResponseTimeout;	u16 beaconListenTimeout;	u16 joinNetTimeout;	u16 authTimeout;	u16 authType;#define AUTH_OPEN 0x1#define AUTH_ENCRYPT 0x101#define AUTH_SHAREDKEY 0x102#define AUTH_ALLOW_UNENCRYPTED 0x200	u16 associationTimeout;	u16 specifiedApTimeout;	u16 offlineScanInterval;	u16 offlineScanDuration;	u16 linkLossDelay;	u16 maxBeaconLostTime;	u16 refreshInterval;#define DISABLE_REFRESH 0xFFFF	u16 _reserved1a[1];	/*---------- Power save operation ----------*/	u16 powerSaveMode;#define POWERSAVE_CAM 0#define POWERSAVE_PSP 1#define POWERSAVE_PSPCAM 2	u16 sleepForDtims;	u16 listenInterval;	u16 fastListenInterval;	u16 listenDecay;	u16 fastListenDelay;	u16 _reserved2[2];	/*---------- Ap/Ibss config items ----------*/	u16 beaconPeriod;	u16 atimDuration;	u16 hopPeriod;	u16 channelSet;	u16 channel;	u16 dtimPeriod;	u16 bridgeDistance;	u16 radioID;	/*---------- Radio configuration ----------*/	u16 radioType;#define RADIOTYPE_DEFAULT 0#define RADIOTYPE_802_11 1#define RADIOTYPE_LEGACY 2	u8 rxDiversity;	u8 txDiversity;	u16 txPower;#define TXPOWER_DEFAULT 0	u16 rssiThreshold;#define RSSI_DEFAULT 0        u16 modulation;#define PREAMBLE_AUTO 0#define PREAMBLE_LONG 1#define PREAMBLE_SHORT 2	u16 preamble;	u16 homeProduct;	u16 radioSpecific;	/*---------- Aironet Extensions ----------*/	u8 nodeName[16];	u16 arlThreshold;	u16 arlDecay;	u16 arlDelay;	u16 _reserved4[1];	/*---------- Aironet Extensions ----------*/	u16 magicAction;#define MAGIC_ACTION_STSCHG 1#define MACIC_ACTION_RESUME 2#define MAGIC_IGNORE_MCAST (1<<8)#define MAGIC_IGNORE_BCAST (1<<9)#define MAGIC_SWITCH_TO_PSP (0<<10)#define MAGIC_STAY_IN_CAM (1<<10)	u16 magicControl;	u16 autoWake;} ConfigRid;typedef struct {	u16 len;	u8 mac[6];	u16 mode;	u16 errorCode;	u16 sigQuality;	u16 SSIDlen;	char SSID[32];	char apName[16];	char bssid[4][6];	u16 beaconPeriod;	u16 dimPeriod;	u16 atimDuration;	u16 hopPeriod;	u16 channelSet;	u16 channel;	u16 hopsToBackbone;	u16 apTotalLoad;	u16 generatedLoad;	u16 accumulatedArl;	u16 signalQuality;	u16 currentXmitRate;	u16 apDevExtensions;	u16 normalizedSignalStrength;	u16 _reserved[10];} StatusRid;typedef struct {	u16 len;	u16 spacer;	u32 vals[100];} StatsRid;typedef struct {	u16 len;	u8 ap[4][6];} APListRid;typedef struct {	u16 len;	char oui[3];	char zero;	u16 prodNum;	char manName[32];	char prodName[16];	char prodVer[8];	char factoryAddr[6];	char aironetAddr[6];	u16 radioType;	u16 country;	char callid[6];	char supportedRates[8];	char rxDiversity;	char txDiversity;	u16 txPowerLevels[8];	u16 hardVer;	u16 hardCap;	u16 tempRange;	u16 softVer;	u16 softSubVer;	u16 interfaceVer;	u16 softCap;	u16 bootBlockVer;	u16 requiredHard;} CapabilityRid;typedef struct {  u16 len;  u16 index; /* First is 0 and 0xffff means end of list */#define RADIO_FH 1 /* Frequency hopping radio type */#define RADIO_DS 2 /* Direct sequence radio type */#define RADIO_TMA 4 /* Proprietary radio used in old cards (2500) */  u16 radioType;  u8 bssid[6]; /* Mac address of the BSS */  u8 zero;  u8 ssidLen;  u8 ssid[32];  u16 rssi;#define CAP_ESS (1<<0)#define CAP_IBSS (1<<1)#define CAP_PRIVACY (1<<4)#define CAP_SHORTHDR (1<<5)  u16 cap;  u16 beaconInterval;  u8 rates[8]; /* Same as rates for config rid */  struct { /* For frequency hopping only */    u16 dwell;    u8 hopSet;    u8 hopPattern;    u8 hopIndex;    u8 fill;  } fh;  u16 dsChannel;  u16 atimWindow;} BSSListRid;typedef struct {  u8 rssipct;  u8 rssidBm;} tdsRssiEntry;typedef struct {  u16 len;  tdsRssiEntry x[256];} tdsRssiRid;#pragma pack()#define TXCTL_TXOK (1<<1) /* report if tx is ok */#define TXCTL_TXEX (1<<2) /* report if tx fails */#define TXCTL_802_3 (0<<3) /* 802.3 packet */#define TXCTL_802_11 (1<<3) /* 802.11 mac packet */#define TXCTL_ETHERNET (0<<4) /* payload has ethertype */#define TXCTL_LLC (1<<4) /* payload is llc */#define TXCTL_RELEASE (0<<5) /* release after completion */#define TXCTL_NORELEASE (1<<5) /* on completion returns to host */#define BUSY_FID 0x10000#ifdef CISCO_EXT#define AIROMAGIC	0xa55a/* Warning : SIOCDEVPRIVATE may disapear during 2.5.X - Jean II */#ifdef SIOCIWFIRSTPRIV#ifdef SIOCDEVPRIVATE#define AIROOLDIOCTL	SIOCDEVPRIVATE#define AIROOLDIDIFC 	AIROOLDIOCTL + 1#endif /* SIOCDEVPRIVATE */#else /* SIOCIWFIRSTPRIV */#define SIOCIWFIRSTPRIV SIOCDEVPRIVATE#endif /* SIOCIWFIRSTPRIV */#define AIROIOCTL	SIOCIWFIRSTPRIV#define AIROIDIFC 	AIROIOCTL + 1/* Ioctl constants to be used in airo_ioctl.command */#define	AIROGCAP  		0	// Capability rid#define AIROGCFG		1       // USED A LOT#define AIROGSLIST		2	// System ID list#define AIROGVLIST		3       // List of specified AP's#define AIROGDRVNAM		4	//  NOTUSED#define AIROGEHTENC		5	// NOTUSED#define AIROGWEPKTMP		6#define AIROGWEPKNV		7#define AIROGSTAT		8#define AIROGSTATSC32		9#define AIROGSTATSD32		10/* Leave gap of 40 commands after AIROGSTATSD32 for future */#define AIROPCAP               	AIROGSTATSD32 + 40#define AIROPVLIST              AIROPCAP      + 1#define AIROPSLIST		AIROPVLIST    + 1#define AIROPCFG		AIROPSLIST    + 1#define AIROPSIDS		AIROPCFG      + 1#define AIROPAPLIST		AIROPSIDS     + 1#define AIROPMACON		AIROPAPLIST   + 1	/* Enable mac  */#define AIROPMACOFF		AIROPMACON    + 1 	/* Disable mac */#define AIROPSTCLR		AIROPMACOFF   + 1#define AIROPWEPKEY		AIROPSTCLR    + 1#define AIROPWEPKEYNV		AIROPWEPKEY   + 1#define AIROPLEAPPWD            AIROPWEPKEYNV + 1#define AIROPLEAPUSR            AIROPLEAPPWD  + 1/* Flash codes */#define AIROFLSHRST	       AIROPWEPKEYNV  + 40#define AIROFLSHGCHR           AIROFLSHRST    + 1#define AIROFLSHSTFL           AIROFLSHGCHR   + 1#define AIROFLSHPCHR           AIROFLSHSTFL   + 1#define AIROFLPUTBUF           AIROFLSHPCHR   + 1#define AIRORESTART            AIROFLPUTBUF   + 1#define FLASHSIZE	32768typedef struct aironet_ioctl {	unsigned short command;	// What to do	unsigned short len;		// Len of data	unsigned char *data;		// d-data} aironet_ioctl;#endif /* CISCO_EXT */#ifdef WIRELESS_EXT// Frequency list (map channels to frequencies)const long frequency_list[] = { 2412, 2417, 2422, 2427, 2432, 2437, 2442,				2447, 2452, 2457, 2462, 2467, 2472, 2484 };// A few details needed for WEP (Wireless Equivalent Privacy)#define MAX_KEY_SIZE 13			// 128 (?) bits#define MIN_KEY_SIZE  5			// 40 bits RC4 - WEPtypedef struct wep_key_t {	u16	len;	u8	key[16];	/* 40-bit and 104-bit keys */} wep_key_t;#endif /* WIRELESS_EXT */static const char version[] = "airo.c 0.3 (Ben Reed & Javier Achirica)";struct airo_info;static int get_dec_u16( char *buffer, int *start, int limit );static void OUT4500( struct airo_info *, u16 register, u16 value );static unsigned short IN4500( struct airo_info *, u16 register );static u16 setup_card(struct airo_info*, u8 *mac, ConfigRid *);static void enable_interrupts(struct airo_info*);static void disable_interrupts(struct airo_info*);static u16 lock_issuecommand(struct airo_info*, Cmd *pCmd, Resp *pRsp);static u16 issuecommand(struct airo_info*, Cmd *pCmd, Resp *pRsp);static int bap_setup(struct airo_info*, u16 rid, u16 offset, int whichbap);static int aux_bap_read(struct airo_info*, u16 *pu16Dst, int bytelen,			int whichbap);static int fast_bap_read(struct airo_info*, u16 *pu16Dst, int bytelen,			 int whichbap);static int bap_write(struct airo_info*, const u16 *pu16Src, int bytelen,		     int whichbap);static int PC4500_accessrid(struct airo_info*, u16 rid, u16 accmd);static int PC4500_readrid(struct airo_info*, u16 rid, void *pBuf, int len);static int PC4500_writerid(struct airo_info*, u16 rid, const void			   *pBuf, int len);static int do_writerid( struct airo_info*, u16 rid, const void *rid_data,			int len );static u16 transmit_allocate(struct airo_info*, int lenPayload);static int transmit_802_3_packet(struct airo_info*, u16 TxFid, char				 *pPacket, int len);static void airo_interrupt( int irq, void* dev_id, struct pt_regs			    *regs);static int airo_ioctl(struct net_device *dev, struct ifreq *rq, int cmd);#ifdef WIRELESS_EXTstruct iw_statistics *airo_get_wireless_stats (struct net_device *dev);#endif /* WIRELESS_EXT */#ifdef CISCO_EXTstatic int readrids(struct net_device *dev, aironet_ioctl *comp);static int writerids(struct net_device *dev, aironet_ioctl *comp);int flashcard(struct net_device *dev, aironet_ioctl *comp);#endif /* CISCO_EXT */struct airo_info {	struct net_device_stats	stats;	int open;	struct net_device             *dev;	/* Note, we can have MAX_FIDS outstanding.  FIDs are 16-bits, so we	   use the high bit to mark wether it is in use. */#define MAX_FIDS 6	int                           fids[MAX_FIDS];	int registered;	ConfigRid config;	u16 authtype; // Used with auto_wep	char keyindex; // Used with auto wep	char defindex; // Used with auto wep	struct timer_list timer;	struct proc_dir_entry *proc_entry;	struct airo_info *next;        spinlock_t aux_lock;        spinlock_t main_lock;        int flags;#define FLAG_PROMISC   IFF_PROMISC#define FLAG_RADIO_OFF 0x02	int (*bap_read)(struct airo_info*, u16 *pu16Dst, int bytelen,			int whichbap);	int (*header_parse)(struct sk_buff*, unsigned char *);	unsigned short *flash;	tdsRssiEntry *rssi;#ifdef WIRELESS_EXT	int			need_commit;	// Need to set config	struct iw_statistics	wstats;		// wireless stats#ifdef WIRELESS_SPY	int			spy_number;	u_char			spy_address[IW_MAX_SPY][6];	struct iw_quality	spy_stat[IW_MAX_SPY];#endif /* WIRELESS_SPY */#endif /* WIRELESS_EXT */};static inline int bap_read(struct airo_info *ai, u16 *pu16Dst, int bytelen,			   int whichbap) {	return ai->bap_read(ai, pu16Dst, bytelen, whichbap);}static int setup_proc_entry( struct net_device *dev,			     struct airo_info *apriv );static int takedown_proc_entry( struct net_device *dev,				struct airo_info *apriv );static int readBSSListRid(struct airo_info *ai, int first,		      BSSListRid *list) {	int rc;			Cmd cmd;			Resp rsp;	if (first == 1) {			memset(&cmd, 0, sizeof(cmd));			cmd.cmd=CMD_LISTBSS;			lock_issuecommand(ai, &cmd, &rsp);			/* Let the command take effect */			set_current_state (TASK_INTERRUPTIBLE);			schedule_timeout (3*HZ);		}	rc = PC4500_readrid(ai,		            first ? RID_BSSLISTFIRST : RID_BSSLISTNEXT,			    list, sizeof(*list));	list->len = le16_to_cpu(list->len);	list->index = le16_to_cpu(list->index);	list->radioType = le16_to_cpu(list->radioType);	list->cap = le16_to_cpu(list->cap);	list->beaconInterval = le16_to_cpu(list->beaconInterval);	list->fh.dwell = le16_to_cpu(list->fh.dwell);	list->dsChannel = le16_to_cpu(list->dsChannel);	list->atimWindow = le16_to_cpu(list->atimWindow);	return rc;}static int readWepKeyRid(struct airo_info*ai, WepKeyRid *wkr, int temp) {	int rc = PC4500_readrid(ai, temp ? RID_WEP_TEMP : RID_WEP_PERM,				wkr, sizeof(*wkr));	wkr->len = le16_to_cpu(wkr->len);	wkr->kindex = le16_to_cpu(wkr->kindex);	wkr->klen = le16_to_cpu(wkr->klen);	return rc;}/* In the writeXXXRid routines we copy the rids so that we don't screwup * the originals when we endian them... */static int writeWepKeyRid(struct airo_info*ai, WepKeyRid *pwkr, int perm) {	int rc;	WepKeyRid wkr = *pwkr;	wkr.len = cpu_to_le16(wkr.len);	wkr.kindex = cpu_to_le16(wkr.kindex);	wkr.klen = cpu_to_le16(wkr.klen);	rc = do_writerid(ai, RID_WEP_TEMP, &wkr, sizeof(wkr));	if (rc!=SUCCESS) printk(KERN_ERR "airo:  WEP_TEMP set %x\n", rc);	if (perm) {		rc = do_writerid(ai, RID_WEP_PERM, &wkr, sizeof(wkr));		if (rc!=SUCCESS) {			printk(KERN_ERR "airo:  WEP_PERM set %x\n", rc);		}	}	return rc;}static int readSsidRid(struct airo_info*ai, SsidRid *ssidr) {	int i;	int rc = PC4500_readrid(ai, RID_SSID, ssidr, sizeof(*ssidr));	ssidr->len = le16_to_cpu(ssidr->len);	for(i = 0; i < 3; i++) {		ssidr->ssids[i].len = le16_to_cpu(ssidr->ssids[i].len);	}	return rc;}static int writeSsidRid(struct airo_info*ai, SsidRid *pssidr) {	int rc;	int i;	SsidRid ssidr = *pssidr;	ssidr.len = cpu_to_le16(ssidr.len);	for(i = 0; i < 3; i++) {		ssidr.ssids[i].len = cpu_to_le16(ssidr.ssids[i].len);	}	rc = do_writerid(ai, RID_SSID, &ssidr, sizeof(ssidr));	return rc;}static int readConfigRid(struct airo_info*ai, ConfigRid *cfgr) {	int rc = PC4500_readrid(ai, RID_ACTUALCONFIG, cfgr, sizeof(*cfgr));	u16 *s;	for(s = &cfgr->len; s <= &cfgr->rtsThres; s++) *s = le16_to_cpu(*s);	for(s = &cfgr->shortRetryLimit; s <= &cfgr->radioType; s++)		*s = le16_to_cpu(*s);	for(s = &cfgr->txPower; s <= &cfgr->radioSpecific; s++)		*s = le16_to_cpu(*s);	for(s = &cfgr->arlThreshold; s <= &cfgr->autoWake; s++)		*s = le16_to_cpu(*s);	return rc;}static int writeConfigRid(struct airo_info*ai, ConfigRid *pcfgr) {	u16 *s;	ConfigRid cfgr = *pcfgr;	for(s = &cfgr.len; s <= &cfgr.rtsThres; s++) *s = cpu_to_le16(*s);	for(s = &cfgr.shortRetryLimit; s <= &cfgr.radioType; s++)		*s = cpu_to_le16(*s);	for(s = &cfgr.txPower; s <= &cfgr.radioSpecific; s++)		*s = cpu_to_le16(*s);	for(s = &cfgr.arlThreshold; s <= &cfgr.autoWake; s++)		*s = cpu_to_le16(*s);	return do_writerid( ai, RID_CONFIG, &cfgr, sizeof(cfgr));}static int readStatusRid(struct airo_info*ai, StatusRid *statr) {	int rc = PC4500_readrid(ai, RID_STATUS, statr, sizeof(*statr));

⌨️ 快捷键说明

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