+/*
+ * The audit token is an opaque token which identifies
+ * Mach tasks and senders of Mach messages as subjects
+ * to the BSM audit system. Only the appropriate BSM
+ * library routines should be used to interpret the
+ * contents of the audit token as the representation
+ * of the subject identity within the token may change
+ * over time.
+ */
+typedef struct
+{
+ unsigned int val[8];
+} audit_token_t;
+
+typedef struct
+{
+ mach_msg_trailer_type_t msgh_trailer_type;
+ mach_msg_trailer_size_t msgh_trailer_size;
+ mach_port_seqno_t msgh_seqno;
+ security_token_t msgh_sender;
+ audit_token_t msgh_audit;
+} mach_msg_audit_trailer_t;
+
+typedef struct
+{
+ mach_msg_trailer_type_t msgh_trailer_type;
+ mach_msg_trailer_size_t msgh_trailer_size;
+ mach_port_seqno_t msgh_seqno;
+ security_token_t msgh_sender;
+ audit_token_t msgh_audit;
+ mach_port_context_t msgh_context;
+} mach_msg_context_trailer_t;
+
+#if defined(MACH_KERNEL_PRIVATE) && defined(__arm64__)
+typedef struct
+{
+ mach_msg_trailer_type_t msgh_trailer_type;
+ mach_msg_trailer_size_t msgh_trailer_size;
+ mach_port_seqno_t msgh_seqno;
+ security_token_t msgh_sender;
+ audit_token_t msgh_audit;
+ mach_port_context32_t msgh_context;
+} mach_msg_context_trailer32_t;
+
+typedef struct
+{
+ mach_msg_trailer_type_t msgh_trailer_type;
+ mach_msg_trailer_size_t msgh_trailer_size;
+ mach_port_seqno_t msgh_seqno;
+ security_token_t msgh_sender;
+ audit_token_t msgh_audit;
+ mach_port_context64_t msgh_context;
+} mach_msg_context_trailer64_t;
+#endif
+
+
+typedef struct
+{
+ mach_port_name_t sender;
+} msg_labels_t;
+
+/*
+ Trailer type to pass MAC policy label info as a mach message trailer.
+
+*/
+
+typedef struct
+{
+ mach_msg_trailer_type_t msgh_trailer_type;
+ mach_msg_trailer_size_t msgh_trailer_size;
+ mach_port_seqno_t msgh_seqno;
+ security_token_t msgh_sender;
+ audit_token_t msgh_audit;
+ mach_port_context_t msgh_context;
+ int msgh_ad;
+ msg_labels_t msgh_labels;
+} mach_msg_mac_trailer_t;
+
+#if defined(MACH_KERNEL_PRIVATE) && defined(__arm64__)
+typedef struct
+{
+ mach_msg_trailer_type_t msgh_trailer_type;
+ mach_msg_trailer_size_t msgh_trailer_size;
+ mach_port_seqno_t msgh_seqno;
+ security_token_t msgh_sender;
+ audit_token_t msgh_audit;
+ mach_port_context32_t msgh_context;
+ int msgh_ad;
+ msg_labels_t msgh_labels;
+} mach_msg_mac_trailer32_t;
+
+typedef struct
+{
+ mach_msg_trailer_type_t msgh_trailer_type;
+ mach_msg_trailer_size_t msgh_trailer_size;
+ mach_port_seqno_t msgh_seqno;
+ security_token_t msgh_sender;
+ audit_token_t msgh_audit;
+ mach_port_context64_t msgh_context;
+ int msgh_ad;
+ msg_labels_t msgh_labels;
+} mach_msg_mac_trailer64_t;
+
+#endif
+
+#define MACH_MSG_TRAILER_MINIMUM_SIZE sizeof(mach_msg_trailer_t)
+
+/*
+ * These values can change from release to release - but clearly
+ * code cannot request additional trailer elements one was not
+ * compiled to understand. Therefore, it is safe to use this
+ * constant when the same module specified the receive options.
+ * Otherwise, you run the risk that the options requested by
+ * another module may exceed the local modules notion of
+ * MAX_TRAILER_SIZE.
+ */
+#if defined(MACH_KERNEL_PRIVATE) && defined(__arm64__)
+typedef mach_msg_mac_trailer64_t mach_msg_max_trailer64_t;
+typedef mach_msg_mac_trailer32_t mach_msg_max_trailer32_t;
+#endif
+
+typedef mach_msg_mac_trailer_t mach_msg_max_trailer_t;
+#define MAX_TRAILER_SIZE ((mach_msg_size_t)sizeof(mach_msg_max_trailer_t))
+
+/*
+ * Legacy requirements keep us from ever updating these defines (even
+ * when the format_0 trailers gain new option data fields in the future).
+ * Therefore, they shouldn't be used going forward. Instead, the sizes
+ * should be compared against the specific element size requested using
+ * REQUESTED_TRAILER_SIZE.
+ */