]> git.saurik.com Git - apple/security.git/blob - OSX/sec/SOSCircle/SecureObjectSync/SOSCirclePriv.h
Security-57337.40.85.tar.gz
[apple/security.git] / OSX / sec / SOSCircle / SecureObjectSync / SOSCirclePriv.h
1 //
2 // SOSCirclePriv.h
3 // sec
4 //
5 // Created by Richard Murphy on 12/4/14.
6 //
7 //
8
9 #ifndef sec_SOSCirclePriv_h
10 #define sec_SOSCirclePriv_h
11
12 #include <CoreFoundation/CFRuntime.h>
13 #include <CoreFoundation/CoreFoundation.h>
14 #include <Security/SecureObjectSync/SOSGenCount.h>
15
16 enum {
17 kOnlyCompatibleVersion = 1, // Sometime in the future this name will be improved to reflect history.
18 kAlwaysIncompatibleVersion = UINT64_MAX,
19 };
20
21 struct __OpaqueSOSCircle {
22 CFRuntimeBase _base;
23 CFStringRef name;
24 SOSGenCountRef generation;
25 CFMutableSetRef peers;
26 CFMutableSetRef applicants;
27 CFMutableSetRef rejected_applicants;
28 CFMutableDictionaryRef signatures;
29 };
30
31
32 static inline void SOSCircleAssertStable(SOSCircleRef circle) {
33 assert(circle);
34 assert(circle->name);
35 assert(circle->generation);
36 assert(circle->peers);
37 assert(circle->applicants);
38 assert(circle->rejected_applicants);
39 assert(circle->signatures);
40 }
41
42
43 static inline SOSCircleRef SOSCircleConvertAndAssertStable(CFTypeRef circleAsType) {
44 if (CFGetTypeID(circleAsType) != SOSCircleGetTypeID()) return NULL;
45 SOSCircleRef circle = (SOSCircleRef) circleAsType;
46 SOSCircleAssertStable(circle);
47 return circle;
48 }
49
50
51 static inline bool SOSCircleIsOffering(SOSCircleRef circle) {
52 return SOSCircleCountRetiredPeers(circle) == 0 && SOSCircleCountPeers(circle) == 1;
53 }
54
55 #endif