-
Notifications
You must be signed in to change notification settings - Fork 2
/
IO80211Interface.h
524 lines (425 loc) · 14 KB
/
IO80211Interface.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
419
420
421
422
423
424
425
426
427
428
429
430
431
432
433
434
435
436
437
438
439
440
441
442
443
444
445
446
447
448
449
450
451
452
453
454
455
456
457
458
459
460
461
462
463
464
465
466
467
468
469
470
471
472
473
474
475
476
477
478
479
480
481
482
483
484
485
486
487
488
489
490
491
492
493
494
495
496
497
498
499
500
501
502
503
504
505
506
507
508
509
510
511
512
513
514
515
516
517
518
519
520
521
522
523
/*
* 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@
*/
#ifndef _IO80211INTERFACE_H
#define _IO80211INTERFACE_H
/*
* Kernel
*/
#if defined(KERNEL) && defined(__cplusplus)
#include <libkern/version.h>
#if VERSION_MAJOR > 8
#define _MODERN_BPF
#endif
#include <IOKit/network/IOEthernetInterface.h>
#include <net/if_var.h>
#include <sys/queue.h>
enum IO80211LinkState
{
kIO80211NetworkLinkUndefined, // Starting link state when an interface is created
kIO80211NetworkLinkDown, // Interface not capable of transmitting packets
kIO80211NetworkLinkUp, // Interface capable of transmitting packets
};
typedef enum IO80211LinkState IO80211LinkState;
/*! @defined kIO80211InterfaceClass
@abstract The name of the IO80211Interface class.
*/
#define kIO80211InterfaceClass "IO80211Interface"
class RSNSupplicant;
class IOTimerEventSource;
class IOGatedOutputQueue;
class IO80211Controller;
class IO80211ScanManager;
struct rsn_pmksa_node;
/*! @class IO80211Interface
@abstract The 80211 interface object.
@discussion An 80211 controller driver, that is a subclass of IOEthernetInterface, will instantiate an object of this class when the driver calls the attachInterface() method. This interface object will then vend an Ethernet interface to DLIL, and manage the connection between the controller driver and the upper networking layers. Drivers will seldom need to subclass IO80211Interface.
*/
class IO80211Interface : public IOEthernetInterface
{
OSDeclareDefaultStructors( IO80211Interface );
public:
/*! @function init
@abstract Initializes an IO80211Interface instance.
@discussion Instance variables are initialized, and ???.
@param controller A network controller object that will service the interface object being initialized.
@result Returns true on success, false otherwise.
*/
virtual bool init(IONetworkController *controller );
/*! @function attachToDataLinkLayer
@abstract ???.
@discussion ???.
*/
virtual IOReturn attachToDataLinkLayer(IOOptionBits options,
void *parameter);
/*! @function detachFromDataLinkLayer
@abstract ???.
@discussion ???.
*/
virtual void detachFromDataLinkLayer(IOOptionBits options,
void *parameter);
/*! @function inputEvent
@abstract Sends an event to the data link layer.
@discussion This method can be used by the network controller to
send an event to the data link layer.
@param type A constant describing the event type.
@param data Data associated with the event.
@result Returns true if the event was delivered, false if the event type
specified is invalid, or if the event delivery was unsuccesful.
*/
virtual bool inputEvent(UInt32 type, void * data);
/*! @function setPoweredOnByUser
@abstract ???.
@discussion ???.
*/
virtual void setPoweredOnByUser(bool poweredOn);
/*! @function poweredOnByUser
@abstract ???.
@discussion ???.
*/
bool poweredOnByUser();
/*! @function setEnabledBySystem
@abstract ???.
@discussion ???.
*/
virtual void setEnabledBySystem(bool systemEnabled);
/*! @function enabledBySystem
@abstract ???.
@discussion ???.
*/
bool enabledBySystem();
/*! @function createStatusDevice
@abstract ???.
@discussion ???.
*/
IOReturn createStatusDevice(char *name );
/*! @function postMessage
@abstract <abstract>.
@discussion ???.
*/
void postMessage( UInt32 msg, void * data = NULL, size_t dataLen = 0 );
/*! @function setAuthTimeout
@abstract <abstract>.
@discussion ???.
*/
void setAuthTimeout( unsigned int timeout );
/*! @function authTimeout
@abstract <abstract>.
@discussion ???.
*/
unsigned int authTimeout();
/*! @function setLinkState
@abstract <abstract>.
@discussion ???.
*/
virtual bool setLinkState( IO80211LinkState linkState, unsigned long blah );
/*! @function linkState
@abstract <abstract>.
@discussion ???.
*/
IO80211LinkState linkState();
/*! @function supplicantListening
@abstract <abstract>.
@discussion ???.
*/
bool initSupplicant( UInt8 * ie );
/*! @function terminateSupplicant
@abstract <abstract>.
@discussion ???.
*/
void terminateSupplicant();
/*! @function resetSupplicant
@abstract <abstract>.
@discussion ???.
*/
void resetSupplicant();
/*! @function setPMK
@abstract <abstract>.
@discussion ???.
*/
bool setPMK( UInt8 * pmk );
/*! @function supplicantExchangeComplete
@abstract <abstract>.
@discussion ???.
*/
bool supplicantExchangeComplete();
/*! @function supplicantInitialized
@abstract <abstract>.
@discussion ???.
*/
bool supplicantInitialized();
/*! @function outputEAPOLFrame
@abstract <abstract>.
@discussion ???.
*/
UInt32 outputEAPOLFrame( mbuf_t m );
/*! @function inputEAPOLFrame
@abstract <abstract>.
@discussion ???.
*/
void inputEAPOLFrame( mbuf_t m );
/*! @function cachePMKSA
@abstract <abstract>.
@discussion ???.
*/
void cachePMKSA( UInt8 * pmk, size_t pmkLen, struct ether_addr * aa, UInt8 * pmkID );
/*! @function cachePMKSA
@abstract <abstract>.
@discussion ???.
*/
SInt32 cachePMKSA( UInt8 * pmk, size_t pmkLen, struct ether_addr * authenticatorEA );
/*! @function pmksaLookup
@abstract <abstract>.
@discussion ???.
*/
struct rsn_pmksa_node * pmksaLookup( struct ether_addr * authenticatorEA, UInt8 * pmkID );
/*! @function shouldRoam
@abstract <abstract>.
@discussion ???.
*/
bool shouldRoam( struct apple80211_scan_result * asr );
/*! @function willRoam
@abstract <abstract>.
@discussion ???.
*/
void willRoam( struct ether_addr * bssid );
/*! @function inputPacket
@abstract <abstract>.
@discussion ???.
*/
virtual UInt32 inputPacket(mbuf_t m,
UInt32 length = 0,
IOOptionBits options = 0,
void * param = 0);
/*! @function outputPacket
@abstract <abstract>.
@discussion ???.
*/
virtual UInt32 outputPacket( mbuf_t m, void * param );
/*! @function getBSDName
@abstract <abstract>.
@discussion ???.
*/
const char * getBSDName();
/*! @function getStatusDevName
@abstract <abstract>.
@discussion ???.
*/
char * getStatusDevName();
/*! @function setCountermeasuresTimer
@abstract <abstract>.
@discussion ???.
*/
void setCountermeasuresTimer( IOTimerEventSource * timer );
/*! @function stopCountermeasures
@abstract <abstract>.
@discussion ???.
*/
static void stopCountermeasures( OSObject *owner, IOTimerEventSource *sender );
/*! @function updateChannelProperty
@abstract <abstract>.
@discussion ???.
*/
void updateChannelProperty();
/*! @function updateSSIDProperty
@abstract <abstract>.
@discussion ???.
*/
void updateSSIDProperty();
/*! @function updateStaticProperties
@abstract <abstract>.
@discussion ???.
*/
void updateStaticProperties();
/*! @function updateCountryCodeProperty
@abstract <abstract>.
@discussion ???.
*/
void updateCountryCodeProperty( bool shouldLog );
/*! @function performCountryCodeOpGated
@abstract ???.
@discussion ???.
*/
static IOReturn performCountryCodeOpGated( OSObject *owner, void * inInterface, void * inParams, void *arg2, void *arg3 );
/*! @function configureAntennae
@abstract ???.
@discussion ???.
*/
void configureAntennae();
/*! @function setDebugFlags
@abstract ???.
@discussion ???.
*/
void setDebugFlags( UInt32 debugFlags );
/*! @function debugFlags
@abstract ???.
@discussion ???.
*/
UInt32 debugFlags();
/*! @function getOutputQueue
@abstract <abstract>.
@discussion ???.
*/
IOGatedOutputQueue * getOutputQueue();
/*! @function bpfAttach
@abstract <abstract>.
@discussion ???.
*/
errno_t bpfAttach( UInt32 dlt, UInt32 headerLen );
/*! @function bpfTap
@abstract <abstract>.
@discussion ???.
*/
errno_t monitorModeInputPacket( mbuf_t m, UInt32 dlt, void * header, size_t header_len );
/*! @function get80211OutputQueue
@abstract <abstract>.
@discussion ???.
*/
IOGatedOutputQueue * get80211OutputQueue();
/*! @function output80211Packet
@abstract <abstract>.
@discussion ???.
*/
virtual UInt32 output80211Packet( mbuf_t m, void * param );
#ifdef WME_QUEUES
IOGatedOutputQueue * getWMEBestEffortQueue() { return _outputQueue; }
IOGatedOutputQueue * getWMEBackgroundQueue() { return _queueBackground; }
IOGatedOutputQueue * getWMEVoiceQueue() { return _queueVoice; }
IOGatedOutputQueue * getWMEVideoQueue() { return _queueVideo; }
bool wmeSupported() { return _wmeSupported; }
UInt32 queueWMEPacket( mbuf_t m, void * param );
IOOutputAction getWMEOutputHandler() { return (IOOutputAction)&IO80211Interface::queueWMEPacket; }
void startOutputQueues();
void stopOutputQueues();
#endif /* WME_QUEUES */
bool shortGISupported40MHz() { return _shortGISupported40MHz; }
bool shortGISupported20MHz() { return _shortGISupported20MHz; }
IO80211ScanManager * getScanManager() { return _scanManager; }
static IOReturn monitorCallbackGated( OSObject *owner, void * arg0, void * arg1, void *arg2, void *arg3 );
void setWoWEnabled( bool enabled ) { _wowEnabled = enabled; }
bool wowEnabled() { return _wowEnabled; }
void setBPFCallbackPending( bool pending ) { _bpfCallbackPending = pending; }
protected:
/*! @function performCommand
@abstract Handles an ioctl command sent to the Ethernet interface.
@discussion This method handles socket ioctl commands sent to the Ethernet interface from DLIL. Commands recognized and processed by this method are SIOCSIFADDR, SIOCSIFFLAGS, SIOCADDMULTI, and SIOCDELMULTI. Other commands are passed to the superclass.
@param controller The controller object.
@param cmd The ioctl command code.
@param arg0 Command argument 0. Generally a pointer to an ifnet structure associated with the interface.
@param arg1 Command argument 1.
@result Returns a BSD return value defined in bsd/sys/errno.h.
*/
virtual SInt32 performCommand(IONetworkController *controller,
UInt32 cmd,
void *arg0,
void *arg1);
/*! @function performGatedCommand
@abstract <abstract>.
@discussion ???.
*/
static int performGatedCommand( void *, void *, void *, void *, void * );
/*! @function free
@abstract Frees the IO80211Interface instance.
@discussion ???, followed by a call to super::free().
*/
virtual void free();
/*! @function powerChangeHandler
@abstract <abstract>.
@discussion ???.
*/
static IOReturn powerChangeHandler( void *target, void *refCon, UInt32 messageType,
IOService *service, void *messageArgument, vm_size_t argSize );
private:
/*! @function inputAWSPacket
@abstract <abstract>.
@discussion ???.
*/
void inputAWSPacket( mbuf_t m );
/*! @function awsRespond
@abstract <abstract>.
@discussion ???.
*/
void awsRespond( mbuf_t m, struct AWSRequest * requestList, size_t numRequests, UInt16 packetID );
/*! @function purgePMKSACache
@abstract <abstract>.
@discussion ???.
*/
void purgePMKSACache();
/*! @function freePMKSACache
@abstract <abstract>.
@discussion ???.
*/
void freePMKSACache();
int _minor;
u_int32_t _devUnit;
char * _statusDevName;
size_t _statusDevNameLen;
bool _poweredOnByUser;
bool _enabledBySystem; // IFF_UP flag set?
unsigned int _authTimeout;
IO80211LinkState _linkState;
bool _pendingLinkEvent;
RSNSupplicant * _rsnSupplicant;
ifmultiaddr_t _awsAddr;
IOTimerEventSource * _countermeasuresTimer;
char _bsdName[IFNAMSIZ];
//struct rsn_pmksa_node * _pmksaCacheHead;
LIST_HEAD( , rsn_pmksa_node ) _pmksaCacheHead;
IONotifier * _powerChangeNotifier;
IOLock * _powerChangeWakeUpLock;
UInt32 _debugFlags;
IOGatedOutputQueue * _outputQueue;
IOGatedOutputQueue * _80211outputQueue;
IO80211Controller * _controller;
void * _llAddr;
UInt8 _ifiType;
bool _wmeSupported;
bool _shortGISupported40MHz;
bool _shortGISupported20MHz;
#ifdef WME_QUEUES
IOGatedOutputQueue * _queueBackground;
IOGatedOutputQueue * _queueVoice;
IOGatedOutputQueue * _queueVideo;
#endif /* WME_QUEUES */
IO80211ScanManager * _scanManager;
bool _wowEnabled;
bool _bpfCallbackPending;
public:
// Virtual function padding
OSMetaClassDeclareReservedUnused( IO80211Interface, 0);
OSMetaClassDeclareReservedUnused( IO80211Interface, 1);
OSMetaClassDeclareReservedUnused( IO80211Interface, 2);
OSMetaClassDeclareReservedUnused( IO80211Interface, 3);
OSMetaClassDeclareReservedUnused( IO80211Interface, 4);
OSMetaClassDeclareReservedUnused( IO80211Interface, 5);
OSMetaClassDeclareReservedUnused( IO80211Interface, 6);
OSMetaClassDeclareReservedUnused( IO80211Interface, 7);
OSMetaClassDeclareReservedUnused( IO80211Interface, 8);
OSMetaClassDeclareReservedUnused( IO80211Interface, 9);
OSMetaClassDeclareReservedUnused( IO80211Interface, 10);
OSMetaClassDeclareReservedUnused( IO80211Interface, 11);
OSMetaClassDeclareReservedUnused( IO80211Interface, 12);
OSMetaClassDeclareReservedUnused( IO80211Interface, 13);
OSMetaClassDeclareReservedUnused( IO80211Interface, 14);
OSMetaClassDeclareReservedUnused( IO80211Interface, 15);
};
#endif /* defined(KERNEL) && defined(__cplusplus) */
#endif /* ! _IO80211INTERFACE_H */