]> git.saurik.com Git - apple/configd.git/blob - SystemConfiguration.fproj/SCNetworkConfigurationPrivate.h
ec41e4cd11715ae64dd2865688f0f1868eedb96f
[apple/configd.git] / SystemConfiguration.fproj / SCNetworkConfigurationPrivate.h
1 /*
2 * Copyright (c) 2005-2009 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 _SCNETWORKCONFIGURATIONPRIVATE_H
25 #define _SCNETWORKCONFIGURATIONPRIVATE_H
26
27 #include <Availability.h>
28 #include <TargetConditionals.h>
29 #include <sys/cdefs.h>
30 #include <CoreFoundation/CoreFoundation.h>
31 #include <SystemConfiguration/SystemConfiguration.h>
32 #include <SystemConfiguration/SCValidation.h>
33 #include <IOKit/IOKitLib.h>
34
35 /*!
36 @header SCNetworkConfigurationPrivate
37 */
38
39 __BEGIN_DECLS
40
41
42 #pragma mark -
43 #pragma mark SCNetworkInterface configuration (SPI)
44
45
46 /*!
47 @group Interface configuration
48 */
49
50 static __inline__ CFTypeRef
51 isA_SCNetworkInterface(CFTypeRef obj)
52 {
53 return (isA_CFType(obj, SCNetworkInterfaceGetTypeID()));
54 }
55
56 #if !TARGET_OS_IPHONE
57 static __inline__ CFTypeRef
58 isA_SCBondInterface(CFTypeRef obj)
59 {
60 CFStringRef interfaceType;
61
62 if (!isA_SCNetworkInterface(obj)) {
63 // if not an SCNetworkInterface
64 return NULL;
65 }
66
67 interfaceType = SCNetworkInterfaceGetInterfaceType((SCNetworkInterfaceRef)obj);
68 if (!CFEqual(interfaceType, kSCNetworkInterfaceTypeBond)) {
69 // if not a Bond
70 return NULL;
71 }
72
73 return obj;
74 }
75
76 static __inline__ CFTypeRef
77 isA_SCVLANInterface(CFTypeRef obj)
78 {
79 CFStringRef interfaceType;
80
81 if (!isA_SCNetworkInterface(obj)) {
82 // if not an SCNetworkInterface
83 return NULL;
84 }
85
86 interfaceType = SCNetworkInterfaceGetInterfaceType((SCNetworkInterfaceRef)obj);
87 if (!CFEqual(interfaceType, kSCNetworkInterfaceTypeVLAN)) {
88 // if not a VLAN
89 return NULL;
90 }
91
92 return obj;
93 }
94 #endif // !TARGET_OS_IPHONE
95
96 /*!
97 @function _SCNetworkInterfaceCompare
98 @discussion Compares two SCNetworkInterface objects.
99 @param val1 The SCNetworkInterface object.
100 @param val2 The SCNetworkInterface object.
101 @param context Not used.
102 @result A comparison result.
103 */
104 CFComparisonResult
105 _SCNetworkInterfaceCompare (const void *val1,
106 const void *val2,
107 void *context) __OSX_AVAILABLE_STARTING(__MAC_10_5,__IPHONE_2_0);
108
109 /*!
110 @function _SCNetworkInterfaceCopySlashDevPath
111 @discussion Returns the /dev pathname for the interface.
112 @param interface The network interface.
113 @result The /dev pathname associated with the interface (e.g. "/dev/modem");
114 NULL if no path is available.
115 */
116 CFStringRef
117 _SCNetworkInterfaceCopySlashDevPath (SCNetworkInterfaceRef interface) __OSX_AVAILABLE_STARTING(__MAC_10_6,__IPHONE_3_0);
118
119 #define kIncludeNoVirtualInterfaces 0x0
120 #define kIncludeVLANInterfaces 0x1
121 #define kIncludeBondInterfaces 0x2
122 #define kIncludeAllVirtualInterfaces 0xffffffff
123
124 /*!
125 @function _SCNetworkInterfaceCreateWithBSDName
126 @discussion Create a new network interface associated with the provided
127 BSD interface name. This API supports Ethhernet, FireWire, and
128 IEEE 802.11 interfaces.
129 @param bsdName The BSD interface name.
130 @param flags Indicates whether virtual (Bond, VLAN)
131 network interfaces should be included.
132 @result A reference to the new SCNetworkInterface.
133 You must release the returned value.
134 */
135 SCNetworkInterfaceRef
136 _SCNetworkInterfaceCreateWithBSDName (CFAllocatorRef allocator,
137 CFStringRef bsdName,
138 UInt32 flags) __OSX_AVAILABLE_STARTING(__MAC_10_5,__IPHONE_2_0);
139
140 /*!
141 @function _SCNetworkInterfaceCreateWithEntity
142 @discussion Create a new network interface associated with the provided
143 SCDynamicStore service entity dictionary.
144 @param interface_entity The entity dictionary.
145 @param service The network service.
146 @result A reference to the new SCNetworkInterface.
147 You must release the returned value.
148 */
149 SCNetworkInterfaceRef
150 _SCNetworkInterfaceCreateWithEntity (CFAllocatorRef allocator,
151 CFDictionaryRef interface_entity,
152 SCNetworkServiceRef service) __OSX_AVAILABLE_STARTING(__MAC_10_5,__IPHONE_2_0);
153
154 /*!
155 @function _SCNetworkInterfaceCreateWithIONetworkInterfaceObject
156 @discussion Create a new network interface associated with the provided
157 IORegistry "IONetworkInterface" object.
158 @param if_obj The IONetworkInterface object.
159 @result A reference to the new SCNetworkInterface.
160 You must release the returned value.
161 */
162 SCNetworkInterfaceRef
163 _SCNetworkInterfaceCreateWithIONetworkInterfaceObject (io_object_t if_obj) __OSX_AVAILABLE_STARTING(__MAC_10_5,__IPHONE_2_0);
164
165 #define kSCNetworkInterfaceConfigurationActionKey CFSTR("New Interface Detected Action")
166 #define kSCNetworkInterfaceConfigurationActionValueNone CFSTR("None")
167 #define kSCNetworkInterfaceConfigurationActionValuePrompt CFSTR("Prompt")
168 #define kSCNetworkInterfaceConfigurationActionValueConfigure CFSTR("Configure")
169
170 /*!
171 @function _SCNetworkInterfaceGetConfigurationAction
172 @discussion Returns a user-notification / auto-configuration action for the interface.
173 @param interface The network interface.
174 @result The user-notification / auto-configuration action;
175 NULL if the default action should be used.
176 */
177 CFStringRef
178 _SCNetworkInterfaceGetConfigurationAction (SCNetworkInterfaceRef interface) __OSX_AVAILABLE_STARTING(__MAC_10_6,__IPHONE_2_0);
179
180 /*!
181 @function _SCNetworkInterfaceGetHardwareAddress
182 @discussion Returns a link layer address for the interface.
183 @param interface The network interface.
184 @result The hardware (MAC) address for the interface.
185 NULL if no hardware address is available.
186 */
187 CFDataRef
188 _SCNetworkInterfaceGetHardwareAddress (SCNetworkInterfaceRef interface) __OSX_AVAILABLE_STARTING(__MAC_10_5,__IPHONE_2_0);
189
190 /*!
191 @function _SCNetworkInterfaceGetIOInterfaceType
192 @discussion Returns the IOInterfaceType for the interface.
193 @param interface The network interface.
194 @result The IOInterfaceType associated with the interface
195 */
196 CFNumberRef
197 _SCNetworkInterfaceGetIOInterfaceType (SCNetworkInterfaceRef interface) __OSX_AVAILABLE_STARTING(__MAC_10_5,__IPHONE_2_0);
198
199 /*!
200 @function _SCNetworkInterfaceGetIOInterfaceUnit
201 @discussion Returns the IOInterfaceUnit for the interface.
202 @param interface The network interface.
203 @result The IOInterfaceUnit associated with the interface;
204 NULL if no IOLocation is available.
205 */
206 CFNumberRef
207 _SCNetworkInterfaceGetIOInterfaceUnit (SCNetworkInterfaceRef interface) __OSX_AVAILABLE_STARTING(__MAC_10_5,__IPHONE_2_0);
208
209 /*!
210 @function _SCNetworkInterfaceGetIOPath
211 @discussion Returns the IOPath for the interface.
212 @param interface The network interface.
213 @result The IOPath associated with the interface;
214 NULL if no IOPath is available.
215 */
216 CFStringRef
217 _SCNetworkInterfaceGetIOPath (SCNetworkInterfaceRef interface) __OSX_AVAILABLE_STARTING(__MAC_10_5,__IPHONE_2_0);
218
219 /*!
220 @function _SCNetworkInterfaceIsBluetoothPAN
221 @discussion Identifies if a network interface is a Bluetooth PAN device.
222 @param interface The network interface.
223 @result TRUE if the interface is a Bluetooth PAN device.
224 */
225 Boolean
226 _SCNetworkInterfaceIsBluetoothPAN (SCNetworkInterfaceRef interface) __OSX_AVAILABLE_STARTING(__MAC_10_6,__IPHONE_3_0);
227
228 /*!
229 @function _SCNetworkInterfaceIsBuiltin
230 @discussion Identifies if a network interface is "built-in".
231 @param interface The network interface.
232 @result TRUE if the interface is "built-in".
233 */
234 Boolean
235 _SCNetworkInterfaceIsBuiltin (SCNetworkInterfaceRef interface) __OSX_AVAILABLE_STARTING(__MAC_10_5,__IPHONE_2_0);
236
237 /*!
238 @function _SCNetworkInterfaceIsTethered
239 @discussion Identifies if a network interface is an Apple tethered device (e.g. an iPhone).
240 @param interface The network interface.
241 @result TRUE if the interface is a tethered device.
242 */
243 Boolean
244 _SCNetworkInterfaceIsTethered (SCNetworkInterfaceRef interface) __OSX_AVAILABLE_STARTING(__MAC_10_6,__IPHONE_3_0);
245
246 /*!
247 @function _SCNetworkInterfaceIsModemV92
248 @discussion Identifies if a modem network interface supports
249 v.92 (hold).
250 @param interface The network interface.
251 @result TRUE if the interface is "v.92" modem.
252 */
253 Boolean
254 _SCNetworkInterfaceIsModemV92 (SCNetworkInterfaceRef interface) __OSX_AVAILABLE_STARTING(__MAC_10_5,__IPHONE_2_0);
255
256 /*!
257 @function _SCNetworkInterfaceForceConfigurationRefresh
258 @discussion Forces a configuration refresh of the
259 specified interface.
260 @param ifName Network interface name.
261 @result TRUE if the refresh was successfully posted.
262 */
263 Boolean
264 _SCNetworkInterfaceForceConfigurationRefresh (CFStringRef ifName) __OSX_AVAILABLE_STARTING(__MAC_10_5,__IPHONE_2_0);
265
266 /*!
267 @function _SCBondInterfaceCopyActive
268 @discussion Returns all Ethernet Bond interfaces on the system.
269 @result The list of SCBondInterface interfaces on the system.
270 You must release the returned value.
271 */
272 CFArrayRef
273 _SCBondInterfaceCopyActive (void) __OSX_AVAILABLE_STARTING(__MAC_10_5,__IPHONE_NA);
274
275 /*!
276 @function _SCBondInterfaceUpdateConfiguration
277 @discussion Updates the bond interface configuration.
278 @param prefs The "preferences" session.
279 @result TRUE if the bond interface configuration was updated.; FALSE if the
280 an error was encountered.
281 */
282 Boolean
283 _SCBondInterfaceUpdateConfiguration (SCPreferencesRef prefs) __OSX_AVAILABLE_STARTING(__MAC_10_5,__IPHONE_NA);
284
285 /*!
286 @function SCBondInterfaceSetMode
287 @discussion Set the mode on the bond interface.
288 @param bond The bond interface on which to adjust the mode.
289 @param mode The mode value (0=IF_BOND_MODE_LACP,1=IF_BOND_MODE_STATIC)
290 @result TRUE if operation succeeded.
291 */
292 Boolean
293 SCBondInterfaceSetMode (SCBondInterfaceRef bond,
294 CFNumberRef mode) __OSX_AVAILABLE_STARTING(__MAC_10_5,__IPHONE_NA);
295
296 /*!
297 @function SCBondInterfaceSetMode
298 @discussion Return the mode for the given bond interface.
299 @param bond The bond interface to get the mode from.
300 @result A CFNumberRef containing the mode (IF_BOND_MODE_{LACP,STATIC}).
301 */
302 CFNumberRef
303 SCBondInterfaceGetMode (SCBondInterfaceRef bond) __OSX_AVAILABLE_STARTING(__MAC_10_5,__IPHONE_NA);
304
305 /*!
306 @function _SCVLANInterfaceCopyActive
307 @discussion Returns all VLAN interfaces on the system.
308 @result The list of SCVLANInterface interfaces on the system.
309 You must release the returned value.
310 */
311 CFArrayRef
312 _SCVLANInterfaceCopyActive (void) __OSX_AVAILABLE_STARTING(__MAC_10_5,__IPHONE_NA);
313
314 /*!
315 @function _SCVLANInterfaceUpdateConfiguration
316 @discussion Updates the VLAN interface configuration.
317 @param prefs The "preferences" session.
318 @result TRUE if the VLAN interface configuration was updated.; FALSE if the
319 an error was encountered.
320 */
321 Boolean
322 _SCVLANInterfaceUpdateConfiguration (SCPreferencesRef prefs) __OSX_AVAILABLE_STARTING(__MAC_10_5,__IPHONE_NA);
323
324
325 #pragma mark -
326 #pragma mark SCNetworkInterface Password SPIs
327
328
329 enum {
330 kSCNetworkInterfacePasswordTypePPP = 1,
331 kSCNetworkInterfacePasswordTypeIPSecSharedSecret,
332 kSCNetworkInterfacePasswordTypeEAPOL,
333 kSCNetworkInterfacePasswordTypeIPSecXAuth,
334 };
335 typedef uint32_t SCNetworkInterfacePasswordType;
336
337 Boolean
338 SCNetworkInterfaceCheckPassword (SCNetworkInterfaceRef interface,
339 SCNetworkInterfacePasswordType passwordType) __OSX_AVAILABLE_STARTING(__MAC_10_5,__IPHONE_2_0);
340
341 CFDataRef
342 SCNetworkInterfaceCopyPassword (SCNetworkInterfaceRef interface,
343 SCNetworkInterfacePasswordType passwordType) __OSX_AVAILABLE_STARTING(__MAC_10_5,__IPHONE_2_0);
344
345 Boolean
346 SCNetworkInterfaceRemovePassword (SCNetworkInterfaceRef interface,
347 SCNetworkInterfacePasswordType passwordType) __OSX_AVAILABLE_STARTING(__MAC_10_5,__IPHONE_2_0);
348
349 Boolean
350 SCNetworkInterfaceSetPassword (SCNetworkInterfaceRef interface,
351 SCNetworkInterfacePasswordType passwordType,
352 CFDataRef password,
353 CFDictionaryRef options) __OSX_AVAILABLE_STARTING(__MAC_10_5,__IPHONE_2_0);
354
355
356 #pragma mark -
357 #pragma mark SCNetworkProtocol configuration (SPI)
358
359
360 /*!
361 @group Protocol configuration
362 */
363
364
365 static __inline__ CFTypeRef
366 isA_SCNetworkProtocol(CFTypeRef obj)
367 {
368 return (isA_CFType(obj, SCNetworkProtocolGetTypeID()));
369 }
370
371
372 #pragma mark -
373 #pragma mark SCNetworkService configuration (SPI)
374
375
376 /*!
377 @group Service configuration
378 */
379
380
381 static __inline__ CFTypeRef
382 isA_SCNetworkService(CFTypeRef obj)
383 {
384 return (isA_CFType(obj, SCNetworkServiceGetTypeID()));
385 }
386
387 enum {
388 kSCNetworkServicePrimaryRankDefault = 0,
389 kSCNetworkServicePrimaryRankFirst = 1,
390 kSCNetworkServicePrimaryRankLast = 2,
391 kSCNetworkServicePrimaryRankNever = 3
392 };
393 typedef uint32_t SCNetworkServicePrimaryRank;
394
395 /*!
396 @function _SCNetworkServiceCopyActive
397 @discussion Returns the network service with the specified identifier.
398
399 Note: The service returned by this SPI differs from the SCNetworkServiceCopy
400 API in that queries and operations interact with the "active" service
401 represented in the SCDynamicStore. Only a limited subset of the
402 SCNetworkService APIs are supported.
403 @param prefs The dynamic store session.
404 @param serviceID The unique identifier for the service.
405 @result A reference to the SCNetworkService represented in the SCDynamicStore;
406 NULL if the serviceID does not exist in the SCDynamicStore or if an
407 error was encountered.
408 You must release the returned value.
409 */
410 SCNetworkServiceRef
411 _SCNetworkServiceCopyActive (SCDynamicStoreRef store,
412 CFStringRef serviceID) __OSX_AVAILABLE_STARTING(__MAC_10_6,__IPHONE_2_1);
413
414 /*!
415 @function SCNetworkServiceGetPrimaryRank
416 @discussion Returns the primary service rank associated with a service.
417 @param service The network service.
418 @result The primary service rank associated with the specified application;
419 kSCNetworkServicePrimaryRankDefault if no rank is associated with the
420 application or an error was encountered.
421 */
422 SCNetworkServicePrimaryRank
423 SCNetworkServiceGetPrimaryRank (SCNetworkServiceRef service) __OSX_AVAILABLE_STARTING(__MAC_10_6,__IPHONE_2_0);
424
425 /*!
426 @function SCNetworkServiceSetPrimaryRank
427 @discussion Updates the the primary service rank associated with a service.
428 @param service The network service.
429 @param newRank The new primary service rank; kSCNetworkServicePrimaryRankDefault
430 if the default service rank should be used.
431 @result TRUE if the rank was stored; FALSE if an error was encountered.
432
433 Notes : The kSCNetworkServicePrimaryRankFirst and kSCNetworkServicePrimaryRankLast
434 values can only valid as a transient setting.
435 */
436 Boolean
437 SCNetworkServiceSetPrimaryRank (SCNetworkServiceRef service,
438 SCNetworkServicePrimaryRank newRank) __OSX_AVAILABLE_STARTING(__MAC_10_6,__IPHONE_2_0);
439
440
441 #pragma mark -
442 #pragma mark SCNetworkSet configuration (SPI)
443
444
445 /*!
446 @group Set configuration
447 */
448
449
450 static __inline__ CFTypeRef
451 isA_SCNetworkSet(CFTypeRef obj)
452 {
453 return (isA_CFType(obj, SCNetworkSetGetTypeID()));
454 }
455
456
457 /*!
458 @function SCNetworkSetEstablishDefaultConfiguration
459 @discussion Updates a network set by adding services for
460 any network interface that is not currently
461 represented.
462 If the provided set contains one (or more) services, new
463 services will only be added for those interfaces that are
464 not represented in *any* set.
465 Otherwise, new services will be added for those interfaces
466 that are not represented in the provided set.
467 The new services are established with "default" configuration
468 options.
469 @param set The network set.
470 @result TRUE if the configuration was updated; FALSE if no
471 changes were required or if an error was encountered.
472 */
473 Boolean
474 SCNetworkSetEstablishDefaultConfiguration (SCNetworkSetRef set) __OSX_AVAILABLE_STARTING(__MAC_10_5,__IPHONE_2_0);
475
476 /*!
477 @function SCNetworkSetEstablishDefaultInterfaceConfiguration
478 @discussion Updates a network set by adding services for
479 the specified network interface if is not currently
480 represented.
481 If the provided set contains one (or more) services, new
482 services will only be added for interfaces that are not
483 represented in *any* set.
484 Otherwise, new services will be added for interfaces that
485 are not represented in the provided set.
486 The new services are established with "default" configuration
487 options.
488 @param set The network set.
489 @param interface The network interface.
490 @result TRUE if the configuration was updated; FALSE if no
491 changes were required or if an error was encountered.
492 */
493 Boolean
494 SCNetworkSetEstablishDefaultInterfaceConfiguration (SCNetworkSetRef set,
495 SCNetworkInterfaceRef interface) __OSX_AVAILABLE_STARTING(__MAC_10_5,__IPHONE_2_0);
496
497 __END_DECLS
498
499 #endif /* _SCNETWORKCONFIGURATIONPRIVATE_H */