4 * The contents of this file are subject to the terms of the
5 * Common Development and Distribution License (the "License").
6 * You may not use this file except in compliance with the License.
8 * You can obtain a copy of the license at usr/src/OPENSOLARIS.LICENSE
9 * or http://www.opensolaris.org/os/licensing.
10 * See the License for the specific language governing permissions
11 * and limitations under the License.
13 * When distributing Covered Code, include this CDDL HEADER in each
14 * file and include the License file at usr/src/OPENSOLARIS.LICENSE.
15 * If applicable, add the following below this CDDL HEADER, with the
16 * fields enclosed by brackets "[]" replaced with your own identifying
17 * information: Portions Copyright [yyyy] [name of copyright owner]
22 * Copyright 2008 Sun Microsystems, Inc. All rights reserved.
23 * Use is subject to license terms.
28 * Adr memory based encoding
31 #include <sys/types.h>
32 #include <bsm/audit.h>
33 #include <bsm/libbsm.h>
34 #include <bsm/audit_record.h>
37 adr_start(adr_t
*adr
, char *p
)
46 return (((intptr_t)adr
->adr_now
) - ((intptr_t)adr
->adr_stream
));
51 * adr_char - pull out characters
54 adr_char(adr_t
*adr
, char *cp
, int count
)
57 *adr
->adr_now
++ = *cp
++;
61 * adr_short - pull out shorts
64 adr_short(adr_t
*adr
, short *sp
, int count
)
67 for (; count
-- > 0; sp
++) {
68 *adr
->adr_now
++ = (char)((*sp
>> 8) & 0x00ff);
69 *adr
->adr_now
++ = (char)(*sp
& 0x00ff);
74 * adr_ushort - pull out ushorts
77 adr_ushort(adr_t
*adr
, ushort_t
*sp
, int count
)
80 for (; count
-- > 0; sp
++) {
81 *adr
->adr_now
++ = (char)((*sp
>> 8) & 0x00ff);
82 *adr
->adr_now
++ = (char)(*sp
& 0x00ff);
87 * adr_int32 - pull out uint32
89 #pragma weak adr_long = adr_int32
91 adr_long(adr_t
*adr
, int32_t *lp
, int count
);
93 adr_int32(adr_t
*adr
, int32_t *lp
, int count
)
95 int i
; /* index for counting */
96 uint32_t l
; /* value for shifting */
98 for (; count
-- > 0; lp
++) {
99 for (i
= 0, l
= *(uint32_t *)lp
; i
< 4; i
++) {
101 (char)((uint32_t)(l
& 0xff000000) >> 24);
112 adr_uid(adr_t
*adr
, uid_t
*up
, int count
)
114 int i
; /* index for counting */
115 uid_t l
; /* value for shifting */
117 for (; count
-- > 0; up
++) {
118 for (i
= 0, l
= *(uint32_t *)up
; i
< 4; i
++) {
120 (char)((uint32_t)(l
& 0xff000000) >> 24);
127 * adr_int64 - pull out uint64_t
130 adr_int64(adr_t
*adr
, int64_t *lp
, int count
)
132 int i
; /* index for counting */
133 uint64_t l
; /* value for shifting */
135 for (; count
-- > 0; lp
++) {
136 for (i
= 0, l
= *(uint64_t *)lp
; i
< 8; i
++) {
137 *adr
->adr_now
++ = (char)
138 ((uint64_t)(l
& 0xff00000000000000ULL
) >> 56);