ADC Home > Reference Library > Reference > Darwin > Kernel Framework Reference
|
IONetworkData |
Inherits from: | |
Declared In: |
An object that manages a fixed-size named buffer.
An IONetworkData object manages a fixed-size named buffer. This object provides external access methods that can be used to access the contents of the data buffer. In addition, serialization is supported, and therefore this object can be added to a property table to publish the data object. An unique name must be assigned to the object during initialization. An OSSymbol key will be created based on the assigned name, and this key can be used when the object is added to a dictionary.
The level of access granted to the access methods can be restricted, by specifying a set of supported access types when the object is initialized, or modified later by calling setAccessTypes(). By default, each IONetworkData object created will support serialization, and will also allow its data buffer to be read through the read() access method.
An access notification handler, in the form of a 'C' function, can be registered to receive a call each time the data buffer is accessed through an access method. Arguments provided to the handler will identify the data object and the type of access that triggered the notification. The handler can therefore perform lazy update of the data buffer until an interested party tries to read or serialize the data. The notification handler can also take over the default action performed by the access methods when the buffer type is set to kIONetworkDataBufferTypeNone. This will prevent the access methods from accessing the data buffer, and allow the handler to override the access protocol.
This object is primarily used by IONetworkInterface to export interface properties to user space.
Clears the data buffer by filling it with zeroes.
Frees the IONetworkData object.
Gets the types of data access supported by this object.
Gets a pointer to the data buffer.
Gets the type of data buffer managed by this object.
Gets a unique OSSymbol key associated with this object.
Gets the C function that was registered to handle access notifications sent from this object.
Gets the parameter that will be passed to the access notification handler.
Gets the first parameter that will be passed to the access notification handler.
Gets the size of the data buffer.
Initializes an IONetworkData object.
An access method that reads from the data buffer.
Reads from the data buffer and copies the data to a destination buffer provided by the caller.
An access method that resets the data buffer.
Serializes the IONetworkData object.
Sets the types of access that are permitted on the data buffer.
Registers a C function to handle access notifications sent from this object.
Factory method that constructs and initializes an IONetworkData object with an external data buffer.
Factory method that constructs and initializes an IONetworkData object with an internal data buffer.
Factory method that constructs and initializes an IONetworkData object without a data buffer.
An access method that writes to the data buffer.
Writes to the data buffer with data from a source buffer provided by the caller.
clearBuffer |
Clears the data buffer by filling it with zeroes.
protected
virtual bool clearBuffer();
Returns true if the operation was successful, false otherwise.
free |
Frees the IONetworkData object.
protected
virtual void free();
getAccessTypes |
Gets the types of data access supported by this object.
public
virtual UInt32 getAccessTypes() const;
Returns a mask of supported access types.
getBuffer |
Gets a pointer to the data buffer.
public
virtual const void * getBuffer() const;
Returns a pointer to the data buffer. Returns 0 if the buffer type is kIONetworkDataBufferTypeNone.
getBufferType |
Gets the type of data buffer managed by this object.
public
virtual UInt32 getBufferType() const;
Returns a constant that describes the type of the data buffer.
getKey |
Gets a unique OSSymbol key associated with this object.
public
virtual const OSSymbol * getKey() const;
Returns an OSSymbol key that was generated from the name assigned to this object.
During initialization, IONetworkData will create an OSSymbol key based on its assigned name.
getNotificationAction |
Gets the C function that was registered to handle access notifications sent from this object.
public
virtual Action getNotificationAction() const;
Returns a pointer to a C function, or 0 if notification is disabled.
getNotificationParameter |
Gets the parameter that will be passed to the access notification handler.
public
virtual void * getNotificationParameter() const;
Returns the parameter that will be passed to the access notification handler.
getNotificationTarget |
Gets the first parameter that will be passed to the access notification handler.
public
virtual void * getNotificationTarget() const;
Returns the first parameter that will be passed to the access notification handler.
getSize |
Gets the size of the data buffer.
public
virtual UInt32 getSize() const;
Returns the size of the data buffer managed by this object in bytes.
init |
Initializes an IONetworkData object.
public
virtual bool init( const char * name, UInt32 bufferType, UInt32 bufferSize, void * externalBuffer = 0, UInt32 accessTypes = ( kIONetworkDataAccessTypeRead | kIONetworkDataAccessTypeSerialize), void *target = 0, Action action = 0, void *param = 0);
name
A name to assign to this object.
bufferType
The type of buffer associated with this object.
bufferSize
The size of the data buffer.
externalBuffer
Pointer to an external data buffer.
accessTypes
The initial supported access types. Can be later modified by calling setAccessTypes().
target
The notification target.
action
The notification action.
param
A parameter to pass to the notification action.
Returns true if initialized successfully, false otherwise.
read |
An access method that reads from the data buffer.
public
virtual IOReturn read( void *dstBuffer, UInt32 *dstBufferSize, UInt32 readOffset = 0);
dstBuffer
Pointer to the destination buffer.
dstBufferSize
Pointer to an integer containing the size of the destination buffer. And is overwritten by this method to the actual number of bytes copied to the destination buffer.
readOffset
An offset from the start of the source data buffer to begin reading.
Returns kIOReturnSuccess on success, kIOReturnBadArgument if any of the arguments provided is invalid, kIOReturnNotReadable if read access is not permitted, or an error from the notification handler.
This method handles an external request to read from the data buffer and copy it to the destination buffer provided by the accessor. If notification is enabled, then the notification handler is called before the data buffer is copied to the destination buffer. The notification handler may use this opportunity to intervene and to update the contents of the data buffer.
readBytes |
Reads from the data buffer and copies the data to a destination buffer provided by the caller.
protected
virtual bool readBytes( void *dstBuffer, UInt32 *dstBufferSize, UInt32 readOffset = 0) const;
dstBuffer
Pointer to the destination buffer.
dstBufferSize
Pointer to an integer containing the size of the destination buffer. And is overwritten by this method with the actual number of bytes copied to the destination buffer.
readOffset
A byte offset from the start of the data buffer to begin reading.
Returns true if the operation was successful, false otherwise.
reset |
An access method that resets the data buffer.
public
virtual IOReturn reset();
Returns kIOReturnSuccess on success, kIOReturnNotWritable if reset access is not permitted, or an error from the notification handler.
This method handles an external request to reset the data buffer. If notification is enabled, then the notification handler is called after the data buffer has been cleared.
serialize |
Serializes the IONetworkData object.
public
virtual bool serialize( OSSerialize *s) const;
s
An OSSerialize object.
Returns true on success, false otherwise.
If notification is enabled, then the notification handler is called just before the data buffer is serialized.
setAccessTypes |
Sets the types of access that are permitted on the data buffer.
public
virtual void setAccessTypes( UInt32 types);
types
A mask of access types indicating the supported access types.
setNotificationTarget |
Registers a C function to handle access notifications sent from this object.
public
virtual void setNotificationTarget( void *target, Action action, void *param = 0);
target
The first parameter passed to the notification handler.
action
A pointer to a C function that will handle the notification. If 0, then notification is disabled.
param
An optional parameter passed to the notification handler.
A notification is sent by an IONetworkData object to the registered notification handler, when an access method is called to modify the contents of the data buffer.
withExternalBuffer |
Factory method that constructs and initializes an IONetworkData object with an external data buffer.
public
static IONetworkData * withExternalBuffer( const char * name, UInt32 bufferSize, void * externalBuffer, UInt32 accessTypes = (kIONetworkDataAccessTypeRead | kIONetworkDataAccessTypeSerialize), void * target = 0, Action action = 0, void *param = 0);
name
A name to assign to this object.
bufferSize
The size of the external data buffer.
externalBuffer
Pointer to the external data buffer.
accessTypes
The initial supported access types.
target
The notification target.
action
The notification action.
param
A parameter to pass to the notification action.
Returns an IONetworkData object on success, or 0 otherwise.
withInternalBuffer |
Factory method that constructs and initializes an IONetworkData object with an internal data buffer.
public
static IONetworkData * withInternalBuffer( const char * name, UInt32 bufferSize, UInt32 accessTypes = (kIONetworkDataAccessTypeRead | kIONetworkDataAccessTypeSerialize), void * target = 0, Action action = 0, void *param = 0);
name
A name to assign to this object.
bufferSize
The number of bytes to allocate for the internal data buffer.
accessTypes
The initial supported access types.
target
The notification target.
action
The notification action.
param
A parameter to pass to the notification action.
Returns an IONetworkData object on success, or 0 otherwise.
withNoBuffer |
Factory method that constructs and initializes an IONetworkData object without a data buffer.
public
static IONetworkData * withNoBuffer( const char * name, UInt32 bufferSize, UInt32 accessTypes, void * target, Action action, void * param = 0);
name
A name to assign to this object.
bufferSize
The size of the phantom data buffer.
accessTypes
The initial supported access types.
target
The notification target.
action
The notification action.
param
A parameter to pass to the notification action.
Returns an IONetworkData object on success, or 0 otherwise.
The notification handler must intervene when the IONetworkData is accessed.
write |
An access method that writes to the data buffer.
public
virtual IOReturn write( void *srcBuffer, UInt32 srcBufferSize, UInt32 writeOffset = 0);
srcBuffer
Pointer to the source buffer.
srcBufferSize
The number of bytes to write to the data buffer.
writeOffset
An offset from the start of the destination data buffer to begin writing.
Returns kIOReturnSuccess on success, kIOReturnBadArgument if any of the arguments provided is invalid, kIOReturnNotWritable if write access is not permitted, or an error from the notification handler.
This method handles an external request to write to the data buffer from a source buffer provided by the accessor. After checking that the data object supports write accesses, the data buffer is updated if it exists. Then the registered notification handler is called.
writeBytes |
Writes to the data buffer with data from a source buffer provided by the caller.
protected
virtual bool writeBytes( const void * srcBuffer, UInt32 srcBufferSize, UInt32 writeOffset = 0);
srcBuffer
Pointer to a source buffer provided by the caller.
srcBufferSize
The size of the source buffer.
writeOffset
A byte offset from the start of the data buffer to begin writting.
Returns true if the operation was successful, false otherwise.
Action |
Defines a C function that may be called by an IONetworkData object when one of its access methods is called.
public
typedef IOReturn ( *Action)( void *target, void *param, IONetworkData *data, UInt32 accessType, void *buffer, UInt32 *bufferSize, UInt32 offset);
target
The target of the notification.
data
The IONetworkData object being accessed, and the sender of the notification.
accessType
A bit will be set indicating the type of access which triggered the notification.
buffer
Pointer to the accessor's buffer. Only valid for read() and write() accesses.
bufferSize
Pointer to the size of the accessor's buffer.
offset
An offset from the start of the data buffer to begin reading or writing.
param
A parameter that was provided when the notification handler was registered.
_reserved |
protected
ExpansionData * _reserved;
Reserved for future use. (Internal use only)
reserved |
protected
ExpansionData * _reserved;
Reserved for future use. (Internal use only)
|
Last Updated: 2008-12-19