]> git.saurik.com Git - apple/configd.git/blob - SystemConfiguration.fproj/SCNetwork.h
configd-1061.40.2.tar.gz
[apple/configd.git] / SystemConfiguration.fproj / SCNetwork.h
1 /*
2 * Copyright (c) 2000, 2001, 2003-2009, 2015, 2018 Apple Inc. All rights reserved.
3 *
4 * @APPLE_LICENSE_HEADER_START@
5 *
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
11 * file.
12 *
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.
20 *
21 * @APPLE_LICENSE_HEADER_END@
22 */
23
24 #ifndef _SCNETWORK_H
25 #define _SCNETWORK_H
26
27 #include <os/availability.h>
28 #include <sys/cdefs.h>
29 #include <sys/types.h>
30 #include <sys/socket.h>
31 #include <CoreFoundation/CoreFoundation.h>
32
33 CF_IMPLICIT_BRIDGING_ENABLED
34 CF_ASSUME_NONNULL_BEGIN
35
36 /*!
37 @header SCNetwork
38 @discussion The SCNetwork API contains functions an application can
39 use to determine remote host reachability and notify the
40 system of configuration changes.
41
42 The two SCNetworkCheckReachability functions allow an
43 application to determine the status of the system's current
44 network configuration and the reachability of a target host
45 or address.
46
47 "Reachability" reflects whether a data packet, sent by an
48 application into the network stack, can leave the local
49 computer. Note that reachability does <i>not</i> guarantee
50 that the data packet will actually be received by the host.
51 */
52
53 /*!
54 @enum SCNetworkConnectionFlags
55 @discussion Flags that indicate whether the specified network
56 nodename or address is reachable, whether a connection is
57 required, and whether some user intervention may be required
58 when establishing a connection.
59
60 Note: the SCNetworkConnection flags have been deprecated
61 in favor of the newer SCNetworkReachability flags defined
62 in SCNetworkReachability.h.
63 @constant kSCNetworkFlagsTransientConnection
64 This flag indicates that the specified nodename or address can
65 be reached via a transient connection, such as PPP.
66 @constant kSCNetworkFlagsReachable
67 This flag indicates that the specified nodename or address can
68 be reached using the current network configuration.
69 @constant kSCNetworkFlagsConnectionRequired
70 This flag indicates that the specified nodename or address can
71 be reached using the current network configuration, but a
72 connection must first be established.
73
74 As an example, this status would be returned for a dialup
75 connection that was not currently active, but could handle
76 network traffic for the target system.
77 @constant kSCNetworkFlagsConnectionAutomatic
78 This flag indicates that the specified nodename or address can
79 be reached using the current network configuration, but a
80 connection must first be established. Any traffic directed
81 to the specified name or address will initiate the connection.
82 @constant kSCNetworkFlagsInterventionRequired
83 This flag indicates that the specified nodename or address can
84 be reached using the current network configuration, but a
85 connection must first be established. In addition, some
86 form of user intervention will be required to establish this
87 connection, such as providing a password, an authentication
88 token, etc.
89
90 Note: At the present time, this flag will only be returned
91 in the case where you have a dial-on-traffic configuration
92 (ConnectionAutomatic), where an attempt to connect has
93 already been made, and where some error (e.g. no dial tone,
94 no answer, bad password, ...) was encountered during the
95 automatic connection attempt. In this case the PPP controller
96 will stop attempting to establish a connection until the user
97 has intervened.
98 @constant kSCNetworkFlagsIsLocalAddress
99 This flag indicates that the specified nodename or address
100 is one associated with a network interface on the current
101 system.
102 @constant kSCNetworkFlagsIsDirect
103 This flag indicates that network traffic to the specified
104 nodename or address will not go through a gateway, but is
105 routed directly to one of the interfaces in the system.
106 */
107 enum {
108 kSCNetworkFlagsTransientConnection = 1<<0,
109 kSCNetworkFlagsReachable = 1<<1,
110 kSCNetworkFlagsConnectionRequired = 1<<2,
111 kSCNetworkFlagsConnectionAutomatic = 1<<3,
112 kSCNetworkFlagsInterventionRequired = 1<<4,
113 kSCNetworkFlagsIsLocalAddress = 1<<16,
114 kSCNetworkFlagsIsDirect = 1<<17,
115 };
116 typedef uint32_t SCNetworkConnectionFlags;
117
118 __BEGIN_DECLS
119
120 /*!
121 @function SCNetworkCheckReachabilityByAddress
122 @discussion Determines if the given network address is
123 reachable using the current network configuration.
124
125 Note: this API has been deprecated but you can
126 get equivalent results with :
127 <pre>
128 SCNetworkReachabilityRef target;
129 SCNetworkReachabilityFlags flags = 0;
130 Boolean ok;
131
132 target = SCNetworkReachabilityCreateWithAddress(NULL, address);
133 ok = SCNetworkReachabilityGetFlags(target, &flags);
134 CFRelease(target);
135 </pre>
136 @param address The network address of the desired host.
137 @param addrlen The length, in bytes, of the address.
138 @param flags A pointer to memory that will be filled with a
139 set of SCNetworkConnectionFlags detailing the reachability
140 of the specified address.
141 @result Returns TRUE if the network connection flags are valid;
142 FALSE if the status could not be determined.
143 */
144 Boolean
145 SCNetworkCheckReachabilityByAddress (
146 const struct sockaddr *address,
147 socklen_t addrlen,
148 SCNetworkConnectionFlags *flags
149 ) API_DEPRECATED("No longer supported", macos(10.1,10.6)) API_UNAVAILABLE(ios, tvos, watchos, bridgeos);
150
151 /*!
152 @function SCNetworkCheckReachabilityByName
153 @discussion Determines if the given network host or node name is
154 reachable using the current network configuration.
155
156 Note: this API has been deprecated but you can
157 get equivalent results with :
158 <pre>
159 SCNetworkReachabilityRef target;
160 SCNetworkReachabilityFlags flags = 0;
161 Boolean ok;
162
163 target = SCNetworkReachabilityCreateWithName(NULL, name);
164 ok = SCNetworkReachabilityGetFlags(target, &flags);
165 CFRelease(target);
166 </pre>
167 @param nodename The node name of the desired host. This name would
168 be the same as that passed to the gethostbyname(3) or
169 getaddrinfo(3) functions.
170 @param flags A pointer to memory that will be filled with a
171 set of SCNetworkConnectionFlags detailing the reachability
172 of the specified node name.
173 @result Returns TRUE if the network connection flags are valid;
174 FALSE if the status could not be determined.
175 */
176 Boolean
177 SCNetworkCheckReachabilityByName (
178 const char *nodename,
179 SCNetworkConnectionFlags *flags
180 ) API_DEPRECATED("No longer supported", macos(10.1,10.6)) API_UNAVAILABLE(ios, tvos, watchos, bridgeos);
181
182 /*!
183 @function SCNetworkInterfaceRefreshConfiguration
184 @discussion Sends a notification to interested configuration agents
185 to have them immediately retry their configuration over a
186 particular network interface.
187
188 Note: This function must be invoked by root (uid == 0).
189 @param ifName The BSD name of the network interface, such as
190 CFSTR("en0").
191 @result Returns TRUE if the notification was sent; FALSE otherwise.
192 @deprecated in version 10.4. Replaced with SCNetworkInterfaceForceConfigurationRefresh.
193 */
194 Boolean
195 SCNetworkInterfaceRefreshConfiguration (
196 CFStringRef ifName
197 ) API_DEPRECATED("No longer supported", macos(10.1,10.5)) API_UNAVAILABLE(ios, tvos, watchos, bridgeos);
198
199 __END_DECLS
200
201 CF_ASSUME_NONNULL_END
202 CF_IMPLICIT_BRIDGING_DISABLED
203
204 #endif /* _SCNETWORK_H */