ADC Home > Reference Library > Reference > Hardware & Drivers > I/O Kit Framework Reference

 


IONetworkData

Inherits from:
Declared In:

Overview

An object that manages a fixed-size named buffer.

Discussion

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.



Typedefs


serialize


Serializes the IONetworkData object.

public

typedef IOReturn ( *Action)( void *target, void *param, IONetworkData *data, UInt32 accessType, void *buffer, UInt32 *bufferSize, UInt32 offset); protected: const OSSymbol * _key; // key associated with this object. UInt32 _access; // supported access types. void * _buffer; // Data buffer. UInt32 _bufType; // buffer type UInt32 _size; // data buffer size. void * _tapTarget; // target for access notification. Action _tapAction; // the function to call. void * _tapParam; // arbitrary notification param. struct ExpansionData { }; ExpansionData * _reserved; virtual void free(); virtual bool writeBytes( const void * srcBuffer, UInt32 srcBufferSize, UInt32 writeOffset = 0); virtual bool readBytes( void *dstBuffer, UInt32 *dstBufferSize, UInt32 readOffset = 0) const; virtual bool clearBuffer(); public: static IONetworkData * withInternalBuffer( const char * name, UInt32 bufferSize, UInt32 accessTypes = (kIONetworkDataAccessTypeRead | kIONetworkDataAccessTypeSerialize), void * target = 0, Action action = 0, void *param = 0); static IONetworkData * withExternalBuffer( const char * name, UInt32 bufferSize, void * externalBuffer, UInt32 accessTypes = (kIONetworkDataAccessTypeRead | kIONetworkDataAccessTypeSerialize), void * target = 0, Action action = 0, void *param = 0); static IONetworkData * withNoBuffer( const char * name, UInt32 bufferSize, UInt32 accessTypes, void * target, Action action, void * param = 0); 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); virtual void setAccessTypes( UInt32 types); virtual void setNotificationTarget( void *target, Action action, void *param = 0); virtual const void * getBuffer() const; virtual UInt32 getBufferType() const; virtual UInt32 getAccessTypes() const; virtual void * getNotificationTarget() const; virtual Action getNotificationAction() const; virtual void * getNotificationParameter() const; virtual const OSSymbol * getKey() const; virtual UInt32 getSize() const; virtual IOReturn reset(); virtual IOReturn read( void *dstBuffer, UInt32 *dstBufferSize, UInt32 readOffset = 0); virtual IOReturn write( void *srcBuffer, UInt32 srcBufferSize, UInt32 writeOffset = 0); virtual bool serialize( OSSerialize *s) const; // Virtual function padding OSMetaClassDeclareReservedUnused( IONetworkData, 0); OSMetaClassDeclareReservedUnused( IONetworkData, 1); OSMetaClassDeclareReservedUnused( IONetworkData, 2); OSMetaClassDeclareReservedUnused( IONetworkData, 3); }
Parameters
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.

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.

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.

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.

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.

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.

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.

types

A mask of access types indicating the supported access types.

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.

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.

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.

s

An OSSerialize object.

Parameters
param

A parameter that was provided when the notification handler was registered.

param

A parameter to pass to the notification action.

param

A parameter to pass to the notification action.

param

A parameter to pass to the notification action.

param

A parameter to pass to the notification action.

param

An optional parameter passed to the notification handler.

Return Value

Returns true on success, false otherwise.

Discussion

If notification is enabled, then the notification handler is called just before the data buffer is serialized.


Did this document help you?
Yes: Tell us what works for you.
It’s good, but: Report typos, inaccuracies, and so forth.
It wasn’t helpful: Tell us what would have helped.

 

Last Updated: 2009-02-23