1#ifndef _mach_voucher_server_
2#define _mach_voucher_server_
3
4/* Module mach_voucher */
5
6#include <string.h>
7#include <mach/ndr.h>
8#include <mach/boolean.h>
9#include <mach/kern_return.h>
10#include <mach/notify.h>
11#include <mach/mach_types.h>
12#include <mach/message.h>
13#include <mach/mig_errors.h>
14#include <mach/port.h>
15
16/* BEGIN MIG_STRNCPY_ZEROFILL CODE */
17
18#if defined(__has_include)
19#if __has_include(<mach/mig_strncpy_zerofill_support.h>)
20#ifndef USING_MIG_STRNCPY_ZEROFILL
21#define USING_MIG_STRNCPY_ZEROFILL
22#endif
23#ifndef __MIG_STRNCPY_ZEROFILL_FORWARD_TYPE_DECLS__
24#define __MIG_STRNCPY_ZEROFILL_FORWARD_TYPE_DECLS__
25#ifdef __cplusplus
26extern "C" {
27#endif
28#ifndef __MIG_STRNCPY_ZEROFILL_FORWARD_TYPE_DECLS_CSTRING_ATTR
29#define __MIG_STRNCPY_ZEROFILL_FORWARD_TYPE_DECLS_CSTRING_COUNTEDBY_ATTR(C) __unsafe_indexable
30#endif
31 extern int mig_strncpy_zerofill(char * dest, const char * src, int len) __attribute__((weak_import));
32#ifdef __cplusplus
33}
34#endif
35#endif /* __MIG_STRNCPY_ZEROFILL_FORWARD_TYPE_DECLS__ */
36#endif /* __has_include(<mach/mig_strncpy_zerofill_support.h>) */
37#endif /* __has_include */
38
39/* END MIG_STRNCPY_ZEROFILL CODE */
40
41
42#ifdef AUTOTEST
43#ifndef FUNCTION_PTR_T
44#define FUNCTION_PTR_T
45typedef void (*function_ptr_t)(mach_port_t, char *, mach_msg_type_number_t);
46typedef struct {
47 char * name;
48 function_ptr_t function;
49} function_table_entry;
50typedef function_table_entry *function_table_t;
51#endif /* FUNCTION_PTR_T */
52#endif /* AUTOTEST */
53
54#ifndef mach_voucher_MSG_COUNT
55#define mach_voucher_MSG_COUNT 5
56#endif /* mach_voucher_MSG_COUNT */
57
58#include <Availability.h>
59#include <mach/std_types.h>
60#include <mach/mig.h>
61#include <ipc/ipc_voucher.h>
62#include <kern/ipc_kobject.h>
63#include <kern/ipc_tt.h>
64#include <kern/ipc_host.h>
65#include <kern/ledger.h>
66#include <kern/processor.h>
67#include <kern/sync_sema.h>
68#include <ipc/ipc_eventlink.h>
69#include <vm/memory_object.h>
70#include <vm/vm_map.h>
71#include <kern/arcade.h>
72#include <kern/ipc_mig.h>
73#include <kern/task_ident.h>
74#include <kern/kern_cdata.h>
75#include <mach/mig.h>
76#include <mach/mach_types.h>
77
78#ifdef __BeforeMigServerHeader
79__BeforeMigServerHeader
80#endif /* __BeforeMigServerHeader */
81
82#ifndef MIG_SERVER_ROUTINE
83#define MIG_SERVER_ROUTINE
84#endif
85
86
87/* Routine mach_voucher_extract_attr_content */
88#ifdef mig_external
89mig_external
90#else
91extern
92#endif /* mig_external */
93MIG_SERVER_ROUTINE
94kern_return_t mach_voucher_extract_attr_content
95(
96 ipc_voucher_t voucher,
97 mach_voucher_attr_key_t key,
98 mach_voucher_attr_content_t content,
99 mach_msg_type_number_t *contentCnt
100);
101
102/* Routine mach_voucher_extract_attr_recipe */
103#ifdef mig_external
104mig_external
105#else
106extern
107#endif /* mig_external */
108MIG_SERVER_ROUTINE
109kern_return_t mach_voucher_extract_attr_recipe
110(
111 ipc_voucher_t voucher,
112 mach_voucher_attr_key_t key,
113 mach_voucher_attr_raw_recipe_t recipe,
114 mach_msg_type_number_t *recipeCnt
115);
116
117/* Routine mach_voucher_extract_all_attr_recipes */
118#ifdef mig_external
119mig_external
120#else
121extern
122#endif /* mig_external */
123MIG_SERVER_ROUTINE
124kern_return_t mach_voucher_extract_all_attr_recipes
125(
126 ipc_voucher_t voucher,
127 mach_voucher_attr_raw_recipe_array_t recipes,
128 mach_msg_type_number_t *recipesCnt
129);
130
131/* Routine mach_voucher_attr_command */
132#ifdef mig_external
133mig_external
134#else
135extern
136#endif /* mig_external */
137MIG_SERVER_ROUTINE
138kern_return_t mach_voucher_attr_command
139(
140 ipc_voucher_t voucher,
141 mach_voucher_attr_key_t key,
142 mach_voucher_attr_command_t command,
143 mach_voucher_attr_content_t in_content,
144 mach_msg_type_number_t in_contentCnt,
145 mach_voucher_attr_content_t out_content,
146 mach_msg_type_number_t *out_contentCnt
147);
148
149/* Routine mach_voucher_debug_info */
150#ifdef mig_external
151mig_external
152#else
153extern
154#endif /* mig_external */
155MIG_SERVER_ROUTINE
156kern_return_t mach_voucher_debug_info
157(
158 ipc_space_read_t task,
159 mach_port_name_t voucher_name,
160 mach_voucher_attr_raw_recipe_array_t recipes,
161 mach_msg_type_number_t *recipesCnt
162);
163
164#ifdef mig_external
165mig_external
166#else
167extern
168#endif /* mig_external */
169boolean_t mach_voucher_server(
170 mach_msg_header_t *InHeadP,
171 void *InDataP,
172 mach_msg_max_trailer_t *InTrailerP,
173 mach_msg_header_t *OutHeadP,
174 void *OutDataP);
175
176#ifdef mig_external
177mig_external
178#else
179extern
180#endif /* mig_external */
181mig_kern_routine_t mach_voucher_server_routine(
182 mach_msg_header_t *InHeadP);
183
184
185/* Description of this kernel subsystem, for use in direct RPC */
186extern const struct mach_voucher_subsystem {
187 mig_kern_server_routine_t kserver; /* Server routine */
188 mach_msg_id_t start; /* Min routine number */
189 mach_msg_id_t end; /* Max routine number + 1 */
190 unsigned int maxsize; /* Max msg size */
191 vm_address_t reserved; /* Reserved */
192 struct kern_routine_descriptor /* Array of routine descriptors */
193 kroutine[5];
194} mach_voucher_subsystem;
195
196/* typedefs for all requests */
197
198#ifndef __Request__mach_voucher_subsystem__defined
199#define __Request__mach_voucher_subsystem__defined
200
201#ifdef __MigPackStructs
202#pragma pack(push, 4)
203#endif
204 typedef struct {
205 mach_msg_header_t Head;
206 NDR_record_t NDR;
207 mach_voucher_attr_key_t key;
208 mach_msg_type_number_t contentCnt;
209 } __Request__mach_voucher_extract_attr_content_t __attribute__((unused));
210#ifdef __MigPackStructs
211#pragma pack(pop)
212#endif
213/* Struct for kernel processed data (Header + Descriptors) */
214#ifdef __MigPackStructs
215#pragma pack(push, 4)
216#endif
217 typedef struct {
218 mach_msg_header_t Head;
219 } __RequestKData__mach_voucher_extract_attr_content_t __attribute__((unused));
220#ifdef __MigPackStructs
221#pragma pack(pop)
222#endif
223/* Struct for pure user data */
224#ifdef __MigPackStructs
225#pragma pack(push, 4)
226#endif
227 typedef struct {
228 NDR_record_t NDR;
229 mach_voucher_attr_key_t key;
230 mach_msg_type_number_t contentCnt;
231 char padding[0]; /* Avoid generating empty UData structs */
232 } __RequestUData__mach_voucher_extract_attr_content_t __attribute__((unused));
233#ifdef __MigPackStructs
234#pragma pack(pop)
235#endif
236
237#ifdef __MigPackStructs
238#pragma pack(push, 4)
239#endif
240 typedef struct {
241 mach_msg_header_t Head;
242 NDR_record_t NDR;
243 mach_voucher_attr_key_t key;
244 mach_msg_type_number_t recipeCnt;
245 } __Request__mach_voucher_extract_attr_recipe_t __attribute__((unused));
246#ifdef __MigPackStructs
247#pragma pack(pop)
248#endif
249/* Struct for kernel processed data (Header + Descriptors) */
250#ifdef __MigPackStructs
251#pragma pack(push, 4)
252#endif
253 typedef struct {
254 mach_msg_header_t Head;
255 } __RequestKData__mach_voucher_extract_attr_recipe_t __attribute__((unused));
256#ifdef __MigPackStructs
257#pragma pack(pop)
258#endif
259/* Struct for pure user data */
260#ifdef __MigPackStructs
261#pragma pack(push, 4)
262#endif
263 typedef struct {
264 NDR_record_t NDR;
265 mach_voucher_attr_key_t key;
266 mach_msg_type_number_t recipeCnt;
267 char padding[0]; /* Avoid generating empty UData structs */
268 } __RequestUData__mach_voucher_extract_attr_recipe_t __attribute__((unused));
269#ifdef __MigPackStructs
270#pragma pack(pop)
271#endif
272
273#ifdef __MigPackStructs
274#pragma pack(push, 4)
275#endif
276 typedef struct {
277 mach_msg_header_t Head;
278 NDR_record_t NDR;
279 mach_msg_type_number_t recipesCnt;
280 } __Request__mach_voucher_extract_all_attr_recipes_t __attribute__((unused));
281#ifdef __MigPackStructs
282#pragma pack(pop)
283#endif
284/* Struct for kernel processed data (Header + Descriptors) */
285#ifdef __MigPackStructs
286#pragma pack(push, 4)
287#endif
288 typedef struct {
289 mach_msg_header_t Head;
290 } __RequestKData__mach_voucher_extract_all_attr_recipes_t __attribute__((unused));
291#ifdef __MigPackStructs
292#pragma pack(pop)
293#endif
294/* Struct for pure user data */
295#ifdef __MigPackStructs
296#pragma pack(push, 4)
297#endif
298 typedef struct {
299 NDR_record_t NDR;
300 mach_msg_type_number_t recipesCnt;
301 char padding[0]; /* Avoid generating empty UData structs */
302 } __RequestUData__mach_voucher_extract_all_attr_recipes_t __attribute__((unused));
303#ifdef __MigPackStructs
304#pragma pack(pop)
305#endif
306
307#ifdef __MigPackStructs
308#pragma pack(push, 4)
309#endif
310 typedef struct {
311 mach_msg_header_t Head;
312 NDR_record_t NDR;
313 mach_voucher_attr_key_t key;
314 mach_voucher_attr_command_t command;
315 mach_msg_type_number_t in_contentCnt;
316 uint8_t in_content[4096];
317 mach_msg_type_number_t out_contentCnt;
318 } __Request__mach_voucher_attr_command_t __attribute__((unused));
319#ifdef __MigPackStructs
320#pragma pack(pop)
321#endif
322/* Struct for kernel processed data (Header + Descriptors) */
323#ifdef __MigPackStructs
324#pragma pack(push, 4)
325#endif
326 typedef struct {
327 mach_msg_header_t Head;
328 } __RequestKData__mach_voucher_attr_command_t __attribute__((unused));
329#ifdef __MigPackStructs
330#pragma pack(pop)
331#endif
332/* Struct for pure user data */
333#ifdef __MigPackStructs
334#pragma pack(push, 4)
335#endif
336 typedef struct {
337 NDR_record_t NDR;
338 mach_voucher_attr_key_t key;
339 mach_voucher_attr_command_t command;
340 mach_msg_type_number_t in_contentCnt;
341 uint8_t in_content[4096];
342 mach_msg_type_number_t out_contentCnt;
343 char padding[0]; /* Avoid generating empty UData structs */
344 } __RequestUData__mach_voucher_attr_command_t __attribute__((unused));
345#ifdef __MigPackStructs
346#pragma pack(pop)
347#endif
348
349#ifdef __MigPackStructs
350#pragma pack(push, 4)
351#endif
352 typedef struct {
353 mach_msg_header_t Head;
354 NDR_record_t NDR;
355 mach_port_name_t voucher_name;
356 mach_msg_type_number_t recipesCnt;
357 } __Request__mach_voucher_debug_info_t __attribute__((unused));
358#ifdef __MigPackStructs
359#pragma pack(pop)
360#endif
361/* Struct for kernel processed data (Header + Descriptors) */
362#ifdef __MigPackStructs
363#pragma pack(push, 4)
364#endif
365 typedef struct {
366 mach_msg_header_t Head;
367 } __RequestKData__mach_voucher_debug_info_t __attribute__((unused));
368#ifdef __MigPackStructs
369#pragma pack(pop)
370#endif
371/* Struct for pure user data */
372#ifdef __MigPackStructs
373#pragma pack(push, 4)
374#endif
375 typedef struct {
376 NDR_record_t NDR;
377 mach_port_name_t voucher_name;
378 mach_msg_type_number_t recipesCnt;
379 char padding[0]; /* Avoid generating empty UData structs */
380 } __RequestUData__mach_voucher_debug_info_t __attribute__((unused));
381#ifdef __MigPackStructs
382#pragma pack(pop)
383#endif
384#endif /* !__Request__mach_voucher_subsystem__defined */
385
386
387/* union of all requests */
388
389#ifndef __RequestUnion__mach_voucher_subsystem__defined
390#define __RequestUnion__mach_voucher_subsystem__defined
391union __RequestUnion__mach_voucher_subsystem {
392 __Request__mach_voucher_extract_attr_content_t Request_mach_voucher_extract_attr_content;
393 __Request__mach_voucher_extract_attr_recipe_t Request_mach_voucher_extract_attr_recipe;
394 __Request__mach_voucher_extract_all_attr_recipes_t Request_mach_voucher_extract_all_attr_recipes;
395 __Request__mach_voucher_attr_command_t Request_mach_voucher_attr_command;
396 __Request__mach_voucher_debug_info_t Request_mach_voucher_debug_info;
397};
398#endif /* __RequestUnion__mach_voucher_subsystem__defined */
399/* typedefs for all replies */
400
401#ifndef __Reply__mach_voucher_subsystem__defined
402#define __Reply__mach_voucher_subsystem__defined
403
404#ifdef __MigPackStructs
405#pragma pack(push, 4)
406#endif
407 typedef struct {
408 mach_msg_header_t Head;
409 NDR_record_t NDR;
410 kern_return_t RetCode;
411 mach_msg_type_number_t contentCnt;
412 uint8_t content[4096];
413 } __Reply__mach_voucher_extract_attr_content_t __attribute__((unused));
414#ifdef __MigPackStructs
415#pragma pack(pop)
416#endif
417/* Struct for kernel processed data (Header + Descriptors) */
418#ifdef __MigPackStructs
419#pragma pack(push, 4)
420#endif
421 typedef struct {
422 mach_msg_header_t Head;
423 } __ReplyKData__mach_voucher_extract_attr_content_t __attribute__((unused));
424#ifdef __MigPackStructs
425#pragma pack(pop)
426#endif
427/* Struct for pure user data */
428#ifdef __MigPackStructs
429#pragma pack(push, 4)
430#endif
431 typedef struct {
432 NDR_record_t NDR;
433 kern_return_t RetCode;
434 mach_msg_type_number_t contentCnt;
435 uint8_t content[4096];
436 char padding[0]; /* Avoid generating empty UData structs */
437 } __ReplyUData__mach_voucher_extract_attr_content_t __attribute__((unused));
438#ifdef __MigPackStructs
439#pragma pack(pop)
440#endif
441
442#ifdef __MigPackStructs
443#pragma pack(push, 4)
444#endif
445 typedef struct {
446 mach_msg_header_t Head;
447 NDR_record_t NDR;
448 kern_return_t RetCode;
449 mach_msg_type_number_t recipeCnt;
450 uint8_t recipe[4096];
451 } __Reply__mach_voucher_extract_attr_recipe_t __attribute__((unused));
452#ifdef __MigPackStructs
453#pragma pack(pop)
454#endif
455/* Struct for kernel processed data (Header + Descriptors) */
456#ifdef __MigPackStructs
457#pragma pack(push, 4)
458#endif
459 typedef struct {
460 mach_msg_header_t Head;
461 } __ReplyKData__mach_voucher_extract_attr_recipe_t __attribute__((unused));
462#ifdef __MigPackStructs
463#pragma pack(pop)
464#endif
465/* Struct for pure user data */
466#ifdef __MigPackStructs
467#pragma pack(push, 4)
468#endif
469 typedef struct {
470 NDR_record_t NDR;
471 kern_return_t RetCode;
472 mach_msg_type_number_t recipeCnt;
473 uint8_t recipe[4096];
474 char padding[0]; /* Avoid generating empty UData structs */
475 } __ReplyUData__mach_voucher_extract_attr_recipe_t __attribute__((unused));
476#ifdef __MigPackStructs
477#pragma pack(pop)
478#endif
479
480#ifdef __MigPackStructs
481#pragma pack(push, 4)
482#endif
483 typedef struct {
484 mach_msg_header_t Head;
485 NDR_record_t NDR;
486 kern_return_t RetCode;
487 mach_msg_type_number_t recipesCnt;
488 uint8_t recipes[5120];
489 } __Reply__mach_voucher_extract_all_attr_recipes_t __attribute__((unused));
490#ifdef __MigPackStructs
491#pragma pack(pop)
492#endif
493/* Struct for kernel processed data (Header + Descriptors) */
494#ifdef __MigPackStructs
495#pragma pack(push, 4)
496#endif
497 typedef struct {
498 mach_msg_header_t Head;
499 } __ReplyKData__mach_voucher_extract_all_attr_recipes_t __attribute__((unused));
500#ifdef __MigPackStructs
501#pragma pack(pop)
502#endif
503/* Struct for pure user data */
504#ifdef __MigPackStructs
505#pragma pack(push, 4)
506#endif
507 typedef struct {
508 NDR_record_t NDR;
509 kern_return_t RetCode;
510 mach_msg_type_number_t recipesCnt;
511 uint8_t recipes[5120];
512 char padding[0]; /* Avoid generating empty UData structs */
513 } __ReplyUData__mach_voucher_extract_all_attr_recipes_t __attribute__((unused));
514#ifdef __MigPackStructs
515#pragma pack(pop)
516#endif
517
518#ifdef __MigPackStructs
519#pragma pack(push, 4)
520#endif
521 typedef struct {
522 mach_msg_header_t Head;
523 NDR_record_t NDR;
524 kern_return_t RetCode;
525 mach_msg_type_number_t out_contentCnt;
526 uint8_t out_content[4096];
527 } __Reply__mach_voucher_attr_command_t __attribute__((unused));
528#ifdef __MigPackStructs
529#pragma pack(pop)
530#endif
531/* Struct for kernel processed data (Header + Descriptors) */
532#ifdef __MigPackStructs
533#pragma pack(push, 4)
534#endif
535 typedef struct {
536 mach_msg_header_t Head;
537 } __ReplyKData__mach_voucher_attr_command_t __attribute__((unused));
538#ifdef __MigPackStructs
539#pragma pack(pop)
540#endif
541/* Struct for pure user data */
542#ifdef __MigPackStructs
543#pragma pack(push, 4)
544#endif
545 typedef struct {
546 NDR_record_t NDR;
547 kern_return_t RetCode;
548 mach_msg_type_number_t out_contentCnt;
549 uint8_t out_content[4096];
550 char padding[0]; /* Avoid generating empty UData structs */
551 } __ReplyUData__mach_voucher_attr_command_t __attribute__((unused));
552#ifdef __MigPackStructs
553#pragma pack(pop)
554#endif
555
556#ifdef __MigPackStructs
557#pragma pack(push, 4)
558#endif
559 typedef struct {
560 mach_msg_header_t Head;
561 NDR_record_t NDR;
562 kern_return_t RetCode;
563 mach_msg_type_number_t recipesCnt;
564 uint8_t recipes[5120];
565 } __Reply__mach_voucher_debug_info_t __attribute__((unused));
566#ifdef __MigPackStructs
567#pragma pack(pop)
568#endif
569/* Struct for kernel processed data (Header + Descriptors) */
570#ifdef __MigPackStructs
571#pragma pack(push, 4)
572#endif
573 typedef struct {
574 mach_msg_header_t Head;
575 } __ReplyKData__mach_voucher_debug_info_t __attribute__((unused));
576#ifdef __MigPackStructs
577#pragma pack(pop)
578#endif
579/* Struct for pure user data */
580#ifdef __MigPackStructs
581#pragma pack(push, 4)
582#endif
583 typedef struct {
584 NDR_record_t NDR;
585 kern_return_t RetCode;
586 mach_msg_type_number_t recipesCnt;
587 uint8_t recipes[5120];
588 char padding[0]; /* Avoid generating empty UData structs */
589 } __ReplyUData__mach_voucher_debug_info_t __attribute__((unused));
590#ifdef __MigPackStructs
591#pragma pack(pop)
592#endif
593#endif /* !__Reply__mach_voucher_subsystem__defined */
594
595
596/* union of all replies */
597
598#ifndef __ReplyUnion__mach_voucher_subsystem__defined
599#define __ReplyUnion__mach_voucher_subsystem__defined
600union __ReplyUnion__mach_voucher_subsystem {
601 __Reply__mach_voucher_extract_attr_content_t Reply_mach_voucher_extract_attr_content;
602 __Reply__mach_voucher_extract_attr_recipe_t Reply_mach_voucher_extract_attr_recipe;
603 __Reply__mach_voucher_extract_all_attr_recipes_t Reply_mach_voucher_extract_all_attr_recipes;
604 __Reply__mach_voucher_attr_command_t Reply_mach_voucher_attr_command;
605 __Reply__mach_voucher_debug_info_t Reply_mach_voucher_debug_info;
606};
607#endif /* __ReplyUnion__mach_voucher_subsystem__defined */
608
609#ifndef subsystem_to_name_map_mach_voucher
610#define subsystem_to_name_map_mach_voucher \
611 { "mach_voucher_extract_attr_content", 5400 },\
612 { "mach_voucher_extract_attr_recipe", 5401 },\
613 { "mach_voucher_extract_all_attr_recipes", 5402 },\
614 { "mach_voucher_attr_command", 5403 },\
615 { "mach_voucher_debug_info", 5404 }
616#endif
617
618#ifdef __AfterMigServerHeader
619__AfterMigServerHeader
620#endif /* __AfterMigServerHeader */
621
622#endif /* _mach_voucher_server_ */
623