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