📄 rtmp.h
字号:
/*************************************************************************** * RT2x00 SourceForge Project - http://rt2x00.serialmonkey.com * * * * 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., * * 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA. * * * * Licensed under the GNU GPL * * Original code supplied under license from RaLink Inc, 2004. * ***************************************************************************//*************************************************************************** * Module Name: rtmp.h * * Abstract: * * Revision History: * Who When What * -------- ---------- ----------------------------- * idamlaj 05-10-2006 Import rfmon implementation * idamlaj 14-10-2006 RFMonTx (based on MarkW's code) * RomainB 31-12-2206 RFMonTx getter * ***************************************************************************/#ifndef __RTMP_H__#define __RTMP_H__#include "mlme.h"#include "oid.h"#include "wpa.h"//// Extern//extern UCHAR BROADCAST_ADDR[MAC_ADDR_LEN];extern UCHAR ZERO_MAC_ADDR[MAC_ADDR_LEN];extern ULONG BIT32[32];extern UCHAR BIT8[8];extern char* CipherName[];extern UCHAR SNAP_802_1H[6];extern UCHAR SNAP_BRIDGE_TUNNEL[6];extern UCHAR EAPOL_LLC_SNAP[8];extern UCHAR EAPOL[2];extern UCHAR IPX[2];extern UCHAR APPLE_TALK[2];extern UCHAR RateIdToPlcpSignal[12]; // see IEEE802.11a-1999 p.14extern UCHAR OfdmSignalToRateId[16] ;extern UCHAR default_cwmin[4];extern UCHAR default_cwmax[4];extern UCHAR default_sta_aifsn[4];extern UCHAR MapUserPriorityToAccessCategory[8];extern UCHAR Phy11BNextRateDownward[];extern UCHAR Phy11BNextRateUpward[];extern UCHAR Phy11BGNextRateDownward[];extern UCHAR Phy11BGNextRateUpward[];extern UCHAR Phy11ANextRateDownward[];extern UCHAR Phy11ANextRateUpward[];extern CHAR RssiSafeLevelForTxRate[];extern UCHAR RateIdToMbps[];extern USHORT RateIdTo500Kbps[];extern UCHAR CipherSuiteWpaNoneTkip[];extern UCHAR CipherSuiteWpaNoneTkipLen;extern UCHAR CipherSuiteWpaNoneAes[];extern UCHAR CipherSuiteWpaNoneAesLen;extern UCHAR SsidIe;extern UCHAR SupRateIe;extern UCHAR ExtRateIe;extern UCHAR ErpIe;extern UCHAR DsIe;extern UCHAR TimIe;extern UCHAR WpaIe;extern UCHAR Wpa2Ie;extern UCHAR IbssIe;extern UCHAR WPA_OUI[];extern UCHAR WME_INFO_ELEM[];extern UCHAR WME_PARM_ELEM[];extern UCHAR RALINK_OUI[];extern struct usb_device_id rtusb_usb_id[];extern INT const rtusb_usb_id_len;//// MACRO for linux usb//typedef struct urb *purbb_t;typedef struct usb_ctrlrequest devctrlrequest;// for vendor-specific control operations#define CONTROL_TIMEOUT_MS (1000) /* msec */ // lengthen timeout for loading firmware#define CONTROL_TIMEOUT_JIFFIES ((CONTROL_TIMEOUT_MS * HZ)/1000)/* map devrequest fields onto usb_ctrlrequest's */#define DEVREQ_REQUEST(x) ((x)->bRequest)#define DEVREQ_REQUESTTYPE(x) ((x)->bRequestType)#define DEVREQ_VALUE(x) ((x)->wValue)#define DEVREQ_INDEX(x) ((x)->wIndex)#define DEVREQ_LENGTH(x) ((x)->wLength)#define PURB purbb_t#define PIRP PVOID#define PMDL PVOID#define NDIS_OID UINT#define STATUS_SUCCESS 0x00#define STATUS_UNSUCCESSFUL 0x01typedef LONG NTSTATUS;typedef NTSTATUS *PNTSTATUS;#define KPRINT(Level, fmt, args...) \ printk(Level DRIVER_NAME ": " fmt, ## args)//// Macro for debugging information//#ifdef DBGextern ULONG RTDebugLevel;#define DBGPRINT(Level, fmt, args...) \{ \ if (Level & RTDebugLevel) \ { \ printk(KERN_DEBUG DRIVER_NAME ": " fmt, ## args); \ } \}#define DBGPRINT_ERR(fmt, args...) \{ \ if (RT_DEBUG_ERROR & RTDebugLevel) \ { \ printk(KERN_DEBUG DRIVER_NAME ": ERROR!!! " fmt, ## args); \ } \}#define DBGPRINT_RAW(Level, fmt, args...) \{ \ if (Level & RTDebugLevel) \ { \ printk(fmt, ## args); \ } \}#else#define DBGPRINT(Level, fmt, args...)#define DBGPRINT_ERR(fmt, args...)#define DBGPRINT_RAW(Level, fmt, args...)#endif# define assert(expr) \ if(unlikely(!(expr))) { \ printk(KERN_ERR "Assertion failed! %s,%s,%s,line=%d\n", \ #expr,__FILE__,__FUNCTION__,__LINE__); \ }#ifndef kzalloc#define kzalloc(size, flags) \({ \ void *data = kmalloc(size, flags); \ if (data) \ memset(data,0,size); \ data; \})#endif#ifndef free_netdev#define free_netdev kfree#endif//// spin_lock enhanced for Nested spin lock//#define NdisAllocateSpinLock(lock) \{ \ spin_lock_init(lock); \}#if 0#define NdisReleaseSpinLock(lock) \{ \ if (in_interrupt()) \ spin_unlock_irqrestore(lock, flags);\ else \ spin_unlock(lock); \}#define NdisAcquireSpinLock(lock) \{ \ if (in_interrupt()) \ spin_lock_irqsave(lock, flags); \ else \ spin_lock(lock); \}#else#define NdisReleaseSpinLock(lock) \{ \ spin_unlock_irqrestore(lock, (unsigned long)flags); \}#define NdisAcquireSpinLock(lock) \{ \ spin_lock_irqsave(lock, flags); \}#endif#define NdisFreeSpinLock(lock) \{ \}#define RTUSBFreeSkbBuffer(skb) \{ \ dev_kfree_skb_any(skb); \}#define RTUSBMlmeUp(pAd) \{ \ if(pAd->MLMEThr_pid>0) \ up(&(pAd->mlme_semaphore)); \}#define RTUSBCMDUp(pAd) \{ \ if(pAd->RTUSBCmdThr_pid>0) \ up(&(pAd->RTUSBCmd_semaphore)); \}//Setup Packet used in Ctrl urb's filler....#define FILL_REQUEST(a,aa,ab,ac,ad,ae) \ do { \ (a)->devreq->request = aa; \ (a)->devreq->requesttype = ab; \ (a)->devreq->value = cpu_to_le16(ac); \ (a)->devreq->index = cpu_to_le16(ad); \ (a)->devreq->length = cpu_to_le16(ae);\ }while(0);// direction is specified in TransferFlags#define URB_FUNCTION_RESERVED0 0x0016//// These are for sending vendor and class commands// on the default pipe//// direction is specified in TransferFlags#define URB_FUNCTION_VENDOR_DEVICE 0x0017#define URB_FUNCTION_VENDOR_INTERFACE 0x0018#define URB_FUNCTION_VENDOR_ENDPOINT 0x0019#define URB_FUNCTION_VENDOR_OTHER 0x0020#define URB_FUNCTION_CLASS_DEVICE 0x001A#define URB_FUNCTION_CLASS_INTERFACE 0x001B#define URB_FUNCTION_CLASS_ENDPOINT 0x001C#define URB_FUNCTION_CLASS_OTHER 0x001F//// Reserved function codes//#define URB_FUNCTION_RESERVED 0x001D#define URB_FUNCTION_GET_CONFIGURATION 0x0026#define URB_FUNCTION_GET_INTERFACE 0x0027#define URB_FUNCTION_LAST 0x0029//// Assert MACRO to make sure program running//#undef ASSERT#define ASSERT(x) \{ \ if (!(x)) \ { \ printk(KERN_WARNING __FILE__ ":%d assert " #x "failed\n", __LINE__); \ } \}//// Macros for flag and ref count operations//#define RTMP_SET_FLAG(_M, _F) ((_M)->Flags |= (_F))#define RTMP_CLEAR_FLAG(_M, _F) ((_M)->Flags &= ~(_F))#define RTMP_CLEAR_FLAGS(_M) ((_M)->Flags = 0)#define RTMP_TEST_FLAG(_M, _F) (((_M)->Flags & (_F)) != 0)#define RTMP_TEST_FLAGS(_M, _F) (((_M)->Flags & (_F)) == (_F))// Flags control for RT2500 USB bulk out frame type// We serialize modification between process context and interrupt context// and between processors, allowing also for relaxed memory consistency - bb//#define RTUSB_SET_BULK_FLAG(_M, _F) ((_M)->BulkFlags |= (_F))#define RTUSB_SET_BULK_FLAG(_M, _F) \{ \ spin_lock_irqsave(&(_M)->BulkFlagsLock, flags); \ smp_wmb(); \ (_M)->BulkFlags |= (_F); \ spin_unlock_irqrestore(&(_M)->BulkFlagsLock, flags); \}//#define RTUSB_CLEAR_BULK_FLAG(_M, _F) ((_M)->BulkFlags &= ~(_F))#define RTUSB_CLEAR_BULK_FLAG(_M, _F) \{ \ spin_lock_irqsave(&(_M)->BulkFlagsLock, flags); \ smp_wmb(); \ (_M)->BulkFlags &= ~(_F); \ spin_unlock_irqrestore(&(_M)->BulkFlagsLock, flags); \}#define RTUSB_TEST_BULK_FLAG(_M, _F) (((_M)->BulkFlags & (_F)) != 0)#define OPSTATUS_SET_FLAG(_pAd, _F) ((_pAd)->PortCfg.OpStatusFlags |= (_F))#define OPSTATUS_CLEAR_FLAG(_pAd, _F) ((_pAd)->PortCfg.OpStatusFlags &= ~(_F))#define OPSTATUS_TEST_FLAG(_pAd, _F) (((_pAd)->PortCfg.OpStatusFlags & (_F)) != 0)#define CLIENT_STATUS_SET_FLAG(_pEntry,_F) ((_pEntry)->ClientStatusFlags |= (_F))#define CLIENT_STATUS_CLEAR_FLAG(_pEntry,_F) ((_pEntry)->ClientStatusFlags &= ~(_F))#define CLIENT_STATUS_TEST_FLAG(_pEntry,_F) (((_pEntry)->ClientStatusFlags & (_F)) != 0)#define INC_RING_INDEX(_idx, _RingSize) \{ \ (_idx)++; \ if ((_idx) >= (_RingSize)) _idx=0; \}// Increase TxTsc value for next transmission// TODO:// When i==6, means TSC has done one full cycle, do re-keying stuff follow specs// Should send a special event microsoft defined to request re-key#define INC_TX_TSC(_tsc) \{ \ int i=0; \ while (++_tsc[i] == 0x0) \ { \ i++; \ if (i == 6) \ break; \ } \}#undef NdisMoveMemory#undef NdisZeroMemory#undef NdisFillMemory#undef NdisEqualMemory#define NdisMoveMemory(Destination, Source, Length) RTMPMoveMemory(Destination, Source, Length)#define NdisZeroMemory(Destination, Length) RTMPZeroMemory(Destination, Length)#define NdisFillMemory(Destination, Length, Fill) RTMPFillMemory(Destination, Length, Fill)#define NdisEqualMemory(Source1, Source2, Length) RTMPEqualMemory(Source1, Source2, Length)#define MAC_ADDR_EQUAL(pAddr1,pAddr2) RTMPEqualMemory((PVOID)(pAddr1), (PVOID)(pAddr2), MAC_ADDR_LEN)#define COPY_MAC_ADDR(Addr1, Addr2) memcpy((Addr1), (Addr2), MAC_ADDR_LEN)#define SSID_EQUAL(ssid1, len1, ssid2, len2) ((len1==len2) && (RTMPEqualMemory(ssid1, ssid2, len1)))#define NdisMSleep mdelay#define MAP_CHANNEL_ID_TO_KHZ(ch, khz) { \ switch (ch) \ { \ case 1: khz = 2412000; break; \ case 2: khz = 2417000; break; \ case 3: khz = 2422000; break; \ case 4: khz = 2427000; break; \ case 5: khz = 2432000; break; \ case 6: khz = 2437000; break; \ case 7: khz = 2442000; break; \ case 8: khz = 2447000; break; \ case 9: khz = 2452000; break; \ case 10: khz = 2457000; break; \ case 11: khz = 2462000; break; \ case 12: khz = 2467000; break; \ case 13: khz = 2472000; break; \ case 14: khz = 2484000; break; \ case 36: /* UNII */ khz = 5180000; break; \ case 40: /* UNII */ khz = 5200000; break; \ case 44: /* UNII */ khz = 5220000; break; \ case 48: /* UNII */ khz = 5240000; break; \ case 52: /* UNII */ khz = 5260000; break; \ case 56: /* UNII */ khz = 5280000; break; \ case 60: /* UNII */ khz = 5300000; break; \ case 64: /* UNII */ khz = 5320000; break; \ case 149: /* UNII */ khz = 5745000; break; \ case 153: /* UNII */ khz = 5765000; break; \ case 157: /* UNII */ khz = 5785000; break; \ case 161: /* UNII */ khz = 5805000; break; \ case 165: /* UNII */ khz = 5825000; break; \ case 100: /* HiperLAN2 */ khz = 5500000; break; \ case 104: /* HiperLAN2 */ khz = 5520000; break; \ case 108: /* HiperLAN2 */ khz = 5540000; break; \ case 112: /* HiperLAN2 */ khz = 5560000; break; \ case 116: /* HiperLAN2 */ khz = 5580000; break; \ case 120: /* HiperLAN2 */ khz = 5600000; break; \ case 124: /* HiperLAN2 */ khz = 5620000; break; \ case 128: /* HiperLAN2 */ khz = 5640000; break; \ case 132: /* HiperLAN2 */ khz = 5660000; break; \ case 136: /* HiperLAN2 */ khz = 5680000; break; \ case 140: /* HiperLAN2 */ khz = 5700000; break; \ case 34: /* Japan MMAC */ khz = 5170000; break; \ case 38: /* Japan MMAC */ khz = 5190000; break; \ case 42: /* Japan MMAC */ khz = 5210000; break; \ case 46: /* Japan MMAC */ khz = 5230000; break; \ default: khz = 2412000; break; \ } \ }#define MAP_KHZ_TO_CHANNEL_ID(khz, ch) { \ switch (khz) \ { \ case 2412000: ch = 1; break; \ case 2417000: ch = 2; break; \ case 2422000: ch = 3; break; \ case 2427000: ch = 4; break; \ case 2432000: ch = 5; break; \ case 2437000: ch = 6; break; \ case 2442000: ch = 7; break; \ case 2447000: ch = 8; break; \ case 2452000: ch = 9; break; \ case 2457000: ch = 10; break; \ case 2462000: ch = 11; break; \ case 2467000: ch = 12; break; \ case 2472000: ch = 13; break; \ case 2484000: ch = 14; break; \ case 5180000: ch = 36; /* UNII */ break; \ case 5200000: ch = 40; /* UNII */ break; \
⌨️ 快捷键说明
复制代码
Ctrl + C
搜索代码
Ctrl + F
全屏模式
F11
切换主题
Ctrl + Shift + D
显示快捷键
?
增大字号
Ctrl + =
减小字号
Ctrl + -