2 * Copyright (c) 2000-2001,2005-2007,2010-2012 Apple Inc. All Rights Reserved.
4 * @APPLE_LICENSE_HEADER_START@
6 * This file contains Original Code and/or Modifications of Original Code
7 * as defined in and that are subject to the Apple Public Source License
8 * Version 2.0 (the 'License'). You may not use this file except in
9 * compliance with the License. Please obtain a copy of the License at
10 * http://www.opensource.apple.com/apsl/ and read it before using this
13 * The Original Code and all software distributed under the License are
14 * distributed on an 'AS IS' basis, WITHOUT WARRANTY OF ANY KIND, EITHER
15 * EXPRESS OR IMPLIED, AND APPLE HEREBY DISCLAIMS ALL SUCH WARRANTIES,
16 * INCLUDING WITHOUT LIMITATION, ANY WARRANTIES OF MERCHANTABILITY,
17 * FITNESS FOR A PARTICULAR PURPOSE, QUIET ENJOYMENT OR NON-INFRINGEMENT.
18 * Please see the License for the specific language governing rights and
19 * limitations under the License.
21 * @APPLE_LICENSE_HEADER_END@
25 * sslDebug.h - Debugging macros.
31 #include "sslContext.h"
32 #include <security_utilities/debugging.h>
39 /* If SSL_USE_SYSLOG is defined and not 0, use syslog() for debug
40 * logging in addition to invoking the secdebug macro (which, as of
41 * Snow Leopard, emits a static dtrace probe instead of an actual
44 #ifndef SSL_USE_SYSLOG
45 #define SSL_USE_SYSLOG 0
50 #define ssl_secdebug(scope, format...) \
52 syslog(LOG_NOTICE, format); \
53 secdebug(scope, format); \
56 #define ssl_secdebug(scope, format...) \
57 secdebug(scope, format)
62 /* log changes in handshake state */
63 #define sslHdskStateDebug(args...) ssl_secdebug("sslHdskState", ## args)
65 /* log handshake and alert messages */
66 #define sslHdskMsgDebug(args...) ssl_secdebug("sslHdskMsg", ## args)
68 /* log negotiated handshake parameters */
69 #define sslLogNegotiateDebug(args...) ssl_secdebug("sslLogNegotiate", ## args)
71 /* log received protocol messsages */
72 #define sslLogRxProtocolDebug(msgType) ssl_secdebug("sslLogRxProtocol", \
73 "---received protoMsg %s", msgType)
75 /* log resumable session info */
76 #define sslLogResumSessDebug(args...) ssl_secdebug("sslResumSession", ## args)
78 /* log low-level session info in appleSession.c */
79 #define sslLogSessCacheDebug(args...) ssl_secdebug("sslSessionCache", ## args)
81 /* log record-level I/O (SSLRead, SSLWrite) */
82 #define sslLogRecordIo(args...) ssl_secdebug("sslRecordIo", ## args)
84 /* cert-related info */
85 #define sslCertDebug(args...) ssl_secdebug("sslCert", ## args)
88 #define sslDhDebug(args...) ssl_secdebug("sslDh", ## args)
90 /* EAP-FAST PAC-based session resumption */
91 #define sslEapDebug(args...) ssl_secdebug("sslEap", ## args)
94 #define sslEcdsaDebug(args...) ssl_secdebug("sslEcdsa", ## args)
98 /* deployment build */
99 #define sslHdskStateDebug(args...)
100 #define sslHdskMsgDebug(args...)
101 #define sslLogNegotiateDebug(args...)
102 #define sslLogRxProtocolDebug(msgType)
103 #define sslLogResumSessDebug(args...)
104 #define sslLogSessCacheDebug(args...)
105 #define sslLogRecordIo(args...)
106 #define sslCertDebug(args...)
107 #define sslDhDebug(args...)
108 #define sslEapDebug(args...)
109 #define sslEcdsaDebug(args...)
116 #define SSLChangeHdskState(ctx, newState) { ctx->state=newState; }
117 #define SSLLogHdskMsg(msg, sent)
119 /* all errors logged to stdout for DEBUG config only */
120 #define sslErrorLog(args...)
121 #define sslDebugLog(args...)
122 #define sslDump(d, l)
126 #include "sslAlertMessage.h"
128 extern void SSLLogHdskMsg(SSLHandshakeType msg
, char sent
);
129 extern char *hdskStateToStr(SSLHandshakeState state
);
130 extern void SSLChangeHdskState(SSLContext
*ctx
, SSLHandshakeState newState
);
131 extern void SSLDump(const unsigned char *data
, unsigned long len
);
133 /* extra debug logging of non-error conditions, if SSL_DEBUG is defined */
135 //#define sslDebugLog(args...) printf(args)
136 #define sslDebugLog(args...) ssl_secdebug("sslDebug", ## args)
138 #define sslDebugLog(args...)
140 /* all errors logged to stdout for DEBUG config only */
141 //#define sslErrorLog(args...) printf(args)
142 #define sslErrorLog(args...) ssl_secdebug("sslError", ## args)
143 #define sslDump(d, l) SSLDump((d), (l))
151 #define ASSERT(s) assert(s)
154 #endif /* _SSL_DEBUG_H_ */