xref: /onnv-gate/usr/src/lib/libkmsagent/common/KMSAuditLogger.h (revision 12720:3db6e0082404)
1*12720SWyllys.Ingersoll@Sun.COM /*
2*12720SWyllys.Ingersoll@Sun.COM  * CDDL HEADER START
3*12720SWyllys.Ingersoll@Sun.COM  *
4*12720SWyllys.Ingersoll@Sun.COM  * The contents of this file are subject to the terms of the
5*12720SWyllys.Ingersoll@Sun.COM  * Common Development and Distribution License (the "License").
6*12720SWyllys.Ingersoll@Sun.COM  * You may not use this file except in compliance with the License.
7*12720SWyllys.Ingersoll@Sun.COM  *
8*12720SWyllys.Ingersoll@Sun.COM  * You can obtain a copy of the license at usr/src/OPENSOLARIS.LICENSE
9*12720SWyllys.Ingersoll@Sun.COM  * or http://www.opensolaris.org/os/licensing.
10*12720SWyllys.Ingersoll@Sun.COM  * See the License for the specific language governing permissions
11*12720SWyllys.Ingersoll@Sun.COM  * and limitations under the License.
12*12720SWyllys.Ingersoll@Sun.COM  *
13*12720SWyllys.Ingersoll@Sun.COM  * When distributing Covered Code, include this CDDL HEADER in each
14*12720SWyllys.Ingersoll@Sun.COM  * file and include the License file at usr/src/OPENSOLARIS.LICENSE.
15*12720SWyllys.Ingersoll@Sun.COM  * If applicable, add the following below this CDDL HEADER, with the
16*12720SWyllys.Ingersoll@Sun.COM  * fields enclosed by brackets "[]" replaced with your own identifying
17*12720SWyllys.Ingersoll@Sun.COM  * information: Portions Copyright [yyyy] [name of copyright owner]
18*12720SWyllys.Ingersoll@Sun.COM  *
19*12720SWyllys.Ingersoll@Sun.COM  * CDDL HEADER END
20*12720SWyllys.Ingersoll@Sun.COM  */
21*12720SWyllys.Ingersoll@Sun.COM 
22*12720SWyllys.Ingersoll@Sun.COM /*
23*12720SWyllys.Ingersoll@Sun.COM  * Copyright (c) 2010, Oracle and/or its affiliates. All rights reserved.
24*12720SWyllys.Ingersoll@Sun.COM  */
25*12720SWyllys.Ingersoll@Sun.COM 
26*12720SWyllys.Ingersoll@Sun.COM /**
27*12720SWyllys.Ingersoll@Sun.COM  * \file KMSAuditLogger.h
28*12720SWyllys.Ingersoll@Sun.COM  */
29*12720SWyllys.Ingersoll@Sun.COM 
30*12720SWyllys.Ingersoll@Sun.COM #ifndef KMSAuditLogger_h
31*12720SWyllys.Ingersoll@Sun.COM #define KMSAuditLogger_h
32*12720SWyllys.Ingersoll@Sun.COM 
33*12720SWyllys.Ingersoll@Sun.COM #ifndef METAWARE
34*12720SWyllys.Ingersoll@Sun.COM #ifdef WIN32
35*12720SWyllys.Ingersoll@Sun.COM #pragma warning(disable: 4786)
36*12720SWyllys.Ingersoll@Sun.COM #endif
37*12720SWyllys.Ingersoll@Sun.COM 
38*12720SWyllys.Ingersoll@Sun.COM // SYSCommon.h needs the following include
39*12720SWyllys.Ingersoll@Sun.COM #include <stdio.h>
40*12720SWyllys.Ingersoll@Sun.COM 
41*12720SWyllys.Ingersoll@Sun.COM #include "SYSCommon.h"
42*12720SWyllys.Ingersoll@Sun.COM #include "AutoMutex.h"
43*12720SWyllys.Ingersoll@Sun.COM #endif // METAWARE
44*12720SWyllys.Ingersoll@Sun.COM 
45*12720SWyllys.Ingersoll@Sun.COM #include "ApplianceParameters.h"
46*12720SWyllys.Ingersoll@Sun.COM 
47*12720SWyllys.Ingersoll@Sun.COM 
48*12720SWyllys.Ingersoll@Sun.COM #define MAX_LOG_FILE_LINE_LENGTH    MAXIMUM_UTF8_STRING_VALUE_LENGTH + 128
49*12720SWyllys.Ingersoll@Sun.COM #define MAX_LOG_FILE_NAME_LENGTH    256
50*12720SWyllys.Ingersoll@Sun.COM 
51*12720SWyllys.Ingersoll@Sun.COM /**
52*12720SWyllys.Ingersoll@Sun.COM  *  Opens a logging file for appending, or creation,
53*12720SWyllys.Ingersoll@Sun.COM  *  with the name "KMSAgentLog.log" beneath the specified directory.
54*12720SWyllys.Ingersoll@Sun.COM  *  @return true on success
55*12720SWyllys.Ingersoll@Sun.COM  */
56*12720SWyllys.Ingersoll@Sun.COM int InitializeFileLogging( const char* const i_sWorkingDirectory );
57*12720SWyllys.Ingersoll@Sun.COM 
58*12720SWyllys.Ingersoll@Sun.COM /**
59*12720SWyllys.Ingersoll@Sun.COM  *  closes the log file
60*12720SWyllys.Ingersoll@Sun.COM  *  @return true if successful close
61*12720SWyllys.Ingersoll@Sun.COM  */
62*12720SWyllys.Ingersoll@Sun.COM int FinalizeFileLogging();
63*12720SWyllys.Ingersoll@Sun.COM 
64*12720SWyllys.Ingersoll@Sun.COM /**
65*12720SWyllys.Ingersoll@Sun.COM  *  write a log entry to the log file
66*12720SWyllys.Ingersoll@Sun.COM  *  @return true if successful
67*12720SWyllys.Ingersoll@Sun.COM  */
68*12720SWyllys.Ingersoll@Sun.COM extern "C" int LogToFile( int i_iErrno,
69*12720SWyllys.Ingersoll@Sun.COM                           const char* const i_sLogLine );
70*12720SWyllys.Ingersoll@Sun.COM 
71*12720SWyllys.Ingersoll@Sun.COM /**
72*12720SWyllys.Ingersoll@Sun.COM  *  Formats a message and to the log file using <code>LogToFile</code>,
73*12720SWyllys.Ingersoll@Sun.COM  *  generating a ISO8601UTC timestamp and
74*12720SWyllys.Ingersoll@Sun.COM  *  appending the various function arguments together.
75*12720SWyllys.Ingersoll@Sun.COM  *  @param i_sOperation optional, an operation and error condition string
76*12720SWyllys.Ingersoll@Sun.COM  *  @param i_sEntityID optional, the name of the entity performing the operation
77*12720SWyllys.Ingersoll@Sun.COM  *  @param i_sNetworkAddress optional, the address of the KMS involved in the operation
78*12720SWyllys.Ingersoll@Sun.COM  *  @param i_sMessage optional, the error message details
79*12720SWyllys.Ingersoll@Sun.COM  *  @return 0 if successful
80*12720SWyllys.Ingersoll@Sun.COM  */
81*12720SWyllys.Ingersoll@Sun.COM int Log_function(
82*12720SWyllys.Ingersoll@Sun.COM    int i_iErrno,
83*12720SWyllys.Ingersoll@Sun.COM    const char* const i_sOperation,
84*12720SWyllys.Ingersoll@Sun.COM    const char* const i_sEntityID,
85*12720SWyllys.Ingersoll@Sun.COM    const char* const i_sNetworkAddress,
86*12720SWyllys.Ingersoll@Sun.COM    const char* const i_sMessage );
87*12720SWyllys.Ingersoll@Sun.COM 
88*12720SWyllys.Ingersoll@Sun.COM // helper macro to convert value to a string
89*12720SWyllys.Ingersoll@Sun.COM #define Log(a,b,c,d) Log_function(a, #a, b, c, d)
90*12720SWyllys.Ingersoll@Sun.COM 
91*12720SWyllys.Ingersoll@Sun.COM #define AUDIT_CLIENT_LOG_BASE 0x200
92*12720SWyllys.Ingersoll@Sun.COM 
93*12720SWyllys.Ingersoll@Sun.COM #define AUDIT_CLIENT_LOAD_PROFILE_CREATE_DIRECTORY_FAILED           (AUDIT_CLIENT_LOG_BASE + 0x0)
94*12720SWyllys.Ingersoll@Sun.COM #define AUDIT_CLIENT_LOAD_PROFILE_CREATE_PROFILE_CONFIG_FAILED      (AUDIT_CLIENT_LOG_BASE + 0x1)
95*12720SWyllys.Ingersoll@Sun.COM #define AUDIT_CLIENT_LOAD_PROFILE_CREATE_PROFILE_CONFIG_SUCCEEDED   (AUDIT_CLIENT_LOG_BASE + 0x2)
96*12720SWyllys.Ingersoll@Sun.COM #define AUDIT_CLIENT_SAVE_CLUSTER_INFORMATION_SUCCEEDED             (AUDIT_CLIENT_LOG_BASE + 0x3)
97*12720SWyllys.Ingersoll@Sun.COM 
98*12720SWyllys.Ingersoll@Sun.COM #define AUDIT_CLIENT_GET_ROOT_CA_CERTIFICATE_SUCCESS                (AUDIT_CLIENT_LOG_BASE + 0x4)
99*12720SWyllys.Ingersoll@Sun.COM #define AUDIT_CLIENT_GET_CERTIFICATE_SUCCESS                        (AUDIT_CLIENT_LOG_BASE + 0x5)
100*12720SWyllys.Ingersoll@Sun.COM #define AUDIT_CLIENT_LOAD_PROFILE                                   (AUDIT_CLIENT_LOG_BASE + 0x6)
101*12720SWyllys.Ingersoll@Sun.COM #define AUDIT_CLIENT_GetClusterInformation                          (AUDIT_CLIENT_LOG_BASE + 0x7)
102*12720SWyllys.Ingersoll@Sun.COM 
103*12720SWyllys.Ingersoll@Sun.COM #define AGENT_LOADBALANCER_FAILOVER                                 (AUDIT_CLIENT_LOG_BASE + 0x8)
104*12720SWyllys.Ingersoll@Sun.COM 
105*12720SWyllys.Ingersoll@Sun.COM #define AUDIT_CLIENT_AGENT_GET_CLUSTER_INFORMATION_INVALID_PARAMETERS      (AUDIT_CLIENT_LOG_BASE + 0x9)
106*12720SWyllys.Ingersoll@Sun.COM #define AUDIT_CLIENT_AGENT_SELECT_APPLIANCE_INVALID_PARAMETERS             (AUDIT_CLIENT_LOG_BASE + 0xa)
107*12720SWyllys.Ingersoll@Sun.COM #define AUDIT_CLIENT_AGENT_LOAD_PROFILE_INVALID_PARAMETERS                 (AUDIT_CLIENT_LOG_BASE + 0xc)
108*12720SWyllys.Ingersoll@Sun.COM #define AUDIT_CLIENT_AGENT_UNLOAD_PROFILE_INVALID_PARAMETERS               (AUDIT_CLIENT_LOG_BASE + 0xd)
109*12720SWyllys.Ingersoll@Sun.COM #define AUDIT_CLIENT_AGENT_LIST_KEY_GROUPS_INVALID_PARAMETERS              (AUDIT_CLIENT_LOG_BASE + 0xe)
110*12720SWyllys.Ingersoll@Sun.COM #define AUDIT_CLIENT_AGENT_CREATE_KEY_INVALID_PARAMETERS                   (AUDIT_CLIENT_LOG_BASE + 0xf)
111*12720SWyllys.Ingersoll@Sun.COM #define AUDIT_CLIENT_AGENT_CREATE_DATA_UNIT_INVALID_PARAMETERS             (AUDIT_CLIENT_LOG_BASE + 0x10)
112*12720SWyllys.Ingersoll@Sun.COM #define AUDIT_CLIENT_AGENT_DISASSOCIATE_DATA_UNIT_KEYS_INVALID_PARAMETERS  (AUDIT_CLIENT_LOG_BASE + 0x11)
113*12720SWyllys.Ingersoll@Sun.COM #define AUDIT_CLIENT_AGENT_RETRIEVE_KEY_INVALID_PARAMETERS                 (AUDIT_CLIENT_LOG_BASE + 0x12)
114*12720SWyllys.Ingersoll@Sun.COM #define AUDIT_CLIENT_AGENT_RETRIEVE_DATA_UNIT_INVALID_PARAMETERS           (AUDIT_CLIENT_LOG_BASE + 0x13)
115*12720SWyllys.Ingersoll@Sun.COM #define AUDIT_CLIENT_AGENT_RETRIEVE_DATA_UNIT_BY_EXTERNAL_UNIQUE_ID_INVALID_PARAMETERS      (AUDIT_CLIENT_LOG_BASE + 0x14)
116*12720SWyllys.Ingersoll@Sun.COM #define AUDIT_CLIENT_AGENT_RETRIEVE_DATA_UNIT_KEYS_INVALID_PARAMETERS      (AUDIT_CLIENT_LOG_BASE + 0x15)
117*12720SWyllys.Ingersoll@Sun.COM #define AUDIT_CLIENT_AGENT_RETRIEVE_PROTECT_AND_PROCESS_KEY_INVALID_PARAMETERS      (AUDIT_CLIENT_LOG_BASE + 0x16)
118*12720SWyllys.Ingersoll@Sun.COM #define AUDIT_CLIENT_AGENT_CREATE_AUDIT_LOG_INVALID_PARAMETERS              (AUDIT_CLIENT_LOG_BASE + 0x17)
119*12720SWyllys.Ingersoll@Sun.COM #define AUDIT_CLIENT_AGENT_CREATED_AUDIT_LOG_INVALID_PARAMETERS             (AUDIT_CLIENT_LOG_BASE + 0x18)
120*12720SWyllys.Ingersoll@Sun.COM #define AUDIT_CLIENT_AGENT_LOAD_PROFILE_PROFILE_ALREADY_LOADED              (AUDIT_CLIENT_LOG_BASE + 0x19)
121*12720SWyllys.Ingersoll@Sun.COM #define AGENT_LOADBALANCER_AESKEYUNWRAP_GETKWK_RETURNED_NULL                (AUDIT_CLIENT_LOG_BASE + 0x1a)
122*12720SWyllys.Ingersoll@Sun.COM #define AGENT_LOADBALANCER_AESKEYUNWRAP_KEY_UNWRAP_FAILED                   (AUDIT_CLIENT_LOG_BASE + 0x1b)
123*12720SWyllys.Ingersoll@Sun.COM #define AUDIT_CLIENT_FILTER_CLUSTER_FAILED                                  (AUDIT_CLIENT_LOG_BASE + 0x1c)
124*12720SWyllys.Ingersoll@Sun.COM #define AUDIT_CLIENT_FILTER_CLUSTER                                         (AUDIT_CLIENT_LOG_BASE + 0x1d)
125*12720SWyllys.Ingersoll@Sun.COM 
126*12720SWyllys.Ingersoll@Sun.COM 
127*12720SWyllys.Ingersoll@Sun.COM 
128*12720SWyllys.Ingersoll@Sun.COM 
129*12720SWyllys.Ingersoll@Sun.COM 
130*12720SWyllys.Ingersoll@Sun.COM 
131*12720SWyllys.Ingersoll@Sun.COM int Log_function(int i_iErrno,
132*12720SWyllys.Ingersoll@Sun.COM                  const char* const i_sOperation,
133*12720SWyllys.Ingersoll@Sun.COM                  const char* const i_sEntityID,
134*12720SWyllys.Ingersoll@Sun.COM                  const char* const i_sNetworkAddress,
135*12720SWyllys.Ingersoll@Sun.COM                  const char* const i_sMessage );
136*12720SWyllys.Ingersoll@Sun.COM 
137*12720SWyllys.Ingersoll@Sun.COM /**
138*12720SWyllys.Ingersoll@Sun.COM  * Log generically 2 parameters (presumably to the screen,
139*12720SWyllys.Ingersoll@Sun.COM  * but could be to a file
140*12720SWyllys.Ingersoll@Sun.COM  */
141*12720SWyllys.Ingersoll@Sun.COM extern "C" int Log2(char* msg1,
142*12720SWyllys.Ingersoll@Sun.COM                     char* msg2);
143*12720SWyllys.Ingersoll@Sun.COM 
144*12720SWyllys.Ingersoll@Sun.COM #endif //KMSAuditLogger_h
145