]> git.saurik.com Git - apple/security.git/blob - OSX/sec/SOSCircle/SecureObjectSync/SOSTransportCircle.c
Security-57336.1.9.tar.gz
[apple/security.git] / OSX / sec / SOSCircle / SecureObjectSync / SOSTransportCircle.c
1
2 #include <CoreFoundation/CoreFoundation.h>
3 #include <Security/SecureObjectSync/SOSTransportCircle.h>
4 #include <Security/SecureObjectSync/SOSTransportCircleKVS.h>
5 #include <Security/SecureObjectSync/SOSTransport.h>
6 #include <Security/SecureObjectSync/SOSKVSKeys.h>
7 #include <Security/SecureObjectSync/SOSAccount.h>
8 #include <Security/SecureObjectSync/SOSAccountPriv.h>
9 #include <SOSPeerInfoDER.h>
10
11 #include <utilities/SecCFWrappers.h>
12 #include <SOSInternal.h>
13 #include <SOSCloudKeychainClient.h>
14 #include <AssertMacros.h>
15
16 CFGiblisWithCompareFor(SOSTransportCircle);
17
18 SOSTransportCircleRef SOSTransportCircleCreateForSubclass(size_t size, SOSAccountRef account, CFErrorRef *error)
19 {
20 SOSTransportCircleRef tpt = CFTypeAllocateWithSpace(SOSTransportCircle, size, kCFAllocatorDefault);
21 tpt->account = CFRetainSafe(account);
22 return tpt;
23 }
24
25 static CFStringRef SOSTransportCircleCopyFormatDescription(CFTypeRef aObj, CFDictionaryRef formatOptions) {
26 SOSTransportCircleRef t = (SOSTransportCircleRef) aObj;
27
28 return CFStringCreateWithFormat(NULL, NULL, CFSTR("<SOSTransportCircle@%p\n>"), t);
29 }
30
31 static void SOSTransportCircleDestroy(CFTypeRef aObj) {
32 SOSTransportCircleRef transport = (SOSTransportCircleRef) aObj;
33 if(transport->destroy)
34 transport->destroy(transport);
35 CFReleaseNull(transport->account);
36 }
37
38 static CFHashCode SOSTransportCircleHash(CFTypeRef obj)
39 {
40 return (intptr_t) obj;
41 }
42
43 static Boolean SOSTransportCircleCompare(CFTypeRef lhs, CFTypeRef rhs)
44 {
45 return SOSTransportCircleHash(lhs) == SOSTransportCircleHash(rhs);
46 }
47
48 SOSAccountRef SOSTransportCircleGetAccount(SOSTransportCircleRef transport){
49 return transport->account;
50 }
51
52 bool SOSTransportCircleFlushChanges(SOSTransportCircleRef transport, CFErrorRef *error) {
53 return transport->flushChanges(transport, error);
54 }
55
56 bool SOSTransportCirclePostCircle(SOSTransportCircleRef transport, CFStringRef circleName, CFDataRef circle_data, CFErrorRef *error) {
57 return transport->postCircle(transport, circleName, circle_data, error);
58 }
59 CF_RETURNS_RETAINED
60 CFDictionaryRef SOSTransportCircleHandleRetirementMessages(SOSTransportCircleRef transport, CFMutableDictionaryRef circle_retirement_messages_table, CFErrorRef *error) {
61 return transport->handleRetirementMessages(transport, circle_retirement_messages_table, error);
62 }
63
64 CF_RETURNS_RETAINED
65 CFArrayRef SOSTransportCircleHandleCircleMessages(SOSTransportCircleRef transport, CFMutableDictionaryRef circle_circle_messages_table, CFErrorRef *error) {
66 return transport->handleCircleMessages(transport, circle_circle_messages_table, error);
67 }
68
69 bool SOSTransportCirclePostRetirement(SOSTransportCircleRef transport, CFStringRef circleName, SOSPeerInfoRef peer, CFErrorRef *error) {
70 bool success = false;
71 CFDataRef retirement_data = NULL;
72
73 retirement_data = SOSPeerInfoCopyEncodedData(peer, kCFAllocatorDefault, error);
74
75 require_quiet(retirement_data, fail);
76
77 success = transport->postRetirement(transport, circleName, SOSPeerInfoGetPeerID(peer), retirement_data, error);
78
79 fail:
80 CFReleaseNull(retirement_data);
81 return success;
82 }
83
84 bool SOSTransportCircleExpireRetirementRecords(SOSTransportCircleRef transport, CFDictionaryRef retirements, CFErrorRef *error){
85 return transport->expireRetirementRecords(transport, retirements, error);
86 }
87
88 CFIndex SOSTransportCircleGetTransportType(SOSTransportCircleRef transport, CFErrorRef *error){
89 return transport->getTransportType ? transport->getTransportType(transport, error) : kUnknown;
90 }
91
92 bool SOSTransportCircleSendPeerInfo(SOSTransportCircleRef transport, CFStringRef peerID, CFDataRef peerInfoData, CFErrorRef *error){
93 return transport->sendPeerInfo(transport, peerID, peerInfoData, error);
94 }
95
96 bool SOSTransportCircleRingFlushChanges(SOSTransportCircleRef transport, CFErrorRef* error){
97 return transport->flushRingChanges(transport, error);
98 }
99
100 bool SOSTransportCircleRingPostRing(SOSTransportCircleRef transport, CFStringRef ringName, CFDataRef ring, CFErrorRef *error){
101 return transport->postRing(transport, ringName, ring, error);
102 }
103
104 bool SOSTransportCircleSendDebugInfo(SOSTransportCircleRef transport, CFStringRef type, CFTypeRef debugInfo, CFErrorRef *error){
105 return transport->sendDebugInfo(transport, type, debugInfo, error);
106 }
107
108 bool SOSTransportCircleSendAccountChangedWithDSID(SOSTransportCircleRef transport, CFStringRef dsid, CFErrorRef *error){
109 return transport->sendAccountChangedWithDSID(transport, dsid, error);
110 }
111
112