]> git.saurik.com Git - apple/security.git/blob - cdsa/cdsa_utilities/mach_notify.c
Security-179.tar.gz
[apple/security.git] / cdsa / cdsa_utilities / mach_notify.c
1 /*
2 * IDENTIFICATION:
3 * stub generated Fri Mar 1 18:02:22 2002
4 * with a MiG generated Thu Feb 21 15:16:47 PST 2002 by root@blur
5 * OPTIONS:
6 */
7
8 /* Module notify */
9
10 #include <string.h>
11 #include <mach/ndr.h>
12 #include <mach/boolean.h>
13 #include <mach/kern_return.h>
14 #include <mach/notify.h>
15 #include <mach/mach_types.h>
16 #include <mach/message.h>
17 #include <mach/mig_errors.h>
18 #include <mach/port.h>
19
20 #include <mach/std_types.h>
21 #include <mach/mig.h>
22
23 #ifndef mig_internal
24 #define mig_internal static
25 #endif /* mig_internal */
26
27 #ifndef mig_external
28 #define mig_external
29 #endif /* mig_external */
30
31 #ifndef TypeCheck
32 #define TypeCheck 0
33 #endif /* TypeCheck */
34
35 #ifndef LimitCheck
36 #define LimitCheck 0
37 #endif /* LimitCheck */
38
39 #ifndef min
40 #define min(a,b) ( ((a) < (b))? (a): (b) )
41 #endif /* min */
42
43 #ifndef UseStaticTemplates
44 #define UseStaticTemplates 1
45 #endif /* UseStaticTemplates */
46
47 #define _WALIGN_(x) (((x) + 3) & ~3)
48 #define _WALIGNSZ_(x) _WALIGN_(sizeof(x))
49 #ifndef __DeclareRcvRpc
50 #define __DeclareRcvRpc(_NUM_, _NAME_)
51 #endif /* __DeclareRcvRpc */
52
53 #ifndef __BeforeRcvRpc
54 #define __BeforeRcvRpc(_NUM_, _NAME_)
55 #endif /* __BeforeRcvRpc */
56
57 #ifndef __AfterRcvRpc
58 #define __AfterRcvRpc(_NUM_, _NAME_)
59 #endif /* __AfterRcvRpc */
60
61 #ifndef __DeclareRcvSimple
62 #define __DeclareRcvSimple(_NUM_, _NAME_)
63 #endif /* __DeclareRcvSimple */
64
65 #ifndef __BeforeRcvSimple
66 #define __BeforeRcvSimple(_NUM_, _NAME_)
67 #endif /* __BeforeRcvSimple */
68
69 #ifndef __AfterRcvSimple
70 #define __AfterRcvSimple(_NUM_, _NAME_)
71 #endif /* __AfterRcvSimple */
72
73 #define novalue void
74
75 #define msgh_request_port msgh_local_port
76 #define MACH_MSGH_BITS_REQUEST(bits) MACH_MSGH_BITS_LOCAL(bits)
77 #define msgh_reply_port msgh_remote_port
78 #define MACH_MSGH_BITS_REPLY(bits) MACH_MSGH_BITS_REMOTE(bits)
79
80 #define MIG_RETURN_ERROR(X, code) {\
81 ((mig_reply_error_t *)X)->RetCode = code;\
82 ((mig_reply_error_t *)X)->NDR = NDR_record;\
83 return;\
84 }
85
86 /* typedefs for all requests */
87
88 typedef struct {
89 mach_msg_header_t Head;
90 NDR_record_t NDR;
91 mach_port_name_t name;
92 } __Request__mach_notify_port_deleted_t;
93
94 typedef struct {
95 mach_msg_header_t Head;
96 /* start of the kernel processed data */
97 mach_msg_body_t msgh_body;
98 mach_msg_port_descriptor_t rights;
99 /* end of the kernel processed data */
100 } __Request__mach_notify_port_destroyed_t;
101
102 typedef struct {
103 mach_msg_header_t Head;
104 NDR_record_t NDR;
105 mach_port_mscount_t mscount;
106 } __Request__mach_notify_no_senders_t;
107
108 typedef struct {
109 mach_msg_header_t Head;
110 } __Request__mach_notify_send_once_t;
111
112 typedef struct {
113 mach_msg_header_t Head;
114 NDR_record_t NDR;
115 mach_port_name_t name;
116 } __Request__mach_notify_dead_name_t;
117
118
119 /* typedefs for all replies */
120
121 typedef struct {
122 mach_msg_header_t Head;
123 NDR_record_t NDR;
124 kern_return_t RetCode;
125 } __Reply__mach_notify_port_deleted_t;
126
127 typedef struct {
128 mach_msg_header_t Head;
129 NDR_record_t NDR;
130 kern_return_t RetCode;
131 } __Reply__mach_notify_port_destroyed_t;
132
133 typedef struct {
134 mach_msg_header_t Head;
135 NDR_record_t NDR;
136 kern_return_t RetCode;
137 } __Reply__mach_notify_no_senders_t;
138
139 typedef struct {
140 mach_msg_header_t Head;
141 NDR_record_t NDR;
142 kern_return_t RetCode;
143 } __Reply__mach_notify_send_once_t;
144
145 typedef struct {
146 mach_msg_header_t Head;
147 NDR_record_t NDR;
148 kern_return_t RetCode;
149 } __Reply__mach_notify_dead_name_t;
150
151
152 /* Forward Declarations */
153
154
155 mig_internal novalue _Xmach_notify_port_deleted
156 (mach_msg_header_t *InHeadP, mach_msg_header_t *OutHeadP);
157
158 mig_internal novalue _Xmach_notify_port_destroyed
159 (mach_msg_header_t *InHeadP, mach_msg_header_t *OutHeadP);
160
161 mig_internal novalue _Xmach_notify_no_senders
162 (mach_msg_header_t *InHeadP, mach_msg_header_t *OutHeadP);
163
164 mig_internal novalue _Xmach_notify_send_once
165 (mach_msg_header_t *InHeadP, mach_msg_header_t *OutHeadP);
166
167 mig_internal novalue _Xmach_notify_dead_name
168 (mach_msg_header_t *InHeadP, mach_msg_header_t *OutHeadP);
169
170
171 /* SimpleRoutine mach_notify_port_deleted */
172 #ifdef mig_external
173 mig_external
174 #else
175 extern
176 #endif /* mig_external */
177 kern_return_t cdsa_mach_notify_port_deleted
178 (
179 mach_port_t notify,
180 mach_port_name_t name
181 );
182
183 /* SimpleRoutine mach_notify_port_deleted */
184 mig_internal novalue _Xmach_notify_port_deleted
185 (mach_msg_header_t *InHeadP, mach_msg_header_t *OutHeadP)
186 {
187 typedef struct {
188 mach_msg_header_t Head;
189 NDR_record_t NDR;
190 mach_port_name_t name;
191 mach_msg_trailer_t trailer;
192 } Request;
193
194 typedef __Request__mach_notify_port_deleted_t __Request;
195
196 typedef __Reply__mach_notify_port_deleted_t Reply;
197 /*
198 * typedef struct {
199 * mach_msg_header_t Head;
200 * NDR_record_t NDR;
201 * kern_return_t RetCode;
202 * } mig_reply_error_t;
203 */
204
205 register Request *In0P = (Request *) InHeadP;
206 register Reply *OutP = (Reply *) OutHeadP;
207 __DeclareRcvSimple(65, "mach_notify_port_deleted")
208 __BeforeRcvSimple(65, "mach_notify_port_deleted")
209 #if TypeCheck
210 if ((In0P->Head.msgh_bits & MACH_MSGH_BITS_COMPLEX) ||
211 (In0P->Head.msgh_size != sizeof(__Request)))
212 { MIG_RETURN_ERROR(OutP, MIG_BAD_ARGUMENTS); }
213 #endif /* TypeCheck */
214
215 OutP->RetCode = cdsa_mach_notify_port_deleted(In0P->Head.msgh_request_port, In0P->name);
216 __AfterRcvSimple(65, "mach_notify_port_deleted")
217 }
218
219 /* SimpleRoutine mach_notify_port_destroyed */
220 #ifdef mig_external
221 mig_external
222 #else
223 extern
224 #endif /* mig_external */
225 kern_return_t cdsa_mach_notify_port_destroyed
226 (
227 mach_port_t notify,
228 mach_port_t rights
229 );
230
231 /* SimpleRoutine mach_notify_port_destroyed */
232 mig_internal novalue _Xmach_notify_port_destroyed
233 (mach_msg_header_t *InHeadP, mach_msg_header_t *OutHeadP)
234 {
235 typedef struct {
236 mach_msg_header_t Head;
237 /* start of the kernel processed data */
238 mach_msg_body_t msgh_body;
239 mach_msg_port_descriptor_t rights;
240 /* end of the kernel processed data */
241 mach_msg_trailer_t trailer;
242 } Request;
243
244 typedef __Request__mach_notify_port_destroyed_t __Request;
245
246 typedef __Reply__mach_notify_port_destroyed_t Reply;
247 /*
248 * typedef struct {
249 * mach_msg_header_t Head;
250 * NDR_record_t NDR;
251 * kern_return_t RetCode;
252 * } mig_reply_error_t;
253 */
254
255 register Request *In0P = (Request *) InHeadP;
256 register Reply *OutP = (Reply *) OutHeadP;
257 __DeclareRcvSimple(69, "mach_notify_port_destroyed")
258 __BeforeRcvSimple(69, "mach_notify_port_destroyed")
259 #if TypeCheck
260 if (!(In0P->Head.msgh_bits & MACH_MSGH_BITS_COMPLEX) ||
261 (In0P->msgh_body.msgh_descriptor_count != 1) ||
262 (In0P->Head.msgh_size != sizeof(__Request)))
263 { MIG_RETURN_ERROR(OutP, MIG_BAD_ARGUMENTS); }
264 #endif /* TypeCheck */
265
266 #if TypeCheck
267 if (In0P->rights.type != MACH_MSG_PORT_DESCRIPTOR ||
268 In0P->rights.disposition != MACH_MSG_TYPE_MOVE_RECEIVE)
269 { MIG_RETURN_ERROR(OutP, MIG_TYPE_ERROR); }
270 #endif /* TypeCheck */
271
272 OutP->RetCode = cdsa_mach_notify_port_destroyed(In0P->Head.msgh_request_port, In0P->rights.name);
273 __AfterRcvSimple(69, "mach_notify_port_destroyed")
274 }
275
276 /* SimpleRoutine mach_notify_no_senders */
277 #ifdef mig_external
278 mig_external
279 #else
280 extern
281 #endif /* mig_external */
282 kern_return_t cdsa_mach_notify_no_senders
283 (
284 mach_port_t notify,
285 mach_port_mscount_t mscount
286 );
287
288 /* SimpleRoutine mach_notify_no_senders */
289 mig_internal novalue _Xmach_notify_no_senders
290 (mach_msg_header_t *InHeadP, mach_msg_header_t *OutHeadP)
291 {
292 typedef struct {
293 mach_msg_header_t Head;
294 NDR_record_t NDR;
295 mach_port_mscount_t mscount;
296 mach_msg_trailer_t trailer;
297 } Request;
298
299 typedef __Request__mach_notify_no_senders_t __Request;
300
301 typedef __Reply__mach_notify_no_senders_t Reply;
302 /*
303 * typedef struct {
304 * mach_msg_header_t Head;
305 * NDR_record_t NDR;
306 * kern_return_t RetCode;
307 * } mig_reply_error_t;
308 */
309
310 register Request *In0P = (Request *) InHeadP;
311 register Reply *OutP = (Reply *) OutHeadP;
312 __DeclareRcvSimple(70, "mach_notify_no_senders")
313 __BeforeRcvSimple(70, "mach_notify_no_senders")
314 #if TypeCheck
315 if ((In0P->Head.msgh_bits & MACH_MSGH_BITS_COMPLEX) ||
316 (In0P->Head.msgh_size != sizeof(__Request)))
317 { MIG_RETURN_ERROR(OutP, MIG_BAD_ARGUMENTS); }
318 #endif /* TypeCheck */
319
320 OutP->RetCode = cdsa_mach_notify_no_senders(In0P->Head.msgh_request_port, In0P->mscount);
321 __AfterRcvSimple(70, "mach_notify_no_senders")
322 }
323
324 /* SimpleRoutine mach_notify_send_once */
325 #ifdef mig_external
326 mig_external
327 #else
328 extern
329 #endif /* mig_external */
330 kern_return_t cdsa_mach_notify_send_once
331 (
332 mach_port_t notify
333 );
334
335 /* SimpleRoutine mach_notify_send_once */
336 mig_internal novalue _Xmach_notify_send_once
337 (mach_msg_header_t *InHeadP, mach_msg_header_t *OutHeadP)
338 {
339 typedef struct {
340 mach_msg_header_t Head;
341 mach_msg_trailer_t trailer;
342 } Request;
343
344 typedef __Request__mach_notify_send_once_t __Request;
345
346 typedef __Reply__mach_notify_send_once_t Reply;
347 /*
348 * typedef struct {
349 * mach_msg_header_t Head;
350 * NDR_record_t NDR;
351 * kern_return_t RetCode;
352 * } mig_reply_error_t;
353 */
354
355 register Request *In0P = (Request *) InHeadP;
356 register Reply *OutP = (Reply *) OutHeadP;
357 __DeclareRcvSimple(71, "mach_notify_send_once")
358 __BeforeRcvSimple(71, "mach_notify_send_once")
359 #if TypeCheck
360 if ((In0P->Head.msgh_bits & MACH_MSGH_BITS_COMPLEX) ||
361 (In0P->Head.msgh_size != sizeof(__Request)))
362 { MIG_RETURN_ERROR(OutP, MIG_BAD_ARGUMENTS); }
363 #endif /* TypeCheck */
364
365 OutP->RetCode = cdsa_mach_notify_send_once(In0P->Head.msgh_request_port);
366 __AfterRcvSimple(71, "mach_notify_send_once")
367 }
368
369 /* SimpleRoutine mach_notify_dead_name */
370 #ifdef mig_external
371 mig_external
372 #else
373 extern
374 #endif /* mig_external */
375 kern_return_t cdsa_mach_notify_dead_name
376 (
377 mach_port_t notify,
378 mach_port_name_t name
379 );
380
381 /* SimpleRoutine mach_notify_dead_name */
382 mig_internal novalue _Xmach_notify_dead_name
383 (mach_msg_header_t *InHeadP, mach_msg_header_t *OutHeadP)
384 {
385 typedef struct {
386 mach_msg_header_t Head;
387 NDR_record_t NDR;
388 mach_port_name_t name;
389 mach_msg_trailer_t trailer;
390 } Request;
391
392 typedef __Request__mach_notify_dead_name_t __Request;
393
394 typedef __Reply__mach_notify_dead_name_t Reply;
395 /*
396 * typedef struct {
397 * mach_msg_header_t Head;
398 * NDR_record_t NDR;
399 * kern_return_t RetCode;
400 * } mig_reply_error_t;
401 */
402
403 register Request *In0P = (Request *) InHeadP;
404 register Reply *OutP = (Reply *) OutHeadP;
405 __DeclareRcvSimple(72, "mach_notify_dead_name")
406 __BeforeRcvSimple(72, "mach_notify_dead_name")
407 #if TypeCheck
408 if ((In0P->Head.msgh_bits & MACH_MSGH_BITS_COMPLEX) ||
409 (In0P->Head.msgh_size != sizeof(__Request)))
410 { MIG_RETURN_ERROR(OutP, MIG_BAD_ARGUMENTS); }
411 #endif /* TypeCheck */
412
413 OutP->RetCode = cdsa_mach_notify_dead_name(In0P->Head.msgh_request_port, In0P->name);
414 __AfterRcvSimple(72, "mach_notify_dead_name")
415 }
416
417 /* union of all requests */
418
419 union __RequestUnion__cdsa_notify_subsystem {
420 __Request__mach_notify_port_deleted_t Request_mach_notify_port_deleted;
421 __Request__mach_notify_port_destroyed_t Request_mach_notify_port_destroyed;
422 __Request__mach_notify_no_senders_t Request_mach_notify_no_senders;
423 __Request__mach_notify_send_once_t Request_mach_notify_send_once;
424 __Request__mach_notify_dead_name_t Request_mach_notify_dead_name;
425 };
426
427 /* union of all replies */
428
429 union __ReplyUnion__cdsa_notify_subsystem {
430 __Reply__mach_notify_port_deleted_t Reply_mach_notify_port_deleted;
431 __Reply__mach_notify_port_destroyed_t Reply_mach_notify_port_destroyed;
432 __Reply__mach_notify_no_senders_t Reply_mach_notify_no_senders;
433 __Reply__mach_notify_send_once_t Reply_mach_notify_send_once;
434 __Reply__mach_notify_dead_name_t Reply_mach_notify_dead_name;
435 };
436
437
438 extern boolean_t cdsa_notify_server(
439 mach_msg_header_t *InHeadP,
440 mach_msg_header_t *OutHeadP);
441
442 extern mig_routine_t notify_server_routine(
443 mach_msg_header_t *InHeadP);
444
445
446 /* Description of this subsystem, for use in direct RPC */
447 const struct cdsa_notify_subsystem {
448 mig_server_routine_t server; /* Server routine */
449 mach_msg_id_t start; /* Min routine number */
450 mach_msg_id_t end; /* Max routine number + 1 */
451 unsigned int maxsize; /* Max msg size */
452 vm_address_t reserved; /* Reserved */
453 struct routine_descriptor /*Array of routine descriptors */
454 routine[9];
455 } cdsa_notify_subsystem = {
456 notify_server_routine,
457 64,
458 73,
459 sizeof(union __ReplyUnion__cdsa_notify_subsystem),
460 (vm_address_t)0,
461 {
462 {0, 0, 0, 0, 0, 0},
463 { (mig_impl_routine_t) 0,
464 (mig_stub_routine_t) _Xmach_notify_port_deleted, 2, 0, (routine_arg_descriptor_t)0, sizeof(__Reply__mach_notify_port_deleted_t)},
465 {0, 0, 0, 0, 0, 0},
466 {0, 0, 0, 0, 0, 0},
467 {0, 0, 0, 0, 0, 0},
468 { (mig_impl_routine_t) 0,
469 (mig_stub_routine_t) _Xmach_notify_port_destroyed, 2, 0, (routine_arg_descriptor_t)0, sizeof(__Reply__mach_notify_port_destroyed_t)},
470 { (mig_impl_routine_t) 0,
471 (mig_stub_routine_t) _Xmach_notify_no_senders, 2, 0, (routine_arg_descriptor_t)0, sizeof(__Reply__mach_notify_no_senders_t)},
472 { (mig_impl_routine_t) 0,
473 (mig_stub_routine_t) _Xmach_notify_send_once, 1, 0, (routine_arg_descriptor_t)0, sizeof(__Reply__mach_notify_send_once_t)},
474 { (mig_impl_routine_t) 0,
475 (mig_stub_routine_t) _Xmach_notify_dead_name, 2, 0, (routine_arg_descriptor_t)0, sizeof(__Reply__mach_notify_dead_name_t)},
476 }
477 };
478
479 mig_external boolean_t cdsa_notify_server
480 (mach_msg_header_t *InHeadP, mach_msg_header_t *OutHeadP)
481 {
482 /*
483 * typedef struct {
484 * mach_msg_header_t Head;
485 * NDR_record_t NDR;
486 * kern_return_t RetCode;
487 * } mig_reply_error_t;
488 */
489
490 register mig_routine_t routine;
491
492 OutHeadP->msgh_bits = MACH_MSGH_BITS(MACH_MSGH_BITS_REPLY(InHeadP->msgh_bits), 0);
493 OutHeadP->msgh_remote_port = InHeadP->msgh_reply_port;
494 /* Minimal size: routine() will update it if different */
495 OutHeadP->msgh_size = sizeof(mig_reply_error_t);
496 OutHeadP->msgh_local_port = MACH_PORT_NULL;
497 OutHeadP->msgh_id = InHeadP->msgh_id + 100;
498
499 if ((InHeadP->msgh_id > 72) || (InHeadP->msgh_id < 64) ||
500 ((routine = cdsa_notify_subsystem.routine[InHeadP->msgh_id - 64].stub_routine) == 0)) {
501 ((mig_reply_error_t *)OutHeadP)->NDR = NDR_record;
502 ((mig_reply_error_t *)OutHeadP)->RetCode = MIG_BAD_ID;
503 return FALSE;
504 }
505 (*routine) (InHeadP, OutHeadP);
506 return TRUE;
507 }
508
509 mig_external mig_routine_t notify_server_routine
510 (mach_msg_header_t *InHeadP)
511 {
512 register int msgh_id;
513
514 msgh_id = InHeadP->msgh_id - 64;
515
516 if ((msgh_id > 8) || (msgh_id < 0))
517 return 0;
518
519 return cdsa_notify_subsystem.routine[msgh_id].stub_routine;
520 }