/*-1* SPDX-License-Identifier: BSD-3-Clause2*3* Copyright (c) 2005-2008 Apple Inc.4* Copyright (c) 2005 SPARTA, Inc.5* All rights reserved.6*7* This code was developed in part by Robert N. M. Watson, Senior Principal8* Scientist, SPARTA, Inc.9*10* Redistribution and use in source and binary forms, with or without11* modification, are permitted provided that the following conditions12* are met:13*14* 1. Redistributions of source code must retain the above copyright15* notice, this list of conditions and the following disclaimer.16* 2. Redistributions in binary form must reproduce the above copyright17* notice, this list of conditions and the following disclaimer in the18* documentation and/or other materials provided with the distribution.19* 3. Neither the name of Apple Inc. ("Apple") nor the names of20* its contributors may be used to endorse or promote products derived21* from this software without specific prior written permission.22*23* THIS SOFTWARE IS PROVIDED BY APPLE AND ITS CONTRIBUTORS "AS IS" AND ANY24* EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED25* WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE26* DISCLAIMED. IN NO EVENT SHALL APPLE OR ITS CONTRIBUTORS BE LIABLE FOR ANY27* DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES28* (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES;29* LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND30* ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT31* (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF32* THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.33*/3435#ifndef _AUDIT_INTERNAL_H36#define _AUDIT_INTERNAL_H3738#if defined(__linux__) && !defined(__unused)39#define __unused40#endif4142/*43* audit_internal.h contains private interfaces that are shared by user space44* and the kernel for the purposes of assembling audit records. Applications45* should not include this file or use the APIs found within, or it may be46* broken with future releases of OpenBSM, which may delete, modify, or47* otherwise break these interfaces or the assumptions they rely on.48*/49struct au_token {50u_char *t_data;51size_t len;52TAILQ_ENTRY(au_token) tokens;53};5455struct au_record {56char used; /* Record currently in use? */57int desc; /* Descriptor for record. */58TAILQ_HEAD(, au_token) token_q; /* Queue of BSM tokens. */59u_char *data;60size_t len;61LIST_ENTRY(au_record) au_rec_q;62};63typedef struct au_record au_record_t;646566/*67* We could determined the header and trailer sizes by defining appropriate68* structures. We hold off that approach until we have a consistent way of69* using structures for all tokens. This is not straightforward since these70* token structures may contain pointers of whose contents we do not know the71* size (e.g text tokens).72*/73#define AUDIT_HEADER_EX_SIZE(a) ((a)->ai_termid.at_type+18+sizeof(u_int32_t))74#define AUDIT_HEADER_SIZE 1875#define MAX_AUDIT_HEADER_SIZE (5*sizeof(u_int32_t)+18)76#define AUDIT_TRAILER_SIZE 77778/*79* BSM token streams store fields in big endian byte order, so as to be80* portable; when encoding and decoding, we must convert byte orders for81* typed values.82*/83#define ADD_U_CHAR(loc, val) \84do { \85*(loc) = (val); \86(loc) += sizeof(u_char); \87} while(0)888990#define ADD_U_INT16(loc, val) \91do { \92be16enc((loc), (val)); \93(loc) += sizeof(u_int16_t); \94} while(0)9596#define ADD_U_INT32(loc, val) \97do { \98be32enc((loc), (val)); \99(loc) += sizeof(u_int32_t); \100} while(0)101102#define ADD_U_INT64(loc, val) \103do { \104be64enc((loc), (val)); \105(loc) += sizeof(u_int64_t); \106} while(0)107108#define ADD_MEM(loc, data, size) \109do { \110memcpy((loc), (data), (size)); \111(loc) += size; \112} while(0)113114#define ADD_STRING(loc, data, size) ADD_MEM(loc, data, size)115116#endif /* !_AUDIT_INTERNAL_H_ */117118119