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.

175 lines
6.8 KiB

  1. //----------------------------------------------------------------------------
  2. // constants used for g_dwLoggingLevel
  3. //----------------------------------------------------------------------------
  4. #define IPA_LOGGING_NONE 0
  5. #define IPA_LOGGING_ERROR 1
  6. #define IPA_LOGGING_WARN 2
  7. #define IPA_LOGGING_INFO 3
  8. // constants and macros used for tracing
  9. //
  10. #define IPA_TRACE_ANY ((DWORD)0xFFFF0000 | TRACE_USE_MASK)
  11. #define IPA_TRACE_ERR ((DWORD)0x00010000 | TRACE_USE_MASK)
  12. #define IPA_TRACE_ENTER ((DWORD)0x00020000 | TRACE_USE_MASK)
  13. #define IPA_TRACE_LEAVE ((DWORD)0x00020000 | TRACE_USE_MASK)
  14. #define IPA_TRACE_START ((DWORD)0x00020000 | TRACE_USE_MASK)
  15. #define IPA_TRACE_STOP ((DWORD)0x00020000 | TRACE_USE_MASK)
  16. #define IPA_TRACE_MSG ((DWORD)0x00040000 | TRACE_USE_MASK)
  17. #define IPA_TRACE_SOCKET ((DWORD)0x00080000 | TRACE_USE_MASK)
  18. #define IPA_TRACE_FSM ((DWORD)0x00100000 | TRACE_USE_MASK)
  19. #define IPA_TRACE_REF ((DWORD)0x10000000 | TRACE_USE_MASK)
  20. #define IPA_TRACE_TIMER ((DWORD)0x20000000 | TRACE_USE_MASK)
  21. #define IPA_TRACE_CS ((DWORD)0x40000000 | TRACE_USE_MASK)
  22. #define IPA_TRACE_CS1 ((DWORD)0x80000000 | TRACE_USE_MASK)
  23. #ifdef LOCK_DBG
  24. #define ENTER_CRITICAL_SECTION(pcs, type, proc) \
  25. Trace0(CS,_T("----To enter ") _T(type) _T(" in ") _T(proc)); \
  26. EnterCriticalSection(pcs); \
  27. Trace0(CS,_T("----Entered ") _T(type) _T(" in ") _T(proc));
  28. //#define ENTER_CRITICAL_SECTION(pcs, type, proc) \
  29. // Trace2(CS,_T("----To enter %s in %s"), type, proc); \
  30. // EnterCriticalSection(pcs); \
  31. // Trace2(CS1,_T("----Entered %s in %s"), type, proc)
  32. #define LEAVE_CRITICAL_SECTION(pcs, type, proc) \
  33. Trace0(CS,_T("----Left ") _T(type) _T(" in ") _T(proc)); \
  34. LeaveCriticalSection(pcs)
  35. //#define LEAVE_CRITICAL_SECTION(pcs, type, proc) \
  36. // Trace2(CS1,_T("----Left %s in %s"), type, proc); \
  37. // LeaveCriticalSection(pcs)
  38. #define WAIT_FOR_SINGLE_OBJECT( event, time, type, proc) \
  39. Trace2(EVENT, _T("++++To wait for singleObj %s in %s"), type, proc); \
  40. WaitForSingleObject(event, time); \
  41. Trace2(EVENT, _T("++++WaitForSingleObj returned %s in %s"), type, proc)
  42. #define SET_EVENT(event, type, proc) \
  43. Trace2(EVENT, _T("++++SetEvent %s in %s"), type, proc); \
  44. SetEvent(event)
  45. #else
  46. #define ENTER_CRITICAL_SECTION(pcs, type, proc) \
  47. EnterCriticalSection(pcs)
  48. #define LEAVE_CRITICAL_SECTION(pcs, type, proc) \
  49. LeaveCriticalSection(pcs)
  50. #define WAIT_FOR_SINGLE_OBJECT( event, time, type, proc) \
  51. WaitForSingleObject(event, time)
  52. #define SET_EVENT(event, type, proc) \
  53. SetEvent(event)
  54. #endif // LOCK_DBG
  55. #define TRACEID g_TraceId
  56. #define Trace0(l,a) \
  57. TracePrintfEx(TRACEID, IPA_TRACE_ ## l, a)
  58. #define Trace1(l,a,b) \
  59. TracePrintfEx(TRACEID, IPA_TRACE_ ## l, a, b)
  60. #define Trace2(l,a,b,c) \
  61. TracePrintfEx(TRACEID, IPA_TRACE_ ## l, a, b, c)
  62. #define Trace3(l,a,b,c,d) \
  63. TracePrintfEx(TRACEID, IPA_TRACE_ ## l, a, b, c, d)
  64. #define Trace4(l,a,b,c,d,e) \
  65. TracePrintfEx(TRACEID, IPA_TRACE_ ## l, a, b, c, d, e)
  66. #define Trace5(l,a,b,c,d,e,f) \
  67. TracePrintfEx(TRACEID, IPA_TRACE_ ## l, a, b, c, d, e, f)
  68. #define Trace6(l,a,b,c,d,e,f,g) \
  69. TracePrintfEx(TRACEID, IPA_TRACE_ ## l, a, b, c, d, e, f,g)
  70. #define Trace7(l,a,b,c,d,e,f,g,h) \
  71. TracePrintfEx(TRACEID, IPA_TRACE_ ## l, a, b, c, d, e, f,g,h)
  72. #define Trace8(l,a,b,c,d,e,f,g,h,i) \
  73. TracePrintfEx(TRACEID, IPA_TRACE_ ## l, a, b, c, d, e, f,g,h,i)
  74. #define Trace9(l,a,b,c,d,e,f,g,h,i,j) \
  75. TracePrintfEx(TRACEID, IPA_TRACE_ ## l, a, b, c, d, e, f,g,h,i,j)
  76. #define TRACEDUMP(l,a,b,c) \
  77. TraceDumpEx(TRACEID,l,a,b,c,TRUE)
  78. #ifdef ENTER_DBG
  79. #define TraceEnter(X) TracePrintfEx(TRACEID, IPA_TRACE_ENTER, \
  80. _T("Entered: ")_T(X))
  81. #define TraceLeave(X) TracePrintfEx(TRACEID, IPA_TRACE_ENTER, \
  82. _T("Leaving: ")_T(X))
  83. #else
  84. #define TraceEnter(X)
  85. #define TraceLeave(X)
  86. #endif // ENTER_DBG
  87. #define LOGLEVEL g_dwLoggingLevel
  88. #define LOGHANDLE g_LogHandle
  89. #define LOGERR RouterLogError
  90. // Error logging
  91. #define Logerr0(msg,err) \
  92. if (LOGLEVEL >= IPA_LOGGING_ERROR) \
  93. LOGERR(LOGHANDLE,IPALOG_ ## msg,0,NULL,(err))
  94. #define Logerr1(msg,a,err) \
  95. if (LOGLEVEL >= IPA_LOGGING_ERROR) \
  96. LOGERR(LOGHANDLE,IPALOG_ ## msg,1,&(a),(err))
  97. #define Logerr2(msg,a,b,err) \
  98. if (LOGLEVEL >= IPA_LOGGING_ERROR) { \
  99. LPSTR _asz[2] = { (a), (b) }; \
  100. LOGERR(LOGHANDLE,IPALOG_ ## msg,2,_asz,(err)); \
  101. }
  102. #define Logerr3(msg,a,b,c,err) \
  103. if (LOGLEVEL >= IPA_LOGGING_ERROR) { \
  104. LPSTR _asz[3] = { (a), (b), (c) }; \
  105. LOGERR(LOGHANDLE,IPALOG_ ## msg,3,_asz,(err)); \
  106. }
  107. #define Logerr4(msg,a,b,c,d,err) \
  108. if (LOGLEVEL >= IPA_LOGGING_ERROR) { \
  109. LPSTR _asz[4] = { (a), (b), (c), (d) }; \
  110. LOGERR(LOGHANDLE,IPALOG_ ## msg,4,_asz,(err)); \
  111. }
  112. //-----------------------------------------------------------------------------
  113. // INITIALIZE_TRACING_LOGGING
  114. //-----------------------------------------------------------------------------
  115. //
  116. // also set the default logging level. It will be reset during
  117. // StartProtocol(), when logging level is set as part of global config
  118. //
  119. #define INITIALIZE_TRACING_LOGGING() { \
  120. TRACEID = TraceRegister(_T("6to4")); \
  121. LOGHANDLE = RouterLogRegister(_T("6to4")); \
  122. LOGLEVEL = IPA_LOGGING_WARN; \
  123. }
  124. //-----------------------------------------------------------------------------
  125. // UNINITIALIZE_TRACING_LOGGING
  126. //-----------------------------------------------------------------------------
  127. #define UNINITIALIZE_TRACING_LOGGING() { \
  128. if (TRACEID != INVALID_TRACEID) { \
  129. TraceDeregister(TRACEID); \
  130. TRACEID = INVALID_TRACEID; \
  131. } \
  132. \
  133. if (LOGHANDLE != NULL) { \
  134. RouterLogDeregister(LOGHANDLE); \
  135. LOGHANDLE = NULL; \
  136. } \
  137. }