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.

230 lines
10 KiB

  1. /*++
  2. Copyright (c) 1989 Microsoft Corporation
  3. Module Name:
  4. WS2IFSL.H
  5. Abstract:
  6. This module defines interface for Winsock2 IFS transport layer driver.
  7. Author:
  8. Vadim Eydelman (VadimE) Dec-1996
  9. Revision History:
  10. Vadim Eydelman (VadimE) Oct-1997, rewrite to properly handle IRP
  11. cancellation
  12. --*/
  13. #ifndef _WS2IFSL_
  14. #define _WS2IFSL_
  15. // Macro to align address data in the output buffer
  16. #define ADDR_ALIGN(sz) (((sz)+1)&(~3))
  17. // Parameters for IOCTL_WS2IFSL_RETRIEVE_DRV_REQ
  18. typedef struct _WS2IFSL_RTRV_PARAMS {
  19. IN ULONG UniqueId; // Unique ID
  20. OUT PVOID DllContext; // Context associated by dll
  21. // with the socket file.
  22. OUT ULONG RequestType; // Request type
  23. #define WS2IFSL_REQUEST_READ 0
  24. #define WS2IFSL_REQUEST_WRITE 1
  25. #define WS2IFSL_REQUEST_SENDTO 2
  26. #define WS2IFSL_REQUEST_RECV 3
  27. #define WS2IFSL_REQUEST_RECVFROM 4
  28. #define WS2IFSL_REQUEST_QUERYHANDLE 5
  29. OUT ULONG DataLen; // Length of data/buffer
  30. OUT ULONG AddrLen; // Length of addr/buffer
  31. OUT ULONG Flags; // Flags
  32. } WS2IFSL_RTRV_PARAMS, *PWS2IFSL_RTRV_PARAMS;
  33. // Parameters for IOCTL_WS2IFSL_COMPLETE_DRV_REQ
  34. typedef struct _WS2IFSL_CMPL_PARAMS {
  35. IN HANDLE SocketHdl; // Handle of socket object
  36. IN ULONG UniqueId; // Unique ID
  37. IN ULONG DataLen; // Length of data to copy/report
  38. IN ULONG AddrLen; // Length of addr to copy and report
  39. IN NTSTATUS Status; // Completion status
  40. } WS2IFSL_CMPL_PARAMS, *PWS2IFSL_CMPL_PARAMS;
  41. // Parameters for IOCTL_WS2IFSL_COMPLETE_DRV_CAN
  42. typedef struct _WS2IFSL_CNCL_PARAMS {
  43. IN ULONG UniqueId; // Unique ID
  44. } WS2IFSL_CNCL_PARAMS, *PWS2IFSL_CNCL_PARAMS;
  45. // Socket context parameters
  46. typedef struct _WS2IFSL_SOCKET_CTX {
  47. PVOID DllContext; // Context value to be associated
  48. // with the socket
  49. HANDLE ProcessFile; // Process file handle for the
  50. // current process
  51. } WS2IFSL_SOCKET_CTX, *PWS2IFSL_SOCKET_CTX;
  52. // Process context parameters
  53. typedef struct _WS2IFSL_PROCESS_CTX {
  54. HANDLE ApcThread; // Thread to queue APC's to
  55. PPS_APC_ROUTINE RequestRoutine; // APC routine to pass requests
  56. PPS_APC_ROUTINE CancelRoutine; // APC routine to pass cancel
  57. PVOID ApcContext; // Apc routine context
  58. ULONG DbgLevel; // Used only in debug builds,
  59. // (0 on free DLL builds and ignored
  60. // by the free driver)
  61. } WS2IFSL_PROCESS_CTX, *PWS2IFSL_PROCESS_CTX;
  62. // WS2IFSL device name
  63. #define WS2IFSL_DEVICE_NAME L"\\Device\\WS2IFSL"
  64. #define WS2IFSL_SOCKET_FILE_NAME WS2IFSL_DEVICE_NAME L"\\NifsSct"
  65. #define WS2IFSL_PROCESS_FILE_NAME WS2IFSL_DEVICE_NAME L"\\NifsPvd"
  66. // Extended attribute names for the WS2IFSL files (note that size of the
  67. // string (including terminating NULL) is carefully chosen to ensure
  68. // quad word alignment of the attribute value):
  69. // Socket file
  70. #define WS2IFSL_SOCKET_EA_NAME "NifsSct"
  71. #define WS2IFSL_SOCKET_EA_NAME_LENGTH (sizeof(WS2IFSL_SOCKET_EA_NAME)-1)
  72. #define WS2IFSL_SOCKET_EA_VALUE_LENGTH (sizeof(WS2IFSL_SOCKET_CTX))
  73. #define WS2IFSL_SOCKET_EA_VALUE_OFFSET \
  74. (FIELD_OFFSET(FILE_FULL_EA_INFORMATION, \
  75. EaName[WS2IFSL_SOCKET_EA_NAME_LENGTH+1]))
  76. #define GET_WS2IFSL_SOCKET_EA_VALUE(eaInfo) \
  77. ((PWS2IFSL_SOCKET_CTX)( \
  78. (PUCHAR)eaInfo +WS2IFSL_SOCKET_EA_VALUE_OFFSET))
  79. #define WS2IFSL_SOCKET_EA_INFO_LENGTH \
  80. (WS2IFSL_SOCKET_EA_VALUE_OFFSET+WS2IFSL_SOCKET_EA_VALUE_LENGTH)
  81. // Process file
  82. #define WS2IFSL_PROCESS_EA_NAME "NifsPvd"
  83. #define WS2IFSL_PROCESS_EA_NAME_LENGTH (sizeof(WS2IFSL_PROCESS_EA_NAME)-1)
  84. #define WS2IFSL_PROCESS_EA_VALUE_LENGTH (sizeof(WS2IFSL_PROCESS_CTX))
  85. #define WS2IFSL_PROCESS_EA_VALUE_OFFSET \
  86. (FIELD_OFFSET(FILE_FULL_EA_INFORMATION, \
  87. EaName[WS2IFSL_PROCESS_EA_NAME_LENGTH+1]))
  88. #define GET_WS2IFSL_PROCESS_EA_VALUE(eaInfo) \
  89. ((PWS2IFSL_PROCESS_CTX)( \
  90. (PUCHAR)eaInfo +WS2IFSL_PROCESS_EA_VALUE_OFFSET))
  91. #define WS2IFSL_PROCESS_EA_INFO_LENGTH \
  92. (WS2IFSL_PROCESS_EA_VALUE_OFFSET+WS2IFSL_PROCESS_EA_VALUE_LENGTH)
  93. // All WS2IFSL IOCTL are private and should be out of range
  94. // reserved by Microsoft for public codes
  95. #define WS2IFSL_IOCTL_PROCESS_BASE 0x00000800
  96. #define WS2IFSL_IOCTL_SOCKET_BASE 0x00000810
  97. // Choice of device type implies access priviliges
  98. #define FILE_DEVICE_WS2IFSL FILE_DEVICE_NAMED_PIPE
  99. // Macro that simplifies definition of WS2IFSL control codes
  100. #define IOCTL_WS2IFSL(File,Function,Method) \
  101. CTL_CODE ( \
  102. FILE_DEVICE_WS2IFSL, \
  103. WS2IFSL_IOCTL_##File##_BASE+Function, \
  104. Method, \
  105. FILE_ANY_ACCESS)
  106. /*
  107. * IOCTL: RETRIEVE_DRV_REQ
  108. * File: Process
  109. * Purpose: Retreive request to be executed by the DLL
  110. * Paremeters: InputBuffer - WS2IFSL_RTRV_PARAMS
  111. * InputBufferLength - sizeof (WS2IFSL_RTRV_PARAMS)
  112. * OutputBuffer - buffer for request
  113. * OutputBufferLength - size of the buffer
  114. * Returns:
  115. * STATUS_SUCCESS - driver request copied ok, no more
  116. * requests pending
  117. * STATUS_MORE_ENTRIES - driver request copied ok, another
  118. * one is pending.
  119. * STATUS_CANCELLED - request was cancelled
  120. * STATUS_NOT_IMPLEMENTED - opretion was performed on file
  121. * that is not WS2IFSL process file
  122. * STATUS_INVALID_PARAMETER - one of the parameters is invalid
  123. * STATUS_NOT_IMPLEMENTED - opretion was performed on file
  124. * that is not WS2IFSL process file
  125. */
  126. #define IOCTL_WS2IFSL_RETRIEVE_DRV_REQ IOCTL_WS2IFSL (PROCESS,0,METHOD_NEITHER)
  127. /*
  128. * IOCTL: COMPLETE_DRV_CAN
  129. * File: Process
  130. * Purpose: Completes cancel request executed by the DLL
  131. * Paremeters: InputBuffer - WS2IFSL_CNCL_PARAMS
  132. * InputBufferLength - sizeof (WS2IFSL_CNCL_PARAMS)
  133. * OutputBuffer - NULL
  134. * OutputBufferLength - 0
  135. * Returns:
  136. * STATUS_SUCCESS - driver completed copied ok, no more
  137. * requests pending.
  138. * STATUS_MORE_ENTRIES - driver request completed ok, another
  139. * one is pending.
  140. * STATUS_INVALID_PARAMETER - one of the parameters is invalid
  141. * STATUS_NOT_IMPLEMENTED - opretion was performed on file
  142. * that is not WS2IFSL process file
  143. */
  144. #define IOCTL_WS2IFSL_COMPLETE_DRV_CAN IOCTL_WS2IFSL (PROCESS,1,METHOD_NEITHER)
  145. /*
  146. * IOCTL: COMPLETE_DRV_REQ
  147. * File: Socket
  148. * Purpose: Completes request retrived from driver.
  149. * Paremeters: InputBuffer - WS2IFSL_CMPL_PARAMS
  150. * InputBufferLength - sizeof (WS2IFSL_CMPL_PARAMS)
  151. * OutputBuffer - buffer for request
  152. * OutputBufferLength - size of the buffer
  153. *
  154. * Returns: STATUS_SUCCESS - operation completed OK.
  155. * STATUS_CANCELLED - operation was cancelled already.
  156. * STATUS_NOT_IMPLEMENTED - opretion was performed on file
  157. * that is not WS2IFSL process file
  158. * STATUS_INVALID_PARAMETER - size of input buffer is invalid
  159. */
  160. #define IOCTL_WS2IFSL_COMPLETE_DRV_REQ IOCTL_WS2IFSL (PROCESS,2,METHOD_NEITHER)
  161. /*
  162. * IOCTL: SET_SOCKET_CONTEXT
  163. * File: Socket
  164. * Purpose: Sets socket process context and associates context value
  165. * with the socket (passed as a parameter to the APC routine).
  166. * Paremeters: InputBuffer - PWS2IFSL_SOCKET_CTX, socket context
  167. * parameters
  168. * InputBufferLength - sizeof(WS2IFSL_SOCKET_CTX)
  169. * OutputBuffer - not used (NULL)
  170. * OutputBufferLength - not used (0)
  171. * Returns: STATUS_SUCCESS - socket context established OK
  172. * STATUS_INSUFFICIENT_RESOURCES - not enough resouces to
  173. * perform the operation
  174. * STATUS_INVALID_PARAMETER - size if input buffer ProcessFile
  175. * parameter are invalid
  176. * STATUS_NOT_IMPLEMENTED - opretion was performed on file
  177. * that is not WS2IFSL socket file
  178. */
  179. #define IOCTL_WS2IFSL_SET_SOCKET_CONTEXT IOCTL_WS2IFSL (SOCKET,0,METHOD_NEITHER)
  180. /*
  181. * IOCTL: COMPLETE_PVD_REQ
  182. * File: Socket
  183. * Purpose: Completes asynchronous requests for providers.
  184. * Paremeters: InputBuffer - PIO_STATUS_INFORMATION, status information
  185. * for the request being completed
  186. * InputBufferLength - sizeof(IO_STATUS_INFORMATION)
  187. * OutputBuffer - NULL
  188. * OutputBufferLength - 0
  189. * Returns: Status field of IO_STATUS_INFORMATION structure.
  190. * STATUS_NOT_IMPLEMENTED - opretion was performed on file
  191. * that is not WS2IFSL socket file
  192. * STATUS_INVALID_PARAMETER - size of input buffer is invalid
  193. */
  194. #define IOCTL_WS2IFSL_COMPLETE_PVD_REQ IOCTL_WS2IFSL (SOCKET,1,METHOD_NEITHER)
  195. #endif