Source code of Windows XP (NT5)
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.

220 lines
6.7 KiB

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