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