]> git.saurik.com Git - apple/configd.git/blob - SystemConfiguration.fproj/SCNetworkConfigurationPrivate.h
63ba8804602c3e97b63706b55ff37410a8ed83d3
[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 _SCNetworkInterfaceCopyInterfaceInfo
172 @discussion Returns interface details
173 @param interface The network interface.
174 @result A dictionary with details about the network interface.
175 */
176 CFDictionaryRef
177 _SCNetworkInterfaceCopyInterfaceInfo (SCNetworkInterfaceRef interface) __OSX_AVAILABLE_STARTING(__MAC_10_6,__IPHONE_3_0);
178
179 /*!
180 @function _SCNetworkInterfaceGetConfigurationAction
181 @discussion Returns a user-notification / auto-configuration action for the interface.
182 @param interface The network interface.
183 @result The user-notification / auto-configuration action;
184 NULL if the default action should be used.
185 */
186 CFStringRef
187 _SCNetworkInterfaceGetConfigurationAction (SCNetworkInterfaceRef interface) __OSX_AVAILABLE_STARTING(__MAC_10_6,__IPHONE_2_0);
188
189 /*!
190 @function _SCNetworkInterfaceGetHardwareAddress
191 @discussion Returns a link layer address for the interface.
192 @param interface The network interface.
193 @result The hardware (MAC) address for the interface.
194 NULL if no hardware address is available.
195 */
196 CFDataRef
197 _SCNetworkInterfaceGetHardwareAddress (SCNetworkInterfaceRef interface) __OSX_AVAILABLE_STARTING(__MAC_10_5,__IPHONE_2_0);
198
199 /*!
200 @function _SCNetworkInterfaceGetIOInterfaceType
201 @discussion Returns the IOInterfaceType for the interface.
202 @param interface The network interface.
203 @result The IOInterfaceType associated with the interface
204 */
205 CFNumberRef
206 _SCNetworkInterfaceGetIOInterfaceType (SCNetworkInterfaceRef interface) __OSX_AVAILABLE_STARTING(__MAC_10_5,__IPHONE_2_0);
207
208 /*!
209 @function _SCNetworkInterfaceGetIOInterfaceUnit
210 @discussion Returns the IOInterfaceUnit for the interface.
211 @param interface The network interface.
212 @result The IOInterfaceUnit associated with the interface;
213 NULL if no IOLocation is available.
214 */
215 CFNumberRef
216 _SCNetworkInterfaceGetIOInterfaceUnit (SCNetworkInterfaceRef interface) __OSX_AVAILABLE_STARTING(__MAC_10_5,__IPHONE_2_0);
217
218 /*!
219 @function _SCNetworkInterfaceGetIOPath
220 @discussion Returns the IOPath for the interface.
221 @param interface The network interface.
222 @result The IOPath associated with the interface;
223 NULL if no IOPath is available.
224 */
225 CFStringRef
226 _SCNetworkInterfaceGetIOPath (SCNetworkInterfaceRef interface) __OSX_AVAILABLE_STARTING(__MAC_10_5,__IPHONE_2_0);
227
228 /*!
229 @function _SCNetworkInterfaceIsBluetoothPAN
230 @discussion Identifies if a network interface is a Bluetooth PAN device.
231 @param interface The network interface.
232 @result TRUE if the interface is a Bluetooth PAN device.
233 */
234 Boolean
235 _SCNetworkInterfaceIsBluetoothPAN (SCNetworkInterfaceRef interface) __OSX_AVAILABLE_STARTING(__MAC_10_6,__IPHONE_3_0);
236
237 /*!
238 @function _SCNetworkInterfaceIsBuiltin
239 @discussion Identifies if a network interface is "built-in".
240 @param interface The network interface.
241 @result TRUE if the interface is "built-in".
242 */
243 Boolean
244 _SCNetworkInterfaceIsBuiltin (SCNetworkInterfaceRef interface) __OSX_AVAILABLE_STARTING(__MAC_10_5,__IPHONE_2_0);
245
246 /*!
247 @function _SCNetworkInterfaceIsTethered
248 @discussion Identifies if a network interface is an Apple tethered device (e.g. an iPhone).
249 @param interface The network interface.
250 @result TRUE if the interface is a tethered device.
251 */
252 Boolean
253 _SCNetworkInterfaceIsTethered (SCNetworkInterfaceRef interface) __OSX_AVAILABLE_STARTING(__MAC_10_6,__IPHONE_3_0);
254
255 /*!
256 @function _SCNetworkInterfaceIsModemV92
257 @discussion Identifies if a modem network interface supports
258 v.92 (hold).
259 @param interface The network interface.
260 @result TRUE if the interface is "v.92" modem.
261 */
262 Boolean
263 _SCNetworkInterfaceIsModemV92 (SCNetworkInterfaceRef interface) __OSX_AVAILABLE_STARTING(__MAC_10_5,__IPHONE_2_0);
264
265 /*!
266 @function _SCNetworkInterfaceForceConfigurationRefresh
267 @discussion Forces a configuration refresh of the
268 specified interface.
269 @param ifName Network interface name.
270 @result TRUE if the refresh was successfully posted.
271 */
272 Boolean
273 _SCNetworkInterfaceForceConfigurationRefresh (CFStringRef ifName) __OSX_AVAILABLE_STARTING(__MAC_10_5,__IPHONE_2_0);
274
275 /*!
276 @function _SCBondInterfaceCopyActive
277 @discussion Returns all Ethernet Bond interfaces on the system.
278 @result The list of SCBondInterface interfaces on the system.
279 You must release the returned value.
280 */
281 CFArrayRef
282 _SCBondInterfaceCopyActive (void) __OSX_AVAILABLE_STARTING(__MAC_10_5,__IPHONE_NA);
283
284 /*!
285 @function _SCBondInterfaceUpdateConfiguration
286 @discussion Updates the bond interface configuration.
287 @param prefs The "preferences" session.
288 @result TRUE if the bond interface configuration was updated.; FALSE if the
289 an error was encountered.
290 */
291 Boolean
292 _SCBondInterfaceUpdateConfiguration (SCPreferencesRef prefs) __OSX_AVAILABLE_STARTING(__MAC_10_5,__IPHONE_NA);
293
294 /*!
295 @function SCBondInterfaceSetMode
296 @discussion Set the mode on the bond interface.
297 @param bond The bond interface on which to adjust the mode.
298 @param mode The mode value (0=IF_BOND_MODE_LACP,1=IF_BOND_MODE_STATIC)
299 @result TRUE if operation succeeded.
300 */
301 Boolean
302 SCBondInterfaceSetMode (SCBondInterfaceRef bond,
303 CFNumberRef mode) __OSX_AVAILABLE_STARTING(__MAC_10_5,__IPHONE_NA);
304
305 /*!
306 @function SCBondInterfaceSetMode
307 @discussion Return the mode for the given bond interface.
308 @param bond The bond interface to get the mode from.
309 @result A CFNumberRef containing the mode (IF_BOND_MODE_{LACP,STATIC}).
310 */
311 CFNumberRef
312 SCBondInterfaceGetMode (SCBondInterfaceRef bond) __OSX_AVAILABLE_STARTING(__MAC_10_5,__IPHONE_NA);
313
314 /*!
315 @function _SCVLANInterfaceCopyActive
316 @discussion Returns all VLAN interfaces on the system.
317 @result The list of SCVLANInterface interfaces on the system.
318 You must release the returned value.
319 */
320 CFArrayRef
321 _SCVLANInterfaceCopyActive (void) __OSX_AVAILABLE_STARTING(__MAC_10_5,__IPHONE_NA);
322
323 /*!
324 @function _SCVLANInterfaceUpdateConfiguration
325 @discussion Updates the VLAN interface configuration.
326 @param prefs The "preferences" session.
327 @result TRUE if the VLAN interface configuration was updated.; FALSE if the
328 an error was encountered.
329 */
330 Boolean
331 _SCVLANInterfaceUpdateConfiguration (SCPreferencesRef prefs) __OSX_AVAILABLE_STARTING(__MAC_10_5,__IPHONE_NA);
332
333
334 #pragma mark -
335 #pragma mark SCNetworkInterface Password SPIs
336
337
338 enum {
339 kSCNetworkInterfacePasswordTypePPP = 1,
340 kSCNetworkInterfacePasswordTypeIPSecSharedSecret,
341 kSCNetworkInterfacePasswordTypeEAPOL,
342 kSCNetworkInterfacePasswordTypeIPSecXAuth,
343 };
344 typedef uint32_t SCNetworkInterfacePasswordType;
345
346 Boolean
347 SCNetworkInterfaceCheckPassword (SCNetworkInterfaceRef interface,
348 SCNetworkInterfacePasswordType passwordType) __OSX_AVAILABLE_STARTING(__MAC_10_5,__IPHONE_2_0);
349
350 CFDataRef
351 SCNetworkInterfaceCopyPassword (SCNetworkInterfaceRef interface,
352 SCNetworkInterfacePasswordType passwordType) __OSX_AVAILABLE_STARTING(__MAC_10_5,__IPHONE_2_0);
353
354 Boolean
355 SCNetworkInterfaceRemovePassword (SCNetworkInterfaceRef interface,
356 SCNetworkInterfacePasswordType passwordType) __OSX_AVAILABLE_STARTING(__MAC_10_5,__IPHONE_2_0);
357
358 Boolean
359 SCNetworkInterfaceSetPassword (SCNetworkInterfaceRef interface,
360 SCNetworkInterfacePasswordType passwordType,
361 CFDataRef password,
362 CFDictionaryRef options) __OSX_AVAILABLE_STARTING(__MAC_10_5,__IPHONE_2_0);
363
364
365 #pragma mark -
366 #pragma mark SCNetworkProtocol configuration (SPI)
367
368
369 /*!
370 @group Protocol configuration
371 */
372
373
374 static __inline__ CFTypeRef
375 isA_SCNetworkProtocol(CFTypeRef obj)
376 {
377 return (isA_CFType(obj, SCNetworkProtocolGetTypeID()));
378 }
379
380
381 #pragma mark -
382 #pragma mark SCNetworkService configuration (SPI)
383
384
385 /*!
386 @group Service configuration
387 */
388
389
390 static __inline__ CFTypeRef
391 isA_SCNetworkService(CFTypeRef obj)
392 {
393 return (isA_CFType(obj, SCNetworkServiceGetTypeID()));
394 }
395
396 enum {
397 kSCNetworkServicePrimaryRankDefault = 0,
398 kSCNetworkServicePrimaryRankFirst = 1,
399 kSCNetworkServicePrimaryRankLast = 2,
400 kSCNetworkServicePrimaryRankNever = 3
401 };
402 typedef uint32_t SCNetworkServicePrimaryRank;
403
404 /*!
405 @function _SCNetworkServiceCopyActive
406 @discussion Returns the network service with the specified identifier.
407
408 Note: The service returned by this SPI differs from the SCNetworkServiceCopy
409 API in that queries and operations interact with the "active" service
410 represented in the SCDynamicStore. Only a limited subset of the
411 SCNetworkService APIs are supported.
412 @param prefs The dynamic store session.
413 @param serviceID The unique identifier for the service.
414 @result A reference to the SCNetworkService represented in the SCDynamicStore;
415 NULL if the serviceID does not exist in the SCDynamicStore or if an
416 error was encountered.
417 You must release the returned value.
418 */
419 SCNetworkServiceRef
420 _SCNetworkServiceCopyActive (SCDynamicStoreRef store,
421 CFStringRef serviceID) __OSX_AVAILABLE_STARTING(__MAC_10_6,__IPHONE_2_1);
422
423 /*!
424 @function SCNetworkServiceGetPrimaryRank
425 @discussion Returns the primary service rank associated with a service.
426 @param service The network service.
427 @result The primary service rank associated with the specified application;
428 kSCNetworkServicePrimaryRankDefault if no rank is associated with the
429 application or an error was encountered.
430 */
431 SCNetworkServicePrimaryRank
432 SCNetworkServiceGetPrimaryRank (SCNetworkServiceRef service) __OSX_AVAILABLE_STARTING(__MAC_10_6,__IPHONE_2_0);
433
434 /*!
435 @function SCNetworkServiceSetPrimaryRank
436 @discussion Updates the the primary service rank associated with a service.
437 @param service The network service.
438 @param newRank The new primary service rank; kSCNetworkServicePrimaryRankDefault
439 if the default service rank should be used.
440 @result TRUE if the rank was stored; FALSE if an error was encountered.
441
442 Notes : The kSCNetworkServicePrimaryRankFirst and kSCNetworkServicePrimaryRankLast
443 values can only valid as a transient setting.
444 */
445 Boolean
446 SCNetworkServiceSetPrimaryRank (SCNetworkServiceRef service,
447 SCNetworkServicePrimaryRank newRank) __OSX_AVAILABLE_STARTING(__MAC_10_6,__IPHONE_2_0);
448
449
450 #pragma mark -
451 #pragma mark SCNetworkSet configuration (SPI)
452
453
454 /*!
455 @group Set configuration
456 */
457
458
459 static __inline__ CFTypeRef
460 isA_SCNetworkSet(CFTypeRef obj)
461 {
462 return (isA_CFType(obj, SCNetworkSetGetTypeID()));
463 }
464
465
466 /*!
467 @function SCNetworkSetEstablishDefaultConfiguration
468 @discussion Updates a network set by adding services for
469 any network interface that is not currently
470 represented.
471 If the provided set contains one (or more) services, new
472 services will only be added for those interfaces that are
473 not represented in *any* set.
474 Otherwise, new services will be added for those interfaces
475 that are not represented in the provided set.
476 The new services are established with "default" configuration
477 options.
478 @param set The network set.
479 @result TRUE if the configuration was updated; FALSE if no
480 changes were required or if an error was encountered.
481 */
482 Boolean
483 SCNetworkSetEstablishDefaultConfiguration (SCNetworkSetRef set) __OSX_AVAILABLE_STARTING(__MAC_10_5,__IPHONE_2_0);
484
485 /*!
486 @function SCNetworkSetEstablishDefaultInterfaceConfiguration
487 @discussion Updates a network set by adding services for
488 the specified network interface if is not currently
489 represented.
490 If the provided set contains one (or more) services, new
491 services will only be added for interfaces that are not
492 represented in *any* set.
493 Otherwise, new services will be added for interfaces that
494 are not represented in the provided set.
495 The new services are established with "default" configuration
496 options.
497 @param set The network set.
498 @param interface The network interface.
499 @result TRUE if the configuration was updated; FALSE if no
500 changes were required or if an error was encountered.
501 */
502 Boolean
503 SCNetworkSetEstablishDefaultInterfaceConfiguration (SCNetworkSetRef set,
504 SCNetworkInterfaceRef interface) __OSX_AVAILABLE_STARTING(__MAC_10_5,__IPHONE_2_0);
505
506 __END_DECLS
507
508 #endif /* _SCNETWORKCONFIGURATIONPRIVATE_H */