]> git.saurik.com Git - apple/configd.git/blob - SystemConfiguration.fproj/SCNetworkConfigurationInternal.h
configd-963.200.27.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 <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 Boolean trustRequired;
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,
212 CFStringRef key);
213
214 CFArrayRef
215 __SCNetworkInterfaceCopyAll_IONetworkInterface (Boolean keep_pre_configured);
216
217 /*!
218 @function __SCNetworkInterfaceCopyStorageEntity
219 @discussion Create interface entity of network interface as seen in
220 NetworkInterfaces.plist
221 @param interface The network interface from which interface entity is create
222 @result Dictionary which contains information about interface entity
223 You must release the returned value.
224 */
225 CFDictionaryRef
226 __SCNetworkInterfaceCopyStorageEntity (SCNetworkInterfaceRef interface);
227
228 /*!
229 @function __SCNetworkInterfaceCopyStoredWithPreferences
230 @discussion Create an array of network interfaces, which is present in the preferences
231 in NetworkInteraces.plist
232 @param ni_prefs Preference for network interfaces
233 @result Array which contains SCNetworkInterfaceRef.
234 You must release the returned value.
235 */
236
237 CFArrayRef // SCNetworkInterfaceRef
238 __SCNetworkInterfaceCopyStoredWithPreferences (SCPreferencesRef ni_prefs);
239
240 SCNetworkInterfacePrivateRef
241 __SCNetworkInterfaceCreateCopy (CFAllocatorRef allocator,
242 SCNetworkInterfaceRef interface,
243 SCPreferencesRef prefs,
244 CFStringRef serviceID);
245
246 /*!
247 @function __SCNetworkInterfaceCreateMappingUsingBSDName
248 @discussion This function creates mapping of BSD name and network interface using
249 preferences which point to the NetworkInterfaces.plist file.
250 @param interfaces An array of network interfaces to use for the mapping.
251 @result BSD Mapping in a dictionary.
252 You must release the returned value.
253 */
254 CFDictionaryRef
255 __SCNetworkInterfaceCreateMappingUsingBSDName (CFArrayRef interfaces);
256
257 SCNetworkInterfaceRef
258 __SCNetworkInterfaceCreateWithNIPreferencesUsingBSDName(CFAllocatorRef allocator,
259 SCPreferencesRef ni_prefs,
260 CFStringRef bsdName);
261
262 SCNetworkInterfacePrivateRef
263 __SCNetworkInterfaceCreatePrivate (CFAllocatorRef allocator,
264 SCNetworkInterfaceRef interface,
265 SCPreferencesRef prefs,
266 CFStringRef serviceID);
267
268 SCNetworkInterfacePrivateRef
269 _SCBondInterfaceCreatePrivate (CFAllocatorRef allocator,
270 CFStringRef bond_if);
271
272 SCNetworkInterfacePrivateRef
273 _SCBridgeInterfaceCreatePrivate (CFAllocatorRef allocator,
274 CFStringRef bridge_if);
275
276 SCNetworkInterfacePrivateRef
277 _SCVLANInterfaceCreatePrivate (CFAllocatorRef allocator,
278 CFStringRef vlan_if);
279
280 CFDictionaryRef
281 __SCNetworkInterfaceCopyInterfaceEntity (SCNetworkInterfaceRef interface);
282
283 CFArrayRef
284 __SCNetworkInterfaceCopyDeepConfiguration (SCNetworkSetRef set,
285 SCNetworkInterfaceRef interface);
286
287 #if !TARGET_OS_IPHONE
288 CFStringRef
289 __SCNetworkInterfaceCopyXLocalizedDisplayName (SCNetworkInterfaceRef interface);
290
291 CFStringRef
292 __SCNetworkInterfaceCopyXNonLocalizedDisplayName(SCNetworkInterfaceRef interface);
293 #endif // !TARGET_OS_IPHONE
294
295 CFStringRef
296 __SCNetworkInterfaceGetDefaultConfigurationType (SCNetworkInterfaceRef interface);
297
298 CFStringRef
299 __SCNetworkInterfaceGetEntitySubType (SCNetworkInterfaceRef interface);
300
301 CFStringRef
302 __SCNetworkInterfaceGetEntityType (SCNetworkInterfaceRef interface);
303
304 CFStringRef
305 __SCNetworkInterfaceGetNonLocalizedDisplayName (SCNetworkInterfaceRef interface);
306
307 void
308 __SCNetworkInterfaceSetUserDefinedName(SCNetworkInterfaceRef interface, CFStringRef name);
309
310 /*!
311 @function __SCNetworkInterfaceGetUserDefinedName
312 @discussion This function returns the user defined name of the interface if available
313 @param interface The network interface.
314 @result String containing the user defined name.
315 */
316 CFStringRef
317 __SCNetworkInterfaceGetUserDefinedName(SCNetworkInterfaceRef interface);
318
319 /*!
320 @function __SCNetworkInterfaceIsActive
321 @discussion Identifies if the configuration of network interface is active or not
322 @param interface The network interface
323 @result TRUE if the interface configuration is active.
324 */
325 Boolean
326 __SCNetworkInterfaceIsActive (SCNetworkInterfaceRef interface);
327
328 Boolean
329 __SCNetworkInterfaceIsMember (SCPreferencesRef prefs,
330 SCNetworkInterfaceRef interface);
331
332 Boolean
333 __SCNetworkInterfaceEntityIsPPTP (CFDictionaryRef entity);
334
335 Boolean
336 __SCNetworkInterfaceIsValidExtendedConfigurationType
337 (SCNetworkInterfaceRef interface,
338 CFStringRef extendedType,
339 Boolean requirePerInterface);
340
341 CFDictionaryRef
342 __SCNetworkInterfaceGetTemplateOverrides (SCNetworkInterfaceRef interface,
343 CFStringRef overrideType);
344
345 int
346 __SCNetworkInterfaceOrder (SCNetworkInterfaceRef interface);
347
348 /*!
349 @function __SCNetworkInterfaceSaveStoredWithPreferences
350 @discussion Saves the array of interfaces in the preferences passed in the function. The interfaces
351 which are already present in the prefs file are replaced.
352 @param prefs Preferences which contain the interfaces to be replaced. If NULL, then preferences on
353 the system are used.
354 @param interfacesToSave The new interfaces array which is to be stored in preferences.
355 @result TRUE if saving of the new interfaces was successful.
356 */
357
358 Boolean
359 __SCNetworkInterfaceSaveStoredWithPreferences (SCPreferencesRef prefs,
360 CFArrayRef interfacesToSave);
361
362 Boolean
363 __SCNetworkInterfaceSetConfiguration (SCNetworkInterfaceRef interface,
364 CFStringRef extendedType,
365 CFDictionaryRef config,
366 Boolean okToHold);
367
368 void
369 __SCNetworkInterfaceSetDeepConfiguration (SCNetworkSetRef set,
370 SCNetworkInterfaceRef interface,
371 CFArrayRef configs);
372
373 /*!
374 @function __SCNetworkInterfaceSetIOInterfaceUnity
375 @discussion Will allow the caller to set IO Interface Unit
376 @param interface The network interface
377 @param unit The new interface unit to set
378
379 */
380 void
381 __SCNetworkInterfaceSetIOInterfaceUnit (SCNetworkInterfaceRef interface,
382 CFNumberRef unit);
383
384 Boolean
385 __SCNetworkInterfaceSupportsVLAN (CFStringRef bsd_if);
386
387 void
388 __SCBondInterfaceListCollectMembers (CFArrayRef interfaces,
389 CFMutableSetRef set);
390
391 Boolean
392 __SCBondInterfaceSetMemberInterfaces (SCBondInterfaceRef bond,
393 CFArrayRef members);
394
395 void
396 __SCBridgeInterfaceListCollectMembers (CFArrayRef interfaces,
397 CFMutableSetRef set);
398
399 Boolean
400 __SCBridgeInterfaceSetMemberInterfaces (SCBridgeInterfaceRef bridge,
401 CFArrayRef members);
402
403 void
404 _SCNetworkInterfaceCacheOpen(void);
405
406 void
407 _SCNetworkInterfaceCacheClose(void);
408
409 #pragma mark -
410 #pragma mark SCNetworkProtocol configuration (internal)
411
412
413 SCNetworkProtocolPrivateRef
414 __SCNetworkProtocolCreatePrivate (CFAllocatorRef allocator,
415 CFStringRef entityID,
416 SCNetworkServiceRef service);
417
418 Boolean
419 __SCNetworkProtocolIsValidType (CFStringRef protocolType);
420
421
422 #pragma mark -
423 #pragma mark SCNetworkService configuration (internal)
424
425
426 CFArrayRef /* of SCNetworkServiceRef's */
427 __SCNetworkServiceCopyAllEnabled (SCPreferencesRef prefs);
428
429 CFArrayRef /* of SCNetworkInterfaceRef's */
430 __SCNetworkServiceCopyAllInterfaces (SCPreferencesRef prefs);
431
432 SCNetworkServicePrivateRef
433 __SCNetworkServiceCreatePrivate (CFAllocatorRef allocator,
434 SCPreferencesRef prefs,
435 CFStringRef serviceID,
436 SCNetworkInterfaceRef interface);
437
438 Boolean
439 __SCNetworkServiceExistsForInterface (CFArrayRef services,
440 SCNetworkInterfaceRef interface);
441
442 Boolean
443 __SCNetworkServiceCreate (SCPreferencesRef prefs,
444 SCNetworkInterfaceRef interface,
445 CFStringRef userDefinedName);
446
447 Boolean
448 __SCNetworkServiceIsPPTP (SCNetworkServiceRef service);
449
450
451 SCPreferencesRef
452 __SCNetworkCreateDefaultNIPrefs (CFStringRef prefsID);
453
454 /*!
455 @function __SCNetworkServiceMigrateNew
456 @discussion Adds network service to SCPreferencesRef if it doesn't exists
457 @param prefs SCPreferencesRef
458 @param service The network service
459 @param bsdMapping Mapping of interface names between configurations
460 @result TRUE if add service to prefs is successful
461 */
462 Boolean
463 __SCNetworkServiceMigrateNew (SCPreferencesRef prefs,
464 SCNetworkServiceRef service,
465 CFDictionaryRef bsdMapping,
466 CFDictionaryRef setMapping,
467 CFDictionaryRef serviceSetMapping);
468
469 void
470 __SCNetworkServiceAddProtocolToService (SCNetworkServiceRef service,
471 CFStringRef protocolType,
472 CFDictionaryRef configuration,
473 Boolean enabled);
474
475 #pragma mark -
476 #pragma mark SCNetworkSet configuration (internal)
477
478
479 #pragma mark -
480 #pragma mark Logging
481
482
483 os_log_t
484 __log_SCNetworkConfiguration (void);
485
486
487 #pragma mark -
488 #pragma mark Miscellaneous (internal)
489
490
491 CFDictionaryRef
492 __copyInterfaceTemplate (CFStringRef interfaceType,
493 CFStringRef childInterfaceType);
494
495 CFDictionaryRef
496 __copyProtocolTemplate (CFStringRef interfaceType,
497 CFStringRef childInterfaceType,
498 CFStringRef protocolType);
499
500 CFDictionaryRef
501 __getPrefsConfiguration (SCPreferencesRef prefs,
502 CFStringRef path);
503
504 Boolean
505 __setPrefsConfiguration (SCPreferencesRef prefs,
506 CFStringRef path,
507 CFDictionaryRef config,
508 Boolean keepInactive);
509
510 Boolean
511 __getPrefsEnabled (SCPreferencesRef prefs,
512 CFStringRef path);
513
514 Boolean
515 __setPrefsEnabled (SCPreferencesRef prefs,
516 CFStringRef path,
517 Boolean enabled);
518
519 Boolean
520 __createInterface (int s,
521 CFStringRef interface);
522
523 Boolean
524 __destroyInterface (int s,
525 CFStringRef interface);
526
527 CFStringRef
528 __SCPreferencesPathCreateUniqueChild_WithMoreSCFCompatibility
529 (SCPreferencesRef prefs,
530 CFStringRef prefix);
531
532 Boolean
533 __extract_password (SCPreferencesRef prefs,
534 CFDictionaryRef config,
535 CFStringRef passwordKey,
536 CFStringRef encryptionKey,
537 CFStringRef encryptionKeyChainValue,
538 CFStringRef unique_id,
539 CFDataRef *password);
540
541 Boolean
542 __remove_password (SCPreferencesRef prefs,
543 CFDictionaryRef config,
544 CFStringRef passwordKey,
545 CFStringRef encryptionKey,
546 CFStringRef encryptionKeyChainValue,
547 CFStringRef unique_id,
548 CFDictionaryRef *newConfig);
549
550 Boolean
551 __rank_to_str (SCNetworkServicePrimaryRank rank,
552 CFStringRef *rankStr);
553
554 Boolean
555 __str_to_rank (CFStringRef rankStr,
556 SCNetworkServicePrimaryRank *rank);
557
558 __END_DECLS
559
560 #endif /* _SCNETWORKCONFIGURATIONINTERNAL_H */