1/* 2 * CDDL HEADER START 3 * 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. 7 * 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. 12 * 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] 18 * 19 * CDDL HEADER END 20 */ 21 22/* 23 * Copyright (c) 2010, Oracle and/or its affiliates. All rights reserved. 24 */ 25 26/** 27 * \file KMSAuditLogger.h 28 */ 29 30#ifndef KMSAuditLogger_h 31#define KMSAuditLogger_h 32 33#ifndef METAWARE 34#ifdef WIN32 35#pragma warning(disable: 4786) 36#endif 37 38// SYSCommon.h needs the following include 39#include <stdio.h> 40 41#include "SYSCommon.h" 42#include "AutoMutex.h" 43#endif // METAWARE 44 45#include "ApplianceParameters.h" 46 47 48#define MAX_LOG_FILE_LINE_LENGTH MAXIMUM_UTF8_STRING_VALUE_LENGTH + 128 49#define MAX_LOG_FILE_NAME_LENGTH 256 50 51/** 52 * Opens a logging file for appending, or creation, 53 * with the name "KMSAgentLog.log" beneath the specified directory. 54 * @return true on success 55 */ 56int InitializeFileLogging( const char* const i_sWorkingDirectory ); 57 58/** 59 * closes the log file 60 * @return true if successful close 61 */ 62int FinalizeFileLogging(); 63 64/** 65 * write a log entry to the log file 66 * @return true if successful 67 */ 68extern "C" int LogToFile( int i_iErrno, 69 const char* const i_sLogLine ); 70 71/** 72 * Formats a message and to the log file using <code>LogToFile</code>, 73 * generating a ISO8601UTC timestamp and 74 * appending the various function arguments together. 75 * @param i_sOperation optional, an operation and error condition string 76 * @param i_sEntityID optional, the name of the entity performing the operation 77 * @param i_sNetworkAddress optional, the address of the KMS involved in the operation 78 * @param i_sMessage optional, the error message details 79 * @return 0 if successful 80 */ 81int Log_function( 82 int i_iErrno, 83 const char* const i_sOperation, 84 const char* const i_sEntityID, 85 const char* const i_sNetworkAddress, 86 const char* const i_sMessage ); 87 88// helper macro to convert value to a string 89#define Log(a,b,c,d) Log_function(a, #a, b, c, d) 90 91#define AUDIT_CLIENT_LOG_BASE 0x200 92 93#define AUDIT_CLIENT_LOAD_PROFILE_CREATE_DIRECTORY_FAILED (AUDIT_CLIENT_LOG_BASE + 0x0) 94#define AUDIT_CLIENT_LOAD_PROFILE_CREATE_PROFILE_CONFIG_FAILED (AUDIT_CLIENT_LOG_BASE + 0x1) 95#define AUDIT_CLIENT_LOAD_PROFILE_CREATE_PROFILE_CONFIG_SUCCEEDED (AUDIT_CLIENT_LOG_BASE + 0x2) 96#define AUDIT_CLIENT_SAVE_CLUSTER_INFORMATION_SUCCEEDED (AUDIT_CLIENT_LOG_BASE + 0x3) 97 98#define AUDIT_CLIENT_GET_ROOT_CA_CERTIFICATE_SUCCESS (AUDIT_CLIENT_LOG_BASE + 0x4) 99#define AUDIT_CLIENT_GET_CERTIFICATE_SUCCESS (AUDIT_CLIENT_LOG_BASE + 0x5) 100#define AUDIT_CLIENT_LOAD_PROFILE (AUDIT_CLIENT_LOG_BASE + 0x6) 101#define AUDIT_CLIENT_GetClusterInformation (AUDIT_CLIENT_LOG_BASE + 0x7) 102 103#define AGENT_LOADBALANCER_FAILOVER (AUDIT_CLIENT_LOG_BASE + 0x8) 104 105#define AUDIT_CLIENT_AGENT_GET_CLUSTER_INFORMATION_INVALID_PARAMETERS (AUDIT_CLIENT_LOG_BASE + 0x9) 106#define AUDIT_CLIENT_AGENT_SELECT_APPLIANCE_INVALID_PARAMETERS (AUDIT_CLIENT_LOG_BASE + 0xa) 107#define AUDIT_CLIENT_AGENT_LOAD_PROFILE_INVALID_PARAMETERS (AUDIT_CLIENT_LOG_BASE + 0xc) 108#define AUDIT_CLIENT_AGENT_UNLOAD_PROFILE_INVALID_PARAMETERS (AUDIT_CLIENT_LOG_BASE + 0xd) 109#define AUDIT_CLIENT_AGENT_LIST_KEY_GROUPS_INVALID_PARAMETERS (AUDIT_CLIENT_LOG_BASE + 0xe) 110#define AUDIT_CLIENT_AGENT_CREATE_KEY_INVALID_PARAMETERS (AUDIT_CLIENT_LOG_BASE + 0xf) 111#define AUDIT_CLIENT_AGENT_CREATE_DATA_UNIT_INVALID_PARAMETERS (AUDIT_CLIENT_LOG_BASE + 0x10) 112#define AUDIT_CLIENT_AGENT_DISASSOCIATE_DATA_UNIT_KEYS_INVALID_PARAMETERS (AUDIT_CLIENT_LOG_BASE + 0x11) 113#define AUDIT_CLIENT_AGENT_RETRIEVE_KEY_INVALID_PARAMETERS (AUDIT_CLIENT_LOG_BASE + 0x12) 114#define AUDIT_CLIENT_AGENT_RETRIEVE_DATA_UNIT_INVALID_PARAMETERS (AUDIT_CLIENT_LOG_BASE + 0x13) 115#define AUDIT_CLIENT_AGENT_RETRIEVE_DATA_UNIT_BY_EXTERNAL_UNIQUE_ID_INVALID_PARAMETERS (AUDIT_CLIENT_LOG_BASE + 0x14) 116#define AUDIT_CLIENT_AGENT_RETRIEVE_DATA_UNIT_KEYS_INVALID_PARAMETERS (AUDIT_CLIENT_LOG_BASE + 0x15) 117#define AUDIT_CLIENT_AGENT_RETRIEVE_PROTECT_AND_PROCESS_KEY_INVALID_PARAMETERS (AUDIT_CLIENT_LOG_BASE + 0x16) 118#define AUDIT_CLIENT_AGENT_CREATE_AUDIT_LOG_INVALID_PARAMETERS (AUDIT_CLIENT_LOG_BASE + 0x17) 119#define AUDIT_CLIENT_AGENT_CREATED_AUDIT_LOG_INVALID_PARAMETERS (AUDIT_CLIENT_LOG_BASE + 0x18) 120#define AUDIT_CLIENT_AGENT_LOAD_PROFILE_PROFILE_ALREADY_LOADED (AUDIT_CLIENT_LOG_BASE + 0x19) 121#define AGENT_LOADBALANCER_AESKEYUNWRAP_GETKWK_RETURNED_NULL (AUDIT_CLIENT_LOG_BASE + 0x1a) 122#define AGENT_LOADBALANCER_AESKEYUNWRAP_KEY_UNWRAP_FAILED (AUDIT_CLIENT_LOG_BASE + 0x1b) 123#define AUDIT_CLIENT_FILTER_CLUSTER_FAILED (AUDIT_CLIENT_LOG_BASE + 0x1c) 124#define AUDIT_CLIENT_FILTER_CLUSTER (AUDIT_CLIENT_LOG_BASE + 0x1d) 125 126 127 128 129 130 131int Log_function(int i_iErrno, 132 const char* const i_sOperation, 133 const char* const i_sEntityID, 134 const char* const i_sNetworkAddress, 135 const char* const i_sMessage ); 136 137/** 138 * Log generically 2 parameters (presumably to the screen, 139 * but could be to a file 140 */ 141extern "C" int Log2(char* msg1, 142 char* msg2); 143 144#endif //KMSAuditLogger_h 145