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.

279 lines
5.5 KiB

  1. /*++
  2. Copyright (C) Microsoft Corporation, 1996 - 1999
  3. Module Name:
  4. wstrans.hxx
  5. Abstract:
  6. Common definitions shared between modules supporting
  7. protocols based on winsock.
  8. Author:
  9. Mario Goertzel [MarioGo]
  10. Revision History:
  11. MarioGo 3/28/1996 Bits 'n pieces
  12. --*/
  13. #ifndef __WSTRANS_HXX
  14. #define __WSTRANS_HXX
  15. const UINT MILLISECONDS_BEFORE_PEEK = DEBUG_MIN(1,10000);
  16. struct WS_TRANS_INFO
  17. {
  18. SHORT AddressFamily;
  19. SHORT SocketType;
  20. SHORT Protocol;
  21. SHORT SockAddrSize;
  22. BOOLEAN fNetbios;
  23. BOOLEAN fCheckShutdowns;
  24. BOOLEAN fSetNoDelay;
  25. BOOLEAN fSetKeepAlive;
  26. BOOLEAN fSetRecvBuffer;
  27. BOOLEAN fSetSendBuffer;
  28. };
  29. extern BOOL fWinsockLoaded;
  30. // Indexed by PROTOCOL_ID.
  31. extern const WS_TRANS_INFO WsTransportTable[];
  32. extern const DWORD cWsTransportTable;
  33. // WS_ function prototypes.
  34. extern RPC_STATUS RPC_ENTRY
  35. WS_Close(
  36. IN RPC_TRANSPORT_CONNECTION,
  37. IN BOOL
  38. );
  39. extern RPC_STATUS RPC_ENTRY
  40. WS_SyncSend(
  41. IN RPC_TRANSPORT_CONNECTION Connection,
  42. IN UINT BufferLength,
  43. IN BUFFER Buffer,
  44. IN BOOL fDisableShutdownCheck,
  45. IN BOOL fDisableCancelCheck,
  46. ULONG Timeout
  47. );
  48. extern RPC_STATUS RPC_ENTRY
  49. WS_SyncRecv(
  50. IN RPC_TRANSPORT_CONNECTION Connection,
  51. OUT BUFFER *pBuffer,
  52. IN OUT PUINT pBufferLength,
  53. IN DWORD dwTimeout
  54. );
  55. extern RPC_STATUS RPC_ENTRY
  56. WS_SyncRecv_Avrf(
  57. IN RPC_TRANSPORT_CONNECTION Connection,
  58. OUT BUFFER *pBuffer,
  59. IN OUT PUINT pBufferLength,
  60. IN DWORD dwTimeout
  61. );
  62. extern VOID
  63. WS_SubmitAccept(
  64. IN BASE_ADDRESS *
  65. );
  66. extern RPC_STATUS
  67. WS_NewConnection(
  68. IN PADDRESS,
  69. OUT PCONNECTION *
  70. );
  71. extern BOOL
  72. WS_ProtectListeningSocket(
  73. IN SOCKET sock,
  74. IN BOOL newValue
  75. );
  76. extern BOOL IsUserModeSocket(SOCKET s, RPC_STATUS *pStatus);
  77. RPC_STATUS
  78. HttpSendIdentifyResponse(
  79. IN SOCKET Socket
  80. );
  81. RPC_STATUS
  82. WS_Bind(IN SOCKET sock,
  83. IN OUT WS_SOCKADDR *pListenAddr,
  84. IN BOOL IpProtocol,
  85. IN DWORD EndpointFlags);
  86. class TCPResolverHint
  87. {
  88. public:
  89. void
  90. GetResolverHint (
  91. OUT BOOL *fIPv4Hint,
  92. OUT WS_SOCKADDR *sa
  93. );
  94. void
  95. SetResolverHint (
  96. IN BOOL fIPv4Hint,
  97. IN WS_SOCKADDR *sa
  98. );
  99. union
  100. {
  101. in6_addr IPv6Hint;
  102. DWORD IPv4Hint;
  103. } u;
  104. BOOL fIPv4HintValid;
  105. };
  106. RPC_STATUS
  107. TCPOrHTTP_Open(
  108. IN WS_CONNECTION *Connection,
  109. IN RPC_CHAR * NetworkAddress,
  110. IN USHORT Endpoint,
  111. IN UINT ConnTimeout,
  112. IN UINT SendBufferSize,
  113. IN UINT RecvBufferSize,
  114. IN OUT TCPResolverHint *ResolverHint,
  115. IN BOOL fHintInitialized,
  116. IN ULONG CallTimeout,
  117. IN BOOL fHTTP2Open,
  118. IN I_RpcProxyIsValidMachineFn IsValidMachineFn OPTIONAL
  119. );
  120. NETWORK_ADDRESS_VECTOR *
  121. WS_GetNetworkAddressVector (
  122. IN RPC_TRANSPORT_ADDRESS ThisAddress
  123. );
  124. RPC_STATUS
  125. WS_Initialize (
  126. IN RPC_TRANSPORT_CONNECTION ThisConnection,
  127. IN RPC_CHAR *NetworkAddress,
  128. IN RPC_CHAR *NetworkOptions,
  129. IN BOOL fAsync
  130. );
  131. RPC_STATUS
  132. WS_Open(
  133. IN PWS_CCONNECTION p,
  134. IN WS_SOCKADDR *psa,
  135. IN UINT ConnTimeout,
  136. IN UINT SendBufferSize,
  137. IN UINT RecvBufferSize,
  138. IN ULONG CallTimeout,
  139. IN BOOL fHTTP2Open
  140. );
  141. RPC_STATUS
  142. TCP_ServerListenEx(
  143. IN RPC_TRANSPORT_ADDRESS ThisAddress,
  144. IN RPC_CHAR *NetworkAddress,
  145. IN OUT RPC_CHAR * *pEndpoint,
  146. IN UINT PendingQueueSize,
  147. IN PSECURITY_DESCRIPTOR SecurityDescriptor,
  148. IN ULONG EndpointFlags,
  149. IN ULONG NICFlags,
  150. IN BOOL fHttp
  151. );
  152. RPC_STATUS
  153. RPC_ENTRY
  154. WS_TurnOnOffKeepAlives (
  155. IN RPC_TRANSPORT_CONNECTION ThisConnection,
  156. IN BOOL TurnOn,
  157. IN BOOL bProtectIO,
  158. IN KEEPALIVE_TIMEOUT_UNITS Units,
  159. IN OUT KEEPALIVE_TIMEOUT KATime,
  160. IN ULONG KAInterval = 5000 OPTIONAL
  161. );
  162. void
  163. RPC_ENTRY
  164. WS_ServerAbortListen(
  165. IN RPC_TRANSPORT_ADDRESS Address
  166. );
  167. RPC_STATUS
  168. WS_ConvertClientAddress (
  169. IN const SOCKADDR *ClientAddress,
  170. IN ULONG ClientAddressType,
  171. OUT RPC_CHAR **pNetworkAddress
  172. );
  173. RPC_STATUS
  174. RPC_ENTRY
  175. TCP_QueryClientAddress (
  176. IN RPC_TRANSPORT_CONNECTION ThisConnection,
  177. OUT RPC_CHAR **pNetworkAddress
  178. );
  179. RPC_STATUS
  180. RPC_ENTRY
  181. TCP_QueryLocalAddress (
  182. IN RPC_TRANSPORT_CONNECTION ThisConnection,
  183. IN OUT void *Buffer,
  184. IN OUT unsigned long *BufferSize,
  185. OUT unsigned long *AddressFormat
  186. );
  187. RPC_STATUS
  188. RPC_ENTRY
  189. TCP_QueryClientId(
  190. IN RPC_TRANSPORT_CONNECTION ThisConnection,
  191. OUT RPC_CLIENT_PROCESS_IDENTIFIER *ClientProcess
  192. );
  193. RPC_STATUS
  194. RPC_ENTRY
  195. TCP_QueryClientIpAddress (
  196. IN RPC_TRANSPORT_CONNECTION ThisConnection,
  197. IN OUT RPC_CLIENT_IP_ADDRESS *ClientIpAddress
  198. );
  199. RPC_STATUS
  200. RPC_ENTRY
  201. HTTP_Abort (
  202. IN RPC_TRANSPORT_CONNECTION Connection
  203. );
  204. const DWORD cTcpTimeoutFactor = 60 * 1000; // Default is TimeoutFactor * 6
  205. inline ULONG
  206. ConvertRuntimeTimeoutToWSTimeout (
  207. ULONG Timeout
  208. )
  209. /*++
  210. Routine Description:
  211. Converts a timeout from the runtime time scale (RPC_C_BINDING_MIN_TIMEOUT
  212. to RPC_C_BINDING_MAX_TIMEOUT) to transport scale timeout (milliseconds)
  213. Arguments:
  214. Timeout - timeout in runtime scale
  215. Return Value:
  216. Timeout in transport scale. There is no failure
  217. --*/
  218. {
  219. ASSERT(((long)Timeout >= RPC_C_BINDING_MIN_TIMEOUT)
  220. && (Timeout <= RPC_C_BINDING_MAX_TIMEOUT));
  221. return cTcpTimeoutFactor * (Timeout + 1);
  222. }
  223. #endif // __WSTRANS_HXX