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.

205 lines
4.1 KiB

  1. /*++
  2. Copyright (c) 1998, Microsoft Corporation
  3. Module Name:
  4. socket.h
  5. Abstract:
  6. This module contains declarations for socket-management.
  7. The routines declared here operate asynchronously on sockets
  8. associated with an I/O completion port. They are also integrated
  9. with the component-reference object, which may optionally be used
  10. by callers to control the number of outstanding entries into a component's
  11. address-space. (See 'COMPREF.H'.)
  12. Author:
  13. Abolade Gbadegesin (aboladeg) 2-Mar-1998
  14. Revision History:
  15. Abolade Gbadegesin (aboladeg) 23-May-1999
  16. Added support for stream sockets.
  17. Jonathan Burstein (jonburs) 12-April-2001
  18. Added support for raw datagram sockets.
  19. --*/
  20. #ifndef _NATHLP_SOCKET_H_
  21. #define _NATHLP_SOCKET_H_
  22. #define INET_NTOA(x) inet_ntoa(*(struct in_addr*)&(x))
  23. ULONG
  24. NhAcceptStreamSocket(
  25. PCOMPONENT_REFERENCE Component,
  26. SOCKET ListeningSocket,
  27. SOCKET AcceptedSocket OPTIONAL,
  28. PNH_BUFFER Bufferp OPTIONAL,
  29. PNH_COMPLETION_ROUTINE AcceptCompletionRoutine,
  30. PVOID Context,
  31. PVOID Context2
  32. );
  33. ULONG
  34. NhConnectStreamSocket(
  35. PCOMPONENT_REFERENCE Component,
  36. SOCKET ConnectingSocket,
  37. ULONG Address,
  38. USHORT Port,
  39. PNH_BUFFER Bufferp OPTIONAL,
  40. PNH_COMPLETION_ROUTINE ConnectCompletionRoutine,
  41. PNH_COMPLETION_ROUTINE CloseNotificationRoutine OPTIONAL,
  42. PVOID Context,
  43. PVOID Context2
  44. );
  45. ULONG
  46. NhCreateDatagramSocket(
  47. ULONG Address,
  48. USHORT Port,
  49. OUT SOCKET* Socketp
  50. );
  51. ULONG
  52. NhCreateRawDatagramSocket(
  53. OUT SOCKET* Socketp
  54. );
  55. ULONG
  56. NhCreateStreamSocket(
  57. ULONG Address OPTIONAL, // may be INADDR_NONE
  58. USHORT Port OPTIONAL,
  59. OUT SOCKET* Socketp
  60. );
  61. #define NhDeleteDatagramSocket(s) NhDeleteSocket(s)
  62. #define NhDeleteStreamSocket(s) NhDeleteSocket(s)
  63. VOID
  64. NhDeleteSocket(
  65. SOCKET Socket
  66. );
  67. //
  68. // BOOLEAN
  69. // NhIsFatalSocketError(
  70. // ULONG Error
  71. // );
  72. //
  73. // Determines whether a request may be reissued on a socket,
  74. // given the error-code from the previous issuance of the request.
  75. // This macro is arranged to branch on the most common error-codes first.
  76. //
  77. #define \
  78. NhIsFatalSocketError( \
  79. _Error \
  80. ) \
  81. ((_Error) != ERROR_OPERATION_ABORTED && \
  82. ((_Error) == WSAEDISCON || \
  83. (_Error) == WSAECONNRESET || \
  84. (_Error) == WSAETIMEDOUT || \
  85. (_Error) == WSAENETDOWN || \
  86. (_Error) == WSAENOTSOCK || \
  87. (_Error) == WSAESHUTDOWN || \
  88. (_Error) == WSAECONNABORTED))
  89. ULONG
  90. NhNotifyOnCloseStreamSocket(
  91. PCOMPONENT_REFERENCE Component,
  92. SOCKET Socket,
  93. PNH_BUFFER Bufferp OPTIONAL,
  94. PNH_COMPLETION_ROUTINE CloseNotificationRoutine,
  95. PVOID Context,
  96. PVOID Context2
  97. );
  98. VOID
  99. NhQueryAcceptEndpoints(
  100. PUCHAR AcceptBuffer,
  101. PULONG LocalAddress OPTIONAL,
  102. PUSHORT LocalPort OPTIONAL,
  103. PULONG RemoteAddress OPTIONAL,
  104. PUSHORT RemotePort OPTIONAL
  105. );
  106. ULONG
  107. NhQueryAddressSocket(
  108. SOCKET Socket
  109. );
  110. ULONG
  111. NhQueryLocalEndpointSocket(
  112. SOCKET Socket,
  113. PULONG Address OPTIONAL,
  114. PUSHORT Port OPTIONAL
  115. );
  116. USHORT
  117. NhQueryPortSocket(
  118. SOCKET Socket
  119. );
  120. ULONG
  121. NhQueryRemoteEndpointSocket(
  122. SOCKET Socket,
  123. PULONG Address OPTIONAL,
  124. PUSHORT Port OPTIONAL
  125. );
  126. ULONG
  127. NhReadDatagramSocket(
  128. PCOMPONENT_REFERENCE Component,
  129. SOCKET Socket,
  130. PNH_BUFFER Bufferp OPTIONAL,
  131. PNH_COMPLETION_ROUTINE CompletionRoutine,
  132. PVOID Context,
  133. PVOID Context2
  134. );
  135. ULONG
  136. NhReadStreamSocket(
  137. PCOMPONENT_REFERENCE Component,
  138. SOCKET Socket,
  139. PNH_BUFFER Bufferp OPTIONAL,
  140. ULONG Length,
  141. ULONG Offset,
  142. PNH_COMPLETION_ROUTINE CompletionRoutine,
  143. PVOID Context,
  144. PVOID Context2
  145. );
  146. ULONG
  147. NhWriteDatagramSocket(
  148. PCOMPONENT_REFERENCE Component,
  149. SOCKET Socket,
  150. ULONG Address,
  151. USHORT Port,
  152. PNH_BUFFER Bufferp,
  153. ULONG Length,
  154. PNH_COMPLETION_ROUTINE CompletionRoutine,
  155. PVOID Context,
  156. PVOID Context2
  157. );
  158. ULONG
  159. NhWriteStreamSocket(
  160. PCOMPONENT_REFERENCE Component,
  161. SOCKET Socket,
  162. PNH_BUFFER Bufferp,
  163. ULONG Length,
  164. ULONG Offset,
  165. PNH_COMPLETION_ROUTINE CompletionRoutine,
  166. PVOID Context,
  167. PVOID Context2
  168. );
  169. #endif // _NATHLP_SOCKET_H_