C H A P T E R 2

Using Network Setup

kOTCfgTCPDNSServersListPref, which contains the list of configured DNS servers. For details, see OTCfgTCPDNSServersList (page 116).

kOTCfgTCPSearchDomainsPref, which contains the list of additional domains to be searched. For details, see OTCfgTCPSearchDomains (page 120).

kOTCfgTCPUnloadAttrPref, which specifies how TCP/IP loads and unloads. For details, see OTCfgTCPUnloadAttr (page 121).

kOTCfgTCPLocksPref, which is used by the TCP/IP control panel to remember which preferences are locked. For details, see OTCfgTCPLocks (page 116).

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-16Packing 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.

50Protocol-specific Topics

Page 50
Image 50
Apple Network Setup manual Start the cursor at the beginning of the packed preference