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.

266 lines
5.0 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. struct FIREWALL_INFO {
  30. DWORD NumAddresses;
  31. DWORD Addresses[1];
  32. };
  33. extern BOOL fWinsockLoaded;
  34. extern FIREWALL_INFO *pFirewallTable;
  35. // Indexed by PROTOCOL_ID.
  36. extern const WS_TRANS_INFO WsTransportTable[];
  37. extern const DWORD cWsTransportTable;
  38. // WS_ function prototypes.
  39. extern RPC_STATUS RPC_ENTRY
  40. WS_Close(
  41. IN RPC_TRANSPORT_CONNECTION,
  42. IN BOOL
  43. );
  44. extern RPC_STATUS RPC_ENTRY
  45. WS_SyncSend(
  46. IN RPC_TRANSPORT_CONNECTION Connection,
  47. IN UINT BufferLength,
  48. IN BUFFER Buffer,
  49. IN BOOL fDisableShutdownCheck,
  50. IN BOOL fDisableCancelCheck,
  51. ULONG Timeout
  52. );
  53. extern RPC_STATUS RPC_ENTRY
  54. WS_SyncRecv(
  55. IN RPC_TRANSPORT_CONNECTION Connection,
  56. OUT BUFFER *pBuffer,
  57. IN OUT PUINT pBufferLength,
  58. IN DWORD dwTimeout
  59. );
  60. extern VOID
  61. WS_SubmitAccept(
  62. IN BASE_ADDRESS *
  63. );
  64. extern RPC_STATUS
  65. WS_NewConnection(
  66. IN PADDRESS,
  67. OUT PCONNECTION *
  68. );
  69. extern BOOL
  70. WS_ProtectListeningSocket(
  71. IN SOCKET sock,
  72. IN BOOL newValue
  73. );
  74. extern BOOL IsUserModeSocket(SOCKET s, RPC_STATUS *pStatus);
  75. RPC_STATUS
  76. HttpSendIdentifyResponse(
  77. IN SOCKET Socket
  78. );
  79. RPC_STATUS
  80. WS_Bind(IN SOCKET sock,
  81. IN OUT WS_SOCKADDR *pListenAddr,
  82. IN BOOL IpProtocol,
  83. IN DWORD EndpointFlags);
  84. class TCPResolverHint
  85. {
  86. public:
  87. void
  88. GetResolverHint (
  89. OUT BOOL *fIPv4Hint,
  90. OUT WS_SOCKADDR *sa
  91. );
  92. void
  93. SetResolverHint (
  94. IN BOOL fIPv4Hint,
  95. IN WS_SOCKADDR *sa
  96. );
  97. union
  98. {
  99. in6_addr IPv6Hint;
  100. DWORD IPv4Hint;
  101. } u;
  102. BOOL fIPv4HintValid;
  103. };
  104. RPC_STATUS
  105. TCPOrHTTP_Open(
  106. IN WS_CONNECTION *Connection,
  107. IN RPC_CHAR * NetworkAddress,
  108. IN USHORT Endpoint,
  109. IN UINT ConnTimeout,
  110. IN UINT SendBufferSize,
  111. IN UINT RecvBufferSize,
  112. IN OUT TCPResolverHint *ResolverHint,
  113. IN BOOL fHintInitialized,
  114. IN ULONG CallTimeout,
  115. IN BOOL fHTTP2Open,
  116. IN I_RpcProxyIsValidMachineFn IsValidMachineFn OPTIONAL
  117. );
  118. RPC_STATUS
  119. WS_Initialize (
  120. IN RPC_TRANSPORT_CONNECTION ThisConnection,
  121. IN RPC_CHAR *NetworkAddress,
  122. IN RPC_CHAR *NetworkOptions,
  123. IN BOOL fAsync
  124. );
  125. RPC_STATUS
  126. WS_Open(
  127. IN PWS_CCONNECTION p,
  128. IN WS_SOCKADDR *psa,
  129. IN UINT ConnTimeout,
  130. IN UINT SendBufferSize,
  131. IN UINT RecvBufferSize,
  132. IN ULONG CallTimeout,
  133. IN BOOL fHTTP2Open
  134. );
  135. RPC_STATUS
  136. TCP_ServerListenEx(
  137. IN RPC_TRANSPORT_ADDRESS ThisAddress,
  138. IN RPC_CHAR *NetworkAddress,
  139. IN OUT RPC_CHAR * *pEndpoint,
  140. IN UINT PendingQueueSize,
  141. IN PSECURITY_DESCRIPTOR SecurityDescriptor,
  142. IN ULONG EndpointFlags,
  143. IN ULONG NICFlags,
  144. IN BOOL fHttp,
  145. OUT NETWORK_ADDRESS_VECTOR **ppAddressVector
  146. );
  147. RPC_STATUS
  148. RPC_ENTRY
  149. WS_TurnOnOffKeepAlives (
  150. IN RPC_TRANSPORT_CONNECTION ThisConnection,
  151. IN BOOL TurnOn,
  152. IN BOOL bProtectIO,
  153. IN KEEPALIVE_TIMEOUT_UNITS Units,
  154. IN OUT KEEPALIVE_TIMEOUT KATime,
  155. IN ULONG KAInterval = 5000 OPTIONAL
  156. );
  157. void
  158. RPC_ENTRY
  159. WS_ServerAbortListen(
  160. IN RPC_TRANSPORT_ADDRESS Address
  161. );
  162. RPC_STATUS
  163. WS_ConvertClientAddress (
  164. IN const SOCKADDR *ClientAddress,
  165. IN ULONG ClientAddressType,
  166. OUT RPC_CHAR **pNetworkAddress
  167. );
  168. RPC_STATUS
  169. RPC_ENTRY
  170. TCP_QueryClientAddress (
  171. IN RPC_TRANSPORT_CONNECTION ThisConnection,
  172. OUT RPC_CHAR **pNetworkAddress
  173. );
  174. RPC_STATUS
  175. RPC_ENTRY
  176. TCP_QueryLocalAddress (
  177. IN RPC_TRANSPORT_CONNECTION ThisConnection,
  178. IN OUT void *Buffer,
  179. IN OUT unsigned long *BufferSize,
  180. OUT unsigned long *AddressFormat
  181. );
  182. RPC_STATUS
  183. RPC_ENTRY
  184. TCP_QueryClientId(
  185. IN RPC_TRANSPORT_CONNECTION ThisConnection,
  186. OUT RPC_CLIENT_PROCESS_IDENTIFIER *ClientProcess
  187. );
  188. RPC_STATUS
  189. RPC_ENTRY
  190. HTTP_Abort (
  191. IN RPC_TRANSPORT_CONNECTION Connection
  192. );
  193. const DWORD cTcpTimeoutFactor = 60 * 1000; // Default is TimeoutFactor * 6
  194. inline ULONG
  195. ConvertRuntimeTimeoutToWSTimeout (
  196. ULONG Timeout
  197. )
  198. /*++
  199. Routine Description:
  200. Converts a timeout from the runtime time scale (RPC_C_BINDING_MIN_TIMEOUT
  201. to RPC_C_BINDING_MAX_TIMEOUT) to transport scale timeout (milliseconds)
  202. Arguments:
  203. Timeout - timeout in runtime scale
  204. Return Value:
  205. Timeout in transport scale. There is no failure
  206. --*/
  207. {
  208. ASSERT(((long)Timeout >= RPC_C_BINDING_MIN_TIMEOUT)
  209. && (Timeout <= RPC_C_BINDING_MAX_TIMEOUT));
  210. return cTcpTimeoutFactor * (Timeout + 1);
  211. }
  212. #endif // __WSTRANS_HXX