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.

387 lines
12 KiB

  1. //+-------------------------------------------------------------------------
  2. //
  3. // Microsoft Windows
  4. //
  5. // Copyright (C) Microsoft Corporation, 1997 - 1999
  6. //
  7. // File: rtrutilp.h
  8. //
  9. //--------------------------------------------------------------------------
  10. // Private RtrUtil header file.
  11. // This is for everything that shouldn't be exported.
  12. #ifndef _RTRUTILP_H_
  13. #define _RTRUTILP_H_
  14. #ifndef _DIALOG_H_
  15. #include "dialog.h"
  16. #endif
  17. #ifndef _RTRUTIL_H
  18. #include "rtrutil.h"
  19. #endif
  20. #include "svcctrl.h"
  21. #ifndef _PORTS_H_
  22. #include "ports.h"
  23. #endif
  24. CString GetLocalMachineName();
  25. //----------------------------------------------------------------------------
  26. // Class: CInterfaceConnectDialog
  27. //
  28. // Controls the 'Interface Connection' dialog, which shows elapsed time
  29. // for interface-connection as well as connection status.
  30. //----------------------------------------------------------------------------
  31. class CInterfaceConnectDialog : public CDialog
  32. {
  33. public:
  34. CInterfaceConnectDialog(
  35. HANDLE hServer,
  36. HANDLE hInterface,
  37. LPCTSTR pszInterface,
  38. CWnd* pParent = NULL );
  39. //{{AFX_VIRTUAL(CInterfaceConnectDialog)
  40. protected:
  41. virtual VOID DoDataExchange(CDataExchange* pDX);
  42. //}}AFX_VIRTUAL
  43. protected:
  44. MPR_SERVER_HANDLE m_hServer;
  45. HANDLE m_hInterface;
  46. CString m_sInterface;
  47. UINT m_nIDEvent;
  48. DWORD m_dwConnectionState;
  49. DWORD m_dwTimeElapsed;
  50. //{{AFX_MSG(CInterfaceConnectDialog)
  51. virtual BOOL OnInitDialog( );
  52. virtual VOID OnCancel( );
  53. virtual VOID OnTimer(UINT nIDEvent);
  54. //}}AFX_MSG
  55. DECLARE_MESSAGE_MAP()
  56. };
  57. /*---------------------------------------------------------------------------
  58. CIfCredentials
  59. The credentials dialog.
  60. ---------------------------------------------------------------------------*/
  61. class CIfCredentials : public CBaseDialog
  62. {
  63. public:
  64. CIfCredentials(
  65. LPCTSTR pszMachine,
  66. LPCTSTR pszInterface,
  67. BOOL bNewInterface = FALSE,
  68. CWnd* pParent = NULL
  69. ) : CBaseDialog(IDD_IF_CREDENTIALS, pParent),
  70. m_sMachine(pszMachine ? pszMachine : TEXT("")),
  71. m_sInterface(pszInterface ? pszInterface : TEXT("")),
  72. m_bNewIf( bNewInterface )
  73. { /*SetHelpMap(m_dwHelpMap);*/ }
  74. protected:
  75. static DWORD m_dwHelpMap[];
  76. CString m_sMachine;
  77. CString m_sInterface;
  78. BOOL m_bNewIf;
  79. virtual BOOL
  80. OnInitDialog( );
  81. virtual VOID
  82. OnOK( );
  83. DECLARE_MESSAGE_MAP()
  84. };
  85. /*!--------------------------------------------------------------------------
  86. ConnectAsAdmin
  87. Connect to remote as administrator with user-supplied credentials.
  88. Author: KennT
  89. ---------------------------------------------------------------------------*/
  90. HRESULT ConnectAsAdmin(IN LPCTSTR szRouterName, IN IRouterInfo *pRouter);
  91. DWORD ValidateMachine(const CString &sName, BOOL bDisplayErr = FALSE);
  92. /*!--------------------------------------------------------------------------
  93. InitiateServerConnection
  94. This should be called when attempting to connect to the server
  95. for the very first time (The parameters are the same as the
  96. ConnectRegistry() function). This will validate the server
  97. and return the HKLM key for that server.
  98. This call will bring up the connecting dialog as well as
  99. prompting the user for credentials if need be.
  100. Returns:
  101. S_OK - if the call succeeded, *phkey contains a valid HKEY.
  102. S_FALSE - user cancelled, *phkey contains NULL
  103. other - error condition, *phkey unchanged
  104. Author: KennT
  105. ---------------------------------------------------------------------------*/
  106. HRESULT InitiateServerConnection(LPCTSTR szMachine,
  107. HKEY *phkey,
  108. BOOL fNoConnectingUI,
  109. IRouterInfo *pRouter);
  110. void DisplayConnectErrorMessage(DWORD dwr);
  111. void FormatRasPortName(BYTE *pRasPort0, LPTSTR pszBuffer, UINT cchMax);
  112. CString& PortConditionToCString(DWORD dwPortCondition);
  113. /*!--------------------------------------------------------------------------
  114. RegFindInterfaceKey
  115. -
  116. This function returns the HKEY of the router interface with this ID.
  117. Author: KennT
  118. ---------------------------------------------------------------------------*/
  119. STDMETHODIMP RegFindInterfaceKey(LPCTSTR pszInterface,
  120. HKEY hkeyMachine,
  121. REGSAM regAccess,
  122. HKEY *pHKey);
  123. void StrListToHourMap(CStringList& stlist, BYTE* map) ;
  124. void HourMapToStrList(BYTE* map, CStringList& stList) ;
  125. // Versions before this rely on the snapin to set the IPEnableRouter key
  126. // Versions after this do not.
  127. // --------------------------------------------------------------------
  128. #define USE_IPENABLEROUTER_VERSION 2094
  129. /*!--------------------------------------------------------------------------
  130. InstallGlobalSettings
  131. Sets the global settings (i.e. registry settings) on this machine
  132. when the router is installed.
  133. For a specific description of the actions involved, look at
  134. the comments in the code.
  135. Author: KennT
  136. ---------------------------------------------------------------------------*/
  137. HRESULT InstallGlobalSettings(LPCTSTR pszMachineName,
  138. IRouterInfo *pRouter);
  139. /*!--------------------------------------------------------------------------
  140. UninstallGlobalSettings
  141. Clears the global settings (i.e. registry settings) on this machine
  142. when the router is installed.
  143. For a specific description of the actions involved, look at
  144. the comments in the code.
  145. Author: KennT
  146. ---------------------------------------------------------------------------*/
  147. HRESULT UninstallGlobalSettings(LPCTSTR pszMachineName,
  148. IRouterInfo *pRouter,
  149. BOOL fNt4,
  150. BOOL fSnapinChanges);
  151. HRESULT WriteErasePSKReg (LPCTSTR pszServerName, DWORD dwErasePSK );
  152. HRESULT ReadErasePSKReg(LPCTSTR pszServerName, DWORD *pdwErasePSK);
  153. /*!--------------------------------------------------------------------------
  154. WriteRouterConfiguredReg
  155. Writes the BOOLEAN that describes whether or not the router
  156. is configured.
  157. Author: KennT
  158. ---------------------------------------------------------------------------*/
  159. HRESULT WriteRouterConfiguredReg(LPCTSTR pszServerName, DWORD dwConfigured);
  160. /*!--------------------------------------------------------------------------
  161. ReadRouterConfiguredReg
  162. Reads the BOOLEAN that describes whether or not the router is
  163. configured.
  164. Author: KennT
  165. ---------------------------------------------------------------------------*/
  166. HRESULT ReadRouterConfiguredReg(LPCTSTR pszServerName, DWORD *pdwConfigured);
  167. /*!--------------------------------------------------------------------------
  168. WriteRRASExtendsComputerManagementKey
  169. Writes the GUID of the RRAS snapin so that it extends Computer
  170. Management.
  171. If dwConfigured is TRUE the key is written/created.
  172. If dwConfigured is FALSE, the key is removed.
  173. Author: KennT
  174. ---------------------------------------------------------------------------*/
  175. HRESULT WriteRRASExtendsComputerManagementKey(LPCTSTR pszServer, DWORD dwConfigured);
  176. /*!--------------------------------------------------------------------------
  177. NotifyTcpipOfChanges
  178. Triggers the TCPIP notification (for the local machine).
  179. Author: KennT
  180. ---------------------------------------------------------------------------*/
  181. void NotifyTcpipOfChanges(LPCTSTR pszMachineName,
  182. IRouterInfo *pRouter,
  183. BOOL fEnableRouter,
  184. UCHAR uPerformRouterDiscovery);
  185. /*!--------------------------------------------------------------------------
  186. UpdateLanaMapForDialinClients
  187. -
  188. Author: KennT
  189. ---------------------------------------------------------------------------*/
  190. HRESULT UpdateLanaMapForDialinClients(LPCTSTR pszServerName, DWORD dwAllowNetworkAccess);
  191. /*!--------------------------------------------------------------------------
  192. HrIsProtocolSupported
  193. This function will check the existence of the first two
  194. registry keys (these two are required). The third key will
  195. also be checked, but this is an optional parameter.
  196. The reason for the third key is that, for IP, we need to
  197. check one more key. It turns out that if we uninstall IP
  198. the first two keys still exist.
  199. Returns S_OK if the protocol is installed on the machine (checks
  200. the two registry keys passed in).
  201. Returns S_FALSE if the protocol is not supported.
  202. Error code otherwise.
  203. Author: KennT
  204. ---------------------------------------------------------------------------*/
  205. HRESULT HrIsProtocolSupported(LPCTSTR pszServerName,
  206. LPCTSTR pszServiceKey,
  207. LPCTSTR pszRasServiceKey,
  208. LPCTSTR pszExtraKey);
  209. /*!--------------------------------------------------------------------------
  210. RegisterRouterInDomain
  211. -
  212. Author: KennT
  213. ---------------------------------------------------------------------------*/
  214. HRESULT RegisterRouterInDomain(LPCTSTR pszRouterName, BOOL fRegister);
  215. /*!--------------------------------------------------------------------------
  216. SetDeviceType
  217. Sets the type of the various WAN devices depending on the
  218. router type. Thus, if we select the router to be a LAN-only
  219. router, we or in the routing-only flags.
  220. The dwTotalPorts is the number of ports that will be split
  221. up between L2TP/PPTP. This value is ignored if it is 0.
  222. Author: KennT
  223. ---------------------------------------------------------------------------*/
  224. HRESULT SetDeviceType(LPCTSTR pszMachineName,
  225. DWORD dwRouterType,
  226. DWORD dwTotalPorts);
  227. HRESULT SetDeviceTypeEx(PortsDeviceList *pDevList, DWORD dwRouterType);
  228. HRESULT SetPortSize(PortsDeviceList *pDeviceList, DWORD dwPorts);
  229. // Marks the sections of the code that read the serverflags from
  230. // the Rasman PPP key rather than RemoteAccess\Parameters.
  231. // This corresponds to NT 4 build number
  232. #define RASMAN_PPP_KEY_LAST_VERSION 1841
  233. // This is a new W2k build number to see if any W2k specific
  234. // logic needs to be performed. Currently it is used
  235. // only to hide/show the Ras Audio Acceleration checkbox.
  236. #define RASMAN_PPP_KEY_LAST_WIN2k_VERSION 2195
  237. CString& PortsDeviceTypeToCString(DWORD dwRasRouter);
  238. HRESULT SetRouterInstallRegistrySettings(LPCWSTR pswzServer,
  239. BOOL fInstall,
  240. BOOL fChangeEnableRouter);
  241. // Use to help debug problems during unattended install
  242. void TraceInstallError(LPCSTR pszString, HRESULT hr);
  243. void TraceInstallResult(LPCSTR pszString, HRESULT hr);
  244. void TraceInstallSz(LPCSTR pszString);
  245. void TraceInstallPrintf(LPCSTR pszFormat, ...);
  246. CString& PortTypeToCString(DWORD dwPortType);
  247. /*---------------------------------------------------------------------------
  248. Class: CWaitForRemoteAccessDlg
  249. This class implements the wait dialog. We wait for the RemoteAccess
  250. service to report that its up and running.
  251. ---------------------------------------------------------------------------*/
  252. class CWaitForRemoteAccessDlg : public CWaitDlg
  253. {
  254. public:
  255. CWaitForRemoteAccessDlg(LPCTSTR pszServerName,
  256. LPCTSTR pszText,
  257. LPCTSTR pszTitle,
  258. CWnd *pParent = NULL); // standard constructor
  259. virtual void OnTimerTick();
  260. };
  261. /*---------------------------------------------------------------------------
  262. Class: CRestartRouterDlg
  263. This class implemnts the wait dialog when we restart the router
  264. ---------------------------------------------------------------------------*/
  265. class CRestartRouterDlg : public CWaitDlg
  266. {
  267. public:
  268. CRestartRouterDlg(LPCTSTR pszServerName,
  269. LPCTSTR pszText,
  270. LPCTSTR pszTitle,
  271. CTime* pTimeStart,
  272. CWnd* pParent = NULL);
  273. virtual void OnTimerTick();
  274. BOOL m_fTimeOut;
  275. DWORD m_dwError;
  276. private:
  277. CTime* m_pTimeStart;
  278. DWORD m_dwTimeElapsed;
  279. };
  280. HRESULT AddNetConnection(LPCTSTR pszConnection);
  281. HRESULT RemoveNetConnection(LPCTSTR pszServer);
  282. HRESULT RemoveAllNetConnections();
  283. // Utility functions
  284. HRESULT RefreshMprConfig(LPCTSTR pszServerName);
  285. HRESULT WINAPI
  286. IsWindows64Bit( LPCWSTR pwszMachine,
  287. LPCWSTR pwszUserName,
  288. LPCWSTR pwszPassword,
  289. LPCWSTR pwszDomain,
  290. BOOL * pf64Bit);
  291. HRESULT WINAPI TransferCredentials ( IRouterInfo * spRISource,
  292. IRouterInfo * spRIDest
  293. );
  294. #endif