Chameleon

Chameleon Svn Source Tree

Root/branches/slice/trunkM/i386/include/mach/message.h

1/*
2 * Copyright (c) 2000-2005 Apple Computer, Inc. All rights reserved.
3 *
4 * @APPLE_OSREFERENCE_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. The rights granted to you under the License
10 * may not be used to create, or enable the creation or redistribution of,
11 * unlawful or unlicensed copies of an Apple operating system, or to
12 * circumvent, violate, or enable the circumvention or violation of, any
13 * terms of an Apple operating system software license agreement.
14 *
15 * Please obtain a copy of the License at
16 * http://www.opensource.apple.com/apsl/ and read it before using this file.
17 *
18 * The Original Code and all software distributed under the License are
19 * distributed on an 'AS IS' basis, WITHOUT WARRANTY OF ANY KIND, EITHER
20 * EXPRESS OR IMPLIED, AND APPLE HEREBY DISCLAIMS ALL SUCH WARRANTIES,
21 * INCLUDING WITHOUT LIMITATION, ANY WARRANTIES OF MERCHANTABILITY,
22 * FITNESS FOR A PARTICULAR PURPOSE, QUIET ENJOYMENT OR NON-INFRINGEMENT.
23 * Please see the License for the specific language governing rights and
24 * limitations under the License.
25 *
26 * @APPLE_OSREFERENCE_LICENSE_HEADER_END@
27 */
28/*
29 * @OSF_COPYRIGHT@
30 */
31/*
32 * Mach Operating System
33 * Copyright (c) 1991,1990,1989,1988,1987 Carnegie Mellon University
34 * All Rights Reserved.
35 *
36 * Permission to use, copy, modify and distribute this software and its
37 * documentation is hereby granted, provided that both the copyright
38 * notice and this permission notice appear in all copies of the
39 * software, derivative works or modified versions, and any portions
40 * thereof, and that both notices appear in supporting documentation.
41 *
42 * CARNEGIE MELLON ALLOWS FREE USE OF THIS SOFTWARE IN ITS "AS IS"
43 * CONDITION. CARNEGIE MELLON DISCLAIMS ANY LIABILITY OF ANY KIND FOR
44 * ANY DAMAGES WHATSOEVER RESULTING FROM THE USE OF THIS SOFTWARE.
45 *
46 * Carnegie Mellon requests users of this software to return to
47 *
48 * Software Distribution Coordinator or Software.Distribution@CS.CMU.EDU
49 * School of Computer Science
50 * Carnegie Mellon University
51 * Pittsburgh PA 15213-3890
52 *
53 * any improvements or extensions that they make and grant Carnegie Mellon
54 * the rights to redistribute these changes.
55 */
56/*
57 * NOTICE: This file was modified by McAfee Research in 2004 to introduce
58 * support for mandatory and extensible security protections. This notice
59 * is included in support of clause 2.2 (b) of the Apple Public License,
60 * Version 2.0.
61 * Copyright (c) 2005 SPARTA, Inc.
62 */
63/*
64 */
65/*
66 *File:mach/message.h
67 *
68 *Mach IPC message and primitive function definitions.
69 */
70
71#ifndef_MACH_MESSAGE_H_
72#define _MACH_MESSAGE_H_
73
74#include <stdint.h>
75#include <mach/port.h>
76#include <mach/boolean.h>
77#include <mach/kern_return.h>
78#include <mach/machine/vm_types.h>
79
80#include <sys/cdefs.h>
81
82/*
83 * The timeout mechanism uses mach_msg_timeout_t values,
84 * passed by value. The timeout units are milliseconds.
85 * It is controlled with the MACH_SEND_TIMEOUT
86 * and MACH_RCV_TIMEOUT options.
87 */
88
89typedef natural_t mach_msg_timeout_t;
90
91/*
92 * The value to be used when there is no timeout.
93 * (No MACH_SEND_TIMEOUT/MACH_RCV_TIMEOUT option.)
94 */
95
96#define MACH_MSG_TIMEOUT_NONE((mach_msg_timeout_t) 0)
97
98/*
99 * The kernel uses MACH_MSGH_BITS_COMPLEX as a hint. If it isn't on, it
100 * assumes the body of the message doesn't contain port rights or OOL
101 * data. The field is set in received messages. A user task must
102 * use caution in interpreting the body of a message if the bit isn't
103 * on, because the mach_msg_type's in the body might "lie" about the
104 * contents. If the bit isn't on, but the mach_msg_types
105 * in the body specify rights or OOL data, the behavior is undefined.
106 * (Ie, an error may or may not be produced.)
107 *
108 * The value of MACH_MSGH_BITS_REMOTE determines the interpretation
109 * of the msgh_remote_port field. It is handled like a msgt_name.
110 *
111 * The value of MACH_MSGH_BITS_LOCAL determines the interpretation
112 * of the msgh_local_port field. It is handled like a msgt_name.
113 *
114 * MACH_MSGH_BITS() combines two MACH_MSG_TYPE_* values, for the remote
115 * and local fields, into a single value suitable for msgh_bits.
116 *
117 * MACH_MSGH_BITS_CIRCULAR should be zero; is is used internally.
118 *
119 * The unused bits should be zero and are reserved for the kernel
120 * or for future interface expansion.
121 */
122
123#define MACH_MSGH_BITS_ZERO0x00000000
124#define MACH_MSGH_BITS_REMOTE_MASK0x000000ff
125#define MACH_MSGH_BITS_LOCAL_MASK0x0000ff00
126#define MACH_MSGH_BITS_COMPLEX0x80000000U
127#define MACH_MSGH_BITS_USER 0x8000ffffU
128
129#defineMACH_MSGH_BITS_CIRCULAR0x40000000/* internal use only */
130#defineMACH_MSGH_BITS_USED0xc000ffffU
131
132#defineMACH_MSGH_BITS_PORTS_MASK\
133(MACH_MSGH_BITS_REMOTE_MASK|MACH_MSGH_BITS_LOCAL_MASK)
134
135#define MACH_MSGH_BITS(remote, local)\
136((remote) | ((local) << 8))
137#defineMACH_MSGH_BITS_REMOTE(bits)\
138((bits) & MACH_MSGH_BITS_REMOTE_MASK)
139#defineMACH_MSGH_BITS_LOCAL(bits)\
140(((bits) & MACH_MSGH_BITS_LOCAL_MASK) >> 8)
141#defineMACH_MSGH_BITS_PORTS(bits)\
142((bits) & MACH_MSGH_BITS_PORTS_MASK)
143#defineMACH_MSGH_BITS_OTHER(bits)\
144((bits) &~ MACH_MSGH_BITS_PORTS_MASK)
145
146/*
147 * Every message starts with a message header.
148 * Following the message header, if the message is complex, are a count
149 * of type descriptors and the type descriptors themselves
150 * (mach_msg_descriptor_t). The size of the message must be specified in
151 * bytes, and includes the message header, descriptor count, descriptors,
152 * and inline data.
153 *
154 * The msgh_remote_port field specifies the destination of the message.
155 * It must specify a valid send or send-once right for a port.
156 *
157 * The msgh_local_port field specifies a "reply port". Normally,
158 * This field carries a send-once right that the receiver will use
159 * to reply to the message. It may carry the values MACH_PORT_NULL,
160 * MACH_PORT_DEAD, a send-once right, or a send right.
161 *
162 * The msgh_seqno field carries a sequence number associated with the
163 * received-from port. A port's sequence number is incremented every
164 * time a message is received from it. In sent messages, the field's
165 * value is ignored.
166 *
167 * The msgh_id field is uninterpreted by the message primitives.
168 * It normally carries information specifying the format
169 * or meaning of the message.
170 */
171
172typedef unsigned int mach_msg_bits_t;
173typedefnatural_t mach_msg_size_t;
174typedef integer_t mach_msg_id_t;
175
176
177#define MACH_MSG_SIZE_NULL (mach_msg_size_t *) 0
178
179typedef unsigned int mach_msg_type_name_t;
180
181#define MACH_MSG_TYPE_MOVE_RECEIVE16/* Must hold receive rights */
182#define MACH_MSG_TYPE_MOVE_SEND17/* Must hold send rights */
183#define MACH_MSG_TYPE_MOVE_SEND_ONCE18/* Must hold sendonce rights */
184#define MACH_MSG_TYPE_COPY_SEND19/* Must hold send rights */
185#define MACH_MSG_TYPE_MAKE_SEND20/* Must hold receive rights */
186#define MACH_MSG_TYPE_MAKE_SEND_ONCE21/* Must hold receive rights */
187#define MACH_MSG_TYPE_COPY_RECEIVE22/* Must hold receive rights */
188
189typedef unsigned int mach_msg_copy_options_t;
190
191#define MACH_MSG_PHYSICAL_COPY0
192#define MACH_MSG_VIRTUAL_COPY 1
193#define MACH_MSG_ALLOCATE2
194#define MACH_MSG_OVERWRITE3
195#ifdef MACH_KERNEL
196#define MACH_MSG_KALLOC_COPY_T4
197#endif /* MACH_KERNEL */
198
199/*
200 * In a complex mach message, the mach_msg_header_t is followed by
201 * a descriptor count, then an array of that number of descriptors
202 * (mach_msg_*_descriptor_t). The type field of mach_msg_type_descriptor_t
203 * (which any descriptor can be cast to) indicates the flavor of the
204 * descriptor.
205 *
206 * Note that in LP64, the various types of descriptors are no longer all
207 * the same size as mach_msg_descriptor_t, so the array cannot be indexed
208 * as expected.
209 */
210
211typedef unsigned int mach_msg_descriptor_type_t;
212
213#define MACH_MSG_PORT_DESCRIPTOR 0
214#define MACH_MSG_OOL_DESCRIPTOR 1
215#define MACH_MSG_OOL_PORTS_DESCRIPTOR 2
216#define MACH_MSG_OOL_VOLATILE_DESCRIPTOR 3
217
218#pragma pack(4)
219
220typedef struct
221{
222 natural_tpad1;
223 mach_msg_size_tpad2;
224 unsigned intpad3 : 24;
225 mach_msg_descriptor_type_ttype : 8;
226} mach_msg_type_descriptor_t;
227
228typedef struct
229{
230 mach_port_tname;
231#if !(defined(KERNEL) && defined(__LP64__))
232// Pad to 8 bytes everywhere except the K64 kernel where mach_port_t is 8 bytes
233 mach_msg_size_tpad1;
234#endif
235 unsigned intpad2 : 16;
236 mach_msg_type_name_tdisposition : 8;
237 mach_msg_descriptor_type_ttype : 8;
238} mach_msg_port_descriptor_t;
239
240typedef struct
241{
242 uint32_taddress;
243 mach_msg_size_t size;
244 boolean_t deallocate: 8;
245 mach_msg_copy_options_t copy: 8;
246 unsigned int pad1: 8;
247 mach_msg_descriptor_type_t type: 8;
248} mach_msg_ool_descriptor32_t;
249
250typedef struct
251{
252 uint64_taddress;
253 boolean_t deallocate: 8;
254 mach_msg_copy_options_t copy: 8;
255 unsigned int pad1: 8;
256 mach_msg_descriptor_type_t type: 8;
257 mach_msg_size_t size;
258} mach_msg_ool_descriptor64_t;
259
260typedef struct
261{
262 void*address;
263#if !defined(__LP64__)
264 mach_msg_size_t size;
265#endif
266 boolean_t deallocate: 8;
267 mach_msg_copy_options_t copy: 8;
268 unsigned int pad1: 8;
269 mach_msg_descriptor_type_t type: 8;
270#if defined(__LP64__)
271 mach_msg_size_t size;
272#endif
273#if defined(KERNEL) && !defined(__LP64__)
274 uint32_t pad_end;
275#endif
276} mach_msg_ool_descriptor_t;
277
278typedef struct
279{
280 uint32_taddress;
281 mach_msg_size_tcount;
282 boolean_t deallocate: 8;
283 mach_msg_copy_options_t copy: 8;
284 mach_msg_type_name_tdisposition : 8;
285 mach_msg_descriptor_type_ttype : 8;
286} mach_msg_ool_ports_descriptor32_t;
287
288typedef struct
289{
290 uint64_taddress;
291 boolean_t deallocate: 8;
292 mach_msg_copy_options_t copy: 8;
293 mach_msg_type_name_tdisposition : 8;
294 mach_msg_descriptor_type_ttype : 8;
295 mach_msg_size_tcount;
296} mach_msg_ool_ports_descriptor64_t;
297
298typedef struct
299{
300 void*address;
301#if !defined(__LP64__)
302 mach_msg_size_tcount;
303#endif
304 boolean_t deallocate: 8;
305 mach_msg_copy_options_t copy: 8;
306 mach_msg_type_name_tdisposition : 8;
307 mach_msg_descriptor_type_ttype : 8;
308#if defined(__LP64__)
309 mach_msg_size_tcount;
310#endif
311#if defined(KERNEL) && !defined(__LP64__)
312 uint32_t pad_end;
313#endif
314} mach_msg_ool_ports_descriptor_t;
315
316/*
317 * LP64support - This union definition is not really
318 * appropriate in LP64 mode because not all descriptors
319 * are of the same size in that environment.
320 */
321#if defined(__LP64__) && defined(KERNEL)
322typedef union
323{
324 mach_msg_port_descriptor_tport;
325 mach_msg_ool_descriptor32_tout_of_line;
326 mach_msg_ool_ports_descriptor32_tool_ports;
327 mach_msg_type_descriptor_ttype;
328} mach_msg_descriptor_t;
329#else
330typedef union
331{
332 mach_msg_port_descriptor_tport;
333 mach_msg_ool_descriptor_tout_of_line;
334 mach_msg_ool_ports_descriptor_tool_ports;
335 mach_msg_type_descriptor_ttype;
336} mach_msg_descriptor_t;
337#endif
338
339typedef struct
340{
341 mach_msg_size_t msgh_descriptor_count;
342} mach_msg_body_t;
343
344#define MACH_MSG_BODY_NULL (mach_msg_body_t *) 0
345#define MACH_MSG_DESCRIPTOR_NULL (mach_msg_descriptor_t *) 0
346
347typedefstruct
348{
349 mach_msg_bits_tmsgh_bits;
350 mach_msg_size_tmsgh_size;
351 mach_port_tmsgh_remote_port;
352 mach_port_tmsgh_local_port;
353 mach_msg_size_t msgh_reserved;
354 mach_msg_id_tmsgh_id;
355} mach_msg_header_t;
356
357#define MACH_MSG_NULL (mach_msg_header_t *) 0
358
359typedef struct
360{
361 mach_msg_header_t header;
362 mach_msg_body_t body;
363} mach_msg_base_t;
364
365typedefunsigned int mach_msg_trailer_type_t;
366
367#defineMACH_MSG_TRAILER_FORMAT_00
368
369typedefunsigned int mach_msg_trailer_size_t;
370
371typedef struct
372{
373 mach_msg_trailer_type_tmsgh_trailer_type;
374 mach_msg_trailer_size_tmsgh_trailer_size;
375} mach_msg_trailer_t;
376
377typedef struct
378{
379 mach_msg_trailer_type_t msgh_trailer_type;
380 mach_msg_trailer_size_t msgh_trailer_size;
381 mach_port_seqno_t msgh_seqno;
382} mach_msg_seqno_trailer_t;
383
384typedef struct
385{
386 unsigned intval[2];
387} security_token_t;
388
389typedef struct
390{
391 mach_msg_trailer_type_tmsgh_trailer_type;
392 mach_msg_trailer_size_tmsgh_trailer_size;
393 mach_port_seqno_tmsgh_seqno;
394 security_token_tmsgh_sender;
395} mach_msg_security_trailer_t;
396
397/*
398 * The audit token is an opaque token which identifies
399 * Mach tasks and senders of Mach messages as subjects
400 * to the BSM audit system. Only the appropriate BSM
401 * library routines should be used to interpret the
402 * contents of the audit token as the representation
403 * of the subject identity within the token may change
404 * over time.
405 */
406typedef struct
407{
408 unsigned intval[8];
409} audit_token_t;
410
411typedef struct
412{
413 mach_msg_trailer_type_tmsgh_trailer_type;
414 mach_msg_trailer_size_tmsgh_trailer_size;
415 mach_port_seqno_tmsgh_seqno;
416 security_token_tmsgh_sender;
417 audit_token_tmsgh_audit;
418} mach_msg_audit_trailer_t;
419
420typedef struct
421{
422 mach_msg_trailer_type_tmsgh_trailer_type;
423 mach_msg_trailer_size_tmsgh_trailer_size;
424 mach_port_seqno_tmsgh_seqno;
425 security_token_tmsgh_sender;
426 audit_token_tmsgh_audit;
427 mach_vm_address_tmsgh_context;
428} mach_msg_context_trailer_t;
429
430
431typedef struct
432{
433 mach_port_name_t sender;
434} msg_labels_t;
435
436/*
437 Trailer type to pass MAC policy label info as a mach message trailer.
438
439*/
440
441typedef struct
442{
443 mach_msg_trailer_type_t msgh_trailer_type;
444 mach_msg_trailer_size_t msgh_trailer_size;
445 mach_port_seqno_t msgh_seqno;
446 security_token_t msgh_sender;
447 audit_token_t msgh_audit;
448 mach_vm_address_t msgh_context;
449 intmsgh_ad;
450 msg_labels_t msgh_labels;
451} mach_msg_mac_trailer_t;
452
453#define MACH_MSG_TRAILER_MINIMUM_SIZE sizeof(mach_msg_trailer_t)
454
455/*
456 * These values can change from release to release - but clearly
457 * code cannot request additional trailer elements one was not
458 * compiled to understand. Therefore, it is safe to use this
459 * constant when the same module specified the receive options.
460 * Otherwise, you run the risk that the options requested by
461 * another module may exceed the local modules notion of
462 * MAX_TRAILER_SIZE.
463 */
464typedef mach_msg_mac_trailer_t mach_msg_max_trailer_t;
465#define MAX_TRAILER_SIZE ((mach_msg_size_t)sizeof(mach_msg_max_trailer_t))
466
467/*
468 * Legacy requirements keep us from ever updating these defines (even
469 * when the format_0 trailers gain new option data fields in the future).
470 * Therefore, they shouldn't be used going forward. Instead, the sizes
471 * should be compared against the specific element size requested using
472 * REQUESTED_TRAILER_SIZE.
473 */
474typedef mach_msg_security_trailer_t mach_msg_format_0_trailer_t;
475
476/*typedef mach_msg_mac_trailer_t mach_msg_format_0_trailer_t;
477*/
478
479#define MACH_MSG_TRAILER_FORMAT_0_SIZE sizeof(mach_msg_format_0_trailer_t)
480
481#define KERNEL_SECURITY_TOKEN_VALUE { {0, 1} }
482extern security_token_t KERNEL_SECURITY_TOKEN;
483
484#define KERNEL_AUDIT_TOKEN_VALUE { {0, 0, 0, 0, 0, 0, 0, 0} }
485extern audit_token_t KERNEL_AUDIT_TOKEN;
486
487typedefinteger_t mach_msg_options_t;
488
489typedef struct
490{
491 mach_msg_header_theader;
492} mach_msg_empty_send_t;
493
494typedef struct
495{
496 mach_msg_header_theader;
497 mach_msg_trailer_ttrailer;
498} mach_msg_empty_rcv_t;
499
500typedef union
501{
502 mach_msg_empty_send_tsend;
503 mach_msg_empty_rcv_trcv;
504} mach_msg_empty_t;
505
506#pragma pack()
507
508/* utility to round the message size - will become machine dependent */
509#define round_msg(x)(((mach_msg_size_t)(x) + sizeof (natural_t) - 1) & \
510~(sizeof (natural_t) - 1))
511
512/*
513 * There is no fixed upper bound to the size of Mach messages.
514 */
515
516#defineMACH_MSG_SIZE_MAX((mach_msg_size_t) ~0)
517
518/*
519 * Compatibility definitions, for code written
520 * when there was a msgh_kind instead of msgh_seqno.
521 */
522#define MACH_MSGH_KIND_NORMAL0x00000000
523#define MACH_MSGH_KIND_NOTIFICATION0x00000001
524#definemsgh_kindmsgh_seqno
525#define mach_msg_kind_tmach_port_seqno_t
526
527typedef natural_t mach_msg_type_size_t;
528typedef natural_t mach_msg_type_number_t;
529
530/*
531 * Values received/carried in messages. Tells the receiver what
532 * sort of port right he now has.
533 *
534 * MACH_MSG_TYPE_PORT_NAME is used to transfer a port name
535 * which should remain uninterpreted by the kernel. (Port rights
536 * are not transferred, just the port name.)
537 */
538
539#define MACH_MSG_TYPE_PORT_NONE0
540
541#define MACH_MSG_TYPE_PORT_NAME15
542#define MACH_MSG_TYPE_PORT_RECEIVEMACH_MSG_TYPE_MOVE_RECEIVE
543#define MACH_MSG_TYPE_PORT_SENDMACH_MSG_TYPE_MOVE_SEND
544#define MACH_MSG_TYPE_PORT_SEND_ONCEMACH_MSG_TYPE_MOVE_SEND_ONCE
545
546#define MACH_MSG_TYPE_LAST22/* Last assigned */
547
548/*
549 * A dummy value. Mostly used to indicate that the actual value
550 * will be filled in later, dynamically.
551 */
552
553#define MACH_MSG_TYPE_POLYMORPHIC((mach_msg_type_name_t) -1)
554
555/*
556 *Is a given item a port type?
557 */
558
559#define MACH_MSG_TYPE_PORT_ANY(x)\
560(((x) >= MACH_MSG_TYPE_MOVE_RECEIVE) &&\
561 ((x) <= MACH_MSG_TYPE_MAKE_SEND_ONCE))
562
563#defineMACH_MSG_TYPE_PORT_ANY_SEND(x)\
564(((x) >= MACH_MSG_TYPE_MOVE_SEND) &&\
565 ((x) <= MACH_MSG_TYPE_MAKE_SEND_ONCE))
566
567#defineMACH_MSG_TYPE_PORT_ANY_RIGHT(x)\
568(((x) >= MACH_MSG_TYPE_MOVE_RECEIVE) &&\
569 ((x) <= MACH_MSG_TYPE_MOVE_SEND_ONCE))
570
571typedef integer_t mach_msg_option_t;
572
573#define MACH_MSG_OPTION_NONE0x00000000
574
575#defineMACH_SEND_MSG0x00000001
576#defineMACH_RCV_MSG0x00000002
577#define MACH_RCV_LARGE0x00000004
578
579#define MACH_SEND_TIMEOUT0x00000010
580#define MACH_SEND_INTERRUPT0x00000040/* libmach implements */
581#define MACH_SEND_CANCEL0x00000080
582#define MACH_SEND_ALWAYS0x00010000/* internal use only */
583#define MACH_SEND_TRAILER0x00020000
584
585#define MACH_RCV_TIMEOUT0x00000100
586#define MACH_RCV_NOTIFY0x00000200
587#define MACH_RCV_INTERRUPT0x00000400/* libmach implements */
588#define MACH_RCV_OVERWRITE0x00001000
589
590/*
591 * NOTE: a 0x00------ RCV mask implies to ask for
592 * a MACH_MSG_TRAILER_FORMAT_0 with 0 Elements,
593 * which is equivalent to a mach_msg_trailer_t.
594 *
595 * XXXMAC: unlike the rest of the MACH_RCV_* flags, MACH_RCV_TRAILER_LABELS
596 * needs its own private bit since we only calculate its fields when absolutely
597 * required.
598 */
599#define MACH_RCV_TRAILER_NULL 0
600#define MACH_RCV_TRAILER_SEQNO 1
601#define MACH_RCV_TRAILER_SENDER 2
602#define MACH_RCV_TRAILER_AUDIT 3
603#define MACH_RCV_TRAILER_CTX 4
604#define MACH_RCV_TRAILER_AV 7
605#define MACH_RCV_TRAILER_LABELS 8
606
607#define MACH_RCV_TRAILER_TYPE(x) (((x) & 0xf) << 28)
608#define MACH_RCV_TRAILER_ELEMENTS(x) (((x) & 0xf) << 24)
609#define MACH_RCV_TRAILER_MASK ((0xff << 24))
610
611#define GET_RCV_ELEMENTS(y) (((y) >> 24) & 0xf)
612
613/*
614 * XXXMAC: note that in the case of MACH_RCV_TRAILER_LABELS,
615 * we just fall through to mach_msg_max_trailer_t.
616 * This is correct behavior since mach_msg_max_trailer_t is defined as
617 * mac_msg_mac_trailer_t which is used for the LABELS trailer.
618 * It also makes things work properly if MACH_RCV_TRAILER_LABELS is ORed
619 * with one of the other options.
620 */
621#define REQUESTED_TRAILER_SIZE(y) \
622((mach_msg_trailer_size_t)\
623 ((GET_RCV_ELEMENTS(y) == MACH_RCV_TRAILER_NULL) ?\
624 sizeof(mach_msg_trailer_t) :\
625 ((GET_RCV_ELEMENTS(y) == MACH_RCV_TRAILER_SEQNO) ?\
626 sizeof(mach_msg_seqno_trailer_t) :\
627 ((GET_RCV_ELEMENTS(y) == MACH_RCV_TRAILER_SENDER) ?\
628 sizeof(mach_msg_security_trailer_t) :\
629 ((GET_RCV_ELEMENTS(y) == MACH_RCV_TRAILER_AUDIT) ?\
630 sizeof(mach_msg_audit_trailer_t) : \
631 ((GET_RCV_ELEMENTS(y) == MACH_RCV_TRAILER_CTX) ?\
632 sizeof(mach_msg_context_trailer_t) : \
633 ((GET_RCV_ELEMENTS(y) == MACH_RCV_TRAILER_AV) ?\
634 sizeof(mach_msg_mac_trailer_t) : \
635 sizeof(mach_msg_max_trailer_t))))))))
636
637/*
638 * Much code assumes that mach_msg_return_t == kern_return_t.
639 * This definition is useful for descriptive purposes.
640 *
641 * See <mach/error.h> for the format of error codes.
642 * IPC errors are system 4. Send errors are subsystem 0;
643 * receive errors are subsystem 1. The code field is always non-zero.
644 * The high bits of the code field communicate extra information
645 * for some error codes. MACH_MSG_MASK masks off these special bits.
646 */
647
648typedef kern_return_t mach_msg_return_t;
649
650#define MACH_MSG_SUCCESS0x00000000
651
652
653#defineMACH_MSG_MASK0x00003e00
654/* All special error code bits defined below. */
655#defineMACH_MSG_IPC_SPACE0x00002000
656/* No room in IPC name space for another capability name. */
657#defineMACH_MSG_VM_SPACE0x00001000
658/* No room in VM address space for out-of-line memory. */
659#defineMACH_MSG_IPC_KERNEL0x00000800
660/* Kernel resource shortage handling an IPC capability. */
661#defineMACH_MSG_VM_KERNEL0x00000400
662/* Kernel resource shortage handling out-of-line memory. */
663
664#define MACH_SEND_IN_PROGRESS0x10000001
665/* Thread is waiting to send. (Internal use only.) */
666#define MACH_SEND_INVALID_DATA0x10000002
667/* Bogus in-line data. */
668#define MACH_SEND_INVALID_DEST0x10000003
669/* Bogus destination port. */
670#define MACH_SEND_TIMED_OUT0x10000004
671/* Message not sent before timeout expired. */
672#define MACH_SEND_INTERRUPTED0x10000007
673/* Software interrupt. */
674#define MACH_SEND_MSG_TOO_SMALL0x10000008
675/* Data doesn't contain a complete message. */
676#define MACH_SEND_INVALID_REPLY0x10000009
677/* Bogus reply port. */
678#define MACH_SEND_INVALID_RIGHT0x1000000a
679/* Bogus port rights in the message body. */
680#define MACH_SEND_INVALID_NOTIFY0x1000000b
681/* Bogus notify port argument. */
682#define MACH_SEND_INVALID_MEMORY0x1000000c
683/* Invalid out-of-line memory pointer. */
684#define MACH_SEND_NO_BUFFER0x1000000d
685/* No message buffer is available. */
686#define MACH_SEND_TOO_LARGE0x1000000e
687/* Send is too large for port */
688#define MACH_SEND_INVALID_TYPE0x1000000f
689/* Invalid msg-type specification. */
690#define MACH_SEND_INVALID_HEADER0x10000010
691/* A field in the header had a bad value. */
692#define MACH_SEND_INVALID_TRAILER0x10000011
693/* The trailer to be sent does not match kernel format. */
694#define MACH_SEND_INVALID_RT_OOL_SIZE0x10000015
695/* compatibility: no longer a returned error */
696
697#define MACH_RCV_IN_PROGRESS0x10004001
698/* Thread is waiting for receive. (Internal use only.) */
699#define MACH_RCV_INVALID_NAME0x10004002
700/* Bogus name for receive port/port-set. */
701#define MACH_RCV_TIMED_OUT0x10004003
702/* Didn't get a message within the timeout value. */
703#define MACH_RCV_TOO_LARGE0x10004004
704/* Message buffer is not large enough for inline data. */
705#define MACH_RCV_INTERRUPTED0x10004005
706/* Software interrupt. */
707#define MACH_RCV_PORT_CHANGED0x10004006
708/* compatibility: no longer a returned error */
709#define MACH_RCV_INVALID_NOTIFY0x10004007
710/* Bogus notify port argument. */
711#define MACH_RCV_INVALID_DATA0x10004008
712/* Bogus message buffer for inline data. */
713#define MACH_RCV_PORT_DIED0x10004009
714/* Port/set was sent away/died during receive. */
715#defineMACH_RCV_IN_SET0x1000400a
716/* compatibility: no longer a returned error */
717#defineMACH_RCV_HEADER_ERROR0x1000400b
718/* Error receiving message header. See special bits. */
719#defineMACH_RCV_BODY_ERROR0x1000400c
720/* Error receiving message body. See special bits. */
721#defineMACH_RCV_INVALID_TYPE0x1000400d
722/* Invalid msg-type specification in scatter list. */
723#defineMACH_RCV_SCATTER_SMALL0x1000400e
724/* Out-of-line overwrite region is not large enough */
725#define MACH_RCV_INVALID_TRAILER0x1000400f
726/* trailer type or number of trailer elements not supported */
727#define MACH_RCV_IN_PROGRESS_TIMED 0x10004011
728 /* Waiting for receive with timeout. (Internal use only.) */
729
730
731__BEGIN_DECLS
732
733/*
734 *Routine:mach_msg_overwrite
735 *Purpose:
736 *Send and/or receive a message. If the message operation
737 *is interrupted, and the user did not request an indication
738 *of that fact, then restart the appropriate parts of the
739 *operation silently (trap version does not restart).
740 *
741 *Distinct send and receive buffers may be specified. If
742 *no separate receive buffer is specified, the msg parameter
743 *will be used for both send and receive operations.
744 *
745 *In addition to a distinct receive buffer, that buffer may
746 *already contain scatter control information to direct the
747 *receiving of the message.
748 */
749
750extern mach_msg_return_tmach_msg_overwrite(
751mach_msg_header_t *msg,
752mach_msg_option_t option,
753mach_msg_size_t send_size,
754mach_msg_size_t rcv_size,
755mach_port_name_t rcv_name,
756mach_msg_timeout_t timeout,
757mach_port_name_t notify,
758mach_msg_header_t *rcv_msg,
759mach_msg_size_t rcv_limit);
760
761
762/*
763 *Routine:mach_msg
764 *Purpose:
765 *Send and/or receive a message. If the message operation
766 *is interrupted, and the user did not request an indication
767 *of that fact, then restart the appropriate parts of the
768 *operation silently (trap version does not restart).
769 */
770extern mach_msg_return_tmach_msg(
771mach_msg_header_t *msg,
772mach_msg_option_t option,
773mach_msg_size_t send_size,
774mach_msg_size_t rcv_size,
775mach_port_name_t rcv_name,
776mach_msg_timeout_t timeout,
777mach_port_name_t notify);
778
779
780__END_DECLS
781
782#endif/* _MACH_MESSAGE_H_ */
783
784

Archive Download this file

Revision: 1171