Listing 2-16 – Apple Network Setup User Manual
Page 50

C H A P T E R 2
Using Network Setup
50
Protocol-specific Topics
■
kOTCfgTCPDNSServersListPref
, which contains the list of configured DNS
■
kOTCfgTCPSearchDomainsPref
, which contains the list of additional domains to
be searched. For details, see
■
kOTCfgTCPUnloadAttrPref
, which specifies how TCP/IP loads and unloads.
■
kOTCfgTCPLocksPref
, which is used by the TCP/IP control panel to remember
which preferences are locked. For details, see
The only complex preference in a TCP/IP network connection entity is the
kOTCfgTCPInterfacesPref
preference. The data for this preference is packed in
an unusual way that makes the preference tricky to access from C. To help solve
this problem, Network Setup declares two sets of C structures for this
preference.
■
OTCfgTCPInterfacesPacked
and
OTCfgTCPInterfacesPackedPart
help you
access the preference in its packed format.
■
OTCfgTCPInterfacesUnpacked
is an unpacked form of the preference that you
can use internally within your code. When you read the preference, you can
unpack it into this structure. You can then manipulate the unpacked
structure and only pack it again when you write it.
Listing 2-16 provides sample code that unpacks and packs a
kOTCfgTCPInterfacesPref
preference.
Listing 2-16
Packing and unpacking the kOTCfgTCPInterfacesPref preference
static OSStatus MyPackTCPInterfacesPref(const OTCfgTCPInterfacesUnpacked *unpackedPref,
OTCfgTCPInterfacesPacked *packedPref,
ByteCount *packedPrefSize)
{
UInt8 *cursor;
assert(unpackedPref != nil);
assert(packedPref != nil);
assert(packedPrefSize != nil);
// Start the cursor at the beginning of the packed preference.