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