Source to iokit/IOKit/network/IOEthernetInterface.h
/*
* Copyright (c) 1998-2000 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@
*/
/*
* Copyright (c) 1999 Apple Computer, Inc. All rights reserved.
*
* IOEthernetInterface.h
*
* HISTORY
* 8-Jan-1999 Joe Liu (jliu) created.
*/
#ifndef _IOETHERNETINTERFACE_H
#define _IOETHERNETINTERFACE_H
#include <IOKit/network/IONetworkInterface.h>
#include <IOKit/network/IOEthernetController.h>
#include <IOKit/network/IOEthernetStats.h>
// IOEthernetInterface properties.
//
#define kIOPacketFilters "IOPacketFilters" // OSNumber:32
#define kIOMulticastAddresses "IOMulticastAddresses" // OSData (6 bytes/addr)
/*! @class IOEthernetInterface
@abstract The Ethernet interface object. An Ethernet controller driver
will instantiate this object to manage its connection to the network
stack. */
class IOEthernetInterface : public IONetworkInterface
{
OSDeclareDefaultStructors(IOEthernetInterface)
private:
struct arpcom * _arpcom; // arpcom struct allocated
UInt _mcAddrCount; // # of multicast addresses
UInt32 _features; // cached controller features
UInt32 _availableFilters; // what is available?
UInt32 _activeFilters; // which should be active?
enet_addr_t _macAddr; // controller's MAC address
bool _controllerEnabled; // Is controller enabled?
IOReturn _enableController(IONetworkController * ctlr);
IOReturn _loadMulticastList(IOEthernetController * ctlr);
bool _setActiveFilters(UInt32 newFilters);
int syncSIOCSIFFLAGS(IOEthernetController * ctlr);
int syncSIOCSIFADDR(IOEthernetController * ctlr);
int syncSIOCADDMULTI(IOEthernetController * ctlr);
int syncSIOCDELMULTI(IOEthernetController * ctlr);
public:
/*! @function init
@abstract Initialize an IOEthernetInterface instance.
@discussion Instance variables are initialized, and an arpcom
structure is allocated.
@param properties A property dictionary.
@result true if initialized successfully, false otherwise. */
virtual bool init(OSDictionary * properties = 0);
/*! @function getNamePrefix
@abstract Get a name prefix for the interface.
@discussion The name of the interface advertised to the network layer
is generated by concatenating the string returned by this method,
and an unit number.
@result A pointer to a constant string "en". Thus Ethernet interfaces
will be registered as en0, en1, etc. */
virtual const char * getNamePrefix() const;
protected:
/*! @function free
@abstract Frees the IOEthernetInterface instance.
@discussion The memory allocated for the arpcom structure is released. */
virtual void free();
/*! @function performCommand
@abstract Handle commands from the network layer.
@discussion The handler for ioctl commands sent from the network layer.
Commands not handled by this method are passed to our superclass.
The ioctl commands handled are SIOCSIFADDR, SIOCSIFFLAGS, SIOCADDMULTI,
and SIOCDELMULTI.
@param controller The controller object that the interface is attached to.
@param cmd The command code.
@param arg0 Command argument. Generally a pointer to an ifnet structure.
@param arg1 Command argument.
@result An error code defined in errno.h (BSD). */
virtual SInt performCommand(IONetworkController * controller,
UInt32 cmd,
void * arg0,
void * arg1);
/*! @function controllerDidOpen
@abstract Prepare the controller after it has been opened.
@discussion This method will be called by our superclass after a
network controller has accepted an open from this interface.
IOEthernetInterface uses this method to inspect the controller
and to cache certain controller properties, such as its hardware
address, and its set of supported packet filters.
@param controller The controller object that was opened.
@result true if the controller was accepted, false otherwise
(which will cause the controller to be closed). */
virtual bool controllerDidOpen(IONetworkController * controller);
/*! @function controllerWillClose
@abstract Quiesce the controller before it is closed.
@discussion When the last close from our client is received, the
interface object will close its controller. But before the controller
is closed, this method will be called by our superclass to perform any
final cleanup. IOEthernetInterface will ensure that the controller
is disabled before it is closed.
@param controller The currently opened controller object. */
virtual void controllerWillClose(IONetworkController * controller);
/*! @function initIfnet
@abstract Initialize the ifnet structure.
@discussion The argument is
a pointer to an ifnet structure obtained through getIfnet().
IOEthernetInterface will initialize this structure in a manner that
is appropriate for Ethernet interfaces, then call super::initIfnet()
to allow the superclass to perform family independent initialization.
@param ifp Pointer to the ifnet structure to be initialized.
@result true if successful, false otherwise. */
virtual bool initIfnet(struct ifnet * ifp);
/*! @function getIfnet
@abstract Get the ifnet structure allocated by the interface object.
@discussion This method returns a pointer to an ifnet structure
maintained by the family specific interface. IOEthernetInterface
allocates an arpcom structure during initialization, and returns
a pointer to this structure when this method is called.
@result Pointer to an ifnet structure. */
virtual struct ifnet * getIfnet() const;
};
#endif /* !_IOETHERNETINTERFACE_H */