-
Notifications
You must be signed in to change notification settings - Fork 1
/
IO80211Controller.h
418 lines (332 loc) · 13.6 KB
/
IO80211Controller.h
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
255
256
257
258
259
260
261
262
263
264
265
266
267
268
269
270
271
272
273
274
275
276
277
278
279
280
281
282
283
284
285
286
287
288
289
290
291
292
293
294
295
296
297
298
299
300
301
302
303
304
305
306
307
308
309
310
311
312
313
314
315
316
317
318
319
320
321
322
323
324
325
326
327
328
329
330
331
332
333
334
335
336
337
338
339
340
341
342
343
344
345
346
347
348
349
350
351
352
353
354
355
356
357
358
359
360
361
362
363
364
365
366
367
368
369
370
371
372
373
374
375
376
377
378
379
380
381
382
383
384
385
386
387
388
389
390
391
392
393
394
395
396
397
398
399
400
401
402
403
404
405
406
407
408
409
410
411
412
413
414
415
416
417
418
/*
* Copyright (c) 2005 Apple Computer, Inc. All rights reserved.
*
* @APPLE_LICENSE_HEADER_START@
*
* The contents of this file constitute Original Code as defined in and
* are subject to the Apple Public Source License Version 1.1 (the
* "License"). You may not use this file except in compliance with the
* License. Please obtain a copy of the License at
* http://www.apple.com/publicsource and read it before using this file.
*
* This Original Code and all software distributed under the License are
* distributed on an "AS IS" basis, WITHOUT WARRANTY OF ANY KIND, EITHER
* EXPRESS OR IMPLIED, AND APPLE HEREBY DISCLAIMS ALL SUCH WARRANTIES,
* INCLUDING WITHOUT LIMITATION, ANY WARRANTIES OF MERCHANTABILITY,
* FITNESS FOR A PARTICULAR PURPOSE OR NON-INFRINGEMENT. Please see the
* License for the specific language governing rights and limitations
* under the License.
*
* @APPLE_LICENSE_HEADER_END@
*/
/* Modified by Prashant Vaibhav for Mac OS X Snow Leopard, (C) 2010 */
#ifndef _IO80211CONTROLLER_H
#define _IO80211CONTROLLER_H
/*
* Kernel
*/
#if defined(KERNEL) && defined(__cplusplus)
#include <libkern/version.h>
#if VERSION_MAJOR > 8
#define _MODERN_BPF
#endif
#include <IOKit/network/IOEthernetController.h>
#include <sys/param.h>
#include <net/bpf.h>
#include "apple80211_ioctl.h"
// always compile with legacy compatibility for now. This will go away soon.
#ifndef IO80211_LEGACY_COMPAT
#define IO80211_LEGACY_COMPAT
#endif
#ifdef IO80211_LEGACY_COMPAT
#ifndef __STRUCT_WEPNETWORK__
#define __STRUCT_WEPNETWORK__
// Have to redifine this here because can't include AirPortComm.h; this header file is used by all the vendors
typedef struct WepNetwork
{
// UInt32 keyLen; // zero keyLen ==> encryption off
UInt16 bssType; // selects Infra/IBSS
UInt16 keyLen; // zero keyLen ==> encryption off
UInt8 key[16]; // WEP key (5 or 13 bytes)
UInt16 authentication; // open system, or shared key
char ssid[34]; // Network name.
UInt8 rsnKey[32]; // RSN keys are bigger
} WepNetwork;
typedef WepNetwork *WepNetworkPtr;
#endif
#endif
#define AUTH_TIMEOUT 15 // seconds
/*! @enum LinkSpeed.
@abstract ???.
@discussion ???.
@constant LINK_SPEED_80211A 54 Mbps
@constant LINK_SPEED_80211B 11 Mbps.
@constant LINK_SPEED_80211G 54 Mbps.
*/
enum {
LINK_SPEED_80211A = 54000000ul, // 54 Mbps
LINK_SPEED_80211B = 11000000ul, // 11 Mbps
LINK_SPEED_80211G = 54000000ul, // 54 Mbps
LINK_SPEED_80211N = 300000000ul, // 300 Mbps (MCS index 15, 400ns GI, 40 MHz channel)
};
enum IO80211CountryCodeOp
{
kIO80211CountryCodeReset, // Reset country code to world wide default, and start
// searching for 802.11d beacon
};
typedef enum IO80211CountryCodeOp IO80211CountryCodeOp;
enum IO80211SystemPowerState
{
kIO80211SystemPowerStateUnknown,
kIO80211SystemPowerStateAwake,
kIO80211SystemPowerStateSleeping,
};
typedef enum IO80211SystemPowerState IO80211SystemPowerState;
enum IO80211FeatureCode
{
kIO80211Feature80211n = 1,
};
typedef enum IO80211FeatureCode IO80211FeatureCode;
#define IO80211_LOG( _interface, _level, _msg, ... ) do{ if( _interface && ( _interface->debugFlags() & _level ) ) IOLog( _msg, ##__VA_ARGS__ ); }while(0)
class IO80211Interface;
class IO80211Scanner;
class IO80211WorkLoop;
class IO80211VirtualInterface;
/*! @class IO80211Controller
@abstract Abstract superclass for 80211 controllers.
@discussion 80211 controller drivers should subclass IO80211Controller, and implement or override the hardware specific methods to create an 80211 driver. An interface object (an IO80211Interface instance) must be instantiated by the driver, through attachInterface(), to connect the controller driver to the data link layer.
*/
class IO80211Controller : public IOEthernetController
{
OSDeclareAbstractStructors( IO80211Controller )
#ifdef IO80211_LEGACY_COMPAT
private:
struct apple80211_assoc_data _lastAssocData;
bool _interferenceRobustness;
IO80211Scanner *_scanner;
WepNetwork _lastLegacyAssocInfo;
public:
/* Removed in SL:
IOReturn newUserClient( task_t owningTask, void * securityID, UInt32 type,
OSDictionary * properties, IOUserClient ** handler );
*/
IOReturn queueCommand( UInt8 commandCode, void *arguments, void *returnValue );
static IOReturn execCommand( OSObject * obj, void *field0, void *field1, void *field2, void *field3 );
SInt32 getLastAssocData( struct apple80211_assoc_data * ad);
SInt32 setLastAssocData( struct apple80211_assoc_data * ad);
IOReturn getLastLegacyAssocInfo(WepNetworkPtr netPtr );
IOReturn setLastLegacyAssocInfo(WepNetworkPtr netPtr );
bool getInterferenceRobustness() { return _interferenceRobustness; }
void setInterferenceRobustness(bool flag) { _interferenceRobustness = flag; }
IO80211Scanner *getScanner() { return _scanner; }
void setScanner(IO80211Scanner *scanner) { _scanner = scanner; }
#endif
public:
/*! @function start
@abstract ???.
@param provider ???.
@result Returns true on success, false otherwise.
*/
virtual bool start(IOService *provider);
/*! @function stop
@abstract ???.
@param provider ???.
*/
virtual void stop(IOService *provider);
/*! @function init
@abstract ???.
@result ???.
*/
virtual bool init(OSDictionary * properties);
/*! @function free
@abstract ???.
@result ???.
*/
virtual void free();
/*! @function createWorkLoop
@abstract ???.
@result ???.
*/
virtual bool createWorkLoop();
/* Added in Snow Leopard */
virtual IOService *getProvider() const;
/*! @function getWorkLoop
@abstract ???.
@result ???.
*/
virtual IOWorkLoop *getWorkLoop() const;
/*! @function getProvider
@abstract ???.
@result ???.
*/
IOService * getProvider();
/*! @function enable
@abstract ???.
@param aNetif ???.
@result Returns ???.
*/
virtual IOReturn enable(IONetworkInterface *aNetif);
/*! @function disable
@abstract ???.
@param aNetif ???.
@result Returns ???.
*/
virtual IOReturn disable(IONetworkInterface *aNetif);
/*! @function getHardwareAddress
@abstract Gets the 80211 controller's station address.
@discussion The default implementation of the abstract method inherited from IONetworkController. This method will call the overloaded form IO80211Controller::getHardwareAddress() that subclasses are expected to override.
@param addr The buffer where the controller's hardware address should be written.
@param inOutAddrBytes The size of the address buffer provided by the client, and replaced by this method with the actual size of the hardware address in bytes.
@result Returns kIOReturnSuccess on success, or an error otherwise.
*/
virtual IOReturn getHardwareAddress(IOEthernetAddress *addr);
/*! @function getOutputQueue
@abstract ???.
@param ???.
@result Returns ???.
*/
virtual IOOutputQueue * getOutputQueue() const;
/*! @function configureInterface
@abstract Configures a newly created network interface object.
@discussion This method configures an interface object that was created by
createInterface(). Subclasses can override this method to customize
and examine the interface object that will be attached to the
controller as a client.
@param interface The interface object to be configured.
@result Returns true if the operation was successful, false otherwise
(this will cause attachInterface() to fail and return 0).
*/
virtual bool configureInterface(IONetworkInterface * netIf);
/* Added in SL: */
virtual IOReturn getHardwareAddressForInterface(IO80211Interface *,IOEthernetAddress *);
/*! @function inputMonitorPacket
@abstract ???.
@param m ???.
*/
virtual void inputMonitorPacket( mbuf_t m, UInt32 dlt, void * header, size_t header_len );
/*! @function outputRaw80211Packet
@abstract ???.
@param m ???.
*/
/* Replaced with bpfOutput
virtual int outputRaw80211Packet( IO80211Interface * interface, mbuf_t m ) { return ENXIO; }
*/
virtual int bpfOutputPacket(OSObject* owner,unsigned long,mbuf_t m) { return ENXIO; }
/* Removed in SL:
virtual UInt32 monitorPacketHeaderLength( IO80211Interface * interface ) { return 0; }
virtual UInt32 monitorDLT( IO80211Interface * interface ) { return DLT_NULL; }
*/
/*! @function monitorModeSetEnabled
@abstract ???.
@result Returns ???.
*/
virtual SInt32 monitorModeSetEnabled( IO80211Interface * interface, bool enabled, unsigned int dlt ) {return ENXIO; }
/*! @function getNetworkInterface
@abstract ???.
@result Returns ???.
*/
virtual IO80211Interface *getNetworkInterface();
/*! @function apple80211_ioctl
@abstract ???.
@param interface ???.
@param ifn ???.
@param cmd ???.
@param data ???.
@result Returns ???.
*/
virtual SInt32 apple80211_ioctl(IO80211Interface *interface,
IO80211VirtualInterface *vap,
ifnet_t ifn,
unsigned long cmd,
void *data);
/* ioctl handlers */
#define IOCTL_GET( type, intf, data ) apple80211Request( SIOCGA80211, APPLE80211_IOC_##type, intf, (void *)data )
#define IOCTL_SET( type, intf, data ) apple80211Request( SIOCSA80211, APPLE80211_IOC_##type, intf, (void *)data )
virtual SInt32 apple80211Request( UInt32 req, int type, IO80211Interface * intf, void * data ) = 0;
// SIOCGA80211
SInt32 getASSOCIATE_RESULT( IO80211Interface * interface,
struct apple80211_assoc_result_data * ard );
// Power management methods
static IOReturn powerChangeGated( OSObject *owner, void *arg0, void *arg1, void *arg2, void *arg3 );
/* newly added for Lion: */
virtual SInt32 apple80211VirtualRequest(UInt32, int, IO80211VirtualInterface *,void *) { return EOPNOTSUPP; }
virtual SInt32 stopDMA() { return EOPNOTSUPP; }
void setSleeping( bool sleeping ) { _sleeping = sleeping; }
// Output queue introspection
virtual UInt32 hardwareOutputQueueDepth( IO80211Interface * interface ) { return 0; }
// For control of country code settings
virtual SInt32 performCountryCodeOperation( IO80211Interface * interface, IO80211CountryCodeOp op ) { return EOPNOTSUPP; }
virtual bool useAppleRSNSupplicant( IO80211Interface * interface ) { return true; }
virtual bool useAppleRSNSupplicant( IO80211VirtualInterface * interface ) { return true; }
virtual void dataLinkLayerAttachComplete( IO80211Interface * interface );
UInt32 radioCountForInterface( IO80211Interface * interface );
virtual SInt32 enableFeature( IO80211FeatureCode feature, void * refcon ) { return EOPNOTSUPP; }
/* New for Lion: */
virtual SInt32 setVirtualHardwareAddress(IO80211VirtualInterface *,ether_addr *);
virtual SInt32 enableVirtualInterface(IO80211VirtualInterface *);
virtual SInt32 disableVirtualInterface(IO80211VirtualInterface *);
protected:
/*! @function powerDownHandler
@abstract ???.
@discussion ???.
*/
static IOReturn powerChangeHandler( void *target, void *refCon, UInt32 messageType,
IOService *service, void *messageArgument, vm_size_t argSize );
// optional methods provided by subclass
/* Removed in SL (?)
virtual bool promiscuousEnabled();
*/
// mostly internal use, but may need to override
virtual IONetworkInterface *createInterface();
virtual void inputPacket( mbuf_t m );
virtual SInt32 apple80211_ioctl_get(IO80211Interface *interface,
IO80211VirtualInterface* vap,
ifnet_t ifn,
void *data);
virtual SInt32 apple80211_ioctl_set(IO80211Interface *interface,
IO80211VirtualInterface* vap,
ifnet_t ifn,
void *data);
// New for Lion:
virtual IO80211VirtualInterface* createVirtualInterface(ether_addr *addr,unsigned long);
virtual bool attachVirtualInterface(IO80211VirtualInterface **,ether_addr *,unsigned long timeout = 5000 /* XXX? */,bool doRegister = true);
virtual bool detachVirtualInterface(IO80211VirtualInterface *,bool);
/* No longer in Lion:
virtual bool attachInterface(IONetworkInterface ** interface,
bool doRegister = true);
// Force a second interface to attach to the same controller
virtual bool attachInterfaceWithMacAddress( void * macAddr,
UInt32 macLen,
IONetworkInterface ** interface,
bool doRegister = true,
UInt32 timeout = 5000 );
*/
private:
bool forceInterfaceRegistration( IO80211Interface * interface );
IO80211WorkLoop *_myWorkLoop;
IONetworkInterface *_netIF;
// Intel power management handler
IONotifier * _powerDownNotifier;
IOService * _provider;
bool _ifAttachPending;
bool _sleeping;
// Virtual function padding
OSMetaClassDeclareReservedUnused( IO80211Controller, 0);
OSMetaClassDeclareReservedUnused( IO80211Controller, 1);
OSMetaClassDeclareReservedUnused( IO80211Controller, 2);
OSMetaClassDeclareReservedUnused( IO80211Controller, 3);
OSMetaClassDeclareReservedUnused( IO80211Controller, 4);
OSMetaClassDeclareReservedUnused( IO80211Controller, 5);
OSMetaClassDeclareReservedUnused( IO80211Controller, 6);
OSMetaClassDeclareReservedUnused( IO80211Controller, 7);
OSMetaClassDeclareReservedUnused( IO80211Controller, 8);
OSMetaClassDeclareReservedUnused( IO80211Controller, 9);
OSMetaClassDeclareReservedUnused( IO80211Controller, 10);
OSMetaClassDeclareReservedUnused( IO80211Controller, 11);
OSMetaClassDeclareReservedUnused( IO80211Controller, 12);
OSMetaClassDeclareReservedUnused( IO80211Controller, 13);
OSMetaClassDeclareReservedUnused( IO80211Controller, 14);
OSMetaClassDeclareReservedUnused( IO80211Controller, 15);
};
#endif /* defined(KERNEL) && defined(__cplusplus) */
#endif /* !_IO80211CONTROLLER_H */