#ifndef _H_VOODOOWIRELESSDEVICE_H
#define _H_VOODOOWIRELESSDEVICE_H
#include <sys/types.h>
#include <sys/kpi_mbuf.h>
#include <IOKit/IOService.h>
#include <IOKit/IOMessage.h>
#include <IOKit/IOWorkLoop.h>
#include <IOKit/apple80211/IO80211Controller.h>
#include <IOKit/apple80211/IO80211Interface.h>
#include <IOKit/apple80211/IO80211WorkLoop.h>
#include <IOKit/network/IOOutputQueue.h>
#include "VoodooWirelessFamily.h"
#include "VoodooIEEE80211.h"
#include "VoodooWirelessDevice_Types.h"
using namespace org_voodoo_wireless;
class VoodooWirelessDevice : public IO80211Controller
{
public:
virtual bool start ( IOService* provider );
virtual void stop ( IOService* provider );
IOReturn registerWithPolicyMaker ( IOService* policyMaker );
SInt32 apple80211Request ( UInt32 request_type, int request_number,
IO80211Interface* interface, void* data );
IOReturn enable ( IONetworkInterface* aNetif );
IOReturn disable ( IONetworkInterface* aNetif );
IOOutputQueue* createOutputQueue ( );
UInt32 outputPacket ( mbuf_t m, void* param );
IOReturn getMaxPacketSize ( UInt32 *maxSize ) const;
const OSString* newVendorString ( ) const;
const OSString* newModelString ( ) const;
const OSString* newRevisionString ( ) const;
IOReturn getHardwareAddress ( IOEthernetAddress* addr );
virtual IOReturn setPromiscuousMode ( IOEnetPromiscuousMode mode );
virtual IOReturn setMulticastMode ( IOEnetMulticastMode mode );
virtual IOReturn setMulticastList ( IOEthernetAddress* addr, UInt32 len );
virtual SInt32 monitorModeSetEnabled ( IO80211Interface * interface, bool enabled, UInt32 dlt );
protected:
struct ExpansionData {};
ExpansionData* reserved;
virtual IOReturn allocateResources ( );
virtual void freeResources ( );
virtual IOReturn turnPowerOn ( );
virtual IOReturn turnPowerOff ( );
virtual IOReturn startScan ( const ScanParameters* params,
const IEEE::ChannelList* channels );
virtual void abortScan ( );
virtual IOReturn associate ( const AssociationParameters* params );
virtual IOReturn disasssociate ( );
virtual void getHardwareInfo ( HardwareInfo* info );
virtual IOReturn getConfiguration ( HardwareConfigType type, void* param );
virtual IOReturn setConfiguration ( HardwareConfigType type, void* param );
void report ( DeviceResponseMessage msg, void* arg );
void inputFrame ( RxFrameHeader hdr, mbuf_t data );
virtual IOReturn outputFrame ( TxFrameHeader hdr, mbuf_t data );
private:
HardwareInfo _hwInfo;
uint32_t _flags;
IOSimpleLock* _simpleLock;
OSMetaClassDeclareReservedUnused(VoodooWirelessDevice, 0);
OSMetaClassDeclareReservedUnused(VoodooWirelessDevice, 1);
OSMetaClassDeclareReservedUnused(VoodooWirelessDevice, 2);
OSMetaClassDeclareReservedUnused(VoodooWirelessDevice, 3);
OSMetaClassDeclareReservedUnused(VoodooWirelessDevice, 4);
OSMetaClassDeclareReservedUnused(VoodooWirelessDevice, 5);
OSMetaClassDeclareReservedUnused(VoodooWirelessDevice, 6);
OSMetaClassDeclareReservedUnused(VoodooWirelessDevice, 7);
OSMetaClassDeclareReservedUnused(VoodooWirelessDevice, 8);
OSMetaClassDeclareReservedUnused(VoodooWirelessDevice, 9);
OSMetaClassDeclareReservedUnused(VoodooWirelessDevice, 10);
OSMetaClassDeclareReservedUnused(VoodooWirelessDevice, 11);
OSMetaClassDeclareReservedUnused(VoodooWirelessDevice, 12);
OSMetaClassDeclareReservedUnused(VoodooWirelessDevice, 13);
OSMetaClassDeclareReservedUnused(VoodooWirelessDevice, 14);
OSMetaClassDeclareReservedUnused(VoodooWirelessDevice, 15);
OSMetaClassDeclareReservedUnused(VoodooWirelessDevice, 16);
OSMetaClassDeclareReservedUnused(VoodooWirelessDevice, 17);
OSMetaClassDeclareReservedUnused(VoodooWirelessDevice, 18);
OSMetaClassDeclareReservedUnused(VoodooWirelessDevice, 19);
OSMetaClassDeclareReservedUnused(VoodooWirelessDevice, 20);
OSMetaClassDeclareReservedUnused(VoodooWirelessDevice, 21);
OSMetaClassDeclareReservedUnused(VoodooWirelessDevice, 22);
OSMetaClassDeclareReservedUnused(VoodooWirelessDevice, 23);
};
#endif//_H_VOODOOWIRELESSDEVICE_H
#ifndef _H_VOODOOWIRELESSDEVICE_TYPES_H
#define _H_VOODOOWIRELESSDEVICE_TYPES_H
#include <libkern/c++/OSSymbol.h>
#include <libkern/c++/OSString.h>
#include "VoodooWirelessFamily.h"
#include "VoodooIEEE80211.h"
namespace org_voodoo_wireless {
struct ScanParameters {
enum ScanType { scanTypeActive, scanTypePassive, scanTypeBackground };
ScanType scanType;
IEEE::PHYModes scanPhyMode;
IEEE::MACAddress bssid;
OSSymbol* ssid;
uint32_t dwellTime;
uint32_t restTime;
};
struct ScanResult {
IEEE::Channel channel;
IEEE::Capability capability;
IEEE::MACAddress bssid;
OSSymbol* ssid;
int noiseLevel;
int signalLevel;
IEEE::RateSet supportedRates;
uint32_t beaconInterval;
uint32_t age;
IEList* extraIEs;
};
struct AssociationParameters {
OSSymbol* ssid;
IEEE::MACAddress bssid;
IEEE::Channel channel;
IEEE::Capability capability;
IEEE::RateSet supportedRates;
uint32_t beaconInterval;
enum APMode { apModeAny, apModeAdHoc, apModeInfrastructure };
APMode connectionMode;
enum AuthType {
authTypeNone = 0,
authTypeShared = 1,
authTypeWPA = 2,
authTypeWPAPSK = 4,
authTypeWPA2 = 6,
authTypeWPA2PSK = 8,
authtypeLEAP = 10,
authType8021X = 12,
authTypeWPS = 14
};
AuthType authType;
IEEE::WEPKey wepKey;
IEList* extraIEs;
bool closedNetwork;
};
struct RxFrameHeader {
IEEE::Channel channel;
IEEE::DataRate rate;
int signalLevel;
bool decrypted;
};
struct TxFrameHeader {
IEEE::DataRate rate;
bool encrypted;
};
struct HardwareCapabilities {
bool WEP :1;
bool TKIP :1;
bool TKIP_MIC :1;
bool AES_CCMP :1;
bool WPA1 :1;
bool WPA2 :1;
bool AdHocMode :1;
bool HostAPMode :1;
bool MonitorMode :1;
bool PowerManagement :1;
bool TxPowerManagement:1;
bool WakeOneWireless :1;
bool ShortSlot :1;
bool ShortPreamble :1;
bool FrameBursting :1;
bool WMEQoS :1;
bool ShortGuardInterval20MHz :1;
bool ShortGuardInterval40MHz :1;
bool hardwareRoaming :1;
};
enum PowerSavingModes {
powerSaveAlwaysOn = 1,
powerSaveNormal = 2,
powerSaveMaximum = 4
};
enum HardwareConfigType {
configTxPower,
configRTSThreshold,
configFragmentationThreshold,
configShortRetryLimit,
configLongRetryLimit,
configCurrentTxRate,
configRateSet,
configInterferenceMitigation,
config11GProtection
};
struct HardwareInfo {
OSString* manufacturer;
OSString* model;
OSString* hardwareRevision;
OSString* driverVersion;
OSString* firmwareVersion;
IEEE::MACAddress hardwareAddress;
IEEE::PHYModes supportedModes;
IEEE::ChannelList supportedChannels;
IEEE::RateSet supportedRates;
unsigned int maxTxPower;
enum SNRUnit { unit_dBm, unit_Percent, unit_mW, unit_Other_Linear, unit_Other_Logarithmic };
SNRUnit snrUnit;
PowerSavingModes powerSavingModes;
HardwareCapabilities capabilities;
uint32_t maxPacketSize;
uint32_t txQueueSize;
};
enum DeviceResponseMessage {
msgNull = iokit_vendor_specific_msg(1),
msgPowerOff,
msgPowerOn,
msgRadioOff,
msgRadioOn,
msgScanAborted,
msgScanCompleted,
msgChannelScanned,
msgAuthenticationFailed,
msgAuthenticationDone,
msgAssociationFailed,
msgAssociationDone,
msgDeassociationFailed,
msgDeassociationDone,
msgDeauthenticated,
msgNoiseLevelReport,
msgSignalStrengthReport,
msgChannelSwitch,
msgLinkQualityReport,
msgBeaconMissed,
msgConfigChanged,
msgMaxMessageNumber
};
};
#endif
#ifndef _H_VOODOOIEEE80211_TYPES_H
#define _H_VOODOOIEEE80211_TYPES_H
#include "VoodooWirelessFamily.h"
namespace org_voodoo_wireless {
namespace IEEE {
struct MACAddress {
uint8_t bytes[6];
};
struct WEPKey {
uint8_t index;
OSString* key;
};
enum PHYModes {
dot11A = 1,
dot11B = 2,
dot11G = 4,
dot11N = 8,
};
const size_t MAX_CHANNELS = 64;
const size_t MAX_RATES = 32;
struct Channel {
uint8_t number;
uint16_t flags;
enum Flags {
supportsActiveScanning = 0x1,
band2GHz = 0x2,
band5GHz = 0x4,
width10MHz = 0x8,
width20MHz = 0x10,
width40MHz = 0x20,
requiresDFS = 0x40,
supportsHostAPMode = 0x80,
supportsAdHocMode = 0x100,
extensionChannelIsAbove = 0x200
};
};
struct ChannelList {
size_t numItems;
Channel channel[MAX_CHANNELS];
};
enum DataRate {
rateIsBasic = 128,
rate1Mbps = 2,
rate2Mbps = 4,
rate5Mbps = 10,
rate6Mbps = 12,
rate9Mbps = 18,
rate11Mbps = 22,
rate12Mbps = 24,
rate18Mbps = 36,
rate24Mbps = 48,
rate36Mbps = 72,
rate48Mbps = 96,
rate54Mbps = 108,
};
struct RateSet {
size_t numItems;
DataRate rate[MAX_RATES];
};
enum ReasonCode {
reasonUnspecified = 1,
reasonPreviousAuthExpired = 2,
reasonDeauthBecauseSTALeft = 3,
reasonDisassocDueToInactivity = 4,
reasonAPFull = 5,
reasonClass2FrameRxWithoutAuth = 6,
reasonClass3FrameRxWithoutAssoc = 7,
reasonDisassocBecauseSTALeft = 8,
reasonNotAuthorized = 9,
reasonPowerCapsUnacceptable = 10,
reasonSupportedChannelsUnacceptable = 11,
reasonInvalidIE = 13,
reasonMICFailure = 14,
reason4WayHandshakeTimeout = 15,
reasonGroupKeyHandshakeTimeout = 16,
reasonIEMismatch = 17,
reasonInvalidGroupCipher = 18,
reasonInvalidPairwiseCipher = 19,
reasonInvalidAKMP = 20,
reasonUnsupportedRSNIE = 21,
reasonInvalidRSNIECaps = 22,
reason8021XAuthFailed = 23,
reasonCipherSuiteRejected = 24,
reasonQoS = 32,
reasonQoSBandwidthUnavailable = 33,
reasonTooManyACKs = 34,
reasonTXOPsOutsideLimits = 35,
reasonPeerSTALeaving = 36,
reasonPeerSTAMechanismRejected = 37,
reasonPeerSTAMechanismNeedsSetup= 38,
reasonPeerSTATimeout = 39,
reasonPeerSTACipherUnsupported = 45,
reasonPrivateUnspecified = 0xffff
};
struct IE {
enum ID {
ieSSID = 0, ieSupportedRates = 1,
ieFHParamSet = 2, ieDSParamSet = 3,
ieCFParamSet = 4, ieTIM = 5,
ieIBSSParamSet = 6, ieCountry = 7,
ieHoppingPatternParams = 8, ieHoppingPatternTable = 9,
ieRequest = 10, ieBSSLoad = 11,
ieEDCAParamSet = 12, ieTSPEC = 13,
ieTCLAS = 14, ieSchedule = 15,
ieChallengeText = 16,
iePowerConstraint = 32, iePowerCapability = 33,
ieTPCRequest = 34, ieTPCReport = 35,
ieSupportedChannels = 36, ieChannelSwitchAnnounce = 37,
ieMeasurementRequest = 38, ieMeasurementReport = 39,
ieQuiet = 40, ieIBSSDFS = 41,
ieERPInformation = 42, ieTSDelay = 43,
ieTCLASProcessing = 44,
ieQoSCapability = 46,
ieRSN = 48,
ieExtendedSupportedRates= 50,
ieExtendedCapabilities = 127,
ieVendorSpecific = 221,
};
uint8_t id;
uint8_t length;
uint8_t data[0];
} __packed;
union Capability {
struct {
bool ESS :1;
bool IBSS :1;
bool CFPollable :1;
bool CFPollRequest :1;
bool Privacy :1;
bool ShortPreamble :1;
bool PBCC :1;
bool ChannelAgility :1;
bool SpectrumMgmt :1;
bool QoS :1;
bool ShortSlotTime :1;
bool APSD :1;
bool Reserved :1;
bool DSSSOFDM :1;
bool DelayedBlockAck :1;
bool ImmediateBlockAck:1;
} bits __packed;
uint16_t value;
} __packed;
struct WiFiFrameHeader
{
enum FrameType {
ManagementFrame = 0,
ControlFrame = 1,
DataFrame = 2,
ReservedFrame = 3
};
enum FrameSubtype {
AssocRequest = 0, AssocResponse = 1,
ReassocRequest = 2, ReassocResponse = 3,
ProbeRequest = 4, ProbeResponse = 5,
Beacon = 8, ATIM = 9,
Disassoc = 10, Authentication = 11,
DeAuthentication= 12, Action = 13,
BlockAckReq = 8, BlockAck = 9,
PSPoll = 10, RTS = 11,
CTS = 12, ACK = 13,
CFEnd = 14, CFEndPoll = 15,
Data = 0, DataCFAck = 1,
DataCFPoll = 2, DataCFAckPoll = 3,
Null = 4, CFAck = 5,
CFPoll = 6, CFAckPoll = 7,
QoSData = 8, QoSDataCFAck = 9,
QoSDataCFPoll = 10, QoSDataCFAckPoll = 11,
QoSNull = 12,
QoSCFPoll = 14, QoSCFAckCFPoll = 15
};
uint8_t protocolVersion :2;
FrameType type :2;
FrameSubtype subtype :4;
bool toDS :1;
bool fromDS :1;
bool moreFrag :1;
bool retry :1;
bool powerSaveMode :1;
bool moreData :1;
bool protectedFrame :1;
bool order :1;
uint16_t durationID :16;
} __packed;
struct SequenceControl {
uint8_t fragmentNumber :4;
uint16_t sequenceNumber :12;
} __packed;
struct ManagementFrameHeader
{
WiFiFrameHeader hdr;
uint8_t da[6];
uint8_t sa[6];
uint8_t bssid[6];
SequenceControl sequenceControl;
} __packed;
struct ProbeResponseFrameHeader {
ManagementFrameHeader mgmt;
uint64_t timestamp;
uint16_t beaconInterval;
uint16_t capability;
uint8_t ieData[0];
} __packed;
struct TxDataFrameHeader {
WiFiFrameHeader hdr;
uint8_t bssid[6];
uint8_t sa[6];
uint8_t da[6];
uint16_t seq;
uint8_t data[0];
} __packed;
struct TxQoSDataFrameHeader {
WiFiFrameHeader hdr;
uint8_t bssid[6];
uint8_t sa[6];
uint8_t da[6];
uint16_t seq;
uint16_t qos;
uint8_t data[0];
} __packed;
struct EthernetFrameHeader {
uint8_t da[6];
uint8_t sa[6];
uint8_t frameType[2];
uint8_t data[0];
} __packed;
}
}
#endif