]> git.saurik.com Git - apple/configd.git/blob - SystemConfiguration.fproj/SCNetworkConfigurationInternal.h
configd-802.40.13.tar.gz
[apple/configd.git] / SystemConfiguration.fproj / SCNetworkConfigurationInternal.h
1 /*
2 * Copyright (c) 2004-2015 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 _SCNETWORKCONFIGURATIONINTERNAL_H
25 #define _SCNETWORKCONFIGURATIONINTERNAL_H
26
27
28 #include <TargetConditionals.h>
29 #include <CoreFoundation/CoreFoundation.h>
30 #include <CoreFoundation/CFRuntime.h>
31 #include <SystemConfiguration/SystemConfiguration.h>
32 #include <SystemConfiguration/SCPreferencesPathKey.h>
33 #include <SystemConfiguration/SCNetworkConfigurationPrivate.h>
34 #include <IOKit/IOKitLib.h>
35
36 #if !TARGET_IPHONE_SIMULATOR
37 #include "IPMonitorControl.h"
38 #endif // !TARGET_IPHONE_SIMULATOR
39
40
41 typedef struct {
42
43 // base CFType information
44 CFRuntimeBase cfBase;
45
46 // set id
47 CFStringRef setID;
48
49 // prefs
50 SCPreferencesRef prefs;
51
52 // name
53 CFStringRef name;
54
55 // misc
56 Boolean established;
57
58 } SCNetworkSetPrivate, *SCNetworkSetPrivateRef;
59
60
61 typedef struct {
62
63 // base CFType information
64 CFRuntimeBase cfBase;
65
66 // service id
67 CFStringRef serviceID;
68
69 // interface
70 SCNetworkInterfaceRef interface;
71
72 // prefs
73 SCPreferencesRef prefs;
74
75 // store (for live SCNetworkService)
76 SCDynamicStoreRef store;
77
78 // name
79 CFStringRef name;
80
81 // external identifiers
82 CFMutableDictionaryRef externalIDs;
83
84 } SCNetworkServicePrivate, *SCNetworkServicePrivateRef;
85
86
87 typedef struct {
88
89 // base CFType information
90 CFRuntimeBase cfBase;
91
92 // entity id
93 CFStringRef entityID;
94
95 // service
96 SCNetworkServiceRef service;
97
98 } SCNetworkProtocolPrivate, *SCNetworkProtocolPrivateRef;
99
100
101 typedef struct {
102
103 // base CFType information
104 CFRuntimeBase cfBase;
105
106 // interface information
107 CFStringRef interface_type; // interface type
108
109 Boolean active;
110
111 // [non-localized] name
112 CFStringRef name; // non-localized [display] name
113
114 // localized name
115 CFStringRef localized_name; // localized [display] name
116 CFStringRef localized_key;
117 CFStringRef localized_arg1;
118 CFStringRef localized_arg2;
119
120 // [layered] interface
121 SCNetworkInterfaceRef interface;
122
123 // prefs (for associated service, BOND interfaces, and VLAN interfaces)
124 SCPreferencesRef prefs;
125
126 // SCDynamicStore
127 SCDynamicStoreRef store;
128
129 // serviceID (NULL if not associated with a service)
130 CFStringRef serviceID;
131
132 // unsaved configuration (when prefs not [yet] available)
133 CFMutableDictionaryRef unsaved;
134
135 // [SCPreferences] interface entity information
136 CFStringRef entity_device; // interface device
137 CFStringRef entity_device_unique; // ... UniqueIdentifier
138 CFStringRef entity_type; // interface type
139 CFStringRef entity_subtype; // interface subtype
140
141 // configuration information
142 CFMutableArrayRef supported_interface_types;
143 CFMutableArrayRef supported_protocol_types;
144
145 // IORegistry (service plane) information
146 CFDataRef address;
147 CFStringRef addressString;
148 Boolean builtin;
149 CFStringRef configurationAction;
150 Boolean hidden;
151 CFStringRef location;
152 CFStringRef path;
153 uint64_t entryID;
154 CFMutableDictionaryRef overrides;
155 Boolean modemIsV92;
156 CFStringRef prefix;
157 CFNumberRef type;
158 CFNumberRef unit;
159 struct {
160 CFStringRef name;
161 CFNumberRef vid;
162 CFNumberRef pid;
163 } usb;
164
165 // misc
166 int sort_order; // sort order for this interface
167
168 // for BOND interfaces
169 Boolean supportsBond;
170 struct {
171 CFArrayRef interfaces;
172 CFNumberRef mode;
173 CFDictionaryRef options;
174 } bond;
175
176 // for Bridge interfaces
177 Boolean supportsBridge;
178 struct {
179 CFArrayRef interfaces;
180 CFDictionaryRef options;
181 } bridge;
182
183 // for VLAN interfaces
184 Boolean supportsVLAN;
185 struct {
186 SCNetworkInterfaceRef interface;
187 CFNumberRef tag; // e.g. 1 <= tag <= 4094
188 CFDictionaryRef options;
189 } vlan;
190
191 #if !TARGET_IPHONE_SIMULATOR
192 // for interface rank assertions
193 IPMonitorControlRef IPMonitorControl;
194 #endif // !TARGET_IPHONE_SIMULATOR
195 } SCNetworkInterfacePrivate, *SCNetworkInterfacePrivateRef;
196
197
198 __BEGIN_DECLS
199
200
201 #pragma mark -
202 #pragma mark SCNetworkInterface configuration (internal)
203
204 Boolean
205 __SCNetworkInterfaceMatchesName (CFStringRef name, CFStringRef key);
206
207 CFArrayRef
208 __SCNetworkInterfaceCopyAll_IONetworkInterface (void);
209
210 /*!
211 @function __SCNetworkInterfaceCopyStorageEntity
212 @discussion Create interface entity of network interface as seen in
213 NetworkInterfaces.plist
214 @param interface The network interface from which interface entity is create
215 @result Dictionary which contains information about interface entity
216 You must release the returned value.
217 */
218 CFDictionaryRef
219 __SCNetworkInterfaceCopyStorageEntity (SCNetworkInterfaceRef interface);
220
221 /*!
222 @function __SCNetworkInterfaceCopyStoredWithPreferences
223 @discussion Create an array of network interfaces, which is present in the preferences
224 in NetworkInteraces.plist
225 @param ni_prefs Preference for network interfaces
226 @result Array which contains SCNetworkInterfaceRef.
227 You must release the returned value.
228 */
229
230 CFArrayRef // SCNetworkInterfaceRef
231 __SCNetworkInterfaceCopyStoredWithPreferences (SCPreferencesRef ni_prefs);
232
233 SCNetworkInterfacePrivateRef
234 __SCNetworkInterfaceCreateCopy (CFAllocatorRef allocator,
235 SCNetworkInterfaceRef interface,
236 SCPreferencesRef prefs,
237 CFStringRef serviceID);
238
239 /*!
240 @function __SCNetworkInterfaceCreateMappingUsingBSDName
241 @discussion This function creates mapping of BSD name and network interface using
242 preferences which point to the NetworkInterfaces.plist file.
243 @param ni_prefs Preferences pointing to NetworkInterfaces.plist
244 @result BSD Mapping in a dictionary.
245 You must release the returned value.
246 */
247 CFDictionaryRef
248 __SCNetworkInterfaceCreateMappingUsingBSDName(CFArrayRef interfaces);
249
250 SCNetworkInterfaceRef
251 __SCNetworkInterfaceCreateWithNIPreferencesUsingBSDName(CFAllocatorRef allocator,
252 SCPreferencesRef ni_prefs,
253 CFStringRef bsdName);
254
255 SCNetworkInterfacePrivateRef
256 __SCNetworkInterfaceCreatePrivate (CFAllocatorRef allocator,
257 SCNetworkInterfaceRef interface,
258 SCPreferencesRef prefs,
259 CFStringRef serviceID);
260
261 SCNetworkInterfacePrivateRef
262 _SCBondInterfaceCreatePrivate (CFAllocatorRef allocator,
263 CFStringRef bond_if);
264
265 SCNetworkInterfacePrivateRef
266 _SCBridgeInterfaceCreatePrivate (CFAllocatorRef allocator,
267 CFStringRef bridge_if);
268
269 SCNetworkInterfacePrivateRef
270 _SCVLANInterfaceCreatePrivate (CFAllocatorRef allocator,
271 CFStringRef vlan_if);
272
273 CFDictionaryRef
274 __SCNetworkInterfaceCopyInterfaceEntity (SCNetworkInterfaceRef interface);
275
276 CFArrayRef
277 __SCNetworkInterfaceCopyDeepConfiguration (SCNetworkSetRef set,
278 SCNetworkInterfaceRef interface);
279
280 #if !TARGET_OS_IPHONE
281 CFStringRef
282 __SCNetworkInterfaceCopyXLocalizedDisplayName (SCNetworkInterfaceRef interface);
283
284 CFStringRef
285 __SCNetworkInterfaceCopyXNonLocalizedDisplayName(SCNetworkInterfaceRef interface);
286 #endif // !TARGET_OS_IPHONE
287
288 int
289 __SCNetworkInterfaceCreateCapabilities (SCNetworkInterfaceRef interface,
290 int capability_base,
291 CFDictionaryRef capability_options);
292
293 int
294 __SCNetworkInterfaceCreateMediaOptions (SCNetworkInterfaceRef interface,
295 CFDictionaryRef media_options);
296
297 CFStringRef
298 __SCNetworkInterfaceGetDefaultConfigurationType (SCNetworkInterfaceRef interface);
299
300 CFStringRef
301 __SCNetworkInterfaceGetEntitySubType (SCNetworkInterfaceRef interface);
302
303 CFStringRef
304 __SCNetworkInterfaceGetEntityType (SCNetworkInterfaceRef interface);
305
306 CFStringRef
307 __SCNetworkInterfaceGetNonLocalizedDisplayName (SCNetworkInterfaceRef interface);
308
309 void
310 __SCNetworkInterfaceSetUserDefinedName(SCNetworkInterfaceRef interface, CFStringRef name);
311
312 /*!
313 @function __SCNetworkInterfaceGetUserDefinedName
314 @discussion This function returns the user defined name of the interface if available
315 @param interface The network interface.
316 @result String containing the user defined name.
317 */
318 CFStringRef
319 __SCNetworkInterfaceGetUserDefinedName(SCNetworkInterfaceRef interface);
320
321 /*!
322 @function __SCNetworkInterfaceIsActive
323 @discussion Identifies if the configuration of network interface is active or not
324 @param interface The network interface
325 @result TRUE if the interface configuration is active.
326 */
327 Boolean
328 __SCNetworkInterfaceIsActive (SCNetworkInterfaceRef interface);
329
330 Boolean
331 __SCNetworkInterfaceIsMember (SCPreferencesRef prefs,
332 SCNetworkInterfaceRef interface);
333
334 Boolean
335 __SCNetworkInterfaceIsValidExtendedConfigurationType
336 (SCNetworkInterfaceRef interface,
337 CFStringRef extendedType,
338 Boolean requirePerInterface);
339
340 CFDictionaryRef
341 __SCNetworkInterfaceGetTemplateOverrides (SCNetworkInterfaceRef interface,
342 CFStringRef overrideType);
343
344 int
345 __SCNetworkInterfaceOrder (SCNetworkInterfaceRef interface);
346
347 /*!
348 @function __SCNetworkInterfaceSaveStoredWithPreferences
349 @discussion Saves the array of interfaces in the preferences passed in the function. The interfaces
350 which are already present in the prefs file are replaced.
351 @param prefs Preferences which contain the interfaces to be replaced. If NULL, then preferences on
352 the system are used.
353 @param interfacesToSave The new interfaces array which is to be stored in preferences.
354 @result TRUE if saving of the new interfaces was successful.
355 */
356
357 Boolean
358 __SCNetworkInterfaceSaveStoredWithPreferences (SCPreferencesRef prefs,
359 CFArrayRef interfacesToSave);
360
361 Boolean
362 __SCNetworkInterfaceSetConfiguration (SCNetworkInterfaceRef interface,
363 CFStringRef extendedType,
364 CFDictionaryRef config,
365 Boolean okToHold);
366
367 void
368 __SCNetworkInterfaceSetDeepConfiguration (SCNetworkSetRef set,
369 SCNetworkInterfaceRef interface,
370 CFArrayRef configs);
371
372 /*!
373 @function __SCNetworkInterfaceSetIOInterfaceUnity
374 @discussion Will allow the caller to set IO Interface Unit
375 @param interface The network interface
376 @param unit The new interface unit to set
377
378 */
379 void
380 __SCNetworkInterfaceSetIOInterfaceUnit (SCNetworkInterfaceRef interface,
381 CFNumberRef unit);
382
383 Boolean
384 __SCNetworkInterfaceSupportsVLAN (CFStringRef bsd_if);
385
386 void
387 __SCBondInterfaceListCollectMembers (CFArrayRef interfaces,
388 CFMutableSetRef set);
389
390 Boolean
391 __SCBondInterfaceSetMemberInterfaces (SCBondInterfaceRef bond,
392 CFArrayRef members);
393
394 void
395 __SCBridgeInterfaceListCollectMembers (CFArrayRef interfaces,
396 CFMutableSetRef set);
397
398 Boolean
399 __SCBridgeInterfaceSetMemberInterfaces (SCBridgeInterfaceRef bridge,
400 CFArrayRef members);
401
402 #pragma mark -
403 #pragma mark SCNetworkProtocol configuration (internal)
404
405
406 SCNetworkProtocolPrivateRef
407 __SCNetworkProtocolCreatePrivate (CFAllocatorRef allocator,
408 CFStringRef entityID,
409 SCNetworkServiceRef service);
410
411 Boolean
412 __SCNetworkProtocolIsValidType (CFStringRef protocolType);
413
414
415 #pragma mark -
416 #pragma mark SCNetworkService configuration (internal)
417
418
419 CFArrayRef /* of SCNetworkServiceRef's */
420 __SCNetworkServiceCopyAllEnabled (SCPreferencesRef prefs);
421
422 CFArrayRef /* of SCNetworkInterfaceRef's */
423 __SCNetworkServiceCopyAllInterfaces (SCPreferencesRef prefs);
424
425 SCNetworkServicePrivateRef
426 __SCNetworkServiceCreatePrivate (CFAllocatorRef allocator,
427 SCPreferencesRef prefs,
428 CFStringRef serviceID,
429 SCNetworkInterfaceRef interface);
430
431 Boolean
432 __SCNetworkServiceExistsForInterface (CFArrayRef services,
433 SCNetworkInterfaceRef interface);
434
435 Boolean
436 __SCNetworkServiceCreate (SCPreferencesRef prefs,
437 SCNetworkInterfaceRef interface,
438 CFStringRef userDefinedName);
439
440 SCPreferencesRef
441 __SCNetworkCreateDefaultNIPrefs (CFStringRef prefsID);
442
443 /*!
444 @function __SCNetworkServiceMigrateNew
445 @discussion Adds network service to SCPreferencesRef if it doesn't exists
446 @param prefs SCPreferencesRef
447 @param service The network service
448 @param bsdMapping Mapping of interface names between configurations
449 @result TRUE if add service to prefs is successful
450 */
451 Boolean
452 __SCNetworkServiceMigrateNew (SCPreferencesRef prefs,
453 SCNetworkServiceRef service,
454 CFDictionaryRef bsdMapping,
455 CFDictionaryRef setMapping,
456 CFDictionaryRef serviceSetMapping);
457
458 void
459 __SCNetworkServiceAddProtocolToService (SCNetworkServiceRef service,
460 CFStringRef protocolType,
461 CFDictionaryRef configuration,
462 Boolean enabled);
463
464 #pragma mark -
465 #pragma mark SCNetworkSet configuration (internal)
466
467
468 #pragma mark -
469 #pragma mark Miscellaneous (internal)
470
471
472 CFDictionaryRef
473 __copyInterfaceTemplate (CFStringRef interfaceType,
474 CFStringRef childInterfaceType);
475
476 CFDictionaryRef
477 __copyProtocolTemplate (CFStringRef interfaceType,
478 CFStringRef childInterfaceType,
479 CFStringRef protocolType);
480
481 CFDictionaryRef
482 __getPrefsConfiguration (SCPreferencesRef prefs,
483 CFStringRef path);
484
485 Boolean
486 __setPrefsConfiguration (SCPreferencesRef prefs,
487 CFStringRef path,
488 CFDictionaryRef config,
489 Boolean keepInactive);
490
491 Boolean
492 __getPrefsEnabled (SCPreferencesRef prefs,
493 CFStringRef path);
494
495 Boolean
496 __setPrefsEnabled (SCPreferencesRef prefs,
497 CFStringRef path,
498 Boolean enabled);
499
500 Boolean
501 __createInterface (int s,
502 CFStringRef interface);
503
504 Boolean
505 __destroyInterface (int s,
506 CFStringRef interface);
507
508 CFStringRef
509 __SCPreferencesPathCreateUniqueChild_WithMoreSCFCompatibility
510 (SCPreferencesRef prefs,
511 CFStringRef prefix);
512
513 Boolean
514 __extract_password (SCPreferencesRef prefs,
515 CFDictionaryRef config,
516 CFStringRef passwordKey,
517 CFStringRef encryptionKey,
518 CFStringRef encryptionKeyChainValue,
519 CFStringRef unique_id,
520 CFDataRef *password);
521
522 Boolean
523 __remove_password (SCPreferencesRef prefs,
524 CFDictionaryRef config,
525 CFStringRef passwordKey,
526 CFStringRef encryptionKey,
527 CFStringRef encryptionKeyChainValue,
528 CFStringRef unique_id,
529 CFDictionaryRef *newConfig);
530
531 Boolean
532 __rank_to_str (SCNetworkServicePrimaryRank rank,
533 CFStringRef *rankStr);
534
535 Boolean
536 __str_to_rank (CFStringRef rankStr,
537 SCNetworkServicePrimaryRank *rank);
538
539 __END_DECLS
540
541 #endif /* _SCNETWORKCONFIGURATIONINTERNAL_H */