5 // Created by Richard Murphy on 12/4/14.
9 #ifndef sec_SOSCirclePriv_h
10 #define sec_SOSCirclePriv_h
12 #include <CoreFoundation/CFRuntime.h>
13 #include <CoreFoundation/CoreFoundation.h>
14 #include "keychain/SecureObjectSync/SOSGenCount.h"
16 #include <security_utilities/simulatecrash_assert.h>
19 kOnlyCompatibleVersion
= 1, // Sometime in the future this name will be improved to reflect history.
20 kAlwaysIncompatibleVersion
= UINT64_MAX
,
23 struct __OpaqueSOSCircle
{
26 SOSGenCountRef generation
;
27 CFMutableSetRef peers
;
28 CFMutableSetRef applicants
;
29 CFMutableSetRef rejected_applicants
;
30 CFMutableDictionaryRef signatures
;
34 static inline void SOSCircleAssertStable(SOSCircleRef circle
) {
37 assert(circle
->generation
);
38 assert(circle
->peers
);
39 assert(circle
->applicants
);
40 assert(circle
->rejected_applicants
);
41 assert(circle
->signatures
);
45 static inline SOSCircleRef
SOSCircleConvertAndAssertStable(CFTypeRef circleAsType
) {
46 if (CFGetTypeID(circleAsType
) != SOSCircleGetTypeID()) return NULL
;
47 SOSCircleRef circle
= (SOSCircleRef
) circleAsType
;
48 SOSCircleAssertStable(circle
);
53 static inline bool SOSCircleIsOffering(SOSCircleRef circle
) {
54 return SOSCircleCountRetiredPeers(circle
) == 0 && SOSCircleCountPeers(circle
) == 1;