1 /*
2 * Copyright (c) 2005 Apple Computer, Inc.
3 * Copyright (c) 2005 SPARTA, Inc.
4 * All rights reserved.
5 *
6 * This code was developed in part by Robert N. M. Watson, Senior Principal
7 * Scientist, SPARTA, Inc.
8 *
9 * @APPLE_BSD_LICENSE_HEADER_START@
10 *
11 * Redistribution and use in source and binary forms, with or without
12 * modification, are permitted provided that the following conditions
13 * are met:
14 *
15 * 1. Redistributions of source code must retain the above copyright
16 * notice, this list of conditions and the following disclaimer.
17 * 2. Redistributions in binary form must reproduce the above copyright
18 * notice, this list of conditions and the following disclaimer in the
19 * documentation and/or other materials provided with the distribution.
20 * 3. Neither the name of Apple Computer, Inc. ("Apple") nor the names of
21 * its contributors may be used to endorse or promote products derived
22 * from this software without specific prior written permission.
23 *
24 * THIS SOFTWARE IS PROVIDED BY APPLE AND ITS CONTRIBUTORS "AS IS" AND ANY
25 * EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED
26 * WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE
27 * DISCLAIMED. IN NO EVENT SHALL APPLE OR ITS CONTRIBUTORS BE LIABLE FOR ANY
28 * DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES
29 * (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES;
30 * LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND
31 * ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
32 * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF
33 * THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
34 *
35 * @APPLE_BSD_LICENSE_HEADER_END@
36 *
37 * $P4: //depot/projects/trustedbsd/audit3/sys/bsm/audit_internal.h#14 $
38 * $FreeBSD: releng/6.2/sys/bsm/audit_internal.h 162821 2006-09-29 22:43:30Z rwatson $
39 */
40
41 #ifndef _AUDIT_INTERNAL_H
42 #define _AUDIT_INTERNAL_H
43
44 #if defined(__linux__) && !defined(__unused)
45 #define __unused
46 #endif
47
48 /*
49 * audit_internal.h contains private interfaces that are shared by user space
50 * and the kernel for the purposes of assembling audit records. Applications
51 * should not include this file or use the APIs found within, or it may be
52 * broken with future releases of OpenBSM, which may delete, modify, or
53 * otherwise break these interfaces or the assumptions they rely on.
54 */
55 struct au_token {
56 u_char *t_data;
57 size_t len;
58 TAILQ_ENTRY(au_token) tokens;
59 };
60
61 struct au_record {
62 char used; /* Record currently in use? */
63 int desc; /* Descriptor for record. */
64 TAILQ_HEAD(, au_token) token_q; /* Queue of BSM tokens. */
65 u_char *data;
66 size_t len;
67 LIST_ENTRY(au_record) au_rec_q;
68 };
69 typedef struct au_record au_record_t;
70
71
72 /*
73 * We could determined the header and trailer sizes by defining appropriate
74 * structures. We hold off that approach until we have a consistent way of
75 * using structures for all tokens. This is not straightforward since these
76 * token structures may contain pointers of whose contents we do not know the
77 * size (e.g text tokens).
78 */
79 #define AUDIT_HEADER_SIZE 18
80 #define AUDIT_TRAILER_SIZE 7
81
82 /*
83 * BSM token streams store fields in big endian byte order, so as to be
84 * portable; when encoding and decoding, we must convert byte orders for
85 * typed values.
86 */
87 #define ADD_U_CHAR(loc, val) \
88 do { \
89 *(loc) = (val); \
90 (loc) += sizeof(u_char); \
91 } while(0)
92
93
94 #define ADD_U_INT16(loc, val) \
95 do { \
96 be16enc((loc), (val)); \
97 (loc) += sizeof(u_int16_t); \
98 } while(0)
99
100 #define ADD_U_INT32(loc, val) \
101 do { \
102 be32enc((loc), (val)); \
103 (loc) += sizeof(u_int32_t); \
104 } while(0)
105
106 #define ADD_U_INT64(loc, val) \
107 do { \
108 be64enc((loc), (val)); \
109 (loc) += sizeof(u_int64_t); \
110 } while(0)
111
112 #define ADD_MEM(loc, data, size) \
113 do { \
114 memcpy((loc), (data), (size)); \
115 (loc) += size; \
116 } while(0)
117
118 #define ADD_STRING(loc, data, size) ADD_MEM(loc, data, size)
119
120 #endif /* !_AUDIT_INTERNAL_H_ */
Cache object: c1883fcdda23f59c64aca6cfda0aefd2
|