lib/krb5: unparse_name_fixed ERANGE if zero buffer len
[heimdal.git] / kdc / kdc-accessors.h
blob5eab2422a0145cea38c1cc9ae7e055a9bfaafdd6
1 /*
2 * Copyright (c) 2022, PADL Software Pty Ltd.
3 * All rights reserved.
5 * Redistribution and use in source and binary forms, with or without
6 * modification, are permitted provided that the following conditions
7 * are met:
9 * 1. Redistributions of source code must retain the above copyright
10 * notice, this list of conditions and the following disclaimer.
12 * 2. Redistributions in binary form must reproduce the above copyright
13 * notice, this list of conditions and the following disclaimer in the
14 * documentation and/or other materials provided with the distribution.
16 * 3. Neither the name of PADL Software nor the names of its contributors
17 * may be used to endorse or promote products derived from this software
18 * without specific prior written permission.
20 * THIS SOFTWARE IS PROVIDED BY PADL SOFTWARE AND CONTRIBUTORS ``AS IS'' AND
21 * ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
22 * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE
23 * ARE DISCLAIMED. IN NO EVENT SHALL PADL SOFTWARE OR CONTRIBUTORS BE LIABLE
24 * FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL
25 * DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS
26 * OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION)
27 * HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT
28 * LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY
29 * OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF
30 * SUCH DAMAGE.
33 #ifndef HEIMDAL_KDC_KDC_ACCESSORS_H
34 #define HEIMDAL_KDC_KDC_ACCESSORS_H 1
36 /* read-only accessor */
37 #ifndef _KDC_REQUEST_GET_ACCESSOR
38 #define _KDC_REQUEST_GET_ACCESSOR(R, T, f) \
39 T \
40 kdc_request_get_ ## f(R);
41 #endif
43 #ifndef _KDC_REQUEST_SET_ACCESSOR
44 #define _KDC_REQUEST_SET_ACCESSOR(R, T, f) \
45 void \
46 kdc_request_set_ ## f(R, T);
47 #endif
49 #ifndef KDC_REQUEST_GET_ACCESSOR
50 #define KDC_REQUEST_GET_ACCESSOR(T, f) \
51 _KDC_REQUEST_GET_ACCESSOR(kdc_request_t, T, f)
52 #endif
54 #ifndef KDC_REQUEST_SET_ACCESSOR
55 #define KDC_REQUEST_SET_ACCESSOR(T, f) \
56 _KDC_REQUEST_SET_ACCESSOR(kdc_request_t, T, f)
57 #endif
59 #ifndef ASTGS_REQUEST_GET_ACCESSOR
60 #define ASTGS_REQUEST_GET_ACCESSOR(T, f) \
61 _KDC_REQUEST_GET_ACCESSOR(astgs_request_t, T, f)
62 #endif
64 #ifndef ASTGS_REQUEST_SET_ACCESSOR
65 #define ASTGS_REQUEST_SET_ACCESSOR(T, f) \
66 _KDC_REQUEST_SET_ACCESSOR(astgs_request_t, T, f)
67 #endif
69 /* get/set accessor for pointer type */
70 #ifndef _KDC_REQUEST_GET_ACCESSOR_PTR
71 #define _KDC_REQUEST_GET_ACCESSOR_PTR(R, T, f) \
72 const T \
73 kdc_request_get_ ## f(R);
74 #endif
76 #ifndef _KDC_REQUEST_SET_ACCESSOR_PTR
77 #define _KDC_REQUEST_SET_ACCESSOR_PTR(R, T, t, f) \
78 krb5_error_code \
79 kdc_request_set_ ## f(R, const T);
80 #endif
82 #ifndef KDC_REQUEST_GET_ACCESSOR_PTR
83 #define KDC_REQUEST_GET_ACCESSOR_PTR(T, f) \
84 _KDC_REQUEST_GET_ACCESSOR_PTR(kdc_request_t, T, f)
85 #endif
87 #ifndef KDC_REQUEST_SET_ACCESSOR_PTR
88 #define KDC_REQUEST_SET_ACCESSOR_PTR(T, t, f) \
89 _KDC_REQUEST_SET_ACCESSOR_PTR(kdc_request_t, T, t, f)
90 #endif
92 #ifndef ASTGS_REQUEST_GET_ACCESSOR_PTR
93 #define ASTGS_REQUEST_GET_ACCESSOR_PTR(T, f) \
94 _KDC_REQUEST_GET_ACCESSOR_PTR(astgs_request_t, T, f)
95 #endif
97 #ifndef ASTGS_REQUEST_SET_ACCESSOR_PTR
98 #define ASTGS_REQUEST_SET_ACCESSOR_PTR(T, t, f) \
99 _KDC_REQUEST_SET_ACCESSOR_PTR(astgs_request_t, T, t, f)
100 #endif
102 /* get/set accessor for struct type */
103 #ifndef _KDC_REQUEST_GET_ACCESSOR_STRUCT
104 #define _KDC_REQUEST_GET_ACCESSOR_STRUCT(R, T, f) \
105 const T * \
106 kdc_request_get_ ## f(R);
107 #endif
109 #ifndef _KDC_REQUEST_SET_ACCESSOR_STRUCT
110 #define _KDC_REQUEST_SET_ACCESSOR_STRUCT(R, T, t, f) \
111 krb5_error_code \
112 kdc_request_set_ ## f(R, const T *);
113 #endif
115 #ifndef KDC_REQUEST_GET_ACCESSOR_STRUCT
116 #define KDC_REQUEST_GET_ACCESSOR_STRUCT(T, f) \
117 _KDC_REQUEST_GET_ACCESSOR_STRUCT(kdc_request_t, T, f)
118 #endif
120 #ifndef KDC_REQUEST_SET_ACCESSOR_STRUCT
121 #define KDC_REQUEST_SET_ACCESSOR_STRUCT(T, t, f) \
122 _KDC_REQUEST_SET_ACCESSOR_STRUCT(kdc_request_t, T, t, f)
123 #endif
125 #ifndef ASTGS_REQUEST_GET_ACCESSOR_STRUCT
126 #define ASTGS_REQUEST_GET_ACCESSOR_STRUCT(T, f) \
127 _KDC_REQUEST_GET_ACCESSOR_STRUCT(astgs_request_t, T, f)
128 #endif
130 #ifndef ASTGS_REQUEST_SET_ACCESSOR_STRUCT
131 #define ASTGS_REQUEST_SET_ACCESSOR_STRUCT(T, t, f) \
132 _KDC_REQUEST_SET_ACCESSOR_STRUCT(astgs_request_t, T, t, f)
133 #endif
136 * krb5_context
137 * kdc_request_get_context(kdc_request_t);
140 KDC_REQUEST_GET_ACCESSOR(krb5_context, context)
143 * krb5_kdc_configuration *
144 * kdc_request_get_config(kdc_request_t);
147 KDC_REQUEST_GET_ACCESSOR(krb5_kdc_configuration *, config)
150 * heim_log_facility *
151 * kdc_request_get_logf(kdc_request_t);
154 KDC_REQUEST_GET_ACCESSOR(heim_log_facility *, logf)
157 * const char *
158 * kdc_request_get_from(kdc_request_t);
161 KDC_REQUEST_GET_ACCESSOR_PTR(char *, from)
164 * const struct sockaddr *
165 * kdc_request_get_addr(kdc_request_t);
168 KDC_REQUEST_GET_ACCESSOR_PTR(struct sockaddr *, addr)
171 * krb5_data
172 * kdc_request_get_request(kdc_request_t);
175 KDC_REQUEST_GET_ACCESSOR(krb5_data, request)
178 * struct timeval
179 * kdc_request_get_tv_start(kdc_request_t);
182 KDC_REQUEST_GET_ACCESSOR(struct timeval, tv_start)
185 * struct timeval
186 * kdc_request_get_tv_end(kdc_request_t);
189 KDC_REQUEST_GET_ACCESSOR(struct timeval, tv_end)
192 * krb5_error_code
193 * kdc_request_get_error_code(kdc_request_t);
195 KDC_REQUEST_GET_ACCESSOR(krb5_error_code, error_code)
198 * void
199 * kdc_request_set_error_code(kdc_request_t, krb5_error_code);
201 KDC_REQUEST_SET_ACCESSOR(krb5_error_code, error_code)
204 * const KDC_REQ *
205 * kdc_request_get_req(astgs_request_t);
208 ASTGS_REQUEST_GET_ACCESSOR_STRUCT(KDC_REQ, req)
211 * const KDC_REP *
212 * kdc_request_get_rep(astgs_request_t);
215 ASTGS_REQUEST_GET_ACCESSOR_STRUCT(KDC_REP, rep)
218 * krb5_error_code
219 * kdc_request_set_rep(astgs_request_t, const KDC_REP *);
222 ASTGS_REQUEST_SET_ACCESSOR_STRUCT(KDC_REP, KDC_REP, rep)
225 * const char *
226 * kdc_request_get_cname(kdc_request_t);
229 KDC_REQUEST_GET_ACCESSOR_PTR(char *, cname)
232 * krb5_error_code
233 * kdc_request_set_cname(kdc_request_t, const char *);
236 KDC_REQUEST_SET_ACCESSOR_PTR(char *, string_ptr, cname)
239 * const Principal *
240 * kdc_request_get_client_princ(astgs_request_t);
243 ASTGS_REQUEST_GET_ACCESSOR_PTR(Principal *, client_princ)
246 * krb5_error_code
247 * kdc_request_set_client_princ(astgs_request_t, const Principal *);
250 ASTGS_REQUEST_SET_ACCESSOR_PTR(Principal *, Principal_ptr, client_princ)
253 * const Principal *
254 * kdc_request_get_canon_client_princ(astgs_request_t);
257 ASTGS_REQUEST_GET_ACCESSOR_PTR(Principal *, canon_client_princ)
260 * krb5_error_code
261 * kdc_request_set_canon_client_princ(astgs_request_t, const Principal *);
264 ASTGS_REQUEST_SET_ACCESSOR_PTR(Principal *, Principal_ptr, canon_client_princ)
267 * const HDB *
268 * kdc_request_get_clientdb(astgs_request_t);
271 ASTGS_REQUEST_GET_ACCESSOR_PTR(HDB *, clientdb)
274 * const hdb_entry *
275 * kdc_request_get_client(astgs_request_t);
278 ASTGS_REQUEST_GET_ACCESSOR_PTR(hdb_entry *, client)
281 * See client accessors
284 KDC_REQUEST_GET_ACCESSOR_PTR(char *, sname)
285 KDC_REQUEST_SET_ACCESSOR_PTR(char *, string_ptr, sname)
286 ASTGS_REQUEST_GET_ACCESSOR_PTR(Principal *, server_princ)
287 ASTGS_REQUEST_SET_ACCESSOR_PTR(Principal *, Principal_ptr, server_princ)
288 ASTGS_REQUEST_GET_ACCESSOR_PTR(HDB *, serverdb)
289 ASTGS_REQUEST_GET_ACCESSOR_PTR(hdb_entry *, server)
292 * See client accessors
295 ASTGS_REQUEST_GET_ACCESSOR_PTR(Principal *, krbtgt_princ)
296 ASTGS_REQUEST_SET_ACCESSOR_PTR(Principal *, Principal_ptr, krbtgt_princ)
297 ASTGS_REQUEST_GET_ACCESSOR_PTR(HDB *, krbtgtdb)
298 ASTGS_REQUEST_GET_ACCESSOR_PTR(hdb_entry *, krbtgt)
301 * krb5_ticket *
302 * kdc_request_get_ticket(astgs_request_t);
305 ASTGS_REQUEST_GET_ACCESSOR(krb5_ticket *, ticket)
308 * const krb5_keyblock *
309 * kdc_request_get_reply_key(astgs_request_t);
312 ASTGS_REQUEST_GET_ACCESSOR_STRUCT(krb5_keyblock, reply_key)
315 * krb5_error_code
316 * kdc_request_set_reply_key(astgs_request_t, const krb5_keyblock *);
319 ASTGS_REQUEST_SET_ACCESSOR_STRUCT(krb5_keyblock, keyblock, reply_key)
322 * krb5_const_pac
323 * kdc_request_get_pac(astgs_request_t);
326 ASTGS_REQUEST_GET_ACCESSOR_PTR(struct krb5_pac_data *, pac)
329 * krb5_error_code
330 * kdc_request_set_pac(astgs_request_t, krb5_const_pac);
333 ASTGS_REQUEST_SET_ACCESSOR_PTR(struct krb5_pac_data *, pac, pac)
336 * uint64_t
337 * kdc_request_get_pac_attributes(astgs_request_t);
340 ASTGS_REQUEST_GET_ACCESSOR(uint64_t, pac_attributes)
343 * void
344 * kdc_request_set_pac_attributes(astgs_request_t, uint64_t);
347 ASTGS_REQUEST_SET_ACCESSOR(uint64_t, pac_attributes)
349 #endif /* HEIMDAL_KDC_KDC_ACCESSORS_H */