Mac Developer Library

Developer

System Configuration Framework Reference SCNetworkConfiguration Reference

Options
Deployment Target:

On This Page
Language:

SCNetworkConfiguration Reference

The SCNetworkConfiguration programming interface provides access to the stored network configuration. The functions include providing access to the network-capable devices on the system, the network sets, network services, and network protocols. Note that these functions follow Core Foundation function-name conventions. A function that has "Create" or "Copy" in its name returns a reference you must release with the CFRelease function.

Note that when using the functions in this programming interface, you must call the SCPreferencesCommitChanges function to ensure that your changes are committed to permanent storage.

Functions

  • Adds the specified network service to the specified set.

    Declaration

    Swift

    func SCNetworkSetAddService(_ set: SCNetworkSet, _ service: SCNetworkService) -> Bool

    Objective-C

    Boolean SCNetworkSetAddService ( SCNetworkSetRef set, SCNetworkServiceRef service );

    Parameters

    set

    The set (the complete configuration for a single location).

    service

    The service to add to the set.

    Return Value

    TRUE if the service was added to the set; FALSE if the service was already present or an error occurred.

    Discussion

    Prior to OS X v10.5, the Network Preferences pane did not support having a single service being a member of more than one set. Therefore, an error is returned if you attempt to add a service to more than one set on a pre-10.5 system.

    Availability

    Available in OS X v10.4 and later.

  • Returns a Boolean value indicating whether the specified interface is represented by at least one network service in the specified set.

    Declaration

    Swift

    func SCNetworkSetContainsInterface(_ set: SCNetworkSet, _ interface: SCNetworkInterface) -> Bool

    Objective-C

    Boolean SCNetworkSetContainsInterface ( SCNetworkSetRef set, SCNetworkInterfaceRef interface );

    Parameters

    set

    The set (the complete configuration for a single location).

    interface

    The network interface.

    Return Value

    TRUE if the interface is represented in the set; otherwise, FALSE.

    Availability

    Available in OS X v10.5 and later.

  • Returns the set with the specified identifier.

    Declaration

    Swift

    func SCNetworkSetCopy(_ prefs: SCPreferences, _ setID: CFString) -> SCNetworkSet?

    Objective-C

    SCNetworkSetRef SCNetworkSetCopy ( SCPreferencesRef prefs, CFStringRef setID );

    Parameters

    prefs

    The preferences session.

    setID

    The unique identifier for the set.

    Return Value

    The network set from the associated preferences, or NULL if the identifier does not exist in the preferences or if an error occurred. You must release the returned value.

    Availability

    Available in OS X v10.4 and later.

  • Returns all available sets for the specified preferences session.

    Declaration

    Swift

    func SCNetworkSetCopyAll(_ prefs: SCPreferences) -> CFArray?

    Objective-C

    CFArrayRef SCNetworkSetCopyAll ( SCPreferencesRef prefs );

    Parameters

    prefs

    The preferences session.

    Return Value

    The list of network sets associated with the preferences. You must release the returned value.

    Availability

    Available in OS X v10.4 and later.

  • Returns the current set.

    Declaration

    Swift

    func SCNetworkSetCopyCurrent(_ prefs: SCPreferences) -> SCNetworkSet?

    Objective-C

    SCNetworkSetRef SCNetworkSetCopyCurrent ( SCPreferencesRef prefs );

    Parameters

    prefs

    The preferences session.

    Return Value

    The current set, or NULL if no current set has been defined.

    Availability

    Available in OS X v10.4 and later.

  • Returns all network services associated with the specified set.

    Declaration

    Swift

    func SCNetworkSetCopyServices(_ set: SCNetworkSet) -> CFArray?

    Objective-C

    CFArrayRef SCNetworkSetCopyServices ( SCNetworkSetRef set );

    Parameters

    set

    The set (the complete configuration for a single location).

    Return Value

    The list of network services associated with the set. You must release the returned value.

    Availability

    Available in OS X v10.4 and later.

  • Creates a new set in the configuration.

    Declaration

    Swift

    func SCNetworkSetCreate(_ prefs: SCPreferences) -> SCNetworkSet?

    Objective-C

    SCNetworkSetRef SCNetworkSetCreate ( SCPreferencesRef prefs );

    Parameters

    prefs

    The preferences session.

    Return Value

    The new network set. You must release the returned value.

    Availability

    Available in OS X v10.4 and later.

  • Returns the user-specified name associated with the specified set.

    Declaration

    Swift

    func SCNetworkSetGetName(_ set: SCNetworkSet) -> CFString?

    Objective-C

    CFStringRef SCNetworkSetGetName ( SCNetworkSetRef set );

    Parameters

    set

    The set (the complete configuration for a single location).

    Return Value

    The user-specified name associated with the set.

    Availability

    Available in OS X v10.4 and later.

  • Returns the user-specified ordering of network services within the specified set.

    Declaration

    Swift

    func SCNetworkSetGetServiceOrder(_ set: SCNetworkSet) -> CFArray?

    Objective-C

    CFArrayRef SCNetworkSetGetServiceOrder ( SCNetworkSetRef set );

    Parameters

    set

    The set (the complete configuration for a single location).

    Return Value

    The ordered list of service identifiers associated with the set, or NULL if no service order has been specified or if an error occurred.

    Availability

    Available in OS X v10.4 and later.

  • Returns the identifier for the specified set.

    Declaration

    Swift

    func SCNetworkSetGetSetID(_ set: SCNetworkSet) -> CFString?

    Objective-C

    CFStringRef SCNetworkSetGetSetID ( SCNetworkSetRef set );

    Parameters

    set

    The set (the complete configuration for a single location).

    Return Value

    The set identifier.

    Availability

    Available in OS X v10.4 and later.

  • Returns the type identifier of all SCNetworkSet instances.

    Declaration

    Swift

    func SCNetworkSetGetTypeID() -> CFTypeID

    Objective-C

    CFTypeID SCNetworkSetGetTypeID ( void );

    Return Value

    The type identifier of all SCNetworkSet instances.

    Availability

    Available in OS X v10.4 and later.

  • Removes the specified set from the configuration.

    Declaration

    Swift

    func SCNetworkSetRemove(_ set: SCNetworkSet) -> Bool

    Objective-C

    Boolean SCNetworkSetRemove ( SCNetworkSetRef set );

    Parameters

    set

    The set (the complete configuration for a single location).

    Return Value

    TRUE if the set was removed; FALSE if an error occurred.

    Availability

    Available in OS X v10.4 and later.

  • Removes the specified network service from the specified set.

    Declaration

    Swift

    func SCNetworkSetRemoveService(_ set: SCNetworkSet, _ service: SCNetworkService) -> Bool

    Objective-C

    Boolean SCNetworkSetRemoveService ( SCNetworkSetRef set, SCNetworkServiceRef service );

    Parameters

    set

    The set (the complete configuration for a single location).

    service

    The service to remove.

    Return Value

    TRUE if the service was removed from the set; FALSE if the service was not already present or an error occurred.

    Availability

    Available in OS X v10.4 and later.

  • Specifies the set that should be the current set.

    Declaration

    Swift

    func SCNetworkSetSetCurrent(_ set: SCNetworkSet) -> Bool

    Objective-C

    Boolean SCNetworkSetSetCurrent ( SCNetworkSetRef set );

    Parameters

    set

    The set (the complete configuration for a single location).

    Return Value

    TRUE if the current set was updated; FALSE if an error occurred.

    Availability

    Available in OS X v10.4 and later.

  • Stores the user-specified name for the specified set.

    Declaration

    Swift

    func SCNetworkSetSetName(_ set: SCNetworkSet, _ name: CFString) -> Bool

    Objective-C

    Boolean SCNetworkSetSetName ( SCNetworkSetRef set, CFStringRef name );

    Parameters

    set

    The set (the complete configuration for a single location).

    name

    The user-defined name to associate with the set.

    Return Value

    TRUE if the name was saved; FALSE if an error occurred.

    Discussion

    Although it is not technically required, the user-specified names for all sets should be unique. For this reason, an error is returned if you attempt to name two sets with the same string.

    Availability

    Available in OS X v10.4 and later.

  • Stores the user-specified ordering of network services for the specified set.

    Declaration

    Swift

    func SCNetworkSetSetServiceOrder(_ set: SCNetworkSet, _ newOrder: CFArray) -> Bool

    Objective-C

    Boolean SCNetworkSetSetServiceOrder ( SCNetworkSetRef set, CFArrayRef newOrder );

    Parameters

    set

    The set (the complete configuration for a single location).

    newOrder

    The ordered list of service identifiers for the set.

    Return Value

    TRUE if the new service order was saved; FALSE if an error occurred.

    Availability

    Available in OS X v10.4 and later.

Data Types

  • The reference to an object that represents a network interface.

    Declaration

    Swift

    class SCNetworkInterface { }

    Objective-C

    typedef const struct __SCNetworkInterface * SCNetworkInterfaceRef;

    Import Statement

    Objective-C

    @import SystemConfiguration;

    Swift

    import SystemConfiguration

    Availability

    Available in OS X v10.4 and later.

  • The reference to an object that represents an Ethernet bond interface.

    Declaration

    Swift

    typealias SCBondInterface = SCNetworkInterfaceRef

    Objective-C

    typedef SCNetworkInterfaceRef SCBondInterfaceRef;

    Import Statement

    Objective-C

    @import SystemConfiguration;

    Swift

    import SystemConfiguration

    Availability

    Available in OS X v10.5 and later.

  • The reference to an object that represents the status of an Ethernet bond interface.

    Declaration

    Swift

    class SCBondStatus { }

    Objective-C

    typedef const struct __SCBondStatus * SCBondStatusRef;

    Import Statement

    Objective-C

    @import SystemConfiguration;

    Swift

    import SystemConfiguration

    Availability

    Available in OS X v10.5 and later.

  • The reference to an object that represents a virtual LAN (VLAN) interface.

    Declaration

    Swift

    typealias SCVLANInterfaceRef = SCVLANInterface

    Objective-C

    typedef SCNetworkInterfaceRef SCVLANInterfaceRef;

    Import Statement

    Objective-C

    @import SystemConfiguration;

    Swift

    import SystemConfiguration

    Availability

    Available in OS X v10.5 and later.

  • The reference to an object that represents a network protocol.

    Declaration

    Swift

    class SCNetworkProtocol { }

    Objective-C

    typedef const struct __SCNetworkProtocol * SCNetworkProtocolRef;

    Import Statement

    Objective-C

    @import SystemConfiguration;

    Swift

    import SystemConfiguration

    Availability

    Available in OS X v10.4 and later.

  • The reference to an object that represents a network service.

    Declaration

    Swift

    class SCNetworkService { }

    Objective-C

    typedef const struct __SCNetworkService * SCNetworkServiceRef;

    Import Statement

    Objective-C

    @import SystemConfiguration;

    Swift

    import SystemConfiguration

    Availability

    Available in OS X v10.4 and later.

  • The reference to an object that represents a network set.

    Declaration

    Swift

    class SCNetworkSet { }

    Objective-C

    typedef const struct __SCNetworkSet * SCNetworkSetRef;

    Import Statement

    Objective-C

    @import SystemConfiguration;

    Swift

    import SystemConfiguration

    Availability

    Available in OS X v10.4 and later.

Constants

  • Ethernet bond aggregation status codes.

    Declaration

    Swift

    var kSCBondStatusOK: Int { get } var kSCBondStatusLinkInvalid: Int { get } var kSCBondStatusNoPartner: Int { get } var kSCBondStatusNotInActiveGroup: Int { get } var kSCBondStatusUnknown: Int { get }

    Objective-C

    enum { kSCBondStatusOK = 0, kSCBondStatusLinkInvalid = 1, kSCBondStatusNoPartner = 2, kSCBondStatusNotInActiveGroup = 3, kSCBondStatusUnknown = 999 };

    Constants

    • kSCBondStatusOK

      kSCBondStatusOK

      The status is valid (for example, enabled, active, running, and so forth.)

      Available in OS X v10.5 and later.

    • kSCBondStatusLinkInvalid

      kSCBondStatusLinkInvalid

      The link state is not valid (such as down, half-duplex, or wrong speed).

      Available in OS X v10.5 and later.

    • kSCBondStatusNoPartner

      kSCBondStatusNoPartner

      The port on the switch to which the device is connected doesn't seem to have 802.3ad Link Aggregation enabled.

      Available in OS X v10.5 and later.

    • kSCBondStatusNotInActiveGroup

      kSCBondStatusNotInActiveGroup

      Communication with a partner is occurring, but the link aggregation group is different from the one that is active.

      Available in OS X v10.5 and later.

    • kSCBondStatusUnknown

      kSCBondStatusUnknown

      Nonspecific failure.

      Available in OS X v10.5 and later.

  • Ethernet bond status codes.

    Declaration

    Swift

    let kSCBondStatusDeviceAggregationStatus: CFString let kSCBondStatusDeviceCollecting: CFString let kSCBondStatusDeviceDistributing: CFString

    Objective-C

    const CFStringRef kSCBondStatusDeviceAggregationStatus; const CFStringRef kSCBondStatusDeviceCollecting; const CFStringRef kSCBondStatusDeviceDistributing;

    Constants

    • kSCBondStatusDeviceAggregationStatus

      kSCBondStatusDeviceAggregationStatus

      Device is aggregating. See Ethernet Bond Aggregation Status for a list of possible values.

      Available in OS X v10.4 and later.

    • kSCBondStatusDeviceCollecting

      kSCBondStatusDeviceCollecting

      Can be 0 or 1.

      Available in OS X v10.4 and later.

    • kSCBondStatusDeviceDistributing

      kSCBondStatusDeviceDistributing

      Can be 0 or 1.

      Available in OS X v10.4 and later.

  • Keys that identify network interface types.

    Declaration

    Swift

    let kSCNetworkInterfaceType6to4: CFString let kSCNetworkInterfaceTypeBluetooth: CFString let kSCNetworkInterfaceTypeBond: CFString let kSCNetworkInterfaceTypeEthernet: CFString let kSCNetworkInterfaceTypeFireWire: CFString let kSCNetworkInterfaceTypeIEEE80211: CFString let kSCNetworkInterfaceTypeIPSec: CFString let kSCNetworkInterfaceTypeIrDA: CFString let kSCNetworkInterfaceTypeL2TP: CFString let kSCNetworkInterfaceTypeModem: CFString let kSCNetworkInterfaceTypePPP: CFString let kSCNetworkInterfaceTypePPTP: CFString let kSCNetworkInterfaceTypeSerial: CFString let kSCNetworkInterfaceTypeVLAN: CFString let kSCNetworkInterfaceTypeWWAN: CFString let kSCNetworkInterfaceTypeIPv4: CFString let kSCNetworkInterfaceIPv4: SCNetworkInterface

    Objective-C

    const CFStringRef kSCNetworkInterfaceType6to4; const CFStringRef kSCNetworkInterfaceTypeBluetooth; const CFStringRef kSCNetworkInterfaceTypeBond; const CFStringRef kSCNetworkInterfaceTypeEthernet; const CFStringRef kSCNetworkInterfaceTypeFireWire; const CFStringRef kSCNetworkInterfaceTypeIEEE80211; const CFStringRef kSCNetworkInterfaceTypeIPSec; const CFStringRef kSCNetworkInterfaceTypeIrDA; const CFStringRef kSCNetworkInterfaceTypeL2TP; const CFStringRef kSCNetworkInterfaceTypeModem; const CFStringRef kSCNetworkInterfaceTypePPP; const CFStringRef kSCNetworkInterfaceTypePPTP; const CFStringRef kSCNetworkInterfaceTypeSerial; const CFStringRef kSCNetworkInterfaceTypeVLAN; const CFStringRef kSCNetworkInterfaceTypeWWAN; const CFStringRef kSCNetworkInterfaceTypeIPv4; const SCNetworkInterfaceRef kSCNetworkInterfaceIPv4;

    Constants

    • kSCNetworkInterfaceType6to4

      kSCNetworkInterfaceType6to4

      The 6to4 interface.

      Available in OS X v10.4 and later.

    • kSCNetworkInterfaceTypeBluetooth

      kSCNetworkInterfaceTypeBluetooth

      The Bluetooth interface.

      Available in OS X v10.4 and later.

    • kSCNetworkInterfaceTypeBond

      kSCNetworkInterfaceTypeBond

      The Ethernet bond interface.

      Available in OS X v10.4 and later.

    • kSCNetworkInterfaceTypeEthernet

      kSCNetworkInterfaceTypeEthernet

      The Ethernet interface.

      Available in OS X v10.4 and later.

    • kSCNetworkInterfaceTypeFireWire

      kSCNetworkInterfaceTypeFireWire

      The FireWire interface.

      Available in OS X v10.4 and later.

    • kSCNetworkInterfaceTypeIEEE80211

      kSCNetworkInterfaceTypeIEEE80211

      The IEEE 802.11 interface.

      Available in OS X v10.4 and later.

    • kSCNetworkInterfaceTypeIPSec

      kSCNetworkInterfaceTypeIPSec

      The IPSec interface.

      Available in OS X v10.5 and later.

    • kSCNetworkInterfaceTypeIrDA

      kSCNetworkInterfaceTypeIrDA

      The IrDA interface.

      Available in OS X v10.4 and later.

    • kSCNetworkInterfaceTypeL2TP

      kSCNetworkInterfaceTypeL2TP

      The L2TP interface.

      Available in OS X v10.4 and later.

    • kSCNetworkInterfaceTypeModem

      kSCNetworkInterfaceTypeModem

      The modem interface.

      Available in OS X v10.4 and later.

    • kSCNetworkInterfaceTypePPP

      kSCNetworkInterfaceTypePPP

      The PPP interface.

      Available in OS X v10.4 and later.

    • kSCNetworkInterfaceTypePPTP

      kSCNetworkInterfaceTypePPTP

      The PPTP interface.

      Available in OS X v10.4 and later.

    • kSCNetworkInterfaceTypeSerial

      kSCNetworkInterfaceTypeSerial

      The serial interface.

      Available in OS X v10.4 and later.

    • kSCNetworkInterfaceTypeVLAN

      kSCNetworkInterfaceTypeVLAN

      The VLAN interface.

      Available in OS X v10.4 and later.

    • kSCNetworkInterfaceTypeWWAN

      kSCNetworkInterfaceTypeWWAN

      The WWAN interface.

      Available in OS X v10.5 and later.

    • kSCNetworkInterfaceTypeIPv4

      kSCNetworkInterfaceTypeIPv4

      The IPv4 interface.

      Available in OS X v10.4 and later.

    • kSCNetworkInterfaceIPv4

      kSCNetworkInterfaceIPv4

      A network interface that can used for layering other interfaces (for example, 6to4, PPTP, or L2TP) over an existing IPv4 network.

      Available in OS X v10.4 and later.

  • Keys that identify network protocol types.

    Declaration

    Swift

    let kSCNetworkProtocolTypeDNS: CFString let kSCNetworkProtocolTypeIPv4: CFString let kSCNetworkProtocolTypeIPv6: CFString let kSCNetworkProtocolTypeProxies: CFString let kSCNetworkProtocolTypeSMB: CFString

    Objective-C

    const CFStringRef kSCNetworkProtocolTypeAppleTalk; const CFStringRef kSCNetworkProtocolTypeDNS; const CFStringRef kSCNetworkProtocolTypeIPv4; const CFStringRef kSCNetworkProtocolTypeIPv6; const CFStringRef kSCNetworkProtocolTypeProxies; const CFStringRef kSCNetworkProtocolTypeSMB;

    Constants

    • kSCNetworkProtocolTypeAppleTalk

      The AppleTalk protocol.

      Available in OS X v10.4 and later.

      Deprecated in OS X v10.6.

    • kSCNetworkProtocolTypeDNS

      kSCNetworkProtocolTypeDNS

      The DNS protocol.

      Available in OS X v10.4 and later.

    • kSCNetworkProtocolTypeIPv4

      kSCNetworkProtocolTypeIPv4

      The IPv4 protocol.

      Available in OS X v10.4 and later.

    • kSCNetworkProtocolTypeIPv6

      kSCNetworkProtocolTypeIPv6

      The IPv6 protocol.

      Available in OS X v10.4 and later.

    • kSCNetworkProtocolTypeProxies

      kSCNetworkProtocolTypeProxies

      Protocol proxies.

      Available in OS X v10.4 and later.

    • kSCNetworkProtocolTypeSMB

      kSCNetworkProtocolTypeSMB

      The SMB procotol.

      Available in OS X v10.5 and later.