2 * Copyright (c) 2000, 2001, 2003-2006 Apple Computer, Inc. All rights reserved.
4 * @APPLE_LICENSE_HEADER_START@
6 * This file contains Original Code and/or Modifications of Original Code
7 * as defined in and that are subject to the Apple Public Source License
8 * Version 2.0 (the 'License'). You may not use this file except in
9 * compliance with the License. Please obtain a copy of the License at
10 * http://www.opensource.apple.com/apsl/ and read it before using this
13 * The Original Code and all software distributed under the License are
14 * distributed on an 'AS IS' basis, WITHOUT WARRANTY OF ANY KIND, EITHER
15 * EXPRESS OR IMPLIED, AND APPLE HEREBY DISCLAIMS ALL SUCH WARRANTIES,
16 * INCLUDING WITHOUT LIMITATION, ANY WARRANTIES OF MERCHANTABILITY,
17 * FITNESS FOR A PARTICULAR PURPOSE, QUIET ENJOYMENT OR NON-INFRINGEMENT.
18 * Please see the License for the specific language governing rights and
19 * limitations under the License.
21 * @APPLE_LICENSE_HEADER_END@
27 #include <sys/cdefs.h>
28 #include <sys/types.h>
29 #include <sys/socket.h>
30 #include <CoreFoundation/CoreFoundation.h>
35 @discussion The SCNetwork API contains functions an application can
36 use to determine remote host reachability and notify the
37 system of configuration changes.
39 The two SCNetworkCheckReachability functions allow an
40 application to determine the status of the system's current
41 network configuration and the reachability of a target host
44 "Reachability" reflects whether a data packet, sent by an
45 application into the network stack, can leave the local
46 computer. Note that reachability does <i>not</i> guarantee
47 that the data packet will actually be received by the host.
51 @enum SCNetworkConnectionFlags
52 @discussion Flags that indicate whether the specified network
53 nodename or address is reachable, whether a connection is
54 required, and whether some user intervention may be required
55 when establishing a connection.
56 @constant kSCNetworkFlagsTransientConnection
57 This flag indicates that the specified nodename or address can
58 be reached via a transient connection, such as PPP.
59 @constant kSCNetworkFlagsReachable
60 This flag indicates that the specified nodename or address can
61 be reached using the current network configuration.
62 @constant kSCNetworkFlagsConnectionRequired
63 This flag indicates that the specified nodename or address can
64 be reached using the current network configuration, but a
65 connection must first be established.
67 As an example, this status would be returned for a dialup
68 connection that was not currently active, but could handle
69 network traffic for the target system.
70 @constant kSCNetworkFlagsConnectionAutomatic
71 This flag indicates that the specified nodename or address can
72 be reached using the current network configuration, but a
73 connection must first be established. Any traffic directed
74 to the specified name or address will initiate the connection.
75 @constant kSCNetworkFlagsInterventionRequired
76 This flag indicates that the specified nodename or address can
77 be reached using the current network configuration, but a
78 connection must first be established. In addition, some
79 form of user intervention will be required to establish this
80 connection, such as providing a password, an authentication
83 Note: At the present time, this flag will only be returned
84 in the case where you have a dial-on-traffic configuration
85 (ConnectionAutomatic), where an attempt to connect has
86 already been made, and where some error (e.g. no dial tone,
87 no answer, bad password, ...) was encountered during the
88 automatic connection attempt. In this case the PPP controller
89 will stop attempting to establish a connection until the user
91 @constant kSCNetworkFlagsIsLocalAddress
92 This flag indicates that the specified nodename or address
93 is one associated with a network interface on the current
95 @constant kSCNetworkFlagsIsDirect
96 This flag indicates that network traffic to the specified
97 nodename or address will not go through a gateway, but is
98 routed directly to one of the interfaces in the system.
101 kSCNetworkFlagsTransientConnection
= 1<<0,
102 kSCNetworkFlagsReachable
= 1<<1,
103 kSCNetworkFlagsConnectionRequired
= 1<<2,
104 kSCNetworkFlagsConnectionAutomatic
= 1<<3,
105 kSCNetworkFlagsInterventionRequired
= 1<<4,
106 kSCNetworkFlagsIsLocalAddress
= 1<<16,
107 kSCNetworkFlagsIsDirect
= 1<<17
109 typedef uint32_t SCNetworkConnectionFlags
;
114 @function SCNetworkCheckReachabilityByAddress
115 @discussion Determines if the given network address is
116 reachable using the current network configuration.
117 @param address The network address of the desired host.
118 @param addrlen The length, in bytes, of the address.
119 @param flags A pointer to memory that will be filled with a
120 set of SCNetworkConnectionFlags detailing the reachability
121 of the specified address.
122 @result Returns TRUE if the network connection flags are valid;
123 FALSE if the status could not be determined.
126 SCNetworkCheckReachabilityByAddress (
127 const struct sockaddr
*address
,
129 SCNetworkConnectionFlags
*flags
133 @function SCNetworkCheckReachabilityByName
134 @discussion Determines if the given network host or node name is
135 reachable using the current network configuration.
136 @param nodename The node name of the desired host. This name would
137 be the same as that passed to the gethostbyname(3) or
138 getaddrinfo(3) functions.
139 @param flags A pointer to memory that will be filled with a
140 set of SCNetworkConnectionFlags detailing the reachability
141 of the specified node name.
142 @result Returns TRUE if the network connection flags are valid;
143 FALSE if the status could not be determined.
146 SCNetworkCheckReachabilityByName (
147 const char *nodename
,
148 SCNetworkConnectionFlags
*flags
152 @function SCNetworkInterfaceRefreshConfiguration
153 @discussion Sends a notification to interested configuration agents
154 to have them immediately retry their configuration over a
155 particular network interface.
157 Note: This function must be invoked by root (uid == 0).
158 @param ifName The BSD name of the network interface, such as
160 @result Returns TRUE if the notification was sent; FALSE otherwise.
161 @deprecated in version 10.4. Replaced with SCNetworkInterfaceForceConfigurationRefresh.
164 SCNetworkInterfaceRefreshConfiguration (
166 ) DEPRECATED_IN_MAC_OS_X_VERSION_10_5_AND_LATER
;
170 #endif /* _SCNETWORK_H */