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.

190 lines
4.1 KiB

  1. /*++
  2. Copyright (c) 1997 Microsoft Corporation
  3. Module Name:
  4. D:\nt\private\ntos\tdi\rawwan\core\rwannt.h
  5. Abstract:
  6. NT-specific definitions for Raw WAN.
  7. Revision History:
  8. Who When What
  9. -------- -------- ----------------------------------------------
  10. arvindm 04-17-97 Created
  11. Notes:
  12. --*/
  13. #ifndef __TDI_RWANNT__H
  14. #define __TDI_RWANNT__H
  15. #ifdef NT
  16. #if DBG_LOG_EP
  17. #define MAX_EP_LOG_ENTRIES 32
  18. typedef struct _RWAND_EP_LOG_ENTRY
  19. {
  20. ULONG LineNumber;
  21. ULONG Event;
  22. PVOID Context1;
  23. PVOID Context2;
  24. } RWAND_EP_LOG_ENTRY, *PRWAND_EP_LOG_ENTRY;
  25. #define RWAN_EP_DBGLOG_SET_SIGNATURE(_pEp) \
  26. (_pEp)->EpLogSig = 'GOLE'
  27. #define RWAN_EP_DBGLOG_ENTRY(_pEp, _Event, _Ctx1, _Ctx2) \
  28. { \
  29. PRWAND_EP_LOG_ENTRY pLogEnt; \
  30. ULONG Index; \
  31. NdisAcquireSpinLock(&RWanDbgLogLock); \
  32. (_pEp)->EpLogCount++; \
  33. Index = (_pEp)->EpLogIndex; \
  34. pLogEnt = &((_pEp)->EpLog[Index]); \
  35. pLogEnt->LineNumber = __LINE__; \
  36. pLogEnt->Event = _Event; \
  37. pLogEnt->Context1 = (PVOID)_Ctx1; \
  38. pLogEnt->Context2 = (PVOID)_Ctx2; \
  39. (_pEp)->EpLogIndex++; \
  40. if ((_pEp)->EpLogIndex == MAX_EP_LOG_ENTRIES) \
  41. { \
  42. (_pEp)->EpLogIndex = 0; \
  43. } \
  44. NdisReleaseSpinLock(&RWanDbgLogLock); \
  45. }
  46. #else
  47. #define RWAN_EP_DBGLOG_SET_SIGNATURE(_pEp)
  48. #define RWAN_EP_DBGLOG_ENTRY(_pEp, _Event, _Ctx1, _Ctx2)
  49. #endif
  50. //
  51. // ***** Endpoint *****
  52. //
  53. // One of these is allocated for each MJ_CREATE successfully processed.
  54. // A pointer to this structure is returned in FileObject->FsContext.
  55. //
  56. // The object it represents is one of these:
  57. // Address object, Connection object, Control channel.
  58. //
  59. // Reference Count: RefCount is incremented for each of the following:
  60. // - for the duration an IRP pertaining to this object is pending
  61. //
  62. typedef struct RWAN_ENDPOINT
  63. {
  64. #if DBG
  65. ULONG nep_sig;
  66. #endif
  67. #ifdef REFDBG
  68. ULONG SendIncrRefs;
  69. ULONG RecvIncrRefs;
  70. ULONG CloseComplDecrRefs;
  71. ULONG DataReqComplDecrRefs;
  72. ULONG CancelComplDecrRefs;
  73. ULONG CancelIncrRefs;
  74. ULONG NonDataIncrRefs;
  75. #endif
  76. #if DBG
  77. PVOID pConnObject; // Transport's context
  78. #endif
  79. union
  80. {
  81. HANDLE AddressHandle; // Address Object
  82. CONNECTION_CONTEXT ConnectionContext; // Connection Object
  83. HANDLE ControlChannel; // Control channel
  84. } Handle;
  85. struct _RWAN_TDI_PROTOCOL * pProtocol;
  86. ULONG RefCount;
  87. BOOLEAN bCancelIrps; // are we cleaning up?
  88. KEVENT CleanupEvent; // synchronization
  89. #if DBG_LOG_EP
  90. ULONG EpLogSig;
  91. ULONG EpLogCount;
  92. ULONG EpLogIndex;
  93. struct _RWAND_EP_LOG_ENTRY EpLog[MAX_EP_LOG_ENTRIES];
  94. #endif
  95. } RWAN_ENDPOINT, *PRWAN_ENDPOINT;
  96. #if DBG
  97. #define nep_signature 'NlEp'
  98. #endif // DBG
  99. #define NULL_PRWAN_ENDPOINT ((PRWAN_ENDPOINT)NULL)
  100. //
  101. // ***** Device Object *****
  102. //
  103. // We create one NT device object for each TDI protocol that we
  104. // expose i.e. each Winsock triple <Family, Proto, Type>.
  105. //
  106. typedef struct _RWAN_DEVICE_OBJECT
  107. {
  108. #if DBG
  109. ULONG ndo_sig;
  110. #endif // DBG
  111. PDEVICE_OBJECT pDeviceObject; // NT device object
  112. struct _RWAN_TDI_PROTOCOL * pProtocol; // Info about the protocol
  113. LIST_ENTRY DeviceObjectLink; // in list of device objs
  114. } RWAN_DEVICE_OBJECT, *PRWAN_DEVICE_OBJECT;
  115. #if DBG
  116. #define ndo_signature 'NlDo'
  117. #endif // DBG
  118. #ifdef REFDBG
  119. #define RWAN_INCR_EP_REF_CNT(_pEp, _Type) \
  120. { \
  121. (_pEp)->RefCount++; \
  122. (_pEp)->_Type##Refs++; \
  123. }
  124. #define RWAN_DECR_EP_REF_CNT(_pEp, _Type) \
  125. { \
  126. (_pEp)->RefCount--; \
  127. (_pEp)->_Type##Refs--; \
  128. }
  129. #else
  130. #define RWAN_INCR_EP_REF_CNT(_pEp, _Type) \
  131. (_pEp)->RefCount++;
  132. #define RWAN_DECR_EP_REF_CNT(_pEp, _Type) \
  133. (_pEp)->RefCount--;
  134. #endif // REFDBG
  135. /*++
  136. LARGE_INTEGER
  137. RWAN_CONVERT_100NS_TO_MS(
  138. IN LARGE_INTEGER HnsTime,
  139. OUT PULONG pRemainder
  140. )
  141. --*/
  142. #define RWAN_CONVERT_100NS_TO_MS(_HnsTime, _pRemainder) \
  143. RtlExtendedLargeIntegerDivide(_HnsTime, 10000, _pRemainder);
  144. #endif // NT
  145. #endif // __TDI_RWANNT__H