]> git.saurik.com Git - apple/configd.git/blob - SystemConfiguration.fproj/SCNetworkConfigurationInternal.h
configd-1109.40.9.tar.gz
[apple/configd.git] / SystemConfiguration.fproj / SCNetworkConfigurationInternal.h
1 /*
2 * Copyright (c) 2004-2020 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 "SCPreferencesPathKey.h"
38 #include "IPMonitorControl.h"
39 #include <IOKit/IOKitLib.h>
40
41
42 #define NETWORK_CONFIGURATION_VERSION 20191120
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 hiddenConfiguration;
155 Boolean hiddenInterface;
156 CFStringRef location;
157 CFStringRef path;
158 uint64_t entryID;
159 CFMutableDictionaryRef overrides;
160 CFStringRef prefix;
161 Boolean trustRequired;
162 CFNumberRef type;
163 CFNumberRef unit;
164 CFNumberRef family;
165 CFNumberRef subfamily;
166 struct {
167 CFStringRef name;
168 CFNumberRef vid;
169 CFNumberRef pid;
170 } usb;
171
172 // misc
173 CFArrayRef matchingMACs;
174 unsigned int sort_order; // sort order for this interface
175
176 // for BOND interfaces
177 Boolean supportsBond;
178 struct {
179 CFArrayRef interfaces;
180 CFNumberRef mode;
181 CFDictionaryRef options;
182 } bond;
183
184 // for Bridge interfaces
185 Boolean supportsBridge;
186 struct {
187 CFArrayRef interfaces;
188 CFDictionaryRef options;
189 } bridge;
190
191 // for VLAN interfaces
192 Boolean supportsVLAN;
193 struct {
194 SCNetworkInterfaceRef interface;
195 CFNumberRef tag; // e.g. 1 <= tag <= 4094
196 CFDictionaryRef options;
197 } vlan;
198
199 // for interface rank assertions
200 IPMonitorControlRef IPMonitorControl;
201
202 } SCNetworkInterfacePrivate, *SCNetworkInterfacePrivateRef;
203
204
205 __BEGIN_DECLS
206
207 #pragma mark -
208 #pragma mark SCNetworkConfiguration (internal)
209
210
211
212 Boolean
213 __SCNetworkConfigurationBackup (SCPreferencesRef prefs,
214 CFStringRef suffix,
215 SCPreferencesRef relativeTo);
216
217
218
219 #pragma mark -
220 #pragma mark SCNetworkInterface configuration (internal)
221
222
223 extern const SCNetworkServiceRef __kSCNetworkInterfaceSearchExternal;
224
225 extern const SCNetworkServiceRef __kSCNetworkInterfaceSearchSystem;
226
227 Boolean
228 __SCNetworkInterfaceMatchesName (CFStringRef name,
229 CFStringRef key);
230
231 CFArrayRef
232 __SCNetworkInterfaceCopyAll_IONetworkInterface (Boolean keep_pre_configured);
233
234 /*!
235 @function __SCNetworkInterfaceCopyStoredWithPreferences
236 @discussion Create an array of network interfaces, which is present in the preferences
237 in NetworkInteraces.plist
238 @param ni_prefs Preference for network interfaces
239 @result Array which contains SCNetworkInterfaceRef.
240 You must release the returned value.
241 */
242
243 CFArrayRef // SCNetworkInterfaceRef
244 __SCNetworkInterfaceCopyStoredWithPreferences (SCPreferencesRef ni_prefs);
245
246 SCNetworkInterfacePrivateRef
247 __SCNetworkInterfaceCreateCopy (CFAllocatorRef allocator,
248 SCNetworkInterfaceRef interface,
249 SCPreferencesRef prefs,
250 CFStringRef serviceID);
251
252 /*!
253 @function __SCNetworkInterfaceCreateMappingUsingBSDName
254 @discussion This function creates mapping of BSD name and network interface using
255 preferences which point to the NetworkInterfaces.plist file.
256 @param interfaces An array of network interfaces to use for the mapping.
257 @result BSD Mapping in a dictionary.
258 You must release the returned value.
259 */
260 CFDictionaryRef
261 __SCNetworkInterfaceCreateMappingUsingBSDName (CFArrayRef interfaces);
262
263 SCNetworkInterfaceRef
264 __SCNetworkInterfaceCreateWithNIPreferencesUsingBSDName(CFAllocatorRef allocator,
265 SCPreferencesRef ni_prefs,
266 CFStringRef bsdName);
267
268 SCNetworkInterfacePrivateRef
269 __SCNetworkInterfaceCreatePrivate (CFAllocatorRef allocator,
270 SCNetworkInterfaceRef interface,
271 SCPreferencesRef prefs,
272 CFStringRef serviceID);
273
274 SCNetworkInterfacePrivateRef
275 _SCBondInterfaceCreatePrivate (CFAllocatorRef allocator,
276 CFStringRef bond_if);
277
278 SCNetworkInterfacePrivateRef
279 _SCBridgeInterfaceCreatePrivate (CFAllocatorRef allocator,
280 CFStringRef bridge_if);
281
282 SCNetworkInterfacePrivateRef
283 _SCVLANInterfaceCreatePrivate (CFAllocatorRef allocator,
284 CFStringRef vlan_if);
285
286 CFDictionaryRef
287 __SCNetworkInterfaceCopyInterfaceEntity (SCNetworkInterfaceRef interface);
288
289 CFArrayRef
290 __SCNetworkInterfaceCopyDeepConfiguration (SCNetworkSetRef set,
291 SCNetworkInterfaceRef interface);
292
293 #if !TARGET_OS_IPHONE
294 CFStringRef
295 __SCNetworkInterfaceCopyXLocalizedDisplayName (SCNetworkInterfaceRef interface);
296
297 CFStringRef
298 __SCNetworkInterfaceCopyXNonLocalizedDisplayName(SCNetworkInterfaceRef interface);
299 #endif // !TARGET_OS_IPHONE
300
301 CFStringRef
302 __SCNetworkInterfaceGetDefaultConfigurationType (SCNetworkInterfaceRef interface);
303
304 CFStringRef
305 __SCNetworkInterfaceGetEntitySubType (SCNetworkInterfaceRef interface);
306
307 CFStringRef
308 __SCNetworkInterfaceGetEntityType (SCNetworkInterfaceRef interface);
309
310 CFStringRef
311 __SCNetworkInterfaceGetNonLocalizedDisplayName (SCNetworkInterfaceRef interface);
312
313 void
314 __SCNetworkInterfaceSetUserDefinedName(SCNetworkInterfaceRef interface, CFStringRef name);
315
316 /*!
317 @function __SCNetworkInterfaceGetUserDefinedName
318 @discussion This function returns the user defined name of the interface if available
319 @param interface The network interface.
320 @result String containing the user defined name.
321 */
322 CFStringRef
323 __SCNetworkInterfaceGetUserDefinedName(SCNetworkInterfaceRef interface);
324
325 /*!
326 @function __SCNetworkInterfaceIsActive
327 @discussion Identifies if the configuration of network interface is active or not
328 @param interface The network interface
329 @result TRUE if the interface configuration is active.
330 */
331 Boolean
332 __SCNetworkInterfaceIsActive (SCNetworkInterfaceRef interface);
333
334 Boolean
335 __SCNetworkInterfaceIsMember (SCPreferencesRef prefs,
336 SCNetworkInterfaceRef interface);
337
338 Boolean
339 __SCNetworkInterfaceEntityIsPPTP (CFDictionaryRef entity);
340
341 Boolean
342 __SCNetworkInterfaceIsValidExtendedConfigurationType
343 (SCNetworkInterfaceRef interface,
344 CFStringRef extendedType,
345 Boolean requirePerInterface);
346
347 CFPropertyListRef
348 __SCNetworkInterfaceGetTemplateOverrides (SCNetworkInterfaceRef interface,
349 CFStringRef overrideType);
350
351 int
352 __SCNetworkInterfaceOrder (SCNetworkInterfaceRef interface);
353
354 /*!
355 @function __SCNetworkInterfaceSaveStoredWithPreferences
356 @discussion Saves the array of interfaces in the preferences passed in the function. The interfaces
357 which are already present in the prefs file are replaced.
358 @param prefs Preferences which contain the interfaces to be replaced. If NULL, then preferences on
359 the system are used.
360 @param interfacesToSave The new interfaces array which is to be stored in preferences.
361 @result TRUE if saving of the new interfaces was successful.
362 */
363
364 Boolean
365 __SCNetworkInterfaceSaveStoredWithPreferences (SCPreferencesRef prefs,
366 CFArrayRef interfacesToSave);
367
368 Boolean
369 __SCNetworkInterfaceSetConfiguration (SCNetworkInterfaceRef interface,
370 CFStringRef extendedType,
371 CFDictionaryRef config,
372 Boolean okToHold);
373
374 void
375 __SCNetworkInterfaceSetDeepConfiguration (SCNetworkSetRef set,
376 SCNetworkInterfaceRef interface,
377 CFArrayRef configs);
378
379 /*!
380 @function __SCNetworkInterfaceSetIOInterfaceUnity
381 @discussion Will allow the caller to set IO Interface Unit
382 @param interface The network interface
383 @param unit The new interface unit to set
384 */
385 void
386 __SCNetworkInterfaceSetIOInterfaceUnit (SCNetworkInterfaceRef interface,
387 CFNumberRef unit);
388
389 Boolean
390 __SCNetworkInterfaceSupportsVLAN (CFStringRef bsd_if);
391
392 void
393 __SCBondInterfaceListCollectMembers (CFArrayRef interfaces,
394 CFMutableSetRef set);
395
396 Boolean
397 __SCBondInterfaceSetMemberInterfaces (SCBondInterfaceRef bond,
398 CFArrayRef members);
399
400 void
401 __SCBridgeInterfaceListCollectMembers (CFArrayRef interfaces,
402 CFMutableSetRef set);
403
404 Boolean
405 __SCBridgeInterfaceSetMemberInterfaces (SCBridgeInterfaceRef bridge,
406 CFArrayRef members);
407
408 void
409 _SCNetworkInterfaceCacheOpen(void);
410
411 void
412 _SCNetworkInterfaceCacheClose(void);
413
414
415 #pragma mark -
416 #pragma mark SCNetworkInterface (NetworkInterfaces.plist) configuration (internal)
417
418
419 #define kSCNetworkInterfaceActive "Active"
420 #define kSCNetworkInterfaceInfo "SCNetworkInterfaceInfo"
421 #define kSCNetworkInterfaceType "SCNetworkInterfaceType"
422 #define kSCNetworkInterfaceBSDName kIOBSDNameKey
423 #define kSCNetworkInterfaceIOBuiltin kIOBuiltin
424 #define kSCNetworkInterfaceIOInterfaceNamePrefix kIOInterfaceNamePrefix
425 #define kSCNetworkInterfaceIOInterfaceType kIOInterfaceType
426 #define kSCNetworkInterfaceIOInterfaceUnit kIOInterfaceUnit
427 #define kSCNetworkInterfaceIOMACAddress kIOMACAddress
428 #define kSCNetworkInterfaceIOPathMatch kIOPathMatchKey
429 #define kSCNetworkInterfaceMatchingMACs "MatchingMACs"
430
431
432 /*!
433 @function __SCNetworkInterfaceCopyStorageEntity
434 @discussion Create interface entity of network interface as seen in
435 NetworkInterfaces.plist
436 @param interface The network interface from which interface entity is create
437 @result Dictionary which contains information about interface entity.
438 You must release the returned value.
439 */
440 CFDictionaryRef
441 __SCNetworkInterfaceCopyStorageEntity (SCNetworkInterfaceRef interface);
442
443
444 #pragma mark -
445 #pragma mark SCNetworkProtocol configuration (internal)
446
447
448 SCNetworkProtocolPrivateRef
449 __SCNetworkProtocolCreatePrivate (CFAllocatorRef allocator,
450 CFStringRef entityID,
451 SCNetworkServiceRef service);
452
453 Boolean
454 __SCNetworkProtocolIsValidType (CFStringRef protocolType);
455
456
457 #pragma mark -
458 #pragma mark SCNetworkService configuration (internal)
459
460
461 CFArrayRef /* of SCNetworkServiceRef's */
462 __SCNetworkServiceCopyAllEnabled (SCPreferencesRef prefs);
463
464 CFArrayRef /* of SCNetworkInterfaceRef's */
465 __SCNetworkServiceCopyAllInterfaces (SCPreferencesRef prefs);
466
467 SCNetworkServicePrivateRef
468 __SCNetworkServiceCreatePrivate (CFAllocatorRef allocator,
469 SCPreferencesRef prefs,
470 CFStringRef serviceID,
471 SCNetworkInterfaceRef interface);
472
473 Boolean
474 __SCNetworkServiceExists (SCNetworkServiceRef service);
475
476 Boolean
477 __SCNetworkServiceExistsForInterface (CFArrayRef services,
478 SCNetworkInterfaceRef interface);
479
480 Boolean
481 __SCNetworkServiceCreate (SCPreferencesRef prefs,
482 SCNetworkInterfaceRef interface,
483 CFStringRef userDefinedName);
484
485 Boolean
486 __SCNetworkServiceIsPPTP (SCNetworkServiceRef service);
487
488
489 /*!
490 @function __SCNetworkServiceMigrateNew
491 @discussion Adds network service to SCPreferencesRef if it doesn't exists
492 @param prefs SCPreferencesRef
493 @param service The network service
494 @param bsdNameMapping Mapping of interface names between configurations
495 @result TRUE if add service to prefs is successful
496 */
497 Boolean
498 __SCNetworkServiceMigrateNew (SCPreferencesRef prefs,
499 SCNetworkServiceRef service,
500 CFDictionaryRef bsdNameMapping,
501 CFDictionaryRef setMapping,
502 CFDictionaryRef serviceSetMapping);
503
504 void
505 __SCNetworkServiceAddProtocolToService (SCNetworkServiceRef service,
506 CFStringRef protocolType,
507 CFDictionaryRef configuration,
508 Boolean enabled);
509
510
511 #pragma mark -
512 #pragma mark SCNetworkSet configuration (internal)
513
514
515 Boolean
516 __SCNetworkSetExists (SCNetworkSetRef set);
517
518
519 #pragma mark -
520 #pragma mark Logging
521
522
523 os_log_t
524 __log_SCNetworkConfiguration (void);
525
526
527 #pragma mark -
528 #pragma mark Miscellaneous (internal)
529
530
531 CFDictionaryRef
532 __copyInterfaceTemplate (CFStringRef interfaceType,
533 CFStringRef childInterfaceType);
534
535 CFDictionaryRef
536 __copyProtocolTemplate (CFStringRef interfaceType,
537 CFStringRef childInterfaceType,
538 CFStringRef protocolType);
539
540 CFDictionaryRef
541 __SCNetworkConfigurationGetValue (SCPreferencesRef prefs,
542 CFStringRef path);
543
544 Boolean
545 __SCNetworkConfigurationSetValue (SCPreferencesRef prefs,
546 CFStringRef path,
547 CFDictionaryRef config,
548 Boolean keepInactive);
549
550 Boolean
551 __getPrefsEnabled (SCPreferencesRef prefs,
552 CFStringRef path);
553
554 Boolean
555 __setPrefsEnabled (SCPreferencesRef prefs,
556 CFStringRef path,
557 Boolean enabled);
558
559 Boolean
560 __createInterface (int s,
561 CFStringRef interface);
562
563 Boolean
564 __destroyInterface (int s,
565 CFStringRef interface);
566
567 CFStringRef
568 __SCPreferencesPathCreateUniqueChild_WithMoreSCFCompatibility
569 (SCPreferencesRef prefs,
570 CFStringRef prefix);
571
572 Boolean
573 __extract_password (SCPreferencesRef prefs,
574 CFDictionaryRef config,
575 CFStringRef passwordKey,
576 CFStringRef encryptionKey,
577 CFStringRef encryptionKeyChainValue,
578 CFStringRef unique_id,
579 CFDataRef *password);
580
581 Boolean
582 __remove_password (SCPreferencesRef prefs,
583 CFDictionaryRef config,
584 CFStringRef passwordKey,
585 CFStringRef encryptionKey,
586 CFStringRef encryptionKeyChainValue,
587 CFStringRef unique_id,
588 CFDictionaryRef *newConfig);
589
590 Boolean
591 __rank_to_str (SCNetworkServicePrimaryRank rank,
592 CFStringRef *rankStr);
593
594 Boolean
595 __str_to_rank (CFStringRef rankStr,
596 SCNetworkServicePrimaryRank *rank);
597
598 __END_DECLS
599
600 #endif /* _SCNETWORKCONFIGURATIONINTERNAL_H */