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.

188 lines
4.0 KiB

  1. //=================================================================
  2. //
  3. // Wsock32Api.h
  4. //
  5. // Copyright (c) 1999-2001 Microsoft Corporation, All Rights Reserved
  6. //
  7. //=================================================================
  8. #ifndef _WSOCK32API_H_
  9. #define _WSOCK32API_H_
  10. #include <winsock.h>
  11. #include <tdiinfo.h>
  12. #include <llinfo.h>
  13. #include <tdistat.h>
  14. #include <ipinfo.h>
  15. /******************************************************************************
  16. * #includes to Register this class with the CResourceManager.
  17. *****************************************************************************/
  18. #include "DllWrapperBase.h"
  19. extern const GUID g_guidWsock32Api;
  20. extern const TCHAR g_tstrWsock32[];
  21. /******************************************************************************
  22. * Function pointer typedefs. Add new functions here as required.
  23. *****************************************************************************/
  24. typedef DWORD (CALLBACK *PFN_WSOCK32_WSCONTROL)
  25. (
  26. DWORD,
  27. DWORD,
  28. LPVOID,
  29. LPDWORD,
  30. LPVOID,
  31. LPDWORD
  32. );
  33. typedef INT (APIENTRY *PFN_WSOCK32_ENUMPROTOCOLS)
  34. (
  35. LPINT lpiProtocols,
  36. LPVOID lpProtocolBuffer,
  37. LPDWORD lpdwBufferLength
  38. ) ;
  39. typedef INT (APIENTRY *PFN_WSOCK32_STARTUP)
  40. (
  41. IN WORD wVersionRequired,
  42. OUT LPWSADATA lpWSAData
  43. ) ;
  44. typedef INT (APIENTRY *PFN_WSOCK32_CLEANUP)
  45. (
  46. ) ;
  47. typedef INT (APIENTRY *PFN_WSOCK32_CLOSESOCKET)
  48. (
  49. SOCKET s
  50. ) ;
  51. typedef int ( PASCAL FAR *PFN_WSOCK32_GETSOCKOPT )
  52. (
  53. SOCKET s,
  54. int level,
  55. int optname,
  56. char FAR * optval,
  57. int FAR *optlen
  58. );
  59. typedef int ( PASCAL FAR *PFN_WSOCK32_BIND )
  60. (
  61. SOCKET s,
  62. const struct sockaddr FAR *addr,
  63. int namelen
  64. );
  65. typedef SOCKET ( PASCAL FAR *PFN_WSOCK32_SOCKET )
  66. (
  67. int af,
  68. int type,
  69. int protocol
  70. );
  71. typedef int ( PASCAL FAR *PFN_WSOCK32_WSAGETLASTERROR ) (void);
  72. typedef char * ( PASCAL FAR *PFN_WSOCK32_INET_NTOA )
  73. (
  74. IN struct in_addr in
  75. );
  76. /******************************************************************************
  77. * Wrapper class for Wsock32 load/unload, for registration with CResourceManager.
  78. ******************************************************************************/
  79. class CWsock32Api : public CDllWrapperBase
  80. {
  81. private:
  82. // Member variables (function pointers) pointing to kernel32 functions.
  83. // Add new functions here as required.
  84. PFN_WSOCK32_WSCONTROL m_pfnWsControl;
  85. PFN_WSOCK32_ENUMPROTOCOLS m_pfnWsEnumProtocols;
  86. PFN_WSOCK32_STARTUP m_pfnWsStartup;
  87. PFN_WSOCK32_CLEANUP m_pfnWsCleanup;
  88. PFN_WSOCK32_CLOSESOCKET m_pfnWsCloseSocket;
  89. PFN_WSOCK32_GETSOCKOPT m_pfnWsGetSockopt ;
  90. PFN_WSOCK32_BIND m_pfnWsBind ;
  91. PFN_WSOCK32_SOCKET m_pfnWsSocket ;
  92. PFN_WSOCK32_WSAGETLASTERROR m_pfnWsWSAGetLastError ;
  93. PFN_WSOCK32_INET_NTOA m_pfnWsInet_NtoA ;
  94. public:
  95. // Constructor and destructor:
  96. CWsock32Api(LPCTSTR a_tstrWrappedDllName);
  97. ~CWsock32Api();
  98. // Inherrited initialization function.
  99. virtual bool Init();
  100. // Member functions wrapping Wsock32 functions.
  101. // Add new functions here as required:
  102. bool WsControl
  103. (
  104. DWORD a_dw1,
  105. DWORD a_dw2,
  106. LPVOID a_lpv1,
  107. LPDWORD a_lpdw1,
  108. LPVOID a_lpv2,
  109. LPDWORD a_lpdw2,
  110. DWORD *a_pdwRetval
  111. );
  112. INT WsEnumProtocols (
  113. LPINT lpiProtocols,
  114. LPVOID lpProtocolBuffer,
  115. LPDWORD lpdwBufferLength
  116. );
  117. INT WsWSAStartup (
  118. IN WORD wVersionRequired,
  119. OUT LPWSADATA lpWSAData
  120. ) ;
  121. INT WsWSACleanup () ;
  122. INT Wsclosesocket ( SOCKET s ) ;
  123. int Wsbind (
  124. SOCKET s,
  125. const struct sockaddr FAR *addr,
  126. int namelen
  127. );
  128. int Wsgetsockopt (
  129. SOCKET s,
  130. int level,
  131. int optname,
  132. char FAR * optval,
  133. int FAR *optlen
  134. );
  135. SOCKET Wssocket (
  136. int af,
  137. int type,
  138. int protocol
  139. );
  140. int WsWSAGetLastError(void);
  141. char * Wsinet_ntoa (
  142. struct in_addr in
  143. ) ;
  144. };
  145. #endif