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