ADC Home > Reference Library > Reference > Networking > System Configuration Framework Reference
|
SCNetworkConnection.h |
Include Path: | <SystemConfiguration/SCNetworkConnection.h> |
Path: | /System/Library/Frameworks/SystemConfiguration.framework/Versions/A/Headers/SCNetworkConnection.h |
Includes: | <AvailabilityMacros.h> <sys/cdefs.h> <sys/types.h> <sys/socket.h> <CoreFoundation/CoreFoundation.h> <SystemConfiguration/SystemConfiguration.h> |
The SCNetworkConnection API contains functions that allow an application to control connection-oriented services defined in the system and get connection-status information.
The functions in the SCNetworkConnection API allow you to control and get information about existing services only. If you need to create, change, or remove services, you should use the SCNetworkConfiguration API instead.
Note: Currently, only PPP services can be controlled.
For more information on using System Configuration framework APIs, see System Configuration Programming Guidelines.
SCNetworkConnectionCopyExtendedStatus |
CFDictionaryRef SCNetworkConnectionCopyExtendedStatus ( SCNetworkConnectionRef connection );
connection
Returns the status dictionary. If NULL is returned, the error can be retrieved using the SCError function.
Returns the extended status of the connection.
An extended status dictionary contains specific dictionaries
describing the status for each subcomponent of the service.
For example, a status dictionary will contain the following
sub-dictionaries, keys, and values:
Other dictionaries could be present for PPPoE, PPTP, and L2TP.
IPv4 : Addresses : the assigned IP address. PPP : Status : the PPP-specific status of type SCNetworkConnectionPPPStatus. LastCause : Available when the status is "Disconnected" and contains the last error associated with connecting or disconnecting. ConnectTime : the time when the connection was established. Modem : ConnectSpeed : the speed of the modem connection in bits/second.
SCNetworkConnectionCopyServiceID |
CFStringRef SCNetworkConnectionCopyServiceID ( SCNetworkConnectionRef connection );
connection
Returns the service ID associated with the SCNetworkConnection.
Returns the service ID associated with the SCNetworkConnection.
SCNetworkConnectionCopyStatistics |
CFDictionaryRef SCNetworkConnectionCopyStatistics ( SCNetworkConnectionRef connection );
connection
Returns the statistics dictionary. If NULL is returned, the error can be retrieved using the SCError function.
Returns the statistics of the SCNetworkConnection.
A statistic dictionary contains specific dictionaries
with statistics for each subcomponent of the service.
For example, a statistics dictionary will contain the following
sub-dictionaries, keys, and values:
The statistics dictionary may be extended in the future to contain additional information.
PPP : BytesIn : PPP : BytesOut : Contains the number of bytes going up into (or coming out of) the network stack for any networking protocol without the PPP headers and trailers. PPP : PacketsIn : PPP : PacketsOut : Contains the number of packets going up into (or coming out of) the network stack for any networking protocol without the PPP headers and trailers. PPP : ErrorsIn : PPP : ErrorsOut : Contains the number of errors going up into (or coming out of) the network stack for any networking protocol without the PPP headers and trailers.
SCNetworkConnectionCopyUserOptions |
CFDictionaryRef SCNetworkConnectionCopyUserOptions ( SCNetworkConnectionRef connection );
connection
Returns the service dictionary containing the connection options. The dictionary can be empty if no user options were used. If NULL is returned, the error can be retrieved using the SCError function.
Copies the user options used to start the connection. This is a mechanism a client can use to retrieve the user options previously passed to the SCNetworkConnectionStart function.
SCNetworkConnectionCopyUserPreferences |
Boolean SCNetworkConnectionCopyUserPreferences ( CFDictionaryRef selectionOptions, CFStringRef *serviceID, CFDictionaryRef *userOptions );
selectionOptions
serviceID
userOptions
Returns TRUE if there is a valid service to dial; FALSE if the function was unable to retrieve a service to dial.
Provides the default service ID and a dictionary of user options for the connection. Applications can use the returned serviceID and userOptions values to open a connection on the fly.
SCNetworkConnectionCreateWithServiceID |
SCNetworkConnectionRef SCNetworkConnectionCreateWithServiceID ( CFAllocatorRef allocator, CFStringRef serviceID, SCNetworkConnectionCallBack callout, SCNetworkConnectionContext *context );
allocator
serviceID
callout
context
Returns a reference to the new SCNetworkConnection.
Creates a new connection reference to use for getting the status or for connecting or disconnecting the associated service.
SCNetworkConnectionGetStatus |
SCNetworkConnectionStatus SCNetworkConnectionGetStatus ( SCNetworkConnectionRef connection );
connection
Returns the status value.
Returns the status of the SCNetworkConnection. A status is one of the following values:
kSCNetworkConnectionInvalid kSCNetworkConnectionDisconnected kSCNetworkConnectionConnecting kSCNetworkConnectionDisconnecting kSCNetworkConnectionConnected
SCNetworkConnectionGetTypeID |
CF_EXPORT CFTypeID SCNetworkConnectionGetTypeID ( void);
Returns the type identifier of all SCNetworkConnection instances.
SCNetworkConnectionScheduleWithRunLoop |
Boolean SCNetworkConnectionScheduleWithRunLoop ( SCNetworkConnectionRef connection, CFRunLoopRef runLoop, CFStringRef runLoopMode );
connection
runLoop
runLoopMode
Returns TRUE if the connection is scheduled successfully; FALSE if the scheduling failed. The error can be retrieved using the SCError function.
Schedules a connection with the run loop.
SCNetworkConnectionStart |
Boolean SCNetworkConnectionStart ( SCNetworkConnectionRef connection, CFDictionaryRef userOptions, Boolean linger );
connection
userOptions
linger
Returns TRUE if the connection was correctly started (the actual connection is not established yet, and the connection status needs to be periodically checked); FALSE if the connection request was not started. The error must be retrieved from the SCError function.
Starts the connection for the SCNetworkConnection.
The connection process is asynchronous and the function will
return immediately. The connection status can be obtained
by polling or by callback. The connection is made with the
default settings from the administrator. Some of the settings
can be overridden for the duration of the connection. These
are specified in an options dictionary. The options dictionary
uses the same format as a network service defined in the system
configuration preferences schema.
Note: Starting and stopping of connections is implicitly
arbitrated. Calling SCNetworkConnectionStart on a connection
already started will indicate that the application has
interest in the connection and it shouldn't be stopped by
anyone else.
SCNetworkConnectionStop |
Boolean SCNetworkConnectionStop ( SCNetworkConnectionRef connection, Boolean forceDisconnect );
connection
Returns TRUE if the disconnection request succeeded; FALSE if the disconnection request failed. The error must be retrieved from the SCError function.
Stops the connection for the SCNetworkConnection.
The disconnection process is asynchronous and the function
will return immediately. The connection status can be
obtained by polling or by callback. This function performs
an arbitrated stop of the connection. If several applications
have marked their interest in the connection, by calling
SCNetworkConnectionStart, the call will succeed but the
actual connection will be maintained until the last interested
application calls SCNetworkConnectionStop.
In certain cases, you might want to stop the connection anyway.
In these cases, you set the forceDisconnect argument to TRUE.
SCNetworkConnectionUnscheduleFromRunLoop |
Boolean SCNetworkConnectionUnscheduleFromRunLoop ( SCNetworkConnectionRef connection, CFRunLoopRef runLoop, CFStringRef runLoopMode );
connection
runLoop
runLoopMode
Returns TRUE if the connection is unscheduled successfully; FALSE if the unscheduling failed. The error can be retrieved using the SCError function.
Unschedules a connection from the run loop.
SCNetworkConnectionCallBack |
typedef void ( *SCNetworkConnectionCallBack) ( SCNetworkConnectionRef connection, SCNetworkConnectionStatus status, void *info );
status
- The connection status.
connection
- The connection reference.
info
- Application-specific information.
Type of the callback function used when a status event is delivered.
SCNetworkConnectionContext |
typedef struct { CFIndex version; void *info; const void *(*retain)( const void *info); void (*release)( const void *info); CFStringRef (*copyDescription)( const void *info); } SCNetworkConnectionContext;
version
- The version number of the structure type being passed in as a parameter to the SCNetworkConnectionCreateWithServiceID function. This structure is version 0.
info
- A C pointer to a user-specified block of data.
retain
- The callback used to add a retain for the info field. If this parameter is not a pointer to a function of the correct prototype, the behavior is undefined. The value may be NULL.
release
- The calllback used to remove a retain previously added for the info field. If this parameter is not a pointer to a function of the correct prototype, the behavior is undefined. The value may be NULL.
copyDescription
- The callback used to provide a description of the info field.
Structure containing user-specified data and callbacks for a SCNetworkConnection.
SCNetworkConnectionRef |
typedef const struct __SCNetworkConnection * SCNetworkConnectionRef;
This is the handle to manage a connection-oriented service.
SCNetworkConnectionPPPStatus |
enum { kSCNetworkConnectionPPPDisconnected = 0, kSCNetworkConnectionPPPInitializing = 1, kSCNetworkConnectionPPPConnectingLink = 2, kSCNetworkConnectionPPPDialOnTraffic = 3, kSCNetworkConnectionPPPNegotiatingLink = 4, kSCNetworkConnectionPPPAuthenticating = 5, kSCNetworkConnectionPPPWaitingForCallBack = 6, kSCNetworkConnectionPPPNegotiatingNetwork = 7, kSCNetworkConnectionPPPConnected = 8, kSCNetworkConnectionPPPTerminating = 9, kSCNetworkConnectionPPPDisconnectingLink = 10, kSCNetworkConnectionPPPHoldingLinkOff = 11, kSCNetworkConnectionPPPSuspended = 12, kSCNetworkConnectionPPPWaitingForRedial = 13 };
kSCNetworkConnectionPPPDisconnected
- PPP is disconnected.
kSCNetworkConnectionPPPInitializing
- PPP is initializing.
kSCNetworkConnectionPPPConnectingLink
- PPP is connecting the lower connection layer (for example, the modem is dialing out).
kSCNetworkConnectionPPPDialOnTraffic
- PPP is waiting for networking traffic to automatically establish the connection.
kSCNetworkConnectionPPPNegotiatingLink
- The PPP lower layer is connected and PPP is negotiating the link layer (LCP protocol).
kSCNetworkConnectionPPPAuthenticating
- PPP is authenticating to the server (PAP, CHAP, MS-CHAP or EAP protocols).
kSCNetworkConnectionPPPWaitingForCallBack
- PPP is waiting for the server to call back.
kSCNetworkConnectionPPPNegotiatingNetwork
- PPP is now authenticated and negotiating the networking layer (IPCP or IPv6CP protocols)
kSCNetworkConnectionPPPConnected
- PPP is now fully connected for at least one networking layer. Additional networking protocol might still be negotiating.
kSCNetworkConnectionPPPTerminating
- PPP networking and link protocols are terminating.
kSCNetworkConnectionPPPDisconnectingLink
- PPP is disconnecting the lower level (for example, the modem is hanging up).
kSCNetworkConnectionPPPHoldingLinkOff
- PPP is disconnected and maintaining the link temporarily off.
kSCNetworkConnectionPPPSuspended
- PPP is suspended as a result of the suspend command (for example, when a V.92 Modem is On Hold).
kSCNetworkConnectionPPPWaitingForRedial
- PPP has found a busy server and is waiting for redial.
PPP-specific status of the network connection. This status is returned as part of the extended information for a PPP service. Note: additional status might be returned in the future. Your application should be prepared to receive an unknown value.
SCNetworkConnectionStatus |
enum { kSCNetworkConnectionInvalid = -1, kSCNetworkConnectionDisconnected = 0, kSCNetworkConnectionConnecting = 1, kSCNetworkConnectionConnected = 2, kSCNetworkConnectionDisconnecting = 3 };
kSCNetworkConnectionInvalid
- The network connection refers to an invalid service.
kSCNetworkConnectionDisconnected
- The network connection is disconnected.
kSCNetworkConnectionConnecting
- The network connection is connecting.
kSCNetworkConnectionConnected
- The network connection is connected.
kSCNetworkConnectionDisconnecting
- The network connection is disconnecting.
Status of the network connection. This status is intended to be generic and high level. An extended status, specific to the type of network connection is also available for applications that need additonal information.
|