1/* 2 * Copyright (c) 1998-2000 Apple Computer, Inc. All rights reserved. 3 * 4 * @APPLE_LICENSE_HEADER_START@ 5 * 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. 11 * 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 18 * under the License. 19 * 20 * @APPLE_LICENSE_HEADER_END@ 21 */ 22/* 23 * Copyright (c) 1999 Apple Computer, Inc. All rights reserved. 24 * 25 * IOFWInterface.h 26 * 27 */ 28 29#ifndef _IOFWINTERFACE_H 30#define _IOFWINTERFACE_H 31 32/*! @defined kIOFWInterfaceClass 33 @abstract kIOFWInterfaceClass is the name of the 34 IOFWInterface class. */ 35 36#define kIOFWInterfaceClass "IOFWInterface" 37 38/*! @defined kIOActivePacketFilters 39 @abstract kIOActivePacketFilters is a property of IOFWInterface 40 objects. It has an OSDictionary value. 41 @discussion The kIOActivePacketFilters property describes the current 42 set of packet filters that have been successfully activated. Each 43 entry in the dictionary is a key/value pair consisting of the filter 44 group name, and an OSNumber describing the set of active filters for 45 that group. Entries in this dictionary will mirror those in 46 kIORequiredPacketFilters if the controller has reported success for 47 all filter change requests from the IOFWInterface object. */ 48 49#define kIOActivePacketFilters "IOActivePacketFilters" 50 51/*! @defined kIORequiredPacketFilters 52 @abstract kIORequiredPacketFilters is a property of IOFWInterface 53 objects. It has an OSDictionary value. 54 @discussion The kIORequiredPacketFilters property describes the current 55 set of required packet filters. Each entry in the dictionary is a 56 key/value pair consisting of the filter group name, and an OSNumber 57 describing the set of required filters for that group. */ 58 59#define kIORequiredPacketFilters "IORequiredPacketFilters" 60 61/*! @defined kIOMulticastAddressList 62 @abstract kIOMulticastAddressList is a property of IOFWInterface 63 objects. It is an OSData object. 64 @discussion The kIOMulticastAddressList property describes the 65 list of multicast addresses that are being used by the 66 controller to match against the destination address of an 67 incoming frame. */ 68 69#define kIOMulticastAddressList "IOMulticastAddressList" 70#define kIOMulticastFilterData kIOMulticastAddressList 71 72/* 73 * Kernel 74 */ 75#if defined(KERNEL) && defined(__cplusplus) 76 77#include <IOKit/network/IONetworkInterface.h> 78#include "IOFWController.h" 79#include "IOFWStats.h" 80 81 82/*! @class IOFWInterface : public IONetworkInterface 83 @abstract The FireWire interface object. An FireWire controller driver, 84 that is a subclass of IOFWController, will instantiate an object 85 of this class when the driver calls the attachInterface() method. 86 This interface object will then vend an FireWire interface to DLIL, 87 and manage the connection between the controller driver and the upper 88 networking layers. Drivers will seldom need to subclass 89 IOFWInterface. */ 90 91class IOFWInterface : public IONetworkInterface 92{ 93 OSDeclareDefaultStructors( IOFWInterface ) 94 95private: 96 OSData * _uniqueID; // used in ifnet recycling 97 UInt32 _mcAddrCount; // # of multicast addresses 98 bool _ctrEnabled; // Is controller enabled? 99 OSDictionary * _supportedFilters; // Controller's supported filters 100 OSDictionary * _requiredFilters; // The required filters 101 OSDictionary * _activeFilters; // Currently active filters 102 bool _controllerLostPower; // true if controller is unusable 103 void * _controller; // we need this to access FireWire specific ARP mechanism. 104 void * _familyCookie; // moved from BSD layer to IOKit. 105 106 struct ExpansionData { }; 107 /*! @var reserved 108 Reserved for future use. (Internal use only) */ 109 ExpansionData * _reserved; 110 111 112 IOReturn enableController(IONetworkController * ctr); 113 IOReturn setupMulticastFilter(IONetworkController * ctr); 114 115 UInt32 getFilters(const OSDictionary * dict, 116 const OSSymbol * group); 117 118 bool setFilters(OSDictionary * dict, 119 const OSSymbol * group, 120 UInt32 filters); 121 122 IOReturn disableFilter(IONetworkController * ctr, 123 const OSSymbol * group, 124 UInt32 filter, 125 IOOptionBits options = 0); 126 127 IOReturn enableFilter(IONetworkController * ctr, 128 const OSSymbol * group, 129 UInt32 filter, 130 IOOptionBits options = 0); 131 132 int syncSIOCSIFFLAGS(IONetworkController * ctr); 133 int syncSIOCSIFADDR(IONetworkController * ctr); 134 int syncSIOCADDMULTI(IONetworkController * ctr); 135 int syncSIOCDELMULTI(IONetworkController * ctr); 136 int syncSIOCSIFMTU(IONetworkController * ctr, struct ifreq * ifr); 137 int syncSIOCSIFLLADDR(IONetworkController * ctr, const char * lladdr, int len); 138 int syncSIOCGIFADDR(IONetworkController * ctr, char * lladdr, int len); 139 140 static int performGatedCommand(void *, void *, void *, void *, void *); 141 142public: 143 144/*! @function init 145 @abstract Initialize an IOFWInterface instance. 146 @discussion Instance variables are initialized 147 @param controller A network controller object that will service 148 the interface object being initialized. 149 @result true on success, false otherwise. */ 150 151 virtual bool init( IONetworkController * controller ); 152 153/*! @function getNamePrefix 154 @abstract Return a string containing the prefix to use when 155 creating a BSD name for this interface. 156 @discussion The BSD name for each interface object is created by 157 concatenating a string returned by this method, with an unique 158 unit number assigned by IONetworkStack. 159 @result A pointer to a constant C string "fw". Therefore, FireWire 160 interfaces will be registered with BSD as fw0, fw1, etc. */ 161 162 virtual const char * getNamePrefix() const; 163 164/*! @function setProperties 165 @abstract Handle a request to set FireWire interface properties from 166 kernel or non-kernel clients. For non-kernel clients, the preferred 167 access mechanism is through an user client connection. 168 @param properties An OSDictionary containing a collection of 169 properties. 170 @result Returns kIOReturnUnsupported if the interface did not 171 recognize any of the properties provided. Otherwise, the return 172 code will be kIOReturnSuccess to indicate no errors, or an 173 IOReturn error code to indicate that an error occurred while 174 handling one of the properties. */ 175 176 virtual IOReturn setProperties( OSObject * properties ); 177 178protected: 179 180/*! @function free 181 @abstract Free the IOFWInterface instance. 182 @discussion The memory allocated for internal bookkeeping is released, 183 followed by a call to super::free(). */ 184 185 virtual void free(); 186 187/*! @function performCommand 188 @abstract Handle an ioctl command sent to the FireWire interface. 189 @discussion This method handles socket ioctl commands sent to the FireWire 190 interface from DLIL. Commands recognized and processed by this method are 191 SIOCSIFADDR, SIOCSIFFLAGS, SIOCADDMULTI, and SIOCDELMULTI. Other commands 192 are passed to the superclass. 193 @param controller The controller object. 194 @param cmd The ioctl command code. 195 @param arg0 Command argument 0. Generally a pointer to an ifnet structure 196 associated with the interface. 197 @param arg1 Command argument 1. 198 @result A BSD return value defined in bsd/sys/errno.h. */ 199 200 virtual SInt32 performCommand(IONetworkController * controller, 201 unsigned long cmd, 202 void * arg0, 203 void * arg1); 204 205/*! @function controllerDidOpen 206 @abstract A notification that the interface has opened the network 207 controller. 208 @discussion This method will be called by IONetworkInterface after a 209 network controller has accepted an open from this interface object. 210 IOFWInterface will first call the implementation in its 211 superclass, then inspect the controller through properties published 212 in the registry. This method is called with the arbitration lock held. 213 @param controller The controller object that was opened. 214 @result true on success, false otherwise. Returning false will 215 cause the controller to be closed, and any pending client opens to be 216 rejected. */ 217 218 virtual bool controllerDidOpen(IONetworkController * controller); 219 220/*! @function controllerWillClose 221 @abstract A notification that the interface will close the network 222 controller. 223 @discussion This method will simply call super to propagate the method 224 call. This method is called with the arbitration lock held. 225 @param controller The controller that is about to be closed. */ 226 227 virtual void controllerWillClose(IONetworkController * controller); 228 229/*! @function initIfnetParams 230 @abstract Initialize the ifnet structure given. 231 @discussion IOFWInterface will initialize this structure in a manner 232 that is appropriate for FireWire interfaces, then call super::initIfnetParams() 233 to allow the superclass to perform generic interface initialization. 234 @param ifp Pointer to an ifnet structure obtained earlier through 235 the getIfnet() method call. 236 @result true on success, false otherwise. */ 237 238 virtual bool initIfnetParams(struct ifnet_init_params *params); 239 240 241/*! @function controllerWillChangePowerState 242 @abstract Handle a notification that the network controller which is 243 servicing this interface object is about to transition to a new power state. 244 @discussion If the controller is about to transition to an unusable state, 245 and it is currently enabled, then the disable() method on the controller is 246 called. 247 @param controller The network controller object. 248 @param flags Flags that describe the capability of the controller in the new 249 power state. 250 @param stateNumber An index to a state in the network controller's 251 power state array that the controller is switching to. 252 @param policyMaker A reference to the network controller's policy-maker, 253 and is also the originator of this notification. 254 @result The return value is always kIOReturnSuccess. */ 255 256 virtual IOReturn controllerWillChangePowerState( 257 IONetworkController * controller, 258 IOPMPowerFlags flags, 259 UInt32 stateNumber, 260 IOService * policyMaker); 261 262/*! @function controllerDidChangePowerState 263 @abstract Handle a notification that the network controller which is servicing 264 this interface object has transitioned to a new power state. 265 @discussion If the controller did transition to a usable state, and it was 266 previously disabled due to a previous power change, then it is re-enabled. 267 @param controller The network controller object. 268 @param flags Flags that describe the capability of the controller in the new 269 power state. 270 @param stateNumber An index to a state in the network controller's 271 power state array that the controller has switched to. 272 @param policyMaker A reference to the network controller's policy-maker, 273 and is also the originator of this notification. 274 @result The return value is always kIOReturnSuccess. */ 275 276 virtual IOReturn controllerDidChangePowerState( 277 IONetworkController * controller, 278 IOPMPowerFlags flags, 279 UInt32 stateNumber, 280 IOService * policyMaker); 281 282public: 283 /* Override IONetworkInterface::willTerminate() */ 284 285 virtual bool willTerminate( IOService * provider, 286 IOOptionBits options ); 287 288 /* Override IONetworkInterface::attachToDataLinkLayer() */ 289 virtual IOReturn attachToDataLinkLayer( IOOptionBits options, 290 void * parameter ); 291 292 virtual void detachFromDataLinkLayer( IOOptionBits options, 293 void * parameter ); 294 295 void setIfnetMTU(UInt32 mtu); 296 297 void setFamilyCookie(void *data); 298 299 void *getFamilyCookie(){return _familyCookie;} 300 301 // Virtual function padding 302 OSMetaClassDeclareReservedUnused( IOFWInterface, 0); 303 OSMetaClassDeclareReservedUnused( IOFWInterface, 1); 304 OSMetaClassDeclareReservedUnused( IOFWInterface, 2); 305 OSMetaClassDeclareReservedUnused( IOFWInterface, 3); 306 OSMetaClassDeclareReservedUnused( IOFWInterface, 4); 307 OSMetaClassDeclareReservedUnused( IOFWInterface, 5); 308 OSMetaClassDeclareReservedUnused( IOFWInterface, 6); 309 OSMetaClassDeclareReservedUnused( IOFWInterface, 7); 310 OSMetaClassDeclareReservedUnused( IOFWInterface, 8); 311 OSMetaClassDeclareReservedUnused( IOFWInterface, 9); 312 OSMetaClassDeclareReservedUnused( IOFWInterface, 10); 313 OSMetaClassDeclareReservedUnused( IOFWInterface, 11); 314 OSMetaClassDeclareReservedUnused( IOFWInterface, 12); 315 OSMetaClassDeclareReservedUnused( IOFWInterface, 13); 316 OSMetaClassDeclareReservedUnused( IOFWInterface, 14); 317 OSMetaClassDeclareReservedUnused( IOFWInterface, 15); 318}; 319 320#endif /* defined(KERNEL) && defined(__cplusplus) */ 321 322#endif /* !_IOFWINTERFACE_H */ 323