Expand PMF_FN_* macros.
[netbsd-mini2440.git] / external / apache2 / mDNSResponder / dist / mDNSCore / mDNSDebug.h
blob54f9e4773839e4860dabeb51a183463c8d214495
1 /* -*- Mode: C; tab-width: 4 -*-
3 * Copyright (c) 2002-2003 Apple Computer, Inc. All rights reserved.
5 * Licensed under the Apache License, Version 2.0 (the "License");
6 * you may not use this file except in compliance with the License.
7 * You may obtain a copy of the License at
8 *
9 * http://www.apache.org/licenses/LICENSE-2.0
11 * Unless required by applicable law or agreed to in writing, software
12 * distributed under the License is distributed on an "AS IS" BASIS,
13 * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
14 * See the License for the specific language governing permissions and
15 * limitations under the License.
17 Change History (most recent first):
19 Log: mDNSDebug.h,v $
20 Revision 1.51 2009/06/25 23:36:59 cheshire
21 To facilitate testing, added command-line switch "-OfferSleepProxyService"
22 to re-enable the previously-supported mode of operation where we offer
23 sleep proxy service on desktop Macs that are set to never sleep.
25 Revision 1.50 2009/05/19 23:34:06 cheshire
26 Updated comment to show correct metric of 80 for a low-priority sleep proxy
28 Revision 1.49 2009/04/24 23:32:28 cheshire
29 To facilitate testing, put back code to be a sleep proxy when set to never sleep, compiled out by compile-time switch
31 Revision 1.48 2009/04/11 01:43:27 jessic2
32 <rdar://problem/4426780> Daemon: Should be able to turn on LogOperation dynamically
34 Revision 1.47 2009/04/11 00:19:41 jessic2
35 <rdar://problem/4426780> Daemon: Should be able to turn on LogOperation dynamically
37 Revision 1.46 2009/02/13 06:36:50 cheshire
38 Update LogSPS definition
40 Revision 1.45 2009/02/13 06:03:12 cheshire
41 Added LogInfo for informational message logging
43 Revision 1.44 2009/02/12 20:57:25 cheshire
44 Renamed 'LogAllOperation' switch to 'LogClientOperations'; added new 'LogSleepProxyActions' switch
46 Revision 1.43 2008/12/10 02:27:14 cheshire
47 Commented out definitions of LogClientOperations, LogTimeStamps, ForceAlerts and MACOSX_MDNS_MALLOC_DEBUGGING
48 to allow overriding values to be easily defined in a Makefile or similar build environment
50 Revision 1.42 2008/11/02 21:22:05 cheshire
51 Changed mallocL size parameter back to "unsigned int"
53 Revision 1.41 2008/11/02 21:14:58 cheshire
54 Fixes to make mallocL/freeL debugging checks work on 64-bit
56 Revision 1.40 2008/10/24 20:53:37 cheshire
57 For now, define USE_SEPARATE_UDNS_SERVICE_LIST, so that we use the old service list code for this submission
59 Revision 1.39 2008/02/26 21:17:11 cheshire
60 Grouped all user settings together near the start of the file; added LogTimeStamps option
62 Revision 1.38 2007/12/13 20:27:07 cheshire
63 Remove unused VerifySameNameAssumptions symbol
65 Revision 1.37 2007/12/01 00:33:17 cheshire
66 Fixes from Bob Bradley for building on EFI
68 Revision 1.36 2007/10/01 19:06:19 cheshire
69 Defined symbolic constant MDNS_LOG_INITIAL_LEVEL to set the logging level we start out at
71 Revision 1.35 2007/07/27 20:19:56 cheshire
72 For now, comment out unused log levels MDNS_LOG_ERROR, MDNS_LOG_WARN, MDNS_LOG_INFO, MDNS_LOG_DEBUG
74 Revision 1.34 2007/07/24 17:23:33 cheshire
75 <rdar://problem/5357133> Add list validation checks for debugging
77 Revision 1.33 2007/06/15 21:54:50 cheshire
78 <rdar://problem/4883206> Add packet logging to help debugging private browsing over TLS
80 Revision 1.32 2007/05/25 16:03:03 cheshire
81 Remove unused LogMalloc
83 Revision 1.31 2007/04/06 19:50:05 cheshire
84 Add ProgramName declaration
86 Revision 1.30 2007/03/24 01:22:44 cheshire
87 Add validator for uDNS data structures
89 Revision 1.29 2006/08/14 23:24:23 cheshire
90 Re-licensed mDNSResponder daemon source code under Apache License, Version 2.0
92 Revision 1.28 2006/07/07 01:09:09 cheshire
93 <rdar://problem/4472013> Add Private DNS server functionality to dnsextd
94 Only use mallocL/freeL debugging routines when building mDNSResponder, not dnsextd
96 Revision 1.27 2006/06/29 07:42:14 cheshire
97 <rdar://problem/3922989> Performance: Remove unnecessary SameDomainName() checks
99 Revision 1.26 2005/07/04 22:40:26 cheshire
100 Additional debugging code to help catch memory corruption
102 Revision 1.25 2004/12/14 21:34:16 cheshire
103 Add "#define ANSWER_REMOTE_HOSTNAME_QUERIES 0" and comment
105 Revision 1.24 2004/09/16 01:58:21 cheshire
106 Fix compiler warnings
108 Revision 1.23 2004/05/18 23:51:25 cheshire
109 Tidy up all checkin comments to use consistent "<rdar://problem/xxxxxxx>" format for bug numbers
111 Revision 1.22 2004/04/22 04:27:42 cheshire
112 Spacing tidyup
114 Revision 1.21 2004/04/14 23:21:41 ksekar
115 Removed accidental checkin of MALLOC_DEBUGING flag in 1.20
117 Revision 1.20 2004/04/14 23:09:28 ksekar
118 Support for TSIG signed dynamic updates.
120 Revision 1.19 2004/03/15 18:57:59 cheshire
121 Undo last checkin that accidentally made verbose debugging the default for all targets
123 Revision 1.18 2004/03/13 01:57:33 ksekar
124 <rdar://problem/3192546>: DynDNS: Dynamic update of service records
126 Revision 1.17 2004/01/28 21:14:23 cheshire
127 Reconcile debug_mode and gDebugLogging into a single flag (mDNS_DebugMode)
129 Revision 1.16 2003/12/09 01:30:06 rpantos
130 Fix usage of ARGS... macros to build properly on Windows.
132 Revision 1.15 2003/12/08 20:55:26 rpantos
133 Move some definitions here from mDNSMacOSX.h.
135 Revision 1.14 2003/08/12 19:56:24 cheshire
136 Update to APSL 2.0
138 Revision 1.13 2003/07/02 21:19:46 cheshire
139 <rdar://problem/3313413> Update copyright notices, etc., in source code comments
141 Revision 1.12 2003/05/26 03:01:27 cheshire
142 <rdar://problem/3268904> sprintf/vsprintf-style functions are unsafe; use snprintf/vsnprintf instead
144 Revision 1.11 2003/05/21 17:48:10 cheshire
145 Add macro to enable GCC's printf format string checking
147 Revision 1.10 2003/04/26 02:32:57 cheshire
148 Add extern void LogMsg(const char *format, ...);
150 Revision 1.9 2002/09/21 20:44:49 zarzycki
151 Added APSL info
153 Revision 1.8 2002/09/19 04:20:43 cheshire
154 Remove high-ascii characters that confuse some systems
156 Revision 1.7 2002/09/16 18:41:42 cheshire
157 Merge in license terms from Quinn's copy, in preparation for Darwin release
161 #ifndef __mDNSDebug_h
162 #define __mDNSDebug_h
164 // Set MDNS_DEBUGMSGS to 0 to optimize debugf() calls out of the compiled code
165 // Set MDNS_DEBUGMSGS to 1 to generate normal debugging messages
166 // Set MDNS_DEBUGMSGS to 2 to generate verbose debugging messages
167 // MDNS_DEBUGMSGS is normally set in the project options (or makefile) but can also be set here if desired
168 // (If you edit the file here to turn on MDNS_DEBUGMSGS while you're debugging some code, be careful
169 // not to accidentally check-in that change by mistake when you check in your other changes.)
171 //#undef MDNS_DEBUGMSGS
172 //#define MDNS_DEBUGMSGS 2
174 // Set MDNS_CHECK_PRINTF_STYLE_FUNCTIONS to 1 to enable extra GCC compiler warnings
175 // Note: You don't normally want to do this, because it generates a bunch of
176 // spurious warnings for the following custom extensions implemented by mDNS_vsnprintf:
177 // warning: `#' flag used with `%s' printf format (for %#s -- pascal string format)
178 // warning: repeated `#' flag in format (for %##s -- DNS name string format)
179 // warning: double format, pointer arg (arg 2) (for %.4a, %.16a, %#a -- IP address formats)
180 #define MDNS_CHECK_PRINTF_STYLE_FUNCTIONS 0
182 typedef enum
184 MDNS_LOG_MSG,
185 MDNS_LOG_OPERATION,
186 MDNS_LOG_SPS,
187 MDNS_LOG_INFO,
188 MDNS_LOG_DEBUG,
189 } mDNSLogLevel_t;
191 // Set this symbol to 1 to answer remote queries for our Address, reverse mapping PTR, and HINFO records
192 #define ANSWER_REMOTE_HOSTNAME_QUERIES 0
194 // Set this symbol to 1 to do extra debug checks on malloc() and free()
195 // Set this symbol to 2 to write a log message for every malloc() and free()
196 //#define MACOSX_MDNS_MALLOC_DEBUGGING 1
198 //#define ForceAlerts 1
199 //#define LogTimeStamps 1
201 #define USE_SEPARATE_UDNS_SERVICE_LIST 1
203 // Developer-settings section ends here
205 #if MDNS_CHECK_PRINTF_STYLE_FUNCTIONS
206 #define IS_A_PRINTF_STYLE_FUNCTION(F,A) __attribute__ ((format(printf,F,A)))
207 #else
208 #define IS_A_PRINTF_STYLE_FUNCTION(F,A)
209 #endif
211 #ifdef __cplusplus
212 extern "C" {
213 #endif
215 // Variable argument macro support. Use ANSI C99 __VA_ARGS__ where possible. Otherwise, use the next best thing.
217 #if (defined(__GNUC__))
218 #if ((__GNUC__ > 3) || ((__GNUC__ == 3) && (__GNUC_MINOR__ >= 2)))
219 #define MDNS_C99_VA_ARGS 1
220 #define MDNS_GNU_VA_ARGS 0
221 #else
222 #define MDNS_C99_VA_ARGS 0
223 #define MDNS_GNU_VA_ARGS 1
224 #endif
225 #define MDNS_HAS_VA_ARG_MACROS 1
226 #elif (_MSC_VER >= 1400) // Visual Studio 2005 and later
227 #define MDNS_C99_VA_ARGS 1
228 #define MDNS_GNU_VA_ARGS 0
229 #define MDNS_HAS_VA_ARG_MACROS 1
230 #elif (defined(__MWERKS__))
231 #define MDNS_C99_VA_ARGS 1
232 #define MDNS_GNU_VA_ARGS 0
233 #define MDNS_HAS_VA_ARG_MACROS 1
234 #else
235 #define MDNS_C99_VA_ARGS 0
236 #define MDNS_GNU_VA_ARGS 0
237 #define MDNS_HAS_VA_ARG_MACROS 0
238 #endif
240 #if (MDNS_HAS_VA_ARG_MACROS)
241 #if (MDNS_C99_VA_ARGS)
242 #define debug_noop( ... ) ((void)0)
243 #define LogMsg( ... ) LogMsgWithLevel(MDNS_LOG_MSG, __VA_ARGS__)
244 #define LogOperation( ... ) do { if (mDNS_LoggingEnabled) LogMsgWithLevel(MDNS_LOG_OPERATION, __VA_ARGS__); } while (0)
245 #define LogSPS( ... ) do { if (mDNS_LoggingEnabled) LogMsgWithLevel(MDNS_LOG_SPS, __VA_ARGS__); } while (0)
246 #define LogInfo( ... ) do { if (mDNS_LoggingEnabled) LogMsgWithLevel(MDNS_LOG_INFO, __VA_ARGS__); } while (0)
247 #elif (MDNS_GNU_VA_ARGS)
248 #define debug_noop( ARGS... ) ((void)0)
249 #define LogMsg( ARGS... ) LogMsgWithLevel(MDNS_LOG_MSG, ARGS)
250 #define LogOperation( ARGS... ) do { if (mDNS_LoggingEnabled) LogMsgWithLevel(MDNS_LOG_OPERATION, ARGS); } while (0)
251 #define LogSPS( ARGS... ) do { if (mDNS_LoggingEnabled) LogMsgWithLevel(MDNS_LOG_SPS, ARGS); } while (0)
252 #define LogInfo( ARGS... ) do { if (mDNS_LoggingEnabled) LogMsgWithLevel(MDNS_LOG_INFO, ARGS); } while (0)
253 #else
254 #error Unknown variadic macros
255 #endif
256 #else
257 // If your platform does not support variadic macros, you need to define the following variadic functions.
258 // See mDNSShared/mDNSDebug.c for sample implementation
259 extern void debug_noop(const char *format, ...);
260 #define LogMsg LogMsg_
261 #define LogOperation mDNS_LoggingEnabled == 0 ? ((void)0) : LogOperation_
262 #define LogSPS mDNS_LoggingEnabled == 0 ? ((void)0) : LogSPS_
263 #define LogInfo mDNS_LoggingEnabled == 0 ? ((void)0) : LogInfo_
264 extern void LogMsg_(const char *format, ...) IS_A_PRINTF_STYLE_FUNCTION(1,2);
265 extern void LogOperation_(const char *format, ...) IS_A_PRINTF_STYLE_FUNCTION(1,2);
266 extern void LogSPS_(const char *format, ...) IS_A_PRINTF_STYLE_FUNCTION(1,2);
267 extern void LogInfo_(const char *format, ...) IS_A_PRINTF_STYLE_FUNCTION(1,2);
268 #endif
270 #if MDNS_DEBUGMSGS
271 #define debugf debugf_
272 extern void debugf_(const char *format, ...) IS_A_PRINTF_STYLE_FUNCTION(1,2);
273 #else
274 #define debugf debug_noop
275 #endif
277 #if MDNS_DEBUGMSGS > 1
278 #define verbosedebugf verbosedebugf_
279 extern void verbosedebugf_(const char *format, ...) IS_A_PRINTF_STYLE_FUNCTION(1,2);
280 #else
281 #define verbosedebugf debug_noop
282 #endif
284 extern int mDNS_LoggingEnabled;
285 extern int mDNS_PacketLoggingEnabled;
286 extern int mDNS_DebugMode; // If non-zero, LogMsg() writes to stderr instead of syslog
287 extern const char ProgramName[];
289 extern void LogMsgWithLevel(mDNSLogLevel_t logLevel, const char *format, ...) IS_A_PRINTF_STYLE_FUNCTION(2,3);
290 #define LogMsgNoIdent LogMsg
292 #if APPLE_OSX_mDNSResponder && MACOSX_MDNS_MALLOC_DEBUGGING >= 1
293 extern void *mallocL(char *msg, unsigned int size);
294 extern void freeL(char *msg, void *x);
295 extern void LogMemCorruption(const char *format, ...);
296 extern void uds_validatelists(void);
297 extern void udns_validatelists(void *const v);
298 #else
299 #define mallocL(X,Y) malloc(Y)
300 #define freeL(X,Y) free(Y)
301 #endif
303 #ifdef __cplusplus
305 #endif
307 #endif