audit_internal.h revision 155191
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#5 $ 38 * $FreeBSD: head/sys/bsm/audit_internal.h 155191 2006-02-01 19:54:22Z rwatson $ 39 */ 40 41#ifndef _LIBBSM_INTERNAL_H 42#define _LIBBSM_INTERNAL_H 43 44/* 45 * audit_internal.h contains private interfaces that are shared by user space 46 * and the kernel for the purposes of assembling audit records. Applications 47 * should not include this file or use the APIs found within, or it may be 48 * broken with future releases of OpenBSM, which may delete, modify, or 49 * otherwise break these interfaces or the assumptions they rely on. 50 */ 51 52/* We could determined the header and trailer sizes by 53 * defining appropriate structures. We hold off that approach 54 * till we have a consistant way of using structures for all tokens. 55 * This is not straightforward since these token structures may 56 * contain pointers of whose contents we dont know the size 57 * (e.g text tokens) 58 */ 59#define BSM_HEADER_SIZE 18 60#define BSM_TRAILER_SIZE 7 61 62/* 63 * BSM token streams store fields in big endian byte order, so as to be 64 * portable; when encoding and decoding, we must convert byte orders for 65 * typed values. 66 */ 67#define ADD_U_CHAR(loc, val) \ 68 do { \ 69 *(loc) = (val); \ 70 (loc) += sizeof(u_char); \ 71 } while(0) 72 73 74#define ADD_U_INT16(loc, val) \ 75 do { \ 76 be16enc((loc), (val)); \ 77 (loc) += sizeof(u_int16_t); \ 78 } while(0) 79 80#define ADD_U_INT32(loc, val) \ 81 do { \ 82 be32enc((loc), (val)); \ 83 (loc) += sizeof(u_int32_t); \ 84 } while(0) 85 86#define ADD_U_INT64(loc, val) \ 87 do { \ 88 be64enc((loc), (val)); \ 89 (loc) += sizeof(u_int64_t); \ 90 } while(0) 91 92#define ADD_MEM(loc, data, size) \ 93 do { \ 94 memcpy((loc), (data), (size)); \ 95 (loc) += size; \ 96 } while(0) 97 98#define ADD_STRING(loc, data, size) ADD_MEM(loc, data, size) 99 100#endif /* !_LIBBSM_INTERNAL_H_ */ 101