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.

417 lines
6.0 KiB

  1. /*++
  2. Copyright (c) 1995 Microsoft Corporation
  3. Module Name:
  4. iwinsock.hxx
  5. Abstract:
  6. Contains prototypes for indirected sockets functions
  7. Author:
  8. Richard L Firth (rfirth) 12-Apr-1995
  9. Revision History:
  10. 12-Apr-1995 rfirth
  11. Created
  12. 08-May-1996 arthurbi
  13. Moved into SOCKET_FUNC_ARRAY in order to supports Socks.
  14. --*/
  15. #if !defined(_IWINSOCK_)
  16. #define _WINSOCK_
  17. #if defined(__cplusplus)
  18. extern "C" {
  19. #endif
  20. //
  21. // includes
  22. //
  23. #include <winsock2.h>
  24. #include <mswsock.h>
  25. #include <ws2tcpip.h>
  26. #include <basetyps.h>
  27. #include <nspapi.h>
  28. #include <svcguid.h>
  29. //
  30. // prototypes
  31. //
  32. VOID
  33. IwinsockInitialize(
  34. VOID
  35. );
  36. VOID
  37. IwinsockTerminate(
  38. VOID
  39. );
  40. DWORD
  41. LoadWinsock(
  42. VOID
  43. );
  44. VOID
  45. UnloadWinsock(
  46. VOID
  47. );
  48. DWORD
  49. SafeCloseSocket(
  50. IN SOCKET Socket
  51. );
  52. //
  53. // sockets functions
  54. //
  55. extern
  56. SOCKET
  57. (PASCAL FAR * _I_accept)(
  58. SOCKET s,
  59. struct sockaddr FAR *addr,
  60. int FAR *addrlen
  61. );
  62. extern
  63. int
  64. (PASCAL FAR * _I_bind)(
  65. SOCKET s,
  66. const struct sockaddr FAR *addr,
  67. int namelen
  68. );
  69. extern
  70. int
  71. (PASCAL FAR * _I_closesocket)(
  72. SOCKET s
  73. );
  74. extern
  75. int
  76. (PASCAL FAR * _I_connect)(
  77. SOCKET s,
  78. const struct sockaddr FAR *name,
  79. int namelen
  80. );
  81. extern
  82. int
  83. (PASCAL FAR * _I_gethostname)(
  84. char FAR * name,
  85. int namelen
  86. );
  87. extern
  88. LPHOSTENT
  89. (PASCAL FAR * _I_gethostbyaddr)(
  90. const char FAR * addr,
  91. int len,
  92. int type
  93. );
  94. extern
  95. LPHOSTENT
  96. (PASCAL FAR * _I_gethostbyname)(
  97. const char FAR * lpHostName
  98. );
  99. extern
  100. int
  101. (PASCAL FAR * _I_getsockname)(
  102. SOCKET s,
  103. struct sockaddr FAR *name,
  104. int FAR * namelen
  105. );
  106. extern
  107. int
  108. (PASCAL FAR * _I_getpeername)(
  109. SOCKET s,
  110. struct sockaddr FAR *name,
  111. int FAR * namelen
  112. );
  113. extern
  114. int
  115. (PASCAL FAR * _I_getsockopt)(
  116. SOCKET s,
  117. int level,
  118. int optname,
  119. char FAR * optval,
  120. int FAR *optlen
  121. );
  122. extern
  123. u_long
  124. (PASCAL FAR * _I_htonl)(
  125. u_long hostlong
  126. );
  127. extern
  128. u_short
  129. (PASCAL FAR * _I_htons)(
  130. u_short hostshort
  131. );
  132. extern
  133. unsigned long
  134. (PASCAL FAR * _I_inet_addr)(
  135. const char FAR * cp
  136. );
  137. extern
  138. char FAR *
  139. (PASCAL FAR * _I_inet_ntoa)(
  140. struct in_addr in
  141. );
  142. extern
  143. int
  144. (PASCAL FAR * _I_ioctlsocket)(
  145. SOCKET s,
  146. long cmd,
  147. u_long FAR *argp
  148. );
  149. extern
  150. int
  151. (PASCAL FAR * _I_listen)(
  152. SOCKET s,
  153. int backlog
  154. );
  155. extern
  156. u_short
  157. (PASCAL FAR * _I_ntohs)(
  158. u_short netshort
  159. );
  160. extern
  161. int
  162. (PASCAL FAR * _I_recv)(
  163. SOCKET s,
  164. char FAR * buf,
  165. int len,
  166. int flags
  167. );
  168. extern
  169. int
  170. (PASCAL FAR * _I_recvfrom)(
  171. SOCKET s,
  172. char FAR * buf,
  173. int len,
  174. int flags,
  175. struct sockaddr FAR *from,
  176. int FAR * fromlen
  177. );
  178. extern
  179. int
  180. (PASCAL FAR * _I_select)(
  181. int nfds,
  182. fd_set FAR *readfds,
  183. fd_set FAR *writefds,
  184. fd_set FAR *exceptfds,
  185. const struct timeval FAR *timeout
  186. );
  187. extern
  188. int
  189. (PASCAL FAR * _I_send)(
  190. SOCKET s,
  191. const char FAR * buf,
  192. int len,
  193. int flags
  194. );
  195. extern
  196. int
  197. (PASCAL FAR * _I_sendto)(
  198. SOCKET s,
  199. const char FAR * buf,
  200. int len,
  201. int flags,
  202. const struct sockaddr FAR *to,
  203. int tolen
  204. );
  205. extern
  206. int
  207. (PASCAL FAR * _I_setsockopt)(
  208. SOCKET s,
  209. int level,
  210. int optname,
  211. const char FAR * optval,
  212. int optlen
  213. );
  214. extern
  215. int
  216. (PASCAL FAR * _I_shutdown)(
  217. SOCKET s,
  218. int how
  219. );
  220. extern
  221. SOCKET
  222. (PASCAL FAR * _I_socket)(
  223. int af,
  224. int type,
  225. int protocol
  226. );
  227. //
  228. // WSA functions
  229. //
  230. extern
  231. int
  232. (PASCAL FAR * _I_WSAStartup)(
  233. WORD wVersionRequired,
  234. LPWSADATA lpWSAData
  235. );
  236. extern
  237. int
  238. (PASCAL FAR * _I_WSACleanup)(
  239. void
  240. );
  241. extern
  242. int
  243. (PASCAL FAR * _I_WSAGetLastError)(
  244. void
  245. );
  246. extern
  247. void
  248. (PASCAL FAR * _I_WSASetLastError)(
  249. int iError
  250. );
  251. extern
  252. int
  253. (PASCAL FAR * _I___WSAFDIsSet)(
  254. SOCKET,
  255. fd_set FAR *
  256. );
  257. //
  258. // address family independent APIs
  259. //
  260. extern
  261. int
  262. (PASCAL FAR * _I_getaddrinfo)(
  263. IN const char FAR * nodename,
  264. IN const char FAR * servname,
  265. IN const struct addrinfo FAR * hints,
  266. OUT struct addrinfo FAR * FAR * res
  267. );
  268. extern
  269. void
  270. (PASCAL FAR * _I_freeaddrinfo)(
  271. IN struct addrinfo *ai
  272. );
  273. extern
  274. int
  275. (PASCAL FAR * _I_getnameinfo)(
  276. IN const struct sockaddr FAR * sa,
  277. IN socklen_t salen,
  278. OUT char FAR * host,
  279. IN size_t hostlen,
  280. OUT char FAR * serv,
  281. IN size_t servlen,
  282. IN int flags
  283. );
  284. //
  285. // winsock2 name resolution API.
  286. //
  287. extern
  288. int
  289. (PASCAL FAR * _I_WSALookupServiceBeginW)(
  290. IN LPWSAQUERYSETW lpqsRestrictions,
  291. IN DWORD dwControlFlags,
  292. OUT LPHANDLE lphLookup
  293. );
  294. extern
  295. int
  296. (PASCAL FAR * _I_WSALookupServiceNextW)(
  297. IN HANDLE hLookup,
  298. IN DWORD dwControlFlags,
  299. IN OUT LPDWORD lpdwBufferLength,
  300. OUT LPWSAQUERYSETW lpqsResults
  301. );
  302. extern
  303. int
  304. (PASCAL FAR * _I_WSALookupServiceEnd)(
  305. IN HANDLE hLookup
  306. );
  307. extern
  308. int
  309. (PASCAL FAR * _I_WSANSPIoctl)(
  310. IN HANDLE hLookup,
  311. IN DWORD dwControlCode,
  312. IN LPVOID lpvInBuffer,
  313. IN DWORD cbInBuffer,
  314. OUT LPVOID lpvOutBuffer,
  315. IN DWORD cbOutBuffer,
  316. OUT LPDWORD lpcbBytesReturned,
  317. IN LPWSACOMPLETION lpCompletion
  318. );
  319. //
  320. // macros
  321. //
  322. #ifndef unix
  323. #if defined(FD_ISSET)
  324. #undef FD_ISSET
  325. #endif
  326. #define FD_ISSET(fd, set) _I___WSAFDIsSet((SOCKET)(fd), (fd_set FAR *)(set))
  327. #endif /* unix */
  328. #if INET_DEBUG
  329. VOID
  330. IWinsockCheckSockets(
  331. VOID
  332. );
  333. #define CHECK_SOCKETS() IWinsockCheckSockets()
  334. #else
  335. #define CHECK_SOCKETS() /* NOTHING */
  336. #endif
  337. #if defined(__cplusplus)
  338. }
  339. #endif
  340. #endif // _IWINSOCK_