Leaked source code of windows server 2003
You can not select more than 25 topics Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.

214 lines
7.1 KiB

  1. /*++
  2. Copyright (c) 1995-1998 Microsoft Corporation
  3. Module Name:
  4. rtmdbg.h
  5. Abstract:
  6. Debugging in Routing Table Manager DLL
  7. --*/
  8. #ifndef __ROUTING_RTMDBG_H__
  9. #define __ROUTING_RTMDBG_H__
  10. //
  11. // Constants used for tracing
  12. //
  13. #define RTM_TRACE_ANY ((DWORD)0xFFFF0000 | TRACE_USE_MASK)
  14. #define RTM_TRACE_ERR ((DWORD)0x00010000 | TRACE_USE_MASK)
  15. #define RTM_TRACE_ENTER ((DWORD)0x00020000 | TRACE_USE_MASK)
  16. #define RTM_TRACE_LEAVE ((DWORD)0x00040000 | TRACE_USE_MASK)
  17. #define RTM_TRACE_LOCK ((DWORD)0x00080000 | TRACE_USE_MASK)
  18. #define RTM_TRACE_REFS ((DWORD)0x00100000 | TRACE_USE_MASK)
  19. #define RTM_TRACE_HANDLE ((DWORD)0x00200000 | TRACE_USE_MASK)
  20. #define RTM_TRACE_MEMORY ((DWORD)0x00400000 | TRACE_USE_MASK)
  21. #define RTM_TRACE_START ((DWORD)0x00800000 | TRACE_USE_MASK)
  22. #define RTM_TRACE_STOP ((DWORD)0x01000000 | TRACE_USE_MASK)
  23. #define RTM_TRACE_REGNS ((DWORD)0x02000000 | TRACE_USE_MASK)
  24. #define RTM_TRACE_ROUTE ((DWORD)0x04000000 | TRACE_USE_MASK)
  25. #define RTM_TRACE_QUERY ((DWORD)0x08000000 | TRACE_USE_MASK)
  26. #define RTM_TRACE_ENUM ((DWORD)0x10000000 | TRACE_USE_MASK)
  27. #define RTM_TRACE_NOTIFY ((DWORD)0x20000000 | TRACE_USE_MASK)
  28. #define RTM_TRACE_TIMER ((DWORD)0x40080000 | TRACE_USE_MASK)
  29. #define RTM_TRACE_CALLBACK ((DWORD)0x80000000 | TRACE_USE_MASK)
  30. //
  31. // Macros used for tracing
  32. //
  33. extern DWORD TracingInited;
  34. extern ULONG TracingHandle;
  35. #define TRACEHANDLE TracingHandle
  36. #define START_TRACING() \
  37. if (InterlockedExchange(&TracingInited, TRUE) == FALSE) \
  38. { \
  39. TRACEHANDLE = TraceRegister("RTMv1"); \
  40. } \
  41. #define STOP_TRACING() TraceDeregister(TRACEHANDLE)
  42. #define Trace0(l,a) \
  43. TracePrintfEx(TRACEHANDLE, RTM_TRACE_ ## l, a)
  44. #define Trace1(l,a,b) \
  45. TracePrintfEx(TRACEHANDLE, RTM_TRACE_ ## l, a, b)
  46. #define Trace2(l,a,b,c) \
  47. TracePrintfEx(TRACEHANDLE, RTM_TRACE_ ## l, a, b, c)
  48. #define Trace3(l,a,b,c,d) \
  49. TracePrintfEx(TRACEHANDLE, RTM_TRACE_ ## l, a, b, c, d)
  50. #define Trace4(l,a,b,c,d,e) \
  51. TracePrintfEx(TRACEHANDLE, RTM_TRACE_ ## l, a, b, c, d, e)
  52. #define Trace5(l,a,b,c,d,e,f) \
  53. TracePrintfEx(TRACEHANDLE, RTM_TRACE_ ## l, a, b, c, d, e, f)
  54. #define Trace6(l,a,b,c,d,e,f,g) \
  55. TracePrintfEx(TRACEHANDLE, RTM_TRACE_ ## l, a, b, c, d, e, f, g)
  56. #define Tracedump(l,a,b,c) \
  57. TraceDumpEx(TRACEHANDLE,l,a,b,c,TRUE)
  58. #if DBG_CAL
  59. #define TraceEnter(X) Trace0(ENTER, "Entered: "X)
  60. #define TraceLeave(X) Trace0(LEAVE, "Leaving: "X"\n")
  61. #else
  62. #define TraceEnter(X)
  63. #define TraceLeave(X)
  64. #endif
  65. //
  66. // Constants used in logging
  67. //
  68. #define RTM_LOGGING_NONE 0
  69. #define RTM_LOGGING_ERROR 1
  70. #define RTM_LOGGING_WARN 2
  71. #define RTM_LOGGING_INFO 3
  72. //
  73. // Event logging macros
  74. //
  75. extern HANDLE LoggingHandle;
  76. extern ULONG LoggingLevel;
  77. #define LOGHANDLE LoggingHandle
  78. #define LOGLEVEL LoggingLevel
  79. #define LOGERR RouterLogError
  80. #define LOGWARN RouterLogWarning
  81. #define LOGINFO RouterLogInformation
  82. #define LOGWARNDATA RouterLogWarningData
  83. //
  84. // Error logging
  85. //
  86. #define START_LOGGING() LOGHANDLE = RouterLogRegister("RTMv1")
  87. #define STOP_LOGGING() RouterLogDeregister(LOGHANDLE)
  88. #define LOGERR0(msg,err) \
  89. if (LOGLEVEL >= RTM_LOGGING_ERROR) \
  90. LOGERR(LOGHANDLE,RTMLOG_ ## msg,0,NULL,(err))
  91. #define LOGERR1(msg,a,err) \
  92. if (LOGLEVEL >= RTM_LOGGING_ERROR) \
  93. LOGERR(LOGHANDLE,RTMLOG_ ## msg,1,&(a),(err))
  94. #define LOGERR2(msg,a,b,err) \
  95. if (LOGLEVEL >= RTM_LOGGING_ERROR) { \
  96. LPSTR _asz[2] = { (a), (b) }; \
  97. LOGERR(LOGHANDLE,RTMLOG_ ## msg,2,_asz,(err)); \
  98. }
  99. #define LOGERR3(msg,a,b,c,err) \
  100. if (LOGLEVEL >= RTM_LOGGING_ERROR) { \
  101. LPSTR _asz[3] = { (a), (b), (c) }; \
  102. LOGERR(LOGHANDLE,RTMLOG_ ## msg,3,_asz,(err)); \
  103. }
  104. #define LOGERR4(msg,a,b,c,d,err) \
  105. if (LOGLEVEL >= RTM_LOGGING_ERROR) { \
  106. LPSTR _asz[4] = { (a), (b), (c), (d) }; \
  107. LOGERR(LOGHANDLE,RTMLOG_ ## msg,4,_asz,(err)); \
  108. }
  109. //
  110. // Warning logging
  111. //
  112. #define LOGWARN0(msg,err) \
  113. if (LOGLEVEL >= RTM_LOGGING_WARN) \
  114. LOGWARN(LOGHANDLE,RTMLOG_ ## msg,0,NULL,(err))
  115. #define LOGWARN1(msg,a,err) \
  116. if (LOGLEVEL >= RTM_LOGGING_WARN) \
  117. LOGWARN(LOGHANDLE,RTMLOG_ ## msg,1,&(a),(err))
  118. #define LOGWARN2(msg,a,b,err) \
  119. if (LOGLEVEL >= RTM_LOGGING_WARN) { \
  120. LPSTR _asz[2] = { (a), (b) }; \
  121. LOGWARN(LOGHANDLE,RTMLOG_ ## msg,2,_asz,(err)); \
  122. }
  123. #define LOGWARN3(msg,a,b,c,err) \
  124. if (LOGLEVEL >= RTM_LOGGING_WARN) { \
  125. LPSTR _asz[3] = { (a), (b), (c) }; \
  126. LOGWARN(LOGHANDLE,RTMLOG_ ## msg,3,_asz,(err)); \
  127. }
  128. #define LOGWARN4(msg,a,b,c,d,err) \
  129. if (LOGLEVEL >= RTM_LOGGING_WARN) { \
  130. LPSTR _asz[4] = { (a), (b), (c), (d) }; \
  131. LOGWARN(LOGHANDLE,RTMLOG_ ## msg,4,_asz,(err)); \
  132. }
  133. #define LOGWARNDATA2(msg,a,b,dw,buf) \
  134. if (LOGLEVEL >= RTM_LOGGING_WARN) { \
  135. LPSTR _asz[2] = { (a), (b) }; \
  136. LOGWARNDATA(LOGHANDLE,RTMLOG_ ## msg,2,_asz,(dw),(buf)); \
  137. }
  138. //
  139. // Information logging
  140. //
  141. #define LOGINFO0(msg,err) \
  142. if (LOGLEVEL >= RTM_LOGGING_INFO) \
  143. LOGINFO(LOGHANDLE,RTMLOG_ ## msg,0,NULL,(err))
  144. #define LOGINFO1(msg,a,err) \
  145. if (LOGLEVEL >= RTM_LOGGING_INFO) \
  146. LOGINFO(LOGHANDLE,RTMLOG_ ## msg,1,&(a),(err))
  147. #define LOGINFO2(msg,a,b,err) \
  148. if (LOGLEVEL >= RTM_LOGGING_INFO) { \
  149. LPSTR _asz[2] = { (a), (b) }; \
  150. LOGINFO(LOGHANDLE,RTMLOG_ ## msg,2,_asz,(err)); \
  151. }
  152. #define LOGINFO3(msg,a,b,c,err) \
  153. if (LOGLEVEL >= RTM_LOGGING_INFO) { \
  154. LPSTR _asz[3] = { (a), (b), (c) }; \
  155. LOGINFO(LOGHANDLE,RTMLOG_ ## msg,3,_asz,(err)); \
  156. }
  157. #define LOGINFO4(msg,a,b,c,d,err) \
  158. if (LOGLEVEL >= RTM_LOGGING_INFO) { \
  159. LPSTR _asz[4] = { (a), (b), (c), (d) }; \
  160. LOGINFO(LOGHANDLE,RTMLOG_ ## msg,4,_asz,(err)); \
  161. }
  162. //
  163. // Misc Debugging Macros
  164. //
  165. #define IPADDR_FORMAT(x) \
  166. ((x)&0x000000ff),(((x)&0x0000ff00)>>8),(((x)&0x00ff0000)>>16),(((x)&0xff000000)>>24)
  167. #define TracePrintAddress(ID, Dest, Mask) \
  168. { \
  169. Trace2(ID, "Dest: %d.%d.%d.%d Mask: %d.%d.%d.%d", \
  170. IPADDR_FORMAT(Dest), \
  171. IPADDR_FORMAT(Mask)); \
  172. }
  173. #endif //__ROUTING_RTMDBG_H__