]> git.saurik.com Git - apple/security.git/blob - base/SecSignpost.h
Security-59754.80.3.tar.gz
[apple/security.git] / base / SecSignpost.h
1 //
2 /*
3 * Copyright (c) 2017 Apple Inc. All Rights Reserved.
4 *
5 * @APPLE_LICENSE_HEADER_START@
6 *
7 * This file contains Original Code and/or Modifications of Original Code
8 * as defined in and that are subject to the Apple Public Source License
9 * Version 2.0 (the 'License'). You may not use this file except in
10 * compliance with the License. Please obtain a copy of the License at
11 * http://www.opensource.apple.com/apsl/ and read it before using this
12 * file.
13 *
14 * The Original Code and all software distributed under the License are
15 * distributed on an 'AS IS' basis, WITHOUT WARRANTY OF ANY KIND, EITHER
16 * EXPRESS OR IMPLIED, AND APPLE HEREBY DISCLAIMS ALL SUCH WARRANTIES,
17 * INCLUDING WITHOUT LIMITATION, ANY WARRANTIES OF MERCHANTABILITY,
18 * FITNESS FOR A PARTICULAR PURPOSE, QUIET ENJOYMENT OR NON-INFRINGEMENT.
19 * Please see the License for the specific language governing rights and
20 * limitations under the License.
21 *
22 * @APPLE_LICENSE_HEADER_END@
23 */
24
25 #ifndef _SECSIGNPOST_H_
26 #define _SECSIGNPOST_H_
27
28
29 #include <CoreFoundation/CoreFoundation.h>
30
31 #if !TARGET_IPHONE_SIMULATOR
32 #import <System/sys/kdebug.h>
33 #endif
34
35 /*
36 If you update this file, please also update SecurityCustomSignposts.plist.
37 */
38
39 static unsigned int SecSignpostComponent = 82;
40
41 typedef CF_ENUM(unsigned int, SecSignpostType) {
42 /* between 0 and SecSignpostImpulse, use every even number
43 * After SecSignpostImpulse, its free for all for custom impulse points
44 * Remeber to update SecurityCustomSignposts.plist
45 */
46 SecSignpostRestoreKeychain = 0,
47 SecSignpostRestoreOpenKeybag = 2,
48 SecSignpostUnlockKeybag = 4,
49 SecSignpostBackupKeychain = 6,
50 SecSignpostBackupOpenKeybag = 8,
51 SecSignpostUpgradePhase1 = 10,
52 SecSignpostUpgradePhase2 = 12,
53 SecSignpostBackupKeychainBackupable = 14,
54 SecSignpostRestoreKeychainBackupable = 16,
55
56 SecSignpostSecItemAdd = 18,
57 SecSignpostSecItemUpdate = 20,
58 SecSignpostSecItemDelete = 22,
59 SecSignpostSecItemCopyMatching = 24,
60
61
62 SecSignpostImpulse = 0x1000,
63 SecSignpostImpulseBackupClassCount = 0x1001,
64 SecSignpostImpulseRestoreClassCount = 0x1002,
65 };
66
67
68 static inline void SecSignpostStart(SecSignpostType type) {
69 #if !TARGET_IPHONE_SIMULATOR
70 kdebug_trace(ARIADNEDBG_CODE(SecSignpostComponent, type + 0), 0, 0, 0, 0);
71 #endif
72 }
73
74 static inline void SecSignpostStop(SecSignpostType type) {
75 #if !TARGET_IPHONE_SIMULATOR
76 kdebug_trace(ARIADNEDBG_CODE(SecSignpostComponent, type + 1), 0, 0, 0, 0);
77 #endif
78 }
79
80 static inline void SecSignpostBackupCount(SecSignpostType type,
81 CFStringRef cls,
82 CFIndex count,
83 unsigned filter) {
84 #if !TARGET_IPHONE_SIMULATOR
85 if (CFStringGetLength(cls) != 4)
86 return;
87 unsigned char ucls[5];
88 if (!CFStringGetCString(cls, (char *)ucls, sizeof(ucls), kCFStringEncodingUTF8))
89 return;
90 uint32_t c = (ucls[0] & 0xff) | (ucls[1] << 8) | (ucls[2] << 16) | (ucls[3] << 24);
91 kdebug_trace(ARIADNEDBG_CODE(SecSignpostComponent, type), c, count, filter, 0);
92 #endif
93 }
94
95
96 #endif /* _SECSIGNPOST_H_ */