Legacy Documentclose button

Important: The information in this document is obsolete and should not be used for new development.

Previous Book Contents Book Index Next

Inside Macintosh: Networking With Open Transport / Part 2 - Open Transport Reference
Chapter 25 - Option Management Reference / Functions
Finding Options /


OTNextOption

Locates the next TOption structure in a buffer.

C INTERFACE
OSStatus OTNextOption (UInt8* buffer, UInt32 buflen, 
                     TOption** prevOptPtr;
C++ INTERFACE
None. C++ applications use the C interface to this function.

PARAMETERS
buffer
A pointer to the buffer containing the option to be found.
buflen
A long specifying the size of the buffer containing the option to be found.
prevOptPtr
A pointer to a pointer to the first or current TOption structure. The first time you call the function, set this parameter. On return, this parameter references the beginning address of the next option
function result
The only error returned by this function is kOTBufferOverflow; the option retrieved is larger than the buffer allocated to contain it.
DISCUSSION
The OTNextOption function allows you to parse through a buffer containing TOption structures describing an endpoint's option values. Within the buffer, TOption structures are aligned to long-word boundaries. This function takes into account this padding when it calculates the beginning address of the next TOption structure and it returns that address in the prevOptPtr parameter.

The first time you call the option, set the prevOptPtr parameter to nil. When the function returns, the prevOptPtr parameter points to the first option in the buffer. You can continue this process, specifying the value returned for the prevOptPtr parameter by the previous invocation of the function, each time you call the function to obtain the beginning address of the next option in the buffer. You know the function has returned all existing TOption structures when nextOption is nil.

For an example of the use of this function, see "Sample Code: Getting and Setting Options".

SPECIAL CONSIDERATIONS
Open Transport also defines a macro, OPT_NEXTHDR, that works like OTNExtOption, with less error checking.

SEE ALSO
The OTFindOption function.


Previous Book Contents Book Index Next

© Apple Computer, Inc.
15 JAN 1998