Apple Network Setup Network Card User Manual


 
CHAPTER 2
Using Network Setup
52 Protocol-specific Topics
static OSStatus MyUnpackTCPInterfacesPref(const OTCfgTCPInterfacesPacked *packedPref,
ByteCount packedPrefSize,
OTCfgTCPInterfacesUnpacked *unpackedPref)
{
UInt8 *cursor;
assert(packedPref != nil);
assert(unpackedPref != nil);
// Put the cursor at the beginning of the packed preference data.
cursor = (UInt8 *) packedPref;
// Walk through the packed preference data and extract the fields.
unpackedPref->fCount = *((UInt16 *) cursor);
if (unpackedPref->fCount != 1) goto prefDataErr;
cursor += sizeof(UInt16);
unpackedPref->fConfigMethod = *cursor;
cursor += sizeof(UInt8);
// The following code accesses a long off a word.
// Network Setup is PowerPC only, and the emulated PowerPC processor handles these
// misaligned accesses.
unpackedPref->fIPAddress = *((InetHost *) cursor);
cursor += sizeof(InetHost);
unpackedPref->fSubnetMask = *((InetHost *) cursor);
cursor += sizeof(InetHost);
// fAppleTalkZone is a Str32. A longer string in the 'iitf' preference causes an
error.
if ( *cursor > 32 ) goto prefDataErr;
BlockMoveData(cursor, unpackedPref->fAppleTalkZone, *cursor + 1);
cursor += (*cursor + 1);
BlockMoveData(cursor, unpackedPref->path, 36);
cursor += 36;
BlockMoveData(cursor, unpackedPref->module, 32);
cursor += 32;
unpackedPref->framing = *((UInt32 *) cursor);
cursor += sizeof(UInt32);