Convert DEBUG_REFERRALS to TRACE_* framework
[krb5.git] / src / include / CredentialsCache2.h
1 /* -*- mode: c; c-basic-offset: 4; indent-tabs-mode: nil -*- */
2 /* include/CredentialsCache2.h */
3 /*
4  * Copyright 2006 Massachusetts Institute of Technology.
5  * All Rights Reserved.
6  *
7  * Export of this software from the United States of America may
8  * require a specific license from the United States Government.
9  * It is the responsibility of any person or organization contemplating
10  * export to obtain such a license before exporting.
11  *
12  * WITHIN THAT CONSTRAINT, permission to use, copy, modify, and
13  * distribute this software and its documentation for any purpose and
14  * without fee is hereby granted, provided that the above copyright
15  * notice appear in all copies and that both that copyright notice and
16  * this permission notice appear in supporting documentation, and that
17  * the name of M.I.T. not be used in advertising or publicity pertaining
18  * to distribution of the software without specific, written prior
19  * permission.  Furthermore if you modify this software you must label
20  * your software as modified software and not distribute it in such a
21  * fashion that it might be confused with the original M.I.T. software.
22  * M.I.T. makes no representations about the suitability of
23  * this software for any purpose.  It is provided "as is" without express
24  * or implied warranty.
25  */
26
27 /*
28  * This is backwards compatibility for CCache API v2 clients to be able to run
29  * against the CCache API v3 library
30  */
31
32 #ifndef CCAPI_V2_H
33 #define CCAPI_V2_H
34
35 #include <CredentialsCache.h>
36
37 #if defined(macintosh) || (defined(__MACH__) && defined(__APPLE__))
38 #include <TargetConditionals.h>
39 #include <AvailabilityMacros.h>
40 #ifdef DEPRECATED_IN_MAC_OS_X_VERSION_10_5_AND_LATER
41 #define CCAPI_DEPRECATED DEPRECATED_IN_MAC_OS_X_VERSION_10_5_AND_LATER
42 #endif
43 #endif
44
45 #ifndef CCAPI_DEPRECATED
46 #define CCAPI_DEPRECATED
47 #endif
48
49 #ifdef __cplusplus
50 extern "C" {
51 #endif /* __cplusplus */
52
53 #if TARGET_OS_MAC
54 #pragma pack(push,2)
55 #endif
56
57 /* Some old types get directly mapped to new types */
58
59 typedef cc_context_d apiCB;
60 typedef cc_ccache_d ccache_p;
61 typedef cc_credentials_iterator_d ccache_cit_creds;
62 typedef cc_ccache_iterator_d ccache_cit_ccache;
63 typedef cc_data cc_data_compat;
64 typedef cc_int32 cc_cred_vers;
65 typedef cc_int32 cc_result;
66
67 /* This doesn't exist in API v3 */
68 typedef cc_uint32 cc_flags;
69
70 /* Credentials types are visible to the caller so we have to keep binary compatibility */
71
72 typedef struct cc_credentials_v5_compat {
73     char*                       client;
74     char*                       server;
75     cc_data_compat              keyblock;
76     cc_time_t                   authtime;
77     cc_time_t                   starttime;
78     cc_time_t                   endtime;
79     cc_time_t                   renew_till;
80     cc_uint32                   is_skey;
81     cc_uint32                   ticket_flags;
82     cc_data_compat**            addresses;
83     cc_data_compat              ticket;
84     cc_data_compat              second_ticket;
85     cc_data_compat**            authdata;
86 } cc_credentials_v5_compat;
87
88 enum {
89     MAX_V4_CRED_LEN = 1250
90 };
91
92 enum {
93     KRB_NAME_SZ = 40,
94     KRB_INSTANCE_SZ = 40,
95     KRB_REALM_SZ = 40
96 };
97
98 typedef struct cc_credentials_v4_compat {
99     unsigned char       kversion;
100     char                principal[KRB_NAME_SZ+1];
101     char                principal_instance[KRB_INSTANCE_SZ+1];
102     char                service[KRB_NAME_SZ+1];
103     char                service_instance[KRB_INSTANCE_SZ+1];
104     char                realm[KRB_REALM_SZ+1];
105     unsigned char       session_key[8];
106     cc_int32            kvno;
107     cc_int32            str_to_key;
108     long                issue_date;
109     cc_int32            lifetime;
110     cc_uint32           address;
111     cc_int32            ticket_sz;
112     unsigned char       ticket[MAX_V4_CRED_LEN];
113     unsigned long       oops;
114 } cc_credentials_v4_compat;
115
116 typedef union cred_ptr_union_compat {
117     cc_credentials_v4_compat* pV4Cred;
118     cc_credentials_v5_compat* pV5Cred;
119 } cred_ptr_union_compat;
120
121 typedef struct cred_union {
122     cc_int32              cred_type;  /* cc_cred_vers */
123     cred_ptr_union_compat cred;
124 } cred_union;
125
126 /* NC info structure is gone in v3 */
127
128 struct infoNC {
129     char*       name;
130     char*       principal;
131     cc_int32    vers;
132 };
133
134 typedef struct infoNC infoNC;
135
136 /* Some old type names */
137
138 typedef cc_credentials_v4_compat V4Cred_type;
139 typedef cc_credentials_v5_compat cc_creds;
140 struct ccache_cit;
141 typedef struct ccache_cit ccache_cit;
142
143 enum {
144     CC_API_VER_2 = ccapi_version_2
145 };
146
147 enum {
148     CC_NOERROR,
149     CC_BADNAME,
150     CC_NOTFOUND,
151     CC_END,
152     CC_IO,
153     CC_WRITE,
154     CC_NOMEM,
155     CC_FORMAT,
156     CC_LOCKED,
157     CC_BAD_API_VERSION,
158     CC_NO_EXIST,
159     CC_NOT_SUPP,
160     CC_BAD_PARM,
161     CC_ERR_CACHE_ATTACH,
162     CC_ERR_CACHE_RELEASE,
163     CC_ERR_CACHE_FULL,
164     CC_ERR_CRED_VERSION
165 };
166
167 enum {
168     CC_CRED_UNKNOWN,
169     CC_CRED_V4,
170     CC_CRED_V5,
171     CC_CRED_MAX
172 };
173
174 enum {
175     CC_LOCK_UNLOCK = 1,
176     CC_LOCK_READER = 2,
177     CC_LOCK_WRITER = 3,
178     CC_LOCK_NOBLOCK = 16
179 };
180
181 CCACHE_API cc_int32
182 cc_shutdown (apiCB **io_context)
183     CCAPI_DEPRECATED;
184
185 CCACHE_API cc_int32
186 cc_get_NC_info (apiCB    *in_context,
187                 infoNC ***out_info)
188     CCAPI_DEPRECATED;
189
190 CCACHE_API cc_int32
191 cc_get_change_time (apiCB     *in_context,
192                     cc_time_t *out_change_time)
193     CCAPI_DEPRECATED;
194
195 CCACHE_API cc_int32
196 cc_open (apiCB       *in_context,
197          const char  *in_name,
198          cc_int32     in_version,
199          cc_uint32    in_flags,
200          ccache_p   **out_ccache)
201     CCAPI_DEPRECATED;
202
203 CCACHE_API cc_int32
204 cc_create (apiCB       *in_context,
205            const char  *in_name,
206            const char  *in_principal,
207            cc_int32     in_version,
208            cc_uint32    in_flags,
209            ccache_p   **out_ccache)
210     CCAPI_DEPRECATED;
211
212 CCACHE_API cc_int32
213 cc_close (apiCB     *in_context,
214           ccache_p **ioCCache)
215     CCAPI_DEPRECATED;
216
217 CCACHE_API cc_int32
218 cc_destroy (apiCB     *in_context,
219             ccache_p **io_ccache)
220     CCAPI_DEPRECATED;
221
222 CCACHE_API cc_int32
223 cc_seq_fetch_NCs_begin (apiCB       *in_context,
224                         ccache_cit **out_nc_iterator)
225     CCAPI_DEPRECATED;
226
227 CCACHE_API cc_int32
228 cc_seq_fetch_NCs_next (apiCB       *in_context,
229                        ccache_p   **out_ccache,
230                        ccache_cit  *in_nc_iterator)
231     CCAPI_DEPRECATED;
232
233 CCACHE_API cc_int32
234 cc_seq_fetch_NCs_end (apiCB       *in_context,
235                       ccache_cit **io_nc_iterator)
236     CCAPI_DEPRECATED;
237
238 CCACHE_API cc_int32
239 cc_get_name (apiCB     *in_context,
240              ccache_p  *in_ccache,
241              char     **out_name)
242     CCAPI_DEPRECATED;
243
244 CCACHE_API cc_int32
245 cc_get_cred_version (apiCB    *in_context,
246                      ccache_p *in_ccache,
247                      cc_int32 *out_version)
248     CCAPI_DEPRECATED;
249
250 CCACHE_API cc_int32
251 cc_set_principal (apiCB    *in_context,
252                   ccache_p *in_ccache,
253                   cc_int32  in_version,
254                   char     *in_principal)
255     CCAPI_DEPRECATED;
256
257 CCACHE_API cc_int32
258 cc_get_principal (apiCB     *in_context,
259                   ccache_p  *in_ccache,
260                   char     **out_principal)
261     CCAPI_DEPRECATED;
262
263 CCACHE_API cc_int32
264 cc_store (apiCB      *in_context,
265           ccache_p   *in_ccache,
266           cred_union  in_credentials)
267     CCAPI_DEPRECATED;
268
269 CCACHE_API cc_int32
270 cc_remove_cred (apiCB      *in_context,
271                 ccache_p   *in_ccache,
272                 cred_union  in_credentials)
273     CCAPI_DEPRECATED;
274
275 CCACHE_API cc_int32
276 cc_seq_fetch_creds_begin (apiCB           *in_context,
277                           const ccache_p  *in_ccache,
278                           ccache_cit     **out_ccache_iterator)
279     CCAPI_DEPRECATED;
280
281 CCACHE_API cc_int32
282 cc_seq_fetch_creds_next (apiCB       *in_context,
283                          cred_union **out_cred_union,
284                          ccache_cit  *in_ccache_iterator)
285     CCAPI_DEPRECATED;
286
287 CCACHE_API cc_int32
288 cc_seq_fetch_creds_end (apiCB       *in_context,
289                         ccache_cit **io_ccache_iterator)
290     CCAPI_DEPRECATED;
291
292 CCACHE_API cc_int32
293 cc_free_principal (apiCB  *in_context,
294                    char  **io_principal)
295     CCAPI_DEPRECATED;
296
297 CCACHE_API cc_int32
298 cc_free_name (apiCB  *in_context,
299               char  **io_name)
300     CCAPI_DEPRECATED;
301
302 CCACHE_API cc_int32
303 cc_free_creds (apiCB       *in_context,
304                cred_union **io_cred_union)
305     CCAPI_DEPRECATED;
306
307 CCACHE_API cc_int32
308 cc_free_NC_info (apiCB    *in_context,
309                  infoNC ***io_info)
310     CCAPI_DEPRECATED;
311
312 CCACHE_API cc_int32
313 cc_lock_request (apiCB          *in_context,
314                  const ccache_p *in_ccache,
315                  const cc_int32  in_lock_type)
316     CCAPI_DEPRECATED;
317
318 #if TARGET_OS_MAC
319 #pragma pack(pop)
320 #endif
321
322 #ifdef __cplusplus
323 }
324 #endif /* __cplusplus */
325
326 #endif /* CCAPI_V2_H */