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