]> git.saurik.com Git - apple/configd.git/blob - SystemConfiguration.fproj/SCNetworkConfigurationInternal.h
configd-888.51.2.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 Boolean modemIsV92;
160 CFStringRef prefix;
161 CFNumberRef type;
162 CFNumberRef unit;
163 CFNumberRef family;
164 CFNumberRef subfamily;
165 struct {
166 CFStringRef name;
167 CFNumberRef vid;
168 CFNumberRef pid;
169 } usb;
170
171 // misc
172 int sort_order; // sort order for this interface
173
174 // for BOND interfaces
175 Boolean supportsBond;
176 struct {
177 CFArrayRef interfaces;
178 CFNumberRef mode;
179 CFDictionaryRef options;
180 } bond;
181
182 // for Bridge interfaces
183 Boolean supportsBridge;
184 struct {
185 CFArrayRef interfaces;
186 CFDictionaryRef options;
187 } bridge;
188
189 // for VLAN interfaces
190 Boolean supportsVLAN;
191 struct {
192 SCNetworkInterfaceRef interface;
193 CFNumberRef tag; // e.g. 1 <= tag <= 4094
194 CFDictionaryRef options;
195 } vlan;
196
197 #if !TARGET_OS_SIMULATOR
198 // for interface rank assertions
199 IPMonitorControlRef IPMonitorControl;
200 #endif // !TARGET_OS_SIMULATOR
201 } SCNetworkInterfacePrivate, *SCNetworkInterfacePrivateRef;
202
203
204 __BEGIN_DECLS
205
206
207 #pragma mark -
208 #pragma mark SCNetworkInterface configuration (internal)
209
210 Boolean
211 __SCNetworkInterfaceMatchesName (CFStringRef name, 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 ni_prefs Preferences pointing to NetworkInterfaces.plist
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 #pragma mark -
416 #pragma mark SCNetworkProtocol configuration (internal)
417
418
419 SCNetworkProtocolPrivateRef
420 __SCNetworkProtocolCreatePrivate (CFAllocatorRef allocator,
421 CFStringRef entityID,
422 SCNetworkServiceRef service);
423
424 Boolean
425 __SCNetworkProtocolIsValidType (CFStringRef protocolType);
426
427
428 #pragma mark -
429 #pragma mark SCNetworkService configuration (internal)
430
431
432 CFArrayRef /* of SCNetworkServiceRef's */
433 __SCNetworkServiceCopyAllEnabled (SCPreferencesRef prefs);
434
435 CFArrayRef /* of SCNetworkInterfaceRef's */
436 __SCNetworkServiceCopyAllInterfaces (SCPreferencesRef prefs);
437
438 SCNetworkServicePrivateRef
439 __SCNetworkServiceCreatePrivate (CFAllocatorRef allocator,
440 SCPreferencesRef prefs,
441 CFStringRef serviceID,
442 SCNetworkInterfaceRef interface);
443
444 Boolean
445 __SCNetworkServiceExistsForInterface (CFArrayRef services,
446 SCNetworkInterfaceRef interface);
447
448 Boolean
449 __SCNetworkServiceCreate (SCPreferencesRef prefs,
450 SCNetworkInterfaceRef interface,
451 CFStringRef userDefinedName);
452
453 Boolean
454 __SCNetworkServiceIsPPTP (SCNetworkServiceRef service);
455
456
457 SCPreferencesRef
458 __SCNetworkCreateDefaultNIPrefs (CFStringRef prefsID);
459
460 /*!
461 @function __SCNetworkServiceMigrateNew
462 @discussion Adds network service to SCPreferencesRef if it doesn't exists
463 @param prefs SCPreferencesRef
464 @param service The network service
465 @param bsdMapping Mapping of interface names between configurations
466 @result TRUE if add service to prefs is successful
467 */
468 Boolean
469 __SCNetworkServiceMigrateNew (SCPreferencesRef prefs,
470 SCNetworkServiceRef service,
471 CFDictionaryRef bsdMapping,
472 CFDictionaryRef setMapping,
473 CFDictionaryRef serviceSetMapping);
474
475 void
476 __SCNetworkServiceAddProtocolToService (SCNetworkServiceRef service,
477 CFStringRef protocolType,
478 CFDictionaryRef configuration,
479 Boolean enabled);
480
481 #pragma mark -
482 #pragma mark SCNetworkSet configuration (internal)
483
484
485 #pragma mark -
486 #pragma mark Logging
487
488
489 os_log_t
490 __log_SCNetworkConfiguration ();
491
492
493 #pragma mark -
494 #pragma mark Miscellaneous (internal)
495
496
497 CFDictionaryRef
498 __copyInterfaceTemplate (CFStringRef interfaceType,
499 CFStringRef childInterfaceType);
500
501 CFDictionaryRef
502 __copyProtocolTemplate (CFStringRef interfaceType,
503 CFStringRef childInterfaceType,
504 CFStringRef protocolType);
505
506 CFDictionaryRef
507 __getPrefsConfiguration (SCPreferencesRef prefs,
508 CFStringRef path);
509
510 Boolean
511 __setPrefsConfiguration (SCPreferencesRef prefs,
512 CFStringRef path,
513 CFDictionaryRef config,
514 Boolean keepInactive);
515
516 Boolean
517 __getPrefsEnabled (SCPreferencesRef prefs,
518 CFStringRef path);
519
520 Boolean
521 __setPrefsEnabled (SCPreferencesRef prefs,
522 CFStringRef path,
523 Boolean enabled);
524
525 Boolean
526 __createInterface (int s,
527 CFStringRef interface);
528
529 Boolean
530 __destroyInterface (int s,
531 CFStringRef interface);
532
533 CFStringRef
534 __SCPreferencesPathCreateUniqueChild_WithMoreSCFCompatibility
535 (SCPreferencesRef prefs,
536 CFStringRef prefix);
537
538 Boolean
539 __extract_password (SCPreferencesRef prefs,
540 CFDictionaryRef config,
541 CFStringRef passwordKey,
542 CFStringRef encryptionKey,
543 CFStringRef encryptionKeyChainValue,
544 CFStringRef unique_id,
545 CFDataRef *password);
546
547 Boolean
548 __remove_password (SCPreferencesRef prefs,
549 CFDictionaryRef config,
550 CFStringRef passwordKey,
551 CFStringRef encryptionKey,
552 CFStringRef encryptionKeyChainValue,
553 CFStringRef unique_id,
554 CFDictionaryRef *newConfig);
555
556 Boolean
557 __rank_to_str (SCNetworkServicePrimaryRank rank,
558 CFStringRef *rankStr);
559
560 Boolean
561 __str_to_rank (CFStringRef rankStr,
562 SCNetworkServicePrimaryRank *rank);
563
564 __END_DECLS
565
566 #endif /* _SCNETWORKCONFIGURATIONINTERNAL_H */