17c478bd9Sstevel@tonic-gate /*
27c478bd9Sstevel@tonic-gate  * CDDL HEADER START
37c478bd9Sstevel@tonic-gate  *
47c478bd9Sstevel@tonic-gate  * The contents of this file are subject to the terms of the
5*45916cd2Sjpk  * Common Development and Distribution License (the "License").
6*45916cd2Sjpk  * You may not use this file except in compliance with the License.
77c478bd9Sstevel@tonic-gate  *
87c478bd9Sstevel@tonic-gate  * You can obtain a copy of the license at usr/src/OPENSOLARIS.LICENSE
97c478bd9Sstevel@tonic-gate  * or http://www.opensolaris.org/os/licensing.
107c478bd9Sstevel@tonic-gate  * See the License for the specific language governing permissions
117c478bd9Sstevel@tonic-gate  * and limitations under the License.
127c478bd9Sstevel@tonic-gate  *
137c478bd9Sstevel@tonic-gate  * When distributing Covered Code, include this CDDL HEADER in each
147c478bd9Sstevel@tonic-gate  * file and include the License file at usr/src/OPENSOLARIS.LICENSE.
157c478bd9Sstevel@tonic-gate  * If applicable, add the following below this CDDL HEADER, with the
167c478bd9Sstevel@tonic-gate  * fields enclosed by brackets "[]" replaced with your own identifying
177c478bd9Sstevel@tonic-gate  * information: Portions Copyright [yyyy] [name of copyright owner]
187c478bd9Sstevel@tonic-gate  *
197c478bd9Sstevel@tonic-gate  * CDDL HEADER END
207c478bd9Sstevel@tonic-gate  */
217c478bd9Sstevel@tonic-gate /*
22*45916cd2Sjpk  * Copyright 2006 Sun Microsystems, Inc.  All rights reserved.
237c478bd9Sstevel@tonic-gate  * Use is subject to license terms.
247c478bd9Sstevel@tonic-gate  */
257c478bd9Sstevel@tonic-gate 
267c478bd9Sstevel@tonic-gate #ifndef _BSM_AUDIT_RECORD_H
277c478bd9Sstevel@tonic-gate #define	_BSM_AUDIT_RECORD_H
287c478bd9Sstevel@tonic-gate 
297c478bd9Sstevel@tonic-gate #pragma ident	"%Z%%M%	%I%	%E% SMI"
307c478bd9Sstevel@tonic-gate 
317c478bd9Sstevel@tonic-gate #ifdef _KERNEL
327c478bd9Sstevel@tonic-gate #include <sys/priv.h>
337c478bd9Sstevel@tonic-gate #else
347c478bd9Sstevel@tonic-gate #include <priv.h>
357c478bd9Sstevel@tonic-gate #endif
367c478bd9Sstevel@tonic-gate #include <sys/socket.h>
377c478bd9Sstevel@tonic-gate #include <sys/acl.h>
387c478bd9Sstevel@tonic-gate 
397c478bd9Sstevel@tonic-gate #include <sys/tsol/label.h>
407c478bd9Sstevel@tonic-gate 
417c478bd9Sstevel@tonic-gate #ifdef __cplusplus
427c478bd9Sstevel@tonic-gate extern "C" {
437c478bd9Sstevel@tonic-gate #endif
447c478bd9Sstevel@tonic-gate 
457c478bd9Sstevel@tonic-gate /*
467c478bd9Sstevel@tonic-gate  * Version of audit attributes
477c478bd9Sstevel@tonic-gate  *
487c478bd9Sstevel@tonic-gate  * OS Release      Version Number    Comments
497c478bd9Sstevel@tonic-gate  * ==========      ==============    ========
507c478bd9Sstevel@tonic-gate  * SunOS 5.1              2        Unbundled Package
517c478bd9Sstevel@tonic-gate  * SunOS 5.3              2        Bundled into the base OS
527c478bd9Sstevel@tonic-gate  * SunOS 5.4-5.x          2
537c478bd9Sstevel@tonic-gate  * Trusted Solaris 2.5    3        To distinguish potential new tokens
547c478bd9Sstevel@tonic-gate  * Trusted Solaris 7-8    4        Redefine X tokens that overlap with
557c478bd9Sstevel@tonic-gate  *                                 SunOS 5.7
567c478bd9Sstevel@tonic-gate  */
577c478bd9Sstevel@tonic-gate 
587c478bd9Sstevel@tonic-gate #ifdef	TSOL
597c478bd9Sstevel@tonic-gate #define	TOKEN_VERSION   4
607c478bd9Sstevel@tonic-gate #else	/* !TSOL */
617c478bd9Sstevel@tonic-gate #define	TOKEN_VERSION   2
627c478bd9Sstevel@tonic-gate #endif	/* TSOL */
637c478bd9Sstevel@tonic-gate 
647c478bd9Sstevel@tonic-gate /*
657c478bd9Sstevel@tonic-gate  * Audit record token type codes
667c478bd9Sstevel@tonic-gate  */
677c478bd9Sstevel@tonic-gate 
687c478bd9Sstevel@tonic-gate /*
697c478bd9Sstevel@tonic-gate  * Control token types
707c478bd9Sstevel@tonic-gate  */
717c478bd9Sstevel@tonic-gate 
727c478bd9Sstevel@tonic-gate #define	AUT_INVALID		((char)0x00)
737c478bd9Sstevel@tonic-gate #define	AUT_OTHER_FILE		((char)0x11)
747c478bd9Sstevel@tonic-gate #define	AUT_OTHER_FILE32	AUT_OTHER_FILE
757c478bd9Sstevel@tonic-gate #define	AUT_OHEADER		((char)0x12)
767c478bd9Sstevel@tonic-gate #define	AUT_TRAILER		((char)0x13)
777c478bd9Sstevel@tonic-gate #define	AUT_HEADER		((char)0x14)
787c478bd9Sstevel@tonic-gate #define	AUT_HEADER32		AUT_HEADER
797c478bd9Sstevel@tonic-gate #define	AUT_HEADER32_EX		((char)0x15)
807c478bd9Sstevel@tonic-gate #define	AUT_TRAILER_MAGIC	((short)0xB105)
817c478bd9Sstevel@tonic-gate 
827c478bd9Sstevel@tonic-gate /*
837c478bd9Sstevel@tonic-gate  * Data token types
847c478bd9Sstevel@tonic-gate  */
857c478bd9Sstevel@tonic-gate 
867c478bd9Sstevel@tonic-gate #define	AUT_DATA		((char)0x21)
877c478bd9Sstevel@tonic-gate #define	AUT_IPC			((char)0x22)
887c478bd9Sstevel@tonic-gate #define	AUT_PATH		((char)0x23)
897c478bd9Sstevel@tonic-gate #define	AUT_SUBJECT		((char)0x24)
907c478bd9Sstevel@tonic-gate #define	AUT_SUBJECT32		AUT_SUBJECT
917c478bd9Sstevel@tonic-gate #define	AUT_XATPATH		((char)0x25)
927c478bd9Sstevel@tonic-gate #define	AUT_PROCESS		((char)0x26)
937c478bd9Sstevel@tonic-gate #define	AUT_PROCESS32		AUT_PROCESS
947c478bd9Sstevel@tonic-gate #define	AUT_RETURN		((char)0x27)
957c478bd9Sstevel@tonic-gate #define	AUT_RETURN32		AUT_RETURN
967c478bd9Sstevel@tonic-gate #define	AUT_TEXT		((char)0x28)
977c478bd9Sstevel@tonic-gate #define	AUT_OPAQUE		((char)0x29)
987c478bd9Sstevel@tonic-gate #define	AUT_IN_ADDR		((char)0x2A)
997c478bd9Sstevel@tonic-gate #define	AUT_IP			((char)0x2B)
1007c478bd9Sstevel@tonic-gate #define	AUT_IPORT		((char)0x2C)
1017c478bd9Sstevel@tonic-gate #define	AUT_ARG			((char)0x2D)
1027c478bd9Sstevel@tonic-gate #define	AUT_ARG32		AUT_ARG
1037c478bd9Sstevel@tonic-gate #define	AUT_SOCKET		((char)0x2E)
1047c478bd9Sstevel@tonic-gate #define	AUT_SEQ			((char)0x2F)
1057c478bd9Sstevel@tonic-gate #define	AUT_TID			((char)0x61)
1067c478bd9Sstevel@tonic-gate 
1077c478bd9Sstevel@tonic-gate /*
1087c478bd9Sstevel@tonic-gate  * Modifier token types
1097c478bd9Sstevel@tonic-gate  */
1107c478bd9Sstevel@tonic-gate 
1117c478bd9Sstevel@tonic-gate #define	AUT_ACL			((char)0x30)
1127c478bd9Sstevel@tonic-gate #define	AUT_ATTR		((char)0x31)
1137c478bd9Sstevel@tonic-gate #define	AUT_IPC_PERM		((char)0x32)
1147c478bd9Sstevel@tonic-gate #define	AUT_LABEL		((char)0x33)
1157c478bd9Sstevel@tonic-gate #define	AUT_GROUPS		((char)0x34)
1167c478bd9Sstevel@tonic-gate #define	AUT_ILABEL		((char)0x35)
1177c478bd9Sstevel@tonic-gate #define	AUT_SLABEL		((char)0x36)
1187c478bd9Sstevel@tonic-gate #define	AUT_CLEAR		((char)0x37)
1197c478bd9Sstevel@tonic-gate #define	AUT_PRIV		((char)0x38)
1207c478bd9Sstevel@tonic-gate #define	AUT_UPRIV		((char)0x39)
1217c478bd9Sstevel@tonic-gate #define	AUT_LIAISON		((char)0x3A)
1227c478bd9Sstevel@tonic-gate #define	AUT_NEWGROUPS		((char)0x3B)
1237c478bd9Sstevel@tonic-gate #define	AUT_EXEC_ARGS		((char)0x3C)
1247c478bd9Sstevel@tonic-gate #define	AUT_EXEC_ENV		((char)0x3D)
1257c478bd9Sstevel@tonic-gate #define	AUT_ATTR32		((char)0x3E)
1267c478bd9Sstevel@tonic-gate #define	AUT_UAUTH		((char)0x3F)
1277c478bd9Sstevel@tonic-gate #define	AUT_ZONENAME		((char)0x60)
1287c478bd9Sstevel@tonic-gate 
1297c478bd9Sstevel@tonic-gate /*
1307c478bd9Sstevel@tonic-gate  * X windows token types
1317c478bd9Sstevel@tonic-gate  */
1327c478bd9Sstevel@tonic-gate 
1337c478bd9Sstevel@tonic-gate #define	AUT_XATOM		((char)0x40)
1347c478bd9Sstevel@tonic-gate #define	AUT_XOBJ		((char)0x41)
1357c478bd9Sstevel@tonic-gate #define	AUT_XPROTO		((char)0x42)
1367c478bd9Sstevel@tonic-gate #define	AUT_XSELECT		((char)0x43)
1377c478bd9Sstevel@tonic-gate 
1387c478bd9Sstevel@tonic-gate #if	TOKEN_VERSION != 3
1397c478bd9Sstevel@tonic-gate #define	AUT_XCOLORMAP		((char)0x44)
1407c478bd9Sstevel@tonic-gate #define	AUT_XCURSOR		((char)0x45)
1417c478bd9Sstevel@tonic-gate #define	AUT_XFONT		((char)0x46)
1427c478bd9Sstevel@tonic-gate #define	AUT_XGC			((char)0x47)
1437c478bd9Sstevel@tonic-gate #define	AUT_XPIXMAP		((char)0x48)
1447c478bd9Sstevel@tonic-gate #define	AUT_XPROPERTY		((char)0x49)
1457c478bd9Sstevel@tonic-gate #define	AUT_XWINDOW		((char)0x4A)
1467c478bd9Sstevel@tonic-gate #define	AUT_XCLIENT		((char)0x4B)
1477c478bd9Sstevel@tonic-gate #else	/* TOKEN_VERSION == 3 */
1487c478bd9Sstevel@tonic-gate #define	AUT_XCOLORMAP		((char)0x74)
1497c478bd9Sstevel@tonic-gate #define	AUT_XCURSOR		((char)0x75)
1507c478bd9Sstevel@tonic-gate #define	AUT_XFONT		((char)0x76)
1517c478bd9Sstevel@tonic-gate #define	AUT_XGC			((char)0x77)
1527c478bd9Sstevel@tonic-gate #define	AUT_XPIXMAP		((char)0x78)
1537c478bd9Sstevel@tonic-gate #define	AUT_XPROPERTY		((char)0x79)
1547c478bd9Sstevel@tonic-gate #define	AUT_XWINDOW		((char)0x7A)
1557c478bd9Sstevel@tonic-gate #define	AUT_XCLIENT		((char)0x7B)
1567c478bd9Sstevel@tonic-gate #endif	/* TOKEN_VERSION != 3 */
1577c478bd9Sstevel@tonic-gate 
1587c478bd9Sstevel@tonic-gate /*
1597c478bd9Sstevel@tonic-gate  * Command token types
1607c478bd9Sstevel@tonic-gate  */
1617c478bd9Sstevel@tonic-gate 
1627c478bd9Sstevel@tonic-gate #define	AUT_CMD   		((char)0x51)
1637c478bd9Sstevel@tonic-gate #define	AUT_EXIT   		((char)0x52)
1647c478bd9Sstevel@tonic-gate 
1657c478bd9Sstevel@tonic-gate /*
1667c478bd9Sstevel@tonic-gate  * Miscellaneous token types
1677c478bd9Sstevel@tonic-gate  */
1687c478bd9Sstevel@tonic-gate 
1697c478bd9Sstevel@tonic-gate #define	AUT_HOST		((char)0x70)
1707c478bd9Sstevel@tonic-gate 
1717c478bd9Sstevel@tonic-gate /*
1727c478bd9Sstevel@tonic-gate  * Solaris64 token types
1737c478bd9Sstevel@tonic-gate  */
1747c478bd9Sstevel@tonic-gate 
1757c478bd9Sstevel@tonic-gate #define	AUT_ARG64		((char)0x71)
1767c478bd9Sstevel@tonic-gate #define	AUT_RETURN64		((char)0x72)
1777c478bd9Sstevel@tonic-gate #define	AUT_ATTR64		((char)0x73)
1787c478bd9Sstevel@tonic-gate #define	AUT_HEADER64		((char)0x74)
1797c478bd9Sstevel@tonic-gate #define	AUT_SUBJECT64		((char)0x75)
1807c478bd9Sstevel@tonic-gate #define	AUT_PROCESS64		((char)0x77)
1817c478bd9Sstevel@tonic-gate #define	AUT_OTHER_FILE64	((char)0x78)
1827c478bd9Sstevel@tonic-gate 
1837c478bd9Sstevel@tonic-gate /*
1847c478bd9Sstevel@tonic-gate  * Extended network address token types
1857c478bd9Sstevel@tonic-gate  */
1867c478bd9Sstevel@tonic-gate 
1877c478bd9Sstevel@tonic-gate #define	AUT_HEADER64_EX		((char)0x79)
1887c478bd9Sstevel@tonic-gate #define	AUT_SUBJECT32_EX	((char)0x7a)
1897c478bd9Sstevel@tonic-gate #define	AUT_PROCESS32_EX	((char)0x7b)
1907c478bd9Sstevel@tonic-gate #define	AUT_SUBJECT64_EX	((char)0x7c)
1917c478bd9Sstevel@tonic-gate #define	AUT_PROCESS64_EX	((char)0x7d)
1927c478bd9Sstevel@tonic-gate #define	AUT_IN_ADDR_EX		((char)0x7e)
1937c478bd9Sstevel@tonic-gate #define	AUT_SOCKET_EX		((char)0x7f)
1947c478bd9Sstevel@tonic-gate 
1957c478bd9Sstevel@tonic-gate 
1967c478bd9Sstevel@tonic-gate /*
1977c478bd9Sstevel@tonic-gate  * Audit print suggestion types.
1987c478bd9Sstevel@tonic-gate  */
1997c478bd9Sstevel@tonic-gate 
2007c478bd9Sstevel@tonic-gate #define	AUP_BINARY	((char)0)
2017c478bd9Sstevel@tonic-gate #define	AUP_OCTAL	((char)1)
2027c478bd9Sstevel@tonic-gate #define	AUP_DECIMAL	((char)2)
2037c478bd9Sstevel@tonic-gate #define	AUP_HEX		((char)3)
2047c478bd9Sstevel@tonic-gate #define	AUP_STRING	((char)4)
2057c478bd9Sstevel@tonic-gate 
2067c478bd9Sstevel@tonic-gate /*
2077c478bd9Sstevel@tonic-gate  * Audit data member types.
2087c478bd9Sstevel@tonic-gate  */
2097c478bd9Sstevel@tonic-gate 
2107c478bd9Sstevel@tonic-gate #define	AUR_BYTE	((char)0)
2117c478bd9Sstevel@tonic-gate #define	AUR_CHAR	((char)0)
2127c478bd9Sstevel@tonic-gate #define	AUR_SHORT	((char)1)
2137c478bd9Sstevel@tonic-gate #define	AUR_INT		((char)2)
2147c478bd9Sstevel@tonic-gate #define	AUR_INT32	((char)2)
2157c478bd9Sstevel@tonic-gate #define	AUR_INT64	((char)3)
2167c478bd9Sstevel@tonic-gate 
2177c478bd9Sstevel@tonic-gate /*
2187c478bd9Sstevel@tonic-gate  * Adr structures
2197c478bd9Sstevel@tonic-gate  */
2207c478bd9Sstevel@tonic-gate 
2217c478bd9Sstevel@tonic-gate struct adr_s {
2227c478bd9Sstevel@tonic-gate 	char *adr_stream;	/* The base of the stream */
2237c478bd9Sstevel@tonic-gate 	char *adr_now;		/* The location within the stream */
2247c478bd9Sstevel@tonic-gate };
2257c478bd9Sstevel@tonic-gate 
2267c478bd9Sstevel@tonic-gate typedef struct adr_s adr_t;
2277c478bd9Sstevel@tonic-gate 
2287c478bd9Sstevel@tonic-gate 
2297c478bd9Sstevel@tonic-gate #ifdef _KERNEL
2307c478bd9Sstevel@tonic-gate 
2317c478bd9Sstevel@tonic-gate #include <sys/param.h>
2327c478bd9Sstevel@tonic-gate #include <sys/systm.h>		/* for rval */
2337c478bd9Sstevel@tonic-gate #include <sys/time.h>
2347c478bd9Sstevel@tonic-gate #include <sys/types.h>
2357c478bd9Sstevel@tonic-gate #include <sys/vnode.h>
2367c478bd9Sstevel@tonic-gate #include <sys/mode.h>
2377c478bd9Sstevel@tonic-gate #include <sys/user.h>
2387c478bd9Sstevel@tonic-gate #include <sys/session.h>
2397c478bd9Sstevel@tonic-gate #include <sys/ipc_impl.h>
2407c478bd9Sstevel@tonic-gate #include <netinet/in_systm.h>
2417c478bd9Sstevel@tonic-gate #include <netinet/in.h>
2427c478bd9Sstevel@tonic-gate #include <netinet/ip.h>
2437c478bd9Sstevel@tonic-gate #include <sys/socket.h>
2447c478bd9Sstevel@tonic-gate #include <net/route.h>
2457c478bd9Sstevel@tonic-gate #include <netinet/in_pcb.h>
2467c478bd9Sstevel@tonic-gate 
2477c478bd9Sstevel@tonic-gate /*
2487c478bd9Sstevel@tonic-gate  * au_close flag arguments
2497c478bd9Sstevel@tonic-gate  */
2507c478bd9Sstevel@tonic-gate 
2517c478bd9Sstevel@tonic-gate #define	AU_OK		0x1	/* Good audit record */
2527c478bd9Sstevel@tonic-gate #define	AU_DONTBLOCK	0x2	/* Don't block or discard if queue full */
2537c478bd9Sstevel@tonic-gate #define	AU_DEFER	0x4	/* Defer record queueing to syscall end */
2547c478bd9Sstevel@tonic-gate 
2557c478bd9Sstevel@tonic-gate /*
2567c478bd9Sstevel@tonic-gate  * Audit token type is really an au_membuf pointer
2577c478bd9Sstevel@tonic-gate  */
2587c478bd9Sstevel@tonic-gate typedef au_buff_t token_t;
2597c478bd9Sstevel@tonic-gate /*
2607c478bd9Sstevel@tonic-gate  * token generation functions
2617c478bd9Sstevel@tonic-gate  */
2627c478bd9Sstevel@tonic-gate token_t *au_append_token(token_t *, token_t *);
2637c478bd9Sstevel@tonic-gate token_t *au_set(caddr_t, uint_t);
2647c478bd9Sstevel@tonic-gate 
2657c478bd9Sstevel@tonic-gate void au_free_rec(au_buff_t *);
2667c478bd9Sstevel@tonic-gate 
2677c478bd9Sstevel@tonic-gate #define	au_getclr()		((token_t *)au_get_buff())
2687c478bd9Sstevel@tonic-gate #define	au_toss_token(tok)	(au_free_rec((au_buff_t *)(tok)))
2697c478bd9Sstevel@tonic-gate 
2707c478bd9Sstevel@tonic-gate token_t *au_to_acl();
2717c478bd9Sstevel@tonic-gate token_t *au_to_attr(struct vattr *);
2727c478bd9Sstevel@tonic-gate token_t *au_to_data(char, char, char, char *);
2737c478bd9Sstevel@tonic-gate token_t *au_to_header(int, au_event_t, au_emod_t);
2747c478bd9Sstevel@tonic-gate token_t *au_to_header_ex(int, au_event_t, au_emod_t);
2757c478bd9Sstevel@tonic-gate token_t *au_to_ipc(char, int);
2767c478bd9Sstevel@tonic-gate token_t *au_to_ipc_perm(kipc_perm_t *);
2777c478bd9Sstevel@tonic-gate token_t *au_to_iport(ushort_t);
2787c478bd9Sstevel@tonic-gate token_t *au_to_in_addr(struct in_addr *);
2797c478bd9Sstevel@tonic-gate token_t *au_to_in_addr_ex(int32_t *);
2807c478bd9Sstevel@tonic-gate token_t *au_to_ip(struct ip *);
2817c478bd9Sstevel@tonic-gate token_t *au_to_groups(const gid_t *, uint_t);
2827c478bd9Sstevel@tonic-gate token_t *au_to_path(struct audit_path *);
2837c478bd9Sstevel@tonic-gate token_t *au_to_seq();
2847c478bd9Sstevel@tonic-gate token_t *au_to_process(uid_t, gid_t, uid_t, gid_t, pid_t,
2857c478bd9Sstevel@tonic-gate 			au_id_t, au_asid_t, const au_tid_addr_t *);
2867c478bd9Sstevel@tonic-gate token_t *au_to_subject(uid_t, gid_t, uid_t, gid_t, pid_t,
2877c478bd9Sstevel@tonic-gate 			au_id_t, au_asid_t, const au_tid_addr_t *);
2887c478bd9Sstevel@tonic-gate token_t *au_to_return32(int, int32_t);
2897c478bd9Sstevel@tonic-gate token_t *au_to_return64(int, int64_t);
2907c478bd9Sstevel@tonic-gate token_t *au_to_text(const char *);
2917c478bd9Sstevel@tonic-gate /* token_t *au_to_tid(au_generic_tid_t *);  no kernel implementation */
2927c478bd9Sstevel@tonic-gate token_t *au_to_trailer(int);
2937c478bd9Sstevel@tonic-gate token_t *au_to_uauth(char *);
2947c478bd9Sstevel@tonic-gate size_t	au_zonename_length(void);
2957c478bd9Sstevel@tonic-gate token_t *au_to_zonename(size_t);
2967c478bd9Sstevel@tonic-gate token_t *au_to_arg32(char, char *, uint32_t);
2977c478bd9Sstevel@tonic-gate token_t *au_to_arg64(char, char *, uint64_t);
2987c478bd9Sstevel@tonic-gate token_t *au_to_socket(struct socket *);
2997c478bd9Sstevel@tonic-gate token_t *au_to_socket_ex(short, short, char *, char *);
3007c478bd9Sstevel@tonic-gate token_t *au_to_sock_inet(struct sockaddr_in *);
3017c478bd9Sstevel@tonic-gate token_t *au_to_exec_args(const char *, ssize_t);
3027c478bd9Sstevel@tonic-gate token_t *au_to_exec_env(const char *, ssize_t);
303*45916cd2Sjpk token_t	*au_to_label(bslabel_t *);
3047c478bd9Sstevel@tonic-gate token_t	*au_to_privset(const char *, const priv_set_t *, char, int);
3057c478bd9Sstevel@tonic-gate 
3067c478bd9Sstevel@tonic-gate void	au_uwrite();
3077c478bd9Sstevel@tonic-gate void	au_close(au_kcontext_t *, caddr_t *, int, au_event_t, au_emod_t);
3087c478bd9Sstevel@tonic-gate void	au_close_defer(token_t *, int, au_event_t, au_emod_t);
3097c478bd9Sstevel@tonic-gate void	au_close_time(au_kcontext_t *, token_t *, int, au_event_t, au_emod_t,
3107c478bd9Sstevel@tonic-gate 	    timestruc_t *);
3117c478bd9Sstevel@tonic-gate void	au_free_rec(au_buff_t *);
3127c478bd9Sstevel@tonic-gate void	au_write(caddr_t *, token_t *);
3137c478bd9Sstevel@tonic-gate void	au_mem_init(void);
3147c478bd9Sstevel@tonic-gate void	au_zone_setup();
3157c478bd9Sstevel@tonic-gate void	au_enqueue(au_kcontext_t *, au_buff_t *, adr_t *, adr_t *, int, int);
3167c478bd9Sstevel@tonic-gate int	au_doorio(au_kcontext_t *);
3177c478bd9Sstevel@tonic-gate int	au_doormsg(au_kcontext_t *, uint32_t, void *);
3187c478bd9Sstevel@tonic-gate int	au_doio(struct vnode *, int);
3197c478bd9Sstevel@tonic-gate int	au_token_size(token_t *);
3207c478bd9Sstevel@tonic-gate int	au_append_rec(au_buff_t *, au_buff_t *, int);
3217c478bd9Sstevel@tonic-gate int	au_append_buf(const char *, int, au_buff_t *);
3227c478bd9Sstevel@tonic-gate 
3237c478bd9Sstevel@tonic-gate #else /* !_KERNEL */
3247c478bd9Sstevel@tonic-gate 
3257c478bd9Sstevel@tonic-gate #include <limits.h>
3267c478bd9Sstevel@tonic-gate #include <sys/types.h>
3277c478bd9Sstevel@tonic-gate #include <sys/vnode.h>
3287c478bd9Sstevel@tonic-gate #include <netinet/in_systm.h>
3297c478bd9Sstevel@tonic-gate #include <netinet/in.h>
3307c478bd9Sstevel@tonic-gate #include <netinet/ip.h>
3317c478bd9Sstevel@tonic-gate #include <sys/ipc.h>
3327c478bd9Sstevel@tonic-gate 
3337c478bd9Sstevel@tonic-gate struct token_s {
3347c478bd9Sstevel@tonic-gate 	struct token_s	*tt_next;	/* Next in the list	*/
3357c478bd9Sstevel@tonic-gate 	short		tt_size;	/* Size of data		*/
3367c478bd9Sstevel@tonic-gate 	char		*tt_data;	/* The data		*/
3377c478bd9Sstevel@tonic-gate };
3387c478bd9Sstevel@tonic-gate typedef struct token_s token_t;
3397c478bd9Sstevel@tonic-gate 
3407c478bd9Sstevel@tonic-gate struct au_arg32_tok {
3417c478bd9Sstevel@tonic-gate 	uchar_t num;
3427c478bd9Sstevel@tonic-gate 	uint32_t val;
3437c478bd9Sstevel@tonic-gate 	ushort_t length;
3447c478bd9Sstevel@tonic-gate 	char *data;
3457c478bd9Sstevel@tonic-gate };
3467c478bd9Sstevel@tonic-gate typedef struct au_arg32_tok au_arg32_tok_t;
3477c478bd9Sstevel@tonic-gate 
3487c478bd9Sstevel@tonic-gate struct au_acl_tok {
3497c478bd9Sstevel@tonic-gate 	ulong_t type;
3507c478bd9Sstevel@tonic-gate 	ulong_t id;
3517c478bd9Sstevel@tonic-gate 	ulong_t mode;
3527c478bd9Sstevel@tonic-gate };
3537c478bd9Sstevel@tonic-gate typedef struct au_acl_tok au_acl_tok_t;
3547c478bd9Sstevel@tonic-gate 
3557c478bd9Sstevel@tonic-gate struct au_arg64_tok {
3567c478bd9Sstevel@tonic-gate 	uchar_t num;
3577c478bd9Sstevel@tonic-gate 	uint64_t val;
3587c478bd9Sstevel@tonic-gate 	ushort_t length;
3597c478bd9Sstevel@tonic-gate 	char *data;
3607c478bd9Sstevel@tonic-gate };
3617c478bd9Sstevel@tonic-gate typedef struct au_arg64_tok au_arg64_tok_t;
3627c478bd9Sstevel@tonic-gate 
3637c478bd9Sstevel@tonic-gate struct au_attr_tok {
3647c478bd9Sstevel@tonic-gate 	uint_t mode;
3657c478bd9Sstevel@tonic-gate 	uint_t uid;
3667c478bd9Sstevel@tonic-gate 	uint_t gid;
3677c478bd9Sstevel@tonic-gate 	int fs;
3687c478bd9Sstevel@tonic-gate 	int32_t node;
3697c478bd9Sstevel@tonic-gate 	uint32_t dev;
3707c478bd9Sstevel@tonic-gate };
3717c478bd9Sstevel@tonic-gate typedef struct au_attr_tok au_attr_tok_t;
3727c478bd9Sstevel@tonic-gate 
3737c478bd9Sstevel@tonic-gate struct au_attr32_tok {
3747c478bd9Sstevel@tonic-gate 	uint_t mode;
3757c478bd9Sstevel@tonic-gate 	uint_t uid;
3767c478bd9Sstevel@tonic-gate 	uint_t gid;
3777c478bd9Sstevel@tonic-gate 	int fs;
3787c478bd9Sstevel@tonic-gate 	int64_t node;
3797c478bd9Sstevel@tonic-gate 	uint32_t dev;
3807c478bd9Sstevel@tonic-gate };
3817c478bd9Sstevel@tonic-gate typedef struct au_attr32_tok au_attr32_tok_t;
3827c478bd9Sstevel@tonic-gate 
3837c478bd9Sstevel@tonic-gate struct au_attr64_tok {
3847c478bd9Sstevel@tonic-gate 	uint_t mode;
3857c478bd9Sstevel@tonic-gate 	uint_t uid;
3867c478bd9Sstevel@tonic-gate 	uint_t gid;
3877c478bd9Sstevel@tonic-gate 	int fs;
3887c478bd9Sstevel@tonic-gate 	int64_t node;
3897c478bd9Sstevel@tonic-gate 	uint64_t dev;
3907c478bd9Sstevel@tonic-gate };
3917c478bd9Sstevel@tonic-gate typedef struct au_attr64_tok au_attr64_tok_t;
3927c478bd9Sstevel@tonic-gate 
3937c478bd9Sstevel@tonic-gate struct au_data_tok {
3947c478bd9Sstevel@tonic-gate 	uchar_t pfmt;
3957c478bd9Sstevel@tonic-gate 	uchar_t size;
3967c478bd9Sstevel@tonic-gate 	uchar_t number;
3977c478bd9Sstevel@tonic-gate 	char *data;
3987c478bd9Sstevel@tonic-gate };
3997c478bd9Sstevel@tonic-gate typedef struct au_data_tok au_data_tok_t;
4007c478bd9Sstevel@tonic-gate 
4017c478bd9Sstevel@tonic-gate struct au_exit_tok {
4027c478bd9Sstevel@tonic-gate 	int status;
4037c478bd9Sstevel@tonic-gate 	int retval;
4047c478bd9Sstevel@tonic-gate };
4057c478bd9Sstevel@tonic-gate typedef struct au_exit_tok au_exit_tok_t;
4067c478bd9Sstevel@tonic-gate 
4077c478bd9Sstevel@tonic-gate struct au_file32_tok {
4087c478bd9Sstevel@tonic-gate 	/* really struct timeval from gettimeofday() */
4097c478bd9Sstevel@tonic-gate 	int32_t sec;		/* seconds since epoc */
4107c478bd9Sstevel@tonic-gate 	int32_t usec;		/* microseconds */
4117c478bd9Sstevel@tonic-gate 	ushort_t length;
4127c478bd9Sstevel@tonic-gate 	char *fname;
4137c478bd9Sstevel@tonic-gate };
4147c478bd9Sstevel@tonic-gate typedef struct au_file32_tok au_file32_tok_t;
4157c478bd9Sstevel@tonic-gate 
4167c478bd9Sstevel@tonic-gate struct au_file64_tok {
4177c478bd9Sstevel@tonic-gate 	/* really struct timeval */
4187c478bd9Sstevel@tonic-gate 	int64_t sec;		/* seconds since epoc */
4197c478bd9Sstevel@tonic-gate 	int64_t usec;		/* microseconds */
4207c478bd9Sstevel@tonic-gate 	ushort_t length;
4217c478bd9Sstevel@tonic-gate 	char *fname;
4227c478bd9Sstevel@tonic-gate };
4237c478bd9Sstevel@tonic-gate typedef struct au_file64_tok au_file64_tok_t;
4247c478bd9Sstevel@tonic-gate 
4257c478bd9Sstevel@tonic-gate 
4267c478bd9Sstevel@tonic-gate struct au_groups_tok {
4277c478bd9Sstevel@tonic-gate 	gid_t groups[NGROUPS_MAX];
4287c478bd9Sstevel@tonic-gate };
4297c478bd9Sstevel@tonic-gate typedef struct au_groups_tok au_groups_tok_t;
4307c478bd9Sstevel@tonic-gate 
4317c478bd9Sstevel@tonic-gate struct au_header32_tok {
4327c478bd9Sstevel@tonic-gate 	uint_t length;
4337c478bd9Sstevel@tonic-gate 	uchar_t version;
4347c478bd9Sstevel@tonic-gate 	au_event_t event;
4357c478bd9Sstevel@tonic-gate 	ushort_t emod;
4367c478bd9Sstevel@tonic-gate 	/* really timestruct_t (struct timespec) from hrestime */
4377c478bd9Sstevel@tonic-gate 	int32_t sec;		/* seconds since epoc */
4387c478bd9Sstevel@tonic-gate 	int32_t nsec;		/* nanoseconds */
4397c478bd9Sstevel@tonic-gate };
4407c478bd9Sstevel@tonic-gate typedef struct au_header32_tok au_header32_tok_t;
4417c478bd9Sstevel@tonic-gate 
4427c478bd9Sstevel@tonic-gate struct au_header64_tok {
4437c478bd9Sstevel@tonic-gate 	uint_t length;
4447c478bd9Sstevel@tonic-gate 	uchar_t version;
4457c478bd9Sstevel@tonic-gate 	au_event_t event;
4467c478bd9Sstevel@tonic-gate 	ushort_t emod;
4477c478bd9Sstevel@tonic-gate 	/* really timestruct_t (struct timespec) from hrestime */
4487c478bd9Sstevel@tonic-gate 	int64_t sec;		/* seconds since epoc */
4497c478bd9Sstevel@tonic-gate 	int64_t nsec;		/* nanoseconds */
4507c478bd9Sstevel@tonic-gate };
4517c478bd9Sstevel@tonic-gate typedef struct au_header64_tok au_header64_tok_t;
4527c478bd9Sstevel@tonic-gate 
4537c478bd9Sstevel@tonic-gate struct au_inaddr_tok {
4547c478bd9Sstevel@tonic-gate 	struct in_addr ia;
4557c478bd9Sstevel@tonic-gate };
4567c478bd9Sstevel@tonic-gate typedef struct au_inaddr_tok au_inaddr_tok_t;
4577c478bd9Sstevel@tonic-gate 
4587c478bd9Sstevel@tonic-gate struct au_ip_tok {
4597c478bd9Sstevel@tonic-gate 	uchar_t version;
4607c478bd9Sstevel@tonic-gate 	struct ip ip;
4617c478bd9Sstevel@tonic-gate };
4627c478bd9Sstevel@tonic-gate typedef struct au_ip_tok au_ip_tok_t;
4637c478bd9Sstevel@tonic-gate 
4647c478bd9Sstevel@tonic-gate struct au_ipc_tok {
4657c478bd9Sstevel@tonic-gate 	key_t id;
4667c478bd9Sstevel@tonic-gate };
4677c478bd9Sstevel@tonic-gate typedef struct au_ipc_tok au_ipc_tok_t;
4687c478bd9Sstevel@tonic-gate 
4697c478bd9Sstevel@tonic-gate struct au_ipc_perm_tok {
4707c478bd9Sstevel@tonic-gate 	struct ipc_perm ipc_perm;
4717c478bd9Sstevel@tonic-gate };
4727c478bd9Sstevel@tonic-gate typedef struct au_ipc_perm_tok au_ipc_perm_tok_t;
4737c478bd9Sstevel@tonic-gate 
4747c478bd9Sstevel@tonic-gate struct au_iport_tok {
4757c478bd9Sstevel@tonic-gate 	ushort_t iport;
4767c478bd9Sstevel@tonic-gate };
4777c478bd9Sstevel@tonic-gate typedef struct au_iport_tok au_iport_tok_t;
4787c478bd9Sstevel@tonic-gate 
4797c478bd9Sstevel@tonic-gate struct au_invalid_tok {
4807c478bd9Sstevel@tonic-gate 	ushort_t length;
4817c478bd9Sstevel@tonic-gate 	char *data;
4827c478bd9Sstevel@tonic-gate };
4837c478bd9Sstevel@tonic-gate typedef struct au_invalid_tok au_invalid_tok_t;
4847c478bd9Sstevel@tonic-gate 
4857c478bd9Sstevel@tonic-gate struct au_opaque_tok {
4867c478bd9Sstevel@tonic-gate 	ushort_t length;
4877c478bd9Sstevel@tonic-gate 	char *data;
4887c478bd9Sstevel@tonic-gate };
4897c478bd9Sstevel@tonic-gate typedef struct au_opaque_tok au_opaque_tok_t;
4907c478bd9Sstevel@tonic-gate 
4917c478bd9Sstevel@tonic-gate struct au_path_tok {
4927c478bd9Sstevel@tonic-gate 	ushort_t length;
4937c478bd9Sstevel@tonic-gate 	char *name;
4947c478bd9Sstevel@tonic-gate };
4957c478bd9Sstevel@tonic-gate typedef struct au_path_tok au_path_tok_t;
4967c478bd9Sstevel@tonic-gate 
4977c478bd9Sstevel@tonic-gate struct au_tid32 {
4987c478bd9Sstevel@tonic-gate 	uint32_t port;
4997c478bd9Sstevel@tonic-gate 	uint32_t machine;
5007c478bd9Sstevel@tonic-gate };
5017c478bd9Sstevel@tonic-gate typedef struct au_tid32 au_tid32_t;
5027c478bd9Sstevel@tonic-gate 
5037c478bd9Sstevel@tonic-gate struct au_tid64 {
5047c478bd9Sstevel@tonic-gate 	uint64_t port;
5057c478bd9Sstevel@tonic-gate 	uint32_t machine;
5067c478bd9Sstevel@tonic-gate };
5077c478bd9Sstevel@tonic-gate typedef struct au_tid64 au_tid64_t;
5087c478bd9Sstevel@tonic-gate 
5097c478bd9Sstevel@tonic-gate struct au_proc32_tok {
5107c478bd9Sstevel@tonic-gate 	au_id_t auid;
5117c478bd9Sstevel@tonic-gate 	uid_t euid;
5127c478bd9Sstevel@tonic-gate 	gid_t egid;
5137c478bd9Sstevel@tonic-gate 	uid_t ruid;
5147c478bd9Sstevel@tonic-gate 	gid_t rgid;
5157c478bd9Sstevel@tonic-gate 	pid_t pid;
5167c478bd9Sstevel@tonic-gate 	pid_t sid;
5177c478bd9Sstevel@tonic-gate 	au_tid32_t tid;
5187c478bd9Sstevel@tonic-gate };
5197c478bd9Sstevel@tonic-gate typedef struct au_proc32_tok au_proc32_tok_t;
5207c478bd9Sstevel@tonic-gate 
5217c478bd9Sstevel@tonic-gate struct au_proc64_tok {
5227c478bd9Sstevel@tonic-gate 	au_id_t auid;
5237c478bd9Sstevel@tonic-gate 	uid_t euid;
5247c478bd9Sstevel@tonic-gate 	gid_t egid;
5257c478bd9Sstevel@tonic-gate 	uid_t ruid;
5267c478bd9Sstevel@tonic-gate 	gid_t rgid;
5277c478bd9Sstevel@tonic-gate 	pid_t pid;
5287c478bd9Sstevel@tonic-gate 	pid_t sid;
5297c478bd9Sstevel@tonic-gate 	au_tid64_t tid;
5307c478bd9Sstevel@tonic-gate };
5317c478bd9Sstevel@tonic-gate typedef struct au_proc64_tok au_proc64_tok_t;
5327c478bd9Sstevel@tonic-gate 
5337c478bd9Sstevel@tonic-gate struct au_ret32_tok {
5347c478bd9Sstevel@tonic-gate 	uchar_t error;
5357c478bd9Sstevel@tonic-gate 	uint32_t retval;
5367c478bd9Sstevel@tonic-gate };
5377c478bd9Sstevel@tonic-gate typedef struct au_ret32_tok au_ret32_tok_t;
5387c478bd9Sstevel@tonic-gate 
5397c478bd9Sstevel@tonic-gate struct au_ret64_tok {
5407c478bd9Sstevel@tonic-gate 	uchar_t error;
5417c478bd9Sstevel@tonic-gate 	uint64_t retval;
5427c478bd9Sstevel@tonic-gate };
5437c478bd9Sstevel@tonic-gate typedef struct au_ret64_tok au_ret64_tok_t;
5447c478bd9Sstevel@tonic-gate 
5457c478bd9Sstevel@tonic-gate struct au_seq_tok {
5467c478bd9Sstevel@tonic-gate 	uint_t num;
5477c478bd9Sstevel@tonic-gate };
5487c478bd9Sstevel@tonic-gate typedef struct au_seq_tok au_seq_tok_t;
5497c478bd9Sstevel@tonic-gate 
5507c478bd9Sstevel@tonic-gate struct au_socket_tok {
5517c478bd9Sstevel@tonic-gate 	short type;
5527c478bd9Sstevel@tonic-gate 	ushort_t lport;
5537c478bd9Sstevel@tonic-gate 	struct in_addr laddr;
5547c478bd9Sstevel@tonic-gate 	ushort_t fport;
5557c478bd9Sstevel@tonic-gate 	struct in_addr faddr;
5567c478bd9Sstevel@tonic-gate };
5577c478bd9Sstevel@tonic-gate typedef struct au_socket_tok au_socket_tok_t;
5587c478bd9Sstevel@tonic-gate 
5597c478bd9Sstevel@tonic-gate struct au_subj32_tok {
5607c478bd9Sstevel@tonic-gate 	au_id_t auid;
5617c478bd9Sstevel@tonic-gate 	uid_t euid;
5627c478bd9Sstevel@tonic-gate 	gid_t egid;
5637c478bd9Sstevel@tonic-gate 	uid_t ruid;
5647c478bd9Sstevel@tonic-gate 	gid_t rgid;
5657c478bd9Sstevel@tonic-gate 	pid_t pid;
5667c478bd9Sstevel@tonic-gate 	pid_t sid;
5677c478bd9Sstevel@tonic-gate 	au_tid32_t tid;
5687c478bd9Sstevel@tonic-gate };
5697c478bd9Sstevel@tonic-gate typedef struct au_subj32_tok au_subj32_tok_t;
5707c478bd9Sstevel@tonic-gate 
5717c478bd9Sstevel@tonic-gate struct au_subj64_tok {
5727c478bd9Sstevel@tonic-gate 	au_id_t auid;
5737c478bd9Sstevel@tonic-gate 	uid_t euid;
5747c478bd9Sstevel@tonic-gate 	gid_t egid;
5757c478bd9Sstevel@tonic-gate 	uid_t ruid;
5767c478bd9Sstevel@tonic-gate 	gid_t rgid;
5777c478bd9Sstevel@tonic-gate 	pid_t pid;
5787c478bd9Sstevel@tonic-gate 	pid_t sid;
5797c478bd9Sstevel@tonic-gate 	au_tid64_t tid;
5807c478bd9Sstevel@tonic-gate };
5817c478bd9Sstevel@tonic-gate typedef struct au_subj64_tok au_subj64_tok_t;
5827c478bd9Sstevel@tonic-gate 
5837c478bd9Sstevel@tonic-gate struct au_server_tok {
5847c478bd9Sstevel@tonic-gate 	au_id_t auid;
5857c478bd9Sstevel@tonic-gate 	uid_t euid;
5867c478bd9Sstevel@tonic-gate 	uid_t ruid;
5877c478bd9Sstevel@tonic-gate 	gid_t egid;
5887c478bd9Sstevel@tonic-gate 	pid_t pid;
5897c478bd9Sstevel@tonic-gate };
5907c478bd9Sstevel@tonic-gate typedef struct au_server_tok au_server_tok_t;
5917c478bd9Sstevel@tonic-gate 
5927c478bd9Sstevel@tonic-gate struct au_text_tok {
5937c478bd9Sstevel@tonic-gate 	ushort_t length;
5947c478bd9Sstevel@tonic-gate 	char *data;
5957c478bd9Sstevel@tonic-gate };
5967c478bd9Sstevel@tonic-gate typedef struct au_text_tok au_text_tok_t;
5977c478bd9Sstevel@tonic-gate 
5987c478bd9Sstevel@tonic-gate struct au_trailer_tok {
5997c478bd9Sstevel@tonic-gate 	ushort_t magic;
6007c478bd9Sstevel@tonic-gate 	uint_t length;
6017c478bd9Sstevel@tonic-gate };
6027c478bd9Sstevel@tonic-gate typedef struct au_trailer_tok au_trailer_tok_t;
6037c478bd9Sstevel@tonic-gate 
6047c478bd9Sstevel@tonic-gate struct au_uauth_tok {
6057c478bd9Sstevel@tonic-gate 	ushort_t length;
6067c478bd9Sstevel@tonic-gate 	char *data;
6077c478bd9Sstevel@tonic-gate };
6087c478bd9Sstevel@tonic-gate typedef struct au_uauth_tok au_uauth_tok_t;
6097c478bd9Sstevel@tonic-gate 
6107c478bd9Sstevel@tonic-gate struct au_token {
6117c478bd9Sstevel@tonic-gate 	char id;
6127c478bd9Sstevel@tonic-gate 	struct au_token *next;
6137c478bd9Sstevel@tonic-gate 	struct au_token *prev;
6147c478bd9Sstevel@tonic-gate 	char *data;
6157c478bd9Sstevel@tonic-gate 	ushort_t size;
6167c478bd9Sstevel@tonic-gate 	union {
6177c478bd9Sstevel@tonic-gate 		au_arg32_tok_t arg32;
6187c478bd9Sstevel@tonic-gate 		au_arg64_tok_t arg64;
6197c478bd9Sstevel@tonic-gate 		au_acl_tok_t acl;
6207c478bd9Sstevel@tonic-gate 		au_attr32_tok_t attr32;
6217c478bd9Sstevel@tonic-gate 		au_attr64_tok_t attr64;
6227c478bd9Sstevel@tonic-gate 		au_data_tok_t data;
6237c478bd9Sstevel@tonic-gate 		au_exit_tok_t exit;
6247c478bd9Sstevel@tonic-gate 		au_file32_tok_t file32;
6257c478bd9Sstevel@tonic-gate 		au_file64_tok_t file64;
6267c478bd9Sstevel@tonic-gate 		au_groups_tok_t groups;
6277c478bd9Sstevel@tonic-gate 		au_header32_tok_t header32;
6287c478bd9Sstevel@tonic-gate 		au_header64_tok_t header64;
6297c478bd9Sstevel@tonic-gate 		au_inaddr_tok_t inaddr;
6307c478bd9Sstevel@tonic-gate 		au_ip_tok_t ip;
6317c478bd9Sstevel@tonic-gate 		au_ipc_perm_tok_t ipc_perm;
6327c478bd9Sstevel@tonic-gate 		au_ipc_tok_t ipc;
6337c478bd9Sstevel@tonic-gate 		au_iport_tok_t iport;
6347c478bd9Sstevel@tonic-gate 		au_invalid_tok_t invalid;
6357c478bd9Sstevel@tonic-gate 		au_opaque_tok_t opaque;
6367c478bd9Sstevel@tonic-gate 		au_path_tok_t path;
6377c478bd9Sstevel@tonic-gate 		au_proc32_tok_t proc32;
6387c478bd9Sstevel@tonic-gate 		au_proc64_tok_t proc64;
6397c478bd9Sstevel@tonic-gate 		au_ret32_tok_t ret32;
6407c478bd9Sstevel@tonic-gate 		au_ret64_tok_t ret64;
6417c478bd9Sstevel@tonic-gate 		au_server_tok_t server;
6427c478bd9Sstevel@tonic-gate 		au_seq_tok_t seq;
6437c478bd9Sstevel@tonic-gate 		au_socket_tok_t socket;
6447c478bd9Sstevel@tonic-gate 		au_subj32_tok_t subj32;
6457c478bd9Sstevel@tonic-gate 		au_subj64_tok_t subj64;
6467c478bd9Sstevel@tonic-gate 		au_text_tok_t text;
6477c478bd9Sstevel@tonic-gate 		au_trailer_tok_t trailer;
6487c478bd9Sstevel@tonic-gate 		au_uauth_tok_t useofauth;
6497c478bd9Sstevel@tonic-gate 	} un;
6507c478bd9Sstevel@tonic-gate };
6517c478bd9Sstevel@tonic-gate typedef struct au_token au_token_t;
6527c478bd9Sstevel@tonic-gate 
6537c478bd9Sstevel@tonic-gate 
6547c478bd9Sstevel@tonic-gate /*
6557c478bd9Sstevel@tonic-gate  *	Old socket structure definition, formerly in <sys/socketvar.h>
6567c478bd9Sstevel@tonic-gate  */
6577c478bd9Sstevel@tonic-gate struct oldsocket {
6587c478bd9Sstevel@tonic-gate 	short	so_type;		/* generic type, see socket.h */
6597c478bd9Sstevel@tonic-gate 	short	so_options;		/* from socket call, see socket.h */
6607c478bd9Sstevel@tonic-gate 	short	so_linger;		/* time to linger while closing */
6617c478bd9Sstevel@tonic-gate 	short	so_state;		/* internal state flags SS_*, below */
6627c478bd9Sstevel@tonic-gate 	struct inpcb	*so_pcb;	/* protocol control block */
6637c478bd9Sstevel@tonic-gate 	struct	protosw *so_proto;	/* protocol handle */
6647c478bd9Sstevel@tonic-gate /*
6657c478bd9Sstevel@tonic-gate  * Variables for connection queueing.
6667c478bd9Sstevel@tonic-gate  * Socket where accepts occur is so_head in all subsidiary sockets.
6677c478bd9Sstevel@tonic-gate  * If so_head is 0, socket is not related to an accept.
6687c478bd9Sstevel@tonic-gate  * For head socket so_q0 queues partially completed connections,
6697c478bd9Sstevel@tonic-gate  * while so_q is a queue of connections ready to be accepted.
6707c478bd9Sstevel@tonic-gate  * If a connection is aborted and it has so_head set, then
6717c478bd9Sstevel@tonic-gate  * it has to be pulled out of either so_q0 or so_q.
6727c478bd9Sstevel@tonic-gate  * We allow connections to queue up based on current queue lengths
6737c478bd9Sstevel@tonic-gate  * and limit on number of queued connections for this socket.
6747c478bd9Sstevel@tonic-gate  */
6757c478bd9Sstevel@tonic-gate 	struct	oldsocket *so_head;	/* back pointer to accept socket */
6767c478bd9Sstevel@tonic-gate 	struct	oldsocket *so_q0;	/* queue of partial connections */
6777c478bd9Sstevel@tonic-gate 	struct	oldsocket *so_q;	/* queue of incoming connections */
6787c478bd9Sstevel@tonic-gate 	short	so_q0len;		/* partials on so_q0 */
6797c478bd9Sstevel@tonic-gate 	short	so_qlen;		/* number of connections on so_q */
6807c478bd9Sstevel@tonic-gate 	short	so_qlimit;		/* max number queued connections */
6817c478bd9Sstevel@tonic-gate 	short	so_timeo;		/* connection timeout */
6827c478bd9Sstevel@tonic-gate 	ushort_t so_error;		/* error affecting connection */
6837c478bd9Sstevel@tonic-gate 	short	so_pgrp;		/* pgrp for signals */
6847c478bd9Sstevel@tonic-gate 	ulong_t	so_oobmark;		/* chars to oob mark */
6857c478bd9Sstevel@tonic-gate /*
6867c478bd9Sstevel@tonic-gate  * Variables for socket buffering.
6877c478bd9Sstevel@tonic-gate  */
6887c478bd9Sstevel@tonic-gate 	struct	sockbuf {
6897c478bd9Sstevel@tonic-gate 		ulong_t	sb_cc;		/* actual chars in buffer */
6907c478bd9Sstevel@tonic-gate 		ulong_t	sb_hiwat;	/* max actual char count */
6917c478bd9Sstevel@tonic-gate 		ulong_t	sb_mbcnt;	/* chars of mbufs used */
6927c478bd9Sstevel@tonic-gate 		ulong_t	sb_mbmax;	/* max chars of mbufs to use */
6937c478bd9Sstevel@tonic-gate 		ulong_t	sb_lowat;	/* low water mark (not used yet) */
6947c478bd9Sstevel@tonic-gate 		struct	mbuf *sb_mb;	/* the mbuf chain */
6957c478bd9Sstevel@tonic-gate 		struct	proc *sb_sel;	/* process selecting read/write */
6967c478bd9Sstevel@tonic-gate 		short	sb_timeo;	/* timeout (not used yet) */
6977c478bd9Sstevel@tonic-gate 		short	sb_flags;	/* flags, see below */
6987c478bd9Sstevel@tonic-gate 	} so_rcv, so_snd;
6997c478bd9Sstevel@tonic-gate /*
7007c478bd9Sstevel@tonic-gate  * Hooks for alternative wakeup strategies.
7017c478bd9Sstevel@tonic-gate  * These are used by kernel subsystems wishing to access the socket
7027c478bd9Sstevel@tonic-gate  * abstraction.  If so_wupfunc is nonnull, it is called in place of
7037c478bd9Sstevel@tonic-gate  * wakeup any time that wakeup would otherwise be called with an
7047c478bd9Sstevel@tonic-gate  * argument whose value is an address lying within a socket structure.
7057c478bd9Sstevel@tonic-gate  */
7067c478bd9Sstevel@tonic-gate 	struct wupalt	*so_wupalt;
7077c478bd9Sstevel@tonic-gate };
7087c478bd9Sstevel@tonic-gate extern token_t *au_to_arg32(char, char *, uint32_t);
7097c478bd9Sstevel@tonic-gate extern token_t *au_to_arg64(char, char *, uint64_t);
7107c478bd9Sstevel@tonic-gate extern token_t *au_to_acl(struct acl *);
7117c478bd9Sstevel@tonic-gate extern token_t *au_to_attr(struct vattr *);
7127c478bd9Sstevel@tonic-gate extern token_t *au_to_cmd(uint_t, char **, char **);
7137c478bd9Sstevel@tonic-gate extern token_t *au_to_data(char, char, char, char *);
7147c478bd9Sstevel@tonic-gate extern token_t *au_to_exec_args(char **);
7157c478bd9Sstevel@tonic-gate extern token_t *au_to_exec_env(char **);
7167c478bd9Sstevel@tonic-gate extern token_t *au_to_exit(int, int);
7177c478bd9Sstevel@tonic-gate extern token_t *au_to_groups(int *);
7187c478bd9Sstevel@tonic-gate extern token_t *au_to_newgroups(int, gid_t *);
7197c478bd9Sstevel@tonic-gate extern token_t *au_to_header(au_event_t, au_emod_t);
7207c478bd9Sstevel@tonic-gate extern token_t *au_to_header_ex(au_event_t, au_emod_t);
7217c478bd9Sstevel@tonic-gate extern token_t *au_to_in_addr(struct in_addr *);
7227c478bd9Sstevel@tonic-gate extern token_t *au_to_in_addr_ex(int32_t *);
7237c478bd9Sstevel@tonic-gate extern token_t *au_to_ipc(char, int);
7247c478bd9Sstevel@tonic-gate extern token_t *au_to_ipc_perm(struct ipc_perm *);
7257c478bd9Sstevel@tonic-gate extern token_t *au_to_iport(ushort_t);
7267c478bd9Sstevel@tonic-gate extern token_t *au_to_me(void);
727*45916cd2Sjpk extern token_t *au_to_mylabel(void);
7287c478bd9Sstevel@tonic-gate extern token_t *au_to_opaque(char *, short);
7297c478bd9Sstevel@tonic-gate extern token_t *au_to_path(char *);
7307c478bd9Sstevel@tonic-gate extern token_t *au_to_privset(const char *, const priv_set_t *);
7317c478bd9Sstevel@tonic-gate extern token_t *au_to_process(au_id_t, uid_t, gid_t, uid_t, gid_t,
7327c478bd9Sstevel@tonic-gate 				pid_t, au_asid_t, au_tid_t *);
7337c478bd9Sstevel@tonic-gate extern token_t *au_to_process_ex(au_id_t, uid_t, gid_t, uid_t, gid_t,
7347c478bd9Sstevel@tonic-gate 				pid_t, au_asid_t, au_tid_addr_t *);
7357c478bd9Sstevel@tonic-gate extern token_t *au_to_return32(char, uint32_t);
7367c478bd9Sstevel@tonic-gate extern token_t *au_to_return64(char, uint64_t);
7377c478bd9Sstevel@tonic-gate extern token_t *au_to_seq(int);
738*45916cd2Sjpk extern token_t *au_to_label(bslabel_t *);
7397c478bd9Sstevel@tonic-gate extern token_t *au_to_socket(struct oldsocket *);
7407c478bd9Sstevel@tonic-gate extern token_t *au_to_socket_ex(short, short,
7417c478bd9Sstevel@tonic-gate 				struct sockaddr *, struct sockaddr *);
7427c478bd9Sstevel@tonic-gate extern token_t *au_to_sock_inet(struct sockaddr_in *);
7437c478bd9Sstevel@tonic-gate extern token_t *au_to_subject(au_id_t, uid_t, gid_t, uid_t, gid_t,
7447c478bd9Sstevel@tonic-gate 				pid_t, au_asid_t, au_tid_t *);
7457c478bd9Sstevel@tonic-gate extern token_t *au_to_subject_ex(au_id_t, uid_t, gid_t, uid_t, gid_t,
7467c478bd9Sstevel@tonic-gate 				pid_t, au_asid_t, au_tid_addr_t *);
7477c478bd9Sstevel@tonic-gate extern token_t *au_to_text(char *);
7487c478bd9Sstevel@tonic-gate extern token_t *au_to_tid(au_generic_tid_t *);
7497c478bd9Sstevel@tonic-gate extern token_t *au_to_trailer(void);
7507c478bd9Sstevel@tonic-gate extern token_t *au_to_uauth(char *);
7517c478bd9Sstevel@tonic-gate extern token_t *au_to_xatom(ushort_t, char *);
7527c478bd9Sstevel@tonic-gate extern token_t *au_to_xobj(int, int, int);
7537c478bd9Sstevel@tonic-gate extern token_t *au_to_xproto(pid_t);
7547c478bd9Sstevel@tonic-gate extern token_t *au_to_xselect(char *, char *, short, char *);
7557c478bd9Sstevel@tonic-gate extern token_t *au_to_zonename(char *);
7567c478bd9Sstevel@tonic-gate #endif /* _KERNEL */
7577c478bd9Sstevel@tonic-gate 
7587c478bd9Sstevel@tonic-gate #ifdef	_KERNEL
7597c478bd9Sstevel@tonic-gate 
7607c478bd9Sstevel@tonic-gate void	adr_char(adr_t *, char *, int);
7617c478bd9Sstevel@tonic-gate void	adr_int32(adr_t *, int32_t *, int);
7627c478bd9Sstevel@tonic-gate void	adr_uint32(adr_t *, uint32_t *, int);
7637c478bd9Sstevel@tonic-gate void	adr_int64(adr_t *, int64_t *, int);
7647c478bd9Sstevel@tonic-gate void	adr_uint64(adr_t *, uint64_t *, int);
7657c478bd9Sstevel@tonic-gate void	adr_short(adr_t *, short *, int);
7667c478bd9Sstevel@tonic-gate void	adr_ushort(adr_t *, ushort_t *, int);
7677c478bd9Sstevel@tonic-gate void	adr_start(adr_t *, char *);
7687c478bd9Sstevel@tonic-gate 
7697c478bd9Sstevel@tonic-gate char	*adr_getchar(adr_t *, char *);
7707c478bd9Sstevel@tonic-gate char	*adr_getshort(adr_t *, short  *);
7717c478bd9Sstevel@tonic-gate char	*adr_getushort(adr_t *, ushort_t  *);
7727c478bd9Sstevel@tonic-gate char	*adr_getint32(adr_t *, int32_t *);
7737c478bd9Sstevel@tonic-gate char	*adr_getuint32(adr_t *, uint32_t *);
7747c478bd9Sstevel@tonic-gate char	*adr_getint64(adr_t *, int64_t *);
7757c478bd9Sstevel@tonic-gate char	*adr_getuint64(adr_t *, uint64_t *);
7767c478bd9Sstevel@tonic-gate 
7777c478bd9Sstevel@tonic-gate int	adr_count(adr_t *);
7787c478bd9Sstevel@tonic-gate 
7797c478bd9Sstevel@tonic-gate #endif	/* _KERNEL */
7807c478bd9Sstevel@tonic-gate 
7817c478bd9Sstevel@tonic-gate #ifdef __cplusplus
7827c478bd9Sstevel@tonic-gate }
7837c478bd9Sstevel@tonic-gate #endif
7847c478bd9Sstevel@tonic-gate 
7857c478bd9Sstevel@tonic-gate #endif /* _BSM_AUDIT_RECORD_H */
786