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.

253 lines
9.2 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. #define IGMP_TRACE_KSL ((DWORD)0x01000000 | TRACE_USE_MASK)
  45. #else
  46. //deldel
  47. #define IGMP_TRACE_TIMER1 ((DWORD)0x40000000 | TRACE_USE_MASK)
  48. #define IGMP_TRACE_ENTER1 ((DWORD)0x02000000 | TRACE_USE_MASK)
  49. #define IGMP_TRACE_MEM ((DWORD)0x00000000 | TRACE_USE_MASK)
  50. #define IGMP_TRACE_KSL ((DWORD)0x00000000 | TRACE_USE_MASK)
  51. #endif
  52. #if DBG1
  53. #define IGMP_TRACE_WORKER ((DWORD)0x01000000 | TRACE_USE_MASK)
  54. //#define IGMP_TRACE_ENTER1 ((DWORD)0x02000000 | TRACE_USE_MASK)
  55. #define IGMP_TRACE_LEAVE1 ((DWORD)0x02000000 | TRACE_USE_MASK)
  56. #define IGMP_TRACE_MIB ((DWORD)0x04000000 | TRACE_USE_MASK)
  57. #define IGMP_TRACE_DYNLOCK ((DWORD)0x08000000 | TRACE_USE_MASK)
  58. #define IGMP_TRACE_CS ((DWORD)0x20000000 | TRACE_USE_MASK)
  59. #define IGMP_TRACE_CS1 ((DWORD)0x80000000 | TRACE_USE_MASK)
  60. #else
  61. #define IGMP_TRACE_WORKER ((DWORD)0x00000000 | TRACE_USE_MASK)
  62. //#define IGMP_TRACE_ENTER1 ((DWORD)0x00000000 | TRACE_USE_MASK)
  63. #define IGMP_TRACE_LEAVE1 ((DWORD)0x00000000 | TRACE_USE_MASK)
  64. #define IGMP_TRACE_MIB ((DWORD)0x00000000 | TRACE_USE_MASK)
  65. #define IGMP_TRACE_DYNLOCK ((DWORD)0x00000000 | TRACE_USE_MASK)
  66. #define IGMP_TRACE_CS ((DWORD)0x00000000 | TRACE_USE_MASK)
  67. #define IGMP_TRACE_CS1 ((DWORD)0x00000000 | TRACE_USE_MASK)
  68. #endif
  69. #ifdef LOCK_DBG
  70. #define ENTER_CRITICAL_SECTION(pcs, type, proc) \
  71. Trace2(CS,"----To enter %s in %s", type, proc); \
  72. EnterCriticalSection(pcs); \
  73. Trace2(CS1,"----Entered %s in %s", type, proc)
  74. #define LEAVE_CRITICAL_SECTION(pcs, type, proc) \
  75. Trace2(CS1,"----Left %s in %s", type, proc); \
  76. LeaveCriticalSection(pcs)
  77. #define WAIT_FOR_SINGLE_OBJECT( event, time, type, proc) \
  78. Trace2(EVENT, "++++To wait for singleObj %s in %s", type, proc); \
  79. WaitForSingleObject(event, time); \
  80. Trace2(EVENT, "++++WaitForSingleObj returned %s in %s", type, proc)
  81. #define SET_EVENT(event, type, proc) \
  82. Trace2(EVENT, "++++SetEvent %s in %s", type, proc); \
  83. SetEvent(event)
  84. #else
  85. #define ENTER_CRITICAL_SECTION(pcs, type, proc) \
  86. EnterCriticalSection(pcs)
  87. #define LEAVE_CRITICAL_SECTION(pcs, type, proc) \
  88. LeaveCriticalSection(pcs)
  89. #define WAIT_FOR_SINGLE_OBJECT( event, time, type, proc) \
  90. WaitForSingleObject(event, time)
  91. #define SET_EVENT(event, type, proc) \
  92. SetEvent(event)
  93. #endif // LOCK_DBG
  94. #define TRACEID g_TraceId
  95. #define Trace0(l,a) \
  96. if (g_TraceId!=INVALID_TRACEID) TracePrintfEx(TRACEID, IGMP_TRACE_ ## l, a)
  97. #define Trace1(l,a,b) \
  98. if (g_TraceId!=INVALID_TRACEID) TracePrintfEx(TRACEID, IGMP_TRACE_ ## l, a, b)
  99. #define Trace2(l,a,b,c) \
  100. if (g_TraceId!=INVALID_TRACEID) TracePrintfEx(TRACEID, IGMP_TRACE_ ## l, a, b, c)
  101. #define Trace3(l,a,b,c,d) \
  102. if (g_TraceId!=INVALID_TRACEID) TracePrintfEx(TRACEID, IGMP_TRACE_ ## l, a, b, c, d)
  103. #define Trace4(l,a,b,c,d,e) \
  104. if (g_TraceId!=INVALID_TRACEID) TracePrintfEx(TRACEID, IGMP_TRACE_ ## l, a, b, c, d, e)
  105. #define Trace5(l,a,b,c,d,e,f) \
  106. if (g_TraceId!=INVALID_TRACEID) TracePrintfEx(TRACEID, IGMP_TRACE_ ## l, a, b, c, d, e, f)
  107. #define Trace6(l,a,b,c,d,e,f,g) \
  108. if (g_TraceId!=INVALID_TRACEID) TracePrintfEx(TRACEID, IGMP_TRACE_ ## l, a, b, c, d, e, f,g)
  109. #define Trace7(l,a,b,c,d,e,f,g,h) \
  110. if (g_TraceId!=INVALID_TRACEID) TracePrintfEx(TRACEID, IGMP_TRACE_ ## l, a, b, c, d, e, f,g,h)
  111. #define Trace8(l,a,b,c,d,e,f,g,h,i) \
  112. if (g_TraceId!=INVALID_TRACEID) TracePrintfEx(TRACEID, IGMP_TRACE_ ## l, a, b, c, d, e, f,g,h,i)
  113. #define Trace9(l,a,b,c,d,e,f,g,h,i,j) \
  114. if (g_TraceId!=INVALID_TRACEID) TracePrintfEx(TRACEID, IGMP_TRACE_ ## l, a, b, c, d, e, f,g,h,i,j)
  115. #define TRACEDUMP(l,a,b,c) \
  116. TraceDumpEx(TRACEID,l,a,b,c,TRUE)
  117. #ifdef ENTER_DBG
  118. #define TraceEnter(X) TracePrintfEx(TRACEID, IGMP_TRACE_ENTER, "Entered: "X)
  119. #define TraceLeave(X) TracePrintfEx(TRACEID, IGMP_TRACE_ENTER, "Leaving: "X"\n")
  120. #else
  121. #define TraceEnter(X)
  122. #define TraceLeave(X)
  123. #endif // ENTER_DBG
  124. //
  125. // Event logging macros
  126. //
  127. #define LOGLEVEL g_Config.LoggingLevel
  128. #define LOGHANDLE g_LogHandle
  129. // Error logging
  130. #define Logerr0(msg,err) \
  131. if (LOGLEVEL >= IGMP_LOGGING_ERROR) \
  132. RouterLogEventEx(LOGHANDLE,EVENTLOG_ERROR_TYPE,\
  133. (err),IGMPLOG_ ## msg, "")
  134. #define Logerr1(msg,Format,a,err) \
  135. if (LOGLEVEL >= IGMP_LOGGING_ERROR) \
  136. RouterLogEventEx(LOGHANDLE,EVENTLOG_ERROR_TYPE,\
  137. (err),IGMPLOG_ ## msg,Format,(a))
  138. #define Logerr2(msg,Format,a,b,err) \
  139. if (LOGLEVEL >= IGMP_LOGGING_ERROR) { \
  140. RouterLogEventEx(LOGHANDLE,EVENTLOG_ERROR_TYPE,\
  141. (err),IGMPLOG_ ## msg,Format,(a),(b)); \
  142. }
  143. #define Logerr3(msg,Format,a,b,c,err) \
  144. if (LOGLEVEL >= IGMP_LOGGING_ERROR) { \
  145. RouterLogEventEx(LOGHANDLE,EVENTLOG_ERROR_TYPE,\
  146. (err),IGMPLOG_ ## msg,Format,(a),(b),(c)); \
  147. }
  148. #define Logerr4(msg,Format,a,b,c,d,err) \
  149. if (LOGLEVEL >= IGMP_LOGGING_ERROR) { \
  150. RouterLogEventEx(LOGHANDLE,EVENTLOG_ERROR_TYPE,\
  151. (err),IGMPLOG_ ## msg,Format,(a),(b),(c),(d)); \
  152. }
  153. // Warning logging
  154. #define Logwarn0(msg,err) \
  155. if (LOGLEVEL >= IGMP_LOGGING_WARN) \
  156. RouterLogEventEx(LOGHANDLE,EVENTLOG_WARNING_TYPE,\
  157. (err),IGMPLOG_ ## msg, "")
  158. #define Logwarn1(msg,Format,a,err) \
  159. if (LOGLEVEL >= IGMP_LOGGING_WARN) \
  160. RouterLogEventEx(LOGHANDLE,EVENTLOG_WARNING_TYPE,\
  161. (err),IGMPLOG_ ## msg,Format,(a))
  162. #define Logwarn2(msg,Format,a,b,err) \
  163. if (LOGLEVEL >= IGMP_LOGGING_WARN) { \
  164. RouterLogEventEx(LOGHANDLE,EVENTLOG_WARNING_TYPE,\
  165. (err),IGMPLOG_ ## msg,Format,(a),(b)); \
  166. }
  167. // Information logging
  168. #define Loginfo0(msg,err) \
  169. if (LOGLEVEL >= IGMP_LOGGING_INFO) \
  170. RouterLogEventEx(LOGHANDLE,EVENTLOG_INFORMATION_TYPE,\
  171. (err),IGMPLOG_ ## msg, "")
  172. #define Loginfo1(msg,Format,a,err) \
  173. if (LOGLEVEL >= IGMP_LOGGING_INFO) \
  174. RouterLogEventEx(LOGHANDLE,EVENTLOG_INFORMATION_TYPE,\
  175. (err),IGMPLOG_ ## msg, Format,(a))
  176. #define Loginfo2(msg,Format,a,b,err) \
  177. if (LOGLEVEL >= IGMP_LOGGING_INFO) \
  178. RouterLogEventEx(LOGHANDLE,EVENTLOG_INFORMATION_TYPE,\
  179. (err),IGMPLOG_ ## msg, Format,(a),(b))
  180. //
  181. // IP address conversion macro:
  182. // calls inet_ntoa directly on a DWORD, by casting it as an IN_ADDR.
  183. //
  184. #define INET_NTOA(dw) inet_ntoa( *(PIN_ADDR)&(dw) )
  185. #define INET_COPY(p1, p2) {\
  186. LPSTR tmp;\
  187. tmp = INET_NTOA(p2); \
  188. if ((tmp)) lstrcpy((p1),tmp); \
  189. else *(p1) = '\0'; \
  190. }
  191. #define INET_CAT(p1, p2) {\
  192. LPSTR tmp; \
  193. tmp = INET_NTOA(p2); \
  194. if ((tmp)) lstrcat((p1),tmp);\
  195. }
  196. #endif // _IGMPTRACE_H_