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.

288 lines
9.2 KiB

  1. //
  2. // NBTNT.H
  3. //
  4. // This file contains common header definitions for NBT in the NT
  5. // environment
  6. //
  7. //
  8. #ifndef _NBT_H
  9. #define _NBT_H
  10. #ifndef VXD
  11. #include <ntosp.h>
  12. #include <zwapi.h>
  13. //#include <status.h>
  14. //#include <ntstatus.h>
  15. #include <tdikrnl.h>
  16. #include <tdi.h>
  17. #include <windef.h>
  18. #include <stdio.h>
  19. #include <nb30.h>
  20. #else
  21. #include <oscfgnbt.h>
  22. #include <cxport.h>
  23. #define __int64 double
  24. #include <windef.h>
  25. #include <nb30.h>
  26. //
  27. // These definitions work around NTisms found in various difficult to change
  28. // places.
  29. //
  30. typedef ULONG NTSTATUS ;
  31. typedef PNCB PIRP ;
  32. typedef PVOID PDEVICE_OBJECT ;
  33. #include <ctemacro.h>
  34. #include <tdi.h>
  35. //
  36. // These are needed because we include windef.h rather then
  37. // ntddk.h, which end up not being defined
  38. //
  39. #define STATUS_NETWORK_NAME_DELETED ((NTSTATUS)0xC00000CAL)
  40. #define STATUS_INVALID_BUFFER_SIZE ((NTSTATUS)0xC0000206L)
  41. #define STATUS_CONNECTION_DISCONNECTED ((NTSTATUS)0xC000020CL)
  42. #define STATUS_CANCELLED ((NTSTATUS)0xC0000120L)
  43. #define STATUS_UNSUCCESSFUL ((NTSTATUS)0xC0000001L)
  44. #define STATUS_TOO_MANY_COMMANDS ((NTSTATUS)0xC00000C1L)
  45. #define STATUS_OBJECT_NAME_COLLISION ((NTSTATUS)0xC0000035L)
  46. #define STATUS_SHARING_VIOLATION ((NTSTATUS)0xC0000043L)
  47. #define STATUS_DUPLICATE_NAME ((NTSTATUS)0xC00000BDL)
  48. #define STATUS_BAD_NETWORK_PATH ((NTSTATUS)0xC00000BEL)
  49. #define STATUS_REMOTE_NOT_LISTENING ((NTSTATUS)0xC00000BCL)
  50. #define STATUS_CONNECTION_REFUSED ((NTSTATUS)0xC0000236L)
  51. #define STATUS_INVALID_PARAMETER ((NTSTATUS)0xC000000DL)
  52. #define STATUS_UNEXPECTED_NETWORK_ERROR ((NTSTATUS)0xC00000C4L)
  53. #define STATUS_NOT_SUPPORTED ((NTSTATUS)0xC00000BBL)
  54. #define STATUS_INVALID_HANDLE ((NTSTATUS)0xC0000008L)
  55. #define STATUS_INVALID_DEVICE_REQUEST ((NTSTATUS)0xC0000010L)
  56. #define STATUS_INVALID_PARAMETER_6 ((NTSTATUS)0xC00000F4L)
  57. //
  58. // The following functions are used by NBT. They are defined in the NT kernel
  59. // TDI stuff which we are trying to avoid.
  60. //
  61. typedef
  62. NTSTATUS
  63. (*PTDI_IND_CONNECT)(
  64. IN PVOID TdiEventContext,
  65. IN int RemoteAddressLength,
  66. IN PVOID RemoteAddress,
  67. IN int UserDataLength,
  68. IN PVOID UserData,
  69. IN int OptionsLength,
  70. IN PVOID Options,
  71. OUT CONNECTION_CONTEXT *ConnectionContext
  72. )
  73. ;
  74. NTSTATUS
  75. TdiDefaultConnectHandler (
  76. IN PVOID TdiEventContext,
  77. IN int RemoteAddressLength,
  78. IN PVOID RemoteAddress,
  79. IN int UserDataLength,
  80. IN PVOID UserData,
  81. IN int OptionsLength,
  82. IN PVOID Options,
  83. OUT CONNECTION_CONTEXT *ConnectionContext
  84. );
  85. //
  86. // Disconnection indication prototype. This is invoked when a connection is
  87. // being disconnected for a reason other than the user requesting it. Note that
  88. // this is a change from TDI V1, which indicated only when the remote caused
  89. // a disconnection. Any non-directed disconnection will cause this indication.
  90. //
  91. typedef
  92. NTSTATUS
  93. (*PTDI_IND_DISCONNECT)(
  94. IN PVOID TdiEventContext,
  95. IN CONNECTION_CONTEXT ConnectionContext,
  96. IN int DisconnectDataLength,
  97. IN PVOID DisconnectData,
  98. IN int DisconnectInformationLength,
  99. IN PVOID DisconnectInformation,
  100. IN ULONG DisconnectFlags
  101. );
  102. NTSTATUS
  103. TdiDefaultDisconnectHandler (
  104. IN PVOID TdiEventContext,
  105. IN CONNECTION_CONTEXT ConnectionContext,
  106. IN int DisconnectDataLength,
  107. IN PVOID DisconnectData,
  108. IN int DisconnectInformationLength,
  109. IN PVOID DisconnectInformation,
  110. IN ULONG DisconnectFlags
  111. );
  112. //
  113. // A protocol error has occurred when this indication happens. This indication
  114. // occurs only for errors of the worst type; the address this indication is
  115. // delivered to is no longer usable for protocol-related operations, and
  116. // should not be used for operations henceforth. All connections associated
  117. // it are invalid.
  118. // For NetBIOS-type providers, this indication is also delivered when a name
  119. // in conflict or duplicate name occurs.
  120. //
  121. typedef
  122. NTSTATUS
  123. (*PTDI_IND_ERROR)(
  124. IN PVOID TdiEventContext, // the endpoint's file object.
  125. IN NTSTATUS Status // status code indicating error type.
  126. );
  127. NTSTATUS
  128. TdiDefaultErrorHandler (
  129. IN PVOID TdiEventContext, // the endpoint's file object.
  130. IN NTSTATUS Status // status code indicating error type.
  131. );
  132. //
  133. // TDI_IND_RECEIVE indication handler definition. This client routine is
  134. // called by the transport provider when a connection-oriented TSDU is received
  135. // that should be presented to the client.
  136. //
  137. typedef
  138. NTSTATUS
  139. (*PTDI_IND_RECEIVE)(
  140. IN PVOID TdiEventContext,
  141. IN CONNECTION_CONTEXT ConnectionContext,
  142. IN ULONG ReceiveFlags,
  143. IN ULONG BytesIndicated,
  144. IN ULONG BytesAvailable,
  145. OUT ULONG *BytesTaken,
  146. IN PVOID Tsdu, // pointer describing this TSDU, typically a lump of bytes
  147. OUT PIRP *IoRequestPacket // TdiReceive IRP if MORE_PROCESSING_REQUIRED.
  148. );
  149. NTSTATUS
  150. TdiDefaultReceiveHandler (
  151. IN PVOID TdiEventContext,
  152. IN CONNECTION_CONTEXT ConnectionContext,
  153. IN ULONG ReceiveFlags,
  154. IN ULONG BytesIndicated,
  155. IN ULONG BytesAvailable,
  156. OUT ULONG *BytesTaken,
  157. IN PVOID Tsdu, // pointer describing this TSDU, typically a lump of bytes
  158. OUT PIRP *IoRequestPacket // TdiReceive IRP if MORE_PROCESSING_REQUIRED.
  159. );
  160. //
  161. // TDI_IND_RECEIVE_DATAGRAM indication handler definition. This client routine
  162. // is called by the transport provider when a connectionless TSDU is received
  163. // that should be presented to the client.
  164. //
  165. typedef
  166. NTSTATUS
  167. (*PTDI_IND_RECEIVE_DATAGRAM)(
  168. IN PVOID TdiEventContext, // the event context
  169. IN int SourceAddressLength, // length of the originator of the datagram
  170. IN PVOID SourceAddress, // string describing the originator of the datagram
  171. IN int OptionsLength, // options for the receive
  172. IN PVOID Options, //
  173. IN ULONG BytesIndicated, // number of bytes this indication
  174. IN ULONG BytesAvailable, // number of bytes in complete Tsdu
  175. OUT ULONG *BytesTaken, // number of bytes used
  176. IN PVOID Tsdu, // pointer describing this TSDU, typically a lump of bytes
  177. OUT PIRP *IoRequestPacket // TdiReceive IRP if MORE_PROCESSING_REQUIRED.
  178. );
  179. NTSTATUS
  180. TdiDefaultRcvDatagramHandler (
  181. IN PVOID TdiEventContext, // the event context
  182. IN int SourceAddressLength, // length of the originator of the datagram
  183. IN PVOID SourceAddress, // string describing the originator of the datagram
  184. IN int OptionsLength, // options for the receive
  185. IN PVOID Options, //
  186. IN ULONG BytesIndicated, // number of bytes this indication
  187. IN ULONG BytesAvailable, // number of bytes in complete Tsdu
  188. OUT ULONG *BytesTaken, // number of bytes used
  189. IN PVOID Tsdu, // pointer describing this TSDU, typically a lump of bytes
  190. OUT PIRP *IoRequestPacket // TdiReceive IRP if MORE_PROCESSING_REQUIRED.
  191. );
  192. //
  193. // This indication is delivered if expedited data is received on the connection.
  194. // This will only occur in providers that support expedited data.
  195. //
  196. typedef
  197. NTSTATUS
  198. (*PTDI_IND_RECEIVE_EXPEDITED)(
  199. IN PVOID TdiEventContext,
  200. IN CONNECTION_CONTEXT ConnectionContext,
  201. IN ULONG ReceiveFlags, //
  202. IN ULONG BytesIndicated, // number of bytes in this indication
  203. IN ULONG BytesAvailable, // number of bytes in complete Tsdu
  204. OUT ULONG *BytesTaken, // number of bytes used by indication routine
  205. IN PVOID Tsdu, // pointer describing this TSDU, typically a lump of bytes
  206. OUT PIRP *IoRequestPacket // TdiReceive IRP if MORE_PROCESSING_REQUIRED.
  207. );
  208. NTSTATUS
  209. TdiDefaultRcvExpeditedHandler (
  210. IN PVOID TdiEventContext,
  211. IN CONNECTION_CONTEXT ConnectionContext,
  212. IN ULONG ReceiveFlags, //
  213. IN ULONG BytesIndicated, // number of bytes in this indication
  214. IN ULONG BytesAvailable, // number of bytes in complete Tsdu
  215. OUT ULONG *BytesTaken, // number of bytes used by indication routine
  216. IN PVOID Tsdu, // pointer describing this TSDU, typically a lump of bytes
  217. OUT PIRP *IoRequestPacket // TdiReceive IRP if MORE_PROCESSING_REQUIRED.
  218. );
  219. //
  220. // This indication is delivered if there is room for a send in the buffer of
  221. // a buffering protocol.
  222. //
  223. typedef
  224. NTSTATUS
  225. (*PTDI_IND_SEND_POSSIBLE)(
  226. IN PVOID TdiEventContext,
  227. IN PVOID ConnectionContext,
  228. IN ULONG BytesAvailable);
  229. NTSTATUS
  230. TdiDefaultSendPossibleHandler (
  231. IN PVOID TdiEventContext,
  232. IN PVOID ConnectionContext,
  233. IN ULONG BytesAvailable);
  234. #endif //VXD
  235. #define FILE_DEVICE_NBT 0x32
  236. #if (defined(_M_IX86) && (_MSC_FULL_VER > 13009037)) || ((defined(_M_AMD64) || defined(_M_IA64)) && (_MSC_FULL_VER > 13009175))
  237. #define htons(x) _byteswap_ushort((USHORT)(x))
  238. #define htonl(x) _byteswap_ulong((ULONG)(x))
  239. #else
  240. #define htons(x) ((((x) >> 8) & 0x00FF) | (((x) << 8) & 0xFF00))
  241. __inline long
  242. htonl(long x)
  243. {
  244. return((((x) >> 24) & 0x000000FFL) |
  245. (((x) >> 8) & 0x0000FF00L) |
  246. (((x) << 8) & 0x00FF0000L) |
  247. (((x) << 24) & 0xFF000000L));
  248. }
  249. #endif
  250. #define ntohs(x) htons(x)
  251. #define ntohl(x) htonl(x)
  252. #endif