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.

259 lines
8.4 KiB

  1. /*++
  2. Copyright (c) 1990-1995 Microsoft Corporation
  3. Module Name:
  4. debug.h
  5. Abstract:
  6. This file contains data structures and defs used by the
  7. NdisWan driver for debugging
  8. Author:
  9. Tony Bell (TonyBe) January 18, 1997
  10. Environment:
  11. Kernel Mode
  12. Revision History:
  13. TonyBe 01/18/97 Created
  14. --*/
  15. #ifndef _NDISWAN_DEBUG_
  16. #define _NDISWAN_DEBUG_
  17. //
  18. // OS specific structures
  19. //
  20. #ifdef NT
  21. #endif
  22. //
  23. // end of OS specific structures
  24. //
  25. //
  26. // Debugging
  27. //
  28. #define DBG_DEATH 1
  29. #define DBG_CRITICAL_ERROR 2
  30. #define DBG_FAILURE 4
  31. #define DBG_INFO 6
  32. #define DBG_TRACE 8
  33. #define DBG_VERBOSE 10
  34. #define DBG_INIT 0x00000001
  35. #define DBG_MINIPORT 0x00000002
  36. #define DBG_PROTOCOL 0x00000004
  37. #define DBG_SEND 0x00000008
  38. #define DBG_RECEIVE 0x00000010
  39. #define DBG_IO 0x00000020
  40. #define DBG_MEMORY 0x00000040
  41. #define DBG_VJ 0x00000080
  42. #define DBG_TAPI 0x00000100
  43. #define DBG_CCP 0x00000200
  44. #define DBG_LOOPBACK 0x00000400
  45. #define DBG_MULTILINK_RECV 0x00000800
  46. #define DBG_MULTILINK_SEND 0x00001000
  47. #define DBG_SEND_VJ 0x00002000
  48. #define DBG_RECV_VJ 0x00004000
  49. #define DBG_CL 0x00008000
  50. #define DBG_CM 0x00010000
  51. #define DBG_INDICATE 0x00020000
  52. #define DBG_BACP 0x00040000
  53. #define DBG_REQUEST 0x00080000
  54. #define DBG_ALL 0xFFFFFFFF
  55. #define INIT_FILESIG 'tini'
  56. #define MINIPORT_FILESIG 'inim'
  57. #define PROTOCOL_FILESIG 'torp'
  58. #define SEND_FILESIG 'dnes'
  59. #define RECEIVE_FILESIG 'vcer'
  60. #define IO_FILESIG ' oi'
  61. #define MEMORY_FILESIG ' mem'
  62. #define CCP_FILESIG ' pcc'
  63. #define CL_FILESIG ' lc'
  64. #define CM_FILESIG ' mc'
  65. #define INDICATE_FILESIG 'idni'
  66. #define REQUEST_FILESIG ' qer'
  67. #define VJ_FILESIG ' jv'
  68. #define TAPI_FILESIG 'ipat'
  69. #define LOOPBACK_FILESIG 'pool'
  70. #define COMPRESS_FILESIG 'pmoc'
  71. #define UTIL_FILESIG 'litu'
  72. #define MAX_BYTE_DEPTH 2048
  73. #if DBG
  74. typedef struct _DBG_PACKET {
  75. LIST_ENTRY Linkage;
  76. PVOID Packet;
  77. ULONG PacketType;
  78. struct _BUNDLECB *BundleCB;
  79. ULONG BundleState;
  80. ULONG BundleFlags;
  81. struct _PROTOCOLCB *ProtocolCB;
  82. ULONG ProtocolState;
  83. struct _LINKCB *LinkCB;
  84. ULONG LinkState;
  85. ULONG SendCount;
  86. } DBG_PACKET, *PDBG_PACKET;
  87. typedef enum DbgPktType {
  88. PacketTypeWan = 1,
  89. PacketTypeNdis
  90. }DbgPktType;
  91. typedef struct _DBG_PKT_CONTEXT {
  92. struct _BUNDLECB *BundleCB;
  93. struct _PROTOCOLCB *ProtocolCB;
  94. struct _LINKCB *LinkCB;
  95. PVOID Packet;
  96. DbgPktType PacketType;
  97. PLIST_ENTRY ListHead;
  98. PNDIS_SPIN_LOCK ListLock;
  99. } DBG_PKT_CONTEXT, *PDBG_PKT_CONTEXT;
  100. typedef enum TRC_EVENT_TYPE {
  101. TrcEventSend = 1,
  102. TrcEventRecv
  103. }TRC_EVENT_TYPE;
  104. typedef struct _WAN_TRC_EVENT {
  105. LIST_ENTRY Linkage;
  106. TRC_EVENT_TYPE TrcType;
  107. WAN_TIME TrcTimeStamp;
  108. ULONG TrcInfoLength;
  109. PUCHAR TrcInfo;
  110. } WAN_TRC_EVENT, *PWAN_TRC_EVENT;
  111. typedef enum SEND_TRC_TYPE {
  112. ProtocolQueue = 1,
  113. ProtocolSend,
  114. ProtocolSendComlete,
  115. FragmentSend,
  116. LinkSend,
  117. LinkSendComplete
  118. } SEND_TRC_TYPE;
  119. typedef struct _SEND_TRC_INFO {
  120. SEND_TRC_TYPE SendTrcType;
  121. PNDIS_PACKET NdisPacket;
  122. NDIS_HANDLE BundleHandle;
  123. NDIS_HANDLE ProtocolHandle;
  124. NDIS_HANDLE LinkHandle;
  125. ULONG SequenceNum;
  126. } SEND_TRC_INFO, *PSEND_TRC_INFO;
  127. #define NdisWanDbgOut(_DebugLevel, _DebugMask, _Out) { \
  128. if ((glDebugLevel >= _DebugLevel) && \
  129. (_DebugMask & glDebugMask)) { \
  130. DbgPrint("NDISWAN: "); \
  131. DbgPrint _Out; \
  132. DbgPrint("\n"); \
  133. } \
  134. }
  135. #undef ASSERT
  136. #define ASSERT(exp) \
  137. { \
  138. if (!(exp)) { \
  139. DbgPrint("NDISWAN: ASSERTION FAILED! %s\n", #exp); \
  140. DbgPrint("NDISWAN: File: %s, Line: %d\n", __FILE__, __LINE__); \
  141. DbgBreakPoint(); \
  142. } \
  143. }
  144. VOID
  145. InsertDbgPacket(
  146. PDBG_PKT_CONTEXT DbgContext
  147. );
  148. BOOLEAN
  149. RemoveDbgPacket(
  150. PDBG_PKT_CONTEXT DbgContext
  151. );
  152. #define INSERT_DBG_SEND(_pt, _ctxcb, _ppcb, _plcb, _p) \
  153. { \
  154. DBG_PKT_CONTEXT DbgContext; \
  155. DbgContext.Packet = (_p); \
  156. DbgContext.BundleCB = (_ppcb)->BundleCB; \
  157. DbgContext.ProtocolCB = (_ppcb); \
  158. DbgContext.LinkCB = (_plcb); \
  159. if (_ctxcb != NULL) { \
  160. DbgContext.PacketType = _pt; \
  161. DbgContext.ListHead = &(_ctxcb)->SendPacketList; \
  162. DbgContext.ListLock = &(_ctxcb)->Lock; \
  163. InsertDbgPacket(&DbgContext); \
  164. } \
  165. }
  166. #define REMOVE_DBG_SEND(_pt, _ctxcb, _p) \
  167. { \
  168. DBG_PKT_CONTEXT DbgContext; \
  169. DbgContext.Packet = (_p); \
  170. if (_ctxcb != NULL) { \
  171. DbgContext.PacketType = _pt; \
  172. DbgContext.ListHead = &(_ctxcb)->SendPacketList; \
  173. DbgContext.ListLock = &(_ctxcb)->Lock; \
  174. RemoveDbgPacket(&DbgContext); \
  175. } \
  176. }
  177. #define INSERT_DBG_RECV(_pt, _ctxcb, _ppcb, _plcb, _p) \
  178. { \
  179. DBG_PKT_CONTEXT DbgContext; \
  180. DbgContext.Packet = (_p); \
  181. DbgContext.BundleCB = NULL; \
  182. DbgContext.ProtocolCB = (_ppcb); \
  183. DbgContext.LinkCB = (_plcb); \
  184. if (_ctxcb != NULL) { \
  185. DbgContext.PacketType = _pt; \
  186. DbgContext.ListHead = &(_ctxcb)->RecvPacketList; \
  187. DbgContext.ListLock = &(_ctxcb)->Lock; \
  188. InsertDbgPacket(&DbgContext); \
  189. } \
  190. }
  191. #define REMOVE_DBG_RECV(_pt, _ctxcb, _p) \
  192. { \
  193. DBG_PKT_CONTEXT DbgContext; \
  194. DbgContext.Packet = (_p); \
  195. if (_ctxcb != NULL) { \
  196. DbgContext.PacketType = _pt; \
  197. DbgContext.ListHead = &(_ctxcb)->RecvPacketList; \
  198. DbgContext.ListLock = &(_ctxcb)->Lock; \
  199. RemoveDbgPacket(&DbgContext); \
  200. } \
  201. }
  202. #define INSERT_RECV_EVENT(_c) \
  203. { \
  204. reA[reI] = _c; \
  205. LastIrpAction = _c; \
  206. if (++reI >= 1024) { \
  207. reI = 0; \
  208. } \
  209. }
  210. #else // If not built with debug
  211. #define NdisWanDbgOut(_DebugLevel, _DebugMask, _Out)
  212. #define INSERT_DBG_SEND(_pt, _ctxcb, _ppcb, _plcb, _p)
  213. #define REMOVE_DBG_SEND(_pt, _ctxcb, _p)
  214. #define INSERT_DBG_RECV(_pt, _ctxcb, _ppcb, _plcb, _p)
  215. #define REMOVE_DBG_RECV(_pt, _ctxcb, _p)
  216. #define INSERT_RECV_EVENT(_c)
  217. #endif // end of !DBG
  218. #endif // end of _NDISWAN_DEBUG