1
0
Fork 0

Staging: Add pristine upstream vt6655 driver sources

Add pristine upstream vt6655 driver sources to drivers/staging/vt6655.  These
files were literally copied from the driver directory in the upstream source
archive, available here:

  http://www.viaarena.com/Driver/vt6655_linux_src_v1.19.12_x86.zip

Signed-off-by: Forest Bond <forest@alittletooquiet.net>
Signed-off-by: Greg Kroah-Hartman <gregkh@suse.de>
hifive-unleashed-5.1
Forest Bond 2009-04-25 10:30:44 -04:00 committed by Greg Kroah-Hartman
parent be2e10710b
commit 5449c685a4
78 changed files with 49521 additions and 0 deletions

View File

@ -0,0 +1,357 @@
/*
* Copyright (c) 1996, 2003 VIA Networking Technologies, Inc.
* All rights reserved.
*
* This program is free software; you can redistribute it and/or modify
* it under the terms of the GNU General Public License as published by
* the Free Software Foundation; either version 2 of the License, or
* (at your option) any later version.
*
* This program is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
* GNU General Public License for more details.
*
* You should have received a copy of the GNU General Public License along
* with this program; if not, write to the Free Software Foundation, Inc.,
* 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA.
*
* File: 80211hdr.h
*
* Purpose: Defines the macros, types, and functions for dealing
* with 802.11 MAC headers.
*
* Author: Lyndon Chen
*
* Date: Apr 8, 2002
*
*/
#ifndef __80211HDR_H__
#define __80211HDR_H__
#if !defined(__TTYPE_H__)
#include "ttype.h"
#endif
/*--------------------- Export Definitions -------------------------*/
// bit type
#define BIT0 0x00000001
#define BIT1 0x00000002
#define BIT2 0x00000004
#define BIT3 0x00000008
#define BIT4 0x00000010
#define BIT5 0x00000020
#define BIT6 0x00000040
#define BIT7 0x00000080
#define BIT8 0x00000100
#define BIT9 0x00000200
#define BIT10 0x00000400
#define BIT11 0x00000800
#define BIT12 0x00001000
#define BIT13 0x00002000
#define BIT14 0x00004000
#define BIT15 0x00008000
#define BIT16 0x00010000
#define BIT17 0x00020000
#define BIT18 0x00040000
#define BIT19 0x00080000
#define BIT20 0x00100000
#define BIT21 0x00200000
#define BIT22 0x00400000
#define BIT23 0x00800000
#define BIT24 0x01000000
#define BIT25 0x02000000
#define BIT26 0x04000000
#define BIT27 0x08000000
#define BIT28 0x10000000
#define BIT29 0x20000000
#define BIT30 0x40000000
#define BIT31 0x80000000
// 802.11 frame related, defined as 802.11 spec
#define WLAN_ADDR_LEN 6
#define WLAN_CRC_LEN 4
#define WLAN_CRC32_LEN 4
#define WLAN_FCS_LEN 4
#define WLAN_BSSID_LEN 6
#define WLAN_BSS_TS_LEN 8
#define WLAN_HDR_ADDR2_LEN 16
#define WLAN_HDR_ADDR3_LEN 24
#define WLAN_HDR_ADDR4_LEN 30
#define WLAN_IEHDR_LEN 2
#define WLAN_SSID_MAXLEN 32
//#define WLAN_RATES_MAXLEN 255
#define WLAN_RATES_MAXLEN 16
#define WLAN_RATES_MAXLEN_11B 4
#define WLAN_RSN_MAXLEN 32
#define WLAN_DATA_MAXLEN 2312
#define WLAN_A3FR_MAXLEN (WLAN_HDR_ADDR3_LEN + WLAN_DATA_MAXLEN + WLAN_CRC_LEN)
#define WLAN_BEACON_FR_MAXLEN WLAN_A3FR_MAXLEN
#define WLAN_ATIM_FR_MAXLEN (WLAN_HDR_ADDR3_LEN + 0)
#define WLAN_NULLDATA_FR_MAXLEN (WLAN_HDR_ADDR3_LEN + 0)
#define WLAN_DISASSOC_FR_MAXLEN (WLAN_HDR_ADDR3_LEN + 2)
#define WLAN_ASSOCREQ_FR_MAXLEN WLAN_A3FR_MAXLEN
#define WLAN_ASSOCRESP_FR_MAXLEN WLAN_A3FR_MAXLEN
#define WLAN_REASSOCREQ_FR_MAXLEN WLAN_A3FR_MAXLEN
#define WLAN_REASSOCRESP_FR_MAXLEN WLAN_A3FR_MAXLEN
#define WLAN_PROBEREQ_FR_MAXLEN WLAN_A3FR_MAXLEN
#define WLAN_PROBERESP_FR_MAXLEN WLAN_A3FR_MAXLEN
#define WLAN_AUTHEN_FR_MAXLEN WLAN_A3FR_MAXLEN
#define WLAN_DEAUTHEN_FR_MAXLEN (WLAN_HDR_ADDR3_LEN + 2)
#define WLAN_WEP_NKEYS 4
#define WLAN_WEP40_KEYLEN 5
#define WLAN_WEP104_KEYLEN 13
#define WLAN_WEP232_KEYLEN 29
//#define WLAN_WEPMAX_KEYLEN 29
#define WLAN_WEPMAX_KEYLEN 32
#define WLAN_CHALLENGE_IE_MAXLEN 255
#define WLAN_CHALLENGE_IE_LEN 130
#define WLAN_CHALLENGE_LEN 128
#define WLAN_WEP_IV_LEN 4
#define WLAN_WEP_ICV_LEN 4
#define WLAN_FRAGS_MAX 16
// Frame Type
#define WLAN_TYPE_MGR 0x00
#define WLAN_TYPE_CTL 0x01
#define WLAN_TYPE_DATA 0x02
#define WLAN_FTYPE_MGMT 0x00
#define WLAN_FTYPE_CTL 0x01
#define WLAN_FTYPE_DATA 0x02
// Frame Subtypes
#define WLAN_FSTYPE_ASSOCREQ 0x00
#define WLAN_FSTYPE_ASSOCRESP 0x01
#define WLAN_FSTYPE_REASSOCREQ 0x02
#define WLAN_FSTYPE_REASSOCRESP 0x03
#define WLAN_FSTYPE_PROBEREQ 0x04
#define WLAN_FSTYPE_PROBERESP 0x05
#define WLAN_FSTYPE_BEACON 0x08
#define WLAN_FSTYPE_ATIM 0x09
#define WLAN_FSTYPE_DISASSOC 0x0a
#define WLAN_FSTYPE_AUTHEN 0x0b
#define WLAN_FSTYPE_DEAUTHEN 0x0c
#define WLAN_FSTYPE_ACTION 0x0d
// Control
#define WLAN_FSTYPE_PSPOLL 0x0a
#define WLAN_FSTYPE_RTS 0x0b
#define WLAN_FSTYPE_CTS 0x0c
#define WLAN_FSTYPE_ACK 0x0d
#define WLAN_FSTYPE_CFEND 0x0e
#define WLAN_FSTYPE_CFENDCFACK 0x0f
// Data
#define WLAN_FSTYPE_DATAONLY 0x00
#define WLAN_FSTYPE_DATA_CFACK 0x01
#define WLAN_FSTYPE_DATA_CFPOLL 0x02
#define WLAN_FSTYPE_DATA_CFACK_CFPOLL 0x03
#define WLAN_FSTYPE_NULL 0x04
#define WLAN_FSTYPE_CFACK 0x05
#define WLAN_FSTYPE_CFPOLL 0x06
#define WLAN_FSTYPE_CFACK_CFPOLL 0x07
#ifdef __BIG_ENDIAN
// GET & SET Frame Control bit
#define WLAN_GET_FC_PRVER(n) ((((WORD)(n) >> 8) & (BIT0 | BIT1))
#define WLAN_GET_FC_FTYPE(n) ((((WORD)(n) >> 8) & (BIT2 | BIT3)) >> 2)
#define WLAN_GET_FC_FSTYPE(n) ((((WORD)(n) >> 8) & (BIT4|BIT5|BIT6|BIT7)) >> 4)
#define WLAN_GET_FC_TODS(n) ((((WORD)(n) << 8) & (BIT8)) >> 8)
#define WLAN_GET_FC_FROMDS(n) ((((WORD)(n) << 8) & (BIT9)) >> 9)
#define WLAN_GET_FC_MOREFRAG(n) ((((WORD)(n) << 8) & (BIT10)) >> 10)
#define WLAN_GET_FC_RETRY(n) ((((WORD)(n) << 8) & (BIT11)) >> 11)
#define WLAN_GET_FC_PWRMGT(n) ((((WORD)(n) << 8) & (BIT12)) >> 12)
#define WLAN_GET_FC_MOREDATA(n) ((((WORD)(n) << 8) & (BIT13)) >> 13)
#define WLAN_GET_FC_ISWEP(n) ((((WORD)(n) << 8) & (BIT14)) >> 14)
#define WLAN_GET_FC_ORDER(n) ((((WORD)(n) << 8) & (BIT15)) >> 15)
// Sequence Field bit
#define WLAN_GET_SEQ_FRGNUM(n) (((WORD)(n) >> 8) & (BIT0|BIT1|BIT2|BIT3))
#define WLAN_GET_SEQ_SEQNUM(n) ((((WORD)(n) >> 8) & (~(BIT0|BIT1|BIT2|BIT3))) >> 4)
// Capability Field bit
#define WLAN_GET_CAP_INFO_ESS(n) (((n) >> 8) & BIT0)
#define WLAN_GET_CAP_INFO_IBSS(n) ((((n) >> 8) & BIT1) >> 1)
#define WLAN_GET_CAP_INFO_CFPOLLABLE(n) ((((n) >> 8) & BIT2) >> 2)
#define WLAN_GET_CAP_INFO_CFPOLLREQ(n) ((((n) >> 8) & BIT3) >> 3)
#define WLAN_GET_CAP_INFO_PRIVACY(n) ((((n) >> 8) & BIT4) >> 4)
#define WLAN_GET_CAP_INFO_SHORTPREAMBLE(n) ((((n) >> 8) & BIT5) >> 5)
#define WLAN_GET_CAP_INFO_PBCC(n) ((((n) >> 8) & BIT6) >> 6)
#define WLAN_GET_CAP_INFO_AGILITY(n) ((((n) >> 8) & BIT7) >> 7)
#define WLAN_GET_CAP_INFO_SPECTRUMMNG(n) ((((n)) & BIT8) >> 10)
#define WLAN_GET_CAP_INFO_SHORTSLOTTIME(n) ((((n)) & BIT10) >> 10)
#define WLAN_GET_CAP_INFO_DSSSOFDM(n) ((((n)) & BIT13) >> 13)
#define WLAN_GET_CAP_INFO_GRPACK(n) ((((n)) & BIT14) >> 14)
#else
// GET & SET Frame Control bit
#define WLAN_GET_FC_PRVER(n) (((WORD)(n)) & (BIT0 | BIT1))
#define WLAN_GET_FC_FTYPE(n) ((((WORD)(n)) & (BIT2 | BIT3)) >> 2)
#define WLAN_GET_FC_FSTYPE(n) ((((WORD)(n)) & (BIT4|BIT5|BIT6|BIT7)) >> 4)
#define WLAN_GET_FC_TODS(n) ((((WORD)(n)) & (BIT8)) >> 8)
#define WLAN_GET_FC_FROMDS(n) ((((WORD)(n)) & (BIT9)) >> 9)
#define WLAN_GET_FC_MOREFRAG(n) ((((WORD)(n)) & (BIT10)) >> 10)
#define WLAN_GET_FC_RETRY(n) ((((WORD)(n)) & (BIT11)) >> 11)
#define WLAN_GET_FC_PWRMGT(n) ((((WORD)(n)) & (BIT12)) >> 12)
#define WLAN_GET_FC_MOREDATA(n) ((((WORD)(n)) & (BIT13)) >> 13)
#define WLAN_GET_FC_ISWEP(n) ((((WORD)(n)) & (BIT14)) >> 14)
#define WLAN_GET_FC_ORDER(n) ((((WORD)(n)) & (BIT15)) >> 15)
// Sequence Field bit
#define WLAN_GET_SEQ_FRGNUM(n) (((WORD)(n)) & (BIT0|BIT1|BIT2|BIT3))
#define WLAN_GET_SEQ_SEQNUM(n) ((((WORD)(n)) & (~(BIT0|BIT1|BIT2|BIT3))) >> 4)
// Capability Field bit
#define WLAN_GET_CAP_INFO_ESS(n) ((n) & BIT0)
#define WLAN_GET_CAP_INFO_IBSS(n) (((n) & BIT1) >> 1)
#define WLAN_GET_CAP_INFO_CFPOLLABLE(n) (((n) & BIT2) >> 2)
#define WLAN_GET_CAP_INFO_CFPOLLREQ(n) (((n) & BIT3) >> 3)
#define WLAN_GET_CAP_INFO_PRIVACY(n) (((n) & BIT4) >> 4)
#define WLAN_GET_CAP_INFO_SHORTPREAMBLE(n) (((n) & BIT5) >> 5)
#define WLAN_GET_CAP_INFO_PBCC(n) (((n) & BIT6) >> 6)
#define WLAN_GET_CAP_INFO_AGILITY(n) (((n) & BIT7) >> 7)
#define WLAN_GET_CAP_INFO_SPECTRUMMNG(n) (((n) & BIT8) >> 10)
#define WLAN_GET_CAP_INFO_SHORTSLOTTIME(n) (((n) & BIT10) >> 10)
#define WLAN_GET_CAP_INFO_DSSSOFDM(n) (((n) & BIT13) >> 13)
#define WLAN_GET_CAP_INFO_GRPACK(n) (((n) & BIT14) >> 14)
#endif //#ifdef __BIG_ENDIAN
#define WLAN_SET_CAP_INFO_ESS(n) (n)
#define WLAN_SET_CAP_INFO_IBSS(n) ((n) << 1)
#define WLAN_SET_CAP_INFO_CFPOLLABLE(n) ((n) << 2)
#define WLAN_SET_CAP_INFO_CFPOLLREQ(n) ((n) << 3)
#define WLAN_SET_CAP_INFO_PRIVACY(n) ((n) << 4)
#define WLAN_SET_CAP_INFO_SHORTPREAMBLE(n) ((n) << 5)
#define WLAN_SET_CAP_INFO_SPECTRUMMNG(n) ((n) << 8)
#define WLAN_SET_CAP_INFO_PBCC(n) ((n) << 6)
#define WLAN_SET_CAP_INFO_AGILITY(n) ((n) << 7)
#define WLAN_SET_CAP_INFO_SHORTSLOTTIME(n) ((n) << 10)
#define WLAN_SET_CAP_INFO_DSSSOFDM(n) ((n) << 13)
#define WLAN_SET_CAP_INFO_GRPACK(n) ((n) << 14)
#define WLAN_SET_FC_PRVER(n) ((WORD)(n))
#define WLAN_SET_FC_FTYPE(n) (((WORD)(n)) << 2)
#define WLAN_SET_FC_FSTYPE(n) (((WORD)(n)) << 4)
#define WLAN_SET_FC_TODS(n) (((WORD)(n)) << 8)
#define WLAN_SET_FC_FROMDS(n) (((WORD)(n)) << 9)
#define WLAN_SET_FC_MOREFRAG(n) (((WORD)(n)) << 10)
#define WLAN_SET_FC_RETRY(n) (((WORD)(n)) << 11)
#define WLAN_SET_FC_PWRMGT(n) (((WORD)(n)) << 12)
#define WLAN_SET_FC_MOREDATA(n) (((WORD)(n)) << 13)
#define WLAN_SET_FC_ISWEP(n) (((WORD)(n)) << 14)
#define WLAN_SET_FC_ORDER(n) (((WORD)(n)) << 15)
#define WLAN_SET_SEQ_FRGNUM(n) ((WORD)(n))
#define WLAN_SET_SEQ_SEQNUM(n) (((WORD)(n)) << 4)
// ERP Field bit
#define WLAN_GET_ERP_NONERP_PRESENT(n) ((n) & BIT0)
#define WLAN_GET_ERP_USE_PROTECTION(n) (((n) & BIT1) >> 1)
#define WLAN_GET_ERP_BARKER_MODE(n) (((n) & BIT2) >> 2)
#define WLAN_SET_ERP_NONERP_PRESENT(n) (n)
#define WLAN_SET_ERP_USE_PROTECTION(n) ((n) << 1)
#define WLAN_SET_ERP_BARKER_MODE(n) ((n) << 2)
// Support & Basic Rates field
#define WLAN_MGMT_IS_BASICRATE(b) ((b) & BIT7)
#define WLAN_MGMT_GET_RATE(b) ((b) & ~BIT7)
// TIM field
#define WLAN_MGMT_IS_MULTICAST_TIM(b) ((b) & BIT0)
#define WLAN_MGMT_GET_TIM_OFFSET(b) (((b) & ~BIT0) >> 1)
// 3-Addr & 4-Addr
#define WLAN_HDR_A3_DATA_PTR(p) (((PBYTE)(p)) + WLAN_HDR_ADDR3_LEN)
#define WLAN_HDR_A4_DATA_PTR(p) (((PBYTE)(p)) + WLAN_HDR_ADDR4_LEN)
// IEEE ADDR
#define IEEE_ADDR_UNIVERSAL 0x02
#define IEEE_ADDR_GROUP 0x01
typedef struct {
BYTE abyAddr[6];
} IEEE_ADDR, *PIEEE_ADDR;
// 802.11 Header Format
typedef struct tagWLAN_80211HDR_A2 {
WORD wFrameCtl;
WORD wDurationID;
BYTE abyAddr1[WLAN_ADDR_LEN];
BYTE abyAddr2[WLAN_ADDR_LEN];
}__attribute__ ((__packed__))
WLAN_80211HDR_A2, *PWLAN_80211HDR_A2;
typedef struct tagWLAN_80211HDR_A3 {
WORD wFrameCtl;
WORD wDurationID;
BYTE abyAddr1[WLAN_ADDR_LEN];
BYTE abyAddr2[WLAN_ADDR_LEN];
BYTE abyAddr3[WLAN_ADDR_LEN];
WORD wSeqCtl;
}__attribute__ ((__packed__))
WLAN_80211HDR_A3, *PWLAN_80211HDR_A3;
typedef struct tagWLAN_80211HDR_A4 {
WORD wFrameCtl;
WORD wDurationID;
BYTE abyAddr1[WLAN_ADDR_LEN];
BYTE abyAddr2[WLAN_ADDR_LEN];
BYTE abyAddr3[WLAN_ADDR_LEN];
WORD wSeqCtl;
BYTE abyAddr4[WLAN_ADDR_LEN];
}__attribute__ ((__packed__))
WLAN_80211HDR_A4, *PWLAN_80211HDR_A4;
typedef union tagUWLAN_80211HDR {
WLAN_80211HDR_A2 sA2;
WLAN_80211HDR_A3 sA3;
WLAN_80211HDR_A4 sA4;
} UWLAN_80211HDR, *PUWLAN_80211HDR;
/*--------------------- Export Classes ----------------------------*/
/*--------------------- Export Variables --------------------------*/
/*--------------------- Export Functions --------------------------*/
#endif // __80211HDR_H__

File diff suppressed because it is too large Load Diff

View File

@ -0,0 +1,832 @@
/*
* Copyright (c) 1996, 2003 VIA Networking Technologies, Inc.
* All rights reserved.
*
* This program is free software; you can redistribute it and/or modify
* it under the terms of the GNU General Public License as published by
* the Free Software Foundation; either version 2 of the License, or
* (at your option) any later version.
*
* This program is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
* GNU General Public License for more details.
*
* You should have received a copy of the GNU General Public License along
* with this program; if not, write to the Free Software Foundation, Inc.,
* 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA.
*
* File: 80211mgr.h
*
* Purpose: Defines the macros, types, and functions for dealing
* with 802.11 managment frames.
*
* Author: Lyndon Chen
*
* Date: May 8, 2002
*
*/
#ifndef __80211MGR_H__
#define __80211MGR_H__
#if !defined(__TTYPE_H__)
#include "ttype.h"
#endif
#if !defined(__80211HDR_H__)
#include "80211hdr.h"
#endif
/*--------------------- Export Definitions -------------------------*/
#define WLAN_MIN_ARRAY 1
// Information Element ID value
#define WLAN_EID_SSID 0
#define WLAN_EID_SUPP_RATES 1
#define WLAN_EID_FH_PARMS 2
#define WLAN_EID_DS_PARMS 3
#define WLAN_EID_CF_PARMS 4
#define WLAN_EID_TIM 5
#define WLAN_EID_IBSS_PARMS 6
#define WLAN_EID_COUNTRY 7
#define WLAN_EID_CHALLENGE 16
#define WLAN_EID_PWR_CONSTRAINT 32
#define WLAN_EID_PWR_CAPABILITY 33
#define WLAN_EID_TPC_REQ 34
#define WLAN_EID_TPC_REP 35
#define WLAN_EID_SUPP_CH 36
#define WLAN_EID_CH_SWITCH 37
#define WLAN_EID_MEASURE_REQ 38
#define WLAN_EID_MEASURE_REP 39
#define WLAN_EID_QUIET 40
#define WLAN_EID_IBSS_DFS 41
#define WLAN_EID_ERP 42
// reference 802.11i 7.3.2 table 20
#define WLAN_EID_RSN 48
#define WLAN_EID_EXTSUPP_RATES 50
// reference WiFi WPA spec.
#define WLAN_EID_RSN_WPA 221
#define WLAN_EID_ERP_NONERP_PRESENT 0x01
#define WLAN_EID_ERP_USE_PROTECTION 0x02
#define WLAN_EID_ERP_BARKER_MODE 0x04
// Reason Codes
#define WLAN_MGMT_REASON_RSVD 0
#define WLAN_MGMT_REASON_UNSPEC 1
#define WLAN_MGMT_REASON_PRIOR_AUTH_INVALID 2
#define WLAN_MGMT_REASON_DEAUTH_LEAVING 3
#define WLAN_MGMT_REASON_DISASSOC_INACTIVE 4
#define WLAN_MGMT_REASON_DISASSOC_AP_BUSY 5
#define WLAN_MGMT_REASON_CLASS2_NONAUTH 6
#define WLAN_MGMT_REASON_CLASS3_NONASSOC 7
#define WLAN_MGMT_REASON_DISASSOC_STA_HASLEFT 8
#define WLAN_MGMT_REASON_CANT_ASSOC_NONAUTH 9
#define WLAN_MGMT_REASON_DISASSOC_PWR_CAP_UNACCEPT 10
#define WLAN_MGMT_REASON_DISASSOC_SUPP_CH_UNACCEPT 11
#define WLAN_MGMT_REASON_INVALID_IE 13
#define WLAN_MGMT_REASON_MIC_FAILURE 14
#define WLAN_MGMT_REASON_4WAY_HANDSHAKE_TIMEOUT 15
#define WLAN_MGMT_REASON_GRPKEY_UPDATE_TIMEOUT 16
#define WLAN_MGMT_REASON_4WAY_INFO_DIFFERENT 17
#define WLAN_MGMT_REASON_MULTCAST_CIPHER_INVALID 18
#define WLAN_MGMT_REASON_UNCAST_CIPHER_INVALID 19
#define WLAN_MGMT_REASON_AKMP_INVALID 20
#define WLAN_MGMT_REASON_RSNE_UNSUPPORTED 21
#define WLAN_MGMT_REASON_RSNE_CAP_INVALID 22
#define WLAN_MGMT_REASON_80211X_AUTH_FAILED 23
// Status Codes
#define WLAN_MGMT_STATUS_SUCCESS 0
#define WLAN_MGMT_STATUS_UNSPEC_FAILURE 1
#define WLAN_MGMT_STATUS_CAPS_UNSUPPORTED 10
#define WLAN_MGMT_STATUS_REASSOC_NO_ASSOC 11
#define WLAN_MGMT_STATUS_ASSOC_DENIED_UNSPEC 12
#define WLAN_MGMT_STATUS_UNSUPPORTED_AUTHALG 13
#define WLAN_MGMT_STATUS_RX_AUTH_NOSEQ 14
#define WLAN_MGMT_STATUS_CHALLENGE_FAIL 15
#define WLAN_MGMT_STATUS_AUTH_TIMEOUT 16
#define WLAN_MGMT_STATUS_ASSOC_DENIED_BUSY 17
#define WLAN_MGMT_STATUS_ASSOC_DENIED_RATES 18
#define WLAN_MGMT_STATUS_ASSOC_DENIED_SHORTPREAMBLE 19
#define WLAN_MGMT_STATUS_ASSOC_DENIED_PBCC 20
#define WLAN_MGMT_STATUS_ASSOC_DENIED_AGILITY 21
// reference 802.11h 7.3.1.9
//
#define WLAN_MGMT_STATUS_ASSOC_REJECT_BCS_SPECTRUM_MNG 22
#define WLAN_MGMT_STATUS_ASSOC_REJECT_BCS_PWR_CAP 23
#define WLAN_MGMT_STATUS_ASSOC_REJECT_BCS_SUPP_CH 24
//
// reference 802.11g 7.3.1.9
//
#define WLAN_MGMT_STATUS_SHORTSLOTTIME_UNSUPPORTED 25
#define WLAN_MGMT_STATUS_DSSSOFDM_UNSUPPORTED 26
//
// reference 802.11i 7.3.1.9 table 19
//
#define WLAN_MGMT_STATUS_INVALID_IE 40
#define WLAN_MGMT_STATUS_GROUP_CIPHER_INVALID 41
#define WLAN_MGMT_STATUS_PAIRWISE_CIPHER_INVALID 42
#define WLAN_MGMT_STATUS_AKMP_INVALID 43
#define WLAN_MGMT_STATUS_UNSUPPORT_RSN_IE_VER 44
#define WLAN_MGMT_STATUS_INVALID_RSN_IE_CAP 45
#define WLAN_MGMT_STATUS_CIPHER_REJECT 46
// Auth Algorithm
#define WLAN_AUTH_ALG_OPENSYSTEM 0
#define WLAN_AUTH_ALG_SHAREDKEY 1
// Management Frame Field Offsets
// Note: Not all fields are listed because of variable lengths.
// Note: These offsets are from the start of the frame data
#define WLAN_BEACON_OFF_TS 0
#define WLAN_BEACON_OFF_BCN_INT 8
#define WLAN_BEACON_OFF_CAPINFO 10
#define WLAN_BEACON_OFF_SSID 12
#define WLAN_DISASSOC_OFF_REASON 0
#define WLAN_ASSOCREQ_OFF_CAP_INFO 0
#define WLAN_ASSOCREQ_OFF_LISTEN_INT 2
#define WLAN_ASSOCREQ_OFF_SSID 4
#define WLAN_ASSOCRESP_OFF_CAP_INFO 0
#define WLAN_ASSOCRESP_OFF_STATUS 2
#define WLAN_ASSOCRESP_OFF_AID 4
#define WLAN_ASSOCRESP_OFF_SUPP_RATES 6
#define WLAN_REASSOCREQ_OFF_CAP_INFO 0
#define WLAN_REASSOCREQ_OFF_LISTEN_INT 2
#define WLAN_REASSOCREQ_OFF_CURR_AP 4
#define WLAN_REASSOCREQ_OFF_SSID 10
#define WLAN_REASSOCRESP_OFF_CAP_INFO 0
#define WLAN_REASSOCRESP_OFF_STATUS 2
#define WLAN_REASSOCRESP_OFF_AID 4
#define WLAN_REASSOCRESP_OFF_SUPP_RATES 6
#define WLAN_PROBEREQ_OFF_SSID 0
#define WLAN_PROBERESP_OFF_TS 0
#define WLAN_PROBERESP_OFF_BCN_INT 8
#define WLAN_PROBERESP_OFF_CAP_INFO 10
#define WLAN_PROBERESP_OFF_SSID 12
#define WLAN_AUTHEN_OFF_AUTH_ALG 0
#define WLAN_AUTHEN_OFF_AUTH_SEQ 2
#define WLAN_AUTHEN_OFF_STATUS 4
#define WLAN_AUTHEN_OFF_CHALLENGE 6
#define WLAN_DEAUTHEN_OFF_REASON 0
//
// Cipher Suite Selectors defiened in 802.11i
//
#define WLAN_11i_CSS_USE_GROUP 0
#define WLAN_11i_CSS_WEP40 1
#define WLAN_11i_CSS_TKIP 2
#define WLAN_11i_CSS_CCMP 4
#define WLAN_11i_CSS_WEP104 5
#define WLAN_11i_CSS_UNKNOWN 255
//
// Authentication and Key Management Suite Selectors defined in 802.11i
//
#define WLAN_11i_AKMSS_802_1X 1
#define WLAN_11i_AKMSS_PSK 2
#define WLAN_11i_AKMSS_UNKNOWN 255
// Measurement type definitions reference ieee 802.11h Table 20b
#define MEASURE_TYPE_BASIC 0
#define MEASURE_TYPE_CCA 1
#define MEASURE_TYPE_RPI 2
// Measurement request mode definitions reference ieee 802.11h Figure 46h
#define MEASURE_MODE_ENABLE 0x02
#define MEASURE_MODE_REQ 0x04
#define MEASURE_MODE_REP 0x08
// Measurement report mode definitions reference ieee 802.11h Figure 46m
#define MEASURE_MODE_LATE 0x01
#define MEASURE_MODE_INCAPABLE 0x02
#define MEASURE_MODE_REFUSED 0x04
/*--------------------- Export Classes ----------------------------*/
/*--------------------- Export Variables --------------------------*/
/*--------------------- Export Types ------------------------------*/
// Information Element Types
#pragma pack(1)
typedef struct tagWLAN_IE {
BYTE byElementID;
BYTE len;
}__attribute__ ((__packed__))
WLAN_IE, *PWLAN_IE;
// Service Set Identity (SSID)
#pragma pack(1)
typedef struct tagWLAN_IE_SSID {
BYTE byElementID;
BYTE len;
BYTE abySSID[1];
}__attribute__ ((__packed__))
WLAN_IE_SSID, *PWLAN_IE_SSID;
// Supported Rates
#pragma pack(1)
typedef struct tagWLAN_IE_SUPP_RATES {
BYTE byElementID;
BYTE len;
BYTE abyRates[1];
}__attribute__ ((__packed__))
WLAN_IE_SUPP_RATES, *PWLAN_IE_SUPP_RATES;
// FH Parameter Set
#pragma pack(1)
typedef struct _WLAN_IE_FH_PARMS {
BYTE byElementID;
BYTE len;
WORD wDwellTime;
BYTE byHopSet;
BYTE byHopPattern;
BYTE byHopIndex;
} WLAN_IE_FH_PARMS, *PWLAN_IE_FH_PARMS;
// DS Parameter Set
#pragma pack(1)
typedef struct tagWLAN_IE_DS_PARMS {
BYTE byElementID;
BYTE len;
BYTE byCurrChannel;
}__attribute__ ((__packed__))
WLAN_IE_DS_PARMS, *PWLAN_IE_DS_PARMS;
// CF Parameter Set
#pragma pack(1)
typedef struct tagWLAN_IE_CF_PARMS {
BYTE byElementID;
BYTE len;
BYTE byCFPCount;
BYTE byCFPPeriod;
WORD wCFPMaxDuration;
WORD wCFPDurRemaining;
}__attribute__ ((__packed__))
WLAN_IE_CF_PARMS, *PWLAN_IE_CF_PARMS;
// TIM
#pragma pack(1)
typedef struct tagWLAN_IE_TIM {
BYTE byElementID;
BYTE len;
BYTE byDTIMCount;
BYTE byDTIMPeriod;
BYTE byBitMapCtl;
BYTE byVirtBitMap[1];
}__attribute__ ((__packed__))
WLAN_IE_TIM, *PWLAN_IE_TIM;
// IBSS Parameter Set
#pragma pack(1)
typedef struct tagWLAN_IE_IBSS_PARMS {
BYTE byElementID;
BYTE len;
WORD wATIMWindow;
}__attribute__ ((__packed__))
WLAN_IE_IBSS_PARMS, *PWLAN_IE_IBSS_PARMS;
// Challenge Text
#pragma pack(1)
typedef struct tagWLAN_IE_CHALLENGE {
BYTE byElementID;
BYTE len;
BYTE abyChallenge[1];
}__attribute__ ((__packed__))
WLAN_IE_CHALLENGE, *PWLAN_IE_CHALLENGE;
#pragma pack(1)
typedef struct tagWLAN_IE_RSN_EXT {
BYTE byElementID;
BYTE len;
BYTE abyOUI[4];
WORD wVersion;
BYTE abyMulticast[4];
WORD wPKCount;
struct {
BYTE abyOUI[4];
} PKSList[1]; // the rest is variable so need to
// overlay ieauth structure
} WLAN_IE_RSN_EXT, *PWLAN_IE_RSN_EXT;
#pragma pack(1)
typedef struct tagWLAN_IE_RSN_AUTH {
WORD wAuthCount;
struct {
BYTE abyOUI[4];
} AuthKSList[1];
} WLAN_IE_RSN_AUTH, *PWLAN_IE_RSN_AUTH;
// RSN Identity
#pragma pack(1)
typedef struct tagWLAN_IE_RSN {
BYTE byElementID;
BYTE len;
WORD wVersion;
BYTE abyRSN[WLAN_MIN_ARRAY];
} WLAN_IE_RSN, *PWLAN_IE_RSN;
// ERP
#pragma pack(1)
typedef struct tagWLAN_IE_ERP {
BYTE byElementID;
BYTE len;
BYTE byContext;
}__attribute__ ((__packed__))
WLAN_IE_ERP, *PWLAN_IE_ERP;
#pragma pack(1)
typedef struct _MEASEURE_REQ {
BYTE byChannel;
BYTE abyStartTime[8];
BYTE abyDuration[2];
} MEASEURE_REQ, *PMEASEURE_REQ,
MEASEURE_REQ_BASIC, *PMEASEURE_REQ_BASIC,
MEASEURE_REQ_CCA, *PMEASEURE_REQ_CCA,
MEASEURE_REQ_RPI, *PMEASEURE_REQ_RPI;
typedef struct _MEASEURE_REP_BASIC {
BYTE byChannel;
BYTE abyStartTime[8];
BYTE abyDuration[2];
BYTE byMap;
} MEASEURE_REP_BASIC, *PMEASEURE_REP_BASIC;
typedef struct _MEASEURE_REP_CCA {
BYTE byChannel;
BYTE abyStartTime[8];
BYTE abyDuration[2];
BYTE byCCABusyFraction;
} MEASEURE_REP_CCA, *PMEASEURE_REP_CCA;
typedef struct _MEASEURE_REP_RPI {
BYTE byChannel;
BYTE abyStartTime[8];
BYTE abyDuration[2];
BYTE abyRPIdensity[8];
} MEASEURE_REP_RPI, *PMEASEURE_REP_RPI;
typedef union _MEASEURE_REP {
MEASEURE_REP_BASIC sBasic;
MEASEURE_REP_CCA sCCA;
MEASEURE_REP_RPI sRPI;
} MEASEURE_REP, *PMEASEURE_REP;
typedef struct _WLAN_IE_MEASURE_REQ {
BYTE byElementID;
BYTE len;
BYTE byToken;
BYTE byMode;
BYTE byType;
MEASEURE_REQ sReq;
} WLAN_IE_MEASURE_REQ, *PWLAN_IE_MEASURE_REQ;
typedef struct _WLAN_IE_MEASURE_REP {
BYTE byElementID;
BYTE len;
BYTE byToken;
BYTE byMode;
BYTE byType;
MEASEURE_REP sRep;
} WLAN_IE_MEASURE_REP, *PWLAN_IE_MEASURE_REP;
typedef struct _WLAN_IE_CH_SW {
BYTE byElementID;
BYTE len;
BYTE byMode;
BYTE byChannel;
BYTE byCount;
} WLAN_IE_CH_SW, *PWLAN_IE_CH_SW;
typedef struct _WLAN_IE_QUIET {
BYTE byElementID;
BYTE len;
BYTE byQuietCount;
BYTE byQuietPeriod;
BYTE abyQuietDuration[2];
BYTE abyQuietOffset[2];
} WLAN_IE_QUIET, *PWLAN_IE_QUIET;
typedef struct _WLAN_IE_COUNTRY {
BYTE byElementID;
BYTE len;
BYTE abyCountryString[3];
BYTE abyCountryInfo[3];
} WLAN_IE_COUNTRY, *PWLAN_IE_COUNTRY;
typedef struct _WLAN_IE_PW_CONST {
BYTE byElementID;
BYTE len;
BYTE byPower;
} WLAN_IE_PW_CONST, *PWLAN_IE_PW_CONST;
typedef struct _WLAN_IE_PW_CAP {
BYTE byElementID;
BYTE len;
BYTE byMinPower;
BYTE byMaxPower;
} WLAN_IE_PW_CAP, *PWLAN_IE_PW_CAP;
typedef struct _WLAN_IE_SUPP_CH {
BYTE byElementID;
BYTE len;
BYTE abyChannelTuple[2];
} WLAN_IE_SUPP_CH, *PWLAN_IE_SUPP_CH;
typedef struct _WLAN_IE_TPC_REQ {
BYTE byElementID;
BYTE len;
} WLAN_IE_TPC_REQ, *PWLAN_IE_TPC_REQ;
typedef struct _WLAN_IE_TPC_REP {
BYTE byElementID;
BYTE len;
BYTE byTxPower;
BYTE byLinkMargin;
} WLAN_IE_TPC_REP, *PWLAN_IE_TPC_REP;
typedef struct _WLAN_IE_IBSS_DFS {
BYTE byElementID;
BYTE len;
BYTE abyDFSOwner[6];
BYTE byDFSRecovery;
BYTE abyChannelMap[2];
} WLAN_IE_IBSS_DFS, *PWLAN_IE_IBSS_DFS;
#pragma pack()
// Frame Types
// prototype structure, all mgmt frame types will start with these members
typedef struct tagWLAN_FR_MGMT {
UINT uType;
UINT len;
PBYTE pBuf;
PUWLAN_80211HDR pHdr;
} WLAN_FR_MGMT, *PWLAN_FR_MGMT;
// Beacon frame
typedef struct tagWLAN_FR_BEACON {
UINT uType;
UINT len;
PBYTE pBuf;
PUWLAN_80211HDR pHdr;
// fixed fields
PQWORD pqwTimestamp;
PWORD pwBeaconInterval;
PWORD pwCapInfo;
/*-- info elements ----------*/
PWLAN_IE_SSID pSSID;
PWLAN_IE_SUPP_RATES pSuppRates;
// PWLAN_IE_FH_PARMS pFHParms;
PWLAN_IE_DS_PARMS pDSParms;
PWLAN_IE_CF_PARMS pCFParms;
PWLAN_IE_TIM pTIM;
PWLAN_IE_IBSS_PARMS pIBSSParms;
PWLAN_IE_RSN pRSN;
PWLAN_IE_RSN_EXT pRSNWPA;
PWLAN_IE_ERP pERP;
PWLAN_IE_SUPP_RATES pExtSuppRates;
PWLAN_IE_COUNTRY pIE_Country;
PWLAN_IE_PW_CONST pIE_PowerConstraint;
PWLAN_IE_CH_SW pIE_CHSW;
PWLAN_IE_IBSS_DFS pIE_IBSSDFS;
PWLAN_IE_QUIET pIE_Quiet;
} WLAN_FR_BEACON, *PWLAN_FR_BEACON;
// IBSS ATIM frame
typedef struct tagWLAN_FR_IBSSATIM {
UINT uType;
UINT len;
PBYTE pBuf;
PUWLAN_80211HDR pHdr;
// fixed fields
// info elements
// this frame type has a null body
} WLAN_FR_IBSSATIM, *PWLAN_FR_IBSSATIM;
// Disassociation
typedef struct tagWLAN_FR_DISASSOC {
UINT uType;
UINT len;
PBYTE pBuf;
PUWLAN_80211HDR pHdr;
/*-- fixed fields -----------*/
PWORD pwReason;
/*-- info elements ----------*/
} WLAN_FR_DISASSOC, *PWLAN_FR_DISASSOC;
// Association Request
typedef struct tagWLAN_FR_ASSOCREQ {
UINT uType;
UINT len;
PBYTE pBuf;
PUWLAN_80211HDR pHdr;
/*-- fixed fields -----------*/
PWORD pwCapInfo;
PWORD pwListenInterval;
/*-- info elements ----------*/
PWLAN_IE_SSID pSSID;
PWLAN_IE_SUPP_RATES pSuppRates;
PWLAN_IE_RSN pRSN;
PWLAN_IE_RSN_EXT pRSNWPA;
PWLAN_IE_SUPP_RATES pExtSuppRates;
PWLAN_IE_PW_CAP pCurrPowerCap;
PWLAN_IE_SUPP_CH pCurrSuppCh;
} WLAN_FR_ASSOCREQ, *PWLAN_FR_ASSOCREQ;
// Association Response
typedef struct tagWLAN_FR_ASSOCRESP {
UINT uType;
UINT len;
PBYTE pBuf;
PUWLAN_80211HDR pHdr;
/*-- fixed fields -----------*/
PWORD pwCapInfo;
PWORD pwStatus;
PWORD pwAid;
/*-- info elements ----------*/
PWLAN_IE_SUPP_RATES pSuppRates;
PWLAN_IE_SUPP_RATES pExtSuppRates;
} WLAN_FR_ASSOCRESP, *PWLAN_FR_ASSOCRESP;
// Reassociation Request
typedef struct tagWLAN_FR_REASSOCREQ {
UINT uType;
UINT len;
PBYTE pBuf;
PUWLAN_80211HDR pHdr;
/*-- fixed fields -----------*/
PWORD pwCapInfo;
PWORD pwListenInterval;
PIEEE_ADDR pAddrCurrAP;
/*-- info elements ----------*/
PWLAN_IE_SSID pSSID;
PWLAN_IE_SUPP_RATES pSuppRates;
PWLAN_IE_RSN pRSN;
PWLAN_IE_RSN_EXT pRSNWPA;
PWLAN_IE_SUPP_RATES pExtSuppRates;
} WLAN_FR_REASSOCREQ, *PWLAN_FR_REASSOCREQ;
// Reassociation Response
typedef struct tagWLAN_FR_REASSOCRESP {
UINT uType;
UINT len;
PBYTE pBuf;
PUWLAN_80211HDR pHdr;
/*-- fixed fields -----------*/
PWORD pwCapInfo;
PWORD pwStatus;
PWORD pwAid;
/*-- info elements ----------*/
PWLAN_IE_SUPP_RATES pSuppRates;
PWLAN_IE_SUPP_RATES pExtSuppRates;
} WLAN_FR_REASSOCRESP, *PWLAN_FR_REASSOCRESP;
// Probe Request
typedef struct tagWLAN_FR_PROBEREQ {
UINT uType;
UINT len;
PBYTE pBuf;
PUWLAN_80211HDR pHdr;
/*-- fixed fields -----------*/
/*-- info elements ----------*/
PWLAN_IE_SSID pSSID;
PWLAN_IE_SUPP_RATES pSuppRates;
PWLAN_IE_SUPP_RATES pExtSuppRates;
} WLAN_FR_PROBEREQ, *PWLAN_FR_PROBEREQ;
// Probe Response
typedef struct tagWLAN_FR_PROBERESP {
UINT uType;
UINT len;
PBYTE pBuf;
PUWLAN_80211HDR pHdr;
/*-- fixed fields -----------*/
PQWORD pqwTimestamp;
PWORD pwBeaconInterval;
PWORD pwCapInfo;
/*-- info elements ----------*/
PWLAN_IE_SSID pSSID;
PWLAN_IE_SUPP_RATES pSuppRates;
PWLAN_IE_DS_PARMS pDSParms;
PWLAN_IE_CF_PARMS pCFParms;
PWLAN_IE_IBSS_PARMS pIBSSParms;
PWLAN_IE_RSN pRSN;
PWLAN_IE_RSN_EXT pRSNWPA;
PWLAN_IE_ERP pERP;
PWLAN_IE_SUPP_RATES pExtSuppRates;
PWLAN_IE_COUNTRY pIE_Country;
PWLAN_IE_PW_CONST pIE_PowerConstraint;
PWLAN_IE_CH_SW pIE_CHSW;
PWLAN_IE_IBSS_DFS pIE_IBSSDFS;
PWLAN_IE_QUIET pIE_Quiet;
} WLAN_FR_PROBERESP, *PWLAN_FR_PROBERESP;
// Authentication
typedef struct tagWLAN_FR_AUTHEN {
UINT uType;
UINT len;
PBYTE pBuf;
PUWLAN_80211HDR pHdr;
/*-- fixed fields -----------*/
PWORD pwAuthAlgorithm;
PWORD pwAuthSequence;
PWORD pwStatus;
/*-- info elements ----------*/
PWLAN_IE_CHALLENGE pChallenge;
} WLAN_FR_AUTHEN, *PWLAN_FR_AUTHEN;
// Deauthenication
typedef struct tagWLAN_FR_DEAUTHEN {
UINT uType;
UINT len;
PBYTE pBuf;
PUWLAN_80211HDR pHdr;
/*-- fixed fields -----------*/
PWORD pwReason;
/*-- info elements ----------*/
} WLAN_FR_DEAUTHEN, *PWLAN_FR_DEAUTHEN;
/*--------------------- Export Functions --------------------------*/
VOID
vMgrEncodeBeacon(
IN PWLAN_FR_BEACON pFrame
);
VOID
vMgrDecodeBeacon(
IN PWLAN_FR_BEACON pFrame
);
VOID
vMgrEncodeIBSSATIM(
IN PWLAN_FR_IBSSATIM pFrame
);
VOID
vMgrDecodeIBSSATIM(
IN PWLAN_FR_IBSSATIM pFrame
);
VOID
vMgrEncodeDisassociation(
IN PWLAN_FR_DISASSOC pFrame
);
VOID
vMgrDecodeDisassociation(
IN PWLAN_FR_DISASSOC pFrame
);
VOID
vMgrEncodeAssocRequest(
IN PWLAN_FR_ASSOCREQ pFrame
);
VOID
vMgrDecodeAssocRequest(
IN PWLAN_FR_ASSOCREQ pFrame
);
VOID
vMgrEncodeAssocResponse(
IN PWLAN_FR_ASSOCRESP pFrame
);
VOID
vMgrDecodeAssocResponse(
IN PWLAN_FR_ASSOCRESP pFrame
);
VOID
vMgrEncodeReassocRequest(
IN PWLAN_FR_REASSOCREQ pFrame
);
VOID
vMgrDecodeReassocRequest(
IN PWLAN_FR_REASSOCREQ pFrame
);
VOID
vMgrEncodeProbeRequest(
IN PWLAN_FR_PROBEREQ pFrame
);
VOID
vMgrDecodeProbeRequest(
IN PWLAN_FR_PROBEREQ pFrame
);
VOID
vMgrEncodeProbeResponse(
IN PWLAN_FR_PROBERESP pFrame
);
VOID
vMgrDecodeProbeResponse(
IN PWLAN_FR_PROBERESP pFrame
);
VOID
vMgrEncodeAuthen(
IN PWLAN_FR_AUTHEN pFrame
);
VOID
vMgrDecodeAuthen(
IN PWLAN_FR_AUTHEN pFrame
);
VOID
vMgrEncodeDeauthen(
IN PWLAN_FR_DEAUTHEN pFrame
);
VOID
vMgrDecodeDeauthen(
IN PWLAN_FR_DEAUTHEN pFrame
);
VOID
vMgrEncodeReassocResponse(
IN PWLAN_FR_REASSOCRESP pFrame
);
VOID
vMgrDecodeReassocResponse(
IN PWLAN_FR_REASSOCRESP pFrame
);
#endif// __80211MGR_H__

View File

@ -0,0 +1,324 @@
/*
* Copyright (c) 1996, 2005 VIA Networking Technologies, Inc.
* All rights reserved.
*
* This program is free software; you can redistribute it and/or modify
* it under the terms of the GNU General Public License as published by
* the Free Software Foundation; either version 2 of the License, or
* (at your option) any later version.
*
* This program is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
* GNU General Public License for more details.
*
* You should have received a copy of the GNU General Public License along
* with this program; if not, write to the Free Software Foundation, Inc.,
* 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA.
*
*
* File: IEEE11h.c
*
* Purpose:
*
* Functions:
*
* Revision History:
*
* Author: Yiching Chen
*
* Date: Mar. 31, 2005
*
*/
#if !defined(__TTYPE_H__)
#include "ttype.h"
#endif
#if !defined(__UMEM_H__)
#include "umem.h"
#endif
#if !defined(__TMACRO_H__)
#include "tmacro.h"
#endif
#if !defined(__TETHER_H__)
#include "tether.h"
#endif
#if !defined(__IEEE11h_H__)
#include "IEEE11h.h"
#endif
#if !defined(__DEVICE_H__)
#include "device.h"
#endif
#if !defined(__WMGR_H__)
#include "wmgr.h"
#endif
#if !defined(__RXTX_H__)
#include "rxtx.h"
#endif
/*--------------------- Static Definitions -------------------------*/
static int msglevel =MSG_LEVEL_INFO;
#pragma pack(1)
typedef struct _WLAN_FRAME_ACTION {
WLAN_80211HDR_A3 Header;
BYTE byCategory;
BYTE byAction;
BYTE abyVars[1];
} WLAN_FRAME_ACTION, *PWLAN_FRAME_ACTION;
typedef struct _WLAN_FRAME_MSRREQ {
WLAN_80211HDR_A3 Header;
BYTE byCategory;
BYTE byAction;
BYTE byDialogToken;
WLAN_IE_MEASURE_REQ sMSRReqEIDs[1];
} WLAN_FRAME_MSRREQ, *PWLAN_FRAME_MSRREQ;
typedef struct _WLAN_FRAME_MSRREP {
WLAN_80211HDR_A3 Header;
BYTE byCategory;
BYTE byAction;
BYTE byDialogToken;
WLAN_IE_MEASURE_REP sMSRRepEIDs[1];
} WLAN_FRAME_MSRREP, *PWLAN_FRAME_MSRREP;
typedef struct _WLAN_FRAME_TPCREQ {
WLAN_80211HDR_A3 Header;
BYTE byCategory;
BYTE byAction;
BYTE byDialogToken;
WLAN_IE_TPC_REQ sTPCReqEIDs;
} WLAN_FRAME_TPCREQ, *PWLAN_FRAME_TPCREQ;
typedef struct _WLAN_FRAME_TPCREP {
WLAN_80211HDR_A3 Header;
BYTE byCategory;
BYTE byAction;
BYTE byDialogToken;
WLAN_IE_TPC_REP sTPCRepEIDs;
} WLAN_FRAME_TPCREP, *PWLAN_FRAME_TPCREP;
#pragma pack()
// action field reference ieee 802.11h Table 20e
#define ACTION_MSRREQ 0
#define ACTION_MSRREP 1
#define ACTION_TPCREQ 2
#define ACTION_TPCREP 3
#define ACTION_CHSW 4
/*--------------------- Static Classes ----------------------------*/
/*--------------------- Static Variables --------------------------*/
/*--------------------- Static Functions --------------------------*/
static BOOL s_bRxMSRReq(PSMgmtObject pMgmt, PWLAN_FRAME_MSRREQ pMSRReq, UINT uLength)
{
UINT uNumOfEIDs = 0;
BOOL bResult = TRUE;
if (uLength <= WLAN_A3FR_MAXLEN) {
MEMvCopy(pMgmt->abyCurrentMSRReq, pMSRReq, uLength);
}
uNumOfEIDs = ((uLength - OFFSET(WLAN_FRAME_MSRREQ, sMSRReqEIDs))/ (sizeof(WLAN_IE_MEASURE_REQ)));
pMgmt->pCurrMeasureEIDRep = &(((PWLAN_FRAME_MSRREP) (pMgmt->abyCurrentMSRRep))->sMSRRepEIDs[0]);
pMgmt->uLengthOfRepEIDs = 0;
bResult = CARDbStartMeasure(pMgmt->pAdapter,
((PWLAN_FRAME_MSRREQ) (pMgmt->abyCurrentMSRReq))->sMSRReqEIDs,
uNumOfEIDs
);
return (bResult);
}
static BOOL s_bRxTPCReq(PSMgmtObject pMgmt, PWLAN_FRAME_TPCREQ pTPCReq, BYTE byRate, BYTE byRSSI)
{
PWLAN_FRAME_TPCREP pFrame;
PSTxMgmtPacket pTxPacket = NULL;
pTxPacket = (PSTxMgmtPacket)pMgmt->pbyMgmtPacketPool;
memset(pTxPacket, 0, sizeof(STxMgmtPacket) + WLAN_A3FR_MAXLEN);
pTxPacket->p80211Header = (PUWLAN_80211HDR)((PBYTE)pTxPacket + sizeof(STxMgmtPacket));
pFrame = (PWLAN_FRAME_TPCREP)((PBYTE)pTxPacket + sizeof(STxMgmtPacket));
pFrame->Header.wFrameCtl = ( WLAN_SET_FC_FTYPE(WLAN_FTYPE_MGMT) |
WLAN_SET_FC_FSTYPE(WLAN_FSTYPE_ACTION)
);
MEMvCopy( pFrame->Header.abyAddr1, pTPCReq->Header.abyAddr2, WLAN_ADDR_LEN);
MEMvCopy( pFrame->Header.abyAddr2, CARDpGetCurrentAddress(pMgmt->pAdapter), WLAN_ADDR_LEN);
MEMvCopy( pFrame->Header.abyAddr3, pMgmt->abyCurrBSSID, WLAN_BSSID_LEN);
pFrame->byCategory = 0;
pFrame->byAction = 3;
pFrame->byDialogToken = ((PWLAN_FRAME_MSRREQ) (pMgmt->abyCurrentMSRReq))->byDialogToken;
pFrame->sTPCRepEIDs.byElementID = WLAN_EID_TPC_REP;
pFrame->sTPCRepEIDs.len = 2;
pFrame->sTPCRepEIDs.byTxPower = CARDbyGetTransmitPower(pMgmt->pAdapter);
switch (byRate) {
case RATE_54M:
pFrame->sTPCRepEIDs.byLinkMargin = 65 - byRSSI;
break;
case RATE_48M:
pFrame->sTPCRepEIDs.byLinkMargin = 66 - byRSSI;
break;
case RATE_36M:
pFrame->sTPCRepEIDs.byLinkMargin = 70 - byRSSI;
break;
case RATE_24M:
pFrame->sTPCRepEIDs.byLinkMargin = 74 - byRSSI;
break;
case RATE_18M:
pFrame->sTPCRepEIDs.byLinkMargin = 77 - byRSSI;
break;
case RATE_12M:
pFrame->sTPCRepEIDs.byLinkMargin = 79 - byRSSI;
break;
case RATE_9M:
pFrame->sTPCRepEIDs.byLinkMargin = 81 - byRSSI;
break;
case RATE_6M:
default:
pFrame->sTPCRepEIDs.byLinkMargin = 82 - byRSSI;
break;
}
pTxPacket->cbMPDULen = sizeof(WLAN_FRAME_TPCREP);
pTxPacket->cbPayloadLen = sizeof(WLAN_FRAME_TPCREP) - WLAN_HDR_ADDR3_LEN;
if (csMgmt_xmit(pMgmt->pAdapter, pTxPacket) != CMD_STATUS_PENDING)
return (FALSE);
return (TRUE);
// return (CARDbSendPacket(pMgmt->pAdapter, pFrame, PKT_TYPE_802_11_MNG, sizeof(WLAN_FRAME_TPCREP)));
}
/*--------------------- Export Variables --------------------------*/
/*--------------------- Export Functions --------------------------*/
/*+
*
* Description:
* Handles action management frames.
*
* Parameters:
* In:
* pMgmt - Management Object structure
* pRxPacket - Received packet
* Out:
* none
*
* Return Value: None.
*
-*/
BOOL
IEEE11hbMgrRxAction (
IN PVOID pMgmtHandle,
IN PVOID pRxPacket
)
{
PSMgmtObject pMgmt = (PSMgmtObject) pMgmtHandle;
PWLAN_FRAME_ACTION pAction = NULL;
UINT uLength = 0;
PWLAN_IE_CH_SW pChannelSwitch = NULL;
// decode the frame
uLength = ((PSRxMgmtPacket)pRxPacket)->cbMPDULen;
if (uLength > WLAN_A3FR_MAXLEN) {
return (FALSE);
}
pAction = (PWLAN_FRAME_ACTION) (((PSRxMgmtPacket)pRxPacket)->p80211Header);
if (pAction->byCategory == 0) {
switch (pAction->byAction) {
case ACTION_MSRREQ:
return (s_bRxMSRReq(pMgmt, (PWLAN_FRAME_MSRREQ) pAction, uLength));
break;
case ACTION_MSRREP:
break;
case ACTION_TPCREQ:
return (s_bRxTPCReq(pMgmt,
(PWLAN_FRAME_TPCREQ) pAction,
((PSRxMgmtPacket)pRxPacket)->byRxRate,
(BYTE) ((PSRxMgmtPacket)pRxPacket)->uRSSI));
break;
case ACTION_TPCREP:
break;
case ACTION_CHSW:
pChannelSwitch = (PWLAN_IE_CH_SW) (pAction->abyVars);
if ((pChannelSwitch->byElementID == WLAN_EID_CH_SWITCH) &&
(pChannelSwitch->len == 3)) {
// valid element id
CARDbChannelSwitch( pMgmt->pAdapter,
pChannelSwitch->byMode,
CARDbyGetChannelMapping(pMgmt->pAdapter, pChannelSwitch->byChannel, pMgmt->eCurrentPHYMode),
pChannelSwitch->byCount
);
}
break;
default:
DEVICE_PRT(MSG_LEVEL_DEBUG, KERN_INFO"Unknown Action = %d\n", pAction->byAction);
break;
}
} else {
DEVICE_PRT(MSG_LEVEL_DEBUG, KERN_INFO"Unknown Category = %d\n", pAction->byCategory);
pAction->byCategory |= 0x80;
//return (CARDbSendPacket(pMgmt->pAdapter, pAction, PKT_TYPE_802_11_MNG, uLength));
return (TRUE);
}
return (TRUE);
}
BOOL IEEE11hbMSRRepTx (
IN PVOID pMgmtHandle
)
{
PSMgmtObject pMgmt = (PSMgmtObject) pMgmtHandle;
PWLAN_FRAME_MSRREP pMSRRep = (PWLAN_FRAME_MSRREP) (pMgmt->abyCurrentMSRRep + sizeof(STxMgmtPacket));
UINT uLength = 0;
PSTxMgmtPacket pTxPacket = NULL;
pTxPacket = (PSTxMgmtPacket)pMgmt->abyCurrentMSRRep;
memset(pTxPacket, 0, sizeof(STxMgmtPacket) + WLAN_A3FR_MAXLEN);
pTxPacket->p80211Header = (PUWLAN_80211HDR)((PBYTE)pTxPacket + sizeof(STxMgmtPacket));
pMSRRep->Header.wFrameCtl = ( WLAN_SET_FC_FTYPE(WLAN_FTYPE_MGMT) |
WLAN_SET_FC_FSTYPE(WLAN_FSTYPE_ACTION)
);
MEMvCopy( pMSRRep->Header.abyAddr1, ((PWLAN_FRAME_MSRREQ) (pMgmt->abyCurrentMSRReq))->Header.abyAddr2, WLAN_ADDR_LEN);
MEMvCopy( pMSRRep->Header.abyAddr2, CARDpGetCurrentAddress(pMgmt->pAdapter), WLAN_ADDR_LEN);
MEMvCopy( pMSRRep->Header.abyAddr3, pMgmt->abyCurrBSSID, WLAN_BSSID_LEN);
pMSRRep->byCategory = 0;
pMSRRep->byAction = 1;
pMSRRep->byDialogToken = ((PWLAN_FRAME_MSRREQ) (pMgmt->abyCurrentMSRReq))->byDialogToken;
uLength = pMgmt->uLengthOfRepEIDs + OFFSET(WLAN_FRAME_MSRREP, sMSRRepEIDs);
pTxPacket->cbMPDULen = uLength;
pTxPacket->cbPayloadLen = uLength - WLAN_HDR_ADDR3_LEN;
if (csMgmt_xmit(pMgmt->pAdapter, pTxPacket) != CMD_STATUS_PENDING)
return (FALSE);
return (TRUE);
// return (CARDbSendPacket(pMgmt->pAdapter, pMSRRep, PKT_TYPE_802_11_MNG, uLength));
}

View File

@ -0,0 +1,68 @@
/*
* Copyright (c) 1996, 2005 VIA Networking Technologies, Inc.
* All rights reserved.
*
* This program is free software; you can redistribute it and/or modify
* it under the terms of the GNU General Public License as published by
* the Free Software Foundation; either version 2 of the License, or
* (at your option) any later version.
*
* This program is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
* GNU General Public License for more details.
*
* You should have received a copy of the GNU General Public License along
* with this program; if not, write to the Free Software Foundation, Inc.,
* 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA.
*
*
* File: IEEE11h.h
*
* Purpose: Defines the macros, types, and functions for dealing
* with IEEE 802.11h.
*
* Author: Yiching Chen
*
* Date: Mar. 31, 2005
*
*/
#ifndef __IEEE11h_H__
#define __IEEE11h_H__
#if !defined(__TTYPE_H__)
#include "ttype.h"
#endif
#if !defined(__80211HDR_H__)
#include "80211hdr.h"
#endif
#if !defined(__80211MGR_H__)
#include "80211mgr.h"
#endif
/*--------------------- Export Definitions -------------------------*/
/*--------------------- Export Classes ----------------------------*/
/*--------------------- Export Variables --------------------------*/
/*--------------------- Export Types ------------------------------*/
/*--------------------- Export Functions --------------------------*/
#ifdef __cplusplus
extern "C" { /* Assume C declarations for C++ */
#endif /* __cplusplus */
BOOL IEEE11hbMSRRepTx (
IN PVOID pMgmtHandle
);
#ifdef __cplusplus
} /* End of extern "C" { */
#endif /* __cplusplus */
#endif // __IEEE11h_H__

View File

@ -0,0 +1,218 @@
#
# Build options:
# PRIV_OBJ := 1 for object version
#
IO_MAP := 0
HOSTAP := 1
PRIV_OBJ := 0
#KSP : = 0
KSP := /lib/modules/$(shell uname -r)/build \
# /usr/src/linux-$(shell uname -r) \
# /usr/src/linux-$(shell uname -r | sed 's/-.*//') \
# /usr/src/kernel-headers-$(shell uname -r) \
# /usr/src/kernel-source-$(shell uname -r) \
# /usr/src/linux-$(shell uname -r | sed 's/\([0-9]*\.[0-9]*\)\..*/\1/') \
# /usr/src/linux /home/plice
#test_dir = $(shell [ -e $(dir)/include/linux ] && echo $(dir))
#KSP := $(foreach dir, $(KSP), $(test_dir))
KSRC := $(firstword $(KSP))
#ifeq (,$(KSRC))
# $( error Linux kernel source not found)
#endif
# check kernel version
KVER := $(shell uname -r | cut -c1-3 | sed 's/2\.[56]/2\.6/')
KERVER2=$(shell uname -r | cut -d. -f2)
ifeq ($(KVER), 2.6)
# 2.6 kernel
TARGET = viawget.ko
else
TARGET = viawget.o
endif
INSTDIR := $(shell find /lib/modules/$(shell uname -r) -name $(TARGET) -printf "%h\n" | sort | head -1)
ifeq (,$(INSTDIR))
ifeq (,$(KERVER2))
ifneq (,$(wildcard /lib/modules/$(shell uname -r)/kernel))
INSTDIR := /lib/modules/$(shell uname -r)/kernel/drivers/net
else
INSTDIR := /lib/modules/$(shell uname -r)/net
endif
else
ifneq ($(KERVER2),2)
INSTDIR := /lib/modules/$(shell uname -r)/kernel/drivers/net
else
INSTDIR := /lib/modules/$(shell uname -r)/net
endif
endif
endif
SRC = device_main.c card.c mac.c baseband.c wctl.c 80211mgr.c \
wcmd.c wmgr.c bssdb.c wpa2.c rxtx.c dpc.c power.c datarate.c \
srom.c mib.c rc4.c tether.c tcrc.c ioctl.c hostap.c wpa.c key.c \
tkip.c michael.c wroute.c rf.c iwctl.c wpactl.c aes_ccmp.c \
vntwifi.c IEEE11h.c
ifeq ($(IO_MAP), 1)
EXTRA_CFLAGS += -DIO_MAP
endif
ifeq ($(HOSTAP), 1)
EXTRA_CFLAGS += -DHOSTAP
endif
ifeq ($(PRIV_OBJ), 1)
EXTRA_CFLAGS += -DPRIVATE_OBJ
endif
EXTRA_CFLAGS += -I$(PWD) -I$(PWD)/../include -I$(PWD)/../solomon
EXTRA_CFLAGS += -I$(PWD)/include -I$(PWD)/solomon
# build rule
ifeq ($(KVER), 2.6)
# 2.6 kernel
ifndef KERNEL_CONF
KERNEL_CONF= $(KSRC)/.config
endif
include ${KERNEL_CONF}
obj-m += viawget.o
viawget-objs := device_main.o card.o mac.o baseband.o wctl.o 80211mgr.o \
wcmd.o wmgr.o bssdb.o rxtx.o dpc.o power.o datarate.o srom.o \
mib.o rc4.o tether.o tcrc.o ioctl.o hostap.o wpa.o key.o tkip.o \
michael.o wroute.o rf.o iwctl.o wpactl.o wpa2.o aes_ccmp.o \
vntwifi.o IEEE11h.o
.c.o:
$(CC) $(CFLAGS) -o $@ $<
default:
make -C $(KSRC) SUBDIRS=$(shell pwd) modules
else
# 2.2/2.4 kernel
OBJS := device_main.o card.o mac.o baseband.o wctl.o 80211mgr.o \
wcmd.o wmgr.o bssdb.o rxtx.o dpc.o power.o datarate.o srom.o \
mib.o rc4.o tether.o tcrc.o ioctl.o hostap.o wpa.o key.o tkip.o \
michael.o wroute.o rf.o iwctl.o wpactl.o wpa2.o aes_ccmp.o \
vntwifi.o IEEE11h.o
VERSION_FILE := $(KSRC)/include/linux/version.h
CONFIG_FILE := $(KSRC)/include/linux/config.h
ifeq (,$(wildcard $(VERSION_FILE)))
$(error Linux kernel source not configured - missing version.h)
endif
ifeq (,$(wildcard $(CONFIG_FILE)))
$(error Linux kernel source not configured - missing config.h)
endif
ifneq (,$(findstring egcs-2.91.66, $(shell cat /proc/version)))
CC := kgcc gcc cc
else
CC := gcc cc
endif
test_cc = $(shell which $(cc) > /dev/null 2>&1 && echo $(cc))
CC := $(foreach cc, $(CC), $(test_cc))
CC := $(firstword $(CC))
EXTRA_CFLAGS += -Wall -DLINUX -D__KERNEL__ -DMODULE -DEXPORT_SYMTAB -D__NO_VERSION__ -O2 -pipe
EXTRA_CFLAGS += -I$(KSRC)/include -Wstrict-prototypes -fomit-frame-pointer -fno-strict-aliasing
EXTRA_CFLAGS += $(shell [ -f $(KSRC)/include/linux/modversions.h ] && \
echo "-DMODVERSIONS -include $(KSRC)/include/linux/modversions.h")
.SILENT: $(TARGET) clean
# look for SMP in config.h
SMP := $(shell $(CC) $(CFLAGS) -E -dM $(CONFIG_FILE) | \
grep CONFIG_SMP | awk '{ print $$3 }')
ifneq ($(SMP),1)
SMP := 0
endif
ifeq ($(SMP), 1)
EXTRA_CFLAGS += -D__SMP__
endif
ifeq ($(PRIV_OBJ), 1)
EXTRA_CFLAGS += -DPRIVATE_OBJ
TARGET = x86g_up.o
ifeq ($(SMP), 1)
TARGET = x86g_smp.o
endif
endif
# check x86_64
SUBARCH := $(shell uname -m)
ifeq ($(SUBARCH),x86_64)
EXTRA_CFLAGS += -mcmodel=kernel -mno-red-zone
endif
$(TARGET): $(filter-out $(TARGET), $(SRC:.c=.o))
$(LD) -r $^ -o $@
echo; echo
echo "**************************************************"
echo "Build options:"
echo " VERSION $(KVER)"
echo -n " SMP "
if [ "$(SMP)" = "1" ]; \
then echo "Enabled"; else echo "Disabled"; fi
endif # ifeq ($(KVER),2.6)
ifeq ($(KVER), 2.6)
install: default
else
install: clean $(TARGET)
endif
mkdir -p $(MOD_ROOT)$(INSTDIR)
install -m 644 -o root $(TARGET) $(MOD_ROOT)$(INSTDIR)
ifeq (,$(MOD_ROOT))
/sbin/depmod -a || true
else
/sbin/depmod -b $(MOD_ROOT) -a || true
endif
uninstall:
rm -f $(INSTDIR)/$(TARGET)
/sbin/depmod -a
clean:
rm -f $(TARGET) $(SRC:.c=.o) *.o *~
rm -f .*.o.d .*.o.cmd .*.ko.cmd *.mod.c *.mod.o
-include .depend.mak

View File

@ -0,0 +1,181 @@
#
#
# Build options:
# PRIV_OBJ := 1 for object version
# BIG_ENDIAN := 1 for big-endian mode
#
# arm-linux-tools chain are located at:
# /usr/local/bin/arm-linux-gcc
# /usr/local/bin/arm-linux-ld
#
IO_MAP := 0
HOSTAP := 1
PRIV_OBJ := 1
BIG_ENDIAN := 1
test_dir = $(shell [ -e $(dir)/include/linux ] && echo $(dir))
KSP := $(foreach dir, $(KSP), $(test_dir))
KSRC := $(firstword $(KSP))
#ifeq (,$(KSRC))
# $(error Linux kernel source not found)
#endif
# check kernel version
KVER := $(shell uname -r | cut -c1-3 | sed 's/2\.[56]/2\.6/')
KERVER2=$(shell uname -r | cut -d. -f2)
ifeq ($(KVER), 2.6)
# 2.6 kernel
TARGET = viawget.ko
else
TARGET = viawget.o
endif
INSTDIR := $(shell find /lib/modules/$(shell uname -r) -name $(TARGET) -printf "%h\n" | sort | head -1)
ifeq (,$(INSTDIR))
ifeq (,$(KERVER2))
ifneq (,$(wildcard /lib/modules/$(shell uname -r)/kernel))
INSTDIR := /lib/modules/$(shell uname -r)/kernel/drivers/net
else
INSTDIR := /lib/modules/$(shell uname -r)/net
endif
else
ifneq ($(KERVER2),2)
INSTDIR := /lib/modules/$(shell uname -r)/kernel/drivers/net
else
INSTDIR := /lib/modules/$(shell uname -r)/net
endif
endif
endif
SRC = device_main.c card.c mac.c baseband.c wctl.c 80211mgr.c \
wcmd.c wmgr.c bssdb.c rxtx.c dpc.c power.c datarate.c srom.c \
mib.c rc4.c tether.c tcrc.c ioctl.c hostap.c wpa.c key.c tkip.c \
michael.c wroute.c rf.c iwctl.c wpactl.c wpa2.c aes_ccmp.c
ifeq ($(IO_MAP), 1)
CFLAGS += -DIO_MAP
endif
ifeq ($(HOSTAP), 1)
CFLAGS += -DHOSTAP
endif
ifeq ($(PRIV_OBJ), 1)
CFLAGS += -DPRIVATE_OBJ
endif
ifeq ($(BIG_ENDIAN), 1)
CFLAGS += -D__BIG_ENDIAN
CFLAGS += -mbig-endian
LDOPTS += -EB
else
CFLAGS += -mlittle-endian
LDOPTS += -EL
endif
CFLAGS += -I$(PWD) -I$(PWD)/../include -I$(PWD)/../solomon
# build rule
ifeq ($(KVER), 2.6)
# 2.6 kernel
ifndef KERNEL_CONF
KERNEL_CONF= $(KSRC)/.config
endif
include ${KERNEL_CONF}
obj-m += viawget.o
viawget-objs := device_main.o card.o mac.o baseband.o wctl.o 80211mgr.o \
wcmd.o wmgr.o bssdb.o rxtx.o dpc.o power.o datarate.o srom.o \
mib.o rc4.o tether.o tcrc.o ioctl.o hostap.o wpa.o key.o tkip.o \
michael.o wroute.o rf.o iwctl.o wpactl.o wpa2.o aes_ccmp.o
.c.o:
$(CC) $(CFLAGS) -o $@ $<
default:
make -C $(KSRC) SUBDIRS=$(shell pwd) modules
else
# 2.2/2.4 kernel
OBJS := device_main.o card.o mac.o baseband.o wctl.o 80211mgr.o \
wcmd.o wmgr.o bssdb.o rxtx.o dpc.o power.o datarate.o srom.o \
mib.o rc4.o tether.o tcrc.o ioctl.o hostap.o wpa.o key.o tkip.o \
michael.o wroute.o rf.o iwctl.o wpactl.o wpa2.o
CC := /usr/local/bin/arm-linux-gcc
LD := /usr/local/bin/arm-linux-ld
CFLAGS += -Wall -DLINUX -D__KERNEL__ -DMODULE -DEXPORT_SYMTAB -D__NO_VERSION__ -O2 -pipe
#CFLAGS += -Wstrict-prototypes -fomit-frame-pointer
COPTS+= -march=armv4 -fno-strict-aliasing -fno-common
#COPTS+= -mapcs-32 -mtune=xscale -mshort-load-bytes -msoft-float -mfp=2
#COPTS+= -mthumb -mcpu=arm9 -ffunction-sections -fdata-sections
.SILENT: $(TARGET) clean
ifeq ($(PRIV_OBJ), 1)
ifeq ($(BIG_ENDIAN), 1)
TARGET = arm_be_g.o
else
TARGET = arm_le_g.o
endif
endif
$(TARGET): $(filter-out $(TARGET), $(SRC:.c=.o))
$(LD) $(LDOPTS) -r $^ -o $@
echo
echo "***********************************"
echo "Build options:"
echo " VERSION $(KVER)"
echo -n " SMP "
if [ "$(SMP)" = "1" ]; \
then echo "Enabled"; else echo "Disabled"; fi
endif # ifeq ($(KVER),2.6)
ifeq ($(KVER), 2.6)
install: default
else
install: clean $(TARGET)
endif
mkdir -p $(MOD_ROOT)$(INSTDIR)
install -m 644 -o root $(TARGET) $(MOD_ROOT)$(INSTDIR)
ifeq (,$(MOD_ROOT))
/sbin/depmod -a || true
else
/sbin/depmod -b $(MOD_ROOT) -a || true
endif
uninstall:
rm -f $(INSTDIR)/$(TARGET)
/sbin/depmod -a
clean:
rm -f $(TARGET) $(SRC:.c=.o) *~
rm -f .*.o.d .*.o.cmd .*.ko.cmd *.mod.c *.mod.o
-include .depend.mak

View File

@ -0,0 +1,209 @@
#
# Build options:
# PRIV_OBJ := 1 for object version
#
IO_MAP := 0
HOSTAP := 1
PRIV_OBJ := 1
KSP := /lib/modules/$(shell uname -r)/build \
/usr/src/linux-$(shell uname -r) \
/usr/src/linux-$(shell uname -r | sed 's/-.*//') \
/usr/src/kernel-headers-$(shell uname -r) \
/usr/src/kernel-source-$(shell uname -r) \
/usr/src/linux-$(shell uname -r | sed 's/\([0-9]*\.[0-9]*\)\..*/\1/') \
/usr/src/linux
test_dir = $(shell [ -e $(dir)/include/linux ] && echo $(dir))
KSP := $(foreach dir, $(KSP), $(test_dir))
KSRC := $(firstword $(KSP))
ifeq (,$(KSRC))
$(error Linux kernel source not found)
endif
# check kernel version
KVER := $(shell uname -r | cut -c1-3 | sed 's/2\.[56]/2\.6/')
KERVER2=$(shell uname -r | cut -d. -f2)
ifeq ($(KVER), 2.6)
# 2.6 kernel
TARGET = viawget.ko
else
TARGET = viawget.o
endif
INSTDIR := $(shell find /lib/modules/$(shell uname -r) -name $(TARGET) -printf "%h\n" | sort | head -1)
ifeq (,$(INSTDIR))
ifeq (,$(KERVER2))
ifneq (,$(wildcard /lib/modules/$(shell uname -r)/kernel))
INSTDIR := /lib/modules/$(shell uname -r)/kernel/drivers/net
else
INSTDIR := /lib/modules/$(shell uname -r)/net
endif
else
ifneq ($(KERVER2),2)
INSTDIR := /lib/modules/$(shell uname -r)/kernel/drivers/net
else
INSTDIR := /lib/modules/$(shell uname -r)/net
endif
endif
endif
SRC = device_main.c card.c mac.c baseband.c wctl.c 80211mgr.c \
wcmd.c wmgr.c bssdb.c wpa2.c rxtx.c dpc.c power.c datarate.c \
srom.c mib.c rc4.c tether.c tcrc.c ioctl.c hostap.c wpa.c key.c \
tkip.c michael.c wroute.c rf.c iwctl.c wpactl.c aes_ccmp.c
ifeq ($(IO_MAP), 1)
CFLAGS += -DIO_MAP
endif
ifeq ($(HOSTAP), 1)
CFLAGS += -DHOSTAP
endif
ifeq ($(PRIV_OBJ), 1)
CFLAGS += -DPRIVATE_OBJ
endif
CFLAGS += -I$(PWD) -I$(PWD)/../include -I$(PWD)/../solomon
# build rule
ifeq ($(KVER), 2.6)
# 2.6 kernel
ifndef KERNEL_CONF
KERNEL_CONF= $(KSRC)/.config
endif
include ${KERNEL_CONF}
obj-m += viawget.o
viawget-objs := device_main.o card.o mac.o baseband.o wctl.o 80211mgr.o \
wcmd.o wmgr.o bssdb.o rxtx.o dpc.o power.o datarate.o srom.o \
mib.o rc4.o tether.o tcrc.o ioctl.o hostap.o wpa.o key.o tkip.o \
michael.o wroute.o rf.o iwctl.o wpactl.o wpa2.o aes_ccmp.o
.c.o:
$(CC) $(CFLAGS) -o $@ $<
default:
make -C $(KSRC) SUBDIRS=$(shell pwd) modules
else
# 2.2/2.4 kernel
OBJS := device_main.o card.o mac.o baseband.o wctl.o 80211mgr.o \
wcmd.o wmgr.o bssdb.o rxtx.o dpc.o power.o datarate.o srom.o \
mib.o rc4.o tether.o tcrc.o ioctl.o hostap.o wpa.o key.o tkip.o \
michael.o wroute.o rf.o iwctl.o wpactl.o wpa2.o aes_ccmp.o
VERSION_FILE := $(KSRC)/include/linux/version.h
CONFIG_FILE := $(KSRC)/include/linux/config.h
ifeq (,$(wildcard $(VERSION_FILE)))
$(error Linux kernel source not configured - missing version.h)
endif
ifeq (,$(wildcard $(CONFIG_FILE)))
$(error Linux kernel source not configured - missing config.h)
endif
ifneq (,$(findstring egcs-2.91.66, $(shell cat /proc/version)))
CC := kgcc gcc cc
else
CC := gcc cc
endif
test_cc = $(shell which $(cc) > /dev/null 2>&1 && echo $(cc))
CC := $(foreach cc, $(CC), $(test_cc))
CC := $(firstword $(CC))
CFLAGS += -Wall -DLINUX -D__KERNEL__ -DMODULE -DEXPORT_SYMTAB -D__NO_VERSION__ -O2 -pipe
CFLAGS += -I$(KSRC)/include -Wstrict-prototypes -fomit-frame-pointer
CFLAGS += $(shell [ -f $(KSRC)/include/linux/modversions.h ] && \
echo "-DMODVERSIONS -include $(KSRC)/include/linux/modversions.h")
.SILENT: $(TARGET) clean
# look for SMP in config.h
SMP := $(shell $(CC) $(CFLAGS) -E -dM $(CONFIG_FILE) | \
grep CONFIG_SMP | awk '{ print $$3 }')
ifneq ($(SMP),1)
SMP := 0
endif
ifeq ($(SMP), 1)
CFLAGS += -D__SMP__
endif
ifeq ($(PRIV_OBJ), 1)
CFLAGS += -DPRIVATE_OBJ
TARGET = x86g_up.o
ifeq ($(SMP), 1)
TARGET = x86g_smp.o
endif
endif
# check x86_64
SUBARCH := $(shell uname -m)
ifeq ($(SUBARCH),x86_64)
CFLAGS += -mcmodel=kernel -mno-red-zone
endif
$(TARGET): $(filter-out $(TARGET), $(SRC:.c=.o))
$(LD) -r $^ -o $@
echo; echo
echo "**************************************************"
echo "Build options:"
echo " VERSION $(KVER)"
echo -n " SMP "
if [ "$(SMP)" = "1" ]; \
then echo "Enabled"; else echo "Disabled"; fi
endif # ifeq ($(KVER),2.6)
ifeq ($(KVER), 2.6)
install: default
else
install: clean $(TARGET)
endif
mkdir -p $(MOD_ROOT)$(INSTDIR)
install -m 644 -o root $(TARGET) $(MOD_ROOT)$(INSTDIR)
ifeq (,$(MOD_ROOT))
/sbin/depmod -a || true
else
/sbin/depmod -b $(MOD_ROOT) -a || true
endif
uninstall:
rm -f $(INSTDIR)/$(TARGET)
/sbin/depmod -a
clean:
rm -f $(TARGET) $(SRC:.c=.o) *~
rm -f .*.o.d .*.o.cmd .*.ko.cmd *.mod.c *.mod.o
-include .depend.mak

View File

@ -0,0 +1,410 @@
/*
* Copyright (c) 1996, 2003 VIA Networking Technologies, Inc.
* All rights reserved.
*
* This program is free software; you can redistribute it and/or modify
* it under the terms of the GNU General Public License as published by
* the Free Software Foundation; either version 2 of the License, or
* (at your option) any later version.
*
* This program is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
* GNU General Public License for more details.
*
* You should have received a copy of the GNU General Public License along
* with this program; if not, write to the Free Software Foundation, Inc.,
* 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA.
*
*
* File: aes_ccmp.c
*
* Purpose: AES_CCMP decryption
*
* Author: Warren Hsu
*
* Date: Feb 15, 2005
*
* Functions:
* AESbGenCCMP - Parsing RX-packet
*
*
* Revision History:
*
*/
#if !defined(__UMEM_H__)
#include "umem.h"
#endif
#if !defined(__DEVICE_H__)
#include "device.h"
#endif
#if !defined(__80211HDR_H__)
#include "80211hdr.h"
#endif
/*--------------------- Static Definitions -------------------------*/
/*--------------------- Static Classes ----------------------------*/
/*--------------------- Static Variables --------------------------*/
/*
* SBOX Table
*/
BYTE sbox_table[256] =
{
0x63, 0x7c, 0x77, 0x7b, 0xf2, 0x6b, 0x6f, 0xc5, 0x30, 0x01, 0x67, 0x2b, 0xfe, 0xd7, 0xab, 0x76,
0xca, 0x82, 0xc9, 0x7d, 0xfa, 0x59, 0x47, 0xf0, 0xad, 0xd4, 0xa2, 0xaf, 0x9c, 0xa4, 0x72, 0xc0,
0xb7, 0xfd, 0x93, 0x26, 0x36, 0x3f, 0xf7, 0xcc, 0x34, 0xa5, 0xe5, 0xf1, 0x71, 0xd8, 0x31, 0x15,
0x04, 0xc7, 0x23, 0xc3, 0x18, 0x96, 0x05, 0x9a, 0x07, 0x12, 0x80, 0xe2, 0xeb, 0x27, 0xb2, 0x75,
0x09, 0x83, 0x2c, 0x1a, 0x1b, 0x6e, 0x5a, 0xa0, 0x52, 0x3b, 0xd6, 0xb3, 0x29, 0xe3, 0x2f, 0x84,
0x53, 0xd1, 0x00, 0xed, 0x20, 0xfc, 0xb1, 0x5b, 0x6a, 0xcb, 0xbe, 0x39, 0x4a, 0x4c, 0x58, 0xcf,
0xd0, 0xef, 0xaa, 0xfb, 0x43, 0x4d, 0x33, 0x85, 0x45, 0xf9, 0x02, 0x7f, 0x50, 0x3c, 0x9f, 0xa8,
0x51, 0xa3, 0x40, 0x8f, 0x92, 0x9d, 0x38, 0xf5, 0xbc, 0xb6, 0xda, 0x21, 0x10, 0xff, 0xf3, 0xd2,
0xcd, 0x0c, 0x13, 0xec, 0x5f, 0x97, 0x44, 0x17, 0xc4, 0xa7, 0x7e, 0x3d, 0x64, 0x5d, 0x19, 0x73,
0x60, 0x81, 0x4f, 0xdc, 0x22, 0x2a, 0x90, 0x88, 0x46, 0xee, 0xb8, 0x14, 0xde, 0x5e, 0x0b, 0xdb,
0xe0, 0x32, 0x3a, 0x0a, 0x49, 0x06, 0x24, 0x5c, 0xc2, 0xd3, 0xac, 0x62, 0x91, 0x95, 0xe4, 0x79,
0xe7, 0xc8, 0x37, 0x6d, 0x8d, 0xd5, 0x4e, 0xa9, 0x6c, 0x56, 0xf4, 0xea, 0x65, 0x7a, 0xae, 0x08,
0xba, 0x78, 0x25, 0x2e, 0x1c, 0xa6, 0xb4, 0xc6, 0xe8, 0xdd, 0x74, 0x1f, 0x4b, 0xbd, 0x8b, 0x8a,
0x70, 0x3e, 0xb5, 0x66, 0x48, 0x03, 0xf6, 0x0e, 0x61, 0x35, 0x57, 0xb9, 0x86, 0xc1, 0x1d, 0x9e,
0xe1, 0xf8, 0x98, 0x11, 0x69, 0xd9, 0x8e, 0x94, 0x9b, 0x1e, 0x87, 0xe9, 0xce, 0x55, 0x28, 0xdf,
0x8c, 0xa1, 0x89, 0x0d, 0xbf, 0xe6, 0x42, 0x68, 0x41, 0x99, 0x2d, 0x0f, 0xb0, 0x54, 0xbb, 0x16
};
BYTE dot2_table[256] = {
0x00, 0x02, 0x04, 0x06, 0x08, 0x0a, 0x0c, 0x0e, 0x10, 0x12, 0x14, 0x16, 0x18, 0x1a, 0x1c, 0x1e,
0x20, 0x22, 0x24, 0x26, 0x28, 0x2a, 0x2c, 0x2e, 0x30, 0x32, 0x34, 0x36, 0x38, 0x3a, 0x3c, 0x3e,
0x40, 0x42, 0x44, 0x46, 0x48, 0x4a, 0x4c, 0x4e, 0x50, 0x52, 0x54, 0x56, 0x58, 0x5a, 0x5c, 0x5e,
0x60, 0x62, 0x64, 0x66, 0x68, 0x6a, 0x6c, 0x6e, 0x70, 0x72, 0x74, 0x76, 0x78, 0x7a, 0x7c, 0x7e,
0x80, 0x82, 0x84, 0x86, 0x88, 0x8a, 0x8c, 0x8e, 0x90, 0x92, 0x94, 0x96, 0x98, 0x9a, 0x9c, 0x9e,
0xa0, 0xa2, 0xa4, 0xa6, 0xa8, 0xaa, 0xac, 0xae, 0xb0, 0xb2, 0xb4, 0xb6, 0xb8, 0xba, 0xbc, 0xbe,
0xc0, 0xc2, 0xc4, 0xc6, 0xc8, 0xca, 0xcc, 0xce, 0xd0, 0xd2, 0xd4, 0xd6, 0xd8, 0xda, 0xdc, 0xde,
0xe0, 0xe2, 0xe4, 0xe6, 0xe8, 0xea, 0xec, 0xee, 0xf0, 0xf2, 0xf4, 0xf6, 0xf8, 0xfa, 0xfc, 0xfe,
0x1b, 0x19, 0x1f, 0x1d, 0x13, 0x11, 0x17, 0x15, 0x0b, 0x09, 0x0f, 0x0d, 0x03, 0x01, 0x07, 0x05,
0x3b, 0x39, 0x3f, 0x3d, 0x33, 0x31, 0x37, 0x35, 0x2b, 0x29, 0x2f, 0x2d, 0x23, 0x21, 0x27, 0x25,
0x5b, 0x59, 0x5f, 0x5d, 0x53, 0x51, 0x57, 0x55, 0x4b, 0x49, 0x4f, 0x4d, 0x43, 0x41, 0x47, 0x45,
0x7b, 0x79, 0x7f, 0x7d, 0x73, 0x71, 0x77, 0x75, 0x6b, 0x69, 0x6f, 0x6d, 0x63, 0x61, 0x67, 0x65,
0x9b, 0x99, 0x9f, 0x9d, 0x93, 0x91, 0x97, 0x95, 0x8b, 0x89, 0x8f, 0x8d, 0x83, 0x81, 0x87, 0x85,
0xbb, 0xb9, 0xbf, 0xbd, 0xb3, 0xb1, 0xb7, 0xb5, 0xab, 0xa9, 0xaf, 0xad, 0xa3, 0xa1, 0xa7, 0xa5,
0xdb, 0xd9, 0xdf, 0xdd, 0xd3, 0xd1, 0xd7, 0xd5, 0xcb, 0xc9, 0xcf, 0xcd, 0xc3, 0xc1, 0xc7, 0xc5,
0xfb, 0xf9, 0xff, 0xfd, 0xf3, 0xf1, 0xf7, 0xf5, 0xeb, 0xe9, 0xef, 0xed, 0xe3, 0xe1, 0xe7, 0xe5
};
BYTE dot3_table[256] = {
0x00, 0x03, 0x06, 0x05, 0x0c, 0x0f, 0x0a, 0x09, 0x18, 0x1b, 0x1e, 0x1d, 0x14, 0x17, 0x12, 0x11,
0x30, 0x33, 0x36, 0x35, 0x3c, 0x3f, 0x3a, 0x39, 0x28, 0x2b, 0x2e, 0x2d, 0x24, 0x27, 0x22, 0x21,
0x60, 0x63, 0x66, 0x65, 0x6c, 0x6f, 0x6a, 0x69, 0x78, 0x7b, 0x7e, 0x7d, 0x74, 0x77, 0x72, 0x71,
0x50, 0x53, 0x56, 0x55, 0x5c, 0x5f, 0x5a, 0x59, 0x48, 0x4b, 0x4e, 0x4d, 0x44, 0x47, 0x42, 0x41,
0xc0, 0xc3, 0xc6, 0xc5, 0xcc, 0xcf, 0xca, 0xc9, 0xd8, 0xdb, 0xde, 0xdd, 0xd4, 0xd7, 0xd2, 0xd1,
0xf0, 0xf3, 0xf6, 0xf5, 0xfc, 0xff, 0xfa, 0xf9, 0xe8, 0xeb, 0xee, 0xed, 0xe4, 0xe7, 0xe2, 0xe1,
0xa0, 0xa3, 0xa6, 0xa5, 0xac, 0xaf, 0xaa, 0xa9, 0xb8, 0xbb, 0xbe, 0xbd, 0xb4, 0xb7, 0xb2, 0xb1,
0x90, 0x93, 0x96, 0x95, 0x9c, 0x9f, 0x9a, 0x99, 0x88, 0x8b, 0x8e, 0x8d, 0x84, 0x87, 0x82, 0x81,
0x9b, 0x98, 0x9d, 0x9e, 0x97, 0x94, 0x91, 0x92, 0x83, 0x80, 0x85, 0x86, 0x8f, 0x8c, 0x89, 0x8a,
0xab, 0xa8, 0xad, 0xae, 0xa7, 0xa4, 0xa1, 0xa2, 0xb3, 0xb0, 0xb5, 0xb6, 0xbf, 0xbc, 0xb9, 0xba,
0xfb, 0xf8, 0xfd, 0xfe, 0xf7, 0xf4, 0xf1, 0xf2, 0xe3, 0xe0, 0xe5, 0xe6, 0xef, 0xec, 0xe9, 0xea,
0xcb, 0xc8, 0xcd, 0xce, 0xc7, 0xc4, 0xc1, 0xc2, 0xd3, 0xd0, 0xd5, 0xd6, 0xdf, 0xdc, 0xd9, 0xda,
0x5b, 0x58, 0x5d, 0x5e, 0x57, 0x54, 0x51, 0x52, 0x43, 0x40, 0x45, 0x46, 0x4f, 0x4c, 0x49, 0x4a,
0x6b, 0x68, 0x6d, 0x6e, 0x67, 0x64, 0x61, 0x62, 0x73, 0x70, 0x75, 0x76, 0x7f, 0x7c, 0x79, 0x7a,
0x3b, 0x38, 0x3d, 0x3e, 0x37, 0x34, 0x31, 0x32, 0x23, 0x20, 0x25, 0x26, 0x2f, 0x2c, 0x29, 0x2a,
0x0b, 0x08, 0x0d, 0x0e, 0x07, 0x04, 0x01, 0x02, 0x13, 0x10, 0x15, 0x16, 0x1f, 0x1c, 0x19, 0x1a
};
/*--------------------- Static Functions --------------------------*/
/*--------------------- Export Variables --------------------------*/
/*--------------------- Export Functions --------------------------*/
void xor_128(BYTE *a, BYTE *b, BYTE *out)
{
PDWORD dwPtrA = (PDWORD) a;
PDWORD dwPtrB = (PDWORD) b;
PDWORD dwPtrOut =(PDWORD) out;
(*dwPtrOut++) = (*dwPtrA++) ^ (*dwPtrB++);
(*dwPtrOut++) = (*dwPtrA++) ^ (*dwPtrB++);
(*dwPtrOut++) = (*dwPtrA++) ^ (*dwPtrB++);
(*dwPtrOut++) = (*dwPtrA++) ^ (*dwPtrB++);
}
void xor_32(BYTE *a, BYTE *b, BYTE *out)
{
PDWORD dwPtrA = (PDWORD) a;
PDWORD dwPtrB = (PDWORD) b;
PDWORD dwPtrOut =(PDWORD) out;
(*dwPtrOut++) = (*dwPtrA++) ^ (*dwPtrB++);
}
void AddRoundKey(BYTE *key, int round)
{
BYTE sbox_key[4];
BYTE rcon_table[10] = { 0x01, 0x02, 0x04, 0x08, 0x10, 0x20, 0x40, 0x80, 0x1b, 0x36};
sbox_key[0] = sbox_table[key[13]];
sbox_key[1] = sbox_table[key[14]];
sbox_key[2] = sbox_table[key[15]];
sbox_key[3] = sbox_table[key[12]];
key[0] = key[0] ^ rcon_table[round];
xor_32(&key[0], sbox_key, &key[0]);
xor_32(&key[4], &key[0], &key[4]);
xor_32(&key[8], &key[4], &key[8]);
xor_32(&key[12], &key[8], &key[12]);
}
void SubBytes(BYTE *in, BYTE *out)
{
int i;
for (i=0; i< 16; i++)
{
out[i] = sbox_table[in[i]];
}
}
void ShiftRows(BYTE *in, BYTE *out)
{
out[0] = in[0];
out[1] = in[5];
out[2] = in[10];
out[3] = in[15];
out[4] = in[4];
out[5] = in[9];
out[6] = in[14];
out[7] = in[3];
out[8] = in[8];
out[9] = in[13];
out[10] = in[2];
out[11] = in[7];
out[12] = in[12];
out[13] = in[1];
out[14] = in[6];
out[15] = in[11];
}
void MixColumns(BYTE *in, BYTE *out)
{
out[0] = dot2_table[in[0]] ^ dot3_table[in[1]] ^ in[2] ^ in[3];
out[1] = in[0] ^ dot2_table[in[1]] ^ dot3_table[in[2]] ^ in[3];
out[2] = in[0] ^ in[1] ^ dot2_table[in[2]] ^ dot3_table[in[3]];
out[3] = dot3_table[in[0]] ^ in[1] ^ in[2] ^ dot2_table[in[3]];
}
void AESv128(BYTE *key, BYTE *data, BYTE *ciphertext)
{
int i;
int round;
BYTE TmpdataA[16];
BYTE TmpdataB[16];
BYTE abyRoundKey[16];
for(i=0; i<16; i++)
abyRoundKey[i] = key[i];
for (round = 0; round < 11; round++)
{
if (round == 0)
{
xor_128(abyRoundKey, data, ciphertext);
AddRoundKey(abyRoundKey, round);
}
else if (round == 10)
{
SubBytes(ciphertext, TmpdataA);
ShiftRows(TmpdataA, TmpdataB);
xor_128(TmpdataB, abyRoundKey, ciphertext);
}
else // round 1 ~ 9
{
SubBytes(ciphertext, TmpdataA);
ShiftRows(TmpdataA, TmpdataB);
MixColumns(&TmpdataB[0], &TmpdataA[0]);
MixColumns(&TmpdataB[4], &TmpdataA[4]);
MixColumns(&TmpdataB[8], &TmpdataA[8]);
MixColumns(&TmpdataB[12], &TmpdataA[12]);
xor_128(TmpdataA, abyRoundKey, ciphertext);
AddRoundKey(abyRoundKey, round);
}
}
}
/*
* Description: AES decryption
*
* Parameters:
* In:
* pbyRxKey - The key used to decrypt
* pbyFrame - Starting address of packet header
* wFrameSize - Total packet size including CRC
* Out:
* none
*
* Return Value: MIC compare result
*
*/
BOOL AESbGenCCMP(PBYTE pbyRxKey, PBYTE pbyFrame, WORD wFrameSize)
{
BYTE abyNonce[13];
BYTE MIC_IV[16];
BYTE MIC_HDR1[16];
BYTE MIC_HDR2[16];
BYTE abyMIC[16];
BYTE abyCTRPLD[16];
BYTE abyTmp[16];
BYTE abyPlainText[16];
BYTE abyLastCipher[16];
PS802_11Header pMACHeader = (PS802_11Header) pbyFrame;
PBYTE pbyIV;
PBYTE pbyPayload;
WORD wHLen = 22;
WORD wPayloadSize = wFrameSize - 8 - 8 - 4 - WLAN_HDR_ADDR3_LEN;//8 is IV, 8 is MIC, 4 is CRC
BOOL bA4 = FALSE;
BYTE byTmp;
WORD wCnt;
int ii,jj,kk;
pbyIV = pbyFrame + WLAN_HDR_ADDR3_LEN;
if ( WLAN_GET_FC_TODS(*(PWORD)pbyFrame) &&
WLAN_GET_FC_FROMDS(*(PWORD)pbyFrame) ) {
bA4 = TRUE;
pbyIV += 6; // 6 is 802.11 address4
wHLen += 6;
wPayloadSize -= 6;
}
pbyPayload = pbyIV + 8; //IV-length
abyNonce[0] = 0x00; //now is 0, if Qos here will be priority
MEMvCopy(&(abyNonce[1]), pMACHeader->abyAddr2, U_ETHER_ADDR_LEN);
abyNonce[7] = pbyIV[7];
abyNonce[8] = pbyIV[6];
abyNonce[9] = pbyIV[5];
abyNonce[10] = pbyIV[4];
abyNonce[11] = pbyIV[1];
abyNonce[12] = pbyIV[0];
//MIC_IV
MIC_IV[0] = 0x59;
MEMvCopy(&(MIC_IV[1]), &(abyNonce[0]), 13);
MIC_IV[14] = (BYTE)(wPayloadSize >> 8);
MIC_IV[15] = (BYTE)(wPayloadSize & 0xff);
//MIC_HDR1
MIC_HDR1[0] = (BYTE)(wHLen >> 8);
MIC_HDR1[1] = (BYTE)(wHLen & 0xff);
byTmp = (BYTE)(pMACHeader->wFrameCtl & 0xff);
MIC_HDR1[2] = byTmp & 0x8f;
byTmp = (BYTE)(pMACHeader->wFrameCtl >> 8);
byTmp &= 0x87;
MIC_HDR1[3] = byTmp | 0x40;
MEMvCopy(&(MIC_HDR1[4]), pMACHeader->abyAddr1, U_ETHER_ADDR_LEN);
MEMvCopy(&(MIC_HDR1[10]), pMACHeader->abyAddr2, U_ETHER_ADDR_LEN);
//MIC_HDR2
MEMvCopy(&(MIC_HDR2[0]), pMACHeader->abyAddr3, U_ETHER_ADDR_LEN);
byTmp = (BYTE)(pMACHeader->wSeqCtl & 0xff);
MIC_HDR2[6] = byTmp & 0x0f;
MIC_HDR2[7] = 0;
if ( bA4 ) {
MEMvCopy(&(MIC_HDR2[8]), pMACHeader->abyAddr4, U_ETHER_ADDR_LEN);
} else {
MIC_HDR2[8] = 0x00;
MIC_HDR2[9] = 0x00;
MIC_HDR2[10] = 0x00;
MIC_HDR2[11] = 0x00;
MIC_HDR2[12] = 0x00;
MIC_HDR2[13] = 0x00;
}
MIC_HDR2[14] = 0x00;
MIC_HDR2[15] = 0x00;
//CCMP
AESv128(pbyRxKey,MIC_IV,abyMIC);
for ( kk=0; kk<16; kk++ ) {
abyTmp[kk] = MIC_HDR1[kk] ^ abyMIC[kk];
}
AESv128(pbyRxKey,abyTmp,abyMIC);
for ( kk=0; kk<16; kk++ ) {
abyTmp[kk] = MIC_HDR2[kk] ^ abyMIC[kk];
}
AESv128(pbyRxKey,abyTmp,abyMIC);
wCnt = 1;
abyCTRPLD[0] = 0x01;
MEMvCopy(&(abyCTRPLD[1]), &(abyNonce[0]), 13);
for(jj=wPayloadSize; jj>16; jj=jj-16) {
abyCTRPLD[14] = (BYTE) (wCnt >> 8);
abyCTRPLD[15] = (BYTE) (wCnt & 0xff);
AESv128(pbyRxKey,abyCTRPLD,abyTmp);
for ( kk=0; kk<16; kk++ ) {
abyPlainText[kk] = abyTmp[kk] ^ pbyPayload[kk];
}
for ( kk=0; kk<16; kk++ ) {
abyTmp[kk] = abyMIC[kk] ^ abyPlainText[kk];
}
AESv128(pbyRxKey,abyTmp,abyMIC);
MEMvCopy(pbyPayload, abyPlainText, 16);
wCnt++;
pbyPayload += 16;
} //for wPayloadSize
//last payload
MEMvCopy(&(abyLastCipher[0]), pbyPayload, jj);
for ( ii=jj; ii<16; ii++ ) {
abyLastCipher[ii] = 0x00;
}
abyCTRPLD[14] = (BYTE) (wCnt >> 8);
abyCTRPLD[15] = (BYTE) (wCnt & 0xff);
AESv128(pbyRxKey,abyCTRPLD,abyTmp);
for ( kk=0; kk<16; kk++ ) {
abyPlainText[kk] = abyTmp[kk] ^ abyLastCipher[kk];
}
MEMvCopy(pbyPayload, abyPlainText, jj);
pbyPayload += jj;
//for MIC calculation
for ( ii=jj; ii<16; ii++ ) {
abyPlainText[ii] = 0x00;
}
for ( kk=0; kk<16; kk++ ) {
abyTmp[kk] = abyMIC[kk] ^ abyPlainText[kk];
}
AESv128(pbyRxKey,abyTmp,abyMIC);
//=>above is the calculate MIC
//--------------------------------------------
wCnt = 0;
abyCTRPLD[14] = (BYTE) (wCnt >> 8);
abyCTRPLD[15] = (BYTE) (wCnt & 0xff);
AESv128(pbyRxKey,abyCTRPLD,abyTmp);
for ( kk=0; kk<8; kk++ ) {
abyTmp[kk] = abyTmp[kk] ^ pbyPayload[kk];
}
//=>above is the dec-MIC from packet
//--------------------------------------------
if ( MEMEqualMemory(abyMIC,abyTmp,8) ) {
return TRUE;
} else {
return FALSE;
}
}

View File

@ -0,0 +1,48 @@
/*
* Copyright (c) 1996, 2003 VIA Networking Technologies, Inc.
* All rights reserved.
*
* This program is free software; you can redistribute it and/or modify
* it under the terms of the GNU General Public License as published by
* the Free Software Foundation; either version 2 of the License, or
* (at your option) any later version.
*
* This program is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
* GNU General Public License for more details.
*
* You should have received a copy of the GNU General Public License along
* with this program; if not, write to the Free Software Foundation, Inc.,
* 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA.
*
*
* File: aes_ccmp.h
*
* Purpose: AES_CCMP Decryption
*
* Author: Warren Hsu
*
* Date: Feb 15, 2005
*
*/
#ifndef __AES_H__
#define __AES_H__
#if !defined(__TTYPE_H__)
#include "ttype.h"
#endif
/*--------------------- Export Definitions -------------------------*/
/*--------------------- Export Types ------------------------------*/
/*--------------------- Export Classes ----------------------------*/
/*--------------------- Export Variables --------------------------*/
/*--------------------- Export Functions --------------------------*/
BOOL AESbGenCCMP(PBYTE pbyRxKey, PBYTE pbyFrame, WORD wFrameSize);
#endif //__AES_H__

File diff suppressed because it is too large Load Diff

View File

@ -0,0 +1,198 @@
/*
* Copyright (c) 1996, 2003 VIA Networking Technologies, Inc.
* All rights reserved.
*
* This program is free software; you can redistribute it and/or modify
* it under the terms of the GNU General Public License as published by
* the Free Software Foundation; either version 2 of the License, or
* (at your option) any later version.
*
* This program is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
* GNU General Public License for more details.
*
* You should have received a copy of the GNU General Public License along
* with this program; if not, write to the Free Software Foundation, Inc.,
* 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA.
*
* File: baseband.h
*
* Purpose: Implement functions to access baseband
*
* Author: Jerry Chen
*
* Date: Jun. 5, 2002
*
*/
#ifndef __BASEBAND_H__
#define __BASEBAND_H__
#if !defined(__TTYPE_H__)
#include "ttype.h"
#endif
#if !defined(__TETHER_H__)
#include "tether.h"
#endif
#if !defined(__DEVICE_H__)
#include "device.h"
#endif
/*--------------------- Export Definitions -------------------------*/
//
// Registers in the BASEBAND
//
#define BB_MAX_CONTEXT_SIZE 256
//
// Baseband RF pair definition in eeprom (Bits 6..0)
//
/*
#define RATE_1M 0
#define RATE_2M 1
#define RATE_5M 2
#define RATE_11M 3
#define RATE_6M 4
#define RATE_9M 5
#define RATE_12M 6
#define RATE_18M 7
#define RATE_24M 8
#define RATE_36M 9
#define RATE_48M 10
#define RATE_54M 11
#define RATE_AUTO 12
#define MAX_RATE 12
//0:11A 1:11B 2:11G
#define BB_TYPE_11A 0
#define BB_TYPE_11B 1
#define BB_TYPE_11G 2
//0:11a,1:11b,2:11gb(only CCK in BasicRate),3:11ga(OFDM in Basic Rate)
#define PK_TYPE_11A 0
#define PK_TYPE_11B 1
#define PK_TYPE_11GB 2
#define PK_TYPE_11GA 3
*/
#define PREAMBLE_LONG 0
#define PREAMBLE_SHORT 1
#define F5G 0
#define F2_4G 1
#define TOP_RATE_54M 0x80000000
#define TOP_RATE_48M 0x40000000
#define TOP_RATE_36M 0x20000000
#define TOP_RATE_24M 0x10000000
#define TOP_RATE_18M 0x08000000
#define TOP_RATE_12M 0x04000000
#define TOP_RATE_11M 0x02000000
#define TOP_RATE_9M 0x01000000
#define TOP_RATE_6M 0x00800000
#define TOP_RATE_55M 0x00400000
#define TOP_RATE_2M 0x00200000
#define TOP_RATE_1M 0x00100000
/*--------------------- Export Types ------------------------------*/
/*--------------------- Export Macros ------------------------------*/
#define BBvClearFOE(dwIoBase) \
{ \
BBbWriteEmbeded(dwIoBase, 0xB1, 0); \
}
#define BBvSetFOE(dwIoBase) \
{ \
BBbWriteEmbeded(dwIoBase, 0xB1, 0x0C); \
}
/*--------------------- Export Classes ----------------------------*/
/*--------------------- Export Variables --------------------------*/
/*--------------------- Export Functions --------------------------*/
#ifdef __cplusplus
extern "C" { /* Assume C declarations for C++ */
#endif /* __cplusplus */
UINT
BBuGetFrameTime(
IN BYTE byPreambleType,
IN BYTE byPktType,
IN UINT cbFrameLength,
IN WORD wRate
);
VOID
BBvCaculateParameter (
IN PSDevice pDevice,
IN UINT cbFrameLength,
IN WORD wRate,
IN BYTE byPacketType,
OUT PWORD pwPhyLen,
OUT PBYTE pbyPhySrv,
OUT PBYTE pbyPhySgn
);
BOOL BBbReadEmbeded(DWORD_PTR dwIoBase, BYTE byBBAddr, PBYTE pbyData);
BOOL BBbWriteEmbeded(DWORD_PTR dwIoBase, BYTE byBBAddr, BYTE byData);
VOID BBvReadAllRegs(DWORD_PTR dwIoBase, PBYTE pbyBBRegs);
void BBvLoopbackOn(PSDevice pDevice);
void BBvLoopbackOff(PSDevice pDevice);
void BBvSetShortSlotTime(PSDevice pDevice);
BOOL BBbIsRegBitsOn(DWORD_PTR dwIoBase, BYTE byBBAddr, BYTE byTestBits);
BOOL BBbIsRegBitsOff(DWORD_PTR dwIoBase, BYTE byBBAddr, BYTE byTestBits);
VOID BBvSetVGAGainOffset(PSDevice pDevice, BYTE byData);
// VT3253 Baseband
BOOL BBbVT3253Init(PSDevice pDevice);
VOID BBvSoftwareReset(DWORD_PTR dwIoBase);
VOID BBvPowerSaveModeON(DWORD_PTR dwIoBase);
VOID BBvPowerSaveModeOFF(DWORD_PTR dwIoBase);
VOID BBvSetTxAntennaMode(DWORD_PTR dwIoBase, BYTE byAntennaMode);
VOID BBvSetRxAntennaMode(DWORD_PTR dwIoBase, BYTE byAntennaMode);
VOID BBvSetDeepSleep(DWORD_PTR dwIoBase, BYTE byLocalID);
VOID BBvExitDeepSleep(DWORD_PTR dwIoBase, BYTE byLocalID);
// timer for antenna diversity
VOID
TimerSQ3CallBack(
IN HANDLE hDeviceContext
);
VOID
TimerState1CallBack(
IN HANDLE hDeviceContext
);
void BBvAntennaDiversity(PSDevice pDevice, BYTE byRxRate, BYTE bySQ3);
VOID
BBvClearAntDivSQ3Value (PSDevice pDevice);
#ifdef __cplusplus
} /* End of extern "C" { */
#endif /* __cplusplus */
#endif // __BASEBAND_H__

File diff suppressed because it is too large Load Diff

View File

@ -0,0 +1,380 @@
/*
* Copyright (c) 1996, 2003 VIA Networking Technologies, Inc.
* All rights reserved.
*
* This program is free software; you can redistribute it and/or modify
* it under the terms of the GNU General Public License as published by
* the Free Software Foundation; either version 2 of the License, or
* (at your option) any later version.
*
* This program is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
* GNU General Public License for more details.
*
* You should have received a copy of the GNU General Public License along
* with this program; if not, write to the Free Software Foundation, Inc.,
* 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA.
*
*
* File: bssdb.h
*
* Purpose: Handles the Basic Service Set & Node Database functions
*
* Author: Lyndon Chen
*
* Date: July 16, 2002
*
*/
#ifndef __BSSDB_H__
#define __BSSDB_H__
//#if !defined(__DEVICE_H__)
//#include "device.h"
//#endif
#include <linux/skbuff.h>
#if !defined(__80211HDR_H__)
#include "80211hdr.h"
#endif
#if !defined(__80211MGR_H__)
#include "80211mgr.h"
#endif
#if !defined(__CARD_H__)
#include "card.h"
#endif
/*--------------------- Export Definitions -------------------------*/
#define MAX_NODE_NUM 64
#define MAX_BSS_NUM 42
#define LOST_BEACON_COUNT 10 // 10 sec, XP defined
#define MAX_PS_TX_BUF 32 // sta max power saving tx buf
#define ADHOC_LOST_BEACON_COUNT 30 // 30 sec, beacon lost for adhoc only
#define MAX_INACTIVE_COUNT 300 // 300 sec, inactive STA node refresh
#define USE_PROTECT_PERIOD 10 // 10 sec, Use protect mode check period
#define ERP_RECOVER_COUNT 30 // 30 sec, ERP support callback check
#define BSS_CLEAR_COUNT 1
#define RSSI_STAT_COUNT 10
#define MAX_CHECK_RSSI_COUNT 8
// STA dwflags
#define WLAN_STA_AUTH BIT0
#define WLAN_STA_ASSOC BIT1
#define WLAN_STA_PS BIT2
#define WLAN_STA_TIM BIT3
// permanent; do not remove entry on expiration
#define WLAN_STA_PERM BIT4
// If 802.1X is used, this flag is
// controlling whether STA is authorized to
// send and receive non-IEEE 802.1X frames
#define WLAN_STA_AUTHORIZED BIT5
#define MAX_RATE 12
#define MAX_WPA_IE_LEN 64
/*--------------------- Export Classes ----------------------------*/
/*--------------------- Export Variables --------------------------*/
/*--------------------- Export Types ------------------------------*/
//
// IEEE 802.11 Structures and definitions
//
typedef enum _NDIS_802_11_NETWORK_TYPE
{
Ndis802_11FH,
Ndis802_11DS,
Ndis802_11OFDM5,
Ndis802_11OFDM24,
Ndis802_11NetworkTypeMax // not a real type, defined as an upper bound
} NDIS_802_11_NETWORK_TYPE, *PNDIS_802_11_NETWORK_TYPE;
typedef struct tagSERPObject {
BOOL bERPExist;
BYTE byERP;
} ERPObject, DEF* PERPObject;
typedef struct tagSRSNCapObject {
BOOL bRSNCapExist;
WORD wRSNCap;
} SRSNCapObject, DEF* PSRSNCapObject;
// BSS info(AP)
#pragma pack(1)
typedef struct tagKnownBSS {
// BSS info
BOOL bActive;
BYTE abyBSSID[WLAN_BSSID_LEN];
UINT uChannel;
BYTE abySuppRates[WLAN_IEHDR_LEN + WLAN_RATES_MAXLEN + 1];
BYTE abyExtSuppRates[WLAN_IEHDR_LEN + WLAN_RATES_MAXLEN + 1];
UINT uRSSI;
BYTE bySQ;
WORD wBeaconInterval;
WORD wCapInfo;
BYTE abySSID[WLAN_IEHDR_LEN + WLAN_SSID_MAXLEN + 1];
BYTE byRxRate;
// WORD wATIMWindow;
BYTE byRSSIStatCnt;
LONG ldBmMAX;
LONG ldBmAverage[RSSI_STAT_COUNT];
LONG ldBmAverRange;
//For any BSSID selection improvment
BOOL bSelected;
//++ WPA informations
BOOL bWPAValid;
BYTE byGKType;
BYTE abyPKType[4];
WORD wPKCount;
BYTE abyAuthType[4];
WORD wAuthCount;
BYTE byDefaultK_as_PK;
BYTE byReplayIdx;
//--
//++ WPA2 informations
BOOL bWPA2Valid;
BYTE byCSSGK;
WORD wCSSPKCount;
BYTE abyCSSPK[4];
WORD wAKMSSAuthCount;
BYTE abyAKMSSAuthType[4];
//++ wpactl
BYTE byWPAIE[MAX_WPA_IE_LEN];
BYTE byRSNIE[MAX_WPA_IE_LEN];
WORD wWPALen;
WORD wRSNLen;
// Clear count
UINT uClearCount;
// BYTE abyIEs[WLAN_BEACON_FR_MAXLEN];
UINT uIELength;
QWORD qwBSSTimestamp;
QWORD qwLocalTSF; // local TSF timer
// NDIS_802_11_NETWORK_TYPE NetworkTypeInUse;
CARD_PHY_TYPE eNetworkTypeInUse;
ERPObject sERP;
SRSNCapObject sRSNCapObj;
BYTE abyIEs[1024]; // don't move this field !!
}__attribute__ ((__packed__))
KnownBSS , DEF* PKnownBSS;
//2006-1116-01,<Add> by NomadZhao
#pragma pack()
typedef enum tagNODE_STATE {
NODE_FREE,
NODE_AGED,
NODE_KNOWN,
NODE_AUTH,
NODE_ASSOC
} NODE_STATE, *PNODE_STATE;
// STA node info
typedef struct tagKnownNodeDB {
// STA info
BOOL bActive;
BYTE abyMACAddr[WLAN_ADDR_LEN];
BYTE abyCurrSuppRates[WLAN_IEHDR_LEN + WLAN_RATES_MAXLEN];
BYTE abyCurrExtSuppRates[WLAN_IEHDR_LEN + WLAN_RATES_MAXLEN];
WORD wTxDataRate;
BOOL bShortPreamble;
BOOL bERPExist;
BOOL bShortSlotTime;
UINT uInActiveCount;
WORD wMaxBasicRate; //Get from byTopOFDMBasicRate or byTopCCKBasicRate which depends on packetTyp.
WORD wMaxSuppRate; //Records the highest supported rate getting from SuppRates IE and ExtSuppRates IE in Beacon.
WORD wSuppRate;
BYTE byTopOFDMBasicRate;//Records the highest basic rate in OFDM mode
BYTE byTopCCKBasicRate; //Records the highest basic rate in CCK mode
// For AP mode
struct sk_buff_head sTxPSQueue;
WORD wCapInfo;
WORD wListenInterval;
WORD wAID;
NODE_STATE eNodeState;
BOOL bPSEnable;
BOOL bRxPSPoll;
BYTE byAuthSequence;
ULONG ulLastRxJiffer;
BYTE bySuppRate;
DWORD dwFlags;
WORD wEnQueueCnt;
BOOL bOnFly;
ULONGLONG KeyRSC;
BYTE byKeyIndex;
DWORD dwKeyIndex;
BYTE byCipherSuite;
DWORD dwTSC47_16;
WORD wTSC15_0;
UINT uWepKeyLength;
BYTE abyWepKey[WLAN_WEPMAX_KEYLEN];
//
// Auto rate fallback vars
BOOL bIsInFallback;
UINT uAverageRSSI;
UINT uRateRecoveryTimeout;
UINT uRatePollTimeout;
UINT uTxFailures;
UINT uTxAttempts;
UINT uTxRetry;
UINT uFailureRatio;
UINT uRetryRatio;
UINT uTxOk[MAX_RATE+1];
UINT uTxFail[MAX_RATE+1];
UINT uTimeCount;
} KnownNodeDB, DEF* PKnownNodeDB;
/*--------------------- Export Functions --------------------------*/
PKnownBSS
BSSpSearchBSSList(
IN HANDLE hDeviceContext,
IN PBYTE pbyDesireBSSID,
IN PBYTE pbyDesireSSID,
IN CARD_PHY_TYPE ePhyType
);
PKnownBSS
BSSpAddrIsInBSSList(
IN HANDLE hDeviceContext,
IN PBYTE abyBSSID,
IN PWLAN_IE_SSID pSSID
);
VOID
BSSvClearBSSList(
IN HANDLE hDeviceContext,
IN BOOL bKeepCurrBSSID
);
BOOL
BSSbInsertToBSSList(
IN HANDLE hDeviceContext,
IN PBYTE abyBSSIDAddr,
IN QWORD qwTimestamp,
IN WORD wBeaconInterval,
IN WORD wCapInfo,
IN BYTE byCurrChannel,
IN PWLAN_IE_SSID pSSID,
IN PWLAN_IE_SUPP_RATES pSuppRates,
IN PWLAN_IE_SUPP_RATES pExtSuppRates,
IN PERPObject psERP,
IN PWLAN_IE_RSN pRSN,
IN PWLAN_IE_RSN_EXT pRSNWPA,
IN PWLAN_IE_COUNTRY pIE_Country,
IN PWLAN_IE_QUIET pIE_Quiet,
IN UINT uIELength,
IN PBYTE pbyIEs,
IN HANDLE pRxPacketContext
);
BOOL
BSSbUpdateToBSSList(
IN HANDLE hDeviceContext,
IN QWORD qwTimestamp,
IN WORD wBeaconInterval,
IN WORD wCapInfo,
IN BYTE byCurrChannel,
IN BOOL bChannelHit,
IN PWLAN_IE_SSID pSSID,
IN PWLAN_IE_SUPP_RATES pSuppRates,
IN PWLAN_IE_SUPP_RATES pExtSuppRates,
IN PERPObject psERP,
IN PWLAN_IE_RSN pRSN,
IN PWLAN_IE_RSN_EXT pRSNWPA,
IN PWLAN_IE_COUNTRY pIE_Country,
IN PWLAN_IE_QUIET pIE_Quiet,
IN PKnownBSS pBSSList,
IN UINT uIELength,
IN PBYTE pbyIEs,
IN HANDLE pRxPacketContext
);
BOOL
BSSDBbIsSTAInNodeDB(
IN HANDLE hDeviceContext,
IN PBYTE abyDstAddr,
OUT PUINT puNodeIndex
);
VOID
BSSvCreateOneNode(
IN HANDLE hDeviceContext,
OUT PUINT puNodeIndex
);
VOID
BSSvUpdateAPNode(
IN HANDLE hDeviceContext,
IN PWORD pwCapInfo,
IN PWLAN_IE_SUPP_RATES pItemRates,
IN PWLAN_IE_SUPP_RATES pExtSuppRates
);
VOID
BSSvSecondCallBack(
IN HANDLE hDeviceContext
);
VOID
BSSvUpdateNodeTxCounter(
IN HANDLE hDeviceContext,
IN BYTE byTsr0,
IN BYTE byTsr1,
IN PBYTE pbyBuffer,
IN UINT uFIFOHeaderSize
);
VOID
BSSvRemoveOneNode(
IN HANDLE hDeviceContext,
IN UINT uNodeIndex
);
VOID
BSSvAddMulticastNode(
IN HANDLE hDeviceContext
);
VOID
BSSvClearNodeDBTable(
IN HANDLE hDeviceContext,
IN UINT uStartIndex
);
VOID
BSSvClearAnyBSSJoinRecord(
IN HANDLE hDeviceContext
);
#endif //__BSSDB_H__

File diff suppressed because it is too large Load Diff

View File

@ -0,0 +1,273 @@
/*
* Copyright (c) 1996, 2003 VIA Networking Technologies, Inc.
* All rights reserved.
*
* This program is free software; you can redistribute it and/or modify
* it under the terms of the GNU General Public License as published by
* the Free Software Foundation; either version 2 of the License, or
* (at your option) any later version.
*
* This program is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
* GNU General Public License for more details.
*
* You should have received a copy of the GNU General Public License along
* with this program; if not, write to the Free Software Foundation, Inc.,
* 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA.
*
* File: card.h
*
* Purpose: Provide functions to setup NIC operation mode
*
* Author: Tevin Chen
*
* Date: May 21, 1996
*
*/
#ifndef __CARD_H__
#define __CARD_H__
//#if !defined(__DEVICE_H__)
//#include "device.h"
//#endif
#if !defined(__TTYPE_H__)
#include "ttype.h"
#endif
/*--------------------- Export Definitions -------------------------*/
//
// Loopback mode
//
// LOBYTE is MAC LB mode, HIBYTE is MII LB mode
#define CARD_LB_NONE MAKEWORD(MAC_LB_NONE, 0)
#define CARD_LB_MAC MAKEWORD(MAC_LB_INTERNAL, 0) // PHY must ISO, avoid MAC loopback packet go out
#define CARD_LB_PHY MAKEWORD(MAC_LB_EXT, 0)
#define DEFAULT_MSDU_LIFETIME 512 // ms
#define DEFAULT_MSDU_LIFETIME_RES_64us 8000 // 64us
#define DEFAULT_MGN_LIFETIME 8 // ms
#define DEFAULT_MGN_LIFETIME_RES_64us 125 // 64us
#define CB_MAX_CHANNEL_24G 14
#define CB_MAX_CHANNEL_5G 42 //[20050104] add channel9(5045MHz), 41==>42
#define CB_MAX_CHANNEL (CB_MAX_CHANNEL_24G+CB_MAX_CHANNEL_5G)
typedef enum _CARD_PHY_TYPE {
PHY_TYPE_AUTO,
PHY_TYPE_11B,
PHY_TYPE_11G,
PHY_TYPE_11A
} CARD_PHY_TYPE, *PCARD_PHY_TYPE;
typedef enum _CARD_PKT_TYPE {
PKT_TYPE_802_11_BCN,
PKT_TYPE_802_11_MNG,
PKT_TYPE_802_11_DATA,
PKT_TYPE_802_11_ALL
} CARD_PKT_TYPE, *PCARD_PKT_TYPE;
typedef enum _CARD_STATUS_TYPE {
CARD_STATUS_MEDIA_CONNECT,
CARD_STATUS_MEDIA_DISCONNECT,
CARD_STATUS_PMKID
} CARD_STATUS_TYPE, *PCARD_STATUS_TYPE;
typedef enum _CARD_OP_MODE {
OP_MODE_INFRASTRUCTURE,
OP_MODE_ADHOC,
OP_MODE_AP,
OP_MODE_UNKNOWN
} CARD_OP_MODE, *PCARD_OP_MODE;
/*--------------------- Export Classes ----------------------------*/
/*--------------------- Export Variables --------------------------*/
/*--------------------- Export Functions --------------------------*/
#ifdef __cplusplus
extern "C" { /* Assume C declarations for C++ */
#endif /* __cplusplus */
BOOL ChannelValid(UINT CountryCode, UINT ChannelIndex);
void CARDvSetRSPINF(PVOID pDeviceHandler, CARD_PHY_TYPE ePHYType);
void vUpdateIFS(PVOID pDeviceHandler);
void CARDvUpdateBasicTopRate(PVOID pDeviceHandler);
BOOL CARDbAddBasicRate(PVOID pDeviceHandler, WORD wRateIdx);
BOOL CARDbIsOFDMinBasicRate(PVOID pDeviceHandler);
void CARDvSetLoopbackMode(DWORD_PTR dwIoBase, WORD wLoopbackMode);
BOOL CARDbSoftwareReset(PVOID pDeviceHandler);
void CARDvSetFirstNextTBTT(DWORD_PTR dwIoBase, WORD wBeaconInterval);
void CARDvUpdateNextTBTT(DWORD_PTR dwIoBase, QWORD qwTSF, WORD wBeaconInterval);
BOOL CARDbGetCurrentTSF(DWORD_PTR dwIoBase, PQWORD pqwCurrTSF);
QWORD CARDqGetNextTBTT(QWORD qwTSF, WORD wBeaconInterval);
QWORD CARDqGetTSFOffset(BYTE byRxRate, QWORD qwTSF1, QWORD qwTSF2);
BOOL CARDbSetTxPower(PVOID pDeviceHandler, ULONG ulTxPower);
BYTE CARDbyGetPktType(PVOID pDeviceHandler);
VOID CARDvSafeResetTx(PVOID pDeviceHandler);
VOID CARDvSafeResetRx(PVOID pDeviceHandler);
//xxx
BOOL CARDbRadioPowerOff(PVOID pDeviceHandler);
BOOL CARDbRadioPowerOn(PVOID pDeviceHandler);
BOOL CARDbSetChannel(PVOID pDeviceHandler, UINT uConnectionChannel);
//BOOL CARDbSendPacket(PVOID pDeviceHandler, PVOID pPacket, CARD_PKT_TYPE ePktType, UINT uLength);
BOOL CARDbIsShortPreamble(PVOID pDeviceHandler);
BOOL CARDbIsShorSlotTime(PVOID pDeviceHandler);
BOOL CARDbSetPhyParameter(PVOID pDeviceHandler, CARD_PHY_TYPE ePHYType, WORD wCapInfo, BYTE byERPField, PVOID pvSupportRateIEs, PVOID pvExtSupportRateIEs);
BOOL CARDbUpdateTSF(PVOID pDeviceHandler, BYTE byRxRate, QWORD qwBSSTimestamp, QWORD qwLocalTSF);
BOOL CARDbStopTxPacket(PVOID pDeviceHandler, CARD_PKT_TYPE ePktType);
BOOL CARDbStartTxPacket(PVOID pDeviceHandler, CARD_PKT_TYPE ePktType);
BOOL CARDbSetBeaconPeriod(PVOID pDeviceHandler, WORD wBeaconInterval);
BOOL CARDbSetBSSID(PVOID pDeviceHandler, PBYTE pbyBSSID, CARD_OP_MODE eOPMode);
BOOL
CARDbPowerDown(
PVOID pDeviceHandler
);
BOOL CARDbSetTxDataRate(
PVOID pDeviceHandler,
WORD wDataRate
);
BOOL CARDbRemoveKey (PVOID pDeviceHandler, PBYTE pbyBSSID);
BOOL
CARDbAdd_PMKID_Candidate (
IN PVOID pDeviceHandler,
IN PBYTE pbyBSSID,
IN BOOL bRSNCapExist,
IN WORD wRSNCap
);
PVOID
CARDpGetCurrentAddress (
IN PVOID pDeviceHandler
);
VOID CARDvInitChannelTable(PVOID pDeviceHandler);
BYTE CARDbyGetChannelMapping(PVOID pDeviceHandler, BYTE byChannelNumber, CARD_PHY_TYPE ePhyType);
BOOL
CARDbStartMeasure (
IN PVOID pDeviceHandler,
IN PVOID pvMeasureEIDs,
IN UINT uNumOfMeasureEIDs
);
BOOL
CARDbChannelSwitch (
IN PVOID pDeviceHandler,
IN BYTE byMode,
IN BYTE byNewChannel,
IN BYTE byCount
);
BOOL
CARDbSetQuiet (
IN PVOID pDeviceHandler,
IN BOOL bResetQuiet,
IN BYTE byQuietCount,
IN BYTE byQuietPeriod,
IN WORD wQuietDuration,
IN WORD wQuietOffset
);
BOOL
CARDbStartQuiet (
IN PVOID pDeviceHandler
);
VOID
CARDvSetCountryInfo (
IN PVOID pDeviceHandler,
IN CARD_PHY_TYPE ePHYType,
IN PVOID pIE
);
VOID
CARDvSetPowerConstraint (
IN PVOID pDeviceHandler,
IN BYTE byChannel,
IN I8 byPower
);
VOID
CARDvGetPowerCapability (
IN PVOID pDeviceHandler,
OUT PBYTE pbyMinPower,
OUT PBYTE pbyMaxPower
);
BYTE
CARDbySetSupportChannels (
IN PVOID pDeviceHandler,
IN OUT PBYTE pbyIEs
);
I8
CARDbyGetTransmitPower (
IN PVOID pDeviceHandler
);
BOOL
CARDbChannelGetList (
IN UINT uCountryCodeIdx,
OUT PBYTE pbyChannelTable
);
VOID
CARDvSetCountryIE(
IN PVOID pDeviceHandler,
IN PVOID pIE
);
BOOL
CARDbGetChannelMapInfo(
IN PVOID pDeviceHandler,
IN UINT uChannelIndex,
OUT PBYTE pbyChannelNumber,
OUT PBYTE pbyMap
);
VOID
CARDvSetChannelMapInfo(
IN PVOID pDeviceHandler,
IN UINT uChannelIndex,
IN BYTE byMap
);
VOID
CARDvClearChannelMapInfo(
IN PVOID pDeviceHandler
);
BYTE
CARDbyAutoChannelSelect(
IN PVOID pDeviceHandler,
CARD_PHY_TYPE ePHYType
);
BYTE CARDbyGetChannelNumber(PVOID pDeviceHandler, BYTE byChannelIndex);
#ifdef __cplusplus
} /* End of extern "C" { */
#endif /* __cplusplus */
#endif // __CARD_H__

View File

@ -0,0 +1,192 @@
/*
* Copyright (c) 1996, 2003 VIA Networking Technologies, Inc.
* All rights reserved.
*
* This program is free software; you can redistribute it and/or modify
* it under the terms of the GNU General Public License as published by
* the Free Software Foundation; either version 2 of the License, or
* (at your option) any later version.
*
* This program is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
* GNU General Public License for more details.
*
* You should have received a copy of the GNU General Public License along
* with this program; if not, write to the Free Software Foundation, Inc.,
* 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA.
*
*
* File: country.h
*
* Purpose: Country Code information
*
* Author: Lucas Lin
*
* Date: Dec 23, 2004
*
*/
#ifndef __COUNTRY_H__
#define __COUNTRY_H__
#if !defined(__TTYPE_H__)
#include "ttype.h"
#endif
/*--------------------- Export Definitions -------------------------*/
/************************************************************************
* The definition here should be complied with the INF country order
* Please check with VNWL.inf/VNWL64.inf/VNWL*.inf
************************************************************************/
typedef enum _COUNTRY_CODE {
CCODE_FCC = 0,
CCODE_TELEC,
CCODE_ETSI,
CCODE_RESV3,
CCODE_RESV4,
CCODE_RESV5,
CCODE_RESV6,
CCODE_RESV7,
CCODE_RESV8,
CCODE_RESV9,
CCODE_RESVa,
CCODE_RESVb,
CCODE_RESVc,
CCODE_RESVd,
CCODE_RESVe,
CCODE_ALLBAND,
CCODE_ALBANIA,
CCODE_ALGERIA,
CCODE_ARGENTINA,
CCODE_ARMENIA,
CCODE_AUSTRALIA,
CCODE_AUSTRIA,
CCODE_AZERBAIJAN,
CCODE_BAHRAIN,
CCODE_BELARUS,
CCODE_BELGIUM,
CCODE_BELIZE,
CCODE_BOLIVIA,
CCODE_BRAZIL,
CCODE_BRUNEI_DARUSSALAM,
CCODE_BULGARIA,
CCODE_CANADA,
CCODE_CHILE,
CCODE_CHINA,
CCODE_COLOMBIA,
CCODE_COSTA_RICA,
CCODE_CROATIA,
CCODE_CYPRUS,
CCODE_CZECH,
CCODE_DENMARK,
CCODE_DOMINICAN_REPUBLIC,
CCODE_ECUADOR,
CCODE_EGYPT,
CCODE_EL_SALVADOR,
CCODE_ESTONIA,
CCODE_FINLAND,
CCODE_FRANCE,
CCODE_GERMANY,
CCODE_GREECE,
CCODE_GEORGIA,
CCODE_GUATEMALA,
CCODE_HONDURAS,
CCODE_HONG_KONG,
CCODE_HUNGARY,
CCODE_ICELAND,
CCODE_INDIA,
CCODE_INDONESIA,
CCODE_IRAN,
CCODE_IRELAND,
CCODE_ITALY,
CCODE_ISRAEL,
CCODE_JAPAN,
CCODE_JORDAN,
CCODE_KAZAKHSTAN,
CCODE_KUWAIT,
CCODE_LATVIA,
CCODE_LEBANON,
CCODE_LEICHTENSTEIN,
CCODE_LITHUANIA,
CCODE_LUXEMBURG,
CCODE_MACAU,
CCODE_MACEDONIA,
CCODE_MALTA,
CCODE_MALAYSIA,
CCODE_MEXICO,
CCODE_MONACO,
CCODE_MOROCCO,
CCODE_NETHERLANDS,
CCODE_NEW_ZEALAND,
CCODE_NORTH_KOREA,
CCODE_NORWAY,
CCODE_OMAN,
CCODE_PAKISTAN,
CCODE_PANAMA,
CCODE_PERU,
CCODE_PHILIPPINES,
CCODE_POLAND,
CCODE_PORTUGAL,
CCODE_PUERTO_RICO,
CCODE_QATAR,
CCODE_ROMANIA,
CCODE_RUSSIA,
CCODE_SAUDI_ARABIA,
CCODE_SINGAPORE,
CCODE_SLOVAKIA,
CCODE_SLOVENIA,
CCODE_SOUTH_AFRICA,
CCODE_SOUTH_KOREA,
CCODE_SPAIN,
CCODE_SWEDEN,
CCODE_SWITZERLAND,
CCODE_SYRIA,
CCODE_TAIWAN,
CCODE_THAILAND,
CCODE_TRINIDAD_TOBAGO,
CCODE_TUNISIA,
CCODE_TURKEY,
CCODE_UK,
CCODE_UKRAINE,
CCODE_UNITED_ARAB_EMIRATES,
CCODE_UNITED_STATES,
CCODE_URUGUAY,
CCODE_UZBEKISTAN,
CCODE_VENEZUELA,
CCODE_VIETNAM,
CCODE_YEMEN,
CCODE_ZIMBABWE,
CCODE_JAPAN_W52_W53,
CCODE_MAX
} COUNTRY_CODE;
typedef struct tagSCountryTable
{
BYTE byChannelCountryCode; /* The country code */
CHAR chCountryCode[2];
BYTE bChannelIdxList[CB_MAX_CHANNEL]; /* Available channels Index */
BYTE byPower[CB_MAX_CHANNEL];
} SCountryTable, DEF* PSCountryTable;
/*--------------------- Export Classes ----------------------------*/
/*--------------------- Export Variables --------------------------*/
extern SCountryTable ChannelRuleTab[CCODE_MAX+1];
/*--------------------- Export Functions --------------------------*/
#ifdef __cplusplus
extern "C" { /* Assume C declarations for C++ */
#endif /* __cplusplus */
#ifdef __cplusplus
} /* End of extern "C" { */
#endif /* __cplusplus */
/************************************************************************
* Function prototype
************************************************************************/
#endif /* __COUNTRY_H__ */

View File

@ -0,0 +1,455 @@
/*
* Copyright (c) 1996, 2003 VIA Networking Technologies, Inc.
* All rights reserved.
*
* This program is free software; you can redistribute it and/or modify
* it under the terms of the GNU General Public License as published by
* the Free Software Foundation; either version 2 of the License, or
* (at your option) any later version.
*
* This program is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
* GNU General Public License for more details.
*
* You should have received a copy of the GNU General Public License along
* with this program; if not, write to the Free Software Foundation, Inc.,
* 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA.
*
* File: datarate.c
*
* Purpose: Handles the auto fallback & data rates functions
*
* Author: Lyndon Chen
*
* Date: July 17, 2002
*
* Functions:
* RATEvParseMaxRate - Parsing the highest basic & support rate in rate field of frame
* RATEvTxRateFallBack - Rate fallback Algorithm Implementaion
* RATEuSetIE- Set rate IE field.
*
* Revision History:
*
*/
#if !defined(__TTYPE_H__)
#include "ttype.h"
#endif
#if !defined(__TMACRO_H__)
#include "tmacro.h"
#endif
#if !defined(__MAC_H__)
#include "mac.h"
#endif
#if !defined(__80211MGR_H__)
#include "80211mgr.h"
#endif
#if !defined(__BSSDB_H__)
#include "bssdb.h"
#endif
#if !defined(__DATARATE_H__)
#include "datarate.h"
#endif
#if !defined(__CARD_H__)
#include "card.h"
#endif
#if !defined(__BASEBAND_H__)
#include "baseband.h"
#endif
#if !defined(__SROM_H__)
#include "srom.h"
#endif
/*--------------------- Static Definitions -------------------------*/
/*--------------------- Static Classes ----------------------------*/
extern WORD TxRate_iwconfig; //2008-5-8 <add> by chester
/*--------------------- Static Variables --------------------------*/
//static int msglevel =MSG_LEVEL_DEBUG;
static int msglevel =MSG_LEVEL_INFO;
const BYTE acbyIERate[MAX_RATE] =
{0x02, 0x04, 0x0B, 0x16, 0x0C, 0x12, 0x18, 0x24, 0x30, 0x48, 0x60, 0x6C};
#define AUTORATE_TXOK_CNT 0x0400
#define AUTORATE_TXFAIL_CNT 0x0064
#define AUTORATE_TIMEOUT 10
/*--------------------- Static Functions --------------------------*/
VOID s_vResetCounter (
IN PKnownNodeDB psNodeDBTable
);
VOID
s_vResetCounter (
IN PKnownNodeDB psNodeDBTable
)
{
BYTE ii;
// clear statistic counter for auto_rate
for(ii=0;ii<=MAX_RATE;ii++) {
psNodeDBTable->uTxOk[ii] = 0;
psNodeDBTable->uTxFail[ii] = 0;
}
}
/*--------------------- Export Variables --------------------------*/
/*--------------------- Export Functions --------------------------*/
/*+
*
* Description:
* Get RateIdx from the value in SuppRates IE or ExtSuppRates IE
*
* Parameters:
* In:
* BYTE - Rate value in SuppRates IE or ExtSuppRates IE
* Out:
* none
*
* Return Value: RateIdx
*
-*/
BYTE
DATARATEbyGetRateIdx (
IN BYTE byRate
)
{
BYTE ii;
//Erase basicRate flag.
byRate = byRate & 0x7F;//0111 1111
for (ii = 0; ii < MAX_RATE; ii ++) {
if (acbyIERate[ii] == byRate)
return ii;
}
return 0;
}
/*+
*
* Routine Description:
* Rate fallback Algorithm Implementaion
*
* Parameters:
* In:
* pDevice - Pointer to the adapter
* psNodeDBTable - Pointer to Node Data Base
* Out:
* none
*
* Return Value: none
*
-*/
#define AUTORATE_TXCNT_THRESHOLD 20
#define AUTORATE_INC_THRESHOLD 30
/*+
*
* Description:
* Get RateIdx from the value in SuppRates IE or ExtSuppRates IE
*
* Parameters:
* In:
* BYTE - Rate value in SuppRates IE or ExtSuppRates IE
* Out:
* none
*
* Return Value: RateIdx
*
-*/
WORD
wGetRateIdx(
IN BYTE byRate
)
{
WORD ii;
//Erase basicRate flag.
byRate = byRate & 0x7F;//0111 1111
for (ii = 0; ii < MAX_RATE; ii ++) {
if (acbyIERate[ii] == byRate)
return ii;
}
return 0;
}
/*+
*
* Description:
* Parsing the highest basic & support rate in rate field of frame.
*
* Parameters:
* In:
* pDevice - Pointer to the adapter
* pItemRates - Pointer to Rate field defined in 802.11 spec.
* pItemExtRates - Pointer to Extended Rate field defined in 802.11 spec.
* Out:
* pwMaxBasicRate - Maximum Basic Rate
* pwMaxSuppRate - Maximum Supported Rate
* pbyTopCCKRate - Maximum Basic Rate in CCK mode
* pbyTopOFDMRate - Maximum Basic Rate in OFDM mode
*
* Return Value: none
*
-*/
VOID
RATEvParseMaxRate (
IN PVOID pDeviceHandler,
IN PWLAN_IE_SUPP_RATES pItemRates,
IN PWLAN_IE_SUPP_RATES pItemExtRates,
IN BOOL bUpdateBasicRate,
OUT PWORD pwMaxBasicRate,
OUT PWORD pwMaxSuppRate,
OUT PWORD pwSuppRate,
OUT PBYTE pbyTopCCKRate,
OUT PBYTE pbyTopOFDMRate
)
{
PSDevice pDevice = (PSDevice) pDeviceHandler;
UINT ii;
BYTE byHighSuppRate = 0;
BYTE byRate = 0;
WORD wOldBasicRate = pDevice->wBasicRate;
UINT uRateLen;
if (pItemRates == NULL)
return;
*pwSuppRate = 0;
uRateLen = pItemRates->len;
DEVICE_PRT(MSG_LEVEL_DEBUG, KERN_INFO"ParseMaxRate Len: %d\n", uRateLen);
if (pDevice->eCurrentPHYType != PHY_TYPE_11B) {
if (uRateLen > WLAN_RATES_MAXLEN)
uRateLen = WLAN_RATES_MAXLEN;
} else {
if (uRateLen > WLAN_RATES_MAXLEN_11B)
uRateLen = WLAN_RATES_MAXLEN_11B;
}
for (ii = 0; ii < uRateLen; ii++) {
byRate = (BYTE)(pItemRates->abyRates[ii]);
if (WLAN_MGMT_IS_BASICRATE(byRate) &&
(bUpdateBasicRate == TRUE)) {
// Add to basic rate set, update pDevice->byTopCCKBasicRate and pDevice->byTopOFDMBasicRate
CARDbAddBasicRate((PVOID)pDevice, wGetRateIdx(byRate));
DEVICE_PRT(MSG_LEVEL_DEBUG, KERN_INFO"ParseMaxRate AddBasicRate: %d\n", wGetRateIdx(byRate));
}
byRate = (BYTE)(pItemRates->abyRates[ii]&0x7F);
if (byHighSuppRate == 0)
byHighSuppRate = byRate;
if (byRate > byHighSuppRate)
byHighSuppRate = byRate;
*pwSuppRate |= (1<<wGetRateIdx(byRate));
}
if ((pItemExtRates != NULL) && (pItemExtRates->byElementID == WLAN_EID_EXTSUPP_RATES) &&
(pDevice->eCurrentPHYType != PHY_TYPE_11B)) {
UINT uExtRateLen = pItemExtRates->len;
if (uExtRateLen > WLAN_RATES_MAXLEN)
uExtRateLen = WLAN_RATES_MAXLEN;
for (ii = 0; ii < uExtRateLen ; ii++) {
byRate = (BYTE)(pItemExtRates->abyRates[ii]);
// select highest basic rate
if (WLAN_MGMT_IS_BASICRATE(pItemExtRates->abyRates[ii])) {
// Add to basic rate set, update pDevice->byTopCCKBasicRate and pDevice->byTopOFDMBasicRate
CARDbAddBasicRate((PVOID)pDevice, wGetRateIdx(byRate));
DEVICE_PRT(MSG_LEVEL_DEBUG, KERN_INFO"ParseMaxRate AddBasicRate: %d\n", wGetRateIdx(byRate));
}
byRate = (BYTE)(pItemExtRates->abyRates[ii]&0x7F);
if (byHighSuppRate == 0)
byHighSuppRate = byRate;
if (byRate > byHighSuppRate)
byHighSuppRate = byRate;
*pwSuppRate |= (1<<wGetRateIdx(byRate));
//DBG_PRN_GRP09(("ParseMaxRate : HighSuppRate: %d, %X\n", wGetRateIdx(byRate), byRate));
}
} //if(pItemExtRates != NULL)
if ((pDevice->byPacketType == PK_TYPE_11GB) && CARDbIsOFDMinBasicRate((PVOID)pDevice)) {
pDevice->byPacketType = PK_TYPE_11GA;
}
*pbyTopCCKRate = pDevice->byTopCCKBasicRate;
*pbyTopOFDMRate = pDevice->byTopOFDMBasicRate;
*pwMaxSuppRate = wGetRateIdx(byHighSuppRate);
if ((pDevice->byPacketType==PK_TYPE_11B) || (pDevice->byPacketType==PK_TYPE_11GB))
*pwMaxBasicRate = pDevice->byTopCCKBasicRate;
else
*pwMaxBasicRate = pDevice->byTopOFDMBasicRate;
if (wOldBasicRate != pDevice->wBasicRate)
CARDvSetRSPINF((PVOID)pDevice, pDevice->eCurrentPHYType);
DEVICE_PRT(MSG_LEVEL_DEBUG, KERN_INFO"Exit ParseMaxRate\n");
}
/*+
*
* Routine Description:
* Rate fallback Algorithm Implementaion
*
* Parameters:
* In:
* pDevice - Pointer to the adapter
* psNodeDBTable - Pointer to Node Data Base
* Out:
* none
*
* Return Value: none
*
-*/
#define AUTORATE_TXCNT_THRESHOLD 20
#define AUTORATE_INC_THRESHOLD 30
VOID
RATEvTxRateFallBack (
IN PVOID pDeviceHandler,
IN PKnownNodeDB psNodeDBTable
)
{
PSDevice pDevice = (PSDevice) pDeviceHandler;
WORD wIdxDownRate = 0;
UINT ii;
//DWORD dwRateTable[MAX_RATE] = {1, 2, 5, 11, 6, 9, 12, 18, 24, 36, 48, 54};
BOOL bAutoRate[MAX_RATE] = {TRUE,TRUE,TRUE,TRUE,FALSE,FALSE,TRUE,TRUE,TRUE,TRUE,TRUE,TRUE};
DWORD dwThroughputTbl[MAX_RATE] = {10, 20, 55, 110, 60, 90, 120, 180, 240, 360, 480, 540};
DWORD dwThroughput = 0;
WORD wIdxUpRate = 0;
DWORD dwTxDiff = 0;
if (pDevice->pMgmt->eScanState != WMAC_NO_SCANNING) {
// Don't do Fallback when scanning Channel
return;
}
psNodeDBTable->uTimeCount ++;
if (psNodeDBTable->uTxFail[MAX_RATE] > psNodeDBTable->uTxOk[MAX_RATE])
dwTxDiff = psNodeDBTable->uTxFail[MAX_RATE] - psNodeDBTable->uTxOk[MAX_RATE];
if ((psNodeDBTable->uTxOk[MAX_RATE] < AUTORATE_TXOK_CNT) &&
(dwTxDiff < AUTORATE_TXFAIL_CNT) &&
(psNodeDBTable->uTimeCount < AUTORATE_TIMEOUT)) {
return;
}
if (psNodeDBTable->uTimeCount >= AUTORATE_TIMEOUT) {
psNodeDBTable->uTimeCount = 0;
}
for(ii=0;ii<MAX_RATE;ii++) {
if (psNodeDBTable->wSuppRate & (0x0001<<ii)) {
if (bAutoRate[ii] == TRUE) {
wIdxUpRate = (WORD) ii;
}
} else {
bAutoRate[ii] = FALSE;
}
}
for(ii=0;ii<=psNodeDBTable->wTxDataRate;ii++) {
if ( (psNodeDBTable->uTxOk[ii] != 0) ||
(psNodeDBTable->uTxFail[ii] != 0) ) {
dwThroughputTbl[ii] *= psNodeDBTable->uTxOk[ii];
if (ii < RATE_11M) {
psNodeDBTable->uTxFail[ii] *= 4;
}
dwThroughputTbl[ii] /= (psNodeDBTable->uTxOk[ii] + psNodeDBTable->uTxFail[ii]);
}
// DBG_PRT(MSG_LEVEL_DEBUG, KERN_INFO"Rate %d,Ok: %d, Fail:%d, Throughput:%d\n",
// ii, psNodeDBTable->uTxOk[ii], psNodeDBTable->uTxFail[ii], dwThroughputTbl[ii]);
}
dwThroughput = dwThroughputTbl[psNodeDBTable->wTxDataRate];
wIdxDownRate = psNodeDBTable->wTxDataRate;
for(ii = psNodeDBTable->wTxDataRate; ii > 0;) {
ii--;
if ( (dwThroughputTbl[ii] > dwThroughput) &&
(bAutoRate[ii]==TRUE) ) {
dwThroughput = dwThroughputTbl[ii];
wIdxDownRate = (WORD) ii;
}
}
psNodeDBTable->wTxDataRate = wIdxDownRate;
if (psNodeDBTable->uTxOk[MAX_RATE]) {
if (psNodeDBTable->uTxOk[MAX_RATE] >
(psNodeDBTable->uTxFail[MAX_RATE] * 4) ) {
psNodeDBTable->wTxDataRate = wIdxUpRate;
}
}else { // adhoc, if uTxOk =0 & uTxFail = 0
if (psNodeDBTable->uTxFail[MAX_RATE] == 0)
psNodeDBTable->wTxDataRate = wIdxUpRate;
}
//2008-5-8 <add> by chester
TxRate_iwconfig=psNodeDBTable->wTxDataRate;
s_vResetCounter(psNodeDBTable);
// DBG_PRT(MSG_LEVEL_DEBUG, KERN_INFO"Rate: %d, U:%d, D:%d\n", psNodeDBTable->wTxDataRate, wIdxUpRate, wIdxDownRate);
return;
}
/*+
*
* Description:
* This routine is used to assemble available Rate IE.
*
* Parameters:
* In:
* pDevice
* Out:
*
* Return Value: None
*
-*/
BYTE
RATEuSetIE (
IN PWLAN_IE_SUPP_RATES pSrcRates,
IN PWLAN_IE_SUPP_RATES pDstRates,
IN UINT uRateLen
)
{
UINT ii, uu, uRateCnt = 0;
if ((pSrcRates == NULL) || (pDstRates == NULL))
return 0;
if (pSrcRates->len == 0)
return 0;
for (ii = 0; ii < uRateLen; ii++) {
for (uu = 0; uu < pSrcRates->len; uu++) {
if ((pSrcRates->abyRates[uu] & 0x7F) == acbyIERate[ii]) {
pDstRates->abyRates[uRateCnt ++] = pSrcRates->abyRates[uu];
break;
}
}
}
return (BYTE)uRateCnt;
}

View File

@ -0,0 +1,95 @@
/*
* Copyright (c) 1996, 2003 VIA Networking Technologies, Inc.
* All rights reserved.
*
* This program is free software; you can redistribute it and/or modify
* it under the terms of the GNU General Public License as published by
* the Free Software Foundation; either version 2 of the License, or
* (at your option) any later version.
*
* This program is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
* GNU General Public License for more details.
*
* You should have received a copy of the GNU General Public License along
* with this program; if not, write to the Free Software Foundation, Inc.,
* 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA.
*
*
* File: datarate.h
*
* Purpose: Handles the auto fallback & data rates functions
*
* Author: Lyndon Chen
*
* Date: July 16, 2002
*
*/
#ifndef __DATARATE_H__
#define __DATARATE_H__
/*--------------------- Export Definitions -------------------------*/
#define FALLBACK_PKT_COLLECT_TR_H 50 // pkts
#define FALLBACK_PKT_COLLECT_TR_L 10 // pkts
#define FALLBACK_POLL_SECOND 5 // 5 sec
#define FALLBACK_RECOVER_SECOND 30 // 30 sec
#define FALLBACK_THRESHOLD 15 // percent
#define UPGRADE_THRESHOLD 5 // percent
#define UPGRADE_CNT_THRD 3 // times
#define RETRY_TIMES_THRD_H 2 // times
#define RETRY_TIMES_THRD_L 1 // times
/*--------------------- Export Classes ----------------------------*/
/*--------------------- Export Variables --------------------------*/
/*--------------------- Export Types ------------------------------*/
/*--------------------- Export Functions --------------------------*/
VOID
RATEvParseMaxRate(
IN PVOID pDeviceHandler,
IN PWLAN_IE_SUPP_RATES pItemRates,
IN PWLAN_IE_SUPP_RATES pItemExtRates,
IN BOOL bUpdateBasicRate,
OUT PWORD pwMaxBasicRate,
OUT PWORD pwMaxSuppRate,
OUT PWORD pwSuppRate,
OUT PBYTE pbyTopCCKRate,
OUT PBYTE pbyTopOFDMRate
);
VOID
RATEvTxRateFallBack(
IN PVOID pDeviceHandler,
IN PKnownNodeDB psNodeDBTable
);
BYTE
RATEuSetIE(
IN PWLAN_IE_SUPP_RATES pSrcRates,
IN PWLAN_IE_SUPP_RATES pDstRates,
IN UINT uRateLen
);
WORD
wGetRateIdx(
IN BYTE byRate
);
BYTE
DATARATEbyGetRateIdx(
IN BYTE byRate
);
#endif //__DATARATE_H__

View File

@ -0,0 +1,697 @@
/*
* Copyright (c) 1996, 2003 VIA Networking Technologies, Inc.
* All rights reserved.
*
* This program is free software; you can redistribute it and/or modify
* it under the terms of the GNU General Public License as published by
* the Free Software Foundation; either version 2 of the License, or
* (at your option) any later version.
*
* This program is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
* GNU General Public License for more details.
*
* You should have received a copy of the GNU General Public License along
* with this program; if not, write to the Free Software Foundation, Inc.,
* 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA.
*
* File: desc.h
*
* Purpose:The header file of descriptor
*
* Revision History:
*
* Author: Tevin Chen
*
* Date: May 21, 1996
*
*/
#ifndef __DESC_H__
#define __DESC_H__
#include <linux/types.h>
#include <linux/mm.h>
#if !defined(__TTYPE_H__)
#include "ttype.h"
#endif
#if !defined(__TETHER_H__)
#include "tether.h"
#endif
// #ifdef PRIVATE_OBJ
//#if !defined(__DEVICE_MODULE_H)
//#include "device_module.h"
//#endif
/*--------------------- Export Definitions -------------------------*/
#define B_OWNED_BY_CHIP 1 //
#define B_OWNED_BY_HOST 0 //
//
// Bits in the RSR register
//
#define RSR_ADDRBROAD 0x80 // 1000 0000
#define RSR_ADDRMULTI 0x40 // 0100 0000
#define RSR_ADDRUNI 0x00 // 0000 0000
#define RSR_IVLDTYP 0x20 // 0010 0000 , invalid packet type
#define RSR_IVLDLEN 0x10 // 0001 0000 , invalid len (> 2312 byte)
#define RSR_BSSIDOK 0x08 // 0000 1000
#define RSR_CRCOK 0x04 // 0000 0100
#define RSR_BCNSSIDOK 0x02 // 0000 0010
#define RSR_ADDROK 0x01 // 0000 0001
//
// Bits in the new RSR register
//
#define NEWRSR_DECRYPTOK 0x10 // 0001 0000
#define NEWRSR_CFPIND 0x08 // 0000 1000
#define NEWRSR_HWUTSF 0x04 // 0000 0100
#define NEWRSR_BCNHITAID 0x02 // 0000 0010
#define NEWRSR_BCNHITAID0 0x01 // 0000 0001
//
// Bits in the TSR0 register
//
#define TSR0_PWRSTS1_2 0xC0 // 1100 0000
#define TSR0_PWRSTS7 0x20 // 0010 0000
#define TSR0_NCR 0x1F // 0001 1111
//
// Bits in the TSR1 register
//
#define TSR1_TERR 0x80 // 1000 0000
#define TSR1_PWRSTS4_6 0x70 // 0111 0000
#define TSR1_RETRYTMO 0x08 // 0000 1000
#define TSR1_TMO 0x04 // 0000 0100
#define TSR1_PWRSTS3 0x02 // 0000 0010
#define ACK_DATA 0x01 // 0000 0000
//
// Bits in the TCR register
//
#define EDMSDU 0x04 // 0000 0100 end of sdu
#define TCR_EDP 0x02 // 0000 0010 end of packet
#define TCR_STP 0x01 // 0000 0001 start of packet
// max transmit or receive buffer size
#define CB_MAX_BUF_SIZE 2900U // max buffer size
// NOTE: must be multiple of 4
#define CB_MAX_TX_BUF_SIZE CB_MAX_BUF_SIZE // max Tx buffer size
#define CB_MAX_RX_BUF_SIZE_NORMAL CB_MAX_BUF_SIZE // max Rx buffer size when not use Multi-RD
#define CB_BEACON_BUF_SIZE 512U // default beacon buffer size
#define CB_MAX_RX_DESC 128 // max # of descriptor
#define CB_MIN_RX_DESC 16 // min # of rx descriptor
#define CB_MAX_TX_DESC 64 // max # of descriptor
#define CB_MIN_TX_DESC 16 // min # of tx descriptor
#define CB_MAX_RECEIVED_PACKETS 16 // max # of received packets at one time
// limit our receive routine to indicating
// this many at a time for 2 reasons:
// 1. driver flow control to protocol layer
// 2. limit the time used in ISR routine
#define CB_EXTRA_RD_NUM 32 // default # of Extra RD
#define CB_RD_NUM 32 // default # of RD
#define CB_TD_NUM 32 // default # of TD
// max number of physical segments
// in a single NDIS packet. Above this threshold, the packet
// is copied into a single physically contiguous buffer
#define CB_MAX_SEGMENT 4
#define CB_MIN_MAP_REG_NUM 4
#define CB_MAX_MAP_REG_NUM CB_MAX_TX_DESC
#define CB_PROTOCOL_RESERVED_SECTION 16
// if retrys excess 15 times , tx will abort, and
// if tx fifo underflow, tx will fail
// we should try to resend it
#define CB_MAX_TX_ABORT_RETRY 3
#ifdef __BIG_ENDIAN
// WMAC definition FIFO Control
#define FIFOCTL_AUTO_FB_1 0x0010 // 0001 0000 0000 0000
#define FIFOCTL_AUTO_FB_0 0x0008 // 0000 1000 0000 0000
#define FIFOCTL_GRPACK 0x0004 // 0000 0100 0000 0000
#define FIFOCTL_11GA 0x0003 // 0000 0011 0000 0000
#define FIFOCTL_11GB 0x0002 // 0000 0010 0000 0000
#define FIFOCTL_11B 0x0001 // 0000 0001 0000 0000
#define FIFOCTL_11A 0x0000 // 0000 0000 0000 0000
#define FIFOCTL_RTS 0x8000 // 0000 0000 1000 0000
#define FIFOCTL_ISDMA0 0x4000 // 0000 0000 0100 0000
#define FIFOCTL_GENINT 0x2000 // 0000 0000 0010 0000
#define FIFOCTL_TMOEN 0x1000 // 0000 0000 0001 0000
#define FIFOCTL_LRETRY 0x0800 // 0000 0000 0000 1000
#define FIFOCTL_CRCDIS 0x0400 // 0000 0000 0000 0100
#define FIFOCTL_NEEDACK 0x0200 // 0000 0000 0000 0010
#define FIFOCTL_LHEAD 0x0100 // 0000 0000 0000 0001
//WMAC definition Frag Control
#define FRAGCTL_AES 0x0003 // 0000 0011 0000 0000
#define FRAGCTL_TKIP 0x0002 // 0000 0010 0000 0000
#define FRAGCTL_LEGACY 0x0001 // 0000 0001 0000 0000
#define FRAGCTL_NONENCRYPT 0x0000 // 0000 0000 0000 0000
//#define FRAGCTL_AC3 0x0C00 // 0000 0000 0000 1100
//#define FRAGCTL_AC2 0x0800 // 0000 0000 0000 1000
//#define FRAGCTL_AC1 0x0400 // 0000 0000 0000 0100
//#define FRAGCTL_AC0 0x0000 // 0000 0000 0000 0000
#define FRAGCTL_ENDFRAG 0x0300 // 0000 0000 0000 0011
#define FRAGCTL_MIDFRAG 0x0200 // 0000 0000 0000 0010
#define FRAGCTL_STAFRAG 0x0100 // 0000 0000 0000 0001
#define FRAGCTL_NONFRAG 0x0000 // 0000 0000 0000 0000
#else
#define FIFOCTL_AUTO_FB_1 0x1000 // 0001 0000 0000 0000
#define FIFOCTL_AUTO_FB_0 0x0800 // 0000 1000 0000 0000
#define FIFOCTL_GRPACK 0x0400 // 0000 0100 0000 0000
#define FIFOCTL_11GA 0x0300 // 0000 0011 0000 0000
#define FIFOCTL_11GB 0x0200 // 0000 0010 0000 0000
#define FIFOCTL_11B 0x0100 // 0000 0001 0000 0000
#define FIFOCTL_11A 0x0000 // 0000 0000 0000 0000
#define FIFOCTL_RTS 0x0080 // 0000 0000 1000 0000
#define FIFOCTL_ISDMA0 0x0040 // 0000 0000 0100 0000
#define FIFOCTL_GENINT 0x0020 // 0000 0000 0010 0000
#define FIFOCTL_TMOEN 0x0010 // 0000 0000 0001 0000
#define FIFOCTL_LRETRY 0x0008 // 0000 0000 0000 1000
#define FIFOCTL_CRCDIS 0x0004 // 0000 0000 0000 0100
#define FIFOCTL_NEEDACK 0x0002 // 0000 0000 0000 0010
#define FIFOCTL_LHEAD 0x0001 // 0000 0000 0000 0001
//WMAC definition Frag Control
#define FRAGCTL_AES 0x0300 // 0000 0011 0000 0000
#define FRAGCTL_TKIP 0x0200 // 0000 0010 0000 0000
#define FRAGCTL_LEGACY 0x0100 // 0000 0001 0000 0000
#define FRAGCTL_NONENCRYPT 0x0000 // 0000 0000 0000 0000
//#define FRAGCTL_AC3 0x000C // 0000 0000 0000 1100
//#define FRAGCTL_AC2 0x0008 // 0000 0000 0000 1000
//#define FRAGCTL_AC1 0x0004 // 0000 0000 0000 0100
//#define FRAGCTL_AC0 0x0000 // 0000 0000 0000 0000
#define FRAGCTL_ENDFRAG 0x0003 // 0000 0000 0000 0011
#define FRAGCTL_MIDFRAG 0x0002 // 0000 0000 0000 0010
#define FRAGCTL_STAFRAG 0x0001 // 0000 0000 0000 0001
#define FRAGCTL_NONFRAG 0x0000 // 0000 0000 0000 0000
#endif // #ifdef __BIG_ENDIAN
//#define TYPE_AC0DMA 0
//#define TYPE_TXDMA0 1
#define TYPE_TXDMA0 0
#define TYPE_AC0DMA 1
#define TYPE_ATIMDMA 2
#define TYPE_SYNCDMA 3
#define TYPE_MAXTD 2
#define TYPE_BEACONDMA 4
#define TYPE_RXDMA0 0
#define TYPE_RXDMA1 1
#define TYPE_MAXRD 2
// TD_INFO flags control bit
#define TD_FLAGS_NETIF_SKB 0x01 // check if need release skb
#define TD_FLAGS_PRIV_SKB 0x02 // check if called from private skb(hostap)
#define TD_FLAGS_PS_RETRY 0x04 // check if PS STA frame re-transmit
//#define TD_FLAGS_NETIF_SKB 0x04
/*--------------------- Export Types ------------------------------*/
// ref_sk_buff is used for mapping the skb structure between pre-built driver-obj & running kernel.
// Since different kernel version (2.4x) may change skb structure, i.e. pre-built driver-obj
// may link to older skb that leads error.
typedef struct tagDEVICE_RD_INFO {
struct sk_buff* skb;
#ifdef PRIVATE_OBJ
ref_sk_buff ref_skb;
#endif
dma_addr_t skb_dma;
dma_addr_t curr_desc;
} DEVICE_RD_INFO, *PDEVICE_RD_INFO;
/*
static inline PDEVICE_RD_INFO alloc_rd_info(void) {
PDEVICE_RD_INFO ptr;
if ((ptr = kmalloc(sizeof(DEVICE_RD_INFO), GFP_ATOMIC)) == NULL)
return NULL;
else {
memset(ptr,0,sizeof(DEVICE_RD_INFO));
return ptr;
}
}
*/
/*
typedef struct tagRDES0 {
WORD wResCount;
WORD wf1Owner ;
// WORD f15Reserved : 15;
// WORD f1Owner : 1;
} __attribute__ ((__packed__))
SRDES0;
*/
#ifdef __BIG_ENDIAN
typedef struct tagRDES0 {
volatile WORD wResCount;
union {
volatile U16 f15Reserved;
struct {
volatile U8 f8Reserved1;
volatile U8 f1Owner:1;
volatile U8 f7Reserved:7;
} __attribute__ ((__packed__));
} __attribute__ ((__packed__));
} __attribute__ ((__packed__))
SRDES0, *PSRDES0;
#else
typedef struct tagRDES0 {
WORD wResCount;
WORD f15Reserved : 15;
WORD f1Owner : 1;
} __attribute__ ((__packed__))
SRDES0;
#endif
typedef struct tagRDES1 {
WORD wReqCount;
WORD wReserved;
} __attribute__ ((__packed__))
SRDES1;
//
// Rx descriptor
//
typedef struct tagSRxDesc {
volatile SRDES0 m_rd0RD0;
volatile SRDES1 m_rd1RD1;
volatile U32 buff_addr;
volatile U32 next_desc;
struct tagSRxDesc *next;//4 bytes
volatile PDEVICE_RD_INFO pRDInfo;//4 bytes
volatile U32 Reserved[2];//8 bytes
} __attribute__ ((__packed__))
SRxDesc, DEF* PSRxDesc;
typedef const SRxDesc DEF* PCSRxDesc;
#ifdef __BIG_ENDIAN
/*
typedef struct tagTDES0 {
volatile BYTE byTSR0;
volatile BYTE byTSR1;
volatile WORD wOwner_Txtime;
// volatile WORD f15Txtime : 15;
// volatile WORD f1Owner:1;
} __attribute__ ((__packed__))
STDES0;
*/
typedef struct tagTDES0 {
volatile BYTE byTSR0;
volatile BYTE byTSR1;
union {
volatile U16 f15Txtime;
struct {
volatile U8 f8Reserved1;
volatile U8 f1Owner:1;
volatile U8 f7Reserved:7;
} __attribute__ ((__packed__));
} __attribute__ ((__packed__));
} __attribute__ ((__packed__))
STDES0, PSTDES0;
#else
typedef struct tagTDES0 {
volatile BYTE byTSR0;
volatile BYTE byTSR1;
volatile WORD f15Txtime : 15;
volatile WORD f1Owner:1;
} __attribute__ ((__packed__))
STDES0;
#endif
typedef struct tagTDES1 {
volatile WORD wReqCount;
volatile BYTE byTCR;
volatile BYTE byReserved;
} __attribute__ ((__packed__))
STDES1;
typedef struct tagDEVICE_TD_INFO{
struct sk_buff* skb;
PBYTE buf;
dma_addr_t skb_dma;
dma_addr_t buf_dma;
dma_addr_t curr_desc;
DWORD dwReqCount;
DWORD dwHeaderLength;
BYTE byFlags;
} DEVICE_TD_INFO, *PDEVICE_TD_INFO;
/*
static inline PDEVICE_TD_INFO alloc_td_info(void) {
PDEVICE_TD_INFO ptr;
if ((ptr = kmalloc(sizeof(DEVICE_TD_INFO),GFP_ATOMIC))==NULL)
return NULL;
else {
memset(ptr,0,sizeof(DEVICE_TD_INFO));
return ptr;
}
}
*/
//
// transmit descriptor
//
typedef struct tagSTxDesc {
volatile STDES0 m_td0TD0;
volatile STDES1 m_td1TD1;
volatile U32 buff_addr;
volatile U32 next_desc;
struct tagSTxDesc* next; //4 bytes
volatile PDEVICE_TD_INFO pTDInfo;//4 bytes
volatile U32 Reserved[2];//8 bytes
} __attribute__ ((__packed__))
STxDesc, DEF* PSTxDesc;
typedef const STxDesc DEF* PCSTxDesc;
typedef struct tagSTxSyncDesc {
volatile STDES0 m_td0TD0;
volatile STDES1 m_td1TD1;
volatile DWORD buff_addr; // pointer to logical buffer
volatile DWORD next_desc; // pointer to next logical descriptor
volatile WORD m_wFIFOCtl;
volatile WORD m_wTimeStamp;
struct tagSTxSyncDesc* next; //4 bytes
volatile PDEVICE_TD_INFO pTDInfo;//4 bytes
volatile DWORD m_dwReserved2;
} __attribute__ ((__packed__))
STxSyncDesc, DEF* PSTxSyncDesc;
typedef const STxSyncDesc DEF* PCSTxSyncDesc;
//
// RsvTime buffer header
//
typedef struct tagSRrvTime_gRTS {
WORD wRTSTxRrvTime_ba;
WORD wRTSTxRrvTime_aa;
WORD wRTSTxRrvTime_bb;
WORD wReserved;
WORD wTxRrvTime_b;
WORD wTxRrvTime_a;
}__attribute__ ((__packed__))
SRrvTime_gRTS, DEF* PSRrvTime_gRTS;
typedef const SRrvTime_gRTS DEF* PCSRrvTime_gRTS;
typedef struct tagSRrvTime_gCTS {
WORD wCTSTxRrvTime_ba;
WORD wReserved;
WORD wTxRrvTime_b;
WORD wTxRrvTime_a;
}__attribute__ ((__packed__))
SRrvTime_gCTS, DEF* PSRrvTime_gCTS;
typedef const SRrvTime_gCTS DEF* PCSRrvTime_gCTS;
typedef struct tagSRrvTime_ab {
WORD wRTSTxRrvTime;
WORD wTxRrvTime;
}__attribute__ ((__packed__))
SRrvTime_ab, DEF* PSRrvTime_ab;
typedef const SRrvTime_ab DEF* PCSRrvTime_ab;
typedef struct tagSRrvTime_atim {
WORD wCTSTxRrvTime_ba;
WORD wTxRrvTime_a;
}__attribute__ ((__packed__))
SRrvTime_atim, DEF* PSRrvTime_atim;
typedef const SRrvTime_atim DEF* PCSRrvTime_atim;
//
// RTS buffer header
//
typedef struct tagSRTSData {
WORD wFrameControl;
WORD wDurationID;
BYTE abyRA[U_ETHER_ADDR_LEN];
BYTE abyTA[U_ETHER_ADDR_LEN];
}__attribute__ ((__packed__))
SRTSData, DEF* PSRTSData;
typedef const SRTSData DEF* PCSRTSData;
typedef struct tagSRTS_g {
BYTE bySignalField_b;
BYTE byServiceField_b;
WORD wTransmitLength_b;
BYTE bySignalField_a;
BYTE byServiceField_a;
WORD wTransmitLength_a;
WORD wDuration_ba;
WORD wDuration_aa;
WORD wDuration_bb;
WORD wReserved;
SRTSData Data;
}__attribute__ ((__packed__))
SRTS_g, DEF* PSRTS_g;
typedef const SRTS_g DEF* PCSRTS_g;
typedef struct tagSRTS_g_FB {
BYTE bySignalField_b;
BYTE byServiceField_b;
WORD wTransmitLength_b;
BYTE bySignalField_a;
BYTE byServiceField_a;
WORD wTransmitLength_a;
WORD wDuration_ba;
WORD wDuration_aa;
WORD wDuration_bb;
WORD wReserved;
WORD wRTSDuration_ba_f0;
WORD wRTSDuration_aa_f0;
WORD wRTSDuration_ba_f1;
WORD wRTSDuration_aa_f1;
SRTSData Data;
}__attribute__ ((__packed__))
SRTS_g_FB, DEF* PSRTS_g_FB;
typedef const SRTS_g_FB DEF* PCSRTS_g_FB;
typedef struct tagSRTS_ab {
BYTE bySignalField;
BYTE byServiceField;
WORD wTransmitLength;
WORD wDuration;
WORD wReserved;
SRTSData Data;
}__attribute__ ((__packed__))
SRTS_ab, DEF* PSRTS_ab;
typedef const SRTS_ab DEF* PCSRTS_ab;
typedef struct tagSRTS_a_FB {
BYTE bySignalField;
BYTE byServiceField;
WORD wTransmitLength;
WORD wDuration;
WORD wReserved;
WORD wRTSDuration_f0;
WORD wRTSDuration_f1;
SRTSData Data;
}__attribute__ ((__packed__))
SRTS_a_FB, DEF* PSRTS_a_FB;
typedef const SRTS_a_FB DEF* PCSRTS_a_FB;
//
// CTS buffer header
//
typedef struct tagSCTSData {
WORD wFrameControl;
WORD wDurationID;
BYTE abyRA[U_ETHER_ADDR_LEN];
WORD wReserved;
}__attribute__ ((__packed__))
SCTSData, DEF* PSCTSData;
typedef struct tagSCTS {
BYTE bySignalField_b;
BYTE byServiceField_b;
WORD wTransmitLength_b;
WORD wDuration_ba;
WORD wReserved;
SCTSData Data;
}__attribute__ ((__packed__))
SCTS, DEF* PSCTS;
typedef const SCTS DEF* PCSCTS;
typedef struct tagSCTS_FB {
BYTE bySignalField_b;
BYTE byServiceField_b;
WORD wTransmitLength_b;
WORD wDuration_ba;
WORD wReserved;
WORD wCTSDuration_ba_f0;
WORD wCTSDuration_ba_f1;
SCTSData Data;
}__attribute__ ((__packed__))
SCTS_FB, DEF* PSCTS_FB;
typedef const SCTS_FB DEF* PCSCTS_FB;
//
// Tx FIFO header
//
typedef struct tagSTxBufHead {
DWORD adwTxKey[4];
WORD wFIFOCtl;
WORD wTimeStamp;
WORD wFragCtl;
BYTE byTxPower;
BYTE wReserved;
}__attribute__ ((__packed__))
STxBufHead, DEF* PSTxBufHead;
typedef const STxBufHead DEF* PCSTxBufHead;
typedef struct tagSTxShortBufHead {
WORD wFIFOCtl;
WORD wTimeStamp;
}__attribute__ ((__packed__))
STxShortBufHead, DEF* PSTxShortBufHead;
typedef const STxShortBufHead DEF* PCSTxShortBufHead;
//
// Tx data header
//
typedef struct tagSTxDataHead_g {
BYTE bySignalField_b;
BYTE byServiceField_b;
WORD wTransmitLength_b;
BYTE bySignalField_a;
BYTE byServiceField_a;
WORD wTransmitLength_a;
WORD wDuration_b;
WORD wDuration_a;
WORD wTimeStampOff_b;
WORD wTimeStampOff_a;
}__attribute__ ((__packed__))
STxDataHead_g, DEF* PSTxDataHead_g;
typedef const STxDataHead_g DEF* PCSTxDataHead_g;
typedef struct tagSTxDataHead_g_FB {
BYTE bySignalField_b;
BYTE byServiceField_b;
WORD wTransmitLength_b;
BYTE bySignalField_a;
BYTE byServiceField_a;
WORD wTransmitLength_a;
WORD wDuration_b;
WORD wDuration_a;
WORD wDuration_a_f0;
WORD wDuration_a_f1;
WORD wTimeStampOff_b;
WORD wTimeStampOff_a;
}__attribute__ ((__packed__))
STxDataHead_g_FB, DEF* PSTxDataHead_g_FB;
typedef const STxDataHead_g_FB DEF* PCSTxDataHead_g_FB;
typedef struct tagSTxDataHead_ab {
BYTE bySignalField;
BYTE byServiceField;
WORD wTransmitLength;
WORD wDuration;
WORD wTimeStampOff;
}__attribute__ ((__packed__))
STxDataHead_ab, DEF* PSTxDataHead_ab;
typedef const STxDataHead_ab DEF* PCSTxDataHead_ab;
typedef struct tagSTxDataHead_a_FB {
BYTE bySignalField;
BYTE byServiceField;
WORD wTransmitLength;
WORD wDuration;
WORD wTimeStampOff;
WORD wDuration_f0;
WORD wDuration_f1;
}__attribute__ ((__packed__))
STxDataHead_a_FB, DEF* PSTxDataHead_a_FB;
typedef const STxDataHead_a_FB DEF* PCSTxDataHead_a_FB;
//
// MICHDR data header
//
typedef struct tagSMICHDRHead {
DWORD adwHDR0[4];
DWORD adwHDR1[4];
DWORD adwHDR2[4];
}__attribute__ ((__packed__))
SMICHDRHead, DEF* PSMICHDRHead;
typedef const SMICHDRHead DEF* PCSMICHDRHead;
typedef struct tagSBEACONCtl {
DWORD BufReady : 1;
DWORD TSF : 15;
DWORD BufLen : 11;
DWORD Reserved : 5;
}__attribute__ ((__packed__))
SBEACONCtl;
typedef struct tagSSecretKey {
DWORD dwLowDword;
BYTE byHighByte;
}__attribute__ ((__packed__))
SSecretKey;
typedef struct tagSKeyEntry {
BYTE abyAddrHi[2];
WORD wKCTL;
BYTE abyAddrLo[4];
DWORD dwKey0[4];
DWORD dwKey1[4];
DWORD dwKey2[4];
DWORD dwKey3[4];
DWORD dwKey4[4];
}__attribute__ ((__packed__))
SKeyEntry;
/*--------------------- Export Macros ------------------------------*/
/*--------------------- Export Classes ----------------------------*/
/*--------------------- Export Variables --------------------------*/
/*--------------------- Export Functions --------------------------*/
#endif // __DESC_H__

File diff suppressed because it is too large Load Diff

File diff suppressed because it is too large Load Diff

File diff suppressed because it is too large Load Diff

View File

@ -0,0 +1,75 @@
/*
* Copyright (c) 1996, 2003 VIA Networking Technologies, Inc.
* All rights reserved.
*
* This program is free software; you can redistribute it and/or modify
* it under the terms of the GNU General Public License as published by
* the Free Software Foundation; either version 2 of the License, or
* (at your option) any later version.
*
* This program is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
* GNU General Public License for more details.
*
* You should have received a copy of the GNU General Public License along
* with this program; if not, write to the Free Software Foundation, Inc.,
* 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA.
*
* File: whdr.h
*
* Purpose:
*
* Author: Jerry Chen
*
* Date: Jun. 27, 2002
*
*/
#ifndef __DPC_H__
#define __DPC_H__
#if !defined(__TTYPE_H__)
#include "ttype.h"
#endif
#if !defined(__DEVICE_H__)
#include "device.h"
#endif
#if !defined(__WCMD_H__)
#include "wcmd.h"
#endif
/*--------------------- Export Definitions -------------------------*/
/*--------------------- Export Classes ----------------------------*/
/*--------------------- Export Variables --------------------------*/
/*--------------------- Export Functions --------------------------*/
#ifdef __cplusplus
extern "C" { /* Assume C declarations for C++ */
#endif /* __cplusplus */
BOOL
device_receive_frame (
IN PSDevice pDevice,
IN PSRxDesc pCurrRD
);
#ifdef __cplusplus
} /* End of extern "C" { */
#endif /* __cplusplus */
VOID MngWorkItem(PVOID Context);
#endif // __RXTX_H__

View File

@ -0,0 +1,907 @@
/*
* Copyright (c) 1996, 2003 VIA Networking Technologies, Inc.
* All rights reserved.
*
* This program is free software; you can redistribute it and/or modify
* it under the terms of the GNU General Public License as published by
* the Free Software Foundation; either version 2 of the License, or
* (at your option) any later version.
*
* This program is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
* GNU General Public License for more details.
*
* You should have received a copy of the GNU General Public License along
* with this program; if not, write to the Free Software Foundation, Inc.,
* 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA.
*
* File: hostap.c
*
* Purpose: handle hostap deamon ioctl input/out functions
*
* Author: Lyndon Chen
*
* Date: Oct. 20, 2003
*
* Functions:
*
* Revision History:
*
*/
#if !defined(__HOSTAP_H__)
#include "hostap.h"
#endif
#if !defined(__IOCMD_H__)
#include "iocmd.h"
#endif
#if !defined(__MAC_H__)
#include "mac.h"
#endif
#if !defined(__CARD_H__)
#include "card.h"
#endif
#if !defined(__BASEBAND_H__)
#include "baseband.h"
#endif
#if !defined(__WPACTL_H__)
#include "wpactl.h"
#endif
#if !defined(__KEY_H__)
#include "key.h"
#endif
#if !defined(__MAC_H__)
#include "mac.h"
#endif
#define VIAWGET_HOSTAPD_MAX_BUF_SIZE 1024
#define HOSTAP_CRYPT_FLAG_SET_TX_KEY BIT0
#define HOSTAP_CRYPT_FLAG_PERMANENT BIT1
#define HOSTAP_CRYPT_ERR_UNKNOWN_ALG 2
#define HOSTAP_CRYPT_ERR_UNKNOWN_ADDR 3
#define HOSTAP_CRYPT_ERR_CRYPT_INIT_FAILED 4
#define HOSTAP_CRYPT_ERR_KEY_SET_FAILED 5
#define HOSTAP_CRYPT_ERR_TX_KEY_SET_FAILED 6
#define HOSTAP_CRYPT_ERR_CARD_CONF_FAILED 7
/*--------------------- Static Definitions -------------------------*/
/*--------------------- Static Classes ----------------------------*/
/*--------------------- Static Variables --------------------------*/
//static int msglevel =MSG_LEVEL_DEBUG;
static int msglevel =MSG_LEVEL_INFO;
/*--------------------- Static Functions --------------------------*/
/*--------------------- Export Variables --------------------------*/
/*
* Description:
* register net_device (AP) for hostap deamon
*
* Parameters:
* In:
* pDevice -
* rtnl_locked -
* Out:
*
* Return Value:
*
*/
static int hostap_enable_hostapd(PSDevice pDevice, int rtnl_locked)
{
struct net_device *dev = pDevice->dev;
int ret;
DEVICE_PRT(MSG_LEVEL_DEBUG, KERN_INFO "%s: Enabling hostapd mode\n", dev->name);
#ifdef PRIVATE_OBJ
pDevice->apdev = ref_init_apdev(dev);
if (pDevice->apdev == NULL)
return -ENOMEM;
if (rtnl_locked)
ret = register_netdevice(pDevice->apdev);
else
ret = register_netdev(pDevice->apdev);
if (ret) {
DEVICE_PRT(MSG_LEVEL_DEBUG, KERN_INFO "%s: register_netdevice(AP) failed!\n",
dev->name);
return -1;
}
DEVICE_PRT(MSG_LEVEL_DEBUG, KERN_INFO "%s: Registered netdevice %s for AP management\n",
dev->name, pDevice->apdev->name);
#else
pDevice->apdev = (struct net_device *)kmalloc(sizeof(struct net_device), GFP_KERNEL);
if (pDevice->apdev == NULL)
return -ENOMEM;
memset(pDevice->apdev, 0, sizeof(struct net_device));
pDevice->apdev->priv = pDevice;
memcpy(pDevice->apdev->dev_addr, dev->dev_addr, ETH_ALEN);
pDevice->apdev->hard_start_xmit = pDevice->tx_80211;
pDevice->apdev->type = ARPHRD_IEEE80211;
pDevice->apdev->base_addr = dev->base_addr;
pDevice->apdev->irq = dev->irq;
pDevice->apdev->mem_start = dev->mem_start;
pDevice->apdev->mem_end = dev->mem_end;
sprintf(pDevice->apdev->name, "%sap", dev->name);
if (rtnl_locked)
ret = register_netdevice(pDevice->apdev);
else
ret = register_netdev(pDevice->apdev);
if (ret) {
DEVICE_PRT(MSG_LEVEL_DEBUG, KERN_INFO "%s: register_netdevice(AP) failed!\n",
dev->name);
return -1;
}
DEVICE_PRT(MSG_LEVEL_DEBUG, KERN_INFO "%s: Registered netdevice %s for AP management\n",
dev->name, pDevice->apdev->name);
KeyvInitTable(&pDevice->sKey, pDevice->PortOffset);
#endif
return 0;
}
/*
* Description:
* unregister net_device(AP)
*
* Parameters:
* In:
* pDevice -
* rtnl_locked -
* Out:
*
* Return Value:
*
*/
static int hostap_disable_hostapd(PSDevice pDevice, int rtnl_locked)
{
DEVICE_PRT(MSG_LEVEL_DEBUG, KERN_INFO "%s: disabling hostapd mode\n", pDevice->dev->name);
if (pDevice->apdev && pDevice->apdev->name && pDevice->apdev->name[0]) {
if (rtnl_locked)
unregister_netdevice(pDevice->apdev);
else
unregister_netdev(pDevice->apdev);
DEVICE_PRT(MSG_LEVEL_DEBUG, KERN_INFO "%s: Netdevice %s unregistered\n",
pDevice->dev->name, pDevice->apdev->name);
}
kfree(pDevice->apdev);
pDevice->apdev = NULL;
pDevice->bEnable8021x = FALSE;
pDevice->bEnableHostWEP = FALSE;
pDevice->bEncryptionEnable = FALSE;
//4.2007-0118-03,<Add> by EinsnLiu
//execute some clear work
pDevice->pMgmt->byCSSPK=KEY_CTL_NONE;
pDevice->pMgmt->byCSSGK=KEY_CTL_NONE;
KeyvInitTable(&pDevice->sKey,pDevice->PortOffset);
return 0;
}
/*
* Description:
* Set enable/disable hostapd mode
*
* Parameters:
* In:
* pDevice -
* rtnl_locked -
* Out:
*
* Return Value:
*
*/
int hostap_set_hostapd(PSDevice pDevice, int val, int rtnl_locked)
{
if (val < 0 || val > 1)
return -EINVAL;
if (pDevice->bEnableHostapd == val)
return 0;
pDevice->bEnableHostapd = val;
if (val)
return hostap_enable_hostapd(pDevice, rtnl_locked);
else
return hostap_disable_hostapd(pDevice, rtnl_locked);
}
/*
* Description:
* remove station function supported for hostap deamon
*
* Parameters:
* In:
* pDevice -
* param -
* Out:
*
* Return Value:
*
*/
static int hostap_remove_sta(PSDevice pDevice,
struct viawget_hostapd_param *param)
{
UINT uNodeIndex;
if (BSSDBbIsSTAInNodeDB(pDevice->pMgmt, param->sta_addr, &uNodeIndex)) {
BSSvRemoveOneNode(pDevice, uNodeIndex);
}
else {
return -ENOENT;
}
return 0;
}
/*
* Description:
* add a station from hostap deamon
*
* Parameters:
* In:
* pDevice -
* param -
* Out:
*
* Return Value:
*
*/
static int hostap_add_sta(PSDevice pDevice,
struct viawget_hostapd_param *param)
{
PSMgmtObject pMgmt = pDevice->pMgmt;
UINT uNodeIndex;
if (!BSSDBbIsSTAInNodeDB(pMgmt, param->sta_addr, &uNodeIndex)) {
BSSvCreateOneNode((PSDevice)pDevice, &uNodeIndex);
}
memcpy(pMgmt->sNodeDBTable[uNodeIndex].abyMACAddr, param->sta_addr, WLAN_ADDR_LEN);
pMgmt->sNodeDBTable[uNodeIndex].eNodeState = NODE_ASSOC;
pMgmt->sNodeDBTable[uNodeIndex].wCapInfo = param->u.add_sta.capability;
// TODO listenInterval
// pMgmt->sNodeDBTable[uNodeIndex].wListenInterval = 1;
pMgmt->sNodeDBTable[uNodeIndex].bPSEnable = FALSE;
pMgmt->sNodeDBTable[uNodeIndex].bySuppRate = param->u.add_sta.tx_supp_rates;
// set max tx rate
pMgmt->sNodeDBTable[uNodeIndex].wTxDataRate =
pMgmt->sNodeDBTable[uNodeIndex].wMaxSuppRate;
// set max basic rate
pMgmt->sNodeDBTable[uNodeIndex].wMaxBasicRate = RATE_2M;
// Todo: check sta preamble, if ap can't support, set status code
pMgmt->sNodeDBTable[uNodeIndex].bShortPreamble =
WLAN_GET_CAP_INFO_SHORTPREAMBLE(pMgmt->sNodeDBTable[uNodeIndex].wCapInfo);
pMgmt->sNodeDBTable[uNodeIndex].wAID = (WORD)param->u.add_sta.aid;
#ifdef PRIVATE_OBJ
pMgmt->sNodeDBTable[uNodeIndex].ulLastRxJiffer = get_jiffies();
#else
pMgmt->sNodeDBTable[uNodeIndex].ulLastRxJiffer = jiffies;
#endif
DEVICE_PRT(MSG_LEVEL_DEBUG, KERN_INFO "Add STA AID= %d \n", pMgmt->sNodeDBTable[uNodeIndex].wAID);
DEVICE_PRT(MSG_LEVEL_DEBUG, KERN_INFO "MAC=%2.2X:%2.2X:%2.2X:%2.2X:%2.2X:%2.2X \n",
param->sta_addr[0],
param->sta_addr[1],
param->sta_addr[2],
param->sta_addr[3],
param->sta_addr[4],
param->sta_addr[5]
) ;
DEVICE_PRT(MSG_LEVEL_DEBUG, KERN_INFO "Max Support rate = %d \n",
pMgmt->sNodeDBTable[uNodeIndex].wMaxSuppRate);
return 0;
}
/*
* Description:
* get station info
*
* Parameters:
* In:
* pDevice -
* param -
* Out:
*
* Return Value:
*
*/
static int hostap_get_info_sta(PSDevice pDevice,
struct viawget_hostapd_param *param)
{
PSMgmtObject pMgmt = pDevice->pMgmt;
UINT uNodeIndex;
if (BSSDBbIsSTAInNodeDB(pMgmt, param->sta_addr, &uNodeIndex)) {
#ifdef PRIVATE_OBJ
param->u.get_info_sta.inactive_sec =
(get_jiffies() - pMgmt->sNodeDBTable[uNodeIndex].ulLastRxJiffer) / HZ;
#else
param->u.get_info_sta.inactive_sec =
(jiffies - pMgmt->sNodeDBTable[uNodeIndex].ulLastRxJiffer) / HZ;
#endif
//param->u.get_info_sta.txexc = pMgmt->sNodeDBTable[uNodeIndex].uTxAttempts;
}
else {
return -ENOENT;
}
return 0;
}
/*
* Description:
* reset txexec
*
* Parameters:
* In:
* pDevice -
* param -
* Out:
* TURE, FALSE
*
* Return Value:
*
*/
/*
static int hostap_reset_txexc_sta(PSDevice pDevice,
struct viawget_hostapd_param *param)
{
PSMgmtObject pMgmt = pDevice->pMgmt;
UINT uNodeIndex;
if (BSSDBbIsSTAInNodeDB(pMgmt, param->sta_addr, &uNodeIndex)) {
pMgmt->sNodeDBTable[uNodeIndex].uTxAttempts = 0;
}
else {
return -ENOENT;
}
return 0;
}
*/
/*
* Description:
* set station flag
*
* Parameters:
* In:
* pDevice -
* param -
* Out:
*
* Return Value:
*
*/
static int hostap_set_flags_sta(PSDevice pDevice,
struct viawget_hostapd_param *param)
{
PSMgmtObject pMgmt = pDevice->pMgmt;
UINT uNodeIndex;
if (BSSDBbIsSTAInNodeDB(pMgmt, param->sta_addr, &uNodeIndex)) {
pMgmt->sNodeDBTable[uNodeIndex].dwFlags |= param->u.set_flags_sta.flags_or;
pMgmt->sNodeDBTable[uNodeIndex].dwFlags &= param->u.set_flags_sta.flags_and;
DEVICE_PRT(MSG_LEVEL_DEBUG, KERN_INFO " dwFlags = %x \n",
(UINT)pMgmt->sNodeDBTable[uNodeIndex].dwFlags);
}
else {
return -ENOENT;
}
return 0;
}
/*
* Description:
* set generic element (wpa ie)
*
* Parameters:
* In:
* pDevice -
* param -
* Out:
*
* Return Value:
*
*/
static int hostap_set_generic_element(PSDevice pDevice,
struct viawget_hostapd_param *param)
{
PSMgmtObject pMgmt = pDevice->pMgmt;
memcpy( pMgmt->abyWPAIE,
param->u.generic_elem.data,
param->u.generic_elem.len
);
pMgmt->wWPAIELen = param->u.generic_elem.len;
DEVICE_PRT(MSG_LEVEL_DEBUG, KERN_INFO"pMgmt->wWPAIELen = %d\n", pMgmt->wWPAIELen);
// disable wpa
if (pMgmt->wWPAIELen == 0) {
pMgmt->eAuthenMode = WMAC_AUTH_OPEN;
DEVICE_PRT(MSG_LEVEL_DEBUG, KERN_INFO " No WPAIE, Disable WPA \n");
} else {
// enable wpa
if ((pMgmt->abyWPAIE[0] == WLAN_EID_RSN_WPA) ||
(pMgmt->abyWPAIE[0] == WLAN_EID_RSN)) {
pMgmt->eAuthenMode = WMAC_AUTH_WPANONE;
DEVICE_PRT(MSG_LEVEL_DEBUG, KERN_INFO "Set WPAIE enable WPA\n");
} else
return -EINVAL;
}
return 0;
}
/*
* Description:
* flush station nodes table.
*
* Parameters:
* In:
* pDevice -
* Out:
*
* Return Value:
*
*/
static void hostap_flush_sta(PSDevice pDevice)
{
// reserved node index =0 for multicast node.
BSSvClearNodeDBTable(pDevice, 1);
pDevice->uAssocCount = 0;
return;
}
/*
* Description:
* set each stations encryption key
*
* Parameters:
* In:
* pDevice -
* param -
* Out:
*
* Return Value:
*
*/
static int hostap_set_encryption(PSDevice pDevice,
struct viawget_hostapd_param *param,
int param_len)
{
PSMgmtObject pMgmt = pDevice->pMgmt;
DWORD dwKeyIndex = 0;
BYTE abyKey[MAX_KEY_LEN];
BYTE abySeq[MAX_KEY_LEN];
NDIS_802_11_KEY_RSC KeyRSC;
BYTE byKeyDecMode = KEY_CTL_WEP;
int ret = 0;
int iNodeIndex = -1;
int ii;
BOOL bKeyTableFull = FALSE;
WORD wKeyCtl = 0;
param->u.crypt.err = 0;
/*
if (param_len !=
(int) ((char *) param->u.crypt.key - (char *) param) +
param->u.crypt.key_len)
return -EINVAL;
*/
if (param->u.crypt.alg > WPA_ALG_CCMP)
return -EINVAL;
if ((param->u.crypt.idx > 3) || (param->u.crypt.key_len > MAX_KEY_LEN)) {
param->u.crypt.err = HOSTAP_CRYPT_ERR_KEY_SET_FAILED;
DEVICE_PRT(MSG_LEVEL_DEBUG, KERN_INFO " HOSTAP_CRYPT_ERR_KEY_SET_FAILED\n");
return -EINVAL;
}
if (param->sta_addr[0] == 0xff && param->sta_addr[1] == 0xff &&
param->sta_addr[2] == 0xff && param->sta_addr[3] == 0xff &&
param->sta_addr[4] == 0xff && param->sta_addr[5] == 0xff) {
if (param->u.crypt.idx >= MAX_GROUP_KEY)
return -EINVAL;
iNodeIndex = 0;
} else {
if (BSSDBbIsSTAInNodeDB(pMgmt, param->sta_addr, &iNodeIndex) == FALSE) {
param->u.crypt.err = HOSTAP_CRYPT_ERR_UNKNOWN_ADDR;
DEVICE_PRT(MSG_LEVEL_DEBUG, KERN_INFO " HOSTAP_CRYPT_ERR_UNKNOWN_ADDR\n");
return -EINVAL;
}
}
DEVICE_PRT(MSG_LEVEL_DEBUG, KERN_INFO " hostap_set_encryption: sta_index %d \n", iNodeIndex);
DEVICE_PRT(MSG_LEVEL_DEBUG, KERN_INFO " hostap_set_encryption: alg %d \n", param->u.crypt.alg);
if (param->u.crypt.alg == WPA_ALG_NONE) {
if (pMgmt->sNodeDBTable[iNodeIndex].bOnFly == TRUE) {
if (KeybRemoveKey(&(pDevice->sKey),
param->sta_addr,
pMgmt->sNodeDBTable[iNodeIndex].dwKeyIndex,
pDevice->PortOffset) == FALSE) {
DEVICE_PRT(MSG_LEVEL_DEBUG, KERN_INFO "KeybRemoveKey fail \n");
}
pMgmt->sNodeDBTable[iNodeIndex].bOnFly = FALSE;
}
pMgmt->sNodeDBTable[iNodeIndex].byKeyIndex = 0;
pMgmt->sNodeDBTable[iNodeIndex].dwKeyIndex = 0;
pMgmt->sNodeDBTable[iNodeIndex].uWepKeyLength = 0;
pMgmt->sNodeDBTable[iNodeIndex].KeyRSC = 0;
pMgmt->sNodeDBTable[iNodeIndex].dwTSC47_16 = 0;
pMgmt->sNodeDBTable[iNodeIndex].wTSC15_0 = 0;
pMgmt->sNodeDBTable[iNodeIndex].byCipherSuite = 0;
memset(&pMgmt->sNodeDBTable[iNodeIndex].abyWepKey[0],
0,
MAX_KEY_LEN
);
return ret;
}
memcpy(abyKey, param->u.crypt.key, param->u.crypt.key_len);
// copy to node key tbl
pMgmt->sNodeDBTable[iNodeIndex].byKeyIndex = param->u.crypt.idx;
pMgmt->sNodeDBTable[iNodeIndex].uWepKeyLength = param->u.crypt.key_len;
memcpy(&pMgmt->sNodeDBTable[iNodeIndex].abyWepKey[0],
param->u.crypt.key,
param->u.crypt.key_len
);
dwKeyIndex = (DWORD)(param->u.crypt.idx);
if (param->u.crypt.flags & HOSTAP_CRYPT_FLAG_SET_TX_KEY) {
pDevice->byKeyIndex = (BYTE)dwKeyIndex;
pDevice->bTransmitKey = TRUE;
dwKeyIndex |= (1 << 31);
}
if (param->u.crypt.alg == WPA_ALG_WEP) {
if ((pDevice->bEnable8021x == FALSE) || (iNodeIndex == 0)) {
KeybSetDefaultKey(&(pDevice->sKey),
dwKeyIndex & ~(BIT30 | USE_KEYRSC),
param->u.crypt.key_len,
NULL,
abyKey,
KEY_CTL_WEP,
pDevice->PortOffset,
pDevice->byLocalID);
} else {
// 8021x enable, individual key
dwKeyIndex |= (1 << 30); // set pairwise key
if (KeybSetKey(&(pDevice->sKey),
&param->sta_addr[0],
dwKeyIndex & ~(USE_KEYRSC),
param->u.crypt.key_len,
(PQWORD) &(KeyRSC),
(PBYTE)abyKey,
KEY_CTL_WEP,
pDevice->PortOffset,
pDevice->byLocalID) == TRUE) {
pMgmt->sNodeDBTable[iNodeIndex].bOnFly = TRUE;
} else {
// Key Table Full
pMgmt->sNodeDBTable[iNodeIndex].bOnFly = FALSE;
bKeyTableFull = TRUE;
}
}
pDevice->eEncryptionStatus = Ndis802_11Encryption1Enabled;
pDevice->bEncryptionEnable = TRUE;
pMgmt->byCSSPK = KEY_CTL_WEP;
pMgmt->byCSSGK = KEY_CTL_WEP;
pMgmt->sNodeDBTable[iNodeIndex].byCipherSuite = KEY_CTL_WEP;
pMgmt->sNodeDBTable[iNodeIndex].dwKeyIndex = dwKeyIndex;
return ret;
}
if (param->u.crypt.seq) {
memcpy(&abySeq, param->u.crypt.seq, 8);
for (ii = 0 ; ii < 8 ; ii++) {
KeyRSC |= (abySeq[ii] << (ii * 8));
}
dwKeyIndex |= 1 << 29;
pMgmt->sNodeDBTable[iNodeIndex].KeyRSC = KeyRSC;
}
if (param->u.crypt.alg == WPA_ALG_TKIP) {
if (param->u.crypt.key_len != MAX_KEY_LEN)
return -EINVAL;
pDevice->eEncryptionStatus = Ndis802_11Encryption2Enabled;
byKeyDecMode = KEY_CTL_TKIP;
pMgmt->byCSSPK = KEY_CTL_TKIP;
pMgmt->byCSSGK = KEY_CTL_TKIP;
}
if (param->u.crypt.alg == WPA_ALG_CCMP) {
if ((param->u.crypt.key_len != AES_KEY_LEN) ||
(pDevice->byLocalID <= REV_ID_VT3253_A1))
return -EINVAL;
pDevice->eEncryptionStatus = Ndis802_11Encryption3Enabled;
byKeyDecMode = KEY_CTL_CCMP;
pMgmt->byCSSPK = KEY_CTL_CCMP;
pMgmt->byCSSGK = KEY_CTL_CCMP;
}
if (iNodeIndex == 0) {
KeybSetDefaultKey(&(pDevice->sKey),
dwKeyIndex,
param->u.crypt.key_len,
(PQWORD) &(KeyRSC),
abyKey,
byKeyDecMode,
pDevice->PortOffset,
pDevice->byLocalID);
pMgmt->sNodeDBTable[iNodeIndex].bOnFly = TRUE;
} else {
dwKeyIndex |= (1 << 30); // set pairwise key
if (KeybSetKey(&(pDevice->sKey),
&param->sta_addr[0],
dwKeyIndex,
param->u.crypt.key_len,
(PQWORD) &(KeyRSC),
(PBYTE)abyKey,
byKeyDecMode,
pDevice->PortOffset,
pDevice->byLocalID) == TRUE) {
pMgmt->sNodeDBTable[iNodeIndex].bOnFly = TRUE;
} else {
// Key Table Full
pMgmt->sNodeDBTable[iNodeIndex].bOnFly = FALSE;
bKeyTableFull = TRUE;
DEVICE_PRT(MSG_LEVEL_DEBUG, KERN_INFO " Key Table Full\n");
}
}
if (bKeyTableFull == TRUE) {
wKeyCtl &= 0x7F00; // clear all key control filed
wKeyCtl |= (byKeyDecMode << 4);
wKeyCtl |= (byKeyDecMode);
wKeyCtl |= 0x0044; // use group key for all address
wKeyCtl |= 0x4000; // disable KeyTable[MAX_KEY_TABLE-1] on-fly to genernate rx int
MACvSetDefaultKeyCtl(pDevice->PortOffset, wKeyCtl, MAX_KEY_TABLE-1, pDevice->byLocalID);
}
DEVICE_PRT(MSG_LEVEL_DEBUG, KERN_INFO " Set key sta_index= %d \n", iNodeIndex);
DEVICE_PRT(MSG_LEVEL_DEBUG, KERN_INFO " tx_index=%d len=%d \n", param->u.crypt.idx,
param->u.crypt.key_len );
DEVICE_PRT(MSG_LEVEL_DEBUG, KERN_INFO " key=%x-%x-%x-%x-%x-xxxxx \n",
pMgmt->sNodeDBTable[iNodeIndex].abyWepKey[0],
pMgmt->sNodeDBTable[iNodeIndex].abyWepKey[1],
pMgmt->sNodeDBTable[iNodeIndex].abyWepKey[2],
pMgmt->sNodeDBTable[iNodeIndex].abyWepKey[3],
pMgmt->sNodeDBTable[iNodeIndex].abyWepKey[4]
);
// set wep key
pDevice->bEncryptionEnable = TRUE;
pMgmt->sNodeDBTable[iNodeIndex].byCipherSuite = byKeyDecMode;
pMgmt->sNodeDBTable[iNodeIndex].dwKeyIndex = dwKeyIndex;
pMgmt->sNodeDBTable[iNodeIndex].dwTSC47_16 = 0;
pMgmt->sNodeDBTable[iNodeIndex].wTSC15_0 = 0;
return ret;
}
/*
* Description:
* get each stations encryption key
*
* Parameters:
* In:
* pDevice -
* param -
* Out:
*
* Return Value:
*
*/
static int hostap_get_encryption(PSDevice pDevice,
struct viawget_hostapd_param *param,
int param_len)
{
PSMgmtObject pMgmt = pDevice->pMgmt;
int ret = 0;
int ii;
int iNodeIndex =0;
param->u.crypt.err = 0;
if (param->sta_addr[0] == 0xff && param->sta_addr[1] == 0xff &&
param->sta_addr[2] == 0xff && param->sta_addr[3] == 0xff &&
param->sta_addr[4] == 0xff && param->sta_addr[5] == 0xff) {
iNodeIndex = 0;
} else {
if (BSSDBbIsSTAInNodeDB(pMgmt, param->sta_addr, &iNodeIndex) == FALSE) {
param->u.crypt.err = HOSTAP_CRYPT_ERR_UNKNOWN_ADDR;
DEVICE_PRT(MSG_LEVEL_DEBUG, KERN_INFO "hostap_get_encryption: HOSTAP_CRYPT_ERR_UNKNOWN_ADDR\n");
return -EINVAL;
}
}
DEVICE_PRT(MSG_LEVEL_DEBUG, KERN_INFO "hostap_get_encryption: %d\n", iNodeIndex);
memset(param->u.crypt.seq, 0, 8);
for (ii = 0 ; ii < 8 ; ii++) {
param->u.crypt.seq[ii] = (BYTE)pMgmt->sNodeDBTable[iNodeIndex].KeyRSC >> (ii * 8);
}
return ret;
}
/*
* Description:
* hostap_ioctl main function supported for hostap deamon.
*
* Parameters:
* In:
* pDevice -
* iw_point -
* Out:
*
* Return Value:
*
*/
int hostap_ioctl(PSDevice pDevice, struct iw_point *p)
{
struct viawget_hostapd_param *param;
int ret = 0;
int ap_ioctl = 0;
if (p->length < sizeof(struct viawget_hostapd_param) ||
p->length > VIAWGET_HOSTAPD_MAX_BUF_SIZE || !p->pointer)
return -EINVAL;
param = (struct viawget_hostapd_param *) kmalloc((int)p->length, (int)GFP_KERNEL);
if (param == NULL)
return -ENOMEM;
if (copy_from_user(param, p->pointer, p->length)) {
ret = -EFAULT;
goto out;
}
switch (param->cmd) {
case VIAWGET_HOSTAPD_SET_ENCRYPTION:
DEVICE_PRT(MSG_LEVEL_DEBUG, KERN_INFO "VIAWGET_HOSTAPD_SET_ENCRYPTION \n");
spin_lock_irq(&pDevice->lock);
ret = hostap_set_encryption(pDevice, param, p->length);
spin_unlock_irq(&pDevice->lock);
break;
case VIAWGET_HOSTAPD_GET_ENCRYPTION:
DEVICE_PRT(MSG_LEVEL_DEBUG, KERN_INFO "VIAWGET_HOSTAPD_GET_ENCRYPTION \n");
spin_lock_irq(&pDevice->lock);
ret = hostap_get_encryption(pDevice, param, p->length);
spin_unlock_irq(&pDevice->lock);
break;
case VIAWGET_HOSTAPD_SET_ASSOC_AP_ADDR:
DEVICE_PRT(MSG_LEVEL_DEBUG, KERN_INFO "VIAWGET_HOSTAPD_SET_ASSOC_AP_ADDR \n");
return -EOPNOTSUPP;
break;
case VIAWGET_HOSTAPD_FLUSH:
DEVICE_PRT(MSG_LEVEL_DEBUG, KERN_INFO "VIAWGET_HOSTAPD_FLUSH \n");
spin_lock_irq(&pDevice->lock);
hostap_flush_sta(pDevice);
spin_unlock_irq(&pDevice->lock);
break;
case VIAWGET_HOSTAPD_ADD_STA:
DEVICE_PRT(MSG_LEVEL_DEBUG, KERN_INFO "VIAWGET_HOSTAPD_ADD_STA \n");
spin_lock_irq(&pDevice->lock);
ret = hostap_add_sta(pDevice, param);
spin_unlock_irq(&pDevice->lock);
break;
case VIAWGET_HOSTAPD_REMOVE_STA:
DEVICE_PRT(MSG_LEVEL_DEBUG, KERN_INFO "VIAWGET_HOSTAPD_REMOVE_STA \n");
spin_lock_irq(&pDevice->lock);
ret = hostap_remove_sta(pDevice, param);
spin_unlock_irq(&pDevice->lock);
break;
case VIAWGET_HOSTAPD_GET_INFO_STA:
DEVICE_PRT(MSG_LEVEL_DEBUG, KERN_INFO "VIAWGET_HOSTAPD_GET_INFO_STA \n");
ret = hostap_get_info_sta(pDevice, param);
ap_ioctl = 1;
break;
/*
case VIAWGET_HOSTAPD_RESET_TXEXC_STA:
DEVICE_PRT(MSG_LEVEL_DEBUG, KERN_INFO "VIAWGET_HOSTAPD_RESET_TXEXC_STA \n");
ret = hostap_reset_txexc_sta(pDevice, param);
break;
*/
case VIAWGET_HOSTAPD_SET_FLAGS_STA:
DEVICE_PRT(MSG_LEVEL_DEBUG, KERN_INFO "VIAWGET_HOSTAPD_SET_FLAGS_STA \n");
ret = hostap_set_flags_sta(pDevice, param);
break;
case VIAWGET_HOSTAPD_MLME:
DEVICE_PRT(MSG_LEVEL_DEBUG, KERN_INFO "VIAWGET_HOSTAPD_MLME \n");
return -EOPNOTSUPP;
case VIAWGET_HOSTAPD_SET_GENERIC_ELEMENT:
DEVICE_PRT(MSG_LEVEL_DEBUG, KERN_INFO "VIAWGET_HOSTAPD_SET_GENERIC_ELEMENT \n");
ret = hostap_set_generic_element(pDevice, param);
break;
case VIAWGET_HOSTAPD_SCAN_REQ:
DEVICE_PRT(MSG_LEVEL_DEBUG, KERN_INFO "VIAWGET_HOSTAPD_SCAN_REQ \n");
return -EOPNOTSUPP;
case VIAWGET_HOSTAPD_STA_CLEAR_STATS:
DEVICE_PRT(MSG_LEVEL_DEBUG, KERN_INFO "VIAWGET_HOSTAPD_STA_CLEAR_STATS \n");
return -EOPNOTSUPP;
default:
DEVICE_PRT(MSG_LEVEL_DEBUG, KERN_INFO "hostap_ioctl: unknown cmd=%d\n",
(int)param->cmd);
return -EOPNOTSUPP;
break;
}
if ((ret == 0) && ap_ioctl) {
if (copy_to_user(p->pointer, param, p->length)) {
ret = -EFAULT;
goto out;
}
}
out:
if (param != NULL)
kfree(param);
return ret;
}

View File

@ -0,0 +1,94 @@
/*
* Copyright (c) 1996, 2003 VIA Networking Technologies, Inc.
* All rights reserved.
*
* This program is free software; you can redistribute it and/or modify
* it under the terms of the GNU General Public License as published by
* the Free Software Foundation; either version 2 of the License, or
* (at your option) any later version.
*
* This program is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
* GNU General Public License for more details.
*
* You should have received a copy of the GNU General Public License along
* with this program; if not, write to the Free Software Foundation, Inc.,
* 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA.
*
* File: hostap.h
*
* Purpose:
*
* Author: Lyndon Chen
*
* Date: May 21, 2003
*
*/
#ifndef __HOSTAP_H__
#define __HOSTAP_H__
#if !defined(__DEVICE_H__)
#include "device.h"
#endif
/*--------------------- Export Definitions -------------------------*/
#if WIRELESS_EXT < 9
struct iw_point {
caddr_t pointer;
__u16 length;
__u16 flags;
};
#endif /* WIRELESS_EXT < 9 */
#define WLAN_RATE_1M BIT0
#define WLAN_RATE_2M BIT1
#define WLAN_RATE_5M5 BIT2
#define WLAN_RATE_11M BIT3
#define WLAN_RATE_6M BIT4
#define WLAN_RATE_9M BIT5
#define WLAN_RATE_12M BIT6
#define WLAN_RATE_18M BIT7
#define WLAN_RATE_24M BIT8
#define WLAN_RATE_36M BIT9
#define WLAN_RATE_48M BIT10
#define WLAN_RATE_54M BIT11
/*--------------------- Export Classes ----------------------------*/
/*--------------------- Export Variables --------------------------*/
/*--------------------- Export Functions --------------------------*/
#ifdef __cplusplus
extern "C" { /* Assume C declarations for C++ */
#endif /* __cplusplus */
#ifndef ETH_P_PAE
#define ETH_P_PAE 0x888E /* Port Access Entity (IEEE 802.1X) */
#endif /* ETH_P_PAE */
#ifndef ARPHRD_IEEE80211
#define ARPHRD_IEEE80211 801
#endif
int hostap_set_hostapd(PSDevice pDevice, int val, int rtnl_locked);
int hostap_ioctl(PSDevice pDevice, struct iw_point *p);
#ifdef __cplusplus
} /* End of extern "C" { */
#endif /* __cplusplus */
#endif // __HOSTAP_H__

View File

@ -0,0 +1,775 @@
/*
* Copyright (c) 1996, 2003 VIA Networking Technologies, Inc.
* All rights reserved.
*
* This program is free software; you can redistribute it and/or modify
* it under the terms of the GNU General Public License as published by
* the Free Software Foundation; either version 2 of the License, or
* (at your option) any later version.
*
* This program is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
* GNU General Public License for more details.
*
* You should have received a copy of the GNU General Public License along
* with this program; if not, write to the Free Software Foundation, Inc.,
* 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA.
*
* File: ioctl.c
*
* Purpose: private ioctl functions
*
* Author: Lyndon Chen
*
* Date: Auguest 20, 2003
*
* Functions:
*
* Revision History:
*
*/
#if !defined(__IOCTL_H__)
#include "ioctl.h"
#endif
#if !defined(__IOCMD_H__)
#include "iocmd.h"
#endif
#if !defined(__MAC_H__)
#include "mac.h"
#endif
#if !defined(__CARD_H__)
#include "card.h"
#endif
#if !defined(__HOSTAP_H__)
#include "hostap.h"
#endif
#if !defined(__UMEM_H__)
#include "umem.h"
#endif
#if !defined(__WPACTL_H__)
#include "wpactl.h"
#endif
#if !defined(__RF_H__)
#include "rf.h"
#endif
/*--------------------- Static Definitions -------------------------*/
/*--------------------- Static Classes ----------------------------*/
/*--------------------- Static Variables --------------------------*/
//static int msglevel =MSG_LEVEL_DEBUG;
static int msglevel =MSG_LEVEL_INFO;
/*--------------------- Static Functions --------------------------*/
#ifdef WPA_SM_Transtatus
SWPAResult wpa_Result;
#endif
/*--------------------- Export Variables --------------------------*/
int private_ioctl(PSDevice pDevice, struct ifreq *rq) {
PSCmdRequest pReq = (PSCmdRequest)rq;
PSMgmtObject pMgmt = pDevice->pMgmt;
int result = 0;
PWLAN_IE_SSID pItemSSID;
SCmdBSSJoin sJoinCmd;
SCmdZoneTypeSet sZoneTypeCmd;
SCmdScan sScanCmd;
SCmdStartAP sStartAPCmd;
SCmdSetWEP sWEPCmd;
SCmdValue sValue;
SBSSIDList sList;
SNodeList sNodeList;
PSBSSIDList pList;
PSNodeList pNodeList;
UINT cbListCount;
PKnownBSS pBSS;
PKnownNodeDB pNode;
UINT ii, jj;
SCmdLinkStatus sLinkStatus;
BYTE abySuppRates[] = {WLAN_EID_SUPP_RATES, 4, 0x02, 0x04, 0x0B, 0x16};
BYTE abyNullAddr[] = {0x00, 0x00, 0x00, 0x00, 0x00, 0x00};
DWORD dwKeyIndex= 0;
BYTE abyScanSSID[WLAN_IEHDR_LEN + WLAN_SSID_MAXLEN + 1];
LONG ldBm;
pReq->wResult = 0;
switch(pReq->wCmdCode) {
case WLAN_CMD_BSS_SCAN:
DEVICE_PRT(MSG_LEVEL_DEBUG, KERN_INFO "WLAN_CMD_BSS_SCAN..begin \n");
if (copy_from_user(&sScanCmd, pReq->data, sizeof(SCmdScan))) {
result = -EFAULT;
break;
};
pItemSSID = (PWLAN_IE_SSID)sScanCmd.ssid;
if (pItemSSID->len != 0) {
memset(abyScanSSID, 0, WLAN_IEHDR_LEN + WLAN_SSID_MAXLEN + 1);
memcpy(abyScanSSID, pItemSSID, pItemSSID->len + WLAN_IEHDR_LEN);
}
if (pDevice->bMACSuspend == TRUE) {
if (pDevice->bRadioOff == TRUE)
CARDbRadioPowerOn(pDevice);
vMgrTimerInit(pDevice);
MACvIntEnable(pDevice->PortOffset, IMR_MASK_VALUE);
add_timer(&pMgmt->sTimerSecondCallback);
pDevice->bMACSuspend = FALSE;
}
spin_lock_irq(&pDevice->lock);
if (memcmp(pMgmt->abyCurrBSSID, &abyNullAddr[0], 6) == 0)
BSSvClearBSSList((HANDLE)pDevice, FALSE);
else
BSSvClearBSSList((HANDLE)pDevice, pDevice->bLinkPass);
if (pItemSSID->len != 0)
bScheduleCommand((HANDLE) pDevice, WLAN_CMD_BSSID_SCAN, abyScanSSID);
else
bScheduleCommand((HANDLE) pDevice, WLAN_CMD_BSSID_SCAN, NULL);
spin_unlock_irq(&pDevice->lock);
break;
case WLAN_CMD_ZONETYPE_SET:
//mike add :cann't support.
result=-EOPNOTSUPP;
break;
if (copy_from_user(&sZoneTypeCmd, pReq->data, sizeof(SCmdZoneTypeSet))) {
result = -EFAULT;
break;
};
if(sZoneTypeCmd.bWrite==TRUE) {
//////write zonetype
if(sZoneTypeCmd.ZoneType == ZoneType_USA) {
//set to USA
printk("set_ZoneType:USA\n");
}
else if(sZoneTypeCmd.ZoneType == ZoneType_Japan) {
//set to Japan
printk("set_ZoneType:Japan\n");
}
else if(sZoneTypeCmd.ZoneType == ZoneType_Europe) {
//set to Europe
printk("set_ZoneType:Europe\n");
}
}
else {
///////read zonetype
BYTE zonetype=0;
if(zonetype == 0x00) { //USA
sZoneTypeCmd.ZoneType = ZoneType_USA;
}
else if(zonetype == 0x01) { //Japan
sZoneTypeCmd.ZoneType = ZoneType_Japan;
}
else if(zonetype == 0x02) { //Europe
sZoneTypeCmd.ZoneType = ZoneType_Europe;
}
else { //Unknow ZoneType
printk("Error:ZoneType[%x] Unknown ???\n",zonetype);
result = -EFAULT;
break;
}
if (copy_to_user(pReq->data, &sZoneTypeCmd, sizeof(SCmdZoneTypeSet))) {
result = -EFAULT;
break;
};
}
break;
case WLAN_CMD_BSS_JOIN:
if (pDevice->bMACSuspend == TRUE) {
if (pDevice->bRadioOff == TRUE)
CARDbRadioPowerOn(pDevice);
vMgrTimerInit(pDevice);
MACvIntEnable(pDevice->PortOffset, IMR_MASK_VALUE);
add_timer(&pMgmt->sTimerSecondCallback);
pDevice->bMACSuspend = FALSE;
}
if (copy_from_user(&sJoinCmd, pReq->data, sizeof(SCmdBSSJoin))) {
result = -EFAULT;
break;
};
pItemSSID = (PWLAN_IE_SSID)sJoinCmd.ssid;
memset(pMgmt->abyDesireSSID, 0, WLAN_IEHDR_LEN + WLAN_SSID_MAXLEN + 1);
memcpy(pMgmt->abyDesireSSID, pItemSSID, pItemSSID->len + WLAN_IEHDR_LEN);
if (sJoinCmd.wBSSType == ADHOC) {
pMgmt->eConfigMode = WMAC_CONFIG_IBSS_STA;
DEVICE_PRT(MSG_LEVEL_DEBUG, KERN_INFO "ioct set to adhoc mode\n");
}
else {
pMgmt->eConfigMode = WMAC_CONFIG_ESS_STA;
DEVICE_PRT(MSG_LEVEL_DEBUG, KERN_INFO "ioct set to STA mode\n");
}
if (sJoinCmd.bPSEnable == TRUE) {
pDevice->ePSMode = WMAC_POWER_FAST;
// pDevice->ePSMode = WMAC_POWER_MAX;
pMgmt->wListenInterval = 2;
DEVICE_PRT(MSG_LEVEL_DEBUG, KERN_INFO "Power Saving On\n");
}
else {
pDevice->ePSMode = WMAC_POWER_CAM;
pMgmt->wListenInterval = 1;
DEVICE_PRT(MSG_LEVEL_DEBUG, KERN_INFO "Power Saving Off \n");
}
if (sJoinCmd.bShareKeyAuth == TRUE){
pMgmt->bShareKeyAlgorithm = TRUE;
DEVICE_PRT(MSG_LEVEL_DEBUG, KERN_INFO "Share Key \n");
}
else {
pMgmt->bShareKeyAlgorithm = FALSE;
DEVICE_PRT(MSG_LEVEL_DEBUG, KERN_INFO "Open System \n");
}
pDevice->uChannel = sJoinCmd.uChannel;
netif_stop_queue(pDevice->dev);
spin_lock_irq(&pDevice->lock);
pMgmt->eCurrState = WMAC_STATE_IDLE;
bScheduleCommand((HANDLE) pDevice, WLAN_CMD_BSSID_SCAN, pMgmt->abyDesireSSID);
bScheduleCommand((HANDLE) pDevice, WLAN_CMD_SSID, NULL);
spin_unlock_irq(&pDevice->lock);
break;
case WLAN_CMD_SET_WEP:
DEVICE_PRT(MSG_LEVEL_DEBUG, KERN_INFO "WLAN_CMD_SET_WEP Key. \n");
memset(&sWEPCmd, 0 ,sizeof(SCmdSetWEP));
if (copy_from_user(&sWEPCmd, pReq->data, sizeof(SCmdSetWEP))) {
result = -EFAULT;
break;
};
if (sWEPCmd.bEnableWep != TRUE) {
pDevice->bEncryptionEnable = FALSE;
pDevice->eEncryptionStatus = Ndis802_11EncryptionDisabled;
MACvDisableDefaultKey(pDevice->PortOffset);
DEVICE_PRT(MSG_LEVEL_DEBUG, KERN_INFO "WEP function disable. \n");
break;
}
for (ii = 0; ii < WLAN_WEP_NKEYS; ii ++) {
if (sWEPCmd.bWepKeyAvailable[ii]) {
if (ii == sWEPCmd.byKeyIndex)
//2006-1123-02,<Modify> by EinsnLiu
//Evaluate the "dwKeyIndex" error
// dwKeyIndex |= (1 << 31);
dwKeyIndex =ii|(1 << 31);
else
dwKeyIndex = ii;
KeybSetDefaultKey(&(pDevice->sKey),
dwKeyIndex,
sWEPCmd.auWepKeyLength[ii],
NULL,
(PBYTE)&sWEPCmd.abyWepKey[ii][0],
KEY_CTL_WEP,
pDevice->PortOffset,
pDevice->byLocalID);
}
}
pDevice->byKeyIndex = sWEPCmd.byKeyIndex;
pDevice->bTransmitKey = TRUE;
pDevice->bEncryptionEnable = TRUE;
pDevice->eEncryptionStatus = Ndis802_11Encryption1Enabled;
break;
case WLAN_CMD_GET_LINK:
DEVICE_PRT(MSG_LEVEL_DEBUG, KERN_INFO "WLAN_CMD_GET_LINK status. \n");
memset(sLinkStatus.abySSID, 0 , WLAN_SSID_MAXLEN + 1);
if (pMgmt->eCurrMode == WMAC_MODE_IBSS_STA)
sLinkStatus.wBSSType = ADHOC;
else
sLinkStatus.wBSSType = INFRA;
if (pMgmt->eCurrState == WMAC_STATE_JOINTED)
sLinkStatus.byState = ADHOC_JOINTED;
else
sLinkStatus.byState = ADHOC_STARTED;
sLinkStatus.uChannel = pMgmt->uCurrChannel;
if (pDevice->bLinkPass == TRUE) {
sLinkStatus.bLink = TRUE;
pItemSSID = (PWLAN_IE_SSID)pMgmt->abyCurrSSID;
memcpy(sLinkStatus.abySSID, pItemSSID->abySSID, pItemSSID->len);
memcpy(sLinkStatus.abyBSSID, pMgmt->abyCurrBSSID, WLAN_BSSID_LEN);
sLinkStatus.uLinkRate = pMgmt->sNodeDBTable[0].wTxDataRate;
DEVICE_PRT(MSG_LEVEL_DEBUG, KERN_INFO" Link Success ! \n");
}
else {
sLinkStatus.bLink = FALSE;
}
if (copy_to_user(pReq->data, &sLinkStatus, sizeof(SCmdLinkStatus))) {
result = -EFAULT;
break;
};
break;
case WLAN_CMD_GET_LISTLEN:
cbListCount = 0;
pBSS = &(pMgmt->sBSSList[0]);
for (ii = 0; ii < MAX_BSS_NUM; ii++) {
pBSS = &(pMgmt->sBSSList[ii]);
if (!pBSS->bActive)
continue;
cbListCount++;
};
sList.uItem = cbListCount;
if (copy_to_user(pReq->data, &sList, sizeof(SBSSIDList))) {
result = -EFAULT;
break;
};
pReq->wResult = 0;
break;
case WLAN_CMD_GET_LIST:
if (copy_from_user(&sList, pReq->data, sizeof(SBSSIDList))) {
result = -EFAULT;
break;
};
pList = (PSBSSIDList)kmalloc(sizeof(SBSSIDList) + (sList.uItem * sizeof(SBSSIDItem)), (int)GFP_ATOMIC);
if (pList == NULL) {
result = -ENOMEM;
break;
}
pList->uItem = sList.uItem;
pBSS = &(pMgmt->sBSSList[0]);
for (ii = 0, jj = 0; jj < MAX_BSS_NUM ; jj++) {
pBSS = &(pMgmt->sBSSList[jj]);
if (pBSS->bActive) {
pList->sBSSIDList[ii].uChannel = pBSS->uChannel;
pList->sBSSIDList[ii].wBeaconInterval = pBSS->wBeaconInterval;
pList->sBSSIDList[ii].wCapInfo = pBSS->wCapInfo;
// pList->sBSSIDList[ii].uRSSI = pBSS->uRSSI;
RFvRSSITodBm(pDevice, (BYTE)(pBSS->uRSSI), &ldBm);
pList->sBSSIDList[ii].uRSSI = (UINT)ldBm;
memcpy(pList->sBSSIDList[ii].abyBSSID, pBSS->abyBSSID, WLAN_BSSID_LEN);
pItemSSID = (PWLAN_IE_SSID)pBSS->abySSID;
memset(pList->sBSSIDList[ii].abySSID, 0, WLAN_SSID_MAXLEN + 1);
memcpy(pList->sBSSIDList[ii].abySSID, pItemSSID->abySSID, pItemSSID->len);
if (WLAN_GET_CAP_INFO_ESS(pBSS->wCapInfo)) {
pList->sBSSIDList[ii].byNetType = INFRA;
}
else {
pList->sBSSIDList[ii].byNetType = ADHOC;
}
if (WLAN_GET_CAP_INFO_PRIVACY(pBSS->wCapInfo)) {
pList->sBSSIDList[ii].bWEPOn = TRUE;
}
else {
pList->sBSSIDList[ii].bWEPOn = FALSE;
}
ii ++;
if (ii >= pList->uItem)
break;
}
}
if (copy_to_user(pReq->data, pList, sizeof(SBSSIDList) + (sList.uItem * sizeof(SBSSIDItem)))) {
result = -EFAULT;
break;
};
kfree(pList);
pReq->wResult = 0;
break;
case WLAN_CMD_GET_MIB:
if (copy_to_user(pReq->data, &(pDevice->s802_11Counter), sizeof(SDot11MIBCount))) {
result = -EFAULT;
break;
};
break;
case WLAN_CMD_GET_STAT:
if (copy_to_user(pReq->data, &(pDevice->scStatistic), sizeof(SStatCounter))) {
result = -EFAULT;
break;
};
break;
case WLAN_CMD_STOP_MAC:
DEVICE_PRT(MSG_LEVEL_DEBUG, KERN_INFO "WLAN_CMD_STOP_MAC\n");
netif_stop_queue(pDevice->dev);
spin_lock_irq(&pDevice->lock);
if (pDevice->bRadioOff == FALSE) {
CARDbRadioPowerOff(pDevice);
}
pDevice->bLinkPass = FALSE;
memset(pMgmt->abyCurrBSSID, 0, 6);
pMgmt->eCurrState = WMAC_STATE_IDLE;
del_timer(&pDevice->sTimerCommand);
del_timer(&pMgmt->sTimerSecondCallback);
pDevice->bCmdRunning = FALSE;
pDevice->bMACSuspend = TRUE;
MACvIntDisable(pDevice->PortOffset);
spin_unlock_irq(&pDevice->lock);
break;
case WLAN_CMD_START_MAC:
DEVICE_PRT(MSG_LEVEL_DEBUG, KERN_INFO "WLAN_CMD_START_MAC\n");
if (pDevice->bMACSuspend == TRUE) {
if (pDevice->bRadioOff == TRUE)
CARDbRadioPowerOn(pDevice);
vMgrTimerInit(pDevice);
MACvIntEnable(pDevice->PortOffset, IMR_MASK_VALUE);
add_timer(&pMgmt->sTimerSecondCallback);
pDevice->bMACSuspend = FALSE;
}
break;
case WLAN_CMD_SET_HOSTAPD:
DEVICE_PRT(MSG_LEVEL_DEBUG, KERN_INFO "WLAN_CMD_SET_HOSTAPD\n");
if (copy_from_user(&sValue, pReq->data, sizeof(SCmdValue))) {
result = -EFAULT;
break;
};
if (sValue.dwValue == 1) {
if (hostap_set_hostapd(pDevice, 1, 1) == 0){
DEVICE_PRT(MSG_LEVEL_DEBUG, KERN_INFO "Enable HOSTAP\n");
}
else {
result = -EFAULT;
break;
}
}
else {
hostap_set_hostapd(pDevice, 0, 1);
DEVICE_PRT(MSG_LEVEL_DEBUG, KERN_INFO "Disable HOSTAP\n");
}
break;
case WLAN_CMD_SET_HOSTAPD_STA:
DEVICE_PRT(MSG_LEVEL_DEBUG, KERN_INFO "WLAN_CMD_SET_HOSTAPD_STA\n");
break;
case WLAN_CMD_SET_802_1X:
DEVICE_PRT(MSG_LEVEL_DEBUG, KERN_INFO "WLAN_CMD_SET_802_1X\n");
if (copy_from_user(&sValue, pReq->data, sizeof(SCmdValue))) {
result = -EFAULT;
break;
};
if (sValue.dwValue == 1) {
pDevice->bEnable8021x = TRUE;
DEVICE_PRT(MSG_LEVEL_DEBUG, KERN_INFO "Enable 802.1x\n");
}
else {
pDevice->bEnable8021x = FALSE;
DEVICE_PRT(MSG_LEVEL_DEBUG, KERN_INFO "Disable 802.1x\n");
}
break;
case WLAN_CMD_SET_HOST_WEP:
DEVICE_PRT(MSG_LEVEL_DEBUG, KERN_INFO "WLAN_CMD_SET_HOST_WEP\n");
if (copy_from_user(&sValue, pReq->data, sizeof(SCmdValue))) {
result = -EFAULT;
break;
};
if (sValue.dwValue == 1) {
pDevice->bEnableHostWEP = TRUE;
DEVICE_PRT(MSG_LEVEL_DEBUG, KERN_INFO "Enable HostWEP\n");
}
else {
pDevice->bEnableHostWEP = FALSE;
DEVICE_PRT(MSG_LEVEL_DEBUG, KERN_INFO "Disable HostWEP\n");
}
break;
case WLAN_CMD_SET_WPA:
DEVICE_PRT(MSG_LEVEL_DEBUG, KERN_INFO "WLAN_CMD_SET_WPA\n");
if (copy_from_user(&sValue, pReq->data, sizeof(SCmdValue))) {
result = -EFAULT;
break;
};
if (sValue.dwValue == 1) {
DEVICE_PRT(MSG_LEVEL_DEBUG, KERN_INFO "up wpadev\n");
memcpy(pDevice->wpadev->dev_addr, pDevice->dev->dev_addr, U_ETHER_ADDR_LEN);
pDevice->bWPADEVUp = TRUE;
}
else {
DEVICE_PRT(MSG_LEVEL_DEBUG, KERN_INFO "close wpadev\n");
pDevice->bWPADEVUp = FALSE;
}
break;
case WLAN_CMD_AP_START:
DEVICE_PRT(MSG_LEVEL_DEBUG, KERN_INFO "WLAN_CMD_AP_START\n");
if (pDevice->bRadioOff == TRUE) {
CARDbRadioPowerOn(pDevice);
vMgrTimerInit(pDevice);
MACvIntEnable(pDevice->PortOffset, IMR_MASK_VALUE);
add_timer(&pMgmt->sTimerSecondCallback);
}
if (copy_from_user(&sStartAPCmd, pReq->data, sizeof(SCmdStartAP))) {
result = -EFAULT;
break;
};
if (sStartAPCmd.wBSSType == AP) {
pMgmt->eConfigMode = WMAC_CONFIG_AP;
DEVICE_PRT(MSG_LEVEL_DEBUG, KERN_INFO "ioct set to AP mode\n");
}
else {
DEVICE_PRT(MSG_LEVEL_DEBUG, KERN_INFO "ioct BSS type not set to AP mode\n");
result = -EFAULT;
break;
}
if (sStartAPCmd.wBBPType == PHY80211g) {
pMgmt->byAPBBType = PHY_TYPE_11G;
}
else if (sStartAPCmd.wBBPType == PHY80211a) {
pMgmt->byAPBBType = PHY_TYPE_11A;
}
else {
pMgmt->byAPBBType = PHY_TYPE_11B;
}
pItemSSID = (PWLAN_IE_SSID)sStartAPCmd.ssid;
memset(pMgmt->abyDesireSSID, 0, WLAN_IEHDR_LEN + WLAN_SSID_MAXLEN + 1);
memcpy(pMgmt->abyDesireSSID, pItemSSID, pItemSSID->len + WLAN_IEHDR_LEN);
if ((sStartAPCmd.uChannel > 0)&&(sStartAPCmd.uChannel <= 14))
pDevice->uChannel = sStartAPCmd.uChannel;
if ((sStartAPCmd.uBeaconInt >= 20) && (sStartAPCmd.uBeaconInt <= 1000))
pMgmt->wIBSSBeaconPeriod = sStartAPCmd.uBeaconInt;
else
pMgmt->wIBSSBeaconPeriod = 100;
if (sStartAPCmd.bShareKeyAuth == TRUE){
pMgmt->bShareKeyAlgorithm = TRUE;
DEVICE_PRT(MSG_LEVEL_DEBUG, KERN_INFO "Share Key \n");
}
else {
pMgmt->bShareKeyAlgorithm = FALSE;
DEVICE_PRT(MSG_LEVEL_DEBUG, KERN_INFO "Open System \n");
}
memcpy(pMgmt->abyIBSSSuppRates, abySuppRates, 6);
if (sStartAPCmd.byBasicRate & BIT3) {
pMgmt->abyIBSSSuppRates[2] |= BIT7;
pMgmt->abyIBSSSuppRates[3] |= BIT7;
pMgmt->abyIBSSSuppRates[4] |= BIT7;
pMgmt->abyIBSSSuppRates[5] |= BIT7;
}else if (sStartAPCmd.byBasicRate & BIT2) {
pMgmt->abyIBSSSuppRates[2] |= BIT7;
pMgmt->abyIBSSSuppRates[3] |= BIT7;
pMgmt->abyIBSSSuppRates[4] |= BIT7;
}else if (sStartAPCmd.byBasicRate & BIT1) {
pMgmt->abyIBSSSuppRates[2] |= BIT7;
pMgmt->abyIBSSSuppRates[3] |= BIT7;
}else if (sStartAPCmd.byBasicRate & BIT1) {
pMgmt->abyIBSSSuppRates[2] |= BIT7;
}else {
//default 1,2M
pMgmt->abyIBSSSuppRates[2] |= BIT7;
pMgmt->abyIBSSSuppRates[3] |= BIT7;
}
DEVICE_PRT(MSG_LEVEL_DEBUG, KERN_INFO "Support Rate= %x %x %x %x\n",
pMgmt->abyIBSSSuppRates[2],
pMgmt->abyIBSSSuppRates[3],
pMgmt->abyIBSSSuppRates[4],
pMgmt->abyIBSSSuppRates[5]
);
netif_stop_queue(pDevice->dev);
spin_lock_irq(&pDevice->lock);
bScheduleCommand((HANDLE)pDevice, WLAN_CMD_RUN_AP, NULL);
spin_unlock_irq(&pDevice->lock);
break;
case WLAN_CMD_GET_NODE_CNT:
cbListCount = 0;
pNode = &(pMgmt->sNodeDBTable[0]);
for (ii = 0; ii < (MAX_NODE_NUM + 1); ii++) {
pNode = &(pMgmt->sNodeDBTable[ii]);
if (!pNode->bActive)
continue;
cbListCount++;
};
sNodeList.uItem = cbListCount;
if (copy_to_user(pReq->data, &sNodeList, sizeof(SNodeList))) {
result = -EFAULT;
break;
};
pReq->wResult = 0;
break;
case WLAN_CMD_GET_NODE_LIST:
if (copy_from_user(&sNodeList, pReq->data, sizeof(SNodeList))) {
result = -EFAULT;
break;
};
pNodeList = (PSNodeList)kmalloc(sizeof(SNodeList) + (sNodeList.uItem * sizeof(SNodeItem)), (int)GFP_ATOMIC);
if (pNodeList == NULL) {
result = -ENOMEM;
break;
}
pNodeList->uItem = sNodeList.uItem;
pNode = &(pMgmt->sNodeDBTable[0]);
for (ii = 0, jj = 0; ii < (MAX_NODE_NUM + 1); ii++) {
pNode = &(pMgmt->sNodeDBTable[ii]);
if (pNode->bActive) {
pNodeList->sNodeList[jj].wAID = pNode->wAID;
memcpy(pNodeList->sNodeList[jj].abyMACAddr, pNode->abyMACAddr, WLAN_ADDR_LEN);
pNodeList->sNodeList[jj].wTxDataRate = pNode->wTxDataRate;
pNodeList->sNodeList[jj].wInActiveCount = (WORD)pNode->uInActiveCount;
pNodeList->sNodeList[jj].wEnQueueCnt = (WORD)pNode->wEnQueueCnt;
pNodeList->sNodeList[jj].wFlags = (WORD)pNode->dwFlags;
pNodeList->sNodeList[jj].bPWBitOn = pNode->bPSEnable;
pNodeList->sNodeList[jj].byKeyIndex = pNode->byKeyIndex;
pNodeList->sNodeList[jj].wWepKeyLength = pNode->uWepKeyLength;
memcpy(&(pNodeList->sNodeList[jj].abyWepKey[0]), &(pNode->abyWepKey[0]), WEP_KEYMAXLEN);
DEVICE_PRT(MSG_LEVEL_DEBUG, KERN_INFO "key= %2.2X:%2.2X:%2.2X:%2.2X:%2.2X\n",
pNodeList->sNodeList[jj].abyWepKey[0],
pNodeList->sNodeList[jj].abyWepKey[1],
pNodeList->sNodeList[jj].abyWepKey[2],
pNodeList->sNodeList[jj].abyWepKey[3],
pNodeList->sNodeList[jj].abyWepKey[4]
);
pNodeList->sNodeList[jj].bIsInFallback = pNode->bIsInFallback;
pNodeList->sNodeList[jj].uTxFailures = pNode->uTxFailures;
pNodeList->sNodeList[jj].uTxAttempts = pNode->uTxAttempts;
pNodeList->sNodeList[jj].wFailureRatio = (WORD)pNode->uFailureRatio;
jj ++;
if (jj >= pNodeList->uItem)
break;
}
};
if (copy_to_user(pReq->data, pNodeList, sizeof(SNodeList) + (sNodeList.uItem * sizeof(SNodeItem)))) {
result = -EFAULT;
break;
};
kfree(pNodeList);
pReq->wResult = 0;
break;
#ifdef WPA_SM_Transtatus
case 0xFF:
memset(wpa_Result.ifname,0,sizeof(wpa_Result.ifname));
wpa_Result.proto = 0;
wpa_Result.key_mgmt = 0;
wpa_Result.eap_type = 0;
wpa_Result.authenticated = FALSE;
pDevice->fWPA_Authened = FALSE;
if (copy_from_user(&wpa_Result, pReq->data, sizeof(wpa_Result))) {
result = -EFAULT;
break;
}
if(wpa_Result.authenticated==TRUE) {
#ifdef SndEvt_ToAPI
{
union iwreq_data wrqu;
pItemSSID = (PWLAN_IE_SSID)pMgmt->abyCurrSSID;
memset(&wrqu, 0, sizeof(wrqu));
wrqu.data.flags = RT_WPACONNECTED_EVENT_FLAG;
wrqu.data.length =pItemSSID->len;
wireless_send_event(pDevice->dev, IWEVCUSTOM, &wrqu, pItemSSID->abySSID);
}
#endif
pDevice->fWPA_Authened = TRUE; //is sucessful peer to wpa_Result.authenticated?
}
//printk("get private wpa_supplicant announce WPA SM\n");
//printk("wpa-->ifname=%s\n",wpa_Result.ifname);
//printk("wpa-->proto=%d\n",wpa_Result.proto);
//printk("wpa-->key-mgmt=%d\n",wpa_Result.key_mgmt);
//printk("wpa-->eap_type=%d\n",wpa_Result.eap_type);
//printk("wpa-->authenticated is %s\n",(wpa_Result.authenticated==TRUE)?"TRUE":"FALSE");
pReq->wResult = 0;
break;
#endif
default:
DEVICE_PRT(MSG_LEVEL_DEBUG, KERN_INFO "Private command not support..\n");
}
return result;
}
/*
VOID
vConfigWEPKey (
IN PSDevice pDevice,
IN DWORD dwKeyIndex,
IN PBYTE pbyKey,
IN ULONG uKeyLength
)
{
int ii;
ZERO_MEMORY(&pDevice->abyWepKey[dwKeyIndex][0], WLAN_WEPMAX_KEYLEN);
MEMvCopy(&pDevice->abyWepKey[dwKeyIndex][0], pbyKey, uKeyLength);
pDevice->bWepKeyAvailable[dwKeyIndex] = TRUE;
pDevice->auWepKeyLength[dwKeyIndex] = uKeyLength;
MACvSetDefaultKeyEntry(pDevice->PortOffset, uKeyLength, dwKeyIndex,
(PDWORD) &(pDevice->abyWepKey[dwKeyIndex][0]), pDevice->byLocalID);
if (pDevice->eEncryptionStatus < Ndis802_11EncryptionNotSupported) {
for(ii=0; ii<MAX_GROUP_KEY; ii++) {
if ((pDevice->bWepKeyAvailable[ii] == TRUE) &&
(pDevice->auWepKeyLength[ii] == WLAN_WEP232_KEYLEN)) {
pDevice->uCurrentWEPMode = TX_WEP_SW232;
MACvDisableDefaultKey(pDevice->PortOffset);
break;
}
}
if ((ii == MAX_GROUP_KEY) &&
(pDevice->eEncryptionStatus < Ndis802_11EncryptionNotSupported)) {
MACvEnableDefaultKey(pDevice->PortOffset, pDevice->byLocalID);
}
}
}
*/

View File

@ -0,0 +1,74 @@
/*
* Copyright (c) 1996, 2003 VIA Networking Technologies, Inc.
* All rights reserved.
*
* This program is free software; you can redistribute it and/or modify
* it under the terms of the GNU General Public License as published by
* the Free Software Foundation; either version 2 of the License, or
* (at your option) any later version.
*
* This program is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
* GNU General Public License for more details.
*
* You should have received a copy of the GNU General Public License along
* with this program; if not, write to the Free Software Foundation, Inc.,
* 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA.
*
* File: hostap.h
*
* Purpose:
*
* Author: Lyndon Chen
*
* Date: May 21, 2003
*
*/
#ifndef __IOCTL_H__
#define __IOCTL_H__
#if !defined(__DEVICE_H__)
#include "device.h"
#endif
/*--------------------- Export Definitions -------------------------*/
/*--------------------- Export Classes ----------------------------*/
/*--------------------- Export Variables --------------------------*/
/*--------------------- Export Functions --------------------------*/
#ifdef __cplusplus
extern "C" { /* Assume C declarations for C++ */
#endif /* __cplusplus */
int private_ioctl(PSDevice pDevice, struct ifreq *rq);
/*
VOID vConfigWEPKey (
IN PSDevice pDevice,
IN DWORD dwKeyIndex,
IN PBYTE pbyKey,
IN ULONG uKeyLength
);
*/
#ifdef __cplusplus
} /* End of extern "C" { */
#endif /* __cplusplus */
#endif // __IOCTL_H__

File diff suppressed because it is too large Load Diff

View File

@ -0,0 +1,332 @@
/*
* Copyright (c) 1996, 2003 VIA Networking Technologies, Inc.
* All rights reserved.
*
* This program is free software; you can redistribute it and/or modify
* it under the terms of the GNU General Public License as published by
* the Free Software Foundation; either version 2 of the License, or
* (at your option) any later version.
*
* This program is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
* GNU General Public License for more details.
*
* You should have received a copy of the GNU General Public License along
* with this program; if not, write to the Free Software Foundation, Inc.,
* 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA.
*
* File: iwctl.h
*
* Purpose:
*
* Author: Lyndon Chen
*
* Date: May 21, 2004
*
*/
#ifndef __IWCTL_H__
#define __IWCTL_H__
#if !defined(__DEVICE_H__)
#include "device.h"
#endif
/*--------------------- Export Definitions -------------------------*/
/*--------------------- Export Classes ----------------------------*/
/*--------------------- Export Variables --------------------------*/
/*--------------------- Export Functions --------------------------*/
#ifdef __cplusplus
extern "C" { /* Assume C declarations for C++ */
#endif /* __cplusplus */
#if WIRELESS_EXT < 18
#define SIOCSIWMLME 0x8B16
#define SIOCSIWGENIE 0x8B30
// WPA : Authentication mode parameters
#define SIOCSIWAUTH 0x8B32
#define SIOCGIWAUTH 0x8B33
// WPA : Extended version of encoding configuration
#define SIOCSIWENCODEEXT 0x8B34
#define SIOCGIWENCODEEXT 0x8B35
#define IW_AUTH_WPA_VERSION 0
#define IW_AUTH_CIPHER_PAIRWISE 1
#define IW_AUTH_CIPHER_GROUP 2
#define IW_AUTH_KEY_MGMT 3
#define IW_AUTH_TKIP_COUNTERMEASURES 4
#define IW_AUTH_DROP_UNENCRYPTED 5
#define IW_AUTH_80211_AUTH_ALG 6
#define IW_AUTH_WPA_ENABLED 7
#define IW_AUTH_RX_UNENCRYPTED_EAPOL 8
#define IW_AUTH_ROAMING_CONTROL 9
#define IW_AUTH_PRIVACY_INVOKED 10
#define IW_AUTH_WPA_VERSION_DISABLED 0x00000001
#define IW_AUTH_WPA_VERSION_WPA 0x00000002
#define IW_AUTH_WPA_VERSION_WPA2 0x00000004
#define IW_AUTH_CIPHER_NONE 0x00000001
#define IW_AUTH_CIPHER_WEP40 0x00000002
#define IW_AUTH_CIPHER_TKIP 0x00000004
#define IW_AUTH_CIPHER_CCMP 0x00000008
#define IW_AUTH_CIPHER_WEP104 0x00000010
#define IW_AUTH_KEY_MGMT_802_1X 1
#define IW_AUTH_KEY_MGMT_PSK 2
#define IW_AUTH_ALG_OPEN_SYSTEM 0x00000001
#define IW_AUTH_ALG_SHARED_KEY 0x00000002
#define IW_AUTH_ALG_LEAP 0x00000004
#define IW_AUTH_ROAMING_ENABLE 0
#define IW_AUTH_ROAMING_DISABLE 1
#define IW_ENCODE_SEQ_MAX_SIZE 8
#define IW_ENCODE_ALG_NONE 0
#define IW_ENCODE_ALG_WEP 1
#define IW_ENCODE_ALG_TKIP 2
#define IW_ENCODE_ALG_CCMP 3
struct iw_encode_ext
{
__u32 ext_flags; // IW_ENCODE_EXT_*
__u8 tx_seq[IW_ENCODE_SEQ_MAX_SIZE]; // LSB first
__u8 rx_seq[IW_ENCODE_SEQ_MAX_SIZE]; // LSB first
struct sockaddr addr; // ff:ff:ff:ff:ff:ff for broadcast/multicast
// (group) keys or unicast address for
// individual keys
__u16 alg; // IW_ENCODE_ALG_*
__u16 key_len;
__u8 key[0];
};
struct iw_mlme
{
__u16 cmd; /* IW_MLME_* */
__u16 reason_code;
struct sockaddr addr;
};
#endif // WIRELESS_EXT < 18
#ifdef WIRELESS_EXT
struct iw_statistics *iwctl_get_wireless_stats (struct net_device *dev);
int iwctl_siwap(struct net_device *dev,
struct iw_request_info *info,
struct sockaddr *wrq,
char *extra);
int iwctl_giwrange(struct net_device *dev,
struct iw_request_info *info,
struct iw_point *wrq,
char *extra);
int iwctl_giwmode(struct net_device *dev,
struct iw_request_info *info,
__u32 *wmode,
char *extra);
int iwctl_siwmode(struct net_device *dev,
struct iw_request_info *info,
__u32 *wmode,
char *extra);
int iwctl_giwfreq(struct net_device *dev,
struct iw_request_info *info,
struct iw_freq *wrq,
char *extra);
int iwctl_siwfreq(struct net_device *dev,
struct iw_request_info *info,
struct iw_freq *wrq,
char *extra);
int iwctl_giwname(struct net_device *dev,
struct iw_request_info *info,
char *wrq,
char *extra);
int iwctl_giwnwid(struct net_device *dev,
struct iw_request_info *info,
struct iw_param *wrq,
char *extra) ;
int iwctl_giwsens(struct net_device *dev,
struct iw_request_info *info,
struct iw_param *wrq,
char *extra);
int iwctl_giwap(struct net_device *dev,
struct iw_request_info *info,
struct sockaddr *wrq,
char *extra);
int iwctl_giwaplist(struct net_device *dev,
struct iw_request_info *info,
struct iw_point *wrq,
char *extra);
int iwctl_siwessid(struct net_device *dev,
struct iw_request_info *info,
struct iw_point *wrq,
char *extra);
int iwctl_giwessid(struct net_device *dev,
struct iw_request_info *info,
struct iw_point *wrq,
char *extra);
int iwctl_siwrate(struct net_device *dev,
struct iw_request_info *info,
struct iw_param *wrq,
char *extra);
int iwctl_giwrate(struct net_device *dev,
struct iw_request_info *info,
struct iw_param *wrq,
char *extra);
int iwctl_siwrts(struct net_device *dev,
struct iw_request_info *info,
struct iw_param *wrq,
char *extra);
int iwctl_giwrts(struct net_device *dev,
struct iw_request_info *info,
struct iw_param *wrq,
char *extra);
int iwctl_siwfrag(struct net_device *dev,
struct iw_request_info *info,
struct iw_param *wrq,
char *extra);
int iwctl_giwfrag(struct net_device *dev,
struct iw_request_info *info,
struct iw_param *wrq,
char *extra);
int iwctl_siwretry(struct net_device *dev,
struct iw_request_info *info,
struct iw_param *wrq,
char *extra);
int iwctl_giwretry(struct net_device *dev,
struct iw_request_info *info,
struct iw_param *wrq,
char *extra);
int iwctl_siwencode(struct net_device *dev,
struct iw_request_info *info,
struct iw_point *wrq,
char *extra);
int iwctl_giwencode(struct net_device *dev,
struct iw_request_info *info,
struct iw_point *wrq,
char *extra);
int iwctl_siwpower(struct net_device *dev,
struct iw_request_info *info,
struct iw_param *wrq,
char *extra);
int iwctl_giwpower(struct net_device *dev,
struct iw_request_info *info,
struct iw_param *wrq,
char *extra);
int iwctl_giwscan(struct net_device *dev,
struct iw_request_info *info,
struct iw_point *wrq,
char *extra);
int iwctl_siwscan(struct net_device *dev,
struct iw_request_info *info,
struct iw_param *wrq,
char *extra);
//2008-0409-07, <Add> by Einsn Liu
#ifdef WPA_SUPPLICANT_DRIVER_WEXT_SUPPORT
int iwctl_siwauth(struct net_device *dev,
struct iw_request_info *info,
struct iw_param *wrq,
char *extra);
int iwctl_giwauth(struct net_device *dev,
struct iw_request_info *info,
struct iw_param *wrq,
char *extra);
int iwctl_siwgenie(struct net_device *dev,
struct iw_request_info *info,
struct iw_point *wrq,
char *extra);
int iwctl_giwgenie(struct net_device *dev,
struct iw_request_info *info,
struct iw_point *wrq,
char *extra);
int iwctl_siwencodeext(struct net_device *dev,
struct iw_request_info *info,
struct iw_point *wrq,
char *extra);
int iwctl_giwencodeext(struct net_device *dev,
struct iw_request_info *info,
struct iw_point *wrq,
char *extra);
int iwctl_siwmlme(struct net_device *dev,
struct iw_request_info * info,
struct iw_point *wrq,
char *extra);
#endif // #ifdef WPA_SUPPLICANT_DRIVER_WEXT_SUPPORT
#endif
#if WIRELESS_EXT > 12
extern const struct iw_handler_def iwctl_handler_def;
extern const struct iw_priv_args iwctl_private_args;
#else
struct iw_request_info {};
#endif //WIRELESS_EXT > 12
#ifdef __cplusplus
} /* End of extern "C" { */
#endif /* __cplusplus */
#endif // __IWCTL_H__

View File

@ -0,0 +1,302 @@
/*
* Copyright (c) 1996, 2003 VIA Networking Technologies, Inc.
* All rights reserved.
*
* This program is free software; you can redistribute it and/or modify
* it under the terms of the GNU General Public License as published by
* the Free Software Foundation; either version 2 of the License, or
* (at your option) any later version.
*
* This program is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
* GNU General Public License for more details.
*
* You should have received a copy of the GNU General Public License along
* with this program; if not, write to the Free Software Foundation, Inc.,
* 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA.
*
*
* File: kcompat.h
*
* Purpose: define kernel compatibility header
*
* Author: Lyndon Chen
*
* Date: Apr 8, 2002
*
*/
#ifndef _KCOMPAT_H
#define _KCOMPAT_H
#include <linux/version.h>
#ifndef __init
#define __init
#endif
#ifndef __exit
#define __exit
#endif
#ifndef __devexit
#define __devexit
#endif
#ifndef __devinitdata
#define __devinitdata
#endif
#ifndef MODULE_LICENSE
#define MODULE_LICENSE(license)
#endif
#ifndef MOD_INC_USE_COUNT
#define MOD_INC_USE_COUNT do {} while (0)
#endif
#ifndef MOD_DEC_USE_COUNT
#define MOD_DEC_USE_COUNT do {} while (0)
#endif
#ifndef HAVE_NETDEV_PRIV
#define netdev_priv(dev) (dev->priv)
#endif
#ifndef IRQ_RETVAL
typedef void irqreturn_t;
#ifdef PRIVATE_OBJ
#define IRQ_RETVAL(x) (int)x
#else
#define IRQ_RETVAL(x)
#endif
#endif
#if LINUX_VERSION_CODE < KERNEL_VERSION(2,2,18)
typedef unsigned long dma_addr_t;
typedef struct wait_queue *wait_queue_head_t;
#define init_waitqueue_head(x) *(x)=NULL
#define set_current_state(status) { current->state = (status); mb(); }
#ifdef MODULE
#define module_init(fn) int init_module (void) { return fn(); }
#define module_exit(fn) void cleanup_module(void) { return fn(); }
#else /* MODULE */
#define module_init(fn) int e100_probe (void) { return fn(); }
#define module_exit(fn) /* NOTHING */
#endif /* MODULE */
#endif /* LINUX_VERSION_CODE < KERNEL_VERSION(2,2,18) */
#if LINUX_VERSION_CODE < KERNEL_VERSION(2,3,0)
#ifdef MODVERSIONS
#include <linux/modversions.h>
#endif
#include <linux/types.h>
#include <linux/pci.h>
#include <linux/slab.h>
#include <asm/io.h>
#define pci_resource_start(dev, bar) \
(((dev)->base_address[(bar)] & PCI_BASE_ADDRESS_SPACE_IO) ? \
((dev)->base_address[(bar)] & PCI_BASE_ADDRESS_IO_MASK) : \
((dev)->base_address[(bar)] & PCI_BASE_ADDRESS_MEM_MASK))
static inline int pci_enable_device(struct pci_dev *dev)
{
1112
return 0;
}
#define __constant_cpu_to_le32 cpu_to_le32
#define __constant_cpu_to_le16 cpu_to_le16
#define PCI_DMA_TODEVICE 1
#define PCI_DMA_FROMDEVICE 2
extern inline void *pci_alloc_consistent (struct pci_dev *dev,
size_t size,
dma_addr_t *dma_handle) {
void *vaddr = kmalloc(size, GFP_ATOMIC);
if(vaddr != NULL) {
*dma_handle = virt_to_bus(vaddr);
}
return vaddr;
}
#define pci_dma_sync_single(dev,dma_handle,size,direction) do{} while(0)
#define pci_dma_supported(dev, addr_mask) (1)
#define pci_free_consistent(dev, size, cpu_addr, dma_handle) kfree(cpu_addr)
#define pci_map_single(dev, addr, size, direction) virt_to_bus(addr)
#define pci_unmap_single(dev, dma_handle, size, direction) do{} while(0)
#define spin_lock_bh spin_lock_irq
#define spin_unlock_bh spin_unlock_irq
#define del_timer_sync(timer) del_timer(timer)
#define net_device device
#define netif_start_queue(dev) ( clear_bit(0, &(dev)->tbusy))
#define netif_stop_queue(dev) ( set_bit(0, &(dev)->tbusy))
#define netif_wake_queue(dev) { clear_bit(0, &(dev)->tbusy); \
mark_bh(NET_BH); }
#define netif_running(dev) ( test_bit(0, &(dev)->start))
#define netif_queue_stopped(dev) ( test_bit(0, &(dev)->tbusy))
#define netif_device_attach(dev) \
do{ (dev)->start = 1; netif_start_queue(dev); } while (0)
#define netif_device_detach(dev) \
do{ (dev)->start = 0; netif_stop_queue(dev); } while (0)
#define dev_kfree_skb_irq(skb) dev_kfree_skb(skb)
#define netif_carrier_on(dev) do {} while (0)
#define netif_carrier_off(dev) do {} while (0)
#define PCI_ANY_ID (~0U)
struct pci_device_id {
unsigned int vendor, device;
unsigned int subvendor, subdevice;
unsigned int class, classmask;
unsigned long driver_data;
};
#define MODULE_DEVICE_TABLE(bus, dev_table)
#define PCI_MAX_NUM_NICS 256
struct pci_driver {
char *name;
struct pci_device_id *id_table;
int (*probe)(struct pci_dev *dev, const struct pci_device_id *id);
void (*remove)(struct pci_dev *dev);
void (*suspend)(struct pci_dev *dev);
void (*resume)(struct pci_dev *dev);
struct pci_dev *pcimap[PCI_MAX_NUM_NICS];
};
static inline int pci_module_init(struct pci_driver *drv)
{
struct pci_dev *pdev;
struct pci_device_id *pcid;
uint16_t subvendor, subdevice;
int board_count = 0;
/* walk the global pci device list looking for matches */
for (pdev = pci_devices; pdev && (board_count < PCI_MAX_NUM_NICS); pdev = pdev->next) {
pcid = &drv->id_table[0];
pci_read_config_word(pdev, PCI_SUBSYSTEM_VENDOR_ID, &subvendor);
pci_read_config_word(pdev, PCI_SUBSYSTEM_ID, &subdevice);
while (pcid->vendor != 0) {
if (((pcid->vendor == pdev->vendor) || (pcid->vendor == PCI_ANY_ID)) &&
((pcid->device == pdev->device) || (pcid->device == PCI_ANY_ID)) &&
((pcid->subvendor == subvendor) || (pcid->subvendor == PCI_ANY_ID)) &&
((pcid->subdevice == subdevice) || (pcid->subdevice == PCI_ANY_ID))) {
if (drv->probe(pdev, pcid) == 0) {
drv->pcimap[board_count] = pdev;
board_count++;
}
break;
}
pcid++;
}
}
if (board_count < PCI_MAX_NUM_NICS) {
drv->pcimap[board_count] = NULL;
}
return (board_count > 0) ? 0 : -ENODEV;
}
static inline void pci_unregister_driver(struct pci_driver *drv)
{
int i;
for (i = 0; i < PCI_MAX_NUM_NICS; i++) {
if (!drv->pcimap[i])
break;
drv->remove(drv->pcimap[i]);
}
}
#define pci_set_drvdata(pcid, data)
#define pci_get_drvdata(pcid) ({ \
PSDevice pInfo; \
for (pInfo = pDevice_Infos; \
pInfo; pInfo = pInfo->next) { \
if (pInfo->pcid == pcid) \
break; \
} \
pInfo; })
#endif /* LINUX_VERSION_CODE < KERNEL_VERSION(2,3,0) */
#if LINUX_VERSION_CODE < KERNEL_VERSION(2,4,5)
#define skb_linearize(skb, gfp_mask) ({ \
struct sk_buff *tmp_skb; \
tmp_skb = skb; \
skb = skb_copy(tmp_skb, gfp_mask); \
dev_kfree_skb_irq(tmp_skb); })
#endif /* LINUX_VERSION_CODE < KERNEL_VERSION(2,4,5) */
#ifndef MODULE_LICESEN
#define MODULE_LICESEN(x)
#endif
#if LINUX_VERSION_CODE < KERNEL_VERSION(2,4,6)
#include <linux/types.h>
#include <linux/pci.h>
#if LINUX_VERSION_CODE < KERNEL_VERSION(2,4,2)
static inline int pci_set_power_state(struct pci_dev* pcid, int state) { return 0; }
#endif
#define PMCSR 0xe0
#define PM_ENABLE_BIT 0x0100
#define PM_CLEAR_BIT 0x8000
#define PM_STATE_MASK 0xFFFC
#define PM_STATE_D1 0x0001
static inline int
pci_enable_wake(struct pci_dev *dev, u32 state, int enable)
{
u16 p_state;
pci_read_config_word(dev, PMCSR, &p_state);
pci_write_config_word(dev, PMCSR, p_state | PM_CLEAR_BIT);
if (enable == 0) {
p_state &= ~PM_ENABLE_BIT;
} else {
p_state |= PM_ENABLE_BIT;
}
p_state &= PM_STATE_MASK;
p_state |= state;
pci_write_config_word(dev, PMCSR, p_state);
return 0;
}
#endif /* LINUX_VERSION_CODE < KERNEL_VERSION(2,4,6) */
#endif

View File

@ -0,0 +1,836 @@
/*
* Copyright (c) 1996, 2003 VIA Networking Technologies, Inc.
* All rights reserved.
*
* This program is free software; you can redistribute it and/or modify
* it under the terms of the GNU General Public License as published by
* the Free Software Foundation; either version 2 of the License, or
* (at your option) any later version.
*
* This program is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
* GNU General Public License for more details.
*
* You should have received a copy of the GNU General Public License along
* with this program; if not, write to the Free Software Foundation, Inc.,
* 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA.
*
*
* File: key.c
*
* Purpose: Implement functions for 802.11i Key management
*
* Author: Jerry Chen
*
* Date: May 29, 2003
*
* Functions:
* KeyvInitTable - Init Key management table
* KeybGetKey - Get Key from table
* KeybSetKey - Set Key to table
* KeybRemoveKey - Remove Key from table
* KeybGetTransmitKey - Get Transmit Key from table
*
* Revision History:
*
*/
#if !defined(__TMACRO_H__)
#include "tmacro.h"
#endif
#if !defined(__TBIT_H__)
#include "tbit.h"
#endif
#if !defined(__KEY_H__)
#include "key.h"
#endif
#if !defined(__UMEM_H__)
#include "umem.h"
#endif
#if !defined(__MAC_H__)
#include "mac.h"
#endif
/*--------------------- Static Definitions -------------------------*/
/*--------------------- Static Classes ----------------------------*/
/*--------------------- Static Variables --------------------------*/
static int msglevel =MSG_LEVEL_INFO;
//static int msglevel =MSG_LEVEL_DEBUG;
/*--------------------- Static Functions --------------------------*/
/*--------------------- Export Variables --------------------------*/
/*--------------------- Static Definitions -------------------------*/
/*--------------------- Static Classes ----------------------------*/
/*--------------------- Static Variables --------------------------*/
/*--------------------- Static Functions --------------------------*/
static VOID
s_vCheckKeyTableValid (PSKeyManagement pTable, DWORD_PTR dwIoBase)
{
int i;
for (i=0;i<MAX_KEY_TABLE;i++) {
if ((pTable->KeyTable[i].bInUse == TRUE) &&
(pTable->KeyTable[i].PairwiseKey.bKeyValid == FALSE) &&
(pTable->KeyTable[i].GroupKey[0].bKeyValid == FALSE) &&
(pTable->KeyTable[i].GroupKey[1].bKeyValid == FALSE) &&
(pTable->KeyTable[i].GroupKey[2].bKeyValid == FALSE) &&
(pTable->KeyTable[i].GroupKey[3].bKeyValid == FALSE)
) {
pTable->KeyTable[i].bInUse = FALSE;
pTable->KeyTable[i].wKeyCtl = 0;
pTable->KeyTable[i].bSoftWEP = FALSE;
MACvDisableKeyEntry(dwIoBase, i);
}
}
}
/*--------------------- Export Functions --------------------------*/
/*
* Description: Init Key management table
*
* Parameters:
* In:
* pTable - Pointer to Key table
* Out:
* none
*
* Return Value: none
*
*/
VOID KeyvInitTable (PSKeyManagement pTable, DWORD_PTR dwIoBase)
{
int i;
int jj;
for (i=0;i<MAX_KEY_TABLE;i++) {
pTable->KeyTable[i].bInUse = FALSE;
pTable->KeyTable[i].PairwiseKey.bKeyValid = FALSE;
pTable->KeyTable[i].PairwiseKey.pvKeyTable = (PVOID)&pTable->KeyTable[i];
for (jj=0; jj < MAX_GROUP_KEY; jj++) {
pTable->KeyTable[i].GroupKey[jj].bKeyValid = FALSE;
pTable->KeyTable[i].GroupKey[jj].pvKeyTable = (PVOID)&pTable->KeyTable[i];
}
pTable->KeyTable[i].wKeyCtl = 0;
pTable->KeyTable[i].dwGTKeyIndex = 0;
pTable->KeyTable[i].bSoftWEP = FALSE;
MACvDisableKeyEntry(dwIoBase, i);
}
}
/*
* Description: Get Key from table
*
* Parameters:
* In:
* pTable - Pointer to Key table
* pbyBSSID - BSSID of Key
* dwKeyIndex - Key Index (0xFFFFFFFF means pairwise key)
* Out:
* pKey - Key return
*
* Return Value: TRUE if found otherwise FALSE
*
*/
BOOL KeybGetKey (
IN PSKeyManagement pTable,
IN PBYTE pbyBSSID,
IN DWORD dwKeyIndex,
OUT PSKeyItem *pKey
)
{
int i;
DEVICE_PRT(MSG_LEVEL_DEBUG, KERN_INFO"KeybGetKey() \n");
*pKey = NULL;
for (i=0;i<MAX_KEY_TABLE;i++) {
if ((pTable->KeyTable[i].bInUse == TRUE) &&
IS_ETH_ADDRESS_EQUAL(pTable->KeyTable[i].abyBSSID,pbyBSSID)) {
if (dwKeyIndex == 0xFFFFFFFF) {
if (pTable->KeyTable[i].PairwiseKey.bKeyValid == TRUE) {
*pKey = &(pTable->KeyTable[i].PairwiseKey);
return (TRUE);
}
else {
return (FALSE);
}
} else if (dwKeyIndex < MAX_GROUP_KEY) {
if (pTable->KeyTable[i].GroupKey[dwKeyIndex].bKeyValid == TRUE) {
*pKey = &(pTable->KeyTable[i].GroupKey[dwKeyIndex]);
return (TRUE);
}
else {
return (FALSE);
}
}
else {
return (FALSE);
}
}
}
return (FALSE);
}
/*
* Description: Set Key to table
*
* Parameters:
* In:
* pTable - Pointer to Key table
* pbyBSSID - BSSID of Key
* dwKeyIndex - Key index (reference to NDIS DDK)
* uKeyLength - Key length
* KeyRSC - Key RSC
* pbyKey - Pointer to key
* Out:
* none
*
* Return Value: TRUE if success otherwise FALSE
*
*/
BOOL KeybSetKey (
PSKeyManagement pTable,
PBYTE pbyBSSID,
DWORD dwKeyIndex,
ULONG uKeyLength,
PQWORD pKeyRSC,
PBYTE pbyKey,
BYTE byKeyDecMode,
DWORD_PTR dwIoBase,
BYTE byLocalID
)
{
int i,j;
UINT ii;
PSKeyItem pKey;
UINT uKeyIdx;
DEVICE_PRT(MSG_LEVEL_DEBUG, KERN_INFO"Enter KeybSetKey: %lX\n", dwKeyIndex);
j = (MAX_KEY_TABLE-1);
for (i=0;i<(MAX_KEY_TABLE-1);i++) {
if ((pTable->KeyTable[i].bInUse == FALSE) &&
(j == (MAX_KEY_TABLE-1))) {
// found empty table
j = i;
}
if ((pTable->KeyTable[i].bInUse == TRUE) &&
IS_ETH_ADDRESS_EQUAL(pTable->KeyTable[i].abyBSSID,pbyBSSID)) {
// found table already exist
if ((dwKeyIndex & PAIRWISE_KEY) != 0) {
// Pairwise key
pKey = &(pTable->KeyTable[i].PairwiseKey);
pTable->KeyTable[i].wKeyCtl &= 0xFFF0; // clear pairwise key control filed
pTable->KeyTable[i].wKeyCtl |= byKeyDecMode;
uKeyIdx = 4; // use HW key entry 4 for pairwise key
} else {
// Group key
if ((dwKeyIndex & 0x000000FF) >= MAX_GROUP_KEY)
return (FALSE);
pKey = &(pTable->KeyTable[i].GroupKey[dwKeyIndex & 0x000000FF]);
if ((dwKeyIndex & TRANSMIT_KEY) != 0) {
// Group transmit key
pTable->KeyTable[i].dwGTKeyIndex = dwKeyIndex;
DEVICE_PRT(MSG_LEVEL_DEBUG, KERN_INFO"Group transmit key(R)[%lX]: %d\n", pTable->KeyTable[i].dwGTKeyIndex, i);
}
pTable->KeyTable[i].wKeyCtl &= 0xFF0F; // clear group key control filed
pTable->KeyTable[i].wKeyCtl |= (byKeyDecMode << 4);
pTable->KeyTable[i].wKeyCtl |= 0x0040; // use group key for group address
uKeyIdx = (dwKeyIndex & 0x000000FF);
}
pTable->KeyTable[i].wKeyCtl |= 0x8000; // enable on-fly
pKey->bKeyValid = TRUE;
pKey->uKeyLength = uKeyLength;
pKey->dwKeyIndex = dwKeyIndex;
pKey->byCipherSuite = byKeyDecMode;
MEMvCopy(pKey->abyKey, pbyKey, uKeyLength);
if (byKeyDecMode == KEY_CTL_WEP) {
if (uKeyLength == WLAN_WEP40_KEYLEN)
pKey->abyKey[15] &= 0x7F;
if (uKeyLength == WLAN_WEP104_KEYLEN)
pKey->abyKey[15] |= 0x80;
}
MACvSetKeyEntry(dwIoBase, pTable->KeyTable[i].wKeyCtl, i, uKeyIdx, pbyBSSID, (PDWORD)pKey->abyKey, byLocalID);
if ((dwKeyIndex & USE_KEYRSC) == 0) {
// RSC set by NIC
ZERO_MEMORY(&(pKey->KeyRSC), sizeof(QWORD));
}
else {
MEMvCopy(&(pKey->KeyRSC), pKeyRSC, sizeof(QWORD));
}
pKey->dwTSC47_16 = 0;
pKey->wTSC15_0 = 0;
DEVICE_PRT(MSG_LEVEL_DEBUG, KERN_INFO"KeybSetKey(R): \n");
DEVICE_PRT(MSG_LEVEL_DEBUG, KERN_INFO"pKey->bKeyValid: %d\n ", pKey->bKeyValid);
//DEVICE_PRT(MSG_LEVEL_DEBUG, KERN_INFO"pKey->uKeyLength: %d\n ", pKey->uKeyLength);
DEVICE_PRT(MSG_LEVEL_DEBUG, KERN_INFO"pKey->abyKey: ");
for (ii = 0; ii < pKey->uKeyLength; ii++) {
DEVICE_PRT(MSG_LEVEL_DEBUG, KERN_INFO "%02x ", pKey->abyKey[ii]);
}
DEVICE_PRT(MSG_LEVEL_DEBUG, KERN_INFO"\n");
DEVICE_PRT(MSG_LEVEL_DEBUG, KERN_INFO"pKey->dwTSC47_16: %lx\n ", pKey->dwTSC47_16);
DEVICE_PRT(MSG_LEVEL_DEBUG, KERN_INFO"pKey->wTSC15_0: %x\n ", pKey->wTSC15_0);
DEVICE_PRT(MSG_LEVEL_DEBUG, KERN_INFO"pKey->dwKeyIndex: %lx\n ", pKey->dwKeyIndex);
return (TRUE);
}
}
if (j < (MAX_KEY_TABLE-1)) {
MEMvCopy(pTable->KeyTable[j].abyBSSID,pbyBSSID,U_ETHER_ADDR_LEN);
pTable->KeyTable[j].bInUse = TRUE;
if ((dwKeyIndex & PAIRWISE_KEY) != 0) {
// Pairwise key
pKey = &(pTable->KeyTable[j].PairwiseKey);
pTable->KeyTable[j].wKeyCtl &= 0xFFF0; // clear pairwise key control filed
pTable->KeyTable[j].wKeyCtl |= byKeyDecMode;
uKeyIdx = 4; // use HW key entry 4 for pairwise key
} else {
// Group key
if ((dwKeyIndex & 0x000000FF) >= MAX_GROUP_KEY)
return (FALSE);
pKey = &(pTable->KeyTable[j].GroupKey[dwKeyIndex & 0x000000FF]);
if ((dwKeyIndex & TRANSMIT_KEY) != 0) {
// Group transmit key
pTable->KeyTable[j].dwGTKeyIndex = dwKeyIndex;
DEVICE_PRT(MSG_LEVEL_DEBUG, KERN_INFO"Group transmit key(N)[%lX]: %d\n", pTable->KeyTable[j].dwGTKeyIndex, j);
}
pTable->KeyTable[j].wKeyCtl &= 0xFF0F; // clear group key control filed
pTable->KeyTable[j].wKeyCtl |= (byKeyDecMode << 4);
pTable->KeyTable[j].wKeyCtl |= 0x0040; // use group key for group address
uKeyIdx = (dwKeyIndex & 0x000000FF);
}
pTable->KeyTable[j].wKeyCtl |= 0x8000; // enable on-fly
pKey->bKeyValid = TRUE;
pKey->uKeyLength = uKeyLength;
pKey->dwKeyIndex = dwKeyIndex;
pKey->byCipherSuite = byKeyDecMode;
MEMvCopy(pKey->abyKey, pbyKey, uKeyLength);
if (byKeyDecMode == KEY_CTL_WEP) {
if (uKeyLength == WLAN_WEP40_KEYLEN)
pKey->abyKey[15] &= 0x7F;
if (uKeyLength == WLAN_WEP104_KEYLEN)
pKey->abyKey[15] |= 0x80;
}
MACvSetKeyEntry(dwIoBase, pTable->KeyTable[j].wKeyCtl, j, uKeyIdx, pbyBSSID, (PDWORD)pKey->abyKey, byLocalID);
if ((dwKeyIndex & USE_KEYRSC) == 0) {
// RSC set by NIC
ZERO_MEMORY(&(pKey->KeyRSC), sizeof(QWORD));
}
else {
MEMvCopy(&(pKey->KeyRSC), pKeyRSC, sizeof(QWORD));
}
pKey->dwTSC47_16 = 0;
pKey->wTSC15_0 = 0;
DEVICE_PRT(MSG_LEVEL_DEBUG, KERN_INFO"KeybSetKey(N): \n");
DEVICE_PRT(MSG_LEVEL_DEBUG, KERN_INFO"pKey->bKeyValid: %d\n ", pKey->bKeyValid);
DEVICE_PRT(MSG_LEVEL_DEBUG, KERN_INFO"pKey->uKeyLength: %d\n ", (int)pKey->uKeyLength);
DEVICE_PRT(MSG_LEVEL_DEBUG, KERN_INFO"pKey->abyKey: ");
for (ii = 0; ii < pKey->uKeyLength; ii++) {
DEVICE_PRT(MSG_LEVEL_DEBUG, KERN_INFO "%02x ", pKey->abyKey[ii]);
}
DEVICE_PRT(MSG_LEVEL_DEBUG, KERN_INFO"\n");
DEVICE_PRT(MSG_LEVEL_DEBUG, KERN_INFO"pKey->dwTSC47_16: %lx\n ", pKey->dwTSC47_16);
DEVICE_PRT(MSG_LEVEL_DEBUG, KERN_INFO"pKey->wTSC15_0: %x\n ", pKey->wTSC15_0);
DEVICE_PRT(MSG_LEVEL_DEBUG, KERN_INFO"pKey->dwKeyIndex: %lx\n ", pKey->dwKeyIndex);
return (TRUE);
}
return (FALSE);
}
/*
* Description: Remove Key from table
*
* Parameters:
* In:
* pTable - Pointer to Key table
* pbyBSSID - BSSID of Key
* dwKeyIndex - Key Index (reference to NDIS DDK)
* Out:
* none
*
* Return Value: TRUE if success otherwise FALSE
*
*/
BOOL KeybRemoveKey (
PSKeyManagement pTable,
PBYTE pbyBSSID,
DWORD dwKeyIndex,
DWORD_PTR dwIoBase
)
{
int i;
if (IS_BROADCAST_ADDRESS(pbyBSSID)) {
// dealte all key
if ((dwKeyIndex & PAIRWISE_KEY) != 0) {
for (i=0;i<MAX_KEY_TABLE;i++) {
pTable->KeyTable[i].PairwiseKey.bKeyValid = FALSE;
}
s_vCheckKeyTableValid(pTable, dwIoBase);
return TRUE;
}
else if ((dwKeyIndex & 0x000000FF) < MAX_GROUP_KEY) {
for (i=0;i<MAX_KEY_TABLE;i++) {
pTable->KeyTable[i].GroupKey[dwKeyIndex & 0x000000FF].bKeyValid = FALSE;
if ((dwKeyIndex & 0x7FFFFFFF) == (pTable->KeyTable[i].dwGTKeyIndex & 0x7FFFFFFF)) {
// remove Group transmit key
pTable->KeyTable[i].dwGTKeyIndex = 0;
}
}
s_vCheckKeyTableValid(pTable, dwIoBase);
return TRUE;
}
else {
return FALSE;
}
}
for (i=0;i<MAX_KEY_TABLE;i++) {
if ((pTable->KeyTable[i].bInUse == TRUE) &&
IS_ETH_ADDRESS_EQUAL(pTable->KeyTable[i].abyBSSID,pbyBSSID)) {
if ((dwKeyIndex & PAIRWISE_KEY) != 0) {
pTable->KeyTable[i].PairwiseKey.bKeyValid = FALSE;
s_vCheckKeyTableValid(pTable, dwIoBase);
return (TRUE);
}
else if ((dwKeyIndex & 0x000000FF) < MAX_GROUP_KEY) {
pTable->KeyTable[i].GroupKey[dwKeyIndex & 0x000000FF].bKeyValid = FALSE;
if ((dwKeyIndex & 0x7FFFFFFF) == (pTable->KeyTable[i].dwGTKeyIndex & 0x7FFFFFFF)) {
// remove Group transmit key
pTable->KeyTable[i].dwGTKeyIndex = 0;
}
s_vCheckKeyTableValid(pTable, dwIoBase);
return (TRUE);
}
else {
return (FALSE);
}
}
}
return (FALSE);
}
/*
* Description: Remove Key from table
*
* Parameters:
* In:
* pTable - Pointer to Key table
* pbyBSSID - BSSID of Key
* Out:
* none
*
* Return Value: TRUE if success otherwise FALSE
*
*/
BOOL KeybRemoveAllKey (
PSKeyManagement pTable,
PBYTE pbyBSSID,
DWORD_PTR dwIoBase
)
{
int i,u;
for (i=0;i<MAX_KEY_TABLE;i++) {
if ((pTable->KeyTable[i].bInUse == TRUE) &&
IS_ETH_ADDRESS_EQUAL(pTable->KeyTable[i].abyBSSID,pbyBSSID)) {
pTable->KeyTable[i].PairwiseKey.bKeyValid = FALSE;
for(u=0;u<MAX_GROUP_KEY;u++) {
pTable->KeyTable[i].GroupKey[u].bKeyValid = FALSE;
}
pTable->KeyTable[i].dwGTKeyIndex = 0;
s_vCheckKeyTableValid(pTable, dwIoBase);
return (TRUE);
}
}
return (FALSE);
}
/*
* Description: Remove WEP Key from table
*
* Parameters:
* In:
* pTable - Pointer to Key table
* Out:
* none
*
* Return Value: TRUE if success otherwise FALSE
*
*/
VOID KeyvRemoveWEPKey (
PSKeyManagement pTable,
DWORD dwKeyIndex,
DWORD_PTR dwIoBase
)
{
if ((dwKeyIndex & 0x000000FF) < MAX_GROUP_KEY) {
if (pTable->KeyTable[MAX_KEY_TABLE-1].bInUse == TRUE) {
if (pTable->KeyTable[MAX_KEY_TABLE-1].GroupKey[dwKeyIndex & 0x000000FF].byCipherSuite == KEY_CTL_WEP) {
pTable->KeyTable[MAX_KEY_TABLE-1].GroupKey[dwKeyIndex & 0x000000FF].bKeyValid = FALSE;
if ((dwKeyIndex & 0x7FFFFFFF) == (pTable->KeyTable[MAX_KEY_TABLE-1].dwGTKeyIndex & 0x7FFFFFFF)) {
// remove Group transmit key
pTable->KeyTable[MAX_KEY_TABLE-1].dwGTKeyIndex = 0;
}
}
}
s_vCheckKeyTableValid(pTable, dwIoBase);
}
return;
}
VOID KeyvRemoveAllWEPKey (
PSKeyManagement pTable,
DWORD_PTR dwIoBase
)
{
int i;
for(i=0;i<MAX_GROUP_KEY;i++) {
KeyvRemoveWEPKey(pTable, i, dwIoBase);
}
}
/*
* Description: Get Transmit Key from table
*
* Parameters:
* In:
* pTable - Pointer to Key table
* pbyBSSID - BSSID of Key
* Out:
* pKey - Key return
*
* Return Value: TRUE if found otherwise FALSE
*
*/
BOOL KeybGetTransmitKey (
IN PSKeyManagement pTable,
IN PBYTE pbyBSSID,
IN DWORD dwKeyType,
OUT PSKeyItem *pKey
)
{
int i, ii;
*pKey = NULL;
for (i=0;i<MAX_KEY_TABLE;i++) {
if ((pTable->KeyTable[i].bInUse == TRUE) &&
IS_ETH_ADDRESS_EQUAL(pTable->KeyTable[i].abyBSSID,pbyBSSID)) {
if (dwKeyType == PAIRWISE_KEY) {
if (pTable->KeyTable[i].PairwiseKey.bKeyValid == TRUE) {
*pKey = &(pTable->KeyTable[i].PairwiseKey);
DEVICE_PRT(MSG_LEVEL_DEBUG, KERN_INFO"KeybGetTransmitKey:");
DEVICE_PRT(MSG_LEVEL_DEBUG, KERN_INFO"PAIRWISE_KEY: KeyTable.abyBSSID: ");
for (ii = 0; ii < 6; ii++) {
DEVICE_PRT(MSG_LEVEL_DEBUG, KERN_INFO"%x ", pTable->KeyTable[i].abyBSSID[ii]);
}
DEVICE_PRT(MSG_LEVEL_DEBUG, KERN_INFO"\n");
return (TRUE);
}
else {
DEVICE_PRT(MSG_LEVEL_DEBUG, KERN_INFO"PairwiseKey.bKeyValid == FALSE\n");
return (FALSE);
}
} // End of Type == PAIRWISE
else {
if (pTable->KeyTable[i].dwGTKeyIndex == 0) {
DEVICE_PRT(MSG_LEVEL_DEBUG, KERN_INFO"ERROR: dwGTKeyIndex == 0 !!!\n");
return FALSE;
}
if (pTable->KeyTable[i].GroupKey[(pTable->KeyTable[i].dwGTKeyIndex&0x000000FF)].bKeyValid == TRUE) {
*pKey = &(pTable->KeyTable[i].GroupKey[(pTable->KeyTable[i].dwGTKeyIndex&0x000000FF)]);
DEVICE_PRT(MSG_LEVEL_DEBUG, KERN_INFO"KeybGetTransmitKey:");
DEVICE_PRT(MSG_LEVEL_DEBUG, KERN_INFO"GROUP_KEY: KeyTable.abyBSSID\n");
for (ii = 0; ii < 6; ii++) {
DEVICE_PRT(MSG_LEVEL_DEBUG, KERN_INFO"%x ", pTable->KeyTable[i].abyBSSID[ii]);
}
DEVICE_PRT(MSG_LEVEL_DEBUG, KERN_INFO"\n");
DEVICE_PRT(MSG_LEVEL_DEBUG, KERN_INFO"dwGTKeyIndex: %lX\n", pTable->KeyTable[i].dwGTKeyIndex);
return (TRUE);
}
else {
DEVICE_PRT(MSG_LEVEL_DEBUG, KERN_INFO"GroupKey.bKeyValid == FALSE\n");
return (FALSE);
}
} // End of Type = GROUP
} // BSSID match
}
DEVICE_PRT(MSG_LEVEL_DEBUG, KERN_INFO"ERROR: NO Match BSSID !!! ");
for (ii = 0; ii < 6; ii++) {
DEVICE_PRT(MSG_LEVEL_DEBUG, KERN_INFO"%02x ", *(pbyBSSID+ii));
}
DEVICE_PRT(MSG_LEVEL_DEBUG, KERN_INFO"\n");
return (FALSE);
}
/*
* Description: Check Pairewise Key
*
* Parameters:
* In:
* pTable - Pointer to Key table
* Out:
* none
*
* Return Value: TRUE if found otherwise FALSE
*
*/
BOOL KeybCheckPairewiseKey (
IN PSKeyManagement pTable,
OUT PSKeyItem *pKey
)
{
int i;
*pKey = NULL;
for (i=0;i<MAX_KEY_TABLE;i++) {
if ((pTable->KeyTable[i].bInUse == TRUE) &&
(pTable->KeyTable[i].PairwiseKey.bKeyValid == TRUE)) {
*pKey = &(pTable->KeyTable[i].PairwiseKey);
return (TRUE);
}
}
return (FALSE);
}
/*
* Description: Set Key to table
*
* Parameters:
* In:
* pTable - Pointer to Key table
* dwKeyIndex - Key index (reference to NDIS DDK)
* uKeyLength - Key length
* KeyRSC - Key RSC
* pbyKey - Pointer to key
* Out:
* none
*
* Return Value: TRUE if success otherwise FALSE
*
*/
BOOL KeybSetDefaultKey (
PSKeyManagement pTable,
DWORD dwKeyIndex,
ULONG uKeyLength,
PQWORD pKeyRSC,
PBYTE pbyKey,
BYTE byKeyDecMode,
DWORD_PTR dwIoBase,
BYTE byLocalID
)
{
UINT ii;
PSKeyItem pKey;
UINT uKeyIdx;
DEVICE_PRT(MSG_LEVEL_DEBUG, KERN_INFO"Enter KeybSetDefaultKey: %1x, %d \n", (int)dwKeyIndex, (int)uKeyLength);
if ((dwKeyIndex & PAIRWISE_KEY) != 0) { // Pairwise key
return (FALSE);
} else if ((dwKeyIndex & 0x000000FF) >= MAX_GROUP_KEY) {
return (FALSE);
}
pTable->KeyTable[MAX_KEY_TABLE-1].bInUse = TRUE;
for(ii=0;ii<U_ETHER_ADDR_LEN;ii++)
pTable->KeyTable[MAX_KEY_TABLE-1].abyBSSID[ii] = 0xFF;
// Group key
pKey = &(pTable->KeyTable[MAX_KEY_TABLE-1].GroupKey[dwKeyIndex & 0x000000FF]);
if ((dwKeyIndex & TRANSMIT_KEY) != 0) {
// Group transmit key
pTable->KeyTable[MAX_KEY_TABLE-1].dwGTKeyIndex = dwKeyIndex;
DEVICE_PRT(MSG_LEVEL_DEBUG, KERN_INFO"Group transmit key(R)[%lX]: %d\n", pTable->KeyTable[MAX_KEY_TABLE-1].dwGTKeyIndex, MAX_KEY_TABLE-1);
}
pTable->KeyTable[MAX_KEY_TABLE-1].wKeyCtl &= 0x7F00; // clear all key control filed
pTable->KeyTable[MAX_KEY_TABLE-1].wKeyCtl |= (byKeyDecMode << 4);
pTable->KeyTable[MAX_KEY_TABLE-1].wKeyCtl |= (byKeyDecMode);
pTable->KeyTable[MAX_KEY_TABLE-1].wKeyCtl |= 0x0044; // use group key for all address
uKeyIdx = (dwKeyIndex & 0x000000FF);
if ((uKeyLength == WLAN_WEP232_KEYLEN) &&
(byKeyDecMode == KEY_CTL_WEP)) {
pTable->KeyTable[MAX_KEY_TABLE-1].wKeyCtl |= 0x4000; // disable on-fly disable address match
pTable->KeyTable[MAX_KEY_TABLE-1].bSoftWEP = TRUE;
} else {
if (pTable->KeyTable[MAX_KEY_TABLE-1].bSoftWEP == FALSE)
pTable->KeyTable[MAX_KEY_TABLE-1].wKeyCtl |= 0xC000; // enable on-fly disable address match
}
pKey->bKeyValid = TRUE;
pKey->uKeyLength = uKeyLength;
pKey->dwKeyIndex = dwKeyIndex;
pKey->byCipherSuite = byKeyDecMode;
MEMvCopy(pKey->abyKey, pbyKey, uKeyLength);
if (byKeyDecMode == KEY_CTL_WEP) {
if (uKeyLength == WLAN_WEP40_KEYLEN)
pKey->abyKey[15] &= 0x7F;
if (uKeyLength == WLAN_WEP104_KEYLEN)
pKey->abyKey[15] |= 0x80;
}
MACvSetKeyEntry(dwIoBase, pTable->KeyTable[MAX_KEY_TABLE-1].wKeyCtl, MAX_KEY_TABLE-1, uKeyIdx, pTable->KeyTable[MAX_KEY_TABLE-1].abyBSSID, (PDWORD)pKey->abyKey, byLocalID);
if ((dwKeyIndex & USE_KEYRSC) == 0) {
// RSC set by NIC
ZERO_MEMORY(&(pKey->KeyRSC), sizeof(QWORD));
} else {
MEMvCopy(&(pKey->KeyRSC), pKeyRSC, sizeof(QWORD));
}
pKey->dwTSC47_16 = 0;
pKey->wTSC15_0 = 0;
DEVICE_PRT(MSG_LEVEL_DEBUG, KERN_INFO"KeybSetKey(R): \n");
DEVICE_PRT(MSG_LEVEL_DEBUG, KERN_INFO"pKey->bKeyValid: %d\n", pKey->bKeyValid);
DEVICE_PRT(MSG_LEVEL_DEBUG, KERN_INFO"pKey->uKeyLength: %d\n", (int)pKey->uKeyLength);
DEVICE_PRT(MSG_LEVEL_DEBUG, KERN_INFO"pKey->abyKey: \n");
for (ii = 0; ii < pKey->uKeyLength; ii++) {
DEVICE_PRT(MSG_LEVEL_DEBUG, KERN_INFO"%x", pKey->abyKey[ii]);
}
DEVICE_PRT(MSG_LEVEL_DEBUG, KERN_INFO"\n");
DEVICE_PRT(MSG_LEVEL_DEBUG, KERN_INFO"pKey->dwTSC47_16: %lx\n", pKey->dwTSC47_16);
DEVICE_PRT(MSG_LEVEL_DEBUG, KERN_INFO"pKey->wTSC15_0: %x\n", pKey->wTSC15_0);
DEVICE_PRT(MSG_LEVEL_DEBUG, KERN_INFO"pKey->dwKeyIndex: %lx\n", pKey->dwKeyIndex);
return (TRUE);
}
/*
* Description: Set Key to table
*
* Parameters:
* In:
* pTable - Pointer to Key table
* dwKeyIndex - Key index (reference to NDIS DDK)
* uKeyLength - Key length
* KeyRSC - Key RSC
* pbyKey - Pointer to key
* Out:
* none
*
* Return Value: TRUE if success otherwise FALSE
*
*/
BOOL KeybSetAllGroupKey (
PSKeyManagement pTable,
DWORD dwKeyIndex,
ULONG uKeyLength,
PQWORD pKeyRSC,
PBYTE pbyKey,
BYTE byKeyDecMode,
DWORD_PTR dwIoBase,
BYTE byLocalID
)
{
int i;
UINT ii;
PSKeyItem pKey;
UINT uKeyIdx;
DEVICE_PRT(MSG_LEVEL_DEBUG, KERN_INFO"Enter KeybSetAllGroupKey: %lX\n", dwKeyIndex);
if ((dwKeyIndex & PAIRWISE_KEY) != 0) { // Pairwise key
return (FALSE);
} else if ((dwKeyIndex & 0x000000FF) >= MAX_GROUP_KEY) {
return (FALSE);
}
for (i=0; i < MAX_KEY_TABLE-1; i++) {
if (pTable->KeyTable[i].bInUse == TRUE) {
// found table already exist
// Group key
pKey = &(pTable->KeyTable[i].GroupKey[dwKeyIndex & 0x000000FF]);
if ((dwKeyIndex & TRANSMIT_KEY) != 0) {
// Group transmit key
pTable->KeyTable[i].dwGTKeyIndex = dwKeyIndex;
DEVICE_PRT(MSG_LEVEL_DEBUG, KERN_INFO"Group transmit key(R)[%lX]: %d\n", pTable->KeyTable[i].dwGTKeyIndex, i);
}
pTable->KeyTable[i].wKeyCtl &= 0xFF0F; // clear group key control filed
pTable->KeyTable[i].wKeyCtl |= (byKeyDecMode << 4);
pTable->KeyTable[i].wKeyCtl |= 0x0040; // use group key for group address
uKeyIdx = (dwKeyIndex & 0x000000FF);
pTable->KeyTable[i].wKeyCtl |= 0x8000; // enable on-fly
pKey->bKeyValid = TRUE;
pKey->uKeyLength = uKeyLength;
pKey->dwKeyIndex = dwKeyIndex;
pKey->byCipherSuite = byKeyDecMode;
MEMvCopy(pKey->abyKey, pbyKey, uKeyLength);
if (byKeyDecMode == KEY_CTL_WEP) {
if (uKeyLength == WLAN_WEP40_KEYLEN)
pKey->abyKey[15] &= 0x7F;
if (uKeyLength == WLAN_WEP104_KEYLEN)
pKey->abyKey[15] |= 0x80;
}
MACvSetKeyEntry(dwIoBase, pTable->KeyTable[i].wKeyCtl, i, uKeyIdx, pTable->KeyTable[i].abyBSSID, (PDWORD)pKey->abyKey, byLocalID);
if ((dwKeyIndex & USE_KEYRSC) == 0) {
// RSC set by NIC
ZERO_MEMORY(&(pKey->KeyRSC), sizeof(QWORD));
}
else {
MEMvCopy(&(pKey->KeyRSC), pKeyRSC, sizeof(QWORD));
}
pKey->dwTSC47_16 = 0;
pKey->wTSC15_0 = 0;
DEVICE_PRT(MSG_LEVEL_DEBUG, KERN_INFO"KeybSetKey(R): \n");
DEVICE_PRT(MSG_LEVEL_DEBUG, KERN_INFO"pKey->bKeyValid: %d\n ", pKey->bKeyValid);
DEVICE_PRT(MSG_LEVEL_DEBUG, KERN_INFO"pKey->uKeyLength: %d\n ", (int)pKey->uKeyLength);
DEVICE_PRT(MSG_LEVEL_DEBUG, KERN_INFO"pKey->abyKey: ");
for (ii = 0; ii < pKey->uKeyLength; ii++) {
DEVICE_PRT(MSG_LEVEL_DEBUG, KERN_INFO"%02x ", pKey->abyKey[ii]);
}
DEVICE_PRT(MSG_LEVEL_DEBUG, KERN_INFO"\n");
//DBG_PRN_GRP12(("pKey->dwTSC47_16: %lX\n ", pKey->dwTSC47_16));
//DBG_PRN_GRP12(("pKey->wTSC15_0: %X\n ", pKey->wTSC15_0));
//DBG_PRN_GRP12(("pKey->dwKeyIndex: %lX\n ", pKey->dwKeyIndex));
} // (pTable->KeyTable[i].bInUse == TRUE)
}
return (TRUE);
}

View File

@ -0,0 +1,202 @@
/*
* Copyright (c) 1996, 2003 VIA Networking Technologies, Inc.
* All rights reserved.
*
* This program is free software; you can redistribute it and/or modify
* it under the terms of the GNU General Public License as published by
* the Free Software Foundation; either version 2 of the License, or
* (at your option) any later version.
*
* This program is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
* GNU General Public License for more details.
*
* You should have received a copy of the GNU General Public License along
* with this program; if not, write to the Free Software Foundation, Inc.,
* 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA.
*
*
* File: key.h
*
* Purpose: Implement functions for 802.11i Key management
*
* Author: Jerry Chen
*
* Date: May 29, 2003
*
*/
#ifndef __KEY_H__
#define __KEY_H__
#if !defined(__TTYPE_H__)
#include "ttype.h"
#endif
#if !defined(__TETHER_H__)
#include "tether.h"
#endif
#if !defined(__80211MGR_H__)
#include "80211mgr.h"
#endif
/*--------------------- Export Definitions -------------------------*/
#define MAX_GROUP_KEY 4
#define MAX_KEY_TABLE 11
#define MAX_KEY_LEN 32
#define AES_KEY_LEN 16
#define AUTHENTICATOR_KEY 0x10000000
#define USE_KEYRSC 0x20000000
#define PAIRWISE_KEY 0x40000000
#define TRANSMIT_KEY 0x80000000
#define GROUP_KEY 0x00000000
#define KEY_CTL_WEP 0x00
#define KEY_CTL_NONE 0x01
#define KEY_CTL_TKIP 0x02
#define KEY_CTL_CCMP 0x03
#define KEY_CTL_INVALID 0xFF
typedef struct tagSKeyItem
{
BOOL bKeyValid;
ULONG uKeyLength;
BYTE abyKey[MAX_KEY_LEN];
QWORD KeyRSC;
DWORD dwTSC47_16;
WORD wTSC15_0;
BYTE byCipherSuite;
BYTE byReserved0;
DWORD dwKeyIndex;
PVOID pvKeyTable;
} SKeyItem, DEF* PSKeyItem; //64
typedef struct tagSKeyTable
{
BYTE abyBSSID[U_ETHER_ADDR_LEN]; //6
BYTE byReserved0[2]; //8
SKeyItem PairwiseKey;
SKeyItem GroupKey[MAX_GROUP_KEY]; //64*5 = 320, 320+8=328
DWORD dwGTKeyIndex; // GroupTransmitKey Index
BOOL bInUse;
//2006-1116-01,<Modify> by NomadZhao
//WORD wKeyCtl;
//BOOL bSoftWEP;
BOOL bSoftWEP;
WORD wKeyCtl; // for address of wKeyCtl at align 4
BYTE byReserved1[6];
} SKeyTable, DEF* PSKeyTable; //348
typedef struct tagSKeyManagement
{
SKeyTable KeyTable[MAX_KEY_TABLE];
} SKeyManagement, DEF* PSKeyManagement;
/*--------------------- Export Types ------------------------------*/
/*--------------------- Export Macros ------------------------------*/
/*--------------------- Export Classes ----------------------------*/
/*--------------------- Export Variables --------------------------*/
/*--------------------- Export Functions --------------------------*/
#ifdef __cplusplus
extern "C" { /* Assume C declarations for C++ */
#endif /* __cplusplus */
VOID KeyvInitTable(PSKeyManagement pTable, DWORD_PTR dwIoBase);
BOOL KeybGetKey(
IN PSKeyManagement pTable,
IN PBYTE pbyBSSID,
IN DWORD dwKeyIndex,
OUT PSKeyItem *pKey
);
BOOL KeybSetKey(
PSKeyManagement pTable,
PBYTE pbyBSSID,
DWORD dwKeyIndex,
ULONG uKeyLength,
PQWORD pKeyRSC,
PBYTE pbyKey,
BYTE byKeyDecMode,
DWORD_PTR dwIoBase,
BYTE byLocalID
);
BOOL KeybSetDefaultKey(
PSKeyManagement pTable,
DWORD dwKeyIndex,
ULONG uKeyLength,
PQWORD pKeyRSC,
PBYTE pbyKey,
BYTE byKeyDecMode,
DWORD_PTR dwIoBase,
BYTE byLocalID
);
BOOL KeybRemoveKey(
PSKeyManagement pTable,
PBYTE pbyBSSID,
DWORD dwKeyIndex,
DWORD_PTR dwIoBase
);
BOOL KeybGetTransmitKey(
IN PSKeyManagement pTable,
IN PBYTE pbyBSSID,
IN DWORD dwKeyType,
OUT PSKeyItem *pKey
);
BOOL KeybCheckPairewiseKey(
IN PSKeyManagement pTable,
OUT PSKeyItem *pKey
);
BOOL KeybRemoveAllKey(
PSKeyManagement pTable,
PBYTE pbyBSSID,
DWORD_PTR dwIoBase
);
VOID KeyvRemoveWEPKey(
PSKeyManagement pTable,
DWORD dwKeyIndex,
DWORD_PTR dwIoBase
);
VOID KeyvRemoveAllWEPKey(
PSKeyManagement pTable,
DWORD_PTR dwIoBase
);
BOOL KeybSetAllGroupKey (
PSKeyManagement pTable,
DWORD dwKeyIndex,
ULONG uKeyLength,
PQWORD pKeyRSC,
PBYTE pbyKey,
BYTE byKeyDecMode,
DWORD_PTR dwIoBase,
BYTE byLocalID
);
#ifdef __cplusplus
} /* End of extern "C" { */
#endif /* __cplusplus */
#endif // __KEY_H__

File diff suppressed because it is too large Load Diff

File diff suppressed because it is too large Load Diff

View File

@ -0,0 +1,616 @@
/*
* Copyright (c) 1996, 2003 VIA Networking Technologies, Inc.
* All rights reserved.
*
* This program is free software; you can redistribute it and/or modify
* it under the terms of the GNU General Public License as published by
* the Free Software Foundation; either version 2 of the License, or
* (at your option) any later version.
*
* This program is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
* GNU General Public License for more details.
*
* You should have received a copy of the GNU General Public License along
* with this program; if not, write to the Free Software Foundation, Inc.,
* 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA.
*
* File: mib.c
*
* Purpose: Implement MIB Data Structure
*
* Author: Tevin Chen
*
* Date: May 21, 1996
*
* Functions:
* STAvClearAllCounter - Clear All MIB Counter
* STAvUpdateIstStatCounter - Update ISR statistic counter
* STAvUpdateRDStatCounter - Update Rx statistic counter
* STAvUpdateRDStatCounterEx - Update Rx statistic counter and copy rcv data
* STAvUpdateTDStatCounter - Update Tx statistic counter
* STAvUpdateTDStatCounterEx - Update Tx statistic counter and copy tx data
* STAvUpdate802_11Counter - Update 802.11 mib counter
*
* Revision History:
*
*/
#if !defined(__UPC_H__)
#include "upc.h"
#endif
#if !defined(__MAC_H__)
#include "mac.h"
#endif
#if !defined(__TBIT_H__)
#include "tbit.h"
#endif
#if !defined(__TETHER_H__)
#include "tether.h"
#endif
#if !defined(__MIB_H__)
#include "mib.h"
#endif
#if !defined(__WCTL_H__)
#include "wctl.h"
#endif
#if !defined(__UMEM_H__)
#include "umem.h"
#endif
#if !defined(__BASEBAND_H__)
#include "baseband.h"
#endif
/*--------------------- Static Definitions -------------------------*/
static int msglevel =MSG_LEVEL_INFO;
/*--------------------- Static Classes ----------------------------*/
/*--------------------- Static Variables --------------------------*/
/*--------------------- Static Functions --------------------------*/
/*--------------------- Export Variables --------------------------*/
/*--------------------- Export Functions --------------------------*/
/*
* Description: Clear All Statistic Counter
*
* Parameters:
* In:
* pStatistic - Pointer to Statistic Counter Data Structure
* Out:
* none
*
* Return Value: none
*
*/
void STAvClearAllCounter (PSStatCounter pStatistic)
{
// set memory to zero
ZERO_MEMORY(pStatistic, sizeof(SStatCounter));
}
/*
* Description: Update Isr Statistic Counter
*
* Parameters:
* In:
* pStatistic - Pointer to Statistic Counter Data Structure
* wisr - Interrupt status
* Out:
* none
*
* Return Value: none
*
*/
void STAvUpdateIsrStatCounter (PSStatCounter pStatistic, DWORD dwIsr)
{
/**********************/
/* ABNORMAL interrupt */
/**********************/
// not any IMR bit invoke irq
if (dwIsr == 0) {
pStatistic->ISRStat.dwIsrUnknown++;
return;
}
//Added by Kyle
if (BITbIsBitOn(dwIsr, ISR_TXDMA0)) // ISR, bit0
pStatistic->ISRStat.dwIsrTx0OK++; // TXDMA0 successful
if (BITbIsBitOn(dwIsr, ISR_AC0DMA)) // ISR, bit1
pStatistic->ISRStat.dwIsrAC0TxOK++; // AC0DMA successful
if (BITbIsBitOn(dwIsr, ISR_BNTX)) // ISR, bit2
pStatistic->ISRStat.dwIsrBeaconTxOK++; // BeaconTx successful
if (BITbIsBitOn(dwIsr, ISR_RXDMA0)) // ISR, bit3
pStatistic->ISRStat.dwIsrRx0OK++; // Rx0 successful
if (BITbIsBitOn(dwIsr, ISR_TBTT)) // ISR, bit4
pStatistic->ISRStat.dwIsrTBTTInt++; // TBTT successful
if (BITbIsBitOn(dwIsr, ISR_SOFTTIMER)) // ISR, bit6
pStatistic->ISRStat.dwIsrSTIMERInt++;
if (BITbIsBitOn(dwIsr, ISR_WATCHDOG)) // ISR, bit7
pStatistic->ISRStat.dwIsrWatchDog++;
if (BITbIsBitOn(dwIsr, ISR_FETALERR)) // ISR, bit8
pStatistic->ISRStat.dwIsrUnrecoverableError++;
if (BITbIsBitOn(dwIsr, ISR_SOFTINT)) // ISR, bit9
pStatistic->ISRStat.dwIsrSoftInterrupt++; // software interrupt
if (BITbIsBitOn(dwIsr, ISR_MIBNEARFULL)) // ISR, bit10
pStatistic->ISRStat.dwIsrMIBNearfull++;
if (BITbIsBitOn(dwIsr, ISR_RXNOBUF)) // ISR, bit11
pStatistic->ISRStat.dwIsrRxNoBuf++; // Rx No Buff
if (BITbIsBitOn(dwIsr, ISR_RXDMA1)) // ISR, bit12
pStatistic->ISRStat.dwIsrRx1OK++; // Rx1 successful
// if (BITbIsBitOn(dwIsr, ISR_ATIMTX)) // ISR, bit13
// pStatistic->ISRStat.dwIsrATIMTxOK++; // ATIMTX successful
// if (BITbIsBitOn(dwIsr, ISR_SYNCTX)) // ISR, bit14
// pStatistic->ISRStat.dwIsrSYNCTxOK++; // SYNCTX successful
// if (BITbIsBitOn(dwIsr, ISR_CFPEND)) // ISR, bit18
// pStatistic->ISRStat.dwIsrCFPEnd++;
// if (BITbIsBitOn(dwIsr, ISR_ATIMEND)) // ISR, bit19
// pStatistic->ISRStat.dwIsrATIMEnd++;
// if (BITbIsBitOn(dwIsr, ISR_SYNCFLUSHOK)) // ISR, bit20
// pStatistic->ISRStat.dwIsrSYNCFlushOK++;
if (BITbIsBitOn(dwIsr, ISR_SOFTTIMER1)) // ISR, bit21
pStatistic->ISRStat.dwIsrSTIMER1Int++;
}
/*
* Description: Update Rx Statistic Counter
*
* Parameters:
* In:
* pStatistic - Pointer to Statistic Counter Data Structure
* byRSR - Rx Status
* byNewRSR - Rx Status
* pbyBuffer - Rx Buffer
* cbFrameLength - Rx Length
* Out:
* none
*
* Return Value: none
*
*/
void STAvUpdateRDStatCounter (PSStatCounter pStatistic,
BYTE byRSR, BYTE byNewRSR, BYTE byRxRate,
PBYTE pbyBuffer, UINT cbFrameLength)
{
//need change
PS802_11Header pHeader = (PS802_11Header)pbyBuffer;
if (BITbIsBitOn(byRSR, RSR_ADDROK))
pStatistic->dwRsrADDROk++;
if (BITbIsBitOn(byRSR, RSR_CRCOK)) {
pStatistic->dwRsrCRCOk++;
pStatistic->ullRsrOK++;
if (cbFrameLength >= U_ETHER_ADDR_LEN) {
// update counters in case that successful transmit
if (BITbIsBitOn(byRSR, RSR_ADDRBROAD)) {
pStatistic->ullRxBroadcastFrames++;
pStatistic->ullRxBroadcastBytes += (ULONGLONG)cbFrameLength;
}
else if (BITbIsBitOn(byRSR, RSR_ADDRMULTI)) {
pStatistic->ullRxMulticastFrames++;
pStatistic->ullRxMulticastBytes += (ULONGLONG)cbFrameLength;
}
else {
pStatistic->ullRxDirectedFrames++;
pStatistic->ullRxDirectedBytes += (ULONGLONG)cbFrameLength;
}
}
}
if(byRxRate==22) {
pStatistic->CustomStat.ullRsr11M++;
if(BITbIsBitOn(byRSR, RSR_CRCOK)) {
pStatistic->CustomStat.ullRsr11MCRCOk++;
}
DEVICE_PRT(MSG_LEVEL_DEBUG, KERN_INFO"11M: ALL[%d], OK[%d]:[%02x]\n", (INT)pStatistic->CustomStat.ullRsr11M, (INT)pStatistic->CustomStat.ullRsr11MCRCOk, byRSR);
}
else if(byRxRate==11) {
pStatistic->CustomStat.ullRsr5M++;
if(BITbIsBitOn(byRSR, RSR_CRCOK)) {
pStatistic->CustomStat.ullRsr5MCRCOk++;
}
DEVICE_PRT(MSG_LEVEL_DEBUG, KERN_INFO" 5M: ALL[%d], OK[%d]:[%02x]\n", (INT)pStatistic->CustomStat.ullRsr5M, (INT)pStatistic->CustomStat.ullRsr5MCRCOk, byRSR);
}
else if(byRxRate==4) {
pStatistic->CustomStat.ullRsr2M++;
if(BITbIsBitOn(byRSR, RSR_CRCOK)) {
pStatistic->CustomStat.ullRsr2MCRCOk++;
}
DEVICE_PRT(MSG_LEVEL_DEBUG, KERN_INFO" 2M: ALL[%d], OK[%d]:[%02x]\n", (INT)pStatistic->CustomStat.ullRsr2M, (INT)pStatistic->CustomStat.ullRsr2MCRCOk, byRSR);
}
else if(byRxRate==2){
pStatistic->CustomStat.ullRsr1M++;
if(BITbIsBitOn(byRSR, RSR_CRCOK)) {
pStatistic->CustomStat.ullRsr1MCRCOk++;
}
DEVICE_PRT(MSG_LEVEL_DEBUG, KERN_INFO" 1M: ALL[%d], OK[%d]:[%02x]\n", (INT)pStatistic->CustomStat.ullRsr1M, (INT)pStatistic->CustomStat.ullRsr1MCRCOk, byRSR);
}
else if(byRxRate==12){
pStatistic->CustomStat.ullRsr6M++;
if(BITbIsBitOn(byRSR, RSR_CRCOK)) {
pStatistic->CustomStat.ullRsr6MCRCOk++;
}
DEVICE_PRT(MSG_LEVEL_DEBUG, KERN_INFO" 6M: ALL[%d], OK[%d]\n", (INT)pStatistic->CustomStat.ullRsr6M, (INT)pStatistic->CustomStat.ullRsr6MCRCOk);
}
else if(byRxRate==18){
pStatistic->CustomStat.ullRsr9M++;
if(BITbIsBitOn(byRSR, RSR_CRCOK)) {
pStatistic->CustomStat.ullRsr9MCRCOk++;
}
DEVICE_PRT(MSG_LEVEL_DEBUG, KERN_INFO" 9M: ALL[%d], OK[%d]\n", (INT)pStatistic->CustomStat.ullRsr9M, (INT)pStatistic->CustomStat.ullRsr9MCRCOk);
}
else if(byRxRate==24){
pStatistic->CustomStat.ullRsr12M++;
if(BITbIsBitOn(byRSR, RSR_CRCOK)) {
pStatistic->CustomStat.ullRsr12MCRCOk++;
}
DEVICE_PRT(MSG_LEVEL_DEBUG, KERN_INFO"12M: ALL[%d], OK[%d]\n", (INT)pStatistic->CustomStat.ullRsr12M, (INT)pStatistic->CustomStat.ullRsr12MCRCOk);
}
else if(byRxRate==36){
pStatistic->CustomStat.ullRsr18M++;
if(BITbIsBitOn(byRSR, RSR_CRCOK)) {
pStatistic->CustomStat.ullRsr18MCRCOk++;
}
DEVICE_PRT(MSG_LEVEL_DEBUG, KERN_INFO"18M: ALL[%d], OK[%d]\n", (INT)pStatistic->CustomStat.ullRsr18M, (INT)pStatistic->CustomStat.ullRsr18MCRCOk);
}
else if(byRxRate==48){
pStatistic->CustomStat.ullRsr24M++;
if(BITbIsBitOn(byRSR, RSR_CRCOK)) {
pStatistic->CustomStat.ullRsr24MCRCOk++;
}
DEVICE_PRT(MSG_LEVEL_DEBUG, KERN_INFO"24M: ALL[%d], OK[%d]\n", (INT)pStatistic->CustomStat.ullRsr24M, (INT)pStatistic->CustomStat.ullRsr24MCRCOk);
}
else if(byRxRate==72){
pStatistic->CustomStat.ullRsr36M++;
if(BITbIsBitOn(byRSR, RSR_CRCOK)) {
pStatistic->CustomStat.ullRsr36MCRCOk++;
}
DEVICE_PRT(MSG_LEVEL_DEBUG, KERN_INFO"36M: ALL[%d], OK[%d]\n", (INT)pStatistic->CustomStat.ullRsr36M, (INT)pStatistic->CustomStat.ullRsr36MCRCOk);
}
else if(byRxRate==96){
pStatistic->CustomStat.ullRsr48M++;
if(BITbIsBitOn(byRSR, RSR_CRCOK)) {
pStatistic->CustomStat.ullRsr48MCRCOk++;
}
DEVICE_PRT(MSG_LEVEL_DEBUG, KERN_INFO"48M: ALL[%d], OK[%d]\n", (INT)pStatistic->CustomStat.ullRsr48M, (INT)pStatistic->CustomStat.ullRsr48MCRCOk);
}
else if(byRxRate==108){
pStatistic->CustomStat.ullRsr54M++;
if(BITbIsBitOn(byRSR, RSR_CRCOK)) {
pStatistic->CustomStat.ullRsr54MCRCOk++;
}
DEVICE_PRT(MSG_LEVEL_DEBUG, KERN_INFO"54M: ALL[%d], OK[%d]\n", (INT)pStatistic->CustomStat.ullRsr54M, (INT)pStatistic->CustomStat.ullRsr54MCRCOk);
}
else {
DEVICE_PRT(MSG_LEVEL_DEBUG, KERN_INFO"Unknown: Total[%d], CRCOK[%d]\n", (INT)pStatistic->dwRsrRxPacket+1, (INT)pStatistic->dwRsrCRCOk);
}
if (BITbIsBitOn(byRSR, RSR_BSSIDOK))
pStatistic->dwRsrBSSIDOk++;
if (BITbIsBitOn(byRSR, RSR_BCNSSIDOK))
pStatistic->dwRsrBCNSSIDOk++;
if (BITbIsBitOn(byRSR, RSR_IVLDLEN)) //invalid len (> 2312 byte)
pStatistic->dwRsrLENErr++;
if (BITbIsBitOn(byRSR, RSR_IVLDTYP)) //invalid packet type
pStatistic->dwRsrTYPErr++;
if (BITbIsBitOn(byRSR, (RSR_IVLDTYP | RSR_IVLDLEN)))
pStatistic->dwRsrErr++;
if (BITbIsBitOn(byNewRSR, NEWRSR_DECRYPTOK))
pStatistic->dwNewRsrDECRYPTOK++;
if (BITbIsBitOn(byNewRSR, NEWRSR_CFPIND))
pStatistic->dwNewRsrCFP++;
if (BITbIsBitOn(byNewRSR, NEWRSR_HWUTSF))
pStatistic->dwNewRsrUTSF++;
if (BITbIsBitOn(byNewRSR, NEWRSR_BCNHITAID))
pStatistic->dwNewRsrHITAID++;
if (BITbIsBitOn(byNewRSR, NEWRSR_BCNHITAID0))
pStatistic->dwNewRsrHITAID0++;
// increase rx packet count
pStatistic->dwRsrRxPacket++;
pStatistic->dwRsrRxOctet += cbFrameLength;
if (IS_TYPE_DATA(pbyBuffer)) {
pStatistic->dwRsrRxData++;
} else if (IS_TYPE_MGMT(pbyBuffer)){
pStatistic->dwRsrRxManage++;
} else if (IS_TYPE_CONTROL(pbyBuffer)){
pStatistic->dwRsrRxControl++;
}
if (BITbIsBitOn(byRSR, RSR_ADDRBROAD))
pStatistic->dwRsrBroadcast++;
else if (BITbIsBitOn(byRSR, RSR_ADDRMULTI))
pStatistic->dwRsrMulticast++;
else
pStatistic->dwRsrDirected++;
if (WLAN_GET_FC_MOREFRAG(pHeader->wFrameCtl))
pStatistic->dwRsrRxFragment++;
if (cbFrameLength < MIN_PACKET_LEN + 4) {
pStatistic->dwRsrRunt++;
}
else if (cbFrameLength == MIN_PACKET_LEN + 4) {
pStatistic->dwRsrRxFrmLen64++;
}
else if ((65 <= cbFrameLength) && (cbFrameLength <= 127)) {
pStatistic->dwRsrRxFrmLen65_127++;
}
else if ((128 <= cbFrameLength) && (cbFrameLength <= 255)) {
pStatistic->dwRsrRxFrmLen128_255++;
}
else if ((256 <= cbFrameLength) && (cbFrameLength <= 511)) {
pStatistic->dwRsrRxFrmLen256_511++;
}
else if ((512 <= cbFrameLength) && (cbFrameLength <= 1023)) {
pStatistic->dwRsrRxFrmLen512_1023++;
}
else if ((1024 <= cbFrameLength) && (cbFrameLength <= MAX_PACKET_LEN + 4)) {
pStatistic->dwRsrRxFrmLen1024_1518++;
} else if (cbFrameLength > MAX_PACKET_LEN + 4) {
pStatistic->dwRsrLong++;
}
}
/*
* Description: Update Rx Statistic Counter and copy Rx buffer
*
* Parameters:
* In:
* pStatistic - Pointer to Statistic Counter Data Structure
* byRSR - Rx Status
* byNewRSR - Rx Status
* pbyBuffer - Rx Buffer
* cbFrameLength - Rx Length
* Out:
* none
*
* Return Value: none
*
*/
void
STAvUpdateRDStatCounterEx (
PSStatCounter pStatistic,
BYTE byRSR,
BYTE byNewRSR,
BYTE byRxRate,
PBYTE pbyBuffer,
UINT cbFrameLength
)
{
STAvUpdateRDStatCounter(
pStatistic,
byRSR,
byNewRSR,
byRxRate,
pbyBuffer,
cbFrameLength
);
// rx length
pStatistic->dwCntRxFrmLength = cbFrameLength;
// rx pattern, we just see 10 bytes for sample
MEMvCopy(pStatistic->abyCntRxPattern, (PBYTE)pbyBuffer, 10);
}
/*
* Description: Update Tx Statistic Counter
*
* Parameters:
* In:
* pStatistic - Pointer to Statistic Counter Data Structure
* byTSR0 - Tx Status
* byTSR1 - Tx Status
* pbyBuffer - Tx Buffer
* cbFrameLength - Tx Length
* uIdx - Index of Tx DMA
* Out:
* none
*
* Return Value: none
*
*/
void
STAvUpdateTDStatCounter (
PSStatCounter pStatistic,
BYTE byTSR0,
BYTE byTSR1,
PBYTE pbyBuffer,
UINT cbFrameLength,
UINT uIdx
)
{
PWLAN_80211HDR_A4 pHeader;
PBYTE pbyDestAddr;
BYTE byTSR0_NCR = byTSR0 & TSR0_NCR;
pHeader = (PWLAN_80211HDR_A4) pbyBuffer;
if (WLAN_GET_FC_TODS(pHeader->wFrameCtl) == 0) {
pbyDestAddr = &(pHeader->abyAddr1[0]);
}
else {
pbyDestAddr = &(pHeader->abyAddr3[0]);
}
// increase tx packet count
pStatistic->dwTsrTxPacket[uIdx]++;
pStatistic->dwTsrTxOctet[uIdx] += cbFrameLength;
if (byTSR0_NCR != 0) {
pStatistic->dwTsrRetry[uIdx]++;
pStatistic->dwTsrTotalRetry[uIdx] += byTSR0_NCR;
if (byTSR0_NCR == 1)
pStatistic->dwTsrOnceRetry[uIdx]++;
else
pStatistic->dwTsrMoreThanOnceRetry[uIdx]++;
}
if ((byTSR1&(TSR1_TERR|TSR1_RETRYTMO|TSR1_TMO|ACK_DATA)) == 0) {
pStatistic->ullTsrOK[uIdx]++;
pStatistic->CustomStat.ullTsrAllOK =
(pStatistic->ullTsrOK[TYPE_AC0DMA] + pStatistic->ullTsrOK[TYPE_TXDMA0]);
// update counters in case that successful transmit
if (IS_BROADCAST_ADDRESS(pbyDestAddr)) {
pStatistic->ullTxBroadcastFrames[uIdx]++;
pStatistic->ullTxBroadcastBytes[uIdx] += (ULONGLONG)cbFrameLength;
}
else if (IS_MULTICAST_ADDRESS(pbyDestAddr)) {
pStatistic->ullTxMulticastFrames[uIdx]++;
pStatistic->ullTxMulticastBytes[uIdx] += (ULONGLONG)cbFrameLength;
}
else {
pStatistic->ullTxDirectedFrames[uIdx]++;
pStatistic->ullTxDirectedBytes[uIdx] += (ULONGLONG)cbFrameLength;
}
}
else {
if (BITbIsBitOn(byTSR1, TSR1_TERR))
pStatistic->dwTsrErr[uIdx]++;
if (BITbIsBitOn(byTSR1, TSR1_RETRYTMO))
pStatistic->dwTsrRetryTimeout[uIdx]++;
if (BITbIsBitOn(byTSR1, TSR1_TMO))
pStatistic->dwTsrTransmitTimeout[uIdx]++;
if (BITbIsBitOn(byTSR1, ACK_DATA))
pStatistic->dwTsrACKData[uIdx]++;
}
if (IS_BROADCAST_ADDRESS(pbyDestAddr))
pStatistic->dwTsrBroadcast[uIdx]++;
else if (IS_MULTICAST_ADDRESS(pbyDestAddr))
pStatistic->dwTsrMulticast[uIdx]++;
else
pStatistic->dwTsrDirected[uIdx]++;
}
/*
* Description: Update Tx Statistic Counter and copy Tx buffer
*
* Parameters:
* In:
* pStatistic - Pointer to Statistic Counter Data Structure
* pbyBuffer - Tx Buffer
* cbFrameLength - Tx Length
* Out:
* none
*
* Return Value: none
*
*/
void
STAvUpdateTDStatCounterEx (
PSStatCounter pStatistic,
PBYTE pbyBuffer,
DWORD cbFrameLength
)
{
UINT uPktLength;
uPktLength = (UINT)cbFrameLength;
// tx length
pStatistic->dwCntTxBufLength = uPktLength;
// tx pattern, we just see 16 bytes for sample
MEMvCopy(pStatistic->abyCntTxPattern, pbyBuffer, 16);
}
/*
* Description: Update 802.11 mib counter
*
* Parameters:
* In:
* p802_11Counter - Pointer to 802.11 mib counter
* pStatistic - Pointer to Statistic Counter Data Structure
* dwCounter - hardware counter for 802.11 mib
* Out:
* none
*
* Return Value: none
*
*/
void
STAvUpdate802_11Counter(
PSDot11Counters p802_11Counter,
PSStatCounter pStatistic,
DWORD dwCounter
)
{
//p802_11Counter->TransmittedFragmentCount
p802_11Counter->MulticastTransmittedFrameCount = (ULONGLONG) (pStatistic->dwTsrBroadcast[TYPE_AC0DMA] +
pStatistic->dwTsrBroadcast[TYPE_TXDMA0] +
pStatistic->dwTsrMulticast[TYPE_AC0DMA] +
pStatistic->dwTsrMulticast[TYPE_TXDMA0]);
p802_11Counter->FailedCount = (ULONGLONG) (pStatistic->dwTsrErr[TYPE_AC0DMA] + pStatistic->dwTsrErr[TYPE_TXDMA0]);
p802_11Counter->RetryCount = (ULONGLONG) (pStatistic->dwTsrRetry[TYPE_AC0DMA] + pStatistic->dwTsrRetry[TYPE_TXDMA0]);
p802_11Counter->MultipleRetryCount = (ULONGLONG) (pStatistic->dwTsrMoreThanOnceRetry[TYPE_AC0DMA] +
pStatistic->dwTsrMoreThanOnceRetry[TYPE_TXDMA0]);
//p802_11Counter->FrameDuplicateCount
p802_11Counter->RTSSuccessCount += (ULONGLONG) (dwCounter & 0x000000ff);
p802_11Counter->RTSFailureCount += (ULONGLONG) ((dwCounter & 0x0000ff00) >> 8);
p802_11Counter->ACKFailureCount += (ULONGLONG) ((dwCounter & 0x00ff0000) >> 16);
p802_11Counter->FCSErrorCount += (ULONGLONG) ((dwCounter & 0xff000000) >> 24);
//p802_11Counter->ReceivedFragmentCount
p802_11Counter->MulticastReceivedFrameCount = (ULONGLONG) (pStatistic->dwRsrBroadcast +
pStatistic->dwRsrMulticast);
}
/*
* Description: Clear 802.11 mib counter
*
* Parameters:
* In:
* p802_11Counter - Pointer to 802.11 mib counter
* Out:
* none
*
* Return Value: none
*
*/
void
STAvClear802_11Counter(PSDot11Counters p802_11Counter)
{
// set memory to zero
ZERO_MEMORY(p802_11Counter, sizeof(SDot11Counters));
}

View File

@ -0,0 +1,399 @@
/*
* Copyright (c) 1996, 2003 VIA Networking Technologies, Inc.
* All rights reserved.
*
* This program is free software; you can redistribute it and/or modify
* it under the terms of the GNU General Public License as published by
* the Free Software Foundation; either version 2 of the License, or
* (at your option) any later version.
*
* This program is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
* GNU General Public License for more details.
*
* You should have received a copy of the GNU General Public License along
* with this program; if not, write to the Free Software Foundation, Inc.,
* 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA.
*
* File: mib.h
*
* Purpose: Implement MIB Data Structure
*
* Author: Tevin Chen
*
* Date: May 21, 1996
*
*/
#ifndef __MIB_H__
#define __MIB_H__
#if !defined(__TTYPE_H__)
#include "ttype.h"
#endif
#if !defined(__TETHER_H__)
#include "tether.h"
#endif
#if !defined(__DESC_H__)
#include "desc.h"
#endif
//#define ULONGLONG ULONG
/*--------------------- Export Definitions -------------------------*/
//
// 802.11 counter
//
typedef struct tagSDot11Counters {
ULONG Length; // Length of structure
ULONGLONG TransmittedFragmentCount;
ULONGLONG MulticastTransmittedFrameCount;
ULONGLONG FailedCount;
ULONGLONG RetryCount;
ULONGLONG MultipleRetryCount;
ULONGLONG RTSSuccessCount;
ULONGLONG RTSFailureCount;
ULONGLONG ACKFailureCount;
ULONGLONG FrameDuplicateCount;
ULONGLONG ReceivedFragmentCount;
ULONGLONG MulticastReceivedFrameCount;
ULONGLONG FCSErrorCount;
ULONGLONG TKIPLocalMICFailures;
ULONGLONG TKIPRemoteMICFailures;
ULONGLONG TKIPICVErrors;
ULONGLONG TKIPCounterMeasuresInvoked;
ULONGLONG TKIPReplays;
ULONGLONG CCMPFormatErrors;
ULONGLONG CCMPReplays;
ULONGLONG CCMPDecryptErrors;
ULONGLONG FourWayHandshakeFailures;
// ULONGLONG WEPUndecryptableCount;
// ULONGLONG WEPICVErrorCount;
// ULONGLONG DecryptSuccessCount;
// ULONGLONG DecryptFailureCount;
} SDot11Counters, DEF* PSDot11Counters;
//
// MIB2 counter
//
typedef struct tagSMib2Counter {
LONG ifIndex;
TCHAR ifDescr[256]; // max size 255 plus zero ending
// e.g. "interface 1"
LONG ifType;
LONG ifMtu;
DWORD ifSpeed;
BYTE ifPhysAddress[U_ETHER_ADDR_LEN];
LONG ifAdminStatus;
LONG ifOperStatus;
DWORD ifLastChange;
DWORD ifInOctets;
DWORD ifInUcastPkts;
DWORD ifInNUcastPkts;
DWORD ifInDiscards;
DWORD ifInErrors;
DWORD ifInUnknownProtos;
DWORD ifOutOctets;
DWORD ifOutUcastPkts;
DWORD ifOutNUcastPkts;
DWORD ifOutDiscards;
DWORD ifOutErrors;
DWORD ifOutQLen;
DWORD ifSpecific;
} SMib2Counter, DEF* PSMib2Counter;
// Value in the ifType entry
//#define ETHERNETCSMACD 6 //
#define WIRELESSLANIEEE80211b 6 //
// Value in the ifAdminStatus/ifOperStatus entry
#define UP 1 //
#define DOWN 2 //
#define TESTING 3 //
//
// RMON counter
//
typedef struct tagSRmonCounter {
LONG etherStatsIndex;
DWORD etherStatsDataSource;
DWORD etherStatsDropEvents;
DWORD etherStatsOctets;
DWORD etherStatsPkts;
DWORD etherStatsBroadcastPkts;
DWORD etherStatsMulticastPkts;
DWORD etherStatsCRCAlignErrors;
DWORD etherStatsUndersizePkts;
DWORD etherStatsOversizePkts;
DWORD etherStatsFragments;
DWORD etherStatsJabbers;
DWORD etherStatsCollisions;
DWORD etherStatsPkt64Octets;
DWORD etherStatsPkt65to127Octets;
DWORD etherStatsPkt128to255Octets;
DWORD etherStatsPkt256to511Octets;
DWORD etherStatsPkt512to1023Octets;
DWORD etherStatsPkt1024to1518Octets;
DWORD etherStatsOwners;
DWORD etherStatsStatus;
} SRmonCounter, DEF* PSRmonCounter;
//
// Custom counter
//
typedef struct tagSCustomCounters {
ULONG Length;
ULONGLONG ullTsrAllOK;
ULONGLONG ullRsr11M;
ULONGLONG ullRsr5M;
ULONGLONG ullRsr2M;
ULONGLONG ullRsr1M;
ULONGLONG ullRsr11MCRCOk;
ULONGLONG ullRsr5MCRCOk;
ULONGLONG ullRsr2MCRCOk;
ULONGLONG ullRsr1MCRCOk;
ULONGLONG ullRsr54M;
ULONGLONG ullRsr48M;
ULONGLONG ullRsr36M;
ULONGLONG ullRsr24M;
ULONGLONG ullRsr18M;
ULONGLONG ullRsr12M;
ULONGLONG ullRsr9M;
ULONGLONG ullRsr6M;
ULONGLONG ullRsr54MCRCOk;
ULONGLONG ullRsr48MCRCOk;
ULONGLONG ullRsr36MCRCOk;
ULONGLONG ullRsr24MCRCOk;
ULONGLONG ullRsr18MCRCOk;
ULONGLONG ullRsr12MCRCOk;
ULONGLONG ullRsr9MCRCOk;
ULONGLONG ullRsr6MCRCOk;
} SCustomCounters, DEF* PSCustomCounters;
//
// Custom counter
//
typedef struct tagSISRCounters {
ULONG Length;
DWORD dwIsrTx0OK;
DWORD dwIsrAC0TxOK;
DWORD dwIsrBeaconTxOK;
DWORD dwIsrRx0OK;
DWORD dwIsrTBTTInt;
DWORD dwIsrSTIMERInt;
DWORD dwIsrWatchDog;
DWORD dwIsrUnrecoverableError;
DWORD dwIsrSoftInterrupt;
DWORD dwIsrMIBNearfull;
DWORD dwIsrRxNoBuf;
DWORD dwIsrUnknown; // unknown interrupt count
DWORD dwIsrRx1OK;
DWORD dwIsrATIMTxOK;
DWORD dwIsrSYNCTxOK;
DWORD dwIsrCFPEnd;
DWORD dwIsrATIMEnd;
DWORD dwIsrSYNCFlushOK;
DWORD dwIsrSTIMER1Int;
/////////////////////////////////////
} SISRCounters, DEF* PSISRCounters;
// Value in the etherStatsStatus entry
#define VALID 1 //
#define CREATE_REQUEST 2 //
#define UNDER_CREATION 3 //
#define INVALID 4 //
//#define MAX_RATE 12
//
// statistic counter
//
typedef struct tagSStatCounter {
//
// ISR status count
//
// RSR status count
//
DWORD dwRsrFrmAlgnErr;
DWORD dwRsrErr;
DWORD dwRsrCRCErr;
DWORD dwRsrCRCOk;
DWORD dwRsrBSSIDOk;
DWORD dwRsrADDROk;
DWORD dwRsrBCNSSIDOk;
DWORD dwRsrLENErr;
DWORD dwRsrTYPErr;
DWORD dwNewRsrDECRYPTOK;
DWORD dwNewRsrCFP;
DWORD dwNewRsrUTSF;
DWORD dwNewRsrHITAID;
DWORD dwNewRsrHITAID0;
DWORD dwRsrLong;
DWORD dwRsrRunt;
DWORD dwRsrRxControl;
DWORD dwRsrRxData;
DWORD dwRsrRxManage;
DWORD dwRsrRxPacket;
DWORD dwRsrRxOctet;
DWORD dwRsrBroadcast;
DWORD dwRsrMulticast;
DWORD dwRsrDirected;
// 64-bit OID
ULONGLONG ullRsrOK;
// for some optional OIDs (64 bits) and DMI support
ULONGLONG ullRxBroadcastBytes;
ULONGLONG ullRxMulticastBytes;
ULONGLONG ullRxDirectedBytes;
ULONGLONG ullRxBroadcastFrames;
ULONGLONG ullRxMulticastFrames;
ULONGLONG ullRxDirectedFrames;
DWORD dwRsrRxFragment;
DWORD dwRsrRxFrmLen64;
DWORD dwRsrRxFrmLen65_127;
DWORD dwRsrRxFrmLen128_255;
DWORD dwRsrRxFrmLen256_511;
DWORD dwRsrRxFrmLen512_1023;
DWORD dwRsrRxFrmLen1024_1518;
// TSR status count
//
DWORD dwTsrTotalRetry[TYPE_MAXTD]; // total collision retry count
DWORD dwTsrOnceRetry[TYPE_MAXTD]; // this packet only occur one collision
DWORD dwTsrMoreThanOnceRetry[TYPE_MAXTD]; // this packet occur more than one collision
DWORD dwTsrRetry[TYPE_MAXTD]; // this packet has ever occur collision,
// that is (dwTsrOnceCollision0 + dwTsrMoreThanOnceCollision0)
DWORD dwTsrACKData[TYPE_MAXTD];
DWORD dwTsrErr[TYPE_MAXTD];
DWORD dwAllTsrOK[TYPE_MAXTD];
DWORD dwTsrRetryTimeout[TYPE_MAXTD];
DWORD dwTsrTransmitTimeout[TYPE_MAXTD];
DWORD dwTsrTxPacket[TYPE_MAXTD];
DWORD dwTsrTxOctet[TYPE_MAXTD];
DWORD dwTsrBroadcast[TYPE_MAXTD];
DWORD dwTsrMulticast[TYPE_MAXTD];
DWORD dwTsrDirected[TYPE_MAXTD];
// RD/TD count
DWORD dwCntRxFrmLength;
DWORD dwCntTxBufLength;
BYTE abyCntRxPattern[16];
BYTE abyCntTxPattern[16];
// Software check....
DWORD dwCntRxDataErr; // rx buffer data software compare CRC err count
DWORD dwCntDecryptErr; // rx buffer data software compare CRC err count
DWORD dwCntRxICVErr; // rx buffer data software compare CRC err count
UINT idxRxErrorDesc[TYPE_MAXRD]; // index for rx data error RD
// 64-bit OID
ULONGLONG ullTsrOK[TYPE_MAXTD];
// for some optional OIDs (64 bits) and DMI support
ULONGLONG ullTxBroadcastFrames[TYPE_MAXTD];
ULONGLONG ullTxMulticastFrames[TYPE_MAXTD];
ULONGLONG ullTxDirectedFrames[TYPE_MAXTD];
ULONGLONG ullTxBroadcastBytes[TYPE_MAXTD];
ULONGLONG ullTxMulticastBytes[TYPE_MAXTD];
ULONGLONG ullTxDirectedBytes[TYPE_MAXTD];
// DWORD dwTxRetryCount[8];
//
// ISR status count
//
SISRCounters ISRStat;
SCustomCounters CustomStat;
#ifdef Calcu_LinkQual
//Tx count:
ULONG TxNoRetryOkCount; //success tx no retry !
ULONG TxRetryOkCount; //sucess tx but retry !
ULONG TxFailCount; //fail tx ?
//Rx count:
ULONG RxOkCnt; //sucess rx !
ULONG RxFcsErrCnt; //fail rx ?
//statistic
ULONG SignalStren;
ULONG LinkQuality;
#endif
} SStatCounter, DEF* PSStatCounter;
/*--------------------- Export Classes ----------------------------*/
/*--------------------- Export Variables --------------------------*/
/*--------------------- Export Functions --------------------------*/
#ifdef __cplusplus
extern "C" { /* Assume C declarations for C++ */
#endif /* __cplusplus */
void STAvClearAllCounter(PSStatCounter pStatistic);
void STAvUpdateIsrStatCounter(PSStatCounter pStatistic, DWORD dwIsr);
void STAvUpdateRDStatCounter(PSStatCounter pStatistic,
BYTE byRSR, BYTE byNewRSR, BYTE byRxRate,
PBYTE pbyBuffer, UINT cbFrameLength);
void STAvUpdateRDStatCounterEx(PSStatCounter pStatistic,
BYTE byRSR, BYTE byNewRsr, BYTE byRxRate,
PBYTE pbyBuffer, UINT cbFrameLength);
void STAvUpdateTDStatCounter(PSStatCounter pStatistic,
BYTE byTSR0, BYTE byTSR1,
PBYTE pbyBuffer, UINT cbFrameLength, UINT uIdx );
void STAvUpdateTDStatCounterEx(
PSStatCounter pStatistic,
PBYTE pbyBuffer,
DWORD cbFrameLength
);
void STAvUpdate802_11Counter(
PSDot11Counters p802_11Counter,
PSStatCounter pStatistic,
DWORD dwCounter
);
void STAvClear802_11Counter(PSDot11Counters p802_11Counter);
#ifdef __cplusplus
} /* End of extern "C" { */
#endif /* __cplusplus */
#endif // __MIB_H__

View File

@ -0,0 +1,188 @@
/*
* Copyright (c) 1996, 2003 VIA Networking Technologies, Inc.
* All rights reserved.
*
* This program is free software; you can redistribute it and/or modify
* it under the terms of the GNU General Public License as published by
* the Free Software Foundation; either version 2 of the License, or
* (at your option) any later version.
*
* This program is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
* GNU General Public License for more details.
*
* You should have received a copy of the GNU General Public License along
* with this program; if not, write to the Free Software Foundation, Inc.,
* 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA.
*
*
* File: michael.cpp
*
* Purpose: The implementation of LIST data structure.
*
* Author: Kyle Hsu
*
* Date: Sep 4, 2002
*
* Functions:
* s_dwGetUINT32 - Convert from BYTE[] to DWORD in a portable way
* s_vPutUINT32 - Convert from DWORD to BYTE[] in a portable way
* s_vClear - Reset the state to the empty message.
* s_vSetKey - Set the key.
* MIC_vInit - Set the key.
* s_vAppendByte - Append the byte to our word-sized buffer.
* MIC_vAppend - call s_vAppendByte.
* MIC_vGetMIC - Append the minimum padding and call s_vAppendByte.
*
* Revision History:
*
*/
#if !defined(__TMACRO_H__)
#include "tmacro.h"
#endif
#if !defined(__TBIT_H__)
#include "tbit.h"
#endif
#if !defined(__MICHAEL_H__)
#include "michael.h"
#endif
/*--------------------- Static Definitions -------------------------*/
/*--------------------- Static Variables --------------------------*/
/*--------------------- Static Functions --------------------------*/
/*
static DWORD s_dwGetUINT32(BYTE * p); // Get DWORD from 4 bytes LSByte first
static VOID s_vPutUINT32(BYTE* p, DWORD val); // Put DWORD into 4 bytes LSByte first
*/
static VOID s_vClear(void); // Clear the internal message,
// resets the object to the state just after construction.
static VOID s_vSetKey(DWORD dwK0, DWORD dwK1);
static VOID s_vAppendByte(BYTE b); // Add a single byte to the internal message
/*--------------------- Export Variables --------------------------*/
static DWORD L, R; // Current state
static DWORD K0, K1; // Key
static DWORD M; // Message accumulator (single word)
static UINT nBytesInM; // # bytes in M
/*--------------------- Export Functions --------------------------*/
/*
static DWORD s_dwGetUINT32 (BYTE * p)
// Convert from BYTE[] to DWORD in a portable way
{
DWORD res = 0;
UINT i;
for(i=0; i<4; i++ )
{
res |= (*p++) << (8*i);
}
return res;
}
static VOID s_vPutUINT32 (BYTE* p, DWORD val)
// Convert from DWORD to BYTE[] in a portable way
{
UINT i;
for(i=0; i<4; i++ )
{
*p++ = (BYTE) (val & 0xff);
val >>= 8;
}
}
*/
static VOID s_vClear (void)
{
// Reset the state to the empty message.
L = K0;
R = K1;
nBytesInM = 0;
M = 0;
}
static VOID s_vSetKey (DWORD dwK0, DWORD dwK1)
{
// Set the key
K0 = dwK0;
K1 = dwK1;
// and reset the message
s_vClear();
}
static VOID s_vAppendByte (BYTE b)
{
// Append the byte to our word-sized buffer
M |= b << (8*nBytesInM);
nBytesInM++;
// Process the word if it is full.
if( nBytesInM >= 4 )
{
L ^= M;
R ^= ROL32( L, 17 );
L += R;
R ^= ((L & 0xff00ff00) >> 8) | ((L & 0x00ff00ff) << 8);
L += R;
R ^= ROL32( L, 3 );
L += R;
R ^= ROR32( L, 2 );
L += R;
// Clear the buffer
M = 0;
nBytesInM = 0;
}
}
VOID MIC_vInit (DWORD dwK0, DWORD dwK1)
{
// Set the key
s_vSetKey(dwK0, dwK1);
}
VOID MIC_vUnInit (void)
{
// Wipe the key material
K0 = 0;
K1 = 0;
// And the other fields as well.
//Note that this sets (L,R) to (K0,K1) which is just fine.
s_vClear();
}
VOID MIC_vAppend (PBYTE src, UINT nBytes)
{
// This is simple
while (nBytes > 0)
{
s_vAppendByte(*src++);
nBytes--;
}
}
VOID MIC_vGetMIC (PDWORD pdwL, PDWORD pdwR)
{
// Append the minimum padding
s_vAppendByte(0x5a);
s_vAppendByte(0);
s_vAppendByte(0);
s_vAppendByte(0);
s_vAppendByte(0);
// and then zeroes until the length is a multiple of 4
while( nBytesInM != 0 )
{
s_vAppendByte(0);
}
// The s_vAppendByte function has already computed the result.
*pdwL = L;
*pdwR = R;
// Reset to the empty message.
s_vClear();
}

View File

@ -0,0 +1,62 @@
/*
* Copyright (c) 1996, 2003 VIA Networking Technologies, Inc.
* All rights reserved.
*
* This program is free software; you can redistribute it and/or modify
* it under the terms of the GNU General Public License as published by
* the Free Software Foundation; either version 2 of the License, or
* (at your option) any later version.
*
* This program is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
* GNU General Public License for more details.
*
* You should have received a copy of the GNU General Public License along
* with this program; if not, write to the Free Software Foundation, Inc.,
* 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA.
*
*
* File: Michael.h
*
* Purpose: Reference implementation for Michael
* written by Niels Ferguson
*
* Author: Kyle Hsu
*
* Date: Jan 2, 2003
*
*/
#ifndef __MICHAEL_H__
#define __MICHAEL_H__
#if !defined(__UMEM_H__)
#include "umem.h"
#endif
/*--------------------- Export Definitions -------------------------*/
/*--------------------- Export Types ------------------------------*/
VOID MIC_vInit(DWORD dwK0, DWORD dwK1);
VOID MIC_vUnInit(void);
// Append bytes to the message to be MICed
VOID MIC_vAppend(PBYTE src, UINT nBytes);
// Get the MIC result. Destination should accept 8 bytes of result.
// This also resets the message to empty.
VOID MIC_vGetMIC(PDWORD pdwL, PDWORD pdwR);
/*--------------------- Export Macros ------------------------------*/
// Rotation functions on 32 bit values
#define ROL32( A, n ) \
( ((A) << (n)) | ( ((A)>>(32-(n))) & ( (1UL << (n)) - 1 ) ) )
#define ROR32( A, n ) ROL32( (A), 32-(n) )
#endif //__MICHAEL_H__

View File

@ -0,0 +1,441 @@
/*
* Copyright (c) 1996, 2003 VIA Networking Technologies, Inc.
* All rights reserved.
*
* This program is free software; you can redistribute it and/or modify
* it under the terms of the GNU General Public License as published by
* the Free Software Foundation; either version 2 of the License, or
* (at your option) any later version.
*
* This program is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
* GNU General Public License for more details.
*
* You should have received a copy of the GNU General Public License along
* with this program; if not, write to the Free Software Foundation, Inc.,
* 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA.
*
* File: power.c
*
* Purpose: Handles 802.11 power managment functions
*
* Author: Lyndon Chen
*
* Date: July 17, 2002
*
* Functions:
* PSvEnablePowerSaving - Enable Power Saving Mode
* PSvDiasblePowerSaving - Disable Power Saving Mode
* PSbConsiderPowerDown - Decide if we can Power Down
* PSvSendPSPOLL - Send PS-POLL packet
* PSbSendNullPacket - Send Null packet
* PSbIsNextTBTTWakeUp - Decide if we need to wake up at next Beacon
*
* Revision History:
*
*/
#if !defined(__TTYPE_H__)
#include "ttype.h"
#endif
#if !defined(__TBIT_H__)
#include "tbit.h"
#endif
#if !defined(__MAC_H__)
#include "mac.h"
#endif
#if !defined(__DEVICE_H__)
#include "device.h"
#endif
#if !defined(__WMGR_H__)
#include "wmgr.h"
#endif
#if !defined(__POWER_H__)
#include "power.h"
#endif
#if !defined(__WCMD_H__)
#include "wcmd.h"
#endif
#if !defined(__TBIT_H__)
#include "tbit.h"
#endif
#if !defined(__UMEM_H__)
#include "umem.h"
#endif
#if !defined(__RXTX_H__)
#include "rxtx.h"
#endif
#if !defined(__CARD_H__)
#include "card.h"
#endif
/*--------------------- Static Definitions -------------------------*/
/*--------------------- Static Classes ----------------------------*/
/*--------------------- Static Variables --------------------------*/
static int msglevel =MSG_LEVEL_INFO;
/*--------------------- Static Functions --------------------------*/
/*--------------------- Export Variables --------------------------*/
/*--------------------- Export Functions --------------------------*/
/*+
*
* Routine Description:
* Enable hw power saving functions
*
* Return Value:
* None.
*
-*/
VOID
PSvEnablePowerSaving(
IN HANDLE hDeviceContext,
IN WORD wListenInterval
)
{
PSDevice pDevice = (PSDevice)hDeviceContext;
PSMgmtObject pMgmt = pDevice->pMgmt;
WORD wAID = pMgmt->wCurrAID | BIT14 | BIT15;
// set period of power up before TBTT
VNSvOutPortW(pDevice->PortOffset + MAC_REG_PWBT, C_PWBT);
if (pDevice->eOPMode != OP_MODE_ADHOC) {
// set AID
VNSvOutPortW(pDevice->PortOffset + MAC_REG_AIDATIM, wAID);
} else {
// set ATIM Window
MACvWriteATIMW(pDevice->PortOffset, pMgmt->wCurrATIMWindow);
}
// Set AutoSleep
MACvRegBitsOn(pDevice->PortOffset, MAC_REG_PSCFG, PSCFG_AUTOSLEEP);
// Set HWUTSF
MACvRegBitsOn(pDevice->PortOffset, MAC_REG_TFTCTL, TFTCTL_HWUTSF);
if (wListenInterval >= 2) {
// clear always listen beacon
MACvRegBitsOff(pDevice->PortOffset, MAC_REG_PSCTL, PSCTL_ALBCN);
//pDevice->wCFG &= ~CFG_ALB;
// first time set listen next beacon
MACvRegBitsOn(pDevice->PortOffset, MAC_REG_PSCTL, PSCTL_LNBCN);
pMgmt->wCountToWakeUp = wListenInterval;
}
else {
// always listen beacon
MACvRegBitsOn(pDevice->PortOffset, MAC_REG_PSCTL, PSCTL_ALBCN);
//pDevice->wCFG |= CFG_ALB;
pMgmt->wCountToWakeUp = 0;
}
// enable power saving hw function
MACvRegBitsOn(pDevice->PortOffset, MAC_REG_PSCTL, PSCTL_PSEN);
pDevice->bEnablePSMode = TRUE;
if (pDevice->eOPMode == OP_MODE_ADHOC) {
// bMgrPrepareBeaconToSend((HANDLE)pDevice, pMgmt);
}
// We don't send null pkt in ad hoc mode since beacon will handle this.
else if (pDevice->eOPMode == OP_MODE_INFRASTRUCTURE) {
PSbSendNullPacket(pDevice);
}
pDevice->bPWBitOn = TRUE;
DEVICE_PRT(MSG_LEVEL_DEBUG, KERN_INFO "PS:Power Saving Mode Enable... \n");
return;
}
/*+
*
* Routine Description:
* Disable hw power saving functions
*
* Return Value:
* None.
*
-*/
VOID
PSvDisablePowerSaving(
IN HANDLE hDeviceContext
)
{
PSDevice pDevice = (PSDevice)hDeviceContext;
// PSMgmtObject pMgmt = pDevice->pMgmt;
// disable power saving hw function
MACbPSWakeup(pDevice->PortOffset);
//clear AutoSleep
MACvRegBitsOff(pDevice->PortOffset, MAC_REG_PSCFG, PSCFG_AUTOSLEEP);
//clear HWUTSF
MACvRegBitsOff(pDevice->PortOffset, MAC_REG_TFTCTL, TFTCTL_HWUTSF);
// set always listen beacon
MACvRegBitsOn(pDevice->PortOffset, MAC_REG_PSCTL, PSCTL_ALBCN);
pDevice->bEnablePSMode = FALSE;
if (pDevice->eOPMode == OP_MODE_INFRASTRUCTURE) {
PSbSendNullPacket(pDevice);
}
pDevice->bPWBitOn = FALSE;
return;
}
/*+
*
* Routine Description:
* Consider to power down when no more packets to tx or rx.
*
* Return Value:
* TRUE, if power down success
* FALSE, if fail
-*/
BOOL
PSbConsiderPowerDown(
IN HANDLE hDeviceContext,
IN BOOL bCheckRxDMA,
IN BOOL bCheckCountToWakeUp
)
{
PSDevice pDevice = (PSDevice)hDeviceContext;
PSMgmtObject pMgmt = pDevice->pMgmt;
UINT uIdx;
// check if already in Doze mode
if (MACbIsRegBitsOn(pDevice->PortOffset, MAC_REG_PSCTL, PSCTL_PS))
return TRUE;
if (pMgmt->eCurrMode != WMAC_MODE_IBSS_STA) {
// check if in TIM wake period
if (pMgmt->bInTIMWake)
return FALSE;
}
// check scan state
if (pDevice->bCmdRunning)
return FALSE;
// Froce PSEN on
MACvRegBitsOn(pDevice->PortOffset, MAC_REG_PSCTL, PSCTL_PSEN);
// check if all TD are empty,
for (uIdx = 0; uIdx < TYPE_MAXTD; uIdx ++) {
if (pDevice->iTDUsed[uIdx] != 0)
return FALSE;
}
// check if rx isr is clear
if (bCheckRxDMA &&
((pDevice->dwIsr& ISR_RXDMA0) != 0) &&
((pDevice->dwIsr & ISR_RXDMA1) != 0)){
return FALSE;
};
if (pMgmt->eCurrMode != WMAC_MODE_IBSS_STA) {
if (bCheckCountToWakeUp &&
(pMgmt->wCountToWakeUp == 0 || pMgmt->wCountToWakeUp == 1)) {
return FALSE;
}
}
// no Tx, no Rx isr, now go to Doze
MACvRegBitsOn(pDevice->PortOffset, MAC_REG_PSCTL, PSCTL_GO2DOZE);
DEVICE_PRT(MSG_LEVEL_DEBUG, KERN_INFO "Go to Doze ZZZZZZZZZZZZZZZ\n");
return TRUE;
}
/*+
*
* Routine Description:
* Send PS-POLL packet
*
* Return Value:
* None.
*
-*/
VOID
PSvSendPSPOLL(
IN HANDLE hDeviceContext
)
{
PSDevice pDevice = (PSDevice)hDeviceContext;
PSMgmtObject pMgmt = pDevice->pMgmt;
PSTxMgmtPacket pTxPacket = NULL;
memset(pMgmt->pbyPSPacketPool, 0, sizeof(STxMgmtPacket) + WLAN_HDR_ADDR2_LEN);
pTxPacket = (PSTxMgmtPacket)pMgmt->pbyPSPacketPool;
pTxPacket->p80211Header = (PUWLAN_80211HDR)((PBYTE)pTxPacket + sizeof(STxMgmtPacket));
pTxPacket->p80211Header->sA2.wFrameCtl = cpu_to_le16(
(
WLAN_SET_FC_FTYPE(WLAN_TYPE_CTL) |
WLAN_SET_FC_FSTYPE(WLAN_FSTYPE_PSPOLL) |
WLAN_SET_FC_PWRMGT(0)
));
pTxPacket->p80211Header->sA2.wDurationID = pMgmt->wCurrAID | BIT14 | BIT15;
memcpy(pTxPacket->p80211Header->sA2.abyAddr1, pMgmt->abyCurrBSSID, WLAN_ADDR_LEN);
memcpy(pTxPacket->p80211Header->sA2.abyAddr2, pMgmt->abyMACAddr, WLAN_ADDR_LEN);
pTxPacket->cbMPDULen = WLAN_HDR_ADDR2_LEN;
pTxPacket->cbPayloadLen = 0;
// send the frame
if (csMgmt_xmit(pDevice, pTxPacket) != CMD_STATUS_PENDING) {
DEVICE_PRT(MSG_LEVEL_DEBUG, KERN_INFO "Send PS-Poll packet failed..\n");
}
else {
// DEVICE_PRT(MSG_LEVEL_DEBUG, KERN_INFO "Send PS-Poll packet success..\n");
};
return;
}
/*+
*
* Routine Description:
* Send NULL packet to AP for notification power state of STA
*
* Return Value:
* None.
*
-*/
BOOL
PSbSendNullPacket(
IN HANDLE hDeviceContext
)
{
PSDevice pDevice = (PSDevice)hDeviceContext;
PSTxMgmtPacket pTxPacket = NULL;
PSMgmtObject pMgmt = pDevice->pMgmt;
UINT uIdx;
if (pDevice->bLinkPass == FALSE) {
return FALSE;
}
#ifdef TxInSleep
if ((pDevice->bEnablePSMode == FALSE) &&
(pDevice->fTxDataInSleep == FALSE)){
return FALSE;
}
#else
if (pDevice->bEnablePSMode == FALSE) {
return FALSE;
}
#endif
if (pDevice->bEnablePSMode) {
for (uIdx = 0; uIdx < TYPE_MAXTD; uIdx ++) {
if (pDevice->iTDUsed[uIdx] != 0)
return FALSE;
}
}
memset(pMgmt->pbyPSPacketPool, 0, sizeof(STxMgmtPacket) + WLAN_NULLDATA_FR_MAXLEN);
pTxPacket = (PSTxMgmtPacket)pMgmt->pbyPSPacketPool;
pTxPacket->p80211Header = (PUWLAN_80211HDR)((PBYTE)pTxPacket + sizeof(STxMgmtPacket));
if (pDevice->bEnablePSMode) {
pTxPacket->p80211Header->sA3.wFrameCtl = cpu_to_le16(
(
WLAN_SET_FC_FTYPE(WLAN_TYPE_DATA) |
WLAN_SET_FC_FSTYPE(WLAN_FSTYPE_NULL) |
WLAN_SET_FC_PWRMGT(1)
));
}
else {
pTxPacket->p80211Header->sA3.wFrameCtl = cpu_to_le16(
(
WLAN_SET_FC_FTYPE(WLAN_TYPE_DATA) |
WLAN_SET_FC_FSTYPE(WLAN_FSTYPE_NULL) |
WLAN_SET_FC_PWRMGT(0)
));
}
if(pMgmt->eCurrMode != WMAC_MODE_IBSS_STA) {
pTxPacket->p80211Header->sA3.wFrameCtl |= cpu_to_le16((WORD)WLAN_SET_FC_TODS(1));
}
memcpy(pTxPacket->p80211Header->sA3.abyAddr1, pMgmt->abyCurrBSSID, WLAN_ADDR_LEN);
memcpy(pTxPacket->p80211Header->sA3.abyAddr2, pMgmt->abyMACAddr, WLAN_ADDR_LEN);
memcpy(pTxPacket->p80211Header->sA3.abyAddr3, pMgmt->abyCurrBSSID, WLAN_BSSID_LEN);
pTxPacket->cbMPDULen = WLAN_HDR_ADDR3_LEN;
pTxPacket->cbPayloadLen = 0;
// send the frame
if (csMgmt_xmit(pDevice, pTxPacket) != CMD_STATUS_PENDING) {
DEVICE_PRT(MSG_LEVEL_DEBUG, KERN_INFO "Send Null Packet failed !\n");
return FALSE;
}
else {
// DEVICE_PRT(MSG_LEVEL_DEBUG, KERN_INFO "Send Null Packet success....\n");
}
return TRUE ;
}
/*+
*
* Routine Description:
* Check if Next TBTT must wake up
*
* Return Value:
* None.
*
-*/
BOOL
PSbIsNextTBTTWakeUp(
IN HANDLE hDeviceContext
)
{
PSDevice pDevice = (PSDevice)hDeviceContext;
PSMgmtObject pMgmt = pDevice->pMgmt;
BOOL bWakeUp = FALSE;
if (pMgmt->wListenInterval >= 2) {
if (pMgmt->wCountToWakeUp == 0) {
pMgmt->wCountToWakeUp = pMgmt->wListenInterval;
}
pMgmt->wCountToWakeUp --;
if (pMgmt->wCountToWakeUp == 1) {
// Turn on wake up to listen next beacon
MACvRegBitsOn(pDevice->PortOffset, MAC_REG_PSCTL, PSCTL_LNBCN);
bWakeUp = TRUE;
}
}
return bWakeUp;
}

View File

@ -0,0 +1,85 @@
/*
* Copyright (c) 1996, 2003 VIA Networking Technologies, Inc.
* All rights reserved.
*
* This program is free software; you can redistribute it and/or modify
* it under the terms of the GNU General Public License as published by
* the Free Software Foundation; either version 2 of the License, or
* (at your option) any later version.
*
* This program is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
* GNU General Public License for more details.
*
* You should have received a copy of the GNU General Public License along
* with this program; if not, write to the Free Software Foundation, Inc.,
* 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA.
*
*
* File: power.h
*
* Purpose: Handles 802.11 power managment functions
*
* Author: Lyndon Chen
*
* Date: July 17, 2002
*
*/
#ifndef __POWER_H__
#define __POWER_H__
/*--------------------- Export Definitions -------------------------*/
#define C_PWBT 1000 // micro sec. power up before TBTT
#define PS_FAST_INTERVAL 1 // Fast power saving listen interval
#define PS_MAX_INTERVAL 4 // MAX power saving listen interval
/*--------------------- Export Classes ----------------------------*/
/*--------------------- Export Variables --------------------------*/
/*--------------------- Export Types ------------------------------*/
/*--------------------- Export Functions --------------------------*/
// IN PSDevice pDevice
// IN PSDevice hDeviceContext
BOOL
PSbConsiderPowerDown(
IN HANDLE hDeviceContext,
IN BOOL bCheckRxDMA,
IN BOOL bCheckCountToWakeUp
);
VOID
PSvDisablePowerSaving(
IN HANDLE hDeviceContext
);
VOID
PSvEnablePowerSaving(
IN HANDLE hDeviceContext,
IN WORD wListenInterval
);
VOID
PSvSendPSPOLL(
IN HANDLE hDeviceContext
);
BOOL
PSbSendNullPacket(
IN HANDLE hDeviceContext
);
BOOL
PSbIsNextTBTTWakeUp(
IN HANDLE hDeviceContext
);
#endif //__POWER_H__

View File

@ -0,0 +1,86 @@
/*
* File: rc4.c
*
* This program is free software; you can redistribute it and/or modify
* it under the terms of the GNU General Public License as published by
* the Free Software Foundation; either version 2 of the License, or
* (at your option) any later version.
*
* This program is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
* GNU General Public License for more details.
*
* You should have received a copy of the GNU General Public License along
* with this program; if not, write to the Free Software Foundation, Inc.,
* 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA.
*
* Purpose:
*
* Functions:
*
* Revision History:
*
* Author: Kyle Hsu
*
* Date: Sep 4, 2002
*
*/
#if !defined(__RC4_H__)
#include "rc4.h"
#endif
VOID rc4_init(PRC4Ext pRC4, PBYTE pbyKey, UINT cbKey_len)
{
UINT ust1, ust2;
UINT keyindex;
UINT stateindex;
PBYTE pbyst;
UINT idx;
pbyst = pRC4->abystate;
pRC4->ux = 0;
pRC4->uy = 0;
for (idx = 0; idx < 256; idx++)
pbyst[idx] = (BYTE)idx;
keyindex = 0;
stateindex = 0;
for (idx = 0; idx < 256; idx++) {
ust1 = pbyst[idx];
stateindex = (stateindex + pbyKey[keyindex] + ust1) & 0xff;
ust2 = pbyst[stateindex];
pbyst[stateindex] = (BYTE)ust1;
pbyst[idx] = (BYTE)ust2;
if (++keyindex >= cbKey_len)
keyindex = 0;
}
}
UINT rc4_byte(PRC4Ext pRC4)
{
UINT ux;
UINT uy;
UINT ustx, usty;
PBYTE pbyst;
pbyst = pRC4->abystate;
ux = (pRC4->ux + 1) & 0xff;
ustx = pbyst[ux];
uy = (ustx + pRC4->uy) & 0xff;
usty = pbyst[uy];
pRC4->ux = ux;
pRC4->uy = uy;
pbyst[uy] = (BYTE)ustx;
pbyst[ux] = (BYTE)usty;
return pbyst[(ustx + usty) & 0xff];
}
VOID rc4_encrypt(PRC4Ext pRC4, PBYTE pbyDest,
PBYTE pbySrc, UINT cbData_len)
{
UINT ii;
for (ii = 0; ii < cbData_len; ii++)
pbyDest[ii] = (BYTE)(pbySrc[ii] ^ rc4_byte(pRC4));
}

View File

@ -0,0 +1,51 @@
/*
* File: rc4.h
*
* This program is free software; you can redistribute it and/or modify
* it under the terms of the GNU General Public License as published by
* the Free Software Foundation; either version 2 of the License, or
* (at your option) any later version.
*
* This program is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
* GNU General Public License for more details.
*
* You should have received a copy of the GNU General Public License along
* with this program; if not, write to the Free Software Foundation, Inc.,
* 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA.
*
* Purpose:
*
* Functions:
*
* Revision History:
*
* Author: Kyle Hsu
*
* Date: Sep 4, 2002
*
*/
#ifndef __RC4_H__
#define __RC4_H__
#if !defined(__TTYPE_H__)
#include "ttype.h"
#endif
/*--------------------- Export Definitions -------------------------*/
/*--------------------- Export Types ------------------------------*/
typedef struct {
UINT ux;
UINT uy;
BYTE abystate[256];
} RC4Ext, DEF* PRC4Ext;
VOID rc4_init(PRC4Ext pRC4, PBYTE pbyKey, UINT cbKey_len);
UINT rc4_byte(PRC4Ext pRC4);
void rc4_encrypt(PRC4Ext pRC4, PBYTE pbyDest, PBYTE pbySrc, UINT cbData_len);
#endif //__RC4_H__

File diff suppressed because it is too large Load Diff

View File

@ -0,0 +1,118 @@
/*
* Copyright (c) 1996, 2003 VIA Networking Technologies, Inc.
* All rights reserved.
*
* This program is free software; you can redistribute it and/or modify
* it under the terms of the GNU General Public License as published by
* the Free Software Foundation; either version 2 of the License, or
* (at your option) any later version.
*
* This program is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
* GNU General Public License for more details.
*
* You should have received a copy of the GNU General Public License along
* with this program; if not, write to the Free Software Foundation, Inc.,
* 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA.
*
*
* File: rf.h
*
* Purpose:
*
* Author: Jerry Chen
*
* Date: Feb. 19, 2004
*
*/
#ifndef __RF_H__
#define __RF_H__
#if !defined(__TTYPE_H__)
#include "ttype.h"
#endif
#if !defined(__DEVICE_H__)
#include "device.h"
#endif
/*--------------------- Export Definitions -------------------------*/
//
// Baseband RF pair definition in eeprom (Bits 6..0)
//
#define RF_RFMD2959 0x01
#define RF_MAXIMAG 0x02
#define RF_AIROHA 0x03
//#define RF_GCT5103 0x04
#define RF_UW2451 0x05
#define RF_MAXIMG 0x06
#define RF_MAXIM2829 0x07 // RobertYu: 20041118
#define RF_UW2452 0x08 // RobertYu: 20041210
#define RF_AIROHA7230 0x0a // RobertYu: 20050104
#define RF_UW2453 0x0b
#define RF_VT3226 0x09
#define RF_AL2230S 0x0e
#define RF_NOTHING 0x7E
#define RF_EMU 0x80
#define RF_MASK 0x7F
#define ZONE_FCC 0
#define ZONE_MKK1 1
#define ZONE_ETSI 2
#define ZONE_IC 3
#define ZONE_SPAIN 4
#define ZONE_FRANCE 5
#define ZONE_MKK 6
#define ZONE_ISRAEL 7
//[20050104] CB_MAXIM2829_CHANNEL_5G_HIGH, CB_UW2452_CHANNEL_5G_HIGH: 40==>41
#define CB_MAXIM2829_CHANNEL_5G_HIGH 41 //Index41: channel = 100, Tf = 5500MHz, set the (A3:A0=0101) D6=1
#define CB_UW2452_CHANNEL_5G_HIGH 41 //[20041210] Index41: channel = 100, Tf = 5500MHz, change VCO2->VCO3
/*--------------------- Export Classes ----------------------------*/
/*--------------------- Export Variables --------------------------*/
/*--------------------- Export Functions --------------------------*/
#ifdef __cplusplus
extern "C" { /* Assume C declarations for C++ */
#endif /* __cplusplus */
BOOL IFRFbWriteEmbeded(DWORD_PTR dwIoBase, DWORD dwData);
BOOL RFbSelectChannel(DWORD_PTR dwIoBase, BYTE byRFType, BYTE byChannel);
BOOL RFbInit (
IN PSDevice pDevice
);
BOOL RFvWriteWakeProgSyn(DWORD_PTR dwIoBase, BYTE byRFType, UINT uChannel);
BOOL RFbSetPower(PSDevice pDevice, UINT uRATE, UINT uCH);
BOOL RFbRawSetPower(
IN PSDevice pDevice,
IN BYTE byPwr,
IN UINT uRATE
);
VOID
RFvRSSITodBm(
IN PSDevice pDevice,
IN BYTE byCurrRSSI,
OUT PLONG pldBm
);
//{{ RobertYu: 20050104
BOOL RFbAL7230SelectChannelPostProcess(DWORD_PTR dwIoBase, BYTE byOldChannel, BYTE byNewChannel);
//}} RobertYu
#ifdef __cplusplus
} /* End of extern "C" { */
#endif /* __cplusplus */
#endif // __RF_H__

File diff suppressed because it is too large Load Diff

View File

@ -0,0 +1,132 @@
/*
* Copyright (c) 1996, 2003 VIA Networking Technologies, Inc.
* All rights reserved.
*
* This program is free software; you can redistribute it and/or modify
* it under the terms of the GNU General Public License as published by
* the Free Software Foundation; either version 2 of the License, or
* (at your option) any later version.
*
* This program is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
* GNU General Public License for more details.
*
* You should have received a copy of the GNU General Public License along
* with this program; if not, write to the Free Software Foundation, Inc.,
* 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA.
*
* File: whdr.h
*
* Purpose:
*
* Author: Jerry Chen
*
* Date: Jun. 27, 2002
*
*/
#ifndef __RXTX_H__
#define __RXTX_H__
#if !defined(__TTYPE_H__)
#include "ttype.h"
#endif
#if !defined(__DEVICE_H__)
#include "device.h"
#endif
#if !defined(__WCMD_H__)
#include "wcmd.h"
#endif
/*--------------------- Export Definitions -------------------------*/
/*--------------------- Export Classes ----------------------------*/
/*--------------------- Export Variables --------------------------*/
/*--------------------- Export Functions --------------------------*/
#ifdef __cplusplus
extern "C" { /* Assume C declarations for C++ */
#endif /* __cplusplus */
/*
VOID vGenerateMACHeader(
IN PSDevice pDevice,
IN DWORD dwTxBufferAddr,
IN PBYTE pbySkbData,
IN UINT cbPacketSize,
IN BOOL bDMA0Used,
OUT PUINT pcbHeadSize,
OUT PUINT pcbAppendPayload
);
VOID vProcessRxMACHeader (
IN PSDevice pDevice,
IN DWORD dwRxBufferAddr,
IN UINT cbPacketSize,
IN BOOL bIsWEP,
OUT PUINT pcbHeadSize
);
*/
VOID
vGenerateMACHeader (
IN PSDevice pDevice,
IN PBYTE pbyBufferAddr,
IN WORD wDuration,
IN PSEthernetHeader psEthHeader,
IN BOOL bNeedEncrypt,
IN WORD wFragType,
IN UINT uDMAIdx,
IN UINT uFragIdx
);
UINT
cbGetFragCount(
IN PSDevice pDevice,
IN PSKeyItem pTransmitKey,
IN UINT cbFrameBodySize,
IN PSEthernetHeader psEthHeader
);
VOID
vGenerateFIFOHeader (
IN PSDevice pDevice,
IN BYTE byPktTyp,
IN PBYTE pbyTxBufferAddr,
IN BOOL bNeedEncrypt,
IN UINT cbPayloadSize,
IN UINT uDMAIdx,
IN PSTxDesc pHeadTD,
IN PSEthernetHeader psEthHeader,
IN PBYTE pPacket,
IN PSKeyItem pTransmitKey,
IN UINT uNodeIndex,
OUT PUINT puMACfragNum,
OUT PUINT pcbHeaderSize
);
VOID vDMA0_tx_80211(PSDevice pDevice, struct sk_buff *skb, PBYTE pbMPDU, UINT cbMPDULen);
CMD_STATUS csMgmt_xmit(PSDevice pDevice, PSTxMgmtPacket pPacket);
CMD_STATUS csBeacon_xmit(PSDevice pDevice, PSTxMgmtPacket pPacket);
#ifdef __cplusplus
} /* End of extern "C" { */
#endif /* __cplusplus */
#endif // __RXTX_H__

View File

@ -0,0 +1,437 @@
/*
* Copyright (c) 1996, 2003 VIA Networking Technologies, Inc.
* All rights reserved.
*
* This program is free software; you can redistribute it and/or modify
* it under the terms of the GNU General Public License as published by
* the Free Software Foundation; either version 2 of the License, or
* (at your option) any later version.
*
* This program is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
* GNU General Public License for more details.
*
* You should have received a copy of the GNU General Public License along
* with this program; if not, write to the Free Software Foundation, Inc.,
* 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA.
*
* File: srom.c
*
* Purpose:Implement functions to access eeprom
*
* Author: Jerry Chen
*
* Date: Jan 29, 2003
*
* Functions:
* SROMbyReadEmbedded - Embedded read eeprom via MAC
* SROMbWriteEmbedded - Embedded write eeprom via MAC
* SROMvRegBitsOn - Set Bits On in eeprom
* SROMvRegBitsOff - Clear Bits Off in eeprom
* SROMbIsRegBitsOn - Test if Bits On in eeprom
* SROMbIsRegBitsOff - Test if Bits Off in eeprom
* SROMvReadAllContents - Read all contents in eeprom
* SROMvWriteAllContents - Write all contents in eeprom
* SROMvReadEtherAddress - Read Ethernet Address in eeprom
* SROMvWriteEtherAddress - Write Ethernet Address in eeprom
* SROMvReadSubSysVenId - Read Sub_VID and Sub_SysId in eeprom
* SROMbAutoLoad - Auto Load eeprom to MAC register
*
* Revision History:
*
*/
#if !defined(__UPC_H__)
#include "upc.h"
#endif
#if !defined(__TMACRO_H__)
#include "tmacro.h"
#endif
#if !defined(__TBIT_H__)
#include "tbit.h"
#endif
#if !defined(__TETHER_H__)
#include "tether.h"
#endif
#if !defined(__MAC_H__)
#include "mac.h"
#endif
#if !defined(__SROM_H__)
#include "srom.h"
#endif
/*--------------------- Static Definitions -------------------------*/
/*--------------------- Static Classes ----------------------------*/
/*--------------------- Static Variables --------------------------*/
/*--------------------- Static Functions --------------------------*/
/*--------------------- Export Variables --------------------------*/
/*--------------------- Export Functions --------------------------*/
/*
* Description: Read a byte from EEPROM, by MAC I2C
*
* Parameters:
* In:
* dwIoBase - I/O base address
* byContntOffset - address of EEPROM
* Out:
* none
*
* Return Value: data read
*
*/
BYTE SROMbyReadEmbedded(DWORD_PTR dwIoBase, BYTE byContntOffset)
{
WORD wDelay, wNoACK;
BYTE byWait;
BYTE byData;
BYTE byOrg;
byData = 0xFF;
VNSvInPortB(dwIoBase + MAC_REG_I2MCFG, &byOrg);
// turn off hardware retry for getting NACK
VNSvOutPortB(dwIoBase + MAC_REG_I2MCFG, (byOrg & (~I2MCFG_NORETRY)));
for (wNoACK = 0; wNoACK < W_MAX_I2CRETRY; wNoACK++) {
VNSvOutPortB(dwIoBase + MAC_REG_I2MTGID, EEP_I2C_DEV_ID);
VNSvOutPortB(dwIoBase + MAC_REG_I2MTGAD, byContntOffset);
// issue read command
VNSvOutPortB(dwIoBase + MAC_REG_I2MCSR, I2MCSR_EEMR);
// wait DONE be set
for (wDelay = 0; wDelay < W_MAX_TIMEOUT; wDelay++) {
VNSvInPortB(dwIoBase + MAC_REG_I2MCSR, &byWait);
if (BITbIsAnyBitsOn(byWait, (I2MCSR_DONE | I2MCSR_NACK)))
break;
PCAvDelayByIO(CB_DELAY_LOOP_WAIT);
}
if ((wDelay < W_MAX_TIMEOUT) &&
(BITbIsBitOff(byWait, I2MCSR_NACK))) {
break;
}
}
VNSvInPortB(dwIoBase + MAC_REG_I2MDIPT, &byData);
VNSvOutPortB(dwIoBase + MAC_REG_I2MCFG, byOrg);
return byData;
}
/*
* Description: Write a byte to EEPROM, by MAC I2C
*
* Parameters:
* In:
* dwIoBase - I/O base address
* byContntOffset - address of EEPROM
* wData - data to write
* Out:
* none
*
* Return Value: TRUE if succeeded; FALSE if failed.
*
*/
BOOL SROMbWriteEmbedded (DWORD_PTR dwIoBase, BYTE byContntOffset, BYTE byData)
{
WORD wDelay, wNoACK;
BYTE byWait;
BYTE byOrg;
VNSvInPortB(dwIoBase + MAC_REG_I2MCFG, &byOrg);
// turn off hardware retry for getting NACK
VNSvOutPortB(dwIoBase + MAC_REG_I2MCFG, (byOrg & (~I2MCFG_NORETRY)));
for (wNoACK = 0; wNoACK < W_MAX_I2CRETRY; wNoACK++) {
VNSvOutPortB(dwIoBase + MAC_REG_I2MTGID, EEP_I2C_DEV_ID);
VNSvOutPortB(dwIoBase + MAC_REG_I2MTGAD, byContntOffset);
VNSvOutPortB(dwIoBase + MAC_REG_I2MDOPT, byData);
// issue write command
VNSvOutPortB(dwIoBase + MAC_REG_I2MCSR, I2MCSR_EEMW);
// wait DONE be set
for (wDelay = 0; wDelay < W_MAX_TIMEOUT; wDelay++) {
VNSvInPortB(dwIoBase + MAC_REG_I2MCSR, &byWait);
if (BITbIsAnyBitsOn(byWait, (I2MCSR_DONE | I2MCSR_NACK)))
break;
PCAvDelayByIO(CB_DELAY_LOOP_WAIT);
}
if ((wDelay < W_MAX_TIMEOUT) &&
(BITbIsBitOff(byWait, I2MCSR_NACK))) {
break;
}
}
if (wNoACK == W_MAX_I2CRETRY) {
VNSvOutPortB(dwIoBase + MAC_REG_I2MCFG, byOrg);
return FALSE;
}
VNSvOutPortB(dwIoBase + MAC_REG_I2MCFG, byOrg);
return TRUE;
}
/*
* Description: Turn bits on in eeprom
*
* Parameters:
* In:
* dwIoBase - I/O base address
* byContntOffset - address of EEPROM
* byBits - bits to turn on
* Out:
* none
*
* Return Value: none
*
*/
void SROMvRegBitsOn (DWORD_PTR dwIoBase, BYTE byContntOffset, BYTE byBits)
{
BYTE byOrgData;
byOrgData = SROMbyReadEmbedded(dwIoBase, byContntOffset);
SROMbWriteEmbedded(dwIoBase, byContntOffset,(BYTE)(byOrgData | byBits));
}
/*
* Description: Turn bits off in eeprom
*
* Parameters:
* In:
* dwIoBase - I/O base address
* byContntOffset - address of EEPROM
* byBits - bits to turn off
* Out:
* none
*
*/
void SROMvRegBitsOff (DWORD_PTR dwIoBase, BYTE byContntOffset, BYTE byBits)
{
BYTE byOrgData;
byOrgData = SROMbyReadEmbedded(dwIoBase, byContntOffset);
SROMbWriteEmbedded(dwIoBase, byContntOffset,(BYTE)(byOrgData & (~byBits)));
}
/*
* Description: Test if bits on in eeprom
*
* Parameters:
* In:
* dwIoBase - I/O base address
* byContntOffset - address of EEPROM
* byTestBits - bits to test
* Out:
* none
*
* Return Value: TRUE if all test bits on; otherwise FALSE
*
*/
BOOL SROMbIsRegBitsOn (DWORD_PTR dwIoBase, BYTE byContntOffset, BYTE byTestBits)
{
BYTE byOrgData;
byOrgData = SROMbyReadEmbedded(dwIoBase, byContntOffset);
return BITbIsAllBitsOn(byOrgData, byTestBits);
}
/*
* Description: Test if bits off in eeprom
*
* Parameters:
* In:
* dwIoBase - I/O base address
* byContntOffset - address of EEPROM
* byTestBits - bits to test
* Out:
* none
*
* Return Value: TRUE if all test bits off; otherwise FALSE
*
*/
BOOL SROMbIsRegBitsOff (DWORD_PTR dwIoBase, BYTE byContntOffset, BYTE byTestBits)
{
BYTE byOrgData;
byOrgData = SROMbyReadEmbedded(dwIoBase, byContntOffset);
return BITbIsAllBitsOff(byOrgData, byTestBits);
}
/*
* Description: Read all contents of eeprom to buffer
*
* Parameters:
* In:
* dwIoBase - I/O base address
* Out:
* pbyEepromRegs - EEPROM content Buffer
*
* Return Value: none
*
*/
void SROMvReadAllContents (DWORD_PTR dwIoBase, PBYTE pbyEepromRegs)
{
int ii;
// ii = Rom Address
for (ii = 0; ii < EEP_MAX_CONTEXT_SIZE; ii++) {
*pbyEepromRegs = SROMbyReadEmbedded(dwIoBase,(BYTE) ii);
pbyEepromRegs++;
}
}
/*
* Description: Write all contents of buffer to eeprom
*
* Parameters:
* In:
* dwIoBase - I/O base address
* pbyEepromRegs - EEPROM content Buffer
* Out:
* none
*
* Return Value: none
*
*/
void SROMvWriteAllContents (DWORD_PTR dwIoBase, PBYTE pbyEepromRegs)
{
int ii;
// ii = Rom Address
for (ii = 0; ii < EEP_MAX_CONTEXT_SIZE; ii++) {
SROMbWriteEmbedded(dwIoBase,(BYTE) ii, *pbyEepromRegs);
pbyEepromRegs++;
}
}
/*
* Description: Read Ethernet Address from eeprom to buffer
*
* Parameters:
* In:
* dwIoBase - I/O base address
* Out:
* pbyEtherAddress - Ethernet Address buffer
*
* Return Value: none
*
*/
void SROMvReadEtherAddress (DWORD_PTR dwIoBase, PBYTE pbyEtherAddress)
{
BYTE ii;
// ii = Rom Address
for (ii = 0; ii < U_ETHER_ADDR_LEN; ii++) {
*pbyEtherAddress = SROMbyReadEmbedded(dwIoBase, ii);
pbyEtherAddress++;
}
}
/*
* Description: Write Ethernet Address from buffer to eeprom
*
* Parameters:
* In:
* dwIoBase - I/O base address
* pbyEtherAddress - Ethernet Address buffer
* Out:
* none
*
* Return Value: none
*
*/
void SROMvWriteEtherAddress (DWORD_PTR dwIoBase, PBYTE pbyEtherAddress)
{
BYTE ii;
// ii = Rom Address
for (ii = 0; ii < U_ETHER_ADDR_LEN; ii++) {
SROMbWriteEmbedded(dwIoBase, ii, *pbyEtherAddress);
pbyEtherAddress++;
}
}
/*
* Description: Read Sub_VID and Sub_SysId from eeprom to buffer
*
* Parameters:
* In:
* dwIoBase - I/O base address
* Out:
* pdwSubSysVenId - Sub_VID and Sub_SysId read
*
* Return Value: none
*
*/
void SROMvReadSubSysVenId (DWORD_PTR dwIoBase, PDWORD pdwSubSysVenId)
{
PBYTE pbyData;
pbyData = (PBYTE)pdwSubSysVenId;
// sub vendor
*pbyData = SROMbyReadEmbedded(dwIoBase, 6);
*(pbyData+1) = SROMbyReadEmbedded(dwIoBase, 7);
// sub system
*(pbyData+2) = SROMbyReadEmbedded(dwIoBase, 8);
*(pbyData+3) = SROMbyReadEmbedded(dwIoBase, 9);
}
/*
* Description: Auto Load EEPROM to MAC register
*
* Parameters:
* In:
* dwIoBase - I/O base address
* Out:
* none
*
* Return Value: TRUE if success; otherwise FALSE
*
*/
BOOL SROMbAutoLoad (DWORD_PTR dwIoBase)
{
BYTE byWait;
int ii;
BYTE byOrg;
VNSvInPortB(dwIoBase + MAC_REG_I2MCFG, &byOrg);
// turn on hardware retry
VNSvOutPortB(dwIoBase + MAC_REG_I2MCFG, (byOrg | I2MCFG_NORETRY));
MACvRegBitsOn(dwIoBase, MAC_REG_I2MCSR, I2MCSR_AUTOLD);
// ii = Rom Address
for (ii = 0; ii < EEP_MAX_CONTEXT_SIZE; ii++) {
MACvTimer0MicroSDelay(dwIoBase, CB_EEPROM_READBYTE_WAIT);
VNSvInPortB(dwIoBase + MAC_REG_I2MCSR, &byWait);
if (BITbIsBitOff(byWait, I2MCSR_AUTOLD))
break;
}
VNSvOutPortB(dwIoBase + MAC_REG_I2MCFG, byOrg);
if (ii == EEP_MAX_CONTEXT_SIZE)
return FALSE;
return TRUE;
}

View File

@ -0,0 +1,179 @@
/*
* Copyright (c) 1996, 2003 VIA Networking Technologies, Inc.
* All rights reserved.
*
* This program is free software; you can redistribute it and/or modify
* it under the terms of the GNU General Public License as published by
* the Free Software Foundation; either version 2 of the License, or
* (at your option) any later version.
*
* This program is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
* GNU General Public License for more details.
*
* You should have received a copy of the GNU General Public License along
* with this program; if not, write to the Free Software Foundation, Inc.,
* 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA.
*
*
* File: srom.h
*
* Purpose: Implement functions to access eeprom
*
* Author: Jerry Chen
*
* Date: Jan 29, 2003
*
*/
#ifndef __SROM_H__
#define __SROM_H__
#if !defined(__TTYPE_H__)
#include "ttype.h"
#endif
/*--------------------- Export Definitions -------------------------*/
#define EEP_MAX_CONTEXT_SIZE 256
#define CB_EEPROM_READBYTE_WAIT 900 //us
#define W_MAX_I2CRETRY 0x0fff
//
// Contents in the EEPROM
//
#define EEP_OFS_PAR 0x00 // physical address
#define EEP_OFS_ANTENNA 0x16
#define EEP_OFS_RADIOCTL 0x17
#define EEP_OFS_RFTYPE 0x1B // for select RF
#define EEP_OFS_MINCHANNEL 0x1C // Min Channel #
#define EEP_OFS_MAXCHANNEL 0x1D // Max Channel #
#define EEP_OFS_SIGNATURE 0x1E //
#define EEP_OFS_ZONETYPE 0x1F //
#define EEP_OFS_RFTABLE 0x20 // RF POWER TABLE
#define EEP_OFS_PWR_CCK 0x20
#define EEP_OFS_SETPT_CCK 0x21
#define EEP_OFS_PWR_OFDMG 0x23
#define EEP_OFS_SETPT_OFDMG 0x24
#define EEP_OFS_PWR_FORMULA_OST 0x26 //
#define EEP_OFS_MAJOR_VER 0x2E
#define EEP_OFS_MINOR_VER 0x2F
#define EEP_OFS_CCK_PWR_TBL 0x30
#define EEP_OFS_CCK_PWR_dBm 0x3F
#define EEP_OFS_OFDM_PWR_TBL 0x40
#define EEP_OFS_OFDM_PWR_dBm 0x4F
//{{ RobertYu: 20041124
#define EEP_OFS_SETPT_OFDMA 0x4E
#define EEP_OFS_OFDMA_PWR_TBL 0x50
//}}
#define EEP_OFS_OFDMA_PWR_dBm 0xD2
//----------need to remove --------------------
#define EEP_OFS_BBTAB_LEN 0x70 // BB Table Length
#define EEP_OFS_BBTAB_ADR 0x71 // BB Table Offset
#define EEP_OFS_CHECKSUM 0xFF // reserved area for baseband 28h ~ 78h
#define EEP_I2C_DEV_ID 0x50 // EEPROM device address on the I2C bus
//
// Bits in EEP_OFS_ANTENNA
//
#define EEP_ANTENNA_MAIN 0x01
#define EEP_ANTENNA_AUX 0x02
#define EEP_ANTINV 0x04
//
// Bits in EEP_OFS_RADIOCTL
//
#define EEP_RADIOCTL_ENABLE 0x80
#define EEP_RADIOCTL_INV 0x01
/*--------------------- Export Types ------------------------------*/
// AT24C02 eeprom contents
// 2048 bits = 256 bytes = 128 words
//
typedef struct tagSSromReg {
BYTE abyPAR[6]; // 0x00 (WORD)
WORD wSUB_VID; // 0x03 (WORD)
WORD wSUB_SID;
BYTE byBCFG0; // 0x05 (WORD)
BYTE byBCFG1;
BYTE byFCR0; // 0x06 (WORD)
BYTE byFCR1;
BYTE byPMC0; // 0x07 (WORD)
BYTE byPMC1;
BYTE byMAXLAT; // 0x08 (WORD)
BYTE byMINGNT;
BYTE byCFG0; // 0x09 (WORD)
BYTE byCFG1;
WORD wCISPTR; // 0x0A (WORD)
WORD wRsv0; // 0x0B (WORD)
WORD wRsv1; // 0x0C (WORD)
BYTE byBBPAIR; // 0x0D (WORD)
BYTE byRFTYPE;
BYTE byMinChannel; // 0x0E (WORD)
BYTE byMaxChannel;
BYTE bySignature; // 0x0F (WORD)
BYTE byCheckSum;
BYTE abyReserved0[96]; // 0x10 (WORD)
BYTE abyCIS[128]; // 0x80 (WORD)
} SSromReg, DEF* PSSromReg;
/*--------------------- Export Macros ------------------------------*/
/*--------------------- Export Classes ----------------------------*/
/*--------------------- Export Variables --------------------------*/
/*--------------------- Export Functions --------------------------*/
#ifdef __cplusplus
extern "C" { /* Assume C declarations for C++ */
#endif /* __cplusplus */
BYTE SROMbyReadEmbedded(DWORD_PTR dwIoBase, BYTE byContntOffset);
BOOL SROMbWriteEmbedded(DWORD_PTR dwIoBase, BYTE byContntOffset, BYTE byData);
void SROMvRegBitsOn(DWORD_PTR dwIoBase, BYTE byContntOffset, BYTE byBits);
void SROMvRegBitsOff(DWORD_PTR dwIoBase, BYTE byContntOffset, BYTE byBits);
BOOL SROMbIsRegBitsOn(DWORD_PTR dwIoBase, BYTE byContntOffset, BYTE byTestBits);
BOOL SROMbIsRegBitsOff(DWORD_PTR dwIoBase, BYTE byContntOffset, BYTE byTestBits);
void SROMvReadAllContents(DWORD_PTR dwIoBase, PBYTE pbyEepromRegs);
void SROMvWriteAllContents(DWORD_PTR dwIoBase, PBYTE pbyEepromRegs);
void SROMvReadEtherAddress(DWORD_PTR dwIoBase, PBYTE pbyEtherAddress);
void SROMvWriteEtherAddress(DWORD_PTR dwIoBase, PBYTE pbyEtherAddress);
VOID SROMvReadSubSysVenId(DWORD_PTR dwIoBase, PDWORD pdwSubSysVenId);
BOOL SROMbAutoLoad (DWORD_PTR dwIoBase);
#ifdef __cplusplus
} /* End of extern "C" { */
#endif /* __cplusplus */
#endif // __EEPROM_H__

View File

@ -0,0 +1,78 @@
/*
* Copyright (c) 1996, 2003 VIA Networking Technologies, Inc.
* All rights reserved.
*
* This program is free software; you can redistribute it and/or modify
* it under the terms of the GNU General Public License as published by
* the Free Software Foundation; either version 2 of the License, or
* (at your option) any later version.
*
* This program is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
* GNU General Public License for more details.
*
* You should have received a copy of the GNU General Public License along
* with this program; if not, write to the Free Software Foundation, Inc.,
* 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA.
*
*
* File: tbit.h
*
* Purpose: Bit routines
*
* Author: Tevin Chen
*
* Date: May 21, 1996
*
*/
#ifndef __TBIT_H__
#define __TBIT_H__
#if !defined(__TTYPE_H__)
#include "ttype.h"
#endif
/*--------------------- Export Definitions -------------------------*/
/*--------------------- Export Types ------------------------------*/
/*--------------------- Export Macros ------------------------------*/
// test single bit on
#define BITbIsBitOn(tData, tTestBit) \
(((tData) & (tTestBit)) != 0)
// test single bit off
#define BITbIsBitOff(tData, tTestBit) \
(((tData) & (tTestBit)) == 0)
#define BITbIsAllBitsOn(tData, tTestBit) \
(((tData) & (tTestBit)) == (tTestBit))
#define BITbIsAllBitsOff(tData, tTestBit) \
(((tData) & (tTestBit)) == 0)
#define BITbIsAnyBitsOn(tData, tTestBit) \
(((tData) & (tTestBit)) != 0)
#define BITbIsAnyBitsOff(tData, tTestBit) \
(((tData) & (tTestBit)) != (tTestBit))
/*--------------------- Export Classes ----------------------------*/
/*--------------------- Export Variables --------------------------*/
/*--------------------- Export Functions --------------------------*/
#endif // __TBIT_H__

View File

@ -0,0 +1,207 @@
/*
* Copyright (c) 2003 VIA Networking, Inc. All rights reserved.
*
* This program is free software; you can redistribute it and/or modify
* it under the terms of the GNU General Public License as published by
* the Free Software Foundation; either version 2 of the License, or
* (at your option) any later version.
*
* This program is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
* GNU General Public License for more details.
*
* You should have received a copy of the GNU General Public License along
* with this program; if not, write to the Free Software Foundation, Inc.,
* 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA.
*
*
* File: tcrc.c
*
* Purpose: Implement functions to caculate CRC
*
* Author: Tevin Chen
*
* Date: May 21, 1996
*
* Functions:
* CRCdwCrc32 -
* CRCdwGetCrc32 -
* CRCdwGetCrc32Ex -
*
* Revision History:
*
*/
#if !defined(__TBIT_H__)
#include "tbit.h"
#endif
#if !defined(__TCRC_H__)
#include "tcrc.h"
#endif
/*--------------------- Static Definitions -------------------------*/
/*--------------------- Static Classes ----------------------------*/
/*--------------------- Static Variables --------------------------*/
// 32-bit CRC table
static const DWORD s_adwCrc32Table[256] = {
0x00000000L, 0x77073096L, 0xEE0E612CL, 0x990951BAL,
0x076DC419L, 0x706AF48FL, 0xE963A535L, 0x9E6495A3L,
0x0EDB8832L, 0x79DCB8A4L, 0xE0D5E91EL, 0x97D2D988L,
0x09B64C2BL, 0x7EB17CBDL, 0xE7B82D07L, 0x90BF1D91L,
0x1DB71064L, 0x6AB020F2L, 0xF3B97148L, 0x84BE41DEL,
0x1ADAD47DL, 0x6DDDE4EBL, 0xF4D4B551L, 0x83D385C7L,
0x136C9856L, 0x646BA8C0L, 0xFD62F97AL, 0x8A65C9ECL,
0x14015C4FL, 0x63066CD9L, 0xFA0F3D63L, 0x8D080DF5L,
0x3B6E20C8L, 0x4C69105EL, 0xD56041E4L, 0xA2677172L,
0x3C03E4D1L, 0x4B04D447L, 0xD20D85FDL, 0xA50AB56BL,
0x35B5A8FAL, 0x42B2986CL, 0xDBBBC9D6L, 0xACBCF940L,
0x32D86CE3L, 0x45DF5C75L, 0xDCD60DCFL, 0xABD13D59L,
0x26D930ACL, 0x51DE003AL, 0xC8D75180L, 0xBFD06116L,
0x21B4F4B5L, 0x56B3C423L, 0xCFBA9599L, 0xB8BDA50FL,
0x2802B89EL, 0x5F058808L, 0xC60CD9B2L, 0xB10BE924L,
0x2F6F7C87L, 0x58684C11L, 0xC1611DABL, 0xB6662D3DL,
0x76DC4190L, 0x01DB7106L, 0x98D220BCL, 0xEFD5102AL,
0x71B18589L, 0x06B6B51FL, 0x9FBFE4A5L, 0xE8B8D433L,
0x7807C9A2L, 0x0F00F934L, 0x9609A88EL, 0xE10E9818L,
0x7F6A0DBBL, 0x086D3D2DL, 0x91646C97L, 0xE6635C01L,
0x6B6B51F4L, 0x1C6C6162L, 0x856530D8L, 0xF262004EL,
0x6C0695EDL, 0x1B01A57BL, 0x8208F4C1L, 0xF50FC457L,
0x65B0D9C6L, 0x12B7E950L, 0x8BBEB8EAL, 0xFCB9887CL,
0x62DD1DDFL, 0x15DA2D49L, 0x8CD37CF3L, 0xFBD44C65L,
0x4DB26158L, 0x3AB551CEL, 0xA3BC0074L, 0xD4BB30E2L,
0x4ADFA541L, 0x3DD895D7L, 0xA4D1C46DL, 0xD3D6F4FBL,
0x4369E96AL, 0x346ED9FCL, 0xAD678846L, 0xDA60B8D0L,
0x44042D73L, 0x33031DE5L, 0xAA0A4C5FL, 0xDD0D7CC9L,
0x5005713CL, 0x270241AAL, 0xBE0B1010L, 0xC90C2086L,
0x5768B525L, 0x206F85B3L, 0xB966D409L, 0xCE61E49FL,
0x5EDEF90EL, 0x29D9C998L, 0xB0D09822L, 0xC7D7A8B4L,
0x59B33D17L, 0x2EB40D81L, 0xB7BD5C3BL, 0xC0BA6CADL,
0xEDB88320L, 0x9ABFB3B6L, 0x03B6E20CL, 0x74B1D29AL,
0xEAD54739L, 0x9DD277AFL, 0x04DB2615L, 0x73DC1683L,
0xE3630B12L, 0x94643B84L, 0x0D6D6A3EL, 0x7A6A5AA8L,
0xE40ECF0BL, 0x9309FF9DL, 0x0A00AE27L, 0x7D079EB1L,
0xF00F9344L, 0x8708A3D2L, 0x1E01F268L, 0x6906C2FEL,
0xF762575DL, 0x806567CBL, 0x196C3671L, 0x6E6B06E7L,
0xFED41B76L, 0x89D32BE0L, 0x10DA7A5AL, 0x67DD4ACCL,
0xF9B9DF6FL, 0x8EBEEFF9L, 0x17B7BE43L, 0x60B08ED5L,
0xD6D6A3E8L, 0xA1D1937EL, 0x38D8C2C4L, 0x4FDFF252L,
0xD1BB67F1L, 0xA6BC5767L, 0x3FB506DDL, 0x48B2364BL,
0xD80D2BDAL, 0xAF0A1B4CL, 0x36034AF6L, 0x41047A60L,
0xDF60EFC3L, 0xA867DF55L, 0x316E8EEFL, 0x4669BE79L,
0xCB61B38CL, 0xBC66831AL, 0x256FD2A0L, 0x5268E236L,
0xCC0C7795L, 0xBB0B4703L, 0x220216B9L, 0x5505262FL,
0xC5BA3BBEL, 0xB2BD0B28L, 0x2BB45A92L, 0x5CB36A04L,
0xC2D7FFA7L, 0xB5D0CF31L, 0x2CD99E8BL, 0x5BDEAE1DL,
0x9B64C2B0L, 0xEC63F226L, 0x756AA39CL, 0x026D930AL,
0x9C0906A9L, 0xEB0E363FL, 0x72076785L, 0x05005713L,
0x95BF4A82L, 0xE2B87A14L, 0x7BB12BAEL, 0x0CB61B38L,
0x92D28E9BL, 0xE5D5BE0DL, 0x7CDCEFB7L, 0x0BDBDF21L,
0x86D3D2D4L, 0xF1D4E242L, 0x68DDB3F8L, 0x1FDA836EL,
0x81BE16CDL, 0xF6B9265BL, 0x6FB077E1L, 0x18B74777L,
0x88085AE6L, 0xFF0F6A70L, 0x66063BCAL, 0x11010B5CL,
0x8F659EFFL, 0xF862AE69L, 0x616BFFD3L, 0x166CCF45L,
0xA00AE278L, 0xD70DD2EEL, 0x4E048354L, 0x3903B3C2L,
0xA7672661L, 0xD06016F7L, 0x4969474DL, 0x3E6E77DBL,
0xAED16A4AL, 0xD9D65ADCL, 0x40DF0B66L, 0x37D83BF0L,
0xA9BCAE53L, 0xDEBB9EC5L, 0x47B2CF7FL, 0x30B5FFE9L,
0xBDBDF21CL, 0xCABAC28AL, 0x53B39330L, 0x24B4A3A6L,
0xBAD03605L, 0xCDD70693L, 0x54DE5729L, 0x23D967BFL,
0xB3667A2EL, 0xC4614AB8L, 0x5D681B02L, 0x2A6F2B94L,
0xB40BBE37L, 0xC30C8EA1L, 0x5A05DF1BL, 0x2D02EF8DL
};
/*--------------------- Static Functions --------------------------*/
/*--------------------- Export Variables --------------------------*/
/*+
*
* Description:
* Generate a CRC-32 from the data stream
*
* Parameters:
* In:
* pbyData - the data stream
* cbByte - the length of the stream
* dwCrcSeed - Seed for CRC32
* Out:
* none
*
* Return Value: CRC-32
*
-*/
DWORD CRCdwCrc32 (PBYTE pbyData, UINT cbByte, DWORD dwCrcSeed)
{
DWORD dwCrc;
dwCrc = dwCrcSeed;
while (cbByte--) {
dwCrc = s_adwCrc32Table[(BYTE)((dwCrc ^ (*pbyData)) & 0xFF)] ^ (dwCrc >> 8);
pbyData++;
}
return dwCrc;
}
/*+
*
* Description:
* To test CRC generator, input 8 bytes packet
* -- 0xff 0xff 0xff 0xff 0x00 0x00 0x00 0x00
* the generated CRC should be
* -- 0xff 0xff 0xff 0xff
*
* Parameters:
* In:
* pbyData - the data stream
* cbByte - the length of the stream
* Out:
* none
*
* Return Value: CRC-32
*
-*/
DWORD CRCdwGetCrc32 (PBYTE pbyData, UINT cbByte)
{
return ~CRCdwCrc32(pbyData, cbByte, 0xFFFFFFFFL);
}
/*+
*
* Description:
*
* NOTE.... Because CRCdwGetCrc32Ex() is an iteration function,
* this means we will use the output of CRCdwGetCrc32Ex()
* to be a new argument to do next CRCdwGetCrc32Ex() calculation.
* Thus, the final result must be inverted to be the
* correct answer.
*
* Parameters:
* In:
* pbyData - the data stream
* cbByte - the length of the stream
* Out:
* none
*
* Return Value: CRC-32
*
-*/
DWORD CRCdwGetCrc32Ex(PBYTE pbyData, UINT cbByte, DWORD dwPreCRC)
{
return CRCdwCrc32(pbyData, cbByte, dwPreCRC);
}

View File

@ -0,0 +1,71 @@
/*
* Copyright (c) 2003 VIA Networking, Inc. All rights reserved.
*
* This program is free software; you can redistribute it and/or modify
* it under the terms of the GNU General Public License as published by
* the Free Software Foundation; either version 2 of the License, or
* (at your option) any later version.
*
* This program is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
* GNU General Public License for more details.
*
* You should have received a copy of the GNU General Public License along
* with this program; if not, write to the Free Software Foundation, Inc.,
* 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA.
*
*
* File: tcrc.h
*
* Purpose: Implement functions to caculate CRC
*
* Author: Tevin Chen
*
* Date: Jan. 28, 1997
*
*/
#ifndef __TCRC_H__
#define __TCRC_H__
#if !defined(__TTYPE_H__)
#include "ttype.h"
#endif
/*--------------------- Export Definitions -------------------------*/
/*--------------------- Export Types ------------------------------*/
/*--------------------- Export Macros ------------------------------*/
/*--------------------- Export Classes ----------------------------*/
/*--------------------- Export Variables --------------------------*/
/*--------------------- Export Functions --------------------------*/
#ifdef __cplusplus
extern "C" { /* Assume C declarations for C++ */
#endif /* __cplusplus */
DWORD CRCdwCrc32(PBYTE pbyData, UINT cbByte, DWORD dwCrcSeed);
DWORD CRCdwGetCrc32(PBYTE pbyData, UINT cbByte);
DWORD CRCdwGetCrc32Ex(PBYTE pbyData, UINT cbByte, DWORD dwPreCRC);
#ifdef __cplusplus
} /* End of extern "C" { */
#endif /* __cplusplus */
#endif // __TCRC_H__

View File

@ -0,0 +1,9 @@
KSP := /lib/modules/$(shell uname -r)/build \
/usr/src/linux-$(shell uname -r) \
/usr/src/linux-$(shell uname -r | sed 's/-.*//') \
# /usr/src/kernel-headers-$(shell uname -r) \
# /usr/src/kernel-source-$(shell uname -r) \
# /usr/src/linux-$(shell uname -r | sed 's/\([0-9]*\.[0-9]*\)\..*/\1/') \
# /usr/src/linux /home/plice
test_dir = $(shell [ -e $(dir)/include/linux ] && echo $(dir))
KSP := $(foreach dir, $(KSP), $(test_dir))

View File

@ -0,0 +1,123 @@
/*
* Copyright (c) 2003 VIA Networking, Inc. All rights reserved.
*
* This program is free software; you can redistribute it and/or modify
* it under the terms of the GNU General Public License as published by
* the Free Software Foundation; either version 2 of the License, or
* (at your option) any later version.
*
* This program is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
* GNU General Public License for more details.
*
* You should have received a copy of the GNU General Public License along
* with this program; if not, write to the Free Software Foundation, Inc.,
* 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA.
*
*
* File: tether.c
*
* Purpose:
*
* Author: Tevin Chen
*
* Date: May 21, 1996
*
* Functions:
* ETHbyGetHashIndexByCrc32 - Caculate multicast hash value by CRC32
* ETHbIsBufferCrc32Ok - Check CRC value of the buffer if Ok or not
*
* Revision History:
*
*/
#if !defined(__DEVICE_H__)
#include "device.h"
#endif
#if !defined(__TMACRO_H__)
#include "tmacro.h"
#endif
#if !defined(__TBIT_H__)
#include "tbit.h"
#endif
#if !defined(__TCRC_H__)
#include "tcrc.h"
#endif
#if !defined(__TETHER_H__)
#include "tether.h"
#endif
/*--------------------- Static Definitions -------------------------*/
/*--------------------- Static Classes ----------------------------*/
/*--------------------- Static Variables --------------------------*/
/*--------------------- Static Functions --------------------------*/
/*--------------------- Export Variables --------------------------*/
/*
* Description: Caculate multicast hash value by CRC32
*
* Parameters:
* In:
* pbyMultiAddr - Multicast Address
* Out:
* none
*
* Return Value: Hash value
*
*/
BYTE ETHbyGetHashIndexByCrc32 (PBYTE pbyMultiAddr)
{
int ii;
BYTE byTmpHash;
BYTE byHash = 0;
// get the least 6-bits from CRC generator
byTmpHash = (BYTE)(CRCdwCrc32(pbyMultiAddr, U_ETHER_ADDR_LEN,
0xFFFFFFFFL) & 0x3F);
// reverse most bit to least bit
for (ii = 0; ii < (sizeof(byTmpHash) * 8); ii++) {
byHash <<= 1;
if (BITbIsBitOn(byTmpHash, 0x01))
byHash |= 1;
byTmpHash >>= 1;
}
// adjust 6-bits to the right most
return (byHash >> 2);
}
/*
* Description: Check CRC value of the buffer if Ok or not
*
* Parameters:
* In:
* pbyBuffer - pointer of buffer (normally is rx buffer)
* cbFrameLength - length of buffer, including CRC portion
* Out:
* none
*
* Return Value: TRUE if ok; FALSE if error.
*
*/
BOOL ETHbIsBufferCrc32Ok (PBYTE pbyBuffer, UINT cbFrameLength)
{
DWORD dwCRC;
dwCRC = CRCdwGetCrc32(pbyBuffer, cbFrameLength - 4);
if (cpu_to_le32(*((PDWORD)(pbyBuffer + cbFrameLength - 4))) != dwCRC) {
return FALSE;
}
return TRUE;
}

View File

@ -0,0 +1,256 @@
/*
* Copyright (c) 1996, 2003 VIA Networking Technologies, Inc.
* All rights reserved.
*
* This program is free software; you can redistribute it and/or modify
* it under the terms of the GNU General Public License as published by
* the Free Software Foundation; either version 2 of the License, or
* (at your option) any later version.
*
* This program is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
* GNU General Public License for more details.
*
* You should have received a copy of the GNU General Public License along
* with this program; if not, write to the Free Software Foundation, Inc.,
* 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA.
*
* File: tether.h
*
* Purpose:
*
* Author: Tevin Chen
*
* Date: Jan. 28, 1997
*
*/
#ifndef __TETHER_H__
#define __TETHER_H__
#if !defined(__TTYPE_H__)
#include "ttype.h"
#endif
/*--------------------- Export Definitions -------------------------*/
//
// constants
//
#define U_ETHER_ADDR_LEN 6 // Ethernet address length
#define U_TYPE_LEN 2 //
#define U_CRC_LEN 4 //
#define U_HEADER_LEN (U_ETHER_ADDR_LEN * 2 + U_TYPE_LEN)
#define U_ETHER_ADDR_STR_LEN (U_ETHER_ADDR_LEN * 2 + 1)
// Ethernet address string length
#define MIN_DATA_LEN 46 // min data length
#define MAX_DATA_LEN 1500 // max data length
#define MIN_PACKET_LEN (MIN_DATA_LEN + U_HEADER_LEN)
// 60
// min total packet length (tx)
#define MAX_PACKET_LEN (MAX_DATA_LEN + U_HEADER_LEN)
// 1514
// max total packet length (tx)
#define MAX_LOOKAHEAD_SIZE MAX_PACKET_LEN
#define U_MULTI_ADDR_LEN 8 // multicast address length
#ifdef __BIG_ENDIAN
#define TYPE_PKT_IP 0x0800 //
#define TYPE_PKT_ARP 0x0806 //
#define TYPE_PKT_RARP 0x8035 //
#define TYPE_PKT_IPX 0x8137 //
#define TYPE_PKT_802_1x 0x888e
#define TYPE_PKT_PreAuth 0x88C7
#define TYPE_PKT_PING_M_REQ 0x8011 // master reguest
#define TYPE_PKT_PING_S_GNT 0x8022 // slave grant
#define TYPE_PKT_PING_M 0x8077 // pingpong master packet
#define TYPE_PKT_PING_S 0x8088 // pingpong slave packet
#define TYPE_PKT_WOL_M_REQ 0x8033 // WOL waker request
#define TYPE_PKT_WOL_S_GNT 0x8044 // WOL sleeper grant
#define TYPE_MGMT_PROBE_RSP 0x5000
#define TYPE_PKT_VNT_DIAG 0x8011 // Diag Pkt
#define TYPE_PKT_VNT_PER 0x8888 // Diag PER Pkt
//
// wFrameCtl field in the S802_11Header
//
// NOTE....
// in network byte order, high byte is going first
#define FC_TODS 0x0001
#define FC_FROMDS 0x0002
#define FC_MOREFRAG 0x0004
#define FC_RETRY 0x0008
#define FC_POWERMGT 0x0010
#define FC_MOREDATA 0x0020
#define FC_WEP 0x0040
#define TYPE_802_11_ATIM 0x9000
#define TYPE_802_11_DATA 0x0800
#define TYPE_802_11_CTL 0x0400
#define TYPE_802_11_MGMT 0x0000
#define TYPE_802_11_MASK 0x0C00
#define TYPE_SUBTYPE_MASK 0xFC00
#define TYPE_802_11_NODATA 0x4000
#define TYPE_DATE_NULL 0x4800
#define TYPE_CTL_PSPOLL 0xa400
#define TYPE_CTL_RTS 0xb400
#define TYPE_CTL_CTS 0xc400
#define TYPE_CTL_ACK 0xd400
//#define WEP_IV_MASK 0xFFFFFF00
#else //if LITTLE_ENDIAN
//
// wType field in the SEthernetHeader
//
// NOTE....
// in network byte order, high byte is going first
#define TYPE_PKT_IP 0x0008 //
#define TYPE_PKT_ARP 0x0608 //
#define TYPE_PKT_RARP 0x3580 //
#define TYPE_PKT_IPX 0x3781 //
#define TYPE_PKT_802_1x 0x8e88
#define TYPE_PKT_PreAuth 0xC788
#define TYPE_PKT_PING_M_REQ 0x1180 // master reguest
#define TYPE_PKT_PING_S_GNT 0x2280 // slave grant
#define TYPE_PKT_PING_M 0x7780 // pingpong master packet
#define TYPE_PKT_PING_S 0x8880 // pingpong slave packet
#define TYPE_PKT_WOL_M_REQ 0x3380 // WOL waker request
#define TYPE_PKT_WOL_S_GNT 0x4480 // WOL sleeper grant
#define TYPE_MGMT_PROBE_RSP 0x0050
#define TYPE_PKT_VNT_DIAG 0x1180 // Diag Pkt
#define TYPE_PKT_VNT_PER 0x8888 // Diag PER Pkt
//
// wFrameCtl field in the S802_11Header
//
// NOTE....
// in network byte order, high byte is going first
#define FC_TODS 0x0100
#define FC_FROMDS 0x0200
#define FC_MOREFRAG 0x0400
#define FC_RETRY 0x0800
#define FC_POWERMGT 0x1000
#define FC_MOREDATA 0x2000
#define FC_WEP 0x4000
#define TYPE_802_11_ATIM 0x0090
#define TYPE_802_11_DATA 0x0008
#define TYPE_802_11_CTL 0x0004
#define TYPE_802_11_MGMT 0x0000
#define TYPE_802_11_MASK 0x000C
#define TYPE_SUBTYPE_MASK 0x00FC
#define TYPE_802_11_NODATA 0x0040
#define TYPE_DATE_NULL 0x0048
#define TYPE_CTL_PSPOLL 0x00a4
#define TYPE_CTL_RTS 0x00b4
#define TYPE_CTL_CTS 0x00c4
#define TYPE_CTL_ACK 0x00d4
//#define WEP_IV_MASK 0x00FFFFFF
#endif //#ifdef __BIG_ENDIAN
#define WEP_IV_MASK 0x00FFFFFF
/*--------------------- Export Types ------------------------------*/
//
// Ethernet packet
//
typedef struct tagSEthernetHeader {
BYTE abyDstAddr[U_ETHER_ADDR_LEN];
BYTE abySrcAddr[U_ETHER_ADDR_LEN];
WORD wType;
}__attribute__ ((__packed__))
SEthernetHeader, DEF* PSEthernetHeader;
//
// 802_3 packet
//
typedef struct tagS802_3Header {
BYTE abyDstAddr[U_ETHER_ADDR_LEN];
BYTE abySrcAddr[U_ETHER_ADDR_LEN];
WORD wLen;
}__attribute__ ((__packed__))
S802_3Header, DEF* PS802_3Header;
//
// 802_11 packet
//
typedef struct tagS802_11Header {
WORD wFrameCtl;
WORD wDurationID;
BYTE abyAddr1[U_ETHER_ADDR_LEN];
BYTE abyAddr2[U_ETHER_ADDR_LEN];
BYTE abyAddr3[U_ETHER_ADDR_LEN];
WORD wSeqCtl;
BYTE abyAddr4[U_ETHER_ADDR_LEN];
}__attribute__ ((__packed__))
S802_11Header, DEF* PS802_11Header;
/*--------------------- Export Macros ------------------------------*/
// Frame type macro
#define IS_MULTICAST_ADDRESS(pbyEtherAddr) \
((*(PBYTE)(pbyEtherAddr) & 0x01) == 1)
#define IS_BROADCAST_ADDRESS(pbyEtherAddr) ( \
(*(PDWORD)(pbyEtherAddr) == 0xFFFFFFFFL) && \
(*(PWORD)((PBYTE)(pbyEtherAddr) + 4) == 0xFFFF) \
)
#define IS_NULL_ADDRESS(pbyEtherAddr) ( \
(*(PDWORD)(pbyEtherAddr) == 0L) && \
(*(PWORD)((PBYTE)(pbyEtherAddr) + 4) == 0) \
)
#define IS_ETH_ADDRESS_EQUAL(pbyAddr1, pbyAddr2) ( \
(*(PDWORD)(pbyAddr1) == *(PDWORD)(pbyAddr2)) && \
(*(PWORD)((PBYTE)(pbyAddr1) + 4) == \
*(PWORD)((PBYTE)(pbyAddr2) + 4)) \
)
/*--------------------- Export Classes ----------------------------*/
/*--------------------- Export Variables --------------------------*/
/*--------------------- Export Functions --------------------------*/
#ifdef __cplusplus
extern "C" { /* Assume C declarations for C++ */
#endif /* __cplusplus */
BYTE ETHbyGetHashIndexByCrc32(PBYTE pbyMultiAddr);
//BYTE ETHbyGetHashIndexByCrc(PBYTE pbyMultiAddr);
BOOL ETHbIsBufferCrc32Ok(PBYTE pbyBuffer, UINT cbFrameLength);
#ifdef __cplusplus
} /* End of extern "C" { */
#endif /* __cplusplus */
#endif // __TETHER_H__

View File

@ -0,0 +1,284 @@
/*
* Copyright (c) 1996, 2003 VIA Networking Technologies, Inc.
* All rights reserved.
*
* This program is free software; you can redistribute it and/or modify
* it under the terms of the GNU General Public License as published by
* the Free Software Foundation; either version 2 of the License, or
* (at your option) any later version.
*
* This program is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
* GNU General Public License for more details.
*
* You should have received a copy of the GNU General Public License along
* with this program; if not, write to the Free Software Foundation, Inc.,
* 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA.
*
*
* File: tkip.c
*
* Purpose: Implement functions for 802.11i TKIP
*
* Author: Jerry Chen
*
* Date: Mar. 11, 2003
*
* Functions:
* TKIPvMixKey - Get TKIP RC4 Key from TK,TA, and TSC
*
* Revision History:
*
*/
#if !defined(__TMACRO_H__)
#include "tmacro.h"
#endif
#if !defined(__TBIT_H__)
#include "tbit.h"
#endif
#if !defined(__TKIP_H__)
#include "tkip.h"
#endif
#if !defined(__UMEM_H__)
#include "umem.h"
#endif
/*--------------------- Static Definitions -------------------------*/
/*--------------------- Static Classes ----------------------------*/
/*--------------------- Static Variables --------------------------*/
/*--------------------- Static Functions --------------------------*/
/*--------------------- Export Variables --------------------------*/
/*--------------------- Static Definitions -------------------------*/
/*--------------------- Static Classes ----------------------------*/
/*--------------------- Static Variables --------------------------*/
/* The Sbox is reduced to 2 16-bit wide tables, each with 256 entries. */
/* The 2nd table is the same as the 1st but with the upper and lower */
/* bytes swapped. To allow an endian tolerant implementation, the byte */
/* halves have been expressed independently here. */
const BYTE TKIP_Sbox_Lower[256] = {
0xA5,0x84,0x99,0x8D,0x0D,0xBD,0xB1,0x54,
0x50,0x03,0xA9,0x7D,0x19,0x62,0xE6,0x9A,
0x45,0x9D,0x40,0x87,0x15,0xEB,0xC9,0x0B,
0xEC,0x67,0xFD,0xEA,0xBF,0xF7,0x96,0x5B,
0xC2,0x1C,0xAE,0x6A,0x5A,0x41,0x02,0x4F,
0x5C,0xF4,0x34,0x08,0x93,0x73,0x53,0x3F,
0x0C,0x52,0x65,0x5E,0x28,0xA1,0x0F,0xB5,
0x09,0x36,0x9B,0x3D,0x26,0x69,0xCD,0x9F,
0x1B,0x9E,0x74,0x2E,0x2D,0xB2,0xEE,0xFB,
0xF6,0x4D,0x61,0xCE,0x7B,0x3E,0x71,0x97,
0xF5,0x68,0x00,0x2C,0x60,0x1F,0xC8,0xED,
0xBE,0x46,0xD9,0x4B,0xDE,0xD4,0xE8,0x4A,
0x6B,0x2A,0xE5,0x16,0xC5,0xD7,0x55,0x94,
0xCF,0x10,0x06,0x81,0xF0,0x44,0xBA,0xE3,
0xF3,0xFE,0xC0,0x8A,0xAD,0xBC,0x48,0x04,
0xDF,0xC1,0x75,0x63,0x30,0x1A,0x0E,0x6D,
0x4C,0x14,0x35,0x2F,0xE1,0xA2,0xCC,0x39,
0x57,0xF2,0x82,0x47,0xAC,0xE7,0x2B,0x95,
0xA0,0x98,0xD1,0x7F,0x66,0x7E,0xAB,0x83,
0xCA,0x29,0xD3,0x3C,0x79,0xE2,0x1D,0x76,
0x3B,0x56,0x4E,0x1E,0xDB,0x0A,0x6C,0xE4,
0x5D,0x6E,0xEF,0xA6,0xA8,0xA4,0x37,0x8B,
0x32,0x43,0x59,0xB7,0x8C,0x64,0xD2,0xE0,
0xB4,0xFA,0x07,0x25,0xAF,0x8E,0xE9,0x18,
0xD5,0x88,0x6F,0x72,0x24,0xF1,0xC7,0x51,
0x23,0x7C,0x9C,0x21,0xDD,0xDC,0x86,0x85,
0x90,0x42,0xC4,0xAA,0xD8,0x05,0x01,0x12,
0xA3,0x5F,0xF9,0xD0,0x91,0x58,0x27,0xB9,
0x38,0x13,0xB3,0x33,0xBB,0x70,0x89,0xA7,
0xB6,0x22,0x92,0x20,0x49,0xFF,0x78,0x7A,
0x8F,0xF8,0x80,0x17,0xDA,0x31,0xC6,0xB8,
0xC3,0xB0,0x77,0x11,0xCB,0xFC,0xD6,0x3A
};
const BYTE TKIP_Sbox_Upper[256] = {
0xC6,0xF8,0xEE,0xF6,0xFF,0xD6,0xDE,0x91,
0x60,0x02,0xCE,0x56,0xE7,0xB5,0x4D,0xEC,
0x8F,0x1F,0x89,0xFA,0xEF,0xB2,0x8E,0xFB,
0x41,0xB3,0x5F,0x45,0x23,0x53,0xE4,0x9B,
0x75,0xE1,0x3D,0x4C,0x6C,0x7E,0xF5,0x83,
0x68,0x51,0xD1,0xF9,0xE2,0xAB,0x62,0x2A,
0x08,0x95,0x46,0x9D,0x30,0x37,0x0A,0x2F,
0x0E,0x24,0x1B,0xDF,0xCD,0x4E,0x7F,0xEA,
0x12,0x1D,0x58,0x34,0x36,0xDC,0xB4,0x5B,
0xA4,0x76,0xB7,0x7D,0x52,0xDD,0x5E,0x13,
0xA6,0xB9,0x00,0xC1,0x40,0xE3,0x79,0xB6,
0xD4,0x8D,0x67,0x72,0x94,0x98,0xB0,0x85,
0xBB,0xC5,0x4F,0xED,0x86,0x9A,0x66,0x11,
0x8A,0xE9,0x04,0xFE,0xA0,0x78,0x25,0x4B,
0xA2,0x5D,0x80,0x05,0x3F,0x21,0x70,0xF1,
0x63,0x77,0xAF,0x42,0x20,0xE5,0xFD,0xBF,
0x81,0x18,0x26,0xC3,0xBE,0x35,0x88,0x2E,
0x93,0x55,0xFC,0x7A,0xC8,0xBA,0x32,0xE6,
0xC0,0x19,0x9E,0xA3,0x44,0x54,0x3B,0x0B,
0x8C,0xC7,0x6B,0x28,0xA7,0xBC,0x16,0xAD,
0xDB,0x64,0x74,0x14,0x92,0x0C,0x48,0xB8,
0x9F,0xBD,0x43,0xC4,0x39,0x31,0xD3,0xF2,
0xD5,0x8B,0x6E,0xDA,0x01,0xB1,0x9C,0x49,
0xD8,0xAC,0xF3,0xCF,0xCA,0xF4,0x47,0x10,
0x6F,0xF0,0x4A,0x5C,0x38,0x57,0x73,0x97,
0xCB,0xA1,0xE8,0x3E,0x96,0x61,0x0D,0x0F,
0xE0,0x7C,0x71,0xCC,0x90,0x06,0xF7,0x1C,
0xC2,0x6A,0xAE,0x69,0x17,0x99,0x3A,0x27,
0xD9,0xEB,0x2B,0x22,0xD2,0xA9,0x07,0x33,
0x2D,0x3C,0x15,0xC9,0x87,0xAA,0x50,0xA5,
0x03,0x59,0x09,0x1A,0x65,0xD7,0x84,0xD0,
0x82,0x29,0x5A,0x1E,0x7B,0xA8,0x6D,0x2C
};
//STKIPKeyManagement sTKIPKeyTable[MAX_TKIP_KEY];
/*--------------------- Static Functions --------------------------*/
unsigned int tkip_sbox(unsigned int index);
unsigned int rotr1(unsigned int a);
/*--------------------- Export Variables --------------------------*/
/************************************************************/
/* tkip_sbox() */
/* Returns a 16 bit value from a 64K entry table. The Table */
/* is synthesized from two 256 entry byte wide tables. */
/************************************************************/
unsigned int tkip_sbox(unsigned int index)
{
unsigned int index_low;
unsigned int index_high;
unsigned int left, right;
index_low = (index % 256);
index_high = ((index >> 8) % 256);
left = TKIP_Sbox_Lower[index_low] + (TKIP_Sbox_Upper[index_low] * 256);
right = TKIP_Sbox_Upper[index_high] + (TKIP_Sbox_Lower[index_high] * 256);
return (left ^ right);
};
unsigned int rotr1(unsigned int a)
{
unsigned int b;
if ((a & 0x01) == 0x01) {
b = (a >> 1) | 0x8000;
} else {
b = (a >> 1) & 0x7fff;
}
b = b % 65536;
return b;
}
/*
* Description: Caculate RC4Key fom TK, TA, and TSC
*
* Parameters:
* In:
* pbyTKey - TKey
* pbyTA - TA
* dwTSC - TSC
* Out:
* pbyRC4Key - RC4Key
*
* Return Value: none
*
*/
VOID TKIPvMixKey(
PBYTE pbyTKey,
PBYTE pbyTA,
WORD wTSC15_0,
DWORD dwTSC47_16,
PBYTE pbyRC4Key
)
{
unsigned int p1k[5];
// unsigned int ttak0, ttak1, ttak2, ttak3, ttak4;
unsigned int tsc0, tsc1, tsc2;
unsigned int ppk0, ppk1, ppk2, ppk3, ppk4, ppk5;
unsigned long int pnl,pnh;
int i, j;
pnl = wTSC15_0;
pnh = dwTSC47_16;
tsc0 = (unsigned int)((pnh >> 16) % 65536); /* msb */
tsc1 = (unsigned int)(pnh % 65536);
tsc2 = (unsigned int)(pnl % 65536); /* lsb */
/* Phase 1, step 1 */
p1k[0] = tsc1;
p1k[1] = tsc0;
p1k[2] = (unsigned int)(pbyTA[0] + (pbyTA[1]*256));
p1k[3] = (unsigned int)(pbyTA[2] + (pbyTA[3]*256));
p1k[4] = (unsigned int)(pbyTA[4] + (pbyTA[5]*256));
/* Phase 1, step 2 */
for (i=0; i<8; i++) {
j = 2*(i & 1);
p1k[0] = (p1k[0] + tkip_sbox( (p1k[4] ^ ((256*pbyTKey[1+j]) + pbyTKey[j])) % 65536 )) % 65536;
p1k[1] = (p1k[1] + tkip_sbox( (p1k[0] ^ ((256*pbyTKey[5+j]) + pbyTKey[4+j])) % 65536 )) % 65536;
p1k[2] = (p1k[2] + tkip_sbox( (p1k[1] ^ ((256*pbyTKey[9+j]) + pbyTKey[8+j])) % 65536 )) % 65536;
p1k[3] = (p1k[3] + tkip_sbox( (p1k[2] ^ ((256*pbyTKey[13+j]) + pbyTKey[12+j])) % 65536 )) % 65536;
p1k[4] = (p1k[4] + tkip_sbox( (p1k[3] ^ (((256*pbyTKey[1+j]) + pbyTKey[j]))) % 65536 )) % 65536;
p1k[4] = (p1k[4] + i) % 65536;
}
/* Phase 2, Step 1 */
ppk0 = p1k[0];
ppk1 = p1k[1];
ppk2 = p1k[2];
ppk3 = p1k[3];
ppk4 = p1k[4];
ppk5 = (p1k[4] + tsc2) % 65536;
/* Phase2, Step 2 */
ppk0 = ppk0 + tkip_sbox( (ppk5 ^ ((256*pbyTKey[1]) + pbyTKey[0])) % 65536);
ppk1 = ppk1 + tkip_sbox( (ppk0 ^ ((256*pbyTKey[3]) + pbyTKey[2])) % 65536);
ppk2 = ppk2 + tkip_sbox( (ppk1 ^ ((256*pbyTKey[5]) + pbyTKey[4])) % 65536);
ppk3 = ppk3 + tkip_sbox( (ppk2 ^ ((256*pbyTKey[7]) + pbyTKey[6])) % 65536);
ppk4 = ppk4 + tkip_sbox( (ppk3 ^ ((256*pbyTKey[9]) + pbyTKey[8])) % 65536);
ppk5 = ppk5 + tkip_sbox( (ppk4 ^ ((256*pbyTKey[11]) + pbyTKey[10])) % 65536);
ppk0 = ppk0 + rotr1(ppk5 ^ ((256*pbyTKey[13]) + pbyTKey[12]));
ppk1 = ppk1 + rotr1(ppk0 ^ ((256*pbyTKey[15]) + pbyTKey[14]));
ppk2 = ppk2 + rotr1(ppk1);
ppk3 = ppk3 + rotr1(ppk2);
ppk4 = ppk4 + rotr1(ppk3);
ppk5 = ppk5 + rotr1(ppk4);
/* Phase 2, Step 3 */
pbyRC4Key[0] = (tsc2 >> 8) % 256;
pbyRC4Key[1] = (((tsc2 >> 8) % 256) | 0x20) & 0x7f;
pbyRC4Key[2] = tsc2 % 256;
pbyRC4Key[3] = ((ppk5 ^ ((256*pbyTKey[1]) + pbyTKey[0])) >> 1) % 256;
pbyRC4Key[4] = ppk0 % 256;
pbyRC4Key[5] = (ppk0 >> 8) % 256;
pbyRC4Key[6] = ppk1 % 256;
pbyRC4Key[7] = (ppk1 >> 8) % 256;
pbyRC4Key[8] = ppk2 % 256;
pbyRC4Key[9] = (ppk2 >> 8) % 256;
pbyRC4Key[10] = ppk3 % 256;
pbyRC4Key[11] = (ppk3 >> 8) % 256;
pbyRC4Key[12] = ppk4 % 256;
pbyRC4Key[13] = (ppk4 >> 8) % 256;
pbyRC4Key[14] = ppk5 % 256;
pbyRC4Key[15] = (ppk5 >> 8) % 256;
}

View File

@ -0,0 +1,76 @@
/*
* Copyright (c) 1996, 2003 VIA Networking Technologies, Inc.
* All rights reserved.
*
* This program is free software; you can redistribute it and/or modify
* it under the terms of the GNU General Public License as published by
* the Free Software Foundation; either version 2 of the License, or
* (at your option) any later version.
*
* This program is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
* GNU General Public License for more details.
*
* You should have received a copy of the GNU General Public License along
* with this program; if not, write to the Free Software Foundation, Inc.,
* 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA.
*
*
* File: tkip.h
*
* Purpose: Implement functions for 802.11i TKIP
*
* Author: Jerry Chen
*
* Date: Mar. 11, 2003
*
*/
#ifndef __TKIP_H__
#define __TKIP_H__
#if !defined(__TTYPE_H__)
#include "ttype.h"
#endif
#if !defined(__TETHER_H__)
#include "tether.h"
#endif
/*--------------------- Export Definitions -------------------------*/
#define TKIP_KEY_LEN 16
/*--------------------- Export Types ------------------------------*/
/*--------------------- Export Macros ------------------------------*/
/*--------------------- Export Classes ----------------------------*/
/*--------------------- Export Variables --------------------------*/
/*--------------------- Export Functions --------------------------*/
#ifdef __cplusplus
extern "C" { /* Assume C declarations for C++ */
#endif /* __cplusplus */
VOID TKIPvMixKey(
PBYTE pbyTKey,
PBYTE pbyTA,
WORD wTSC15_0,
DWORD dwTSC47_16,
PBYTE pbyRC4Key
);
#ifdef __cplusplus
} /* End of extern "C" { */
#endif /* __cplusplus */
#endif // __TKIP_H__

View File

@ -0,0 +1,152 @@
/*
* Copyright (c) 1996, 2003 VIA Networking Technologies, Inc.
* All rights reserved.
*
* This program is free software; you can redistribute it and/or modify
* it under the terms of the GNU General Public License as published by
* the Free Software Foundation; either version 2 of the License, or
* (at your option) any later version.
*
* This program is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
* GNU General Public License for more details.
*
* You should have received a copy of the GNU General Public License along
* with this program; if not, write to the Free Software Foundation, Inc.,
* 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA.
*
* File: tmacro.h
*
* Purpose: define basic common types and macros
*
* Author: Tevin Chen
*
* Date: May 21, 1996
*
*/
#ifndef __TMACRO_H__
#define __TMACRO_H__
#if !defined(__TTYPE_H__)
#include "ttype.h"
#endif
/****** Common helper macros ***********************************************/
#if !defined(LONIBBLE)
#define LONIBBLE(b) ((BYTE)(b) & 0x0F)
#endif
#if !defined(HINIBBLE)
#define HINIBBLE(b) ((BYTE)(((WORD)(b) >> 4) & 0x0F))
#endif
#if !defined(LOBYTE)
#define LOBYTE(w) ((BYTE)(w))
#endif
#if !defined(HIBYTE)
#define HIBYTE(w) ((BYTE)(((WORD)(w) >> 8) & 0xFF))
#endif
#if !defined(LOWORD)
#define LOWORD(d) ((WORD)(d))
#endif
#if !defined(HIWORD)
#define HIWORD(d) ((WORD)((((DWORD)(d)) >> 16) & 0xFFFF))
#endif
#define LODWORD(q) ((q).u.dwLowDword)
#define HIDWORD(q) ((q).u.dwHighDword)
#if !defined(MAKEBYTE)
#define MAKEBYTE(ln, hn) ((BYTE)(((BYTE)(ln) & 0x0F) | ((BYTE)(hn) << 4)))
#endif
#if !defined(MAKEWORD)
#define MAKEWORD(lb, hb) ((WORD)(((BYTE)(lb)) | (((WORD)((BYTE)(hb))) << 8)))
#endif
#if !defined(MAKEDWORD)
#define MAKEDWORD(lw, hw) ((DWORD)(((WORD)(lw)) | (((DWORD)((WORD)(hw))) << 16)))
#endif
#if !defined(MAKEQWORD)
#define MAKEQWORD(ld, hd, pq) {pq->u.dwLowDword = ld; pq->u.dwHighDword = hd;}
#endif
#if !defined(MAKELONG)
#define MAKELONG(low, high) ((LONG)(((WORD)(low)) | (((DWORD)((WORD)(high))) << 16)))
#endif
// Bytes Reverse: big endian to little endian convert
#if !defined(REVWORD)
#define REVWORD(w) ((WORD)( ((WORD)(w) >> 8) | ((WORD)(w) << 8) ))
#endif
#if !defined(REVDWORD)
#define REVDWORD(d) (MAKEDWORD(MAKEWORD(HIBYTE(HIWORD(d)),LOBYTE(HIWORD(d))),MAKEWORD(HIBYTE(LOWORD(d)),LOBYTE(LOWORD(d)))))
#endif
/* map to known network names */
/*
#define ntohs(x) REVWORD(x)
#define ntohl(x) REVDWORD(x)
#define htons(x) REVWORD(x)
#define htonl(x) REVDWORD(x)
*/
/*
#ifndef NOMINMAX
#ifndef max
#define max(a,b) (((a) > (b)) ? (a) : (b))
#endif
#ifndef min
#define min(a,b) (((a) < (b)) ? (a) : (b))
#endif
#endif // NOMINMAX
*/
/****** Misc macros ********************************************************/
// get the field offset in the type(struct, class, ...)
#define OFFSET(type, field) ((int)(&((type NEAR*)1)->field)-1)
/* string equality shorthand */
#define STR_EQ(x, y) (strcmp(x, y) == 0)
#define STR_NE(x, y) (strcmp(x, y) != 0)
// calculate element # of array
#define ELEMENT_NUM(array) (sizeof(array) / sizeof(array[0]))
//#define ARRAY_SIZE(a) (sizeof(a) / sizeof(a[0]))
// null statement
#define NULL_FUNC()
/* Since not all compilers support structure assignment, the ASSIGN()
* macro is used. This controls how it's actually implemented.
*/
#ifdef NOSTRUCTASSIGN /* Version for old compilers that don't support it */
#define ASSIGN(a,b) memcpy((char *)&(a),(char *)&(b),sizeof(b);
#else /* Version for compilers that do */
#define ASSIGN(a,b) ((a) = (b))
#endif
#endif // __TMACRO_H__

View File

@ -0,0 +1,117 @@
/*
* Copyright (c) 1996, 2003 VIA Networking Technologies, Inc.
* All rights reserved.
*
* This program is free software; you can redistribute it and/or modify
* it under the terms of the GNU General Public License as published by
* the Free Software Foundation; either version 2 of the License, or
* (at your option) any later version.
*
* This program is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
* GNU General Public License for more details.
*
* You should have received a copy of the GNU General Public License along
* with this program; if not, write to the Free Software Foundation, Inc.,
* 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA.
*
*
* File: tpci.h
*
* Purpose: PCI routines
*
* Author: Tevin Chen
*
* Date: May 21, 1996
*
*/
#ifndef __TPCI_H__
#define __TPCI_H__
#if !defined(__TTYPE_H__)
#include "ttype.h"
#endif
/*--------------------- Export Definitions -------------------------*/
#define MAX_PCI_BUS 4 // max. # of PCI bus that we support
#define MAX_PCI_DEVICE 32 // max. # of PCI devices
//
// Registers in the PCI configuration space
//
#define PCI_REG_VENDOR_ID 0x00 //
#define PCI_REG_DEVICE_ID 0x02 //
#define PCI_REG_COMMAND 0x04 //
#define PCI_REG_STATUS 0x06 //
#define PCI_REG_REV_ID 0x08 //
#define PCI_REG_CLASS_CODE 0x09 //
#define PCI_REG_CACHELINE_SIZE 0x0C //
#define PCI_REG_LAT_TIMER 0x0D //
#define PCI_REG_HDR_TYPE 0x0E //
#define PCI_REG_BIST 0x0F //
#define PCI_REG_BAR0 0x10 //
#define PCI_REG_BAR1 0x14 //
#define PCI_REG_BAR2 0x18 //
#define PCI_REG_CARDBUS_CIS_PTR 0x28 //
#define PCI_REG_SUB_VEN_ID 0x2C //
#define PCI_REG_SUB_SYS_ID 0x2E //
#define PCI_REG_EXP_ROM_BAR 0x30 //
#define PCI_REG_CAP 0x34 //
#define PCI_REG_INT_LINE 0x3C //
#define PCI_REG_INT_PIN 0x3D //
#define PCI_REG_MIN_GNT 0x3E //
#define PCI_REG_MAX_LAT 0x3F //
#define PCI_REG_MAX_SIZE 0x100 // maximun total PCI registers
//
// Bits in the COMMAND register
//
#define COMMAND_BUSM 0x04 //
#define COMMAND_WAIT 0x80 //
/*--------------------- Export Types ------------------------------*/
/*--------------------- Export Macros ------------------------------*/
// macro MAKE Bus Dev Fun ID into WORD
#define MAKE_BDF_TO_WORD(byBusId, byDevId, byFunId) \
MAKEWORD( \
((((BYTE)(byDevId)) & 0x1F) << 3) + \
(((BYTE)(byFunId)) & 0x07), \
(byBusId) \
)
#define GET_BUSID(wBusDevFunId) \
HIBYTE(wBusDevFunId)
#define GET_DEVID(wBusDevFunId) \
(LOBYTE(wBusDevFunId) >> 3)
#define GET_FUNID(wBusDevFunId) \
(LOBYTE(wBusDevFunId) & 0x07)
/*--------------------- Export Classes ----------------------------*/
/*--------------------- Export Variables --------------------------*/
/*--------------------- Export Functions --------------------------*/
#endif // __TPCI_H__

View File

@ -0,0 +1,75 @@
/*
* Copyright (c) 1996, 2003 VIA Networking Technologies, Inc.
* All rights reserved.
*
* This program is free software; you can redistribute it and/or modify
* it under the terms of the GNU General Public License as published by
* the Free Software Foundation; either version 2 of the License, or
* (at your option) any later version.
*
* This program is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
* GNU General Public License for more details.
*
* You should have received a copy of the GNU General Public License along
* with this program; if not, write to the Free Software Foundation, Inc.,
* 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA.
*
*
* File: umem.h
*
* Purpose: Define Memory macros
*
* Author: Tevin Chen
*
* Date: Mar 17, 1997
*
*/
#ifndef __UMEM_H__
#define __UMEM_H__
#if !defined(__TTYPE_H__)
#include "ttype.h"
#endif
/*--------------------- Export Definitions -------------------------*/
// 4-byte memory tag
#define MEM_TAG 'mTEW'
// Macros used for memory allocation and deallocation.
#define ZERO_MEMORY(Destination,Length) { \
memset((PVOID)(Destination), \
0, \
(ULONG)(Length) \
); \
}
#define MEMvCopy(pvDest, pvSource, uCount) { \
memcpy((PVOID)(pvDest), \
(PVOID)(pvSource), \
(ULONG)(uCount) \
); \
}
#define MEMEqualMemory(Destination,Source,Length) (!memcmp((Destination),(Source),(Length)))
/*--------------------- Export Classes ----------------------------*/
/*--------------------- Export Variables --------------------------*/
/*--------------------- Export Functions --------------------------*/
#endif // __UMEM_H__

View File

@ -0,0 +1,171 @@
/*
* Copyright (c) 1996, 2003 VIA Networking Technologies, Inc.
* All rights reserved.
*
* This program is free software; you can redistribute it and/or modify
* it under the terms of the GNU General Public License as published by
* the Free Software Foundation; either version 2 of the License, or
* (at your option) any later version.
*
* This program is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
* GNU General Public License for more details.
*
* You should have received a copy of the GNU General Public License along
* with this program; if not, write to the Free Software Foundation, Inc.,
* 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA.
*
* File: upc.h
*
* Purpose: Macros to access device
*
* Author: Tevin Chen
*
* Date: Mar 17, 1997
*
*/
#ifndef __UPC_H__
#define __UPC_H__
#if !defined(DEVICE_H)
#include "device.h"
#endif
#if !defined(__TTYPE_H__)
#include "ttype.h"
#endif
/*--------------------- Export Definitions -------------------------*/
//
// For IO mapped
//
#ifdef IO_MAP
#define VNSvInPortB(dwIOAddress, pbyData) { \
*(pbyData) = inb(dwIOAddress); \
}
#define VNSvInPortW(dwIOAddress, pwData) { \
*(pwData) = inw(dwIOAddress); \
}
#define VNSvInPortD(dwIOAddress, pdwData) { \
*(pdwData) = inl(dwIOAddress); \
}
#define VNSvOutPortB(dwIOAddress, byData) { \
outb(byData, dwIOAddress); \
}
#define VNSvOutPortW(dwIOAddress, wData) { \
outw(wData, dwIOAddress); \
}
#define VNSvOutPortD(dwIOAddress, dwData) { \
outl(dwData, dwIOAddress); \
}
#else
//
// For memory mapped IO
//
#define VNSvInPortB(dwIOAddress, pbyData) { \
volatile BYTE* pbyAddr = ((PBYTE)(dwIOAddress)); \
*(pbyData) = readb(pbyAddr); \
}
#define VNSvInPortW(dwIOAddress, pwData) { \
volatile WORD* pwAddr = ((PWORD)(dwIOAddress)); \
*(pwData) = readw(pwAddr); \
}
#define VNSvInPortD(dwIOAddress, pdwData) { \
volatile DWORD* pdwAddr = ((PDWORD)(dwIOAddress)); \
*(pdwData) = readl(pdwAddr); \
}
#define VNSvOutPortB(dwIOAddress, byData) { \
volatile BYTE* pbyAddr = ((PBYTE)(dwIOAddress)); \
writeb((BYTE)byData, pbyAddr); \
}
#define VNSvOutPortW(dwIOAddress, wData) { \
volatile WORD* pwAddr = ((PWORD)(dwIOAddress)); \
writew((WORD)wData, pwAddr); \
}
#define VNSvOutPortD(dwIOAddress, dwData) { \
volatile DWORD* pdwAddr = ((PDWORD)(dwIOAddress)); \
writel((DWORD)dwData, pdwAddr); \
}
#endif
//
// ALWAYS IO-Mapped IO when in 16-bit/32-bit environment
//
#define PCBvInPortB(dwIOAddress, pbyData) { \
*(pbyData) = inb(dwIOAddress); \
}
#define PCBvInPortW(dwIOAddress, pwData) { \
*(pwData) = inw(dwIOAddress); \
}
#define PCBvInPortD(dwIOAddress, pdwData) { \
*(pdwData) = inl(dwIOAddress); \
}
#define PCBvOutPortB(dwIOAddress, byData) { \
outb(byData, dwIOAddress); \
}
#define PCBvOutPortW(dwIOAddress, wData) { \
outw(wData, dwIOAddress); \
}
#define PCBvOutPortD(dwIOAddress, dwData) { \
outl(dwData, dwIOAddress); \
}
#define PCAvDelayByIO(uDelayUnit) { \
BYTE byData; \
ULONG ii; \
\
if (uDelayUnit <= 50) { \
udelay(uDelayUnit); \
} \
else { \
for (ii = 0; ii < (uDelayUnit); ii++) \
byData = inb(0x61); \
} \
}
/*--------------------- Export Classes ----------------------------*/
/*--------------------- Export Variables --------------------------*/
/*--------------------- Export Functions --------------------------*/
#endif // __UPC_H__

View File

@ -0,0 +1 @@
ZONETYPE=EUROPE

View File

@ -0,0 +1,832 @@
/*
* Copyright (c) 1996, 2003 VIA Networking Technologies, Inc.
* All rights reserved.
*
* This program is free software; you can redistribute it and/or modify
* it under the terms of the GNU General Public License as published by
* the Free Software Foundation; either version 2 of the License, or
* (at your option) any later version.
*
* This program is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
* GNU General Public License for more details.
*
* You should have received a copy of the GNU General Public License along
* with this program; if not, write to the Free Software Foundation, Inc.,
* 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA.
*
*
* File: vntwifi.c
*
* Purpose: export functions for vntwifi lib
*
* Functions:
*
* Revision History:
*
* Author: Yiching Chen
*
* Date: feb. 2, 2005
*
*/
#if !defined(__VNTWIFI_H__)
#include "vntwifi.h"
#endif
#if !defined(__UMEM_H__)
#include "umem.h"
#endif
#if !defined(__TBIT_H__)
#include "tbit.h"
#endif
#if !defined(__IEEE11h_H__)
#include "IEEE11h.h"
#endif
#if !defined(__COUNTRY_H__)
#include "country.h"
#endif
#if !defined(__DEVICE_H__)
#include "device.h"
#endif
#if !defined(__WMGR_H__)
#include "wmgr.h"
#endif
#if !defined(__DATARATE_H__)
#include "datarate.h"
#endif
//#define PLICE_DEBUG
/*--------------------- Static Definitions -------------------------*/
//static int msglevel =MSG_LEVEL_DEBUG;
//static int msglevel =MSG_LEVEL_INFO;
/*--------------------- Static Classes ----------------------------*/
/*--------------------- Static Variables --------------------------*/
/*--------------------- Static Functions --------------------------*/
/*--------------------- Export Variables --------------------------*/
/*--------------------- Export Functions --------------------------*/
/*+
*
* Description:
* Set Operation Mode
*
* Parameters:
* In:
* pMgmtHandle - pointer to management object
* eOPMode - Opreation Mode
* Out:
* none
*
* Return Value: none
*
-*/
VOID
VNTWIFIvSetOPMode (
IN PVOID pMgmtHandle,
IN WMAC_CONFIG_MODE eOPMode
)
{
PSMgmtObject pMgmt = (PSMgmtObject)pMgmtHandle;
pMgmt->eConfigMode = eOPMode;
}
/*+
*
* Description:
* Set Operation Mode
*
* Parameters:
* In:
* pMgmtHandle - pointer to management object
* wBeaconPeriod - Beacon Period
* wATIMWindow - ATIM window
* uChannel - channel number
* Out:
* none
*
* Return Value: none
*
-*/
VOID
VNTWIFIvSetIBSSParameter (
IN PVOID pMgmtHandle,
IN WORD wBeaconPeriod,
IN WORD wATIMWindow,
IN UINT uChannel
)
{
PSMgmtObject pMgmt = (PSMgmtObject)pMgmtHandle;
pMgmt->wIBSSBeaconPeriod = wBeaconPeriod;
pMgmt->wIBSSATIMWindow = wATIMWindow;
pMgmt->uIBSSChannel = uChannel;
}
/*+
*
* Description:
* Get current SSID
*
* Parameters:
* In:
* pMgmtHandle - pointer to management object
* Out:
* none
*
* Return Value: current SSID pointer.
*
-*/
PWLAN_IE_SSID
VNTWIFIpGetCurrentSSID (
IN PVOID pMgmtHandle
)
{
PSMgmtObject pMgmt = (PSMgmtObject)pMgmtHandle;
return((PWLAN_IE_SSID) pMgmt->abyCurrSSID);
}
/*+
*
* Description:
* Get current link channel
*
* Parameters:
* In:
* pMgmtHandle - pointer to management object
* Out:
* none
*
* Return Value: current Channel.
*
-*/
UINT
VNTWIFIpGetCurrentChannel (
IN PVOID pMgmtHandle
)
{
PSMgmtObject pMgmt = (PSMgmtObject)pMgmtHandle;
if (pMgmtHandle != NULL) {
return (pMgmt->uCurrChannel);
}
return 0;
}
/*+
*
* Description:
* Get current Assoc ID
*
* Parameters:
* In:
* pMgmtHandle - pointer to management object
* Out:
* none
*
* Return Value: current Assoc ID
*
-*/
WORD
VNTWIFIwGetAssocID (
IN PVOID pMgmtHandle
)
{
PSMgmtObject pMgmt = (PSMgmtObject)pMgmtHandle;
return(pMgmt->wCurrAID);
}
/*+
*
* Description:
* This routine return max support rate of IES
*
* Parameters:
* In:
* pSupportRateIEs
* pExtSupportRateIEs
*
* Out:
*
* Return Value: max support rate
*
-*/
BYTE
VNTWIFIbyGetMaxSupportRate (
IN PWLAN_IE_SUPP_RATES pSupportRateIEs,
IN PWLAN_IE_SUPP_RATES pExtSupportRateIEs
)
{
BYTE byMaxSupportRate = RATE_1M;
BYTE bySupportRate = RATE_1M;
UINT ii = 0;
if (pSupportRateIEs) {
for (ii = 0; ii < pSupportRateIEs->len; ii++) {
bySupportRate = DATARATEbyGetRateIdx(pSupportRateIEs->abyRates[ii]);
if (bySupportRate > byMaxSupportRate) {
byMaxSupportRate = bySupportRate;
}
}
}
if (pExtSupportRateIEs) {
for (ii = 0; ii < pExtSupportRateIEs->len; ii++) {
bySupportRate = DATARATEbyGetRateIdx(pExtSupportRateIEs->abyRates[ii]);
if (bySupportRate > byMaxSupportRate) {
byMaxSupportRate = bySupportRate;
}
}
}
return byMaxSupportRate;
}
/*+
*
* Description:
* This routine return data rate of ACK packtet
*
* Parameters:
* In:
* byRxDataRate
* pSupportRateIEs
* pExtSupportRateIEs
*
* Out:
*
* Return Value: max support rate
*
-*/
BYTE
VNTWIFIbyGetACKTxRate (
IN BYTE byRxDataRate,
IN PWLAN_IE_SUPP_RATES pSupportRateIEs,
IN PWLAN_IE_SUPP_RATES pExtSupportRateIEs
)
{
BYTE byMaxAckRate;
BYTE byBasicRate;
UINT ii;
if (byRxDataRate <= RATE_11M) {
byMaxAckRate = RATE_1M;
} else {
// 24M is mandatory for 802.11a and 802.11g
byMaxAckRate = RATE_24M;
}
if (pSupportRateIEs) {
for (ii = 0; ii < pSupportRateIEs->len; ii++) {
if (pSupportRateIEs->abyRates[ii] & 0x80) {
byBasicRate = DATARATEbyGetRateIdx(pSupportRateIEs->abyRates[ii]);
if ((byBasicRate <= byRxDataRate) &&
(byBasicRate > byMaxAckRate)) {
byMaxAckRate = byBasicRate;
}
}
}
}
if (pExtSupportRateIEs) {
for (ii = 0; ii < pExtSupportRateIEs->len; ii++) {
if (pExtSupportRateIEs->abyRates[ii] & 0x80) {
byBasicRate = DATARATEbyGetRateIdx(pExtSupportRateIEs->abyRates[ii]);
if ((byBasicRate <= byRxDataRate) &&
(byBasicRate > byMaxAckRate)) {
byMaxAckRate = byBasicRate;
}
}
}
}
return byMaxAckRate;
}
/*+
*
* Description:
* Set Authentication Mode
*
* Parameters:
* In:
* pMgmtHandle - pointer to management object
* eAuthMode - Authentication mode
* Out:
* none
*
* Return Value: none
*
-*/
VOID
VNTWIFIvSetAuthenticationMode (
IN PVOID pMgmtHandle,
IN WMAC_AUTHENTICATION_MODE eAuthMode
)
{
PSMgmtObject pMgmt = (PSMgmtObject)pMgmtHandle;
pMgmt->eAuthenMode = eAuthMode;
if ((eAuthMode == WMAC_AUTH_SHAREKEY) ||
(eAuthMode == WMAC_AUTH_AUTO)) {
pMgmt->bShareKeyAlgorithm = TRUE;
} else {
pMgmt->bShareKeyAlgorithm = FALSE;
}
}
/*+
*
* Description:
* Set Encryption Mode
*
* Parameters:
* In:
* pMgmtHandle - pointer to management object
* eAuthMode - Authentication mode
* Out:
* none
*
* Return Value: none
*
-*/
VOID
VNTWIFIvSetEncryptionMode (
IN PVOID pMgmtHandle,
IN WMAC_ENCRYPTION_MODE eEncryptionMode
)
{
PSMgmtObject pMgmt = (PSMgmtObject)pMgmtHandle;
pMgmt->eEncryptionMode = eEncryptionMode;
if ((eEncryptionMode == WMAC_ENCRYPTION_WEPEnabled) ||
(eEncryptionMode == WMAC_ENCRYPTION_TKIPEnabled) ||
(eEncryptionMode == WMAC_ENCRYPTION_AESEnabled) ) {
pMgmt->bPrivacyInvoked = TRUE;
} else {
pMgmt->bPrivacyInvoked = FALSE;
}
}
BOOL
VNTWIFIbConfigPhyMode (
IN PVOID pMgmtHandle,
IN CARD_PHY_TYPE ePhyType
)
{
PSMgmtObject pMgmt = (PSMgmtObject)pMgmtHandle;
if ((ePhyType != PHY_TYPE_AUTO) &&
(ePhyType != pMgmt->eCurrentPHYMode)) {
if (CARDbSetPhyParameter(pMgmt->pAdapter, ePhyType, 0, 0, NULL, NULL)==TRUE) {
pMgmt->eCurrentPHYMode = ePhyType;
} else {
return(FALSE);
}
}
pMgmt->eConfigPHYMode = ePhyType;
return(TRUE);
}
VOID
VNTWIFIbGetConfigPhyMode (
IN PVOID pMgmtHandle,
OUT PVOID pePhyType
)
{
PSMgmtObject pMgmt = (PSMgmtObject)pMgmtHandle;
if ((pMgmt != NULL) && (pePhyType != NULL)) {
*(PCARD_PHY_TYPE)pePhyType = pMgmt->eConfigPHYMode;
}
}
/*+
*
* Description:
* Clear BSS List Database except current assoc BSS
*
* Parameters:
* In:
* pMgmtHandle - Management Object structure
* bLinkPass - Current Link status
* Out:
*
* Return Value: None.
*
-*/
/*+
*
* Description:
* Query BSS List in management database
*
* Parameters:
* In:
* pMgmtHandle - Management Object structure
* Out:
* puBSSCount - BSS count
* pvFirstBSS - pointer to first BSS
*
* Return Value: None.
*
-*/
VOID
VNTWIFIvQueryBSSList (
IN PVOID pMgmtHandle,
OUT PUINT puBSSCount,
OUT PVOID *pvFirstBSS
)
{
UINT ii = 0;
PSMgmtObject pMgmt = (PSMgmtObject)pMgmtHandle;
PKnownBSS pBSS = NULL;
UINT uCount = 0;
*pvFirstBSS = NULL;
for (ii = 0; ii < MAX_BSS_NUM; ii++) {
pBSS = &(pMgmt->sBSSList[ii]);
if (!pBSS->bActive) {
continue;
}
if (*pvFirstBSS == NULL) {
*pvFirstBSS = &(pMgmt->sBSSList[ii]);
}
uCount++;
}
*puBSSCount = uCount;
}
VOID
VNTWIFIvGetNextBSS (
IN PVOID pMgmtHandle,
IN PVOID pvCurrentBSS,
OUT PVOID *pvNextBSS
)
{
PKnownBSS pBSS = (PKnownBSS) pvCurrentBSS;
PSMgmtObject pMgmt = (PSMgmtObject)pMgmtHandle;
*pvNextBSS = NULL;
while (*pvNextBSS == NULL) {
pBSS++;
if (pBSS > &(pMgmt->sBSSList[MAX_BSS_NUM])) {
return;
}
if (pBSS->bActive == TRUE) {
*pvNextBSS = pBSS;
return;
}
}
}
/*+
*
* Description:
* Update Tx attemps, Tx failure counter in Node DB
*
* In:
* Out:
* none
*
* Return Value: none
*
-*/
VOID
VNTWIFIvUpdateNodeTxCounter(
IN PVOID pMgmtHandle,
IN PBYTE pbyDestAddress,
IN BOOL bTxOk,
IN WORD wRate,
IN PBYTE pbyTxFailCount
)
{
PSMgmtObject pMgmt = (PSMgmtObject)pMgmtHandle;
UINT uNodeIndex = 0;
UINT ii;
if ((pMgmt->eCurrMode == WMAC_MODE_IBSS_STA) ||
(pMgmt->eCurrMode == WMAC_MODE_ESS_AP)) {
if (BSSDBbIsSTAInNodeDB(pMgmt, pbyDestAddress, &uNodeIndex) == FALSE) {
return;
}
}
pMgmt->sNodeDBTable[uNodeIndex].uTxAttempts++;
if (bTxOk == TRUE) {
// transmit success, TxAttempts at least plus one
pMgmt->sNodeDBTable[uNodeIndex].uTxOk[MAX_RATE]++;
pMgmt->sNodeDBTable[uNodeIndex].uTxOk[wRate]++;
} else {
pMgmt->sNodeDBTable[uNodeIndex].uTxFailures++;
}
pMgmt->sNodeDBTable[uNodeIndex].uTxRetry += pbyTxFailCount[MAX_RATE];
for(ii=0;ii<MAX_RATE;ii++) {
pMgmt->sNodeDBTable[uNodeIndex].uTxFail[ii] += pbyTxFailCount[ii];
}
return;
}
VOID
VNTWIFIvGetTxRate(
IN PVOID pMgmtHandle,
IN PBYTE pbyDestAddress,
OUT PWORD pwTxDataRate,
OUT PBYTE pbyACKRate,
OUT PBYTE pbyCCKBasicRate,
OUT PBYTE pbyOFDMBasicRate
)
{
PSMgmtObject pMgmt = (PSMgmtObject)pMgmtHandle;
UINT uNodeIndex = 0;
WORD wTxDataRate = RATE_1M;
BYTE byACKRate = RATE_1M;
BYTE byCCKBasicRate = RATE_1M;
BYTE byOFDMBasicRate = RATE_24M;
PWLAN_IE_SUPP_RATES pSupportRateIEs = NULL;
PWLAN_IE_SUPP_RATES pExtSupportRateIEs = NULL;
if ((pMgmt->eCurrMode == WMAC_MODE_IBSS_STA) ||
(pMgmt->eCurrMode == WMAC_MODE_ESS_AP)) {
// Adhoc Tx rate decided from node DB
if(BSSDBbIsSTAInNodeDB(pMgmt, pbyDestAddress, &uNodeIndex)) {
wTxDataRate = (pMgmt->sNodeDBTable[uNodeIndex].wTxDataRate);
pSupportRateIEs = (PWLAN_IE_SUPP_RATES) (pMgmt->sNodeDBTable[uNodeIndex].abyCurrSuppRates);
pExtSupportRateIEs = (PWLAN_IE_SUPP_RATES) (pMgmt->sNodeDBTable[uNodeIndex].abyCurrExtSuppRates);
} else {
if (pMgmt->eCurrentPHYMode != PHY_TYPE_11A) {
wTxDataRate = RATE_2M;
} else {
wTxDataRate = RATE_24M;
}
pSupportRateIEs = (PWLAN_IE_SUPP_RATES) pMgmt->abyCurrSuppRates;
pExtSupportRateIEs = (PWLAN_IE_SUPP_RATES) pMgmt->abyCurrExtSuppRates;
}
} else { // Infrastructure: rate decided from AP Node, index = 0
wTxDataRate = (pMgmt->sNodeDBTable[0].wTxDataRate);
#ifdef PLICE_DEBUG
printk("GetTxRate:AP MAC is %02x:%02x:%02x:%02x:%02x:%02x,TxRate is %d\n",
pMgmt->sNodeDBTable[0].abyMACAddr[0],pMgmt->sNodeDBTable[0].abyMACAddr[1],
pMgmt->sNodeDBTable[0].abyMACAddr[2],pMgmt->sNodeDBTable[0].abyMACAddr[3],
pMgmt->sNodeDBTable[0].abyMACAddr[4],pMgmt->sNodeDBTable[0].abyMACAddr[5],wTxDataRate);
#endif
pSupportRateIEs = (PWLAN_IE_SUPP_RATES) pMgmt->abyCurrSuppRates;
pExtSupportRateIEs = (PWLAN_IE_SUPP_RATES) pMgmt->abyCurrExtSuppRates;
}
byACKRate = VNTWIFIbyGetACKTxRate( (BYTE) wTxDataRate,
pSupportRateIEs,
pExtSupportRateIEs
);
if (byACKRate > (BYTE) wTxDataRate) {
byACKRate = (BYTE) wTxDataRate;
}
byCCKBasicRate = VNTWIFIbyGetACKTxRate( RATE_11M,
pSupportRateIEs,
pExtSupportRateIEs
);
byOFDMBasicRate = VNTWIFIbyGetACKTxRate(RATE_54M,
pSupportRateIEs,
pExtSupportRateIEs
);
*pwTxDataRate = wTxDataRate;
*pbyACKRate = byACKRate;
*pbyCCKBasicRate = byCCKBasicRate;
*pbyOFDMBasicRate = byOFDMBasicRate;
return;
}
BYTE
VNTWIFIbyGetKeyCypher(
IN PVOID pMgmtHandle,
IN BOOL bGroupKey
)
{
PSMgmtObject pMgmt = (PSMgmtObject)pMgmtHandle;
if (bGroupKey == TRUE) {
return (pMgmt->byCSSGK);
} else {
return (pMgmt->byCSSPK);
}
}
/*
BOOL
VNTWIFIbInit(
IN PVOID pAdapterHandler,
OUT PVOID *pMgmtHandler
)
{
PSMgmtObject pMgmt = NULL;
UINT ii;
pMgmt = (PSMgmtObject)kmalloc(sizeof(SMgmtObject), (int)GFP_ATOMIC);
if (pMgmt == NULL) {
*pMgmtHandler = NULL;
return FALSE;
}
memset(pMgmt, 0, sizeof(SMgmtObject));
pMgmt->pAdapter = (PVOID) pAdapterHandler;
// should initial MAC address abyMACAddr
for(ii=0;ii<WLAN_BSSID_LEN;ii++) {
pMgmt->abyDesireBSSID[ii] = 0xFF;
}
pMgmt->pbyPSPacketPool = &pMgmt->byPSPacketPool[0];
pMgmt->pbyMgmtPacketPool = &pMgmt->byMgmtPacketPool[0];
pMgmt->byCSSPK = KEY_CTL_NONE;
pMgmt->byCSSGK = KEY_CTL_NONE;
pMgmt->wIBSSBeaconPeriod = DEFAULT_IBSS_BI;
pMgmt->cbFreeCmdQueue = CMD_Q_SIZE;
pMgmt->uCmdDequeueIdx = 0;
pMgmt->uCmdEnqueueIdx = 0;
pMgmt->eCommandState = WLAN_CMD_STATE_IDLE;
pMgmt->bCmdStop = FALSE;
pMgmt->bCmdRunning = FALSE;
*pMgmtHandler = pMgmt;
return TRUE;
}
*/
BOOL
VNTWIFIbSetPMKIDCache (
IN PVOID pMgmtObject,
IN ULONG ulCount,
IN PVOID pPMKIDInfo
)
{
PSMgmtObject pMgmt = (PSMgmtObject) pMgmtObject;
if (ulCount > MAX_PMKID_CACHE) {
return (FALSE);
}
pMgmt->gsPMKIDCache.BSSIDInfoCount = ulCount;
MEMvCopy(pMgmt->gsPMKIDCache.BSSIDInfo, pPMKIDInfo, (ulCount*sizeof(PMKIDInfo)));
return (TRUE);
}
WORD
VNTWIFIwGetMaxSupportRate(
IN PVOID pMgmtObject
)
{
WORD wRate = RATE_54M;
PSMgmtObject pMgmt = (PSMgmtObject) pMgmtObject;
for(wRate = RATE_54M; wRate > RATE_1M; wRate--) {
if (BITbIsBitOn(pMgmt->sNodeDBTable[0].wSuppRate, (1<<wRate))) {
return (wRate);
}
}
if (pMgmt->eCurrentPHYMode == PHY_TYPE_11A) {
return (RATE_6M);
} else {
return (RATE_1M);
}
}
VOID
VNTWIFIvSet11h (
IN PVOID pMgmtObject,
IN BOOL b11hEnable
)
{
PSMgmtObject pMgmt = (PSMgmtObject) pMgmtObject;
pMgmt->b11hEnable = b11hEnable;
}
BOOL
VNTWIFIbMeasureReport(
IN PVOID pMgmtObject,
IN BOOL bEndOfReport,
IN PVOID pvMeasureEID,
IN BYTE byReportMode,
IN BYTE byBasicMap,
IN BYTE byCCAFraction,
IN PBYTE pbyRPIs
)
{
PSMgmtObject pMgmt = (PSMgmtObject) pMgmtObject;
PBYTE pbyCurrentEID = (PBYTE) (pMgmt->pCurrMeasureEIDRep);
//spin_lock_irq(&pDevice->lock);
if ((pvMeasureEID != NULL) &&
(pMgmt->uLengthOfRepEIDs < (WLAN_A3FR_MAXLEN - sizeof(MEASEURE_REP) - sizeof(WLAN_80211HDR_A3) - 3))
) {
pMgmt->pCurrMeasureEIDRep->byElementID = WLAN_EID_MEASURE_REP;
pMgmt->pCurrMeasureEIDRep->len = 3;
pMgmt->pCurrMeasureEIDRep->byToken = ((PWLAN_IE_MEASURE_REQ) pvMeasureEID)->byToken;
pMgmt->pCurrMeasureEIDRep->byMode = byReportMode;
pMgmt->pCurrMeasureEIDRep->byType = ((PWLAN_IE_MEASURE_REQ) pvMeasureEID)->byType;
switch (pMgmt->pCurrMeasureEIDRep->byType) {
case MEASURE_TYPE_BASIC :
pMgmt->pCurrMeasureEIDRep->len += sizeof(MEASEURE_REP_BASIC);
MEMvCopy( &(pMgmt->pCurrMeasureEIDRep->sRep.sBasic),
&(((PWLAN_IE_MEASURE_REQ) pvMeasureEID)->sReq),
sizeof(MEASEURE_REQ));
pMgmt->pCurrMeasureEIDRep->sRep.sBasic.byMap = byBasicMap;
break;
case MEASURE_TYPE_CCA :
pMgmt->pCurrMeasureEIDRep->len += sizeof(MEASEURE_REP_CCA);
MEMvCopy( &(pMgmt->pCurrMeasureEIDRep->sRep.sCCA),
&(((PWLAN_IE_MEASURE_REQ) pvMeasureEID)->sReq),
sizeof(MEASEURE_REQ));
pMgmt->pCurrMeasureEIDRep->sRep.sCCA.byCCABusyFraction = byCCAFraction;
break;
case MEASURE_TYPE_RPI :
pMgmt->pCurrMeasureEIDRep->len += sizeof(MEASEURE_REP_RPI);
MEMvCopy( &(pMgmt->pCurrMeasureEIDRep->sRep.sRPI),
&(((PWLAN_IE_MEASURE_REQ) pvMeasureEID)->sReq),
sizeof(MEASEURE_REQ));
MEMvCopy(pMgmt->pCurrMeasureEIDRep->sRep.sRPI.abyRPIdensity, pbyRPIs, 8);
break;
default :
break;
}
pbyCurrentEID += (2 + pMgmt->pCurrMeasureEIDRep->len);
pMgmt->uLengthOfRepEIDs += (2 + pMgmt->pCurrMeasureEIDRep->len);
pMgmt->pCurrMeasureEIDRep = (PWLAN_IE_MEASURE_REP) pbyCurrentEID;
}
if (bEndOfReport == TRUE) {
IEEE11hbMSRRepTx(pMgmt);
}
//spin_unlock_irq(&pDevice->lock);
return (TRUE);
}
BOOL
VNTWIFIbChannelSwitch(
IN PVOID pMgmtObject,
IN BYTE byNewChannel
)
{
PSMgmtObject pMgmt = (PSMgmtObject) pMgmtObject;
//spin_lock_irq(&pDevice->lock);
pMgmt->uCurrChannel = byNewChannel;
pMgmt->bSwitchChannel = FALSE;
//spin_unlock_irq(&pDevice->lock);
return TRUE;
}
/*
BOOL
VNTWIFIbRadarPresent(
IN PVOID pMgmtObject,
IN BYTE byChannel
)
{
PSMgmtObject pMgmt = (PSMgmtObject) pMgmtObject;
if ((pMgmt->eCurrMode == WMAC_MODE_IBSS_STA) &&
(byChannel == (BYTE) pMgmt->uCurrChannel) &&
(pMgmt->bSwitchChannel != TRUE) &&
(pMgmt->b11hEnable == TRUE)) {
if (IS_ETH_ADDRESS_EQUAL(pMgmt->abyIBSSDFSOwner, CARDpGetCurrentAddress(pMgmt->pAdapter))) {
pMgmt->byNewChannel = CARDbyAutoChannelSelect(pMgmt->pAdapter,(BYTE) pMgmt->uCurrChannel);
pMgmt->bSwitchChannel = TRUE;
}
BEACONbSendBeacon(pMgmt);
CARDbChannelSwitch(pMgmt->pAdapter, 0, pMgmt->byNewChannel, 10);
}
return TRUE;
}
*/

View File

@ -0,0 +1,330 @@
/*
* Copyright (c) 1996, 2003 VIA Networking Technologies, Inc.
* All rights reserved.
*
* This program is free software; you can redistribute it and/or modify
* it under the terms of the GNU General Public License as published by
* the Free Software Foundation; either version 2 of the License, or
* (at your option) any later version.
*
* This program is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
* GNU General Public License for more details.
*
* You should have received a copy of the GNU General Public License along
* with this program; if not, write to the Free Software Foundation, Inc.,
* 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA.
*
*
* File: vntwifi.h
*
* Purpose: export VNT Host WiFi library function
*
* Author: Yiching Chen
*
* Date: Jan 7, 2004
*
*/
#ifndef __VNTWIFI_H__
#define __VNTWIFI_H__
#if !defined(__TTYPE_H__)
#include "ttype.h"
#endif
#if !defined(__80211MGR_H__)
#include "80211mgr.h"
#endif
#if !defined(__CARD_H__)
#include "card.h"
#endif
/*--------------------- Export Definitions -------------------------*/
#define RATE_1M 0
#define RATE_2M 1
#define RATE_5M 2
#define RATE_11M 3
#define RATE_6M 4
#define RATE_9M 5
#define RATE_12M 6
#define RATE_18M 7
#define RATE_24M 8
#define RATE_36M 9
#define RATE_48M 10
#define RATE_54M 11
#define RATE_AUTO 12
#define MAX_RATE 12
// key CipherSuite
#define KEY_CTL_WEP 0x00
#define KEY_CTL_NONE 0x01
#define KEY_CTL_TKIP 0x02
#define KEY_CTL_CCMP 0x03
#define KEY_CTL_INVALID 0xFF
#define CHANNEL_MAX_24G 14
#define MAX_BSS_NUM 42
#define MAX_PMKID_CACHE 16
// Pre-configured Authenticaiton Mode (from XP)
typedef enum tagWMAC_AUTHENTICATION_MODE {
WMAC_AUTH_OPEN,
WMAC_AUTH_SHAREKEY,
WMAC_AUTH_AUTO,
WMAC_AUTH_WPA,
WMAC_AUTH_WPAPSK,
WMAC_AUTH_WPANONE,
WMAC_AUTH_WPA2,
WMAC_AUTH_WPA2PSK,
WMAC_AUTH_MAX // Not a real mode, defined as upper bound
} WMAC_AUTHENTICATION_MODE, *PWMAC_AUTHENTICATION_MODE;
typedef enum tagWMAC_ENCRYPTION_MODE {
WMAC_ENCRYPTION_WEPEnabled,
WMAC_ENCRYPTION_WEPDisabled,
WMAC_ENCRYPTION_WEPKeyAbsent,
WMAC_ENCRYPTION_WEPNotSupported,
WMAC_ENCRYPTION_TKIPEnabled,
WMAC_ENCRYPTION_TKIPKeyAbsent,
WMAC_ENCRYPTION_AESEnabled,
WMAC_ENCRYPTION_AESKeyAbsent
} WMAC_ENCRYPTION_MODE, *PWMAC_ENCRYPTION_MODE;
// Pre-configured Mode (from XP)
typedef enum tagWMAC_CONFIG_MODE {
WMAC_CONFIG_ESS_STA = 0,
WMAC_CONFIG_IBSS_STA,
WMAC_CONFIG_AUTO,
WMAC_CONFIG_AP
} WMAC_CONFIG_MODE, *PWMAC_CONFIG_MODE;
typedef enum tagWMAC_POWER_MODE {
WMAC_POWER_CAM,
WMAC_POWER_FAST,
WMAC_POWER_MAX
} WMAC_POWER_MODE, *PWMAC_POWER_MODE;
#define VNTWIFIbIsShortSlotTime(wCapInfo) \
WLAN_GET_CAP_INFO_SHORTSLOTTIME(wCapInfo) \
#define VNTWIFIbIsProtectMode(byERP) \
((byERP & WLAN_EID_ERP_USE_PROTECTION) != 0) \
#define VNTWIFIbIsBarkerMode(byERP) \
((byERP & WLAN_EID_ERP_BARKER_MODE) != 0) \
#define VNTWIFIbIsShortPreamble(wCapInfo) \
WLAN_GET_CAP_INFO_SHORTPREAMBLE(wCapInfo) \
#define VNTWIFIbIsEncryption(wCapInfo) \
WLAN_GET_CAP_INFO_PRIVACY(wCapInfo) \
#define VNTWIFIbIsESS(wCapInfo) \
WLAN_GET_CAP_INFO_ESS(wCapInfo) \
/*--------------------- Export Classes ----------------------------*/
/*--------------------- Export Variables --------------------------*/
/*--------------------- Export Types ------------------------------*/
/*--------------------- Export Functions --------------------------*/
#ifdef __cplusplus
extern "C" { /* Assume C declarations for C++ */
#endif /* __cplusplus */
VOID
VNTWIFIvSetIBSSParameter (
IN PVOID pMgmtHandle,
IN WORD wBeaconPeriod,
IN WORD wATIMWindow,
IN UINT uChannel
);
VOID
VNTWIFIvSetOPMode (
IN PVOID pMgmtHandle,
IN WMAC_CONFIG_MODE eOPMode
);
PWLAN_IE_SSID
VNTWIFIpGetCurrentSSID(
IN PVOID pMgmtHandle
);
UINT
VNTWIFIpGetCurrentChannel(
IN PVOID pMgmtHandle
);
WORD
VNTWIFIwGetAssocID (
IN PVOID pMgmtHandle
);
BYTE
VNTWIFIbyGetMaxSupportRate (
IN PWLAN_IE_SUPP_RATES pSupportRateIEs,
IN PWLAN_IE_SUPP_RATES pExtSupportRateIEs
);
BYTE
VNTWIFIbyGetACKTxRate (
IN BYTE byRxDataRate,
IN PWLAN_IE_SUPP_RATES pSupportRateIEs,
IN PWLAN_IE_SUPP_RATES pExtSupportRateIEs
);
VOID
VNTWIFIvSetAuthenticationMode (
IN PVOID pMgmtHandle,
IN WMAC_AUTHENTICATION_MODE eAuthMode
);
VOID
VNTWIFIvSetEncryptionMode (
IN PVOID pMgmtHandle,
IN WMAC_ENCRYPTION_MODE eEncryptionMode
);
BOOL
VNTWIFIbConfigPhyMode(
IN PVOID pMgmtHandle,
IN CARD_PHY_TYPE ePhyType
);
VOID
VNTWIFIbGetConfigPhyMode(
IN PVOID pMgmtHandle,
OUT PVOID pePhyType
);
VOID
VNTWIFIvQueryBSSList(
IN PVOID pMgmtHandle,
OUT PUINT puBSSCount,
OUT PVOID *pvFirstBSS
);
VOID
VNTWIFIvGetNextBSS (
IN PVOID pMgmtHandle,
IN PVOID pvCurrentBSS,
OUT PVOID *pvNextBSS
);
VOID
VNTWIFIvUpdateNodeTxCounter(
IN PVOID pMgmtHandle,
IN PBYTE pbyDestAddress,
IN BOOL bTxOk,
IN WORD wRate,
IN PBYTE pbyTxFailCount
);
VOID
VNTWIFIvGetTxRate(
IN PVOID pMgmtHandle,
IN PBYTE pbyDestAddress,
OUT PWORD pwTxDataRate,
OUT PBYTE pbyACKRate,
OUT PBYTE pbyCCKBasicRate,
OUT PBYTE pbyOFDMBasicRate
);
/*
BOOL
VNTWIFIbInit(
IN PVOID pAdapterHandler,
OUT PVOID *pMgmtHandler
);
*/
BYTE
VNTWIFIbyGetKeyCypher(
IN PVOID pMgmtHandle,
IN BOOL bGroupKey
);
BOOL
VNTWIFIbSetPMKIDCache (
IN PVOID pMgmtObject,
IN ULONG ulCount,
IN PVOID pPMKIDInfo
);
BOOL
VNTWIFIbCommandRunning (
IN PVOID pMgmtObject
);
WORD
VNTWIFIwGetMaxSupportRate(
IN PVOID pMgmtObject
);
// for 802.11h
VOID
VNTWIFIvSet11h (
IN PVOID pMgmtObject,
IN BOOL b11hEnable
);
BOOL
VNTWIFIbMeasureReport(
IN PVOID pMgmtObject,
IN BOOL bEndOfReport,
IN PVOID pvMeasureEID,
IN BYTE byReportMode,
IN BYTE byBasicMap,
IN BYTE byCCAFraction,
IN PBYTE pbyRPIs
);
BOOL
VNTWIFIbChannelSwitch(
IN PVOID pMgmtObject,
IN BYTE byNewChannel
);
/*
BOOL
VNTWIFIbRadarPresent(
IN PVOID pMgmtObject,
IN BYTE byChannel
);
*/
#ifdef __cplusplus
} /* End of extern "C" { */
#endif /* __cplusplus */
#endif //__VNTWIFI_H__

File diff suppressed because it is too large Load Diff

View File

@ -0,0 +1,151 @@
/*
* Copyright (c) 1996, 2003 VIA Networking Technologies, Inc.
* All rights reserved.
*
* This program is free software; you can redistribute it and/or modify
* it under the terms of the GNU General Public License as published by
* the Free Software Foundation; either version 2 of the License, or
* (at your option) any later version.
*
* This program is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
* GNU General Public License for more details.
*
* You should have received a copy of the GNU General Public License along
* with this program; if not, write to the Free Software Foundation, Inc.,
* 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA.
*
* File: wcmd.h
*
* Purpose: Handles the management command interface functions
*
* Author: Lyndon Chen
*
* Date: May 8, 2002
*
*/
#ifndef __WCMD_H__
#define __WCMD_H__
#if !defined(__TTYPE_H__)
#include "ttype.h"
#endif
#if !defined(__80211HDR_H__)
#include "80211hdr.h"
#endif
#if !defined(__80211MGR_H__)
#include "80211mgr.h"
#endif
/*--------------------- Export Definitions -------------------------*/
#define AUTHENTICATE_TIMEOUT 1000 //ms
#define ASSOCIATE_TIMEOUT 1000 //ms
// Command code
typedef enum tagCMD_CODE {
WLAN_CMD_BSSID_SCAN,
WLAN_CMD_SSID,
WLAN_CMD_DISASSOCIATE,
WLAN_CMD_DEAUTH,
WLAN_CMD_RX_PSPOLL,
WLAN_CMD_RADIO,
WLAN_CMD_CHANGE_BBSENSITIVITY,
WLAN_CMD_SETPOWER,
WLAN_CMD_TBTT_WAKEUP,
WLAN_CMD_BECON_SEND,
WLAN_CMD_CHANGE_ANTENNA,
WLAN_CMD_REMOVE_ALLKEY,
WLAN_CMD_MAC_DISPOWERSAVING,
WLAN_CMD_11H_CHSW,
WLAN_CMD_RUN_AP
} CMD_CODE, DEF* PCMD_CODE;
#define CMD_Q_SIZE 32
// Command code
typedef enum tagCMD_STATUS {
CMD_STATUS_SUCCESS,
CMD_STATUS_FAILURE,
CMD_STATUS_RESOURCES,
CMD_STATUS_TIMEOUT,
CMD_STATUS_PENDING
} CMD_STATUS, DEF* PCMD_STATUS;
typedef struct tagCMD_ITEM {
CMD_CODE eCmd;
BYTE abyCmdDesireSSID[WLAN_IEHDR_LEN + WLAN_SSID_MAXLEN + 1];
BOOL bNeedRadioOFF;
WORD wDeAuthenReason;
BOOL bRadioCmd;
BOOL bForceSCAN;
} CMD_ITEM, DEF* PCMD_ITEM;
// Command state
typedef enum tagCMD_STATE {
WLAN_CMD_SCAN_START,
WLAN_CMD_SCAN_END,
WLAN_CMD_DISASSOCIATE_START,
WLAN_CMD_SSID_START,
WLAN_AUTHENTICATE_WAIT,
WLAN_ASSOCIATE_WAIT,
WLAN_DISASSOCIATE_WAIT,
WLAN_CMD_TX_PSPACKET_START,
WLAN_CMD_AP_MODE_START,
WLAN_CMD_RADIO_START,
WLAN_CMD_CHECK_BBSENSITIVITY_CHANGE,
WLAN_CMD_IDLE
} CMD_STATE, DEF* PCMD_STATE;
/*--------------------- Export Classes ----------------------------*/
/*--------------------- Export Variables --------------------------*/
/*--------------------- Export Types ------------------------------*/
/*--------------------- Export Functions --------------------------*/
VOID
vResetCommandTimer(
IN HANDLE hDeviceContext
);
VOID
vCommandTimer (
IN HANDLE hDeviceContext
);
BOOL bClearBSSID_SCAN(
IN HANDLE hDeviceContext
);
BOOL
bScheduleCommand(
IN HANDLE hDeviceContext,
IN CMD_CODE eCommand,
IN PBYTE pbyItem0
);
VOID
vCommandTimerWait(
IN HANDLE hDeviceContext,
IN UINT MSecond
);
#ifdef TxInSleep
VOID
BSSvSecondTxData(
IN HANDLE hDeviceContext
);
#endif
#endif //__WCMD_H__

View File

@ -0,0 +1,261 @@
/*
* Copyright (c) 1996, 2003 VIA Networking Technologies, Inc.
* All rights reserved.
*
* This program is free software; you can redistribute it and/or modify
* it under the terms of the GNU General Public License as published by
* the Free Software Foundation; either version 2 of the License, or
* (at your option) any later version.
*
* This program is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
* GNU General Public License for more details.
*
* You should have received a copy of the GNU General Public License along
* with this program; if not, write to the Free Software Foundation, Inc.,
* 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA.
*
* File: wctl.c
*
* Purpose: handle WMAC duplicate filter & defragment
*
* Author: Jerry Chen
*
* Date: Jun. 27, 2002
*
* Functions:
* WCTLbIsDuplicate - Test if duplicate packet
* WCTLuSearchDFCB - Search DeFragment Control Database
* WCTLuInsertDFCB - Insert DeFragment Control Database
* WCTLbHandleFragment - Handle received fragment packet
*
* Revision History:
*
*/
#if !defined(__WCTL_H__)
#include "wctl.h"
#endif
#if !defined(__DEVICE_H__)
#include "device.h"
#endif
#if !defined(__CARD_H__)
#include "card.h"
#endif
/*--------------------- Static Definitions -------------------------*/
/*--------------------- Static Classes ----------------------------*/
/*--------------------- Static Variables --------------------------*/
// static int msglevel =MSG_LEVEL_INFO;
/*--------------------- Static Functions --------------------------*/
/*--------------------- Export Variables --------------------------*/
/*
* Description:
* Scan Rx cache. Return TRUE if packet is duplicate, else
* inserts in receive cache and returns FALSE.
*
* Parameters:
* In:
* pCache - Receive packets history
* pMACHeader - 802.11 MAC Header of received packet
* Out:
* none
*
* Return Value: TRUE if packet duplicate; otherwise FALSE
*
*/
BOOL WCTLbIsDuplicate (PSCache pCache, PS802_11Header pMACHeader)
{
UINT uIndex;
UINT ii;
PSCacheEntry pCacheEntry;
if (IS_FC_RETRY(pMACHeader)) {
uIndex = pCache->uInPtr;
for (ii = 0; ii < DUPLICATE_RX_CACHE_LENGTH; ii++) {
pCacheEntry = &(pCache->asCacheEntry[uIndex]);
if ((pCacheEntry->wFmSequence == pMACHeader->wSeqCtl) &&
(IS_ETH_ADDRESS_EQUAL (&(pCacheEntry->abyAddr2[0]), &(pMACHeader->abyAddr2[0])))
) {
/* Duplicate match */
return TRUE;
}
ADD_ONE_WITH_WRAP_AROUND(uIndex, DUPLICATE_RX_CACHE_LENGTH);
}
}
/* Not fount in cache - insert */
pCacheEntry = &pCache->asCacheEntry[pCache->uInPtr];
pCacheEntry->wFmSequence = pMACHeader->wSeqCtl;
memcpy(&(pCacheEntry->abyAddr2[0]), &(pMACHeader->abyAddr2[0]), U_ETHER_ADDR_LEN);
ADD_ONE_WITH_WRAP_AROUND(pCache->uInPtr, DUPLICATE_RX_CACHE_LENGTH);
return FALSE;
}
/*
* Description:
* Found if sequence number of received fragment packet in Defragment Database
*
* Parameters:
* In:
* pDevice - Pointer to adapter
* pMACHeader - 802.11 MAC Header of received packet
* Out:
* none
*
* Return Value: index number in Defragment Database
*
*/
UINT WCTLuSearchDFCB (PSDevice pDevice, PS802_11Header pMACHeader)
{
UINT ii;
for(ii=0;ii<pDevice->cbDFCB;ii++) {
if ((pDevice->sRxDFCB[ii].bInUse == TRUE) &&
(IS_ETH_ADDRESS_EQUAL (&(pDevice->sRxDFCB[ii].abyAddr2[0]), &(pMACHeader->abyAddr2[0])))
) {
//
return(ii);
}
}
return(pDevice->cbDFCB);
}
/*
* Description:
* Insert received fragment packet in Defragment Database
*
* Parameters:
* In:
* pDevice - Pointer to adapter
* pMACHeader - 802.11 MAC Header of received packet
* Out:
* none
*
* Return Value: index number in Defragment Database
*
*/
UINT WCTLuInsertDFCB (PSDevice pDevice, PS802_11Header pMACHeader)
{
UINT ii;
if (pDevice->cbFreeDFCB == 0)
return(pDevice->cbDFCB);
for(ii=0;ii<pDevice->cbDFCB;ii++) {
if (pDevice->sRxDFCB[ii].bInUse == FALSE) {
pDevice->cbFreeDFCB--;
pDevice->sRxDFCB[ii].uLifetime = pDevice->dwMaxReceiveLifetime;
pDevice->sRxDFCB[ii].bInUse = TRUE;
pDevice->sRxDFCB[ii].wSequence = (pMACHeader->wSeqCtl >> 4);
pDevice->sRxDFCB[ii].wFragNum = (pMACHeader->wSeqCtl & 0x000F);
memcpy(&(pDevice->sRxDFCB[ii].abyAddr2[0]), &(pMACHeader->abyAddr2[0]), U_ETHER_ADDR_LEN);
return(ii);
}
}
return(pDevice->cbDFCB);
}
/*
* Description:
* Handle received fragment packet
*
* Parameters:
* In:
* pDevice - Pointer to adapter
* pMACHeader - 802.11 MAC Header of received packet
* cbFrameLength - Frame length
* bWEP - is WEP packet
* Out:
* none
*
* Return Value: TRUE if it is valid fragment packet and we have resource to defragment; otherwise FALSE
*
*/
BOOL WCTLbHandleFragment (PSDevice pDevice, PS802_11Header pMACHeader, UINT cbFrameLength, BOOL bWEP, BOOL bExtIV)
{
UINT uHeaderSize;
if (bWEP == TRUE) {
uHeaderSize = 28;
if (bExtIV)
// ExtIV
uHeaderSize +=4;
}
else {
uHeaderSize = 24;
}
if (IS_FIRST_FRAGMENT_PKT(pMACHeader)) {
pDevice->uCurrentDFCBIdx = WCTLuSearchDFCB(pDevice, pMACHeader);
if (pDevice->uCurrentDFCBIdx < pDevice->cbDFCB) {
// duplicate, we must flush previous DCB
pDevice->sRxDFCB[pDevice->uCurrentDFCBIdx].uLifetime = pDevice->dwMaxReceiveLifetime;
pDevice->sRxDFCB[pDevice->uCurrentDFCBIdx].wSequence = (pMACHeader->wSeqCtl >> 4);
pDevice->sRxDFCB[pDevice->uCurrentDFCBIdx].wFragNum = (pMACHeader->wSeqCtl & 0x000F);
}
else {
pDevice->uCurrentDFCBIdx = WCTLuInsertDFCB(pDevice, pMACHeader);
if (pDevice->uCurrentDFCBIdx == pDevice->cbDFCB) {
return(FALSE);
}
}
// reserve 4 byte to match MAC RX Buffer
#ifdef PRIVATE_OBJ
pDevice->sRxDFCB[pDevice->uCurrentDFCBIdx].pbyRxBuffer = (PBYTE) (pDevice->sRxDFCB[pDevice->uCurrentDFCBIdx].ref_skb.data + 4);
#else
pDevice->sRxDFCB[pDevice->uCurrentDFCBIdx].pbyRxBuffer = (PBYTE) (pDevice->sRxDFCB[pDevice->uCurrentDFCBIdx].skb->data + 4);
#endif
memcpy(pDevice->sRxDFCB[pDevice->uCurrentDFCBIdx].pbyRxBuffer, pMACHeader, cbFrameLength);
pDevice->sRxDFCB[pDevice->uCurrentDFCBIdx].cbFrameLength = cbFrameLength;
pDevice->sRxDFCB[pDevice->uCurrentDFCBIdx].pbyRxBuffer += cbFrameLength;
pDevice->sRxDFCB[pDevice->uCurrentDFCBIdx].wFragNum++;
//DEVICE_PRT(MSG_LEVEL_DEBUG, KERN_INFO "First pDevice->uCurrentDFCBIdx= %d\n", pDevice->uCurrentDFCBIdx);
return(FALSE);
}
else {
pDevice->uCurrentDFCBIdx = WCTLuSearchDFCB(pDevice, pMACHeader);
if (pDevice->uCurrentDFCBIdx != pDevice->cbDFCB) {
if ((pDevice->sRxDFCB[pDevice->uCurrentDFCBIdx].wSequence == (pMACHeader->wSeqCtl >> 4)) &&
(pDevice->sRxDFCB[pDevice->uCurrentDFCBIdx].wFragNum == (pMACHeader->wSeqCtl & 0x000F)) &&
((pDevice->sRxDFCB[pDevice->uCurrentDFCBIdx].cbFrameLength + cbFrameLength - uHeaderSize) < 2346)) {
memcpy(pDevice->sRxDFCB[pDevice->uCurrentDFCBIdx].pbyRxBuffer, ((PBYTE) (pMACHeader) + uHeaderSize), (cbFrameLength - uHeaderSize));
pDevice->sRxDFCB[pDevice->uCurrentDFCBIdx].cbFrameLength += (cbFrameLength - uHeaderSize);
pDevice->sRxDFCB[pDevice->uCurrentDFCBIdx].pbyRxBuffer += (cbFrameLength - uHeaderSize);
pDevice->sRxDFCB[pDevice->uCurrentDFCBIdx].wFragNum++;
//DEVICE_PRT(MSG_LEVEL_DEBUG, KERN_INFO "Second pDevice->uCurrentDFCBIdx= %d\n", pDevice->uCurrentDFCBIdx);
}
else {
// seq error or frag # error flush DFCB
pDevice->cbFreeDFCB++;
pDevice->sRxDFCB[pDevice->uCurrentDFCBIdx].bInUse = FALSE;
return(FALSE);
}
}
else {
return(FALSE);
}
if (IS_LAST_FRAGMENT_PKT(pMACHeader)) {
//enq defragcontrolblock
pDevice->cbFreeDFCB++;
pDevice->sRxDFCB[pDevice->uCurrentDFCBIdx].bInUse = FALSE;
//DEVICE_PRT(MSG_LEVEL_DEBUG, KERN_INFO "Last pDevice->uCurrentDFCBIdx= %d\n", pDevice->uCurrentDFCBIdx);
return(TRUE);
}
return(FALSE);
}
}

View File

@ -0,0 +1,127 @@
/*
* Copyright (c) 1996, 2003 VIA Networking Technologies, Inc.
* All rights reserved.
*
* This program is free software; you can redistribute it and/or modify
* it under the terms of the GNU General Public License as published by
* the Free Software Foundation; either version 2 of the License, or
* (at your option) any later version.
*
* This program is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
* GNU General Public License for more details.
*
* You should have received a copy of the GNU General Public License along
* with this program; if not, write to the Free Software Foundation, Inc.,
* 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA.
*
* File: wctl.h
*
* Purpose:
*
* Author: Jerry Chen
*
* Date: Jun. 27, 2002
*
*/
#ifndef __WCTL_H__
#define __WCTL_H__
#if !defined(__TTYPE_H__)
#include "ttype.h"
#endif
#if !defined(__TETHER_H__)
#include "tether.h"
#endif
#if !defined(__DEVICE_H__)
#include "device.h"
#endif
/*--------------------- Export Definitions -------------------------*/
#define IS_TYPE_DATA(pMACHeader) \
((((PS802_11Header) pMACHeader)->wFrameCtl & TYPE_802_11_MASK) == TYPE_802_11_DATA)
#define IS_TYPE_MGMT(pMACHeader) \
((((PS802_11Header) pMACHeader)->wFrameCtl & TYPE_802_11_MASK) == TYPE_802_11_MGMT)
#define IS_TYPE_CONTROL(pMACHeader) \
((((PS802_11Header) pMACHeader)->wFrameCtl & TYPE_802_11_MASK) == TYPE_802_11_CTL)
#define IS_FC_MOREDATA(pMACHeader) \
((((PS802_11Header) pMACHeader)->wFrameCtl & FC_MOREDATA) == FC_MOREDATA)
#define IS_FC_POWERMGT(pMACHeader) \
((((PS802_11Header) pMACHeader)->wFrameCtl & FC_POWERMGT) == FC_POWERMGT)
#define IS_FC_RETRY(pMACHeader) \
((((PS802_11Header) pMACHeader)->wFrameCtl & FC_RETRY) == FC_RETRY)
#define IS_FC_WEP(pMACHeader) \
((((PS802_11Header) pMACHeader)->wFrameCtl & FC_WEP) == FC_WEP)
#ifdef __BIG_ENDIAN
#define IS_FRAGMENT_PKT(pMACHeader) \
(((((PS802_11Header) pMACHeader)->wFrameCtl & FC_MOREFRAG) != 0) | \
((((PS802_11Header) pMACHeader)->wSeqCtl & 0x0F00) != 0))
#define IS_FIRST_FRAGMENT_PKT(pMACHeader) \
((((PS802_11Header) pMACHeader)->wSeqCtl & 0x0F00) == 0)
#else
#define IS_FRAGMENT_PKT(pMACHeader) \
(((((PS802_11Header) pMACHeader)->wFrameCtl & FC_MOREFRAG) != 0) | \
((((PS802_11Header) pMACHeader)->wSeqCtl & 0x000F) != 0))
#define IS_FIRST_FRAGMENT_PKT(pMACHeader) \
((((PS802_11Header) pMACHeader)->wSeqCtl & 0x000F) == 0)
#endif//#ifdef __BIG_ENDIAN
#define IS_LAST_FRAGMENT_PKT(pMACHeader) \
((((PS802_11Header) pMACHeader)->wFrameCtl & FC_MOREFRAG) == 0)
#define IS_CTL_PSPOLL(pMACHeader) \
((((PS802_11Header) pMACHeader)->wFrameCtl & TYPE_SUBTYPE_MASK) == TYPE_CTL_PSPOLL)
#define ADD_ONE_WITH_WRAP_AROUND(uVar, uModulo) { \
if ((uVar) >= ((uModulo) - 1)) \
(uVar) = 0; \
else \
(uVar)++; \
}
/*--------------------- Export Classes ----------------------------*/
/*--------------------- Export Variables --------------------------*/
/*--------------------- Export Functions --------------------------*/
#ifdef __cplusplus
extern "C" { /* Assume C declarations for C++ */
#endif /* __cplusplus */
BOOL WCTLbIsDuplicate(PSCache pCache, PS802_11Header pMACHeader);
BOOL WCTLbHandleFragment(PSDevice pDevice, PS802_11Header pMACHeader, UINT cbFrameLength, BOOL bWEP, BOOL bExtIV);
UINT WCTLuSearchDFCB(PSDevice pDevice, PS802_11Header pMACHeader);
UINT WCTLuInsertDFCB(PSDevice pDevice, PS802_11Header pMACHeader);
#ifdef __cplusplus
} /* End of extern "C" { */
#endif /* __cplusplus */
#endif // __WCTL_H__

File diff suppressed because it is too large Load Diff

View File

@ -0,0 +1,521 @@
/*
* Copyright (c) 1996, 2003 VIA Networking Technologies, Inc.
* All rights reserved.
*
* This program is free software; you can redistribute it and/or modify
* it under the terms of the GNU General Public License as published by
* the Free Software Foundation; either version 2 of the License, or
* (at your option) any later version.
*
* This program is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
* GNU General Public License for more details.
*
* You should have received a copy of the GNU General Public License along
* with this program; if not, write to the Free Software Foundation, Inc.,
* 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA.
*
*
* File: wmgr.h
*
* Purpose:
*
* Author: lyndon chen
*
* Date: Jan 2, 2003
*
* Functions:
*
* Revision History:
*
*/
#ifndef __WMGR_H__
#define __WMGR_H__
#if !defined(__TTYPE_H__)
#include "ttype.h"
#endif
#if !defined(__80211MGR_H__)
#include "80211mgr.h"
#endif
#if !defined(__80211HDR_H__)
#include "80211hdr.h"
#endif
#if !defined(__WCMD_H__)
#include "wcmd.h"
#endif
#if !defined(__BSSDB_H__)
#include "bssdb.h"
#endif
#if !defined(__CARD_H__)
#include "card.h"
#endif
#if !defined(__WPA2_H__)
#include "wpa2.h"
#endif
#if !defined(__VNTWIFI_H__)
#include "vntwifi.h"
#endif
/*--------------------- Export Definitions -------------------------*/
// Scan time
#define PROBE_DELAY 100 // (us)
#define SWITCH_CHANNEL_DELAY 200 // (us)
#define WLAN_SCAN_MINITIME 25 // (ms)
#define WLAN_SCAN_MAXTIME 100 // (ms)
#define TRIVIAL_SYNC_DIFFERENCE 0 // (us)
#define DEFAULT_IBSS_BI 100 // (ms)
#define WCMD_ACTIVE_SCAN_TIME 50 //(ms)
#define WCMD_PASSIVE_SCAN_TIME 100 //(ms)
#define DEFAULT_MSDU_LIFETIME 512 // ms
#define DEFAULT_MSDU_LIFETIME_RES_64us 8000 // 64us
#define DEFAULT_MGN_LIFETIME 8 // ms
#define DEFAULT_MGN_LIFETIME_RES_64us 125 // 64us
#define MAKE_BEACON_RESERVED 10 //(us)
#define TIM_MULTICAST_MASK 0x01
#define TIM_BITMAPOFFSET_MASK 0xFE
#define DEFAULT_DTIM_PERIOD 1
#define AP_LONG_RETRY_LIMIT 4
#define DEFAULT_IBSS_CHANNEL 6 //2.4G
/*--------------------- Export Classes ----------------------------*/
/*--------------------- Export Variables --------------------------*/
/*--------------------- Export Types ------------------------------*/
#define timer_expire(timer,next_tick) mod_timer(&timer, RUN_AT(next_tick))
typedef void (*TimerFunction)(ULONG);
//+++ NDIS related
typedef UCHAR NDIS_802_11_MAC_ADDRESS[6];
typedef struct _NDIS_802_11_AI_REQFI
{
USHORT Capabilities;
USHORT ListenInterval;
NDIS_802_11_MAC_ADDRESS CurrentAPAddress;
} NDIS_802_11_AI_REQFI, *PNDIS_802_11_AI_REQFI;
typedef struct _NDIS_802_11_AI_RESFI
{
USHORT Capabilities;
USHORT StatusCode;
USHORT AssociationId;
} NDIS_802_11_AI_RESFI, *PNDIS_802_11_AI_RESFI;
typedef struct _NDIS_802_11_ASSOCIATION_INFORMATION
{
ULONG Length;
USHORT AvailableRequestFixedIEs;
NDIS_802_11_AI_REQFI RequestFixedIEs;
ULONG RequestIELength;
ULONG OffsetRequestIEs;
USHORT AvailableResponseFixedIEs;
NDIS_802_11_AI_RESFI ResponseFixedIEs;
ULONG ResponseIELength;
ULONG OffsetResponseIEs;
} NDIS_802_11_ASSOCIATION_INFORMATION, *PNDIS_802_11_ASSOCIATION_INFORMATION;
typedef struct tagSAssocInfo {
NDIS_802_11_ASSOCIATION_INFORMATION AssocInfo;
BYTE abyIEs[WLAN_BEACON_FR_MAXLEN+WLAN_BEACON_FR_MAXLEN];
// store ReqIEs set by OID_802_11_ASSOCIATION_INFORMATION
ULONG RequestIELength;
BYTE abyReqIEs[WLAN_BEACON_FR_MAXLEN];
} SAssocInfo, DEF* PSAssocInfo;
//---
/*
typedef enum tagWMAC_AUTHENTICATION_MODE {
WMAC_AUTH_OPEN,
WMAC_AUTH_SHAREKEY,
WMAC_AUTH_AUTO,
WMAC_AUTH_WPA,
WMAC_AUTH_WPAPSK,
WMAC_AUTH_WPANONE,
WMAC_AUTH_WPA2,
WMAC_AUTH_WPA2PSK,
WMAC_AUTH_MAX // Not a real mode, defined as upper bound
} WMAC_AUTHENTICATION_MODE, *PWMAC_AUTHENTICATION_MODE;
*/
// Pre-configured Mode (from XP)
/*
typedef enum tagWMAC_CONFIG_MODE {
WMAC_CONFIG_ESS_STA,
WMAC_CONFIG_IBSS_STA,
WMAC_CONFIG_AUTO,
WMAC_CONFIG_AP
} WMAC_CONFIG_MODE, *PWMAC_CONFIG_MODE;
*/
typedef enum tagWMAC_SCAN_TYPE {
WMAC_SCAN_ACTIVE,
WMAC_SCAN_PASSIVE,
WMAC_SCAN_HYBRID
} WMAC_SCAN_TYPE, *PWMAC_SCAN_TYPE;
typedef enum tagWMAC_SCAN_STATE {
WMAC_NO_SCANNING,
WMAC_IS_SCANNING,
WMAC_IS_PROBEPENDING
} WMAC_SCAN_STATE, *PWMAC_SCAN_STATE;
// Notes:
// Basic Service Set state explained as following:
// WMAC_STATE_IDLE : no BSS is selected (Adhoc or Infra)
// WMAC_STATE_STARTED : no BSS is selected, start own IBSS (Adhoc only)
// WMAC_STATE_JOINTED : BSS is selected and synchronized (Adhoc or Infra)
// WMAC_STATE_AUTHPENDING : Authentication pending (Infra)
// WMAC_STATE_AUTH : Authenticated (Infra)
// WMAC_STATE_ASSOCPENDING : Association pending (Infra)
// WMAC_STATE_ASSOC : Associated (Infra)
typedef enum tagWMAC_BSS_STATE {
WMAC_STATE_IDLE,
WMAC_STATE_STARTED,
WMAC_STATE_JOINTED,
WMAC_STATE_AUTHPENDING,
WMAC_STATE_AUTH,
WMAC_STATE_ASSOCPENDING,
WMAC_STATE_ASSOC
} WMAC_BSS_STATE, *PWMAC_BSS_STATE;
// WMAC selected running mode
typedef enum tagWMAC_CURRENT_MODE {
WMAC_MODE_STANDBY,
WMAC_MODE_ESS_STA,
WMAC_MODE_IBSS_STA,
WMAC_MODE_ESS_AP
} WMAC_CURRENT_MODE, *PWMAC_CURRENT_MODE;
/*
typedef enum tagWMAC_POWER_MODE {
WMAC_POWER_CAM,
WMAC_POWER_FAST,
WMAC_POWER_MAX
} WMAC_POWER_MODE, *PWMAC_POWER_MODE;
*/
// Tx Managment Packet descriptor
typedef struct tagSTxMgmtPacket {
PUWLAN_80211HDR p80211Header;
UINT cbMPDULen;
UINT cbPayloadLen;
} STxMgmtPacket, DEF* PSTxMgmtPacket;
// Rx Managment Packet descriptor
typedef struct tagSRxMgmtPacket {
PUWLAN_80211HDR p80211Header;
QWORD qwLocalTSF;
UINT cbMPDULen;
UINT cbPayloadLen;
UINT uRSSI;
BYTE bySQ;
BYTE byRxRate;
BYTE byRxChannel;
} SRxMgmtPacket, DEF* PSRxMgmtPacket;
typedef struct tagSMgmtObject
{
PVOID pAdapter;
// MAC address
BYTE abyMACAddr[WLAN_ADDR_LEN];
// Configuration Mode
WMAC_CONFIG_MODE eConfigMode; // MAC pre-configed mode
CARD_PHY_TYPE eCurrentPHYMode;
CARD_PHY_TYPE eConfigPHYMode;
// Operation state variables
WMAC_CURRENT_MODE eCurrMode; // MAC current connection mode
WMAC_BSS_STATE eCurrState; // MAC current BSS state
PKnownBSS pCurrBSS;
BYTE byCSSGK;
BYTE byCSSPK;
// BYTE abyNewSuppRates[WLAN_IEHDR_LEN + WLAN_RATES_MAXLEN];
// BYTE abyNewExtSuppRates[WLAN_IEHDR_LEN + WLAN_RATES_MAXLEN];
// Current state vars
UINT uCurrChannel;
BYTE abyCurrSuppRates[WLAN_IEHDR_LEN + WLAN_RATES_MAXLEN + 1];
BYTE abyCurrExtSuppRates[WLAN_IEHDR_LEN + WLAN_RATES_MAXLEN + 1];
BYTE abyCurrSSID[WLAN_IEHDR_LEN + WLAN_SSID_MAXLEN + 1];
BYTE abyCurrBSSID[WLAN_BSSID_LEN];
WORD wCurrCapInfo;
WORD wCurrAID;
WORD wCurrATIMWindow;
WORD wCurrBeaconPeriod;
BOOL bIsDS;
BYTE byERPContext;
CMD_STATE eCommandState;
UINT uScanChannel;
// Desire joinning BSS vars
BYTE abyDesireSSID[WLAN_IEHDR_LEN + WLAN_SSID_MAXLEN + 1];
BYTE abyDesireBSSID[WLAN_BSSID_LEN];
// Adhoc or AP configuration vars
//BYTE abyAdHocSSID[WLAN_IEHDR_LEN + WLAN_SSID_MAXLEN + 1];
WORD wIBSSBeaconPeriod;
WORD wIBSSATIMWindow;
UINT uIBSSChannel;
BYTE abyIBSSSuppRates[WLAN_IEHDR_LEN + WLAN_RATES_MAXLEN + 1];
BYTE byAPBBType;
BYTE abyWPAIE[MAX_WPA_IE_LEN];
WORD wWPAIELen;
UINT uAssocCount;
BOOL bMoreData;
// Scan state vars
WMAC_SCAN_STATE eScanState;
WMAC_SCAN_TYPE eScanType;
UINT uScanStartCh;
UINT uScanEndCh;
WORD wScanSteps;
UINT uScanBSSType;
// Desire scannig vars
BYTE abyScanSSID[WLAN_IEHDR_LEN + WLAN_SSID_MAXLEN + 1];
BYTE abyScanBSSID[WLAN_BSSID_LEN];
// Privacy
WMAC_AUTHENTICATION_MODE eAuthenMode;
WMAC_ENCRYPTION_MODE eEncryptionMode;
BOOL bShareKeyAlgorithm;
BYTE abyChallenge[WLAN_CHALLENGE_LEN];
BOOL bPrivacyInvoked;
// Received beacon state vars
BOOL bInTIM;
BOOL bMulticastTIM;
BYTE byDTIMCount;
BYTE byDTIMPeriod;
// Power saving state vars
WMAC_POWER_MODE ePSMode;
WORD wListenInterval;
WORD wCountToWakeUp;
BOOL bInTIMWake;
PBYTE pbyPSPacketPool;
BYTE byPSPacketPool[sizeof(STxMgmtPacket) + WLAN_NULLDATA_FR_MAXLEN];
BOOL bRxBeaconInTBTTWake;
BYTE abyPSTxMap[MAX_NODE_NUM + 1];
// managment command related
UINT uCmdBusy;
UINT uCmdHostAPBusy;
// managment packet pool
PBYTE pbyMgmtPacketPool;
BYTE byMgmtPacketPool[sizeof(STxMgmtPacket) + WLAN_A3FR_MAXLEN];
// One second callback timer
struct timer_list sTimerSecondCallback;
// Temporarily Rx Mgmt Packet Descriptor
SRxMgmtPacket sRxPacket;
// link list of known bss's (scan results)
KnownBSS sBSSList[MAX_BSS_NUM];
// table list of known node
// sNodeDBList[0] is reserved for AP under Infra mode
// sNodeDBList[0] is reserved for Multicast under adhoc/AP mode
KnownNodeDB sNodeDBTable[MAX_NODE_NUM + 1];
// WPA2 PMKID Cache
SPMKIDCache gsPMKIDCache;
BOOL bRoaming;
// rate fall back vars
// associate info
SAssocInfo sAssocInfo;
// for 802.11h
BOOL b11hEnable;
BOOL bSwitchChannel;
BYTE byNewChannel;
PWLAN_IE_MEASURE_REP pCurrMeasureEIDRep;
UINT uLengthOfRepEIDs;
BYTE abyCurrentMSRReq[sizeof(STxMgmtPacket) + WLAN_A3FR_MAXLEN];
BYTE abyCurrentMSRRep[sizeof(STxMgmtPacket) + WLAN_A3FR_MAXLEN];
BYTE abyIECountry[WLAN_A3FR_MAXLEN];
BYTE abyIBSSDFSOwner[6];
BYTE byIBSSDFSRecovery;
struct sk_buff skb;
} SMgmtObject, DEF *PSMgmtObject;
/*--------------------- Export Macros ------------------------------*/
/*--------------------- Export Functions --------------------------*/
void
vMgrObjectInit(
IN HANDLE hDeviceContext
);
void
vMgrTimerInit(
IN HANDLE hDeviceContext
);
VOID
vMgrObjectReset(
IN HANDLE hDeviceContext
);
void
vMgrAssocBeginSta(
IN HANDLE hDeviceContext,
IN PSMgmtObject pMgmt,
OUT PCMD_STATUS pStatus
);
VOID
vMgrReAssocBeginSta(
IN HANDLE hDeviceContext,
IN PSMgmtObject pMgmt,
OUT PCMD_STATUS pStatus
);
VOID
vMgrDisassocBeginSta(
IN HANDLE hDeviceContext,
IN PSMgmtObject pMgmt,
IN PBYTE abyDestAddress,
IN WORD wReason,
OUT PCMD_STATUS pStatus
);
VOID
vMgrAuthenBeginSta(
IN HANDLE hDeviceContext,
IN PSMgmtObject pMgmt,
OUT PCMD_STATUS pStatus
);
VOID
vMgrCreateOwnIBSS(
IN HANDLE hDeviceContext,
OUT PCMD_STATUS pStatus
);
VOID
vMgrJoinBSSBegin(
IN HANDLE hDeviceContext,
OUT PCMD_STATUS pStatus
);
VOID
vMgrRxManagePacket(
IN HANDLE hDeviceContext,
IN PSMgmtObject pMgmt,
IN PSRxMgmtPacket pRxPacket
);
/*
VOID
vMgrScanBegin(
IN HANDLE hDeviceContext,
OUT PCMD_STATUS pStatus
);
*/
VOID
vMgrDeAuthenBeginSta(
IN HANDLE hDeviceContext,
IN PSMgmtObject pMgmt,
IN PBYTE abyDestAddress,
IN WORD wReason,
OUT PCMD_STATUS pStatus
);
BOOL
bMgrPrepareBeaconToSend(
IN HANDLE hDeviceContext,
IN PSMgmtObject pMgmt
);
BOOL
bAdd_PMKID_Candidate (
IN HANDLE hDeviceContext,
IN PBYTE pbyBSSID,
IN PSRSNCapObject psRSNCapObj
);
VOID
vFlush_PMKID_Candidate (
IN HANDLE hDeviceContext
);
#endif // __WMGR_H__

View File

@ -0,0 +1,339 @@
/*
* Copyright (c) 1996, 2003 VIA Networking Technologies, Inc.
* All rights reserved.
*
* This program is free software; you can redistribute it and/or modify
* it under the terms of the GNU General Public License as published by
* the Free Software Foundation; either version 2 of the License, or
* (at your option) any later version.
*
* This program is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
* GNU General Public License for more details.
*
* You should have received a copy of the GNU General Public License along
* with this program; if not, write to the Free Software Foundation, Inc.,
* 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA.
*
*
* File: wpa.c
*
* Purpose: Handles the Basic Service Set & Node Database functions
*
* Functions:
* WPA_ParseRSN - Parse RSN IE.
*
* Revision History:
*
* Author: Kyle Hsu
*
* Date: July 14, 2003
*
*/
#if !defined(__TTYPE_H__)
#include "ttype.h"
#endif
#if !defined(__UMEM_H__)
#include "umem.h"
#endif
#if !defined(__TMACRO_H__)
#include "tmacro.h"
#endif
#if !defined(__TETHER_H__)
#include "tether.h"
#endif
#if !defined(__DEVICE_H__)
#include "device.h"
#endif
#if !defined(__80211HDR_H__)
#include "80211hdr.h"
#endif
#if !defined(__BSSDB_H__)
#include "bssdb.h"
#endif
#if !defined(__WMGR_H__)
#include "wmgr.h"
#endif
#if !defined(__WPA_H__)
#include "wpa.h"
#endif
#if !defined(__80211MGR_H__)
#include "80211mgr.h"
#endif
/*--------------------- Static Variables --------------------------*/
static int msglevel =MSG_LEVEL_INFO;
const BYTE abyOUI00[4] = { 0x00, 0x50, 0xf2, 0x00 };
const BYTE abyOUI01[4] = { 0x00, 0x50, 0xf2, 0x01 };
const BYTE abyOUI02[4] = { 0x00, 0x50, 0xf2, 0x02 };
const BYTE abyOUI03[4] = { 0x00, 0x50, 0xf2, 0x03 };
const BYTE abyOUI04[4] = { 0x00, 0x50, 0xf2, 0x04 };
const BYTE abyOUI05[4] = { 0x00, 0x50, 0xf2, 0x05 };
/*+
*
* Description:
* Clear RSN information in BSSList.
*
* Parameters:
* In:
* pBSSList - BSS list.
* Out:
* none
*
* Return Value: none.
*
-*/
VOID
WPA_ClearRSN (
IN PKnownBSS pBSSList
)
{
int ii;
pBSSList->byGKType = WPA_TKIP;
for (ii=0; ii < 4; ii ++)
pBSSList->abyPKType[ii] = WPA_TKIP;
pBSSList->wPKCount = 0;
for (ii=0; ii < 4; ii ++)
pBSSList->abyAuthType[ii] = WPA_AUTH_IEEE802_1X;
pBSSList->wAuthCount = 0;
pBSSList->byDefaultK_as_PK = 0;
pBSSList->byReplayIdx = 0;
pBSSList->sRSNCapObj.bRSNCapExist = FALSE;
pBSSList->sRSNCapObj.wRSNCap = 0;
pBSSList->bWPAValid = FALSE;
}
/*+
*
* Description:
* Parse RSN IE.
*
* Parameters:
* In:
* pBSSList - BSS list.
* pRSN - Pointer to the RSN IE.
* Out:
* none
*
* Return Value: none.
*
-*/
VOID
WPA_ParseRSN (
IN PKnownBSS pBSSList,
IN PWLAN_IE_RSN_EXT pRSN
)
{
PWLAN_IE_RSN_AUTH pIE_RSN_Auth = NULL;
int i, j, m, n = 0;
PBYTE pbyCaps;
WPA_ClearRSN(pBSSList);
DEVICE_PRT(MSG_LEVEL_DEBUG, KERN_INFO"WPA_ParseRSN: [%d]\n", pRSN->len);
// information element header makes sense
if ((pRSN->len >= 6) // oui1(4)+ver(2)
&& (pRSN->byElementID == WLAN_EID_RSN_WPA) && MEMEqualMemory(pRSN->abyOUI, abyOUI01, 4)
&& (pRSN->wVersion == 1)) {
DEVICE_PRT(MSG_LEVEL_DEBUG, KERN_INFO"Legal RSN\n");
// update each variable if pRSN is long enough to contain the variable
if (pRSN->len >= 10) //oui1(4)+ver(2)+GKSuite(4)
{
if (MEMEqualMemory(pRSN->abyMulticast, abyOUI01, 4))
pBSSList->byGKType = WPA_WEP40;
else if (MEMEqualMemory(pRSN->abyMulticast, abyOUI02, 4))
pBSSList->byGKType = WPA_TKIP;
else if (MEMEqualMemory(pRSN->abyMulticast, abyOUI03, 4))
pBSSList->byGKType = WPA_AESWRAP;
else if (MEMEqualMemory(pRSN->abyMulticast, abyOUI04, 4))
pBSSList->byGKType = WPA_AESCCMP;
else if (MEMEqualMemory(pRSN->abyMulticast, abyOUI05, 4))
pBSSList->byGKType = WPA_WEP104;
else
// any vendor checks here
pBSSList->byGKType = WPA_NONE;
DEVICE_PRT(MSG_LEVEL_DEBUG, KERN_INFO"byGKType: %x\n", pBSSList->byGKType);
}
if (pRSN->len >= 12) //oui1(4)+ver(2)+GKS(4)+PKSCnt(2)
{
j = 0;
DEVICE_PRT(MSG_LEVEL_DEBUG, KERN_INFO"wPKCount: %d, sizeof(pBSSList->abyPKType): %d\n", pRSN->wPKCount, sizeof(pBSSList->abyPKType));
for(i = 0; (i < pRSN->wPKCount) && (j < sizeof(pBSSList->abyPKType)/sizeof(BYTE)); i++) {
if(pRSN->len >= 12+i*4+4) { //oui1(4)+ver(2)+GKS(4)+PKSCnt(2)+PKS(4*i)
if (MEMEqualMemory(pRSN->PKSList[i].abyOUI, abyOUI00, 4))
pBSSList->abyPKType[j++] = WPA_NONE;
else if (MEMEqualMemory(pRSN->PKSList[i].abyOUI, abyOUI02, 4))
pBSSList->abyPKType[j++] = WPA_TKIP;
else if (MEMEqualMemory(pRSN->PKSList[i].abyOUI, abyOUI03, 4))
pBSSList->abyPKType[j++] = WPA_AESWRAP;
else if (MEMEqualMemory(pRSN->PKSList[i].abyOUI, abyOUI04, 4))
pBSSList->abyPKType[j++] = WPA_AESCCMP;
else
// any vendor checks here
;
}
else
break;
//DBG_PRN_GRP14(("abyPKType[%d]: %X\n", j-1, pBSSList->abyPKType[j-1]));
} //for
pBSSList->wPKCount = (WORD)j;
DEVICE_PRT(MSG_LEVEL_DEBUG, KERN_INFO"wPKCount: %d\n", pBSSList->wPKCount);
}
m = pRSN->wPKCount;
DEVICE_PRT(MSG_LEVEL_DEBUG, KERN_INFO"m: %d\n", m);
DEVICE_PRT(MSG_LEVEL_DEBUG, KERN_INFO"14+m*4: %d\n", 14+m*4);
if (pRSN->len >= 14+m*4) { //oui1(4)+ver(2)+GKS(4)+PKSCnt(2)+PKS(4*m)+AKC(2)
// overlay IE_RSN_Auth structure into correct place
pIE_RSN_Auth = (PWLAN_IE_RSN_AUTH) pRSN->PKSList[m].abyOUI;
j = 0;
DEVICE_PRT(MSG_LEVEL_DEBUG, KERN_INFO"wAuthCount: %d, sizeof(pBSSList->abyAuthType): %d\n",
pIE_RSN_Auth->wAuthCount, sizeof(pBSSList->abyAuthType));
for(i = 0; (i < pIE_RSN_Auth->wAuthCount) && (j < sizeof(pBSSList->abyAuthType)/sizeof(BYTE)); i++) {
if(pRSN->len >= 14+4+(m+i)*4) { //oui1(4)+ver(2)+GKS(4)+PKSCnt(2)+PKS(4*m)+AKC(2)+AKS(4*i)
if (MEMEqualMemory(pIE_RSN_Auth->AuthKSList[i].abyOUI, abyOUI01, 4))
pBSSList->abyAuthType[j++] = WPA_AUTH_IEEE802_1X;
else if (MEMEqualMemory(pIE_RSN_Auth->AuthKSList[i].abyOUI, abyOUI02, 4))
pBSSList->abyAuthType[j++] = WPA_AUTH_PSK;
else
// any vendor checks here
;
}
else
break;
//DBG_PRN_GRP14(("abyAuthType[%d]: %X\n", j-1, pBSSList->abyAuthType[j-1]));
}
if(j > 0)
pBSSList->wAuthCount = (WORD)j;
DEVICE_PRT(MSG_LEVEL_DEBUG, KERN_INFO"wAuthCount: %d\n", pBSSList->wAuthCount);
}
if (pIE_RSN_Auth != NULL) {
n = pIE_RSN_Auth->wAuthCount;
DEVICE_PRT(MSG_LEVEL_DEBUG, KERN_INFO"n: %d\n", n);
DEVICE_PRT(MSG_LEVEL_DEBUG, KERN_INFO"14+4+(m+n)*4: %d\n", 14+4+(m+n)*4);
if(pRSN->len+2 >= 14+4+(m+n)*4) { //oui1(4)+ver(2)+GKS(4)+PKSCnt(2)+PKS(4*m)+AKC(2)+AKS(4*n)+Cap(2)
pbyCaps = (PBYTE)pIE_RSN_Auth->AuthKSList[n].abyOUI;
pBSSList->byDefaultK_as_PK = (*pbyCaps) & WPA_GROUPFLAG;
pBSSList->byReplayIdx = 2 << ((*pbyCaps >> WPA_REPLAYBITSSHIFT) & WPA_REPLAYBITS);
pBSSList->sRSNCapObj.bRSNCapExist = TRUE;
pBSSList->sRSNCapObj.wRSNCap = *(PWORD)pbyCaps;
//DBG_PRN_GRP14(("pbyCaps: %X\n", *pbyCaps));
//DBG_PRN_GRP14(("byDefaultK_as_PK: %X\n", pBSSList->byDefaultK_as_PK));
//DBG_PRN_GRP14(("byReplayIdx: %X\n", pBSSList->byReplayIdx));
}
}
pBSSList->bWPAValid = TRUE;
}
}
/*+
*
* Description:
* Search RSN information in BSSList.
*
* Parameters:
* In:
* byCmd - Search type
* byEncrypt- Encrcypt Type
* pBSSList - BSS list
* Out:
* none
*
* Return Value: none.
*
-*/
BOOL
WPA_SearchRSN (
BYTE byCmd,
BYTE byEncrypt,
IN PKnownBSS pBSSList
)
{
int ii;
BYTE byPKType = WPA_NONE;
if (pBSSList->bWPAValid == FALSE)
return FALSE;
switch(byCmd) {
case 0:
if (byEncrypt != pBSSList->byGKType)
return FALSE;
if (pBSSList->wPKCount > 0) {
for (ii = 0; ii < pBSSList->wPKCount; ii ++) {
if (pBSSList->abyPKType[ii] == WPA_AESCCMP)
byPKType = WPA_AESCCMP;
else if ((pBSSList->abyPKType[ii] == WPA_TKIP) && (byPKType != WPA_AESCCMP))
byPKType = WPA_TKIP;
else if ((pBSSList->abyPKType[ii] == WPA_WEP40) && (byPKType != WPA_AESCCMP) && (byPKType != WPA_TKIP))
byPKType = WPA_WEP40;
else if ((pBSSList->abyPKType[ii] == WPA_WEP104) && (byPKType != WPA_AESCCMP) && (byPKType != WPA_TKIP))
byPKType = WPA_WEP104;
}
if (byEncrypt != byPKType)
return FALSE;
}
return TRUE;
// if (pBSSList->wAuthCount > 0)
// for (ii=0; ii < pBSSList->wAuthCount; ii ++)
// if (byAuth == pBSSList->abyAuthType[ii])
// break;
break;
default:
break;
}
return FALSE;
}
/*+
*
* Description:
* Check if RSN IE makes sense.
*
* Parameters:
* In:
* pRSN - Pointer to the RSN IE.
* Out:
* none
*
* Return Value: none.
*
-*/
BOOL
WPAb_Is_RSN (
IN PWLAN_IE_RSN_EXT pRSN
)
{
if (pRSN == NULL)
return FALSE;
if ((pRSN->len >= 6) && // oui1(4)+ver(2)
(pRSN->byElementID == WLAN_EID_RSN_WPA) && MEMEqualMemory(pRSN->abyOUI, abyOUI01, 4) &&
(pRSN->wVersion == 1)) {
return TRUE;
}
else
return FALSE;
}

View File

@ -0,0 +1,98 @@
/*
* Copyright (c) 1996, 2003 VIA Networking Technologies, Inc.
* All rights reserved.
*
* This program is free software; you can redistribute it and/or modify
* it under the terms of the GNU General Public License as published by
* the Free Software Foundation; either version 2 of the License, or
* (at your option) any later version.
*
* This program is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
* GNU General Public License for more details.
*
* You should have received a copy of the GNU General Public License along
* with this program; if not, write to the Free Software Foundation, Inc.,
* 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA.
*
*
* File: wpa.h
*
* Purpose: Defines the macros, types, and functions for dealing
* with WPA informations.
*
* Author: Kyle Hsu
*
* Date: Jul 14, 2003
*
*/
#ifndef __WPA_H__
#define __WPA_H__
#if !defined(__TTYPE_H__)
#include "ttype.h"
#endif
#if !defined(__80211HDR_H__)
#include "80211hdr.h"
#endif
/*--------------------- Export Definitions -------------------------*/
#define WPA_NONE 0
#define WPA_WEP40 1
#define WPA_TKIP 2
#define WPA_AESWRAP 3
#define WPA_AESCCMP 4
#define WPA_WEP104 5
#define WPA_AUTH_IEEE802_1X 1
#define WPA_AUTH_PSK 2
#define WPA_GROUPFLAG 0x02
#define WPA_REPLAYBITSSHIFT 2
#define WPA_REPLAYBITS 0x03
/*--------------------- Export Classes ----------------------------*/
/*--------------------- Export Variables --------------------------*/
/*--------------------- Export Types ------------------------------*/
/*--------------------- Export Functions --------------------------*/
#ifdef __cplusplus
extern "C" { /* Assume C declarations for C++ */
#endif /* __cplusplus */
VOID
WPA_ClearRSN(
IN PKnownBSS pBSSList
);
VOID
WPA_ParseRSN(
IN PKnownBSS pBSSList,
IN PWLAN_IE_RSN_EXT pRSN
);
BOOL
WPA_SearchRSN(
BYTE byCmd,
BYTE byEncrypt,
IN PKnownBSS pBSSList
);
BOOL
WPAb_Is_RSN(
IN PWLAN_IE_RSN_EXT pRSN
);
#ifdef __cplusplus
} /* End of extern "C" { */
#endif /* __cplusplus */
#endif // __WPA_H__

View File

@ -0,0 +1,373 @@
/*
* Copyright (c) 1996, 2003 VIA Networking Technologies, Inc.
* All rights reserved.
*
* This program is free software; you can redistribute it and/or modify
* it under the terms of the GNU General Public License as published by
* the Free Software Foundation; either version 2 of the License, or
* (at your option) any later version.
*
* This program is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
* GNU General Public License for more details.
*
* You should have received a copy of the GNU General Public License along
* with this program; if not, write to the Free Software Foundation, Inc.,
* 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA.
*
*
* File: wpa2.c
*
* Purpose: Handles the Basic Service Set & Node Database functions
*
* Functions:
*
* Revision History:
*
* Author: Yiching Chen
*
* Date: Oct. 4, 2004
*
*/
#if !defined(__WPA2_H__)
#include "wpa2.h"
#endif
#if !defined(__UMEM_H__)
#include "umem.h"
#endif
#if !defined(__DEVICE_H__)
#include "device.h"
#endif
#if !defined(__WMGR_H__)
#include "wmgr.h"
#endif
/*--------------------- Static Definitions -------------------------*/
static int msglevel =MSG_LEVEL_INFO;
//static int msglevel =MSG_LEVEL_DEBUG;
/*--------------------- Static Classes ----------------------------*/
/*--------------------- Static Variables --------------------------*/
const BYTE abyOUIGK[4] = { 0x00, 0x0F, 0xAC, 0x00 };
const BYTE abyOUIWEP40[4] = { 0x00, 0x0F, 0xAC, 0x01 };
const BYTE abyOUIWEP104[4] = { 0x00, 0x0F, 0xAC, 0x05 };
const BYTE abyOUITKIP[4] = { 0x00, 0x0F, 0xAC, 0x02 };
const BYTE abyOUICCMP[4] = { 0x00, 0x0F, 0xAC, 0x04 };
const BYTE abyOUI8021X[4] = { 0x00, 0x0F, 0xAC, 0x01 };
const BYTE abyOUIPSK[4] = { 0x00, 0x0F, 0xAC, 0x02 };
/*--------------------- Static Functions --------------------------*/
/*--------------------- Export Variables --------------------------*/
/*--------------------- Export Functions --------------------------*/
/*+
*
* Description:
* Clear RSN information in BSSList.
*
* Parameters:
* In:
* pBSSNode - BSS list.
* Out:
* none
*
* Return Value: none.
*
-*/
VOID
WPA2_ClearRSN (
IN PKnownBSS pBSSNode
)
{
int ii;
pBSSNode->bWPA2Valid = FALSE;
pBSSNode->byCSSGK = WLAN_11i_CSS_CCMP;
for (ii=0; ii < 4; ii ++)
pBSSNode->abyCSSPK[ii] = WLAN_11i_CSS_CCMP;
pBSSNode->wCSSPKCount = 1;
for (ii=0; ii < 4; ii ++)
pBSSNode->abyAKMSSAuthType[ii] = WLAN_11i_AKMSS_802_1X;
pBSSNode->wAKMSSAuthCount = 1;
pBSSNode->sRSNCapObj.bRSNCapExist = FALSE;
pBSSNode->sRSNCapObj.wRSNCap = 0;
}
/*+
*
* Description:
* Parse RSN IE.
*
* Parameters:
* In:
* pBSSNode - BSS list.
* pRSN - Pointer to the RSN IE.
* Out:
* none
*
* Return Value: none.
*
-*/
VOID
WPA2vParseRSN (
IN PKnownBSS pBSSNode,
IN PWLAN_IE_RSN pRSN
)
{
int i, j;
WORD m = 0, n = 0;
PBYTE pbyOUI;
BOOL bUseGK = FALSE;
DEVICE_PRT(MSG_LEVEL_DEBUG, KERN_INFO"WPA2_ParseRSN: [%d]\n", pRSN->len);
WPA2_ClearRSN(pBSSNode);
if (pRSN->len == 2) { // ver(2)
if ((pRSN->byElementID == WLAN_EID_RSN) && (pRSN->wVersion == 1)) {
pBSSNode->bWPA2Valid = TRUE;
}
return;
}
if (pRSN->len < 6) { // ver(2) + GK(4)
// invalid CSS, P802.11i/D10.0, p31
return;
}
// information element header makes sense
if ((pRSN->byElementID == WLAN_EID_RSN) &&
(pRSN->wVersion == 1)) {
DEVICE_PRT(MSG_LEVEL_DEBUG, KERN_INFO"Legal 802.11i RSN\n");
pbyOUI = &(pRSN->abyRSN[0]);
if (MEMEqualMemory(pbyOUI, abyOUIWEP40, 4))
pBSSNode->byCSSGK = WLAN_11i_CSS_WEP40;
else if (MEMEqualMemory(pbyOUI, abyOUITKIP, 4))
pBSSNode->byCSSGK = WLAN_11i_CSS_TKIP;
else if (MEMEqualMemory(pbyOUI, abyOUICCMP, 4))
pBSSNode->byCSSGK = WLAN_11i_CSS_CCMP;
else if (MEMEqualMemory(pbyOUI, abyOUIWEP104, 4))
pBSSNode->byCSSGK = WLAN_11i_CSS_WEP104;
else if (MEMEqualMemory(pbyOUI, abyOUIGK, 4)) {
// invalid CSS, P802.11i/D10.0, p32
return;
} else
// any vendor checks here
pBSSNode->byCSSGK = WLAN_11i_CSS_UNKNOWN;
DEVICE_PRT(MSG_LEVEL_DEBUG, KERN_INFO"802.11i CSS: %X\n", pBSSNode->byCSSGK);
if (pRSN->len == 6) {
pBSSNode->bWPA2Valid = TRUE;
return;
}
if (pRSN->len >= 8) { // ver(2) + GK(4) + PK count(2)
pBSSNode->wCSSPKCount = *((PWORD) &(pRSN->abyRSN[4]));
j = 0;
pbyOUI = &(pRSN->abyRSN[6]);
for (i = 0; (i < pBSSNode->wCSSPKCount) && (j < sizeof(pBSSNode->abyCSSPK)/sizeof(BYTE)); i++) {
if (pRSN->len >= 8+i*4+4) { // ver(2)+GK(4)+PKCnt(2)+PKS(4*i)
if (MEMEqualMemory(pbyOUI, abyOUIGK, 4)) {
pBSSNode->abyCSSPK[j++] = WLAN_11i_CSS_USE_GROUP;
bUseGK = TRUE;
} else if (MEMEqualMemory(pbyOUI, abyOUIWEP40, 4)) {
// Invialid CSS, continue to parsing
} else if (MEMEqualMemory(pbyOUI, abyOUITKIP, 4)) {
if (pBSSNode->byCSSGK != WLAN_11i_CSS_CCMP)
pBSSNode->abyCSSPK[j++] = WLAN_11i_CSS_TKIP;
else
; // Invialid CSS, continue to parsing
} else if (MEMEqualMemory(pbyOUI, abyOUICCMP, 4)) {
pBSSNode->abyCSSPK[j++] = WLAN_11i_CSS_CCMP;
} else if (MEMEqualMemory(pbyOUI, abyOUIWEP104, 4)) {
// Invialid CSS, continue to parsing
} else {
// any vendor checks here
pBSSNode->abyCSSPK[j++] = WLAN_11i_CSS_UNKNOWN;
}
pbyOUI += 4;
DEVICE_PRT(MSG_LEVEL_DEBUG, KERN_INFO"abyCSSPK[%d]: %X\n", j-1, pBSSNode->abyCSSPK[j-1]);
} else
break;
} //for
if (bUseGK == TRUE) {
if (j != 1) {
// invalid CSS, This should be only PK CSS.
return;
}
if (pBSSNode->byCSSGK == WLAN_11i_CSS_CCMP) {
// invalid CSS, If CCMP is enable , PK can't be CSSGK.
return;
}
}
if ((pBSSNode->wCSSPKCount != 0) && (j == 0)) {
// invalid CSS, No valid PK.
return;
}
pBSSNode->wCSSPKCount = (WORD)j;
DEVICE_PRT(MSG_LEVEL_DEBUG, KERN_INFO"wCSSPKCount: %d\n", pBSSNode->wCSSPKCount);
}
m = *((PWORD) &(pRSN->abyRSN[4]));
if (pRSN->len >= 10+m*4) { // ver(2) + GK(4) + PK count(2) + PKS(4*m) + AKMSS count(2)
pBSSNode->wAKMSSAuthCount = *((PWORD) &(pRSN->abyRSN[6+4*m]));;
j = 0;
pbyOUI = &(pRSN->abyRSN[8+4*m]);
for (i = 0; (i < pBSSNode->wAKMSSAuthCount) && (j < sizeof(pBSSNode->abyAKMSSAuthType)/sizeof(BYTE)); i++) {
if (pRSN->len >= 10+(m+i)*4+4) { // ver(2)+GK(4)+PKCnt(2)+PKS(4*m)+AKMSS(2)+AKS(4*i)
if (MEMEqualMemory(pbyOUI, abyOUI8021X, 4))
pBSSNode->abyAKMSSAuthType[j++] = WLAN_11i_AKMSS_802_1X;
else if (MEMEqualMemory(pbyOUI, abyOUIPSK, 4))
pBSSNode->abyAKMSSAuthType[j++] = WLAN_11i_AKMSS_PSK;
else
// any vendor checks here
pBSSNode->abyAKMSSAuthType[j++] = WLAN_11i_AKMSS_UNKNOWN;
DEVICE_PRT(MSG_LEVEL_DEBUG, KERN_INFO"abyAKMSSAuthType[%d]: %X\n", j-1, pBSSNode->abyAKMSSAuthType[j-1]);
} else
break;
}
pBSSNode->wAKMSSAuthCount = (WORD)j;
DEVICE_PRT(MSG_LEVEL_DEBUG, KERN_INFO"wAKMSSAuthCount: %d\n", pBSSNode->wAKMSSAuthCount);
n = *((PWORD) &(pRSN->abyRSN[6+4*m]));;
if (pRSN->len >= 12+4*m+4*n) { // ver(2)+GK(4)+PKCnt(2)+PKS(4*m)+AKMSSCnt(2)+AKMSS(4*n)+Cap(2)
pBSSNode->sRSNCapObj.bRSNCapExist = TRUE;
pBSSNode->sRSNCapObj.wRSNCap = *((PWORD) &(pRSN->abyRSN[8+4*m+4*n]));
}
}
//ignore PMKID lists bcs only (Re)Assocrequest has this field
pBSSNode->bWPA2Valid = TRUE;
}
}
/*+
*
* Description:
* Set WPA IEs
*
* Parameters:
* In:
* pMgmtHandle - Pointer to management object
* Out:
* pRSNIEs - Pointer to the RSN IE to set.
*
* Return Value: length of IEs.
*
-*/
UINT
WPA2uSetIEs(
IN PVOID pMgmtHandle,
OUT PWLAN_IE_RSN pRSNIEs
)
{
PSMgmtObject pMgmt = (PSMgmtObject) pMgmtHandle;
PBYTE pbyBuffer = NULL;
UINT ii = 0;
PWORD pwPMKID = NULL;
if (pRSNIEs == NULL) {
return(0);
}
if (((pMgmt->eAuthenMode == WMAC_AUTH_WPA2) ||
(pMgmt->eAuthenMode == WMAC_AUTH_WPA2PSK)) &&
(pMgmt->pCurrBSS != NULL)) {
/* WPA2 IE */
pbyBuffer = (PBYTE) pRSNIEs;
pRSNIEs->byElementID = WLAN_EID_RSN;
pRSNIEs->len = 6; //Version(2)+GK(4)
pRSNIEs->wVersion = 1;
//Group Key Cipher Suite
pRSNIEs->abyRSN[0] = 0x00;
pRSNIEs->abyRSN[1] = 0x0F;
pRSNIEs->abyRSN[2] = 0xAC;
if (pMgmt->byCSSGK == KEY_CTL_WEP) {
pRSNIEs->abyRSN[3] = pMgmt->pCurrBSS->byCSSGK;
} else if (pMgmt->byCSSGK == KEY_CTL_TKIP) {
pRSNIEs->abyRSN[3] = WLAN_11i_CSS_TKIP;
} else if (pMgmt->byCSSGK == KEY_CTL_CCMP) {
pRSNIEs->abyRSN[3] = WLAN_11i_CSS_CCMP;
} else {
pRSNIEs->abyRSN[3] = WLAN_11i_CSS_UNKNOWN;
}
// Pairwise Key Cipher Suite
pRSNIEs->abyRSN[4] = 1;
pRSNIEs->abyRSN[5] = 0;
pRSNIEs->abyRSN[6] = 0x00;
pRSNIEs->abyRSN[7] = 0x0F;
pRSNIEs->abyRSN[8] = 0xAC;
if (pMgmt->byCSSPK == KEY_CTL_TKIP) {
pRSNIEs->abyRSN[9] = WLAN_11i_CSS_TKIP;
} else if (pMgmt->byCSSPK == KEY_CTL_CCMP) {
pRSNIEs->abyRSN[9] = WLAN_11i_CSS_CCMP;
} else if (pMgmt->byCSSPK == KEY_CTL_NONE) {
pRSNIEs->abyRSN[9] = WLAN_11i_CSS_USE_GROUP;
} else {
pRSNIEs->abyRSN[9] = WLAN_11i_CSS_UNKNOWN;
}
pRSNIEs->len += 6;
// Auth Key Management Suite
pRSNIEs->abyRSN[10] = 1;
pRSNIEs->abyRSN[11] = 0;
pRSNIEs->abyRSN[12] = 0x00;
pRSNIEs->abyRSN[13] = 0x0F;
pRSNIEs->abyRSN[14] = 0xAC;
if (pMgmt->eAuthenMode == WMAC_AUTH_WPA2PSK) {
pRSNIEs->abyRSN[15] = WLAN_11i_AKMSS_PSK;
} else if (pMgmt->eAuthenMode == WMAC_AUTH_WPA2) {
pRSNIEs->abyRSN[15] = WLAN_11i_AKMSS_802_1X;
} else {
pRSNIEs->abyRSN[15] = WLAN_11i_AKMSS_UNKNOWN;
}
pRSNIEs->len +=6;
// RSN Capabilites
if (pMgmt->pCurrBSS->sRSNCapObj.bRSNCapExist == TRUE) {
MEMvCopy(&pRSNIEs->abyRSN[16], &pMgmt->pCurrBSS->sRSNCapObj.wRSNCap, 2);
} else {
pRSNIEs->abyRSN[16] = 0;
pRSNIEs->abyRSN[17] = 0;
}
pRSNIEs->len +=2;
if ((pMgmt->gsPMKIDCache.BSSIDInfoCount > 0) &&
(pMgmt->bRoaming == TRUE) &&
(pMgmt->eAuthenMode == WMAC_AUTH_WPA2)) {
// RSN PMKID
pwPMKID = (PWORD)(&pRSNIEs->abyRSN[18]); // Point to PMKID count
*pwPMKID = 0; // Initialize PMKID count
pbyBuffer = &pRSNIEs->abyRSN[20]; // Point to PMKID list
for (ii = 0; ii < pMgmt->gsPMKIDCache.BSSIDInfoCount; ii++) {
if (MEMEqualMemory(&pMgmt->gsPMKIDCache.BSSIDInfo[ii].abyBSSID[0], pMgmt->abyCurrBSSID, U_ETHER_ADDR_LEN)) {
(*pwPMKID) ++;
MEMvCopy(pbyBuffer, pMgmt->gsPMKIDCache.BSSIDInfo[ii].abyPMKID, 16);
pbyBuffer += 16;
}
}
if (*pwPMKID != 0) {
pRSNIEs->len += (2 + (*pwPMKID)*16);
} else {
pbyBuffer = &pRSNIEs->abyRSN[18];
}
}
return(pRSNIEs->len + WLAN_IEHDR_LEN);
}
return(0);
}

View File

@ -0,0 +1,100 @@
/*
* Copyright (c) 1996, 2003 VIA Networking Technologies, Inc.
* All rights reserved.
*
* This program is free software; you can redistribute it and/or modify
* it under the terms of the GNU General Public License as published by
* the Free Software Foundation; either version 2 of the License, or
* (at your option) any later version.
*
* This program is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
* GNU General Public License for more details.
*
* You should have received a copy of the GNU General Public License along
* with this program; if not, write to the Free Software Foundation, Inc.,
* 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA.
*
*
* File: wpa2.h
*
* Purpose: Defines the macros, types, and functions for dealing
* with WPA2 informations.
*
* Author: Yiching Chen
*
* Date: Oct. 4, 2004
*
*/
#ifndef __WPA2_H__
#define __WPA2_H__
#if !defined(__TTYPE_H__)
#include "ttype.h"
#endif
#if !defined(__80211MGR_H__)
#include "80211mgr.h"
#endif
#if !defined(__80211HDR_H__)
#include "80211hdr.h"
#endif
#if !defined(__BSSDB_H__)
#include "bssdb.h"
#endif
#if !defined(__VNTWIFI_H__)
#include "vntwifi.h"
#endif
/*--------------------- Export Definitions -------------------------*/
typedef struct tagsPMKIDInfo {
BYTE abyBSSID[6];
BYTE abyPMKID[16];
} PMKIDInfo, *PPMKIDInfo;
typedef struct tagSPMKIDCache {
ULONG BSSIDInfoCount;
PMKIDInfo BSSIDInfo[MAX_PMKID_CACHE];
} SPMKIDCache, *PSPMKIDCache;
/*--------------------- Export Classes ----------------------------*/
/*--------------------- Export Variables --------------------------*/
/*--------------------- Export Types ------------------------------*/
/*--------------------- Export Functions --------------------------*/
#ifdef __cplusplus
extern "C" { /* Assume C declarations for C++ */
#endif /* __cplusplus */
VOID
WPA2_ClearRSN (
IN PKnownBSS pBSSNode
);
VOID
WPA2vParseRSN (
IN PKnownBSS pBSSNode,
IN PWLAN_IE_RSN pRSN
);
UINT
WPA2uSetIEs(
IN PVOID pMgmtHandle,
OUT PWLAN_IE_RSN pRSNIEs
);
#ifdef __cplusplus
} /* End of extern "C" { */
#endif /* __cplusplus */
#endif // __WPA2_H__

File diff suppressed because it is too large Load Diff

View File

@ -0,0 +1,89 @@
/*
* Copyright (c) 1996, 2003 VIA Networking Technologies, Inc.
* All rights reserved.
*
* This program is free software; you can redistribute it and/or modify
* it under the terms of the GNU General Public License as published by
* the Free Software Foundation; either version 2 of the License, or
* (at your option) any later version.
*
* This program is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
* GNU General Public License for more details.
*
* You should have received a copy of the GNU General Public License along
* with this program; if not, write to the Free Software Foundation, Inc.,
* 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA.
*
* File: wpactl.h
*
* Purpose:
*
* Author: Lyndon Chen
*
* Date: March 1, 2005
*
*/
#ifndef __WPACTL_H__
#define __WPACTL_H__
#if !defined(__DEVICE_H__)
#include "device.h"
#endif
#ifdef WPA_SUPPLICANT_DRIVER_WEXT_SUPPORT
#if !defined(__IOWPA_H__)
#include "iowpa.h"
#endif
#endif
/*--------------------- Export Definitions -------------------------*/
//WPA related
typedef enum { WPA_ALG_NONE, WPA_ALG_WEP, WPA_ALG_TKIP, WPA_ALG_CCMP } wpa_alg;
typedef enum { CIPHER_NONE, CIPHER_WEP40, CIPHER_TKIP, CIPHER_CCMP,
CIPHER_WEP104 } wpa_cipher;
typedef enum { KEY_MGMT_802_1X, KEY_MGMT_CCKM,KEY_MGMT_PSK, KEY_MGMT_NONE,
KEY_MGMT_802_1X_NO_WPA, KEY_MGMT_WPA_NONE } wpa_key_mgmt;
#define AUTH_ALG_OPEN_SYSTEM 0x01
#define AUTH_ALG_SHARED_KEY 0x02
#define AUTH_ALG_LEAP 0x04
#define GENERIC_INFO_ELEM 0xdd
#define RSN_INFO_ELEM 0x30
typedef ULONGLONG NDIS_802_11_KEY_RSC;
/*--------------------- Export Classes ----------------------------*/
/*--------------------- Export Variables --------------------------*/
/*--------------------- Export Functions --------------------------*/
#ifdef __cplusplus
extern "C" { /* Assume C declarations for C++ */
#endif /* __cplusplus */
int wpa_set_wpadev(PSDevice pDevice, int val);
int wpa_ioctl(PSDevice pDevice, struct iw_point *p);
int wpa_set_keys(PSDevice pDevice, void *ctx, BOOL fcpfkernel);
#ifdef __cplusplus
} /* End of extern "C" { */
#endif /* __cplusplus */
#endif // __WPACL_H__

View File

@ -0,0 +1,211 @@
/*
* Copyright (c) 1996, 2003 VIA Networking Technologies, Inc.
* All rights reserved.
*
* This program is free software; you can redistribute it and/or modify
* it under the terms of the GNU General Public License as published by
* the Free Software Foundation; either version 2 of the License, or
* (at your option) any later version.
*
* This program is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
* GNU General Public License for more details.
*
* You should have received a copy of the GNU General Public License along
* with this program; if not, write to the Free Software Foundation, Inc.,
* 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA.
*
* File: wroute.c
*
* Purpose: handle WMAC frame relay & filterring
*
* Author: Lyndon Chen
*
* Date: May 20, 2003
*
* Functions:
* ROUTEbRelay - Relay packet
*
* Revision History:
*
*/
#if !defined(__MAC_H__)
#include "mac.h"
#endif
#if !defined(__TCRC_H__)
#include "tcrc.h"
#endif
#if !defined(__RXTX_H__)
#include "rxtx.h"
#endif
#if !defined(__WROUTE_H__)
#include "wroute.h"
#endif
#if !defined(__CARD_H__)
#include "card.h"
#endif
#if !defined(__BASEBAND_H__)
#include "baseband.h"
#endif
/*--------------------- Static Definitions -------------------------*/
/*--------------------- Static Classes ----------------------------*/
/*--------------------- Static Variables --------------------------*/
static int msglevel =MSG_LEVEL_INFO;
//static int msglevel =MSG_LEVEL_DEBUG;
/*--------------------- Static Functions --------------------------*/
/*--------------------- Export Variables --------------------------*/
/*
* Description:
* Relay packet. Return TRUE if packet is copy to DMA1
*
* Parameters:
* In:
* pDevice -
* pbySkbData - rx packet skb data
* Out:
* TURE, FALSE
*
* Return Value: TRUE if packet duplicate; otherwise FALSE
*
*/
BOOL ROUTEbRelay (PSDevice pDevice, PBYTE pbySkbData, UINT uDataLen, UINT uNodeIndex)
{
PSMgmtObject pMgmt = pDevice->pMgmt;
PSTxDesc pHeadTD, pLastTD;
UINT cbFrameBodySize;
UINT uMACfragNum;
BYTE byPktTyp;
BOOL bNeedEncryption = FALSE;
SKeyItem STempKey;
PSKeyItem pTransmitKey = NULL;
UINT cbHeaderSize;
UINT ii;
PBYTE pbyBSSID;
if (AVAIL_TD(pDevice, TYPE_AC0DMA)<=0) {
DEVICE_PRT(MSG_LEVEL_DEBUG, KERN_INFO "Relay can't allocate TD1..\n");
return FALSE;
}
pHeadTD = pDevice->apCurrTD[TYPE_AC0DMA];
pHeadTD->m_td1TD1.byTCR = (TCR_EDP|TCR_STP);
memcpy(pDevice->sTxEthHeader.abyDstAddr, (PBYTE)pbySkbData, U_HEADER_LEN);
cbFrameBodySize = uDataLen - U_HEADER_LEN;
if (ntohs(pDevice->sTxEthHeader.wType) > MAX_DATA_LEN) {
cbFrameBodySize += 8;
}
if (pDevice->bEncryptionEnable == TRUE) {
bNeedEncryption = TRUE;
// get group key
pbyBSSID = pDevice->abyBroadcastAddr;
if(KeybGetTransmitKey(&(pDevice->sKey), pbyBSSID, GROUP_KEY, &pTransmitKey) == FALSE) {
pTransmitKey = NULL;
DEVICE_PRT(MSG_LEVEL_DEBUG, KERN_DEBUG"KEY is NULL. [%d]\n", pDevice->pMgmt->eCurrMode);
} else {
DEVICE_PRT(MSG_LEVEL_DEBUG, KERN_DEBUG"Get GTK.\n");
}
}
if (pDevice->bEnableHostWEP) {
if (uNodeIndex >= 0) {
pTransmitKey = &STempKey;
pTransmitKey->byCipherSuite = pMgmt->sNodeDBTable[uNodeIndex].byCipherSuite;
pTransmitKey->dwKeyIndex = pMgmt->sNodeDBTable[uNodeIndex].dwKeyIndex;
pTransmitKey->uKeyLength = pMgmt->sNodeDBTable[uNodeIndex].uWepKeyLength;
pTransmitKey->dwTSC47_16 = pMgmt->sNodeDBTable[uNodeIndex].dwTSC47_16;
pTransmitKey->wTSC15_0 = pMgmt->sNodeDBTable[uNodeIndex].wTSC15_0;
memcpy(pTransmitKey->abyKey,
&pMgmt->sNodeDBTable[uNodeIndex].abyWepKey[0],
pTransmitKey->uKeyLength
);
}
}
uMACfragNum = cbGetFragCount(pDevice, pTransmitKey, cbFrameBodySize, &pDevice->sTxEthHeader);
if (uMACfragNum > AVAIL_TD(pDevice,TYPE_AC0DMA)) {
return FALSE;
}
byPktTyp = (BYTE)pDevice->byPacketType;
if (pDevice->bFixRate) {
if (pDevice->eCurrentPHYType == PHY_TYPE_11B) {
if (pDevice->uConnectionRate >= RATE_11M) {
pDevice->wCurrentRate = RATE_11M;
} else {
pDevice->wCurrentRate = (WORD)pDevice->uConnectionRate;
}
} else {
if ((pDevice->eCurrentPHYType == PHY_TYPE_11A) &&
(pDevice->uConnectionRate <= RATE_6M)) {
pDevice->wCurrentRate = RATE_6M;
} else {
if (pDevice->uConnectionRate >= RATE_54M)
pDevice->wCurrentRate = RATE_54M;
else
pDevice->wCurrentRate = (WORD)pDevice->uConnectionRate;
}
}
}
else {
pDevice->wCurrentRate = pDevice->pMgmt->sNodeDBTable[uNodeIndex].wTxDataRate;
}
if (pDevice->wCurrentRate <= RATE_11M)
byPktTyp = PK_TYPE_11B;
vGenerateFIFOHeader(pDevice, byPktTyp, pDevice->pbyTmpBuff, bNeedEncryption,
cbFrameBodySize, TYPE_AC0DMA, pHeadTD,
&pDevice->sTxEthHeader, pbySkbData, pTransmitKey, uNodeIndex,
&uMACfragNum,
&cbHeaderSize
);
if (MACbIsRegBitsOn(pDevice->PortOffset, MAC_REG_PSCTL, PSCTL_PS)) {
// Disable PS
MACbPSWakeup(pDevice->PortOffset);
}
pDevice->bPWBitOn = FALSE;
pLastTD = pHeadTD;
for (ii = 0; ii < uMACfragNum; ii++) {
// Poll Transmit the adapter
wmb();
pHeadTD->m_td0TD0.f1Owner=OWNED_BY_NIC;
wmb();
if (ii == (uMACfragNum - 1))
pLastTD = pHeadTD;
pHeadTD = pHeadTD->next;
}
pLastTD->pTDInfo->skb = 0;
pLastTD->pTDInfo->byFlags = 0;
pDevice->apCurrTD[TYPE_AC0DMA] = pHeadTD;
MACvTransmitAC0(pDevice->PortOffset);
return TRUE;
}

View File

@ -0,0 +1,65 @@
/*
* Copyright (c) 1996, 2003 VIA Networking Technologies, Inc.
* All rights reserved.
*
* This program is free software; you can redistribute it and/or modify
* it under the terms of the GNU General Public License as published by
* the Free Software Foundation; either version 2 of the License, or
* (at your option) any later version.
*
* This program is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
* GNU General Public License for more details.
*
* You should have received a copy of the GNU General Public License along
* with this program; if not, write to the Free Software Foundation, Inc.,
* 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA.
*
* File: wroute.h
*
* Purpose:
*
* Author: Lyndon Chen
*
* Date: May 21, 2003
*
*/
#ifndef __WROUTE_H__
#define __WROUTE_H__
#if !defined(__DEVICE_H__)
#include "device.h"
#endif
/*--------------------- Export Definitions -------------------------*/
/*--------------------- Export Classes ----------------------------*/
/*--------------------- Export Variables --------------------------*/
/*--------------------- Export Functions --------------------------*/
#ifdef __cplusplus
extern "C" { /* Assume C declarations for C++ */
#endif /* __cplusplus */
BOOL ROUTEbRelay (PSDevice pDevice, PBYTE pbySkbData, UINT uDataLen, UINT uNodeIndex);
#ifdef __cplusplus
} /* End of extern "C" { */
#endif /* __cplusplus */
#endif // __WROUTE_H__