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.

253 lines
8.9 KiB

  1. //=============================================================================
  2. // Copyright (c) 1997 Microsoft Corporation
  3. //
  4. // File Name: igmptrace.h
  5. //
  6. // Abstract:
  7. // This module contains declarations related to tracing.
  8. //
  9. // Author: K.S.Lokesh (lokeshs@) 11-1-97
  10. //
  11. //=============================================================================
  12. #ifndef _IGMPTRACE_H_
  13. #define _IGMPTRACE_H_
  14. #ifdef MIB_DEBUG
  15. #if !DBG
  16. #undef MIB_DEBUG
  17. #endif
  18. #endif
  19. //kslksl remove below
  20. #define DBG1 0
  21. //deldel
  22. // constants and macros used for tracing
  23. //
  24. #define IGMP_TRACE_ANY ((DWORD)0xFFFF0000 | TRACE_USE_MASK)
  25. #define IGMP_TRACE_ERR ((DWORD)0x00010000 | TRACE_USE_MASK)
  26. #define IGMP_TRACE_ENTER ((DWORD)0x00020000 | TRACE_USE_MASK)
  27. #define IGMP_TRACE_LEAVE ((DWORD)0x00020000 | TRACE_USE_MASK)
  28. #define IGMP_TRACE_START ((DWORD)0x00020000 | TRACE_USE_MASK)
  29. #define IGMP_TRACE_STOP ((DWORD)0x00020000 | TRACE_USE_MASK)
  30. #define IGMP_TRACE_IF ((DWORD)0x00040000 | TRACE_USE_MASK)
  31. #define IGMP_TRACE_CONFIG ((DWORD)0x00040000 | TRACE_USE_MASK)
  32. #define IGMP_TRACE_RECEIVE ((DWORD)0x00100000 | TRACE_USE_MASK)
  33. #define IGMP_TRACE_SEND ((DWORD)0x00100000 | TRACE_USE_MASK)
  34. #define IGMP_TRACE_QUERIER ((DWORD)0x00200000 | TRACE_USE_MASK)
  35. #define IGMP_TRACE_GROUP ((DWORD)0x00200000 | TRACE_USE_MASK)
  36. #define IGMP_TRACE_MGM ((DWORD)0x00400000 | TRACE_USE_MASK)
  37. #define IGMP_TRACE_SOURCES ((DWORD)0x00800000 | TRACE_USE_MASK)
  38. //kslksl deldel
  39. #define IGMP_TRACE_TIMER ((DWORD)0x10000000 | TRACE_USE_MASK)
  40. #if DBG
  41. #define IGMP_TRACE_TIMER1 ((DWORD)0x40000000 | TRACE_USE_MASK)
  42. #define IGMP_TRACE_ENTER1 ((DWORD)0x02000000 | TRACE_USE_MASK)
  43. #define IGMP_TRACE_MEM ((DWORD)0x80000000 | TRACE_USE_MASK)
  44. #else
  45. #define IGMP_TRACE_TIMER1 ((DWORD)0x00000000 | TRACE_USE_MASK)
  46. #define IGMP_TRACE_ENTER1 ((DWORD)0x00000000 | TRACE_USE_MASK)
  47. #define IGMP_TRACE_MEM ((DWORD)0x00000000 | TRACE_USE_MASK)
  48. #endif
  49. #if DBG1
  50. #define IGMP_TRACE_KSL ((DWORD)0x01000000 | TRACE_USE_MASK)
  51. #define IGMP_TRACE_WORKER ((DWORD)0x01000000 | TRACE_USE_MASK)
  52. //#define IGMP_TRACE_ENTER1 ((DWORD)0x02000000 | TRACE_USE_MASK)
  53. #define IGMP_TRACE_LEAVE1 ((DWORD)0x02000000 | TRACE_USE_MASK)
  54. #define IGMP_TRACE_MIB ((DWORD)0x04000000 | TRACE_USE_MASK)
  55. #define IGMP_TRACE_DYNLOCK ((DWORD)0x08000000 | TRACE_USE_MASK)
  56. #define IGMP_TRACE_CS ((DWORD)0x20000000 | TRACE_USE_MASK)
  57. #define IGMP_TRACE_CS1 ((DWORD)0x80000000 | TRACE_USE_MASK)
  58. #else
  59. #define IGMP_TRACE_KSL ((DWORD)0x00000000 | TRACE_USE_MASK)
  60. #define IGMP_TRACE_WORKER ((DWORD)0x00000000 | TRACE_USE_MASK)
  61. //#define IGMP_TRACE_ENTER1 ((DWORD)0x00000000 | TRACE_USE_MASK)
  62. #define IGMP_TRACE_LEAVE1 ((DWORD)0x00000000 | TRACE_USE_MASK)
  63. #define IGMP_TRACE_MIB ((DWORD)0x00000000 | TRACE_USE_MASK)
  64. #define IGMP_TRACE_DYNLOCK ((DWORD)0x00000000 | TRACE_USE_MASK)
  65. #define IGMP_TRACE_CS ((DWORD)0x00000000 | TRACE_USE_MASK)
  66. #define IGMP_TRACE_CS1 ((DWORD)0x00000000 | TRACE_USE_MASK)
  67. #endif
  68. #ifdef LOCK_DBG
  69. #define ENTER_CRITICAL_SECTION(pcs, type, proc) \
  70. Trace2(CS,"----To enter %s in %s", type, proc); \
  71. EnterCriticalSection(pcs); \
  72. Trace2(CS1,"----Entered %s in %s", type, proc)
  73. #define LEAVE_CRITICAL_SECTION(pcs, type, proc) \
  74. Trace2(CS1,"----Left %s in %s", type, proc); \
  75. LeaveCriticalSection(pcs)
  76. #define WAIT_FOR_SINGLE_OBJECT( event, time, type, proc) \
  77. Trace2(EVENT, "++++To wait for singleObj %s in %s", type, proc); \
  78. WaitForSingleObject(event, time); \
  79. Trace2(EVENT, "++++WaitForSingleObj returned %s in %s", type, proc)
  80. #define SET_EVENT(event, type, proc) \
  81. Trace2(EVENT, "++++SetEvent %s in %s", type, proc); \
  82. SetEvent(event)
  83. #else
  84. #define ENTER_CRITICAL_SECTION(pcs, type, proc) \
  85. EnterCriticalSection(pcs)
  86. #define LEAVE_CRITICAL_SECTION(pcs, type, proc) \
  87. LeaveCriticalSection(pcs)
  88. #define WAIT_FOR_SINGLE_OBJECT( event, time, type, proc) \
  89. WaitForSingleObject(event, time)
  90. #define SET_EVENT(event, type, proc) \
  91. SetEvent(event)
  92. #endif // LOCK_DBG
  93. #define TRACEID g_TraceId
  94. #define Trace0(l,a) \
  95. if (g_TraceId!=INVALID_TRACEID) TracePrintfEx(TRACEID, IGMP_TRACE_ ## l, a)
  96. #define Trace1(l,a,b) \
  97. if (g_TraceId!=INVALID_TRACEID) TracePrintfEx(TRACEID, IGMP_TRACE_ ## l, a, b)
  98. #define Trace2(l,a,b,c) \
  99. if (g_TraceId!=INVALID_TRACEID) TracePrintfEx(TRACEID, IGMP_TRACE_ ## l, a, b, c)
  100. #define Trace3(l,a,b,c,d) \
  101. if (g_TraceId!=INVALID_TRACEID) TracePrintfEx(TRACEID, IGMP_TRACE_ ## l, a, b, c, d)
  102. #define Trace4(l,a,b,c,d,e) \
  103. if (g_TraceId!=INVALID_TRACEID) TracePrintfEx(TRACEID, IGMP_TRACE_ ## l, a, b, c, d, e)
  104. #define Trace5(l,a,b,c,d,e,f) \
  105. if (g_TraceId!=INVALID_TRACEID) TracePrintfEx(TRACEID, IGMP_TRACE_ ## l, a, b, c, d, e, f)
  106. #define Trace6(l,a,b,c,d,e,f,g) \
  107. if (g_TraceId!=INVALID_TRACEID) TracePrintfEx(TRACEID, IGMP_TRACE_ ## l, a, b, c, d, e, f,g)
  108. #define Trace7(l,a,b,c,d,e,f,g,h) \
  109. if (g_TraceId!=INVALID_TRACEID) TracePrintfEx(TRACEID, IGMP_TRACE_ ## l, a, b, c, d, e, f,g,h)
  110. #define Trace8(l,a,b,c,d,e,f,g,h,i) \
  111. if (g_TraceId!=INVALID_TRACEID) TracePrintfEx(TRACEID, IGMP_TRACE_ ## l, a, b, c, d, e, f,g,h,i)
  112. #define Trace9(l,a,b,c,d,e,f,g,h,i,j) \
  113. if (g_TraceId!=INVALID_TRACEID) TracePrintfEx(TRACEID, IGMP_TRACE_ ## l, a, b, c, d, e, f,g,h,i,j)
  114. #define TRACEDUMP(l,a,b,c) \
  115. TraceDumpEx(TRACEID,l,a,b,c,TRUE)
  116. #ifdef ENTER_DBG
  117. #define TraceEnter(X) TracePrintfEx(TRACEID, IGMP_TRACE_ENTER, "Entered: "X)
  118. #define TraceLeave(X) TracePrintfEx(TRACEID, IGMP_TRACE_ENTER, "Leaving: "X"\n")
  119. #else
  120. #define TraceEnter(X)
  121. #define TraceLeave(X)
  122. #endif // ENTER_DBG
  123. //
  124. // Event logging macros
  125. //
  126. #define LOGLEVEL g_Config.LoggingLevel
  127. #define LOGHANDLE g_LogHandle
  128. // Error logging
  129. #define Logerr0(msg,err) \
  130. if (LOGLEVEL >= IGMP_LOGGING_ERROR) \
  131. RouterLogEventEx(LOGHANDLE,EVENTLOG_ERROR_TYPE,\
  132. (err),IGMPLOG_ ## msg, "")
  133. #define Logerr1(msg,Format,a,err) \
  134. if (LOGLEVEL >= IGMP_LOGGING_ERROR) \
  135. RouterLogEventEx(LOGHANDLE,EVENTLOG_ERROR_TYPE,\
  136. (err),IGMPLOG_ ## msg,Format,(a))
  137. #define Logerr2(msg,Format,a,b,err) \
  138. if (LOGLEVEL >= IGMP_LOGGING_ERROR) { \
  139. RouterLogEventEx(LOGHANDLE,EVENTLOG_ERROR_TYPE,\
  140. (err),IGMPLOG_ ## msg,Format,(a),(b)); \
  141. }
  142. #define Logerr3(msg,Format,a,b,c,err) \
  143. if (LOGLEVEL >= IGMP_LOGGING_ERROR) { \
  144. RouterLogEventEx(LOGHANDLE,EVENTLOG_ERROR_TYPE,\
  145. (err),IGMPLOG_ ## msg,Format,(a),(b),(c)); \
  146. }
  147. #define Logerr4(msg,Format,a,b,c,d,err) \
  148. if (LOGLEVEL >= IGMP_LOGGING_ERROR) { \
  149. RouterLogEventEx(LOGHANDLE,EVENTLOG_ERROR_TYPE,\
  150. (err),IGMPLOG_ ## msg,Format,(a),(b),(c),(d)); \
  151. }
  152. // Warning logging
  153. #define Logwarn0(msg,err) \
  154. if (LOGLEVEL >= IGMP_LOGGING_WARN) \
  155. RouterLogEventEx(LOGHANDLE,EVENTLOG_WARNING_TYPE,\
  156. (err),IGMPLOG_ ## msg, "")
  157. #define Logwarn1(msg,Format,a,err) \
  158. if (LOGLEVEL >= IGMP_LOGGING_WARN) \
  159. RouterLogEventEx(LOGHANDLE,EVENTLOG_WARNING_TYPE,\
  160. (err),IGMPLOG_ ## msg,Format,(a))
  161. #define Logwarn2(msg,Format,a,b,err) \
  162. if (LOGLEVEL >= IGMP_LOGGING_WARN) { \
  163. RouterLogEventEx(LOGHANDLE,EVENTLOG_WARNING_TYPE,\
  164. (err),IGMPLOG_ ## msg,Format,(a),(b)); \
  165. }
  166. // Information logging
  167. #define Loginfo0(msg,err) \
  168. if (LOGLEVEL >= IGMP_LOGGING_INFO) \
  169. RouterLogEventEx(LOGHANDLE,EVENTLOG_INFORMATION_TYPE,\
  170. (err),IGMPLOG_ ## msg, "")
  171. #define Loginfo1(msg,Format,a,err) \
  172. if (LOGLEVEL >= IGMP_LOGGING_INFO) \
  173. RouterLogEventEx(LOGHANDLE,EVENTLOG_INFORMATION_TYPE,\
  174. (err),IGMPLOG_ ## msg, Format,(a))
  175. #define Loginfo2(msg,Format,a,b,err) \
  176. if (LOGLEVEL >= IGMP_LOGGING_INFO) \
  177. RouterLogEventEx(LOGHANDLE,EVENTLOG_INFORMATION_TYPE,\
  178. (err),IGMPLOG_ ## msg, Format,(a),(b))
  179. //
  180. // IP address conversion macro:
  181. // calls inet_ntoa directly on a DWORD, by casting it as an IN_ADDR.
  182. //
  183. #define INET_NTOA(dw) inet_ntoa( *(PIN_ADDR)&(dw) )
  184. #define INET_COPY(p1, p2) {\
  185. LPSTR tmp;\
  186. tmp = INET_NTOA(p2); \
  187. if ((tmp)) lstrcpy((p1),tmp); \
  188. else *(p1) = '\0'; \
  189. }
  190. #define INET_CAT(p1, p2) {\
  191. LPSTR tmp; \
  192. tmp = INET_NTOA(p2); \
  193. if ((tmp)) lstrcat((p1),tmp);\
  194. }
  195. #endif // _IGMPTRACE_H_