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.

243 lines
8.0 KiB

  1. #ifndef _RTRUTIL_H_
  2. #define _RTRUTIL_H_
  3. interface IInterfaceInfo;
  4. #include "mprapi.h"
  5. #include "rtrguid.h"
  6. #include "rrascfg.h"
  7. typedef HANDLE MPR_CONFIG_HANDLE;
  8. // since all of the handles typdef out to a HANDLE, we need to have different
  9. // explicit classes to make sure they get freed up correctly.
  10. class SPMprServerHandle
  11. {
  12. public:
  13. SPMprServerHandle() { m_h = NULL; }
  14. SPMprServerHandle(MPR_SERVER_HANDLE h) { m_h = h; }
  15. ~SPMprServerHandle() { Release(); }
  16. operator MPR_SERVER_HANDLE() const { return m_h; }
  17. MPR_SERVER_HANDLE *operator &() { Assert(!m_h); return &m_h; }
  18. MPR_SERVER_HANDLE operator=(MPR_SERVER_HANDLE h) { Assert(!m_h); m_h = h; return m_h; }
  19. inline void Attach(MPR_SERVER_HANDLE hT) { Release(); m_h = hT; }
  20. inline MPR_SERVER_HANDLE Detach() { MPR_SERVER_HANDLE hT; hT = m_h; m_h = NULL; return hT; }
  21. inline void Release() { MPR_SERVER_HANDLE hT; hT = Detach(); ReleaseSmartHandle(hT); }
  22. inline void ReleaseSmartHandle(MPR_SERVER_HANDLE h)
  23. {
  24. ::MprAdminServerDisconnect(h);
  25. }
  26. protected:
  27. MPR_SERVER_HANDLE m_h;
  28. };
  29. class SPMibServerHandle
  30. {
  31. public:
  32. SPMibServerHandle() { m_h = NULL; }
  33. SPMibServerHandle(MIB_SERVER_HANDLE h) { m_h = h; }
  34. ~SPMibServerHandle() { Release(); }
  35. operator MIB_SERVER_HANDLE() const { return m_h; }
  36. MIB_SERVER_HANDLE *operator &() { Assert(!m_h); return &m_h; }
  37. MIB_SERVER_HANDLE operator=(MIB_SERVER_HANDLE h) { Assert(!m_h); m_h = h; return m_h; }
  38. inline void Attach(MIB_SERVER_HANDLE hT) { Release(); m_h = hT; }
  39. inline MIB_SERVER_HANDLE Detach() { MIB_SERVER_HANDLE hT; hT = m_h; m_h = NULL; return hT; }
  40. inline void Release() { MIB_SERVER_HANDLE hT; hT = Detach(); ReleaseSmartHandle(hT); }
  41. inline void ReleaseSmartHandle(MIB_SERVER_HANDLE h)
  42. {
  43. ::MprAdminMIBServerDisconnect(h);
  44. }
  45. protected:
  46. MIB_SERVER_HANDLE m_h;
  47. };
  48. class SPMprConfigHandle
  49. {
  50. public:
  51. SPMprConfigHandle() { m_h = NULL; }
  52. SPMprConfigHandle(MPR_CONFIG_HANDLE h) { m_h = h; }
  53. ~SPMprConfigHandle() { Release(); }
  54. operator MPR_CONFIG_HANDLE() const { return m_h; }
  55. MPR_CONFIG_HANDLE *operator &() { Assert(!m_h); return &m_h; }
  56. MPR_CONFIG_HANDLE operator=(MPR_CONFIG_HANDLE h) { Assert(!m_h); m_h = h; return m_h; }
  57. inline void Attach(MPR_CONFIG_HANDLE hT) { Release(); m_h = hT; }
  58. inline MPR_CONFIG_HANDLE Detach() { MPR_CONFIG_HANDLE hT; hT = m_h; m_h = NULL; return hT; }
  59. inline void Release() { MPR_CONFIG_HANDLE hT; hT = Detach(); ReleaseSmartHandle(hT); }
  60. inline void ReleaseSmartHandle(MPR_CONFIG_HANDLE h)
  61. {
  62. if(h != NULL)
  63. ::MprConfigServerDisconnect(h);
  64. }
  65. protected:
  66. MPR_CONFIG_HANDLE m_h;
  67. };
  68. //----------------------------------------------------------------------------
  69. // Function: ConnectRouter
  70. //
  71. // Connects to the router on the specified machine. Returns the RPC handle
  72. // for that router.
  73. //----------------------------------------------------------------------------
  74. TFSCORE_API(DWORD) ConnectRouter(LPCTSTR pszMachine, MPR_SERVER_HANDLE *phMachine);
  75. //----------------------------------------------------------------------------
  76. // Function: GetRouterUpTime
  77. //
  78. // Get the router up time
  79. //----------------------------------------------------------------------------
  80. TFSCORE_API(DWORD) GetRouterUpTime(IN LPCTSTR pszMachine, OUT DWORD * pdwUpTime);
  81. //----------------------------------------------------------------------------
  82. // Function: GetRouterPhonebookPath
  83. //
  84. // Constructs the path to the router-phonebook file on the given machine.
  85. //----------------------------------------------------------------------------
  86. HRESULT
  87. GetRouterPhonebookPath(
  88. IN LPCTSTR pszMachine,
  89. IN CString * pstPath );
  90. HRESULT DeleteRouterPhonebook(IN LPCTSTR pszMachine);
  91. CString GetLocalMachineName();
  92. DeclareSPPrivateBasic(SPMprAdminBuffer, BYTE, if (m_p) ::MprAdminBufferFree(m_p));
  93. DeclareSPPrivateBasic(SPMprMibBuffer, BYTE, if (m_p) ::MprAdminMIBBufferFree(m_p));
  94. DeclareSPPrivateBasic(SPMprConfigBuffer, BYTE, if(m_p) ::MprConfigBufferFree(m_p));
  95. /*---------------------------------------------------------------------------
  96. Function: ConnectInterface
  97. Called to connet/disconnect a demand-dial interface. Displays a dialog
  98. showing elasped time, allowing the user to cancel the connection.
  99. ---------------------------------------------------------------------------*/
  100. TFSCORE_API(DWORD) ConnectInterface(LPCTSTR pszMachine,
  101. LPCTSTR pszInterface,
  102. BOOL bConnect,
  103. HWND hwndParent);
  104. TFSCORE_API(DWORD) ConnectInterfaceEx(MPR_SERVER_HANDLE hRouter,
  105. HANDLE hInterface,
  106. BOOL bConnect,
  107. HWND hwndParent,
  108. LPCTSTR pszParent);
  109. /*!--------------------------------------------------------------------------
  110. PromptForCredentials
  111. Brings up the Credentials dialog.
  112. Author: KennT
  113. ---------------------------------------------------------------------------*/
  114. TFSCORE_API(DWORD) PromptForCredentials(LPCTSTR pszMachine,
  115. LPCTSTR pszInterface,
  116. BOOL fNT4,
  117. BOOL fNewInterface,
  118. HWND hwndParent);
  119. /*!--------------------------------------------------------------------------
  120. UpdateDDM
  121. Updates changes to the phonebook entry in the DDM. Invoke this
  122. to cause DDM to pick up changes to the phonebook entry
  123. dynamically.
  124. Author: KennT
  125. ---------------------------------------------------------------------------*/
  126. TFSCORE_API(DWORD) UpdateDDM(IInterfaceInfo *pInterfaceInfo);
  127. /*!--------------------------------------------------------------------------
  128. UpdateRoutes
  129. Performs an autostatic update on the given machine's interface,
  130. for a specific transport.
  131. Author: KennT
  132. ---------------------------------------------------------------------------*/
  133. TFSCORE_API(DWORD) UpdateRoutesEx(IN MPR_SERVER_HANDLE hRouter,
  134. IN HANDLE hInterface,
  135. IN DWORD dwTransportId,
  136. IN HWND hwndParent,
  137. IN LPCTSTR pszInterface);
  138. TFSCORE_API(DWORD) UpdateRoutes(IN LPCTSTR pszMachine,
  139. IN LPCTSTR pszInterface,
  140. IN DWORD dwTransportId,
  141. IN HWND hwndParent);
  142. /*---------------------------------------------------------------------------
  143. IsRouterServiceRunning
  144. Returns S_OK if the service is running.
  145. Returns S_FALSE if the service is not running.
  146. Returns an error code otherwise.
  147. Author: KennT
  148. ---------------------------------------------------------------------------*/
  149. TFSCORE_API(HRESULT) IsRouterServiceRunning(IN LPCWSTR pszMachine,
  150. OUT DWORD *pdwErrorCode);
  151. TFSCORE_API(HRESULT) GetRouterServiceStatus(IN LPCWSTR pszMachine,
  152. OUT DWORD *pdwStatus,
  153. OUT DWORD *pdwErrorCode);
  154. TFSCORE_API(HRESULT) GetRouterServiceStartType(IN LPCWSTR pszMachine,
  155. OUT DWORD *pdwStartType);
  156. TFSCORE_API(HRESULT) SetRouterServiceStartType(IN LPCWSTR pszMachine,
  157. DWORD dwStartType);
  158. TFSCORE_API(HRESULT) StartRouterService(IN LPCWSTR pszMachine);
  159. TFSCORE_API(HRESULT) StopRouterService(IN LPCWSTR pszMachine);
  160. TFSCORE_API(HRESULT) PauseRouterService(IN LPCWSTR pszMachine);
  161. TFSCORE_API(HRESULT) ResumeRouterService(IN LPCWSTR pszMachine);
  162. TFSCORE_API(HRESULT) ForceGlobalRefresh(IRouterInfo *pRouter);
  163. typedef ComSmartPointer<IRouterProtocolConfig, &IID_IRouterProtocolConfig> SPIRouterProtocolConfig;
  164. typedef ComSmartPointer<IAuthenticationProviderConfig, &IID_IAuthenticationProviderConfig> SPIAuthenticationProviderConfig;
  165. typedef ComSmartPointer<IAccountingProviderConfig, &IID_IAccountingProviderConfig> SPIAccountingProviderConfig;
  166. typedef ComSmartPointer<IEAPProviderConfig, &IID_IEAPProviderConfig> SPIEAPProviderConfig;
  167. typedef ComSmartPointer<IRouterAdminAccess, &IID_IRouterAdminAccess> SPIRouterAdminAccess;
  168. // Some helper functions for IP/IPX
  169. TFSCORE_API(HRESULT) AddIpPerInterfaceBlocks(IInterfaceInfo *pIf,
  170. IInfoBase *pInfoBase);
  171. TFSCORE_API(HRESULT) AddIpxPerInterfaceBlocks(IInterfaceInfo *pIf,
  172. IInfoBase *pInfoBase);
  173. #endif