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.

275 lines
8.8 KiB

  1. //
  2. // clicnct.h - the Rome/Shuttle Client Connection API
  3. //
  4. // initial version - July 1995 - t-alexwe
  5. //
  6. // This file lives in both the Shuttle and MOS SLM trees. In shuttle it
  7. // belongs in \mos\h\clicnct.h. In MOS it belongs in \mos\include\mos.
  8. //
  9. #ifndef _CLICNCT_H_
  10. #define _CLICNCT_H_
  11. #include <windows.h>
  12. //
  13. // this has the event codes in it
  14. //
  15. #include "moscl.h"
  16. #ifdef __cplusplus
  17. extern "C" {
  18. #endif
  19. #ifndef DllExport
  20. #define DllExport __declspec(dllexport)
  21. #endif // DllExport
  22. //
  23. // Client Connection API error codes
  24. //
  25. // win32 error code - customer bit set, error bits set, facility 0x300
  26. //
  27. #define PROXYERR_BASE 0xE3000000
  28. #define PROXYERR_INVALID_STATE (PROXYERR_BASE+0)
  29. #define PROXYERR_UNSUPPORTED_VER (PROXYERR_BASE+1)
  30. #define PROXYERR_INVALID_PACKET (PROXYERR_BASE+2)
  31. #define PROXYERR_HOSTNAME_TOO_LONG (PROXYERR_BASE+3)
  32. #define PROXYERR_TOO_MANY_SOCKOPTS (PROXYERR_BASE+4)
  33. #define PROXYERR_AUTH_ERROR (PROXYERR_BASE+5)
  34. //
  35. // this is the callback function that will be called with event progress.
  36. // it uses the events above
  37. //
  38. // possible events:
  39. //
  40. typedef void (WINAPI *EVENT_CALLBACK)(DWORD obj, DWORD event, DWORD errcode);
  41. typedef void (WINAPI *ERRORLOG_CALLBACK)(DWORD obj, PSTR psz, DWORD dw);
  42. //
  43. // structure for passing socket options in ProxyConnectOpen(). Each element
  44. // has the same purpose as the similarily named parameter in setsockopt().
  45. //
  46. typedef struct {
  47. int level;
  48. int optname;
  49. const char FAR *optval;
  50. int optlen;
  51. } *PSOCKOPT, SOCKOPT;
  52. // Init and Deinit functions because launching and killing threads in DLLMain
  53. // causes major grief
  54. DllExport void WINAPI ProxyDllStartup(void);
  55. DllExport void WINAPI ProxyDllShutdown(void);
  56. typedef void (WINAPI *LPFNPROXYDLLSTARTUP)(void);
  57. typedef void (WINAPI *LPFNPROXYDLLSHUTDOWN)(void);
  58. //
  59. // Synopsis
  60. // API takes a DialParams string in the form below
  61. // dials up primary/backup phone number as configured in registry
  62. //
  63. // Parameters:
  64. // pszDialParams - <P|B>:<username>:<password>
  65. // phEventHandle - returned: an event handle that is signalled when
  66. // the dialing is complete (or an error has occured).
  67. // lpfnEventCb - fn ptr to post events & errors
  68. // lpfnErrorCb - fn ptr to log (for stats/debugging) errors
  69. // dwLogParam - magic cookie passed into lpfnEventCb, lpfnErrorCb
  70. // pdwDialId - returned: a dialing ID that can be used by
  71. // ProxyDialClose() and ProxyDialGetResult().
  72. //
  73. // Returns:
  74. // Success - ERROR_SUCCESS (0)
  75. // Failure - NT or WinSock error code
  76. //
  77. DllExport DWORD WINAPI ProxyDialOpen(PSTR lpszDialParams, // [in]
  78. EVENT_CALLBACK lpfnEventCb, // [in]
  79. ERRORLOG_CALLBACK lpfnErrLogCb, // [in]
  80. DWORD dwLogParam, // [in]
  81. PHANDLE phEventHandle, // [out]
  82. PDWORD pdwDialId ); // [out]
  83. typedef DWORD (WINAPI *LPFNPROXYDIALOPEN)(PSTR, EVENT_CALLBACK, ERRORLOG_CALLBACK, DWORD, PHANDLE, PDWORD);
  84. //
  85. // Synopsis:
  86. // Closes a dial connection started by ProxyDialOpen().
  87. // Cancels dial if still in progress.
  88. //
  89. // Parameters:
  90. // dwConnectId - the dial ID returned by ProxyDialOpen()
  91. //
  92. // Returns:
  93. // Success - ERROR_SUCCESS(0)
  94. // Failure - NT or WinSock error code
  95. //
  96. // Notes:
  97. // This should always succeed unless passed in invalid parameters.
  98. //
  99. DllExport DWORD WINAPI ProxyDialClose(DWORD dwConnectId); // [in]
  100. typedef DWORD (WINAPI *LPFNPROXYDIALCLOSE)(DWORD);
  101. //
  102. // Synopsis:
  103. // Gets dial completion status a dial started by ProxyDialOpen().
  104. //
  105. // Parameters:
  106. // dwConnectId - the dial ID returned by ProxyDialOpen()
  107. //
  108. // Returns:
  109. // Success - ERROR_SUCCESS(0)
  110. // Failure - NT or WinSock error code
  111. //
  112. DllExport DWORD WINAPI ProxyDialGetResult(DWORD dwConnectId); // [in]
  113. typedef DWORD (WINAPI *LPFNPROXYDIALGETRESULT)(DWORD);
  114. //
  115. // Synopsis:
  116. // Gets dial error-log string in specific format
  117. // applicable only to TCPCONN.DLL. Other proxy DLLs
  118. // should _not_ implement this entry point!!
  119. //
  120. // Parameters:
  121. // dwConnectId - the dial ID returned by ProxyDialOpen()
  122. // pszErrStr - buffer to write result into
  123. // dwLen - length of buffer
  124. //
  125. // Returns:
  126. // Success - ERROR_SUCCESS(0)
  127. // Failure - NT or WinSock error code
  128. //
  129. DllExport DWORD WINAPI ProxyDialGetErrorLogString(DWORD dwConnectId, PSTR pszStr, DWORD dwLen); // [in]
  130. typedef DWORD (WINAPI *LPFNPROXYDIALGETERRORLOGSTRING)(DWORD, PSTR, DWORD);
  131. //=====================================================
  132. //
  133. // Synopsis
  134. // API takes a hostname for MSN and socket options for the socket to
  135. // be created and returns immediatly with an event handle and a
  136. // connection ID. The calling process should wait on the event
  137. // handle for completion. The connection ID is used for CancelConnect()
  138. // and ProxyConnectGetResult().
  139. //
  140. // Parameters:
  141. // pszDNSName0 - the PRIMARY hostname to connect to
  142. // pszDNSName1 - the BACKUP hostname to connect to
  143. // wPort - the TCP/IP port to connect to
  144. // pSockopts - the socket options to use on the socket
  145. // cSockopts - the number of socket options in pSockopts
  146. // lpfnEventCb - fn ptr to post events & errors
  147. // lpfnErrorCb - fn ptr to log (for stats/debugging) errors
  148. // dwLogParam - magic cookie passed into lpfnEventCb, lpfnErrorCb
  149. // phEventHandle - returned: an event handle that is signalled when
  150. // the connection is complete (or an error has occured).
  151. // pdwConnectId - returned: a connection ID that can be used by
  152. // ProxyConnectClose() and ProxyConnectGetResult().
  153. //
  154. // Returns:
  155. // Success - ERROR_SUCCESS (0)
  156. // Failure - NT or WinSock error code
  157. //
  158. DllExport DWORD WINAPI ProxyConnectOpen(PSTR pszDNSName0, // [in]
  159. PSTR pszDNSName1, // [in]
  160. WORD wPort, // [in]
  161. PSOCKOPT pSockopts, // [in]
  162. DWORD cSockopts, // [in]
  163. EVENT_CALLBACK lpfnEventCb, // [in]
  164. ERRORLOG_CALLBACK lpfnErrLogCb, // [in]
  165. DWORD dwLogParam, // [in]
  166. PHANDLE phEventHandle, // [out]
  167. PDWORD pdwConnectId ); // [out]
  168. typedef DWORD (WINAPI *LPFNPROXYCONNECTOPEN)(PSTR, PSTR, WORD, PSOCKOPT, DWORD, EVENT_CALLBACK, ERRORLOG_CALLBACK, DWORD, PHANDLE, PDWORD);
  169. //
  170. // Synopsis:
  171. // Closes a connection opened by ProxyConnectOpen().
  172. // Cancels a connection attempt if in progress.
  173. //
  174. // Parameters:
  175. // dwConnectId - the connection ID returned by ProxyConnectOpen()
  176. //
  177. // Returns:
  178. // Success - ERROR_SUCCESS(0)
  179. // Failure - NT or WinSock error code
  180. //
  181. // Notes:
  182. // This should always succeed unless passed in invalid parameters.
  183. //
  184. DllExport DWORD WINAPI ProxyConnectClose(DWORD dwConnectId ); // [in]
  185. typedef DWORD (WINAPI *LPFNPROXYCONNECTCLOSE)(DWORD);
  186. //
  187. // Synopsis:
  188. // Gets a connected socket handle from a connection started by
  189. // ProxyConnectOpen().
  190. //
  191. // Parameters:
  192. // hEventHandle - the event handle returned by ProxyConnectOpen()
  193. // dwConnectId - the connection ID returned by ProxyConnectOpen()
  194. // phSocket - returned: the socket handle
  195. //
  196. // Returns:
  197. // Success - ERROR_SUCCESS(0)
  198. // Failure - NT or WinSock error code
  199. //
  200. DllExport DWORD WINAPI ProxyConnectGetResult(DWORD dwConnectId, // [in]
  201. PHANDLE phSocket ); // [out]
  202. typedef DWORD (WINAPI *LPFNPROXYCONNECTGETRESULT)(DWORD, PHANDLE);
  203. //
  204. // Synopsis:
  205. // Gets the set of local IP addres in a string in specific format
  206. // applicable only to TCPCONN.DLL. Other proxy DLLs
  207. // should _not_ implement this entry point!!
  208. //
  209. // Parameters:
  210. // dwConnectId - the dial ID returned by ProxyConnectOpen()
  211. //
  212. // Returns:
  213. // Success - string ptr (LocalAlloc'd string)
  214. // Failure - NULL
  215. //
  216. DllExport PSTR WINAPI ProxyConnectGetMyIPAddrs(DWORD dwConnectId); // [in]
  217. typedef PSTR (WINAPI *LPFNPROXYCONNECTGETMYIPADDRS)(DWORD);
  218. typedef struct
  219. {
  220. HINSTANCE hinst;
  221. LPFNPROXYDLLSTARTUP lpfnProxyDllStartup;
  222. LPFNPROXYDLLSHUTDOWN lpfnProxyDllShutdown;
  223. LPFNPROXYDIALOPEN lpfnProxyDialOpen;
  224. LPFNPROXYDIALCLOSE lpfnProxyDialClose;
  225. LPFNPROXYDIALGETRESULT lpfnProxyDialGetResult;
  226. LPFNPROXYCONNECTOPEN lpfnProxyConnectOpen;
  227. LPFNPROXYCONNECTCLOSE lpfnProxyConnectClose;
  228. LPFNPROXYCONNECTGETRESULT lpfnProxyConnectGetResult;
  229. LPFNPROXYCONNECTGETMYIPADDRS lpfnProxyConnectGetMyIPAddrs;
  230. LPFNPROXYDIALGETERRORLOGSTRING lpfnProxyDialGetErrorLogString;
  231. }
  232. PROXYDLLPTRS, *PPROXYDLLPTRS;
  233. #define SZPROXYDLLSTARTUP "ProxyDllStartup"
  234. #define SZPROXYDLLSHUTDOWN "ProxyDllShutdown"
  235. #define SZPROXYDIALOPEN "ProxyDialOpen"
  236. #define SZPROXYDIALCLOSE "ProxyDialClose"
  237. #define SZPROXYDIALGETRESULT "ProxyDialGetResult"
  238. #define SZPROXYCONNECTOPEN "ProxyConnectOpen"
  239. #define SZPROXYCONNECTCLOSE "ProxyConnectClose"
  240. #define SZPROXYCONNECTGETRESULT "ProxyConnectGetResult"
  241. #define SZPROXYCONNECTGETMYIPADDRS "ProxyConnectGetMyIPAddrs"
  242. #define SZPROXYDIALGETERRORLOGSTRING "ProxyDialGetErrorLogString"
  243. #ifdef __cplusplus
  244. }
  245. #endif
  246. #endif