IONetworkParameter



Member Functions

clearBytes

public:

virtual bool clearBytes();

Clear the entire data buffer by calling bzero().

Result: true if the buffer was cleared, false otherwise.

copyBytes

public:

virtual bool copyBytes(void * bytes, UInt * inOutLength) const;

Copy the data buffer to a destination buffer provided by the caller.

Parameters

NameDescription
bytesPointer to a destination buffer.
inOutLengthThe caller must initialize the integer value pointed by inOutLength with the size of the destination buffer, and this method will overwrite it with the number of bytes copied.
Result: true if the destination buffer is larger or equal to the length of the parameter, false otherwise.

free

protected:

virtual void free();

Frees the IONetworkParameter instance.


getAccessTypes

public:

virtual UInt32 getAccessTypes() const;

Result: The access types supported by this instance.

getAction

public:

virtual IONPAction getAction() const;

Result: The notification action.

getArgument

public:

virtual void * getArgument() const;

Result: The notification argument.

getBuffer

public:

virtual const void * getBuffer() const;

Result: A pointer to the data buffer.

getCapacity

public:

virtual UInt getCapacity() const;

Override the getCapacity() method inherited from OSData.

Result: The capacity of the data buffer in bytes.

getDescriptor

public:

virtual void getDescriptor(IONPDescriptor * descP) const;

Updates the IONPDescriptor structure provided by the caller.

Parameters

NameDescription
Pointerto an IONPDescriptor structure allocated by the caller.

getKey

public:

virtual const OSSymbol * getKey() const;

During initialization, IONetworkParameter will create an OSSymbol key based on its assigned name. This key can be used when adding this object to a dictionary.

Result: An OSSymbol key based on the parameter's assigned name.

getTarget

public:

virtual OSObject * getTarget() const;

Result: The notification target.

init

public:

virtual bool initWithName(const char * name, void * buffer, UInt32 size, UInt32 accessTypes = kIONPAccessRead, OSObject * target = 0, IONPAction action = 0, void * arg = 0);

Initialize an IONetworkParameter instance. A target/action may be assigned to receive notifications when the read(), write(), or reset() methods are called. See those methods for additional information.

Parameters

NameDescription
nameA name assigned to the parameter.
bufferPoints to an external data buffer. If set to kIONPInternalBuffer, then internal buffer storage shall be allocated.
sizeSize of the data buffer in bytes. Both the capacity and the length are intialized to the size given.
accessTypesThe types of access allowed. Can be later changed by calling setAccessTypes().
targetNotification target.
actionNotification action.
argNotification argument.
Result: true if initialized successfully, false otherwise.

initialize

protected:

static void initialize();

Class initializer which allocates a global mutex lock (gIONPLock).


read

public:

virtual IOReturn read(void * inBuffer, UInt * inOutSize);

Handle a request to read from the data buffer and copy it to the destination buffer provided. If notification is enabled, then the notification handler is called with the access argument set to kIONPAccessRead before the data buffer is copied to the destination buffer. The notification handler may take this opportunity to update the contents of the data buffer.

Parameters

NameDescription
inBufferPointer to the destination buffer.
inOutSizePoints to the size of the destination buffer before the call. This method will change it to contain the actual number of bytes written to the destination buffer.
Result: kIOReturnSuccess if success, kIOReturnBadArgument if any argument is invalid, kIOReturnNoSpace if the destination buffer is too small, kIOReturnNotReadable if read access is not permitted, or some other error code from the notification handler if called.

reset

public:

virtual IOReturn reset();

Handle a request to reset the parameter. If notication is enabled, then the notification handler is called with the access argument set to kIONPAccessReset, after the data buffer is cleared.

Result: kIOReturnNotWritable if reset access is not allowed, or kIOReturnSuccess otherwise. If a notification handler is called, then the return value from the handler is returned.

serialize

public:

virtual bool serialize(OSSerialize * s) const;

Serialize the parameter object. If notification is enabled, then the notification target is called as though a read() access has occurred.

Parameters

NameDescription
sAn OSSerialize object.

setAccessTypes

public:

virtual void setAccessTypes(UInt32 accessTypes);

Sets the types of external access allowed. For instance, if access is set to kIONPAccessRead, then only read() will return success. Calls to write() or reset() will return kIOReturnNotWritable. To change this and allow writes, access must be set to (kIONPAccessRead | kIONPAccessWrite). Note that other methods in IONetworkParameter do not check the access types.

Parameters

NameDescription
accessTypesAll supported access types.

setBytes

public:

virtual bool setBytes(const void * bytes, UInt inLength);

Replace the data buffer contents from a source buffer provided by the caller.

Parameters

NameDescription
bytesPointer to a source buffer provided by the caller.
inLengthLength of the source buffer. The length provided must be smaller or equal to the capacity of the parameter object.
Result: true if the length of the source buffer is valid, and the source buffer was copied, false otherwise.

setLength

public:

virtual bool setLength(UInt inLength);

Set a new data buffer length.

Parameters

NameDescription
inLengthLength of the data buffer in bytes. The length provided must be smaller or equal to the capacity of the parameter object.
Result: true if the length provided was accepted.

setNotificationTarget

public:

virtual void setNotificationTarget(OSObject * target, IONPAction action, void * arg = 0);

Set a target/action to receive external access notifications.

Parameters

NameDescription
targetThe target object. If set to 0, then notification will be disabled.
actionThe notification action or handler. If set to 0, then notification will be disabled.
argAn optional argument that will be passed to the notification handler.

withTarget

public:

static IONetworkParameter * withName( const char * name, void * buffer, UInt32 size, UInt32 accessTypes = kIONPAccessRead, OSObject * target = 0, IONPAction action = 0, void * arg = 0);

Factory method that will construct and initialize an IONetworkParameter instance.

Parameters

NameDescription
nameSame as init().
bufferSame as init().
sizeSame as init().
accessTypesSame as init().
targetSame as init().
actionSame as init().
argSame as init().
Result: An IONetworkParameter instance upon success, or 0 otherwise.

write

public:

virtual IOReturn write(void * inBuffer, UInt size);

Handle a request to write to the data buffer from a source buffer provided. If notification is enabled, then the notification handler is called with the access argument set to kIONPAccessWrite after the source buffer has been copied to the data buffer.

Parameters

NameDescription
inBufferPointer to the source buffer.
sizeSize of the source buffer in bytes.
Result: kIOReturnSuccess if success, kIOReturnBadArgument if any argument is invalid, kIOReturnNoSpace if the source buffer is too big, kIOReturnNotWritable if write access is not permitted, or some other error code from the notification handler if called.

© 2000 Apple Computer, Inc. — (Last Updated 2/23/2000)