2 * Copyright (c) 1998-2000 Apple Computer, Inc. All rights reserved.
4 * @APPLE_LICENSE_HEADER_START@
6 * The contents of this file constitute Original Code as defined in and
7 * are subject to the Apple Public Source License Version 1.1 (the
8 * "License"). You may not use this file except in compliance with the
9 * License. Please obtain a copy of the License at
10 * http://www.apple.com/publicsource and read it before using this file.
12 * This Original Code and all software distributed under the License are
13 * distributed on an "AS IS" basis, WITHOUT WARRANTY OF ANY KIND, EITHER
14 * EXPRESS OR IMPLIED, AND APPLE HEREBY DISCLAIMS ALL SUCH WARRANTIES,
15 * INCLUDING WITHOUT LIMITATION, ANY WARRANTIES OF MERCHANTABILITY,
16 * FITNESS FOR A PARTICULAR PURPOSE OR NON-INFRINGEMENT. Please see the
17 * License for the specific language governing rights and limitations
20 * @APPLE_LICENSE_HEADER_END@
23 * Copyright (c) 1999 Apple Computer, Inc. All rights reserved.
25 * IOEthernetController.h
29 * Dec 3, 1998 jliu - C++ conversion.
32 #ifndef _IOETHERNETCONTROLLER_H
33 #define _IOETHERNETCONTROLLER_H
35 #include <IOKit/network/IONetworkController.h>
37 /*! @defined kIOEthernetControllerClass
38 @abstract kIOEthernetControllerClass is the name of the
39 IOEthernetController class. */
41 #define kIOEthernetControllerClass "IOEthernetController"
43 /*! @defined kIOEthernetAddressSize
44 @abstract The number of bytes in an Ethernet hardware address. */
46 #define kIOEthernetAddressSize 6
48 /*! @defined kIOEthernetMaxPacketSize
49 @abstract The maximum size of an Ethernet packet, including
52 #define kIOEthernetMaxPacketSize 1518
54 /*! @defined kIOEthernetMinPacketSize
55 @abstract The minimum size of an Ethernet packet, including
58 #define kIOEthernetMinPacketSize 64
60 /*! @defined kIOEthernetCRCSize
61 @abstract The size in bytes of the 32-bit CRC value appended
62 to the end of each Ethernet frame. */
64 #define kIOEthernetCRCSize 4
66 /*! @defined kIOEthernetWakeOnLANFilterGroup
67 @abstract kIOEthernetWakeOnLANFilterGroup describes the name assigned
68 to the Ethernet wake-On-LAN filter group. */
70 #define kIOEthernetWakeOnLANFilterGroup "IOEthernetWakeOnLANFilterGroup"
72 /*! @enum Enumeration of wake-On-LAN filters.
73 @discussion An enumeration of all filters in the wake-on-LAN filter
74 group. Each filter listed will respond to a network event that
75 will trigger a system wake-up.
76 @constant kIOEthernetWakeOnMagicPacket Reception of a Magic Packet. */
79 kIOEthernetWakeOnMagicPacket
= 0x1
85 #if defined(KERNEL) && defined(__cplusplus)
87 struct IOEthernetAddress
{
88 UInt8 bytes
[kIOEthernetAddressSize
];
91 extern "C" { // FIXME - remove
92 #include <sys/socket.h>
94 #include <net/etherdefs.h>
97 /*! @defined gIOEthernetWakeOnLANFilterGroup
98 @discussion gIOEthernetWakeOnLANFilterGroup is an OSSymbol object
99 that contains the name of the Ethernet wake-on-LAN filter group
100 defined by kIOEthernetWakeOnLANFilterGroup. */
102 extern const OSSymbol
* gIOEthernetWakeOnLANFilterGroup
;
104 /*! @class IOEthernetController : public IONetworkController
105 @abstract An abstract superclass for Ethernet controllers. Ethernet
106 controller drivers should subclass IOEthernetController, and implement
107 or override the hardware specific methods to create an Ethernet driver.
108 An interface object (an IOEthernetInterface instance) must be
109 instantiated by the driver, through attachInterface(), to connect
110 the controller driver to the data link layer. */
112 class IOEthernetController
: public IONetworkController
114 OSDeclareAbstractStructors( IOEthernetController
)
117 struct ExpansionData
{ };
119 Reserved for future use. (Internal use only) */
120 ExpansionData
* _reserved
;
125 /*! @function initialize
126 @abstract IOEthernetController class initializer.
127 @discussion Create global OSSymbol objects that are used as keys. */
129 static void initialize();
132 @abstract Initialize an IOEthernetController object.
133 @param properties A dictionary object containing a property table
134 associated with this instance.
135 @result true on success, false otherwise. */
137 virtual bool init(OSDictionary
* properties
);
139 /*! @function getPacketFilters
140 @abstract Get the set of packet filters supported by the Ethernet
141 controller in the given filter group.
142 @discussion The default implementation of the abstract method inherited
143 from IONetworkController. When the filter group specified is
144 gIONetworkFilterGroup, then this method will return a value formed by
145 a bitwise OR of kIOPacketFilterUnicast, kIOPacketFilterBroadcast,
146 kIOPacketFilterMulticast, kIOPacketFilterPromiscuous. Otherwise, the
147 return value will be set to zero (0). Subclasses must override this
148 method if their filtering capability differs from what is reported by
149 this default implementation. This method is called from the workloop
150 context, and the result is published to the I/O Kit registry.
151 @param group The name of the filter group.
152 @param filters Pointer to the mask of supported filters returned by
154 @result kIOReturnSuccess. Drivers that override this
155 method must return kIOReturnSuccess to indicate success, or an error
156 return code otherwise. */
158 virtual IOReturn
getPacketFilters(const OSSymbol
* group
,
159 UInt32
* filters
) const;
161 /*! @function enablePacketFilter
162 @abstract Enable one of the supported packet filters from the
164 @discussion The default implementation of the abstract method inherited
165 from IONetworkController. This method will call setMulticastMode() or
166 setPromiscuousMode() when the multicast or the promiscuous filter is to be
167 enabled. Requests to disable the Unicast or Broadcast filters are handled
168 silently, without informing the subclass. Subclasses can override this
169 method to change this default behavior, or to extend it to handle
170 additional filter types or filter groups. This method call is synchronized
171 by the workloop's gate.
172 @param group The name of the filter group containing the filter to be
174 @param aFilter The filter to enable.
175 @param enabledFilters All filters currently enabled by the client.
176 @param options Optional flags for the enable request.
177 @result The return from setMulticastMode() or setPromiscuousMode() if
178 either of those two methods are called. kIOReturnSuccess if the filter
179 specified is kIOPacketFilterUnicast or kIOPacketFilterBroadcast.
180 kIOReturnUnsupported if the filter group specified is not
181 gIONetworkFilterGroup. */
183 virtual IOReturn
enablePacketFilter(const OSSymbol
* group
,
185 UInt32 enabledFilters
,
186 IOOptionBits options
= 0);
188 /*! @function disablePacketFilter
189 @abstract Disable a packet filter that is currently enabled from the
191 @discussion The default implementation of the abstract method inherited
192 from IONetworkController. This method will call setMulticastMode() or
193 setPromiscuousMode() when the multicast or the promiscuous filter is to be
194 disabled. Requests to disable the Unicast or Broadcast filters are handled
195 silently, without informing the subclass. Subclasses can override this
196 method to change this default behavior, or to extend it to handle
197 additional filter types or filter groups. This method call is synchronized
198 by the workloop's gate.
199 @param group The name of the filter group containing the filter to be
201 @param aFilter The filter to disable.
202 @param enabledFilters All filters currently enabled by the client.
203 @param options Optional flags for the disable request.
204 @result The return from setMulticastMode() or setPromiscuousMode() if
205 either of those two methods are called. kIOReturnSuccess if the filter
206 specified is kIOPacketFilterUnicast or kIOPacketFilterBroadcast.
207 kIOReturnUnsupported if the filter group specified is not
208 gIONetworkFilterGroup. */
210 virtual IOReturn
disablePacketFilter(const OSSymbol
* group
,
212 UInt32 enabledFilters
,
213 IOOptionBits options
= 0);
215 /*! @function getHardwareAddress
216 @abstract Get the Ethernet controller's station address.
217 @discussion The default implementation of the abstract method inherited
218 from IONetworkController. This method will call the overloaded form
219 IOEthernetController::getHardwareAddress() that subclasses are expected
221 @param addr The buffer where the controller's hardware address should
223 @param inOutAddrBytes The size of the address buffer provided by the
224 client, and replaced by this method with the actual size of
225 the hardware address in bytes.
226 @result kIOReturnSuccess on success, or an error otherwise. */
228 virtual IOReturn
getHardwareAddress(void * addr
,
229 UInt32
* inOutAddrBytes
);
231 /*! @function setHardwareAddress
232 @abstract Set or change the station address used by the Ethernet
234 @discussion The default implementation of the abstract method inherited
235 from IONetworkController. This method will call the overloaded form
236 IOEthernetController::setHardwareAddress() that subclasses are expected
238 @param addr The buffer containing the hardware address provided by
240 @param addrBytes The size of the address buffer provided by the
242 @result kIOReturnSuccess on success, or an error otherwise. */
244 virtual IOReturn
setHardwareAddress(const void * addr
,
247 /*! @function getMaxPacketSize
248 @abstract Get the maximum packet size supported by the Ethernet
249 controller, including the frame header and FCS.
250 @param maxSize Pointer to the return value.
251 @result kIOReturnSuccess on success, or an error code otherwise. */
253 virtual IOReturn
getMaxPacketSize(UInt32
* maxSize
) const;
255 /*! @function getMinPacketSize
256 @abstract Get the minimum packet size supported by the Ethernet
257 controller, including the frame header and FCS.
258 @param minSize Pointer to the return value.
259 @result kIOReturnSuccess on success, or an error code otherwise. */
261 virtual IOReturn
getMinPacketSize(UInt32
* minSize
) const;
263 /*! @function getPacketFilters
264 @abstract Get the set of packet filters supported by the Ethernet
265 controller in the network filter group.
266 @param filters Pointer to the return value containing a mask of
268 @result kIOReturnSuccess. Drivers that override this
269 method must return kIOReturnSuccess to indicate success, or an error
270 return code otherwise. */
272 virtual IOReturn
getPacketFilters(UInt32
* filters
) const;
274 /*! @function getHardwareAddress
275 @abstract Get the Ethernet controller's permanent station address.
276 @discussion. Ethernet drivers must implement this method, by reading the
277 address from hardware and writing it to the buffer provided. This method
278 is called from the workloop context.
279 @param addrP Pointer to an IOEthernetAddress where the hardware address
281 @result kIOReturnSuccess on success, or an error return code otherwise. */
283 virtual IOReturn
getHardwareAddress(IOEthernetAddress
* addrP
) = 0;
285 /*! @function setHardwareAddress
286 @abstract Set or change the station address used by the Ethernet
288 @discussion This method is called in response to a client command to
289 change the station address used by the Ethernet controller. Implementation
290 of this method is optional. This method is called from the workloop context.
291 @param addrP Pointer to an IOEthernetAddress containing the new station
293 @result The default implementation will always return kIOReturnUnsupported.
294 If overridden, drivers must return kIOReturnSuccess on success, or an error
295 return code otherwise. */
297 virtual IOReturn
setHardwareAddress(const IOEthernetAddress
* addrP
);
299 /*! @function setMulticastMode
300 @abstract Enable or disable multicast mode.
301 @discussion Called by enablePacketFilter() or disablePacketFilter()
302 when there is a change in the activation state of the multicast filter
303 identified by kIOPacketFilterMulticast. This method is called from the
305 @param active True to enable multicast mode, false to disable it.
306 @result kIOReturnUnsupported. If overridden, drivers must return
307 kIOReturnSuccess on success, or an error return code otherwise. */
309 virtual IOReturn
setMulticastMode(bool active
);
311 /*! @function setMulticastList
312 @abstract Set the list of multicast addresses that the multicast filter
313 should use to match against the destination address of an incoming frame.
314 The frame should be accepted when a match occurs.
315 @discussion Called when the multicast group membership of an interface
316 object is changed. Drivers that support kIOPacketFilterMulticast should
317 override this method and update the hardware multicast filter using the
318 list of Ethernet addresses provided. Perfect multicast filtering is
319 preferred if supported by the hardware, to order to reduce the number of
320 unwanted packets received. If the number of multicast addresses in the
321 list exceeds what the hardware is capable of supporting, or if perfect
322 filtering is not supported, then ideally the hardware should be programmed
323 to perform imperfect filtering, thorugh some form of hash filtering
324 mechanism. Only at the last resort should the driver enable reception of
325 all multicast packets to satisfy this request. This method is called
326 from the workloop context, and only if the driver reports
327 kIOPacketFilterMulticast support in getPacketFilters().
328 @param addrs An array of Ethernet addresses. This argument must be
329 ignored if the count argument is 0.
330 @param count The number of Ethernet addresses in the list. This value
331 will be zero when the list becomes empty.
332 @result kIOReturnUnsupported. Drivers must return kIOReturnSuccess to
333 indicate success, or an error return code otherwise. */
335 virtual IOReturn
setMulticastList(IOEthernetAddress
* addrs
,
338 /*! @function setPromiscuousMode
339 @abstract Enable or disable promiscuous mode.
340 @discussion Called by enablePacketFilter() or disablePacketFilter()
341 when there is a change in the activation state of the promiscuous
342 filter identified by kIOPacketFilterPromiscuous. This method is
343 called from the workloop context.
344 @param active True to enable promiscuous mode, false to disable it.
345 @result kIOReturnUnsupported. If overridden, drivers must return
346 kIOReturnSuccess on success, or an error return code otherwise. */
348 virtual IOReturn
setPromiscuousMode(bool active
);
350 /*! @function setWakeOnMagicPacket
351 @abstract Enable or disable the wake on Magic Packet support.
352 @discussion Called by enablePacketFilter() or disablePacketFilter()
353 when there is a change in the activation state of the wake-on-LAN
354 filter identified by kIOEthernetWakeOnMagicPacket. This method is
355 called from the workloop context.
356 @param active True to enable support for system wake on reception
357 of a Magic Packet, false to disable it.
358 @result kIOReturnUnsupported. If overridden, drivers must return
359 kIOReturnSuccess on success, or an error return code otherwise. */
361 virtual IOReturn
setWakeOnMagicPacket(bool active
);
365 /*! @function createInterface
366 @abstract Create an IOEthernetInterface object.
367 @discussion Allocate and return a new IOEthernetInterface instance.
368 A subclass of IONetworkController must implement this method and return
369 a matching interface object. The implementation in IOEthernetController
370 will return an IOEthernetInterface object. Subclasses of
371 IOEthernetController, such as Ethernet controller drivers, will have
372 little reason to override this implementation.
373 @result A newly allocated and initialized IOEthernetInterface object. */
375 virtual IONetworkInterface
* createInterface();
378 @abstract Free the IOEthernetController instance. Release resources,
379 then followed by a call to super::free(). */
383 /*! @function publishProperties
384 @abstract Publish Ethernet controller properties and capabilities.
385 @discussion Publish Ethernet controller properties to the property
386 table. For instance, getHardwareAddress() is called to fetch the
387 hardware address, and the address is then published to the property
388 table. This method call is synchronized by the workloop's gate,
389 and must never be called directly by subclasses.
390 @result true if all properties and capabilities were discovered,
391 and published successfully, false otherwise. Returning false will
392 prevent client objects from attaching to the Ethernet controller
393 since a property that a client relies upon may be missing. */
395 virtual bool publishProperties();
397 // Virtual function padding
398 OSMetaClassDeclareReservedUnused( IOEthernetController
, 0);
399 OSMetaClassDeclareReservedUnused( IOEthernetController
, 1);
400 OSMetaClassDeclareReservedUnused( IOEthernetController
, 2);
401 OSMetaClassDeclareReservedUnused( IOEthernetController
, 3);
402 OSMetaClassDeclareReservedUnused( IOEthernetController
, 4);
403 OSMetaClassDeclareReservedUnused( IOEthernetController
, 5);
404 OSMetaClassDeclareReservedUnused( IOEthernetController
, 6);
405 OSMetaClassDeclareReservedUnused( IOEthernetController
, 7);
406 OSMetaClassDeclareReservedUnused( IOEthernetController
, 8);
407 OSMetaClassDeclareReservedUnused( IOEthernetController
, 9);
408 OSMetaClassDeclareReservedUnused( IOEthernetController
, 10);
409 OSMetaClassDeclareReservedUnused( IOEthernetController
, 11);
410 OSMetaClassDeclareReservedUnused( IOEthernetController
, 12);
411 OSMetaClassDeclareReservedUnused( IOEthernetController
, 13);
412 OSMetaClassDeclareReservedUnused( IOEthernetController
, 14);
413 OSMetaClassDeclareReservedUnused( IOEthernetController
, 15);
414 OSMetaClassDeclareReservedUnused( IOEthernetController
, 16);
415 OSMetaClassDeclareReservedUnused( IOEthernetController
, 17);
416 OSMetaClassDeclareReservedUnused( IOEthernetController
, 18);
417 OSMetaClassDeclareReservedUnused( IOEthernetController
, 19);
418 OSMetaClassDeclareReservedUnused( IOEthernetController
, 20);
419 OSMetaClassDeclareReservedUnused( IOEthernetController
, 21);
420 OSMetaClassDeclareReservedUnused( IOEthernetController
, 22);
421 OSMetaClassDeclareReservedUnused( IOEthernetController
, 23);
422 OSMetaClassDeclareReservedUnused( IOEthernetController
, 24);
423 OSMetaClassDeclareReservedUnused( IOEthernetController
, 25);
424 OSMetaClassDeclareReservedUnused( IOEthernetController
, 26);
425 OSMetaClassDeclareReservedUnused( IOEthernetController
, 27);
426 OSMetaClassDeclareReservedUnused( IOEthernetController
, 28);
427 OSMetaClassDeclareReservedUnused( IOEthernetController
, 29);
428 OSMetaClassDeclareReservedUnused( IOEthernetController
, 30);
429 OSMetaClassDeclareReservedUnused( IOEthernetController
, 31);
433 * FIXME: remove this.
436 kIOEnetPromiscuousModeOff
= false,
437 kIOEnetPromiscuousModeOn
= true,
438 kIOEnetPromiscuousModeAll
= true,
439 kIOEnetMulticastModeOff
= false,
440 kIOEnetMulticastModeFilter
= true
442 typedef bool IOEnetPromiscuousMode
;
443 typedef bool IOEnetMulticastMode
;
445 #endif /* defined(KERNEL) && defined(__cplusplus) */
447 #endif /* !_IOETHERNETCONTROLLER_H */