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.

210 lines
7.2 KiB

  1. /*++
  2. Copyright (c) 1989-1993 Microsoft Corporation
  3. Module Name:
  4. spxdev.h
  5. Abstract:
  6. This module contains definitions specific to the
  7. SPX module of the ISN transport.
  8. Author:
  9. Adam Barr (adamba ) Original Version
  10. Nikhil Kamkolkar (nikhilk) 17-November-1993
  11. Environment:
  12. Kernel mode
  13. Revision History:
  14. --*/
  15. // Hash buckets for SPX_ADDR done using socket number
  16. #define NUM_SPXADDR_HASH_BUCKETS 8
  17. #define NUM_SPXADDR_HASH_MASK 7
  18. #define NUM_SPXCONN_HASH_BUCKETS 8
  19. #define NUM_SPXCONN_HASH_MASK 7
  20. // This structure defines the per-device structure for SPX
  21. // (one of these is allocated globally).
  22. #define DREF_CREATE 0
  23. #define DREF_LOADED 1
  24. #define DREF_ADAPTER 2
  25. #define DREF_ADDRESS 3
  26. #define DREF_ORPHAN 4
  27. #define DREF_TOTAL 5
  28. typedef struct _DEVICE {
  29. PDEVICE_OBJECT dev_DevObj; // the I/O system's device object.
  30. #if DBG
  31. ULONG dev_RefTypes[DREF_TOTAL];
  32. #endif
  33. CSHORT dev_Type; // type of this structure
  34. USHORT dev_Size; // size of this structure
  35. #if DBG
  36. UCHAR dev_Signature1[4]; // contains "SPX1"
  37. #endif
  38. // activity count/this provider.
  39. LONG dev_RefCount;
  40. UCHAR dev_State;
  41. // number of adapters IPX is bound to.
  42. USHORT dev_Adapters;
  43. // GLOBAL lock for reference count (used in ExInterlockedXxx calls).
  44. CTELock dev_Interlock;
  45. CTELock dev_Lock;
  46. // Hash table of lists of addresses opened on this device
  47. struct _SPX_ADDR * dev_AddrHashTable[NUM_SPXADDR_HASH_BUCKETS];
  48. // List of all active connections, later this be a tree.
  49. struct _SPX_CONN_FILE * dev_GlobalActiveConnList[NUM_SPXCONN_HASH_BUCKETS];
  50. USHORT dev_NextConnId;
  51. // Other configuration parameters.
  52. // Where the current socket allocation is.
  53. USHORT dev_CurrentSocket;
  54. // Our node and network.
  55. UCHAR dev_Network[4];
  56. UCHAR dev_Node[6];
  57. // Pointer to the config information from registry
  58. PCONFIG dev_ConfigInfo;
  59. // Control channel identifier
  60. ULONG dev_CcId;
  61. // These are kept around for error logging, and stored right
  62. // after this structure.
  63. PWCHAR dev_DeviceName;
  64. #if defined(_PNP_POWER)
  65. USHORT dev_DeviceNameLen;
  66. #else
  67. ULONG dev_DeviceNameLen;
  68. #endif _PNP_POWER
  69. #if DBG
  70. UCHAR dev_Signature2[4]; // contains "SPX2"
  71. #endif
  72. // Handle to ndis buffer pool for spx stack.
  73. NDIS_HANDLE dev_NdisBufferPoolHandle;
  74. // registration handle with tdi clients.
  75. #if defined(_PNP_POWER)
  76. HANDLE dev_TdiRegistrationHandle;
  77. #endif _PNP_POWER
  78. // This interlock is used to guard access to the statistics
  79. // define below.
  80. KSPIN_LOCK dev_StatInterlock; // for ULONG quantities
  81. KSPIN_LOCK dev_StatSpinLock; // for LARGE_INTEGER quantities
  82. // Counters for most of the statistics that SPX maintains;
  83. // some of these are kept elsewhere. Including the structure
  84. // itself wastes a little space but ensures that the alignment
  85. // inside the structure is correct.
  86. TDI_PROVIDER_STATISTICS dev_Stat;
  87. // This resource guards access to the ShareAccess
  88. // and SecurityDescriptor fields in addresses.
  89. ERESOURCE dev_AddrResource;
  90. // The following structure contains statistics counters for use
  91. // by TdiQueryInformation and TdiSetInformation. They should not
  92. // be used for maintenance of internal data structures.
  93. TDI_PROVIDER_INFO dev_ProviderInfo; // information about this provider.
  94. } DEVICE, * PDEVICE;
  95. //
  96. // As part of "doing it ourselves" theme as opposed to the DeviceExtension code,
  97. // we declare a global SpxDevice that will be used by all.
  98. //
  99. //PDEVICE SpxDevice;
  100. //PDEVICE_OBJECT DeviceObject;
  101. // device state definitions
  102. #if defined(_PNP_POWER)
  103. #define DEVICE_STATE_CLOSED 0x00 // Initial state
  104. #define DEVICE_STATE_LOADED 0x01 // Loaded and bound to IPX but no adapters
  105. #define DEVICE_STATE_OPEN 0x02 // Fully operational
  106. #define DEVICE_STATE_STOPPING 0x03 // Unload has been initiated, The I/O system
  107. // will not call us until nobody above has Netbios open.
  108. #else
  109. #define DEVICE_STATE_CLOSED 0x00
  110. #define DEVICE_STATE_OPEN 0x01
  111. #define DEVICE_STATE_STOPPING 0x02
  112. #endif _PNP_POWER
  113. // SPX device name
  114. #define SPX_DEVICE_NAME L"\\Device\\NwlnkSpx"
  115. #define SPX_TDI_RESOURCES 9
  116. // MACROS
  117. #if DBG
  118. #define SpxReferenceDevice(_Device, _Type) \
  119. { \
  120. (VOID)SPX_ADD_ULONG ( \
  121. &(_Device)->dev_RefTypes[_Type], \
  122. 1, \
  123. &SpxGlobalInterlock); \
  124. \
  125. (VOID)InterlockedIncrement ( \
  126. &(_Device)->dev_RefCount); \
  127. }
  128. #define SpxDereferenceDevice(_Device, _Type) \
  129. { \
  130. (VOID)SPX_ADD_ULONG ( \
  131. &(_Device)->dev_RefTypes[_Type], \
  132. (ULONG)-1, \
  133. &SpxGlobalInterlock); \
  134. SpxDerefDevice (_Device); \
  135. }
  136. #else
  137. #define SpxReferenceDevice(_Device, _Type) \
  138. { \
  139. (VOID)InterlockedIncrement ( \
  140. &(_Device)->dev_RefCount); \
  141. }
  142. #define SpxDereferenceDevice(_Device, _Type) \
  143. SpxDerefDevice (_Device)
  144. #endif
  145. // EXPORTED ROUTINES
  146. VOID
  147. SpxDestroyDevice(
  148. IN PDEVICE Device);
  149. VOID
  150. SpxDerefDevice(
  151. IN PDEVICE Device);
  152. NTSTATUS
  153. SpxInitCreateDevice(
  154. IN PDRIVER_OBJECT DriverObject,
  155. IN PUNICODE_STRING DeviceName);
  156.