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.

812 lines
24 KiB

  1. //============================================================================
  2. // Copyright (C) Microsoft Corporation, 1996 - 1999
  3. //
  4. // File: info.h
  5. //
  6. // History:
  7. // Abolade Gbadegesin Feb. 10, 1996 Created.
  8. //
  9. // This file contains declarations for InfoBase parsing code.
  10. // Also including are classes for loading and saving the Router's
  11. // configuration tree (CRouterInfo, CRmInfo, etc.)
  12. //
  13. // The classes are as follows
  14. // (in the diagrams, d => derives, c => contains-list-of):
  15. //
  16. //
  17. // CInfoBase
  18. // |
  19. // c---SInfoBlock
  20. //
  21. //
  22. // CInfoBase holds block of data broken up into a list
  23. // of SInfoBlock structures using RTR_INFO_BLOCK_HEADER
  24. // as a template (see rtinfo.h).
  25. //
  26. // CRouterInfo // router info
  27. // |
  28. // c---CRmInfo // router-manager info
  29. // | |
  30. // | c---CRmProtInfo // protocol info
  31. // |
  32. // c---CInterfaceInfo // router interface info
  33. // |
  34. // c---CRmInterfaceInfo // router-manager interface
  35. // |
  36. // c---CRmProtInterfaceInfo // protocol info
  37. //
  38. // CRouterInfo top-level container for Router registry info.
  39. // holds list of router-managers and interfaces.
  40. //
  41. // CRmInfo global information for a router-manager,
  42. // holds list of routing-protocols.
  43. //
  44. // CRmProtInfo global information for a routing-protocol.
  45. //
  46. // CInterfaceInfo global information for a router-interface.
  47. // holds list of CRmInterfaceInfo structures,
  48. // which hold per-interface info for router-managers.
  49. //
  50. // CRmInterfaceInfo per-interface info for a router-manager.
  51. // holds list of CRmProtInterfaceInfo structures,
  52. // which hold per-interface info for protocols.
  53. //
  54. // CRmProtInterfaceInfo per-interface info for a routing-protocol.
  55. //
  56. //============================================================================
  57. #ifndef _INFOI_H_
  58. #define _INFOI_H_
  59. #include "router.h"
  60. #ifndef _INFOPRIV_H
  61. #include "infopriv.h"
  62. #endif
  63. #ifndef _RTRLIST_H
  64. #include "rtrlist.h"
  65. #endif
  66. //
  67. // Forward declarations of router-information classes.
  68. //
  69. class CRmInfo;
  70. class CRmProtInfo;
  71. class CInterfaceInfo;
  72. class CRmInterfaceInfo;
  73. class CRmProtInterfaceInfo;
  74. class RouterRefreshObject;
  75. typedef struct _SRouterCB
  76. {
  77. DWORD dwLANOnlyMode; // 0 or 1
  78. void LoadFrom(const RouterCB *pcb);
  79. void SaveTo(RouterCB *pcb);
  80. } SRouterCB;
  81. typedef struct _SRtrMgrCB
  82. {
  83. DWORD dwTransportId; // e.g. PID_IP (mprapi.h)
  84. CString stId; // e.g. "Tcpip"
  85. CString stTitle; // e.g. "TCP/IP Router Manager"
  86. CString stDLLPath; // e.g. "%systemroot%\system32\iprtrmgr.dll"
  87. //CString stConfigDLL; // e.g. "rtrui.dll"
  88. // Internal data
  89. DWORD dwPrivate; // private data (for use internally)
  90. void LoadFrom(const RtrMgrCB *pcb);
  91. void SaveTo(RtrMgrCB *pcb);
  92. } SRtrMgrCB;
  93. typedef struct _SRtrMgrProtocolCB
  94. {
  95. DWORD dwProtocolId; // e.g. IP_RIP (routprot.h)
  96. CString stId; // e.g. "IPRIP"
  97. DWORD dwFlags;
  98. DWORD dwTransportId; // e.g. PID_IP
  99. CString stRtrMgrId; // e.g. "Tcpip"
  100. CString stTitle; // e.g. "RIP for Internet Protocol"
  101. CString stDLLName; // e.g. "iprip2.dll"
  102. //CString stConfigDLL; // e.g. "rtrui.dll"
  103. GUID guidConfig; // CLSID for config object
  104. GUID guidAdminUI; // CLSID for snapin
  105. CString stVendorName;
  106. // Internal data
  107. DWORD dwPrivate; // private data (for use internally)
  108. void LoadFrom(const RtrMgrProtocolCB *pcb);
  109. void SaveTo(RtrMgrProtocolCB *pcb);
  110. } SRtrMgrProtocolCB;
  111. typedef struct _SInterfaceCB
  112. {
  113. CString stId; // e.g. "EPRO1"
  114. DWORD dwIfType; // e.g. ROUTER_IF_TYPE_CLIENT (mprapi.h)
  115. BOOL bEnable; // e.g. Enabled or Disabled
  116. CString stTitle; // e.g. friendly name(NT5) or the device name(NT4)
  117. CString stDeviceName; // e.g. "[1] Intel EtherPro"
  118. DWORD dwBindFlags; // e.g. Bound to IP or IPX
  119. // Internal data
  120. DWORD dwPrivate; // private data (for use internally)
  121. void LoadFrom(const InterfaceCB *pcb);
  122. void SaveTo(InterfaceCB *pcb);
  123. } SInterfaceCB;
  124. typedef struct _SRtrMgrInterfaceCB
  125. {
  126. DWORD dwTransportId; // e.g. PID_IP (mprapi.h)
  127. CString stId; // e.g. "Tcpip"
  128. CString stInterfaceId; // e.g. "EPRO1"
  129. DWORD dwIfType; // e.g. ROUTER_IF_TYPE_CLIENT (mprapi.h)
  130. CString stTitle; // e.g. "[1] Intel Etherexpress PRO"
  131. // Internal data
  132. DWORD dwPrivate; // private data (for use internally)
  133. void LoadFrom(const RtrMgrInterfaceCB *pcb);
  134. void SaveTo(RtrMgrInterfaceCB *pcb);
  135. } SRtrMgrInterfaceCB;
  136. typedef struct _SRtrMgrProtocolInterfaceCB
  137. {
  138. DWORD dwProtocolId; // e.g. IP_RIP (routprot.h)
  139. CString stId; // e.g. "IPRIP"
  140. DWORD dwTransportId; // e.g. PID_IP
  141. CString stRtrMgrId; // e.g. "Tcpip"
  142. CString stInterfaceId; // e.g. "EPRO1"
  143. DWORD dwIfType; // e.g. ROUTER_IF_TYPE_CLIENT (mprapi.h)
  144. CString stTitle; // e.g. "[1] Intel Etherexpress PRO"
  145. // Internal data
  146. DWORD dwPrivate; // private data (for use internally)
  147. void LoadFrom(const RtrMgrProtocolInterfaceCB *pcb);
  148. void SaveTo(RtrMgrProtocolInterfaceCB *pcb);
  149. } SRtrMgrProtocolInterfaceCB;
  150. /*---------------------------------------------------------------------------
  151. CList classes for the external structures
  152. ---------------------------------------------------------------------------*/
  153. typedef CList<RtrMgrCB *, RtrMgrCB *> RtrMgrCBList;
  154. typedef CList<RtrMgrProtocolCB *, RtrMgrProtocolCB *> RtrMgrProtocolCBList;
  155. typedef CList<InterfaceCB *, InterfaceCB *> InterfaceCBList;
  156. typedef CList<RtrMgrInterfaceCB *, RtrMgrInterfaceCB *> RtrMgrInterfaceCBList;
  157. typedef CList<RtrMgrProtocolInterfaceCB *, RtrMgrProtocolInterfaceCB *> RtrMgrProtocolInterfaceCBList;
  158. /*---------------------------------------------------------------------------
  159. CList classes for the various internal structures
  160. ---------------------------------------------------------------------------*/
  161. typedef CList<SRtrMgrCB *, SRtrMgrCB *> SRtrMgrCBList;
  162. typedef CList<SRtrMgrProtocolCB *, SRtrMgrProtocolCB *> SRtrMgrProtocolCBList;
  163. typedef CList<SInterfaceCB *, SInterfaceCB *> SInterfaceCBList;
  164. typedef CList<SRtrMgrInterfaceCB *, SRtrMgrInterfaceCB *> SRtrMgrInterfaceCBList;
  165. typedef CList<SRtrMgrProtocolInterfaceCB *, SRtrMgrProtocolInterfaceCB *> SRtrMgrProtocolInterfaceCBList;
  166. /*---------------------------------------------------------------------------
  167. Smart pointers for the various structures
  168. ---------------------------------------------------------------------------*/
  169. DeclareSP(SRouterCB, SRouterCB)
  170. DeclareSP(SRtrMgrCB, SRtrMgrCB)
  171. DeclareSP(SRtrMgrProtocolCB, SRtrMgrProtocolCB)
  172. DeclareSP(SInterfaceCB, SInterfaceCB)
  173. DeclareSP(SRtrMgrInterfaceCB, SRtrMgrInterfaceCB)
  174. DeclareSP(SRtrMgrProtocolInterfaceCB, SRtrMgrProtocolInterfaceCB)
  175. struct SRmData
  176. {
  177. IRtrMgrInfo * m_pRmInfo;
  178. SRmData() : m_pRmInfo(NULL){};
  179. // Do this instead of using a destructor to avoid problems with
  180. // destruction of temporaries.
  181. static void Destroy(SRmData *pRmData);
  182. };
  183. typedef CList<SRmData, SRmData> RmDataList;
  184. struct SIfData
  185. {
  186. IInterfaceInfo * pIfInfo;
  187. DWORD dwConnection;
  188. SIfData() : pIfInfo(NULL), dwConnection(0) {};
  189. };
  190. typedef CList<SIfData, SIfData> IfList;
  191. /*---------------------------------------------------------------------------
  192. CreateEnum for the various CBs
  193. ---------------------------------------------------------------------------*/
  194. HRESULT CreateEnumFromSRmCBList(SRtrMgrCBList *pRmCBList,
  195. IEnumRtrMgrCB **ppEnum);
  196. HRESULT CreateEnumFromSRmProtCBList(SRtrMgrProtocolCBList *pRmProtCBList,
  197. IEnumRtrMgrProtocolCB **ppEnum);
  198. HRESULT CreateEnumFromSIfCBList(SInterfaceCBList *pIfCBList,
  199. IEnumInterfaceCB **ppEnum);
  200. HRESULT CreateEnumFromSRmIfCBList(SRtrMgrInterfaceCBList *pRmIfCBList,
  201. IEnumRtrMgrInterfaceCB **ppEnum);
  202. HRESULT CreateEnumFromSRmProtIfCBList(SRtrMgrProtocolInterfaceCBList *pRmIfProtCBList,
  203. IEnumRtrMgrProtocolInterfaceCB **ppEnum);
  204. /*---------------------------------------------------------------------------
  205. CreateEnum for the various interface lists
  206. ---------------------------------------------------------------------------*/
  207. // These lists are assumed to have arrays of WEAK references!
  208. HRESULT CreateEnumFromRmList(RmDataList *pRmList,
  209. IEnumRtrMgrInfo **ppEnum);
  210. HRESULT CreateEnumFromRtrMgrProtocolList(PRtrMgrProtocolInfoList *pRmProtList,
  211. IEnumRtrMgrProtocolInfo **ppEnum);
  212. HRESULT CreateEnumFromInterfaceList(PInterfaceInfoList *pIfList,
  213. IEnumInterfaceInfo **ppEnum);
  214. HRESULT CreateEnumFromRtrMgrInterfaceList(PRtrMgrInterfaceInfoList *pRmIfList,
  215. IEnumRtrMgrInterfaceInfo **ppEnum);
  216. HRESULT CreateEnumFromRtrMgrProtocolInterfaceList(PRtrMgrProtocolInterfaceInfoList *pRmProtIfList,
  217. IEnumRtrMgrProtocolInterfaceInfo **ppEnum);
  218. /*---------------------------------------------------------------------------
  219. Struct: SAdviseData
  220. Helper class for management of advise connections.
  221. ---------------------------------------------------------------------------*/
  222. struct SAdviseData
  223. {
  224. IRtrAdviseSink *m_pAdvise;
  225. LONG_PTR m_ulConnection;
  226. LPARAM m_lUserParam;
  227. // This m_ulFlags parameter is used by the AdviseDataList.
  228. ULONG m_ulFlags;
  229. SAdviseData() : m_pAdvise(NULL), m_ulConnection(0) {};
  230. static void Destroy(SAdviseData *pAdviseData);
  231. };
  232. typedef CList<SAdviseData, SAdviseData> _SAdviseDataList;
  233. // Possible values for the m_ulFlags
  234. #define ADVISEDATA_DELETED (1)
  235. class AdviseDataList : public _SAdviseDataList
  236. {
  237. public:
  238. HRESULT AddConnection(IRtrAdviseSink *pAdvise,
  239. LONG_PTR ulConnection,
  240. LPARAM lUserParam);
  241. HRESULT RemoveConnection(LONG_PTR ulConnection);
  242. HRESULT NotifyChange(DWORD dwChange, DWORD dwObj, LPARAM lParam);
  243. protected:
  244. // Need to have a private list to handle the notifies.
  245. // This list is created while in a NotifyChange(). Any calls
  246. // to RemoveConnection() DURING a notify, will mark entries as
  247. // invalid (and are thus not called during the NotifyChange()).
  248. _SAdviseDataList m_listNotify;
  249. };
  250. /*---------------------------------------------------------------------------
  251. Class: RtrCriticalSection
  252. This class is used to support entering/leaving of critical sections.
  253. Put this class at the top of a function that you want protected.
  254. ---------------------------------------------------------------------------*/
  255. class RtrCriticalSection
  256. {
  257. public:
  258. RtrCriticalSection(CRITICAL_SECTION *pCritSec)
  259. : m_pCritSec(pCritSec)
  260. {
  261. IfDebug(m_cEnter=0;)
  262. Assert(m_pCritSec);
  263. Enter();
  264. }
  265. ~RtrCriticalSection()
  266. {
  267. Detach();
  268. }
  269. void Enter()
  270. {
  271. if (m_pCritSec)
  272. {
  273. IfDebug(m_cEnter++;)
  274. EnterCriticalSection(m_pCritSec);
  275. AssertSz(m_cEnter==1, "EnterCriticalSection called too much!");
  276. }
  277. }
  278. BOOL TryToEnter()
  279. {
  280. if (m_pCritSec)
  281. return TryEnterCriticalSection(m_pCritSec);
  282. return TRUE;
  283. }
  284. void Leave()
  285. {
  286. if (m_pCritSec)
  287. {
  288. IfDebug(m_cEnter--;)
  289. LeaveCriticalSection(m_pCritSec);
  290. Assert(m_cEnter==0);
  291. }
  292. }
  293. void Detach()
  294. {
  295. Leave();
  296. m_pCritSec = NULL;
  297. }
  298. private:
  299. CRITICAL_SECTION * m_pCritSec;
  300. IfDebug(int m_cEnter;)
  301. };
  302. /*---------------------------------------------------------------------------
  303. Class: RouterInfo
  304. ---------------------------------------------------------------------------*/
  305. class RouterInfo :
  306. public CWeakRef,
  307. public IRouterInfo,
  308. public IRouterAdminAccess
  309. {
  310. public:
  311. DeclareIUnknownMembers(IMPL)
  312. DeclareIRouterRefreshAccessMembers(IMPL)
  313. DeclareIRouterInfoMembers(IMPL)
  314. DeclareIRtrAdviseSinkMembers(IMPL)
  315. DeclareIRouterAdminAccessMembers(IMPL)
  316. // Constructor
  317. RouterInfo(HWND hWndSync, LPCWSTR machineName);
  318. // If you are releasing ANY interface pointers do it in
  319. // the Destruct() call instead.
  320. virtual ~RouterInfo();
  321. // Internal calls to help out with adding/removing interfaces
  322. // ----------------------------------------------------------------
  323. HRESULT AddInterfaceInternal(IInterfaceInfo *pInfo, BOOL fForce,
  324. BOOL fAddToRouter);
  325. HRESULT RemoveInterfaceInternal(LPCOLESTR pszIf, BOOL fRemoveFromRouter);
  326. HRESULT RemoteRtrMgrInternal(DWORD dwTransportId, BOOL fRemoveFromRouter);
  327. HRESULT FindInterfaceByName(LPCOLESTR pszIfName, IInterfaceInfo **ppInfo);
  328. HRESULT NotifyRtrMgrInterfaceOfMove(IInterfaceInfo *pInfo);
  329. // Functions to load up static information about the router.
  330. // This will return information about the INSTALLED protocols/rms,
  331. // not necessarily the RUNNING protocols/rms.
  332. // ----------------------------------------------------------------
  333. static HRESULT LoadInstalledRtrMgrList(LPCTSTR pszMachine,
  334. SRtrMgrCBList *pRmCBList);
  335. static HRESULT LoadInstalledInterfaceList(LPCTSTR pszMachine,
  336. SInterfaceCBList *pIfCBList);
  337. static HRESULT LoadInstalledRtrMgrProtocolList(LPCTSTR pszMachine,
  338. DWORD dwTransportId, SRtrMgrProtocolCBList *pRmProtCBList,
  339. LPCWSTR lpwszUserName, LPCWSTR lpwszPassword , LPCWSTR lpwszDomain );
  340. static HRESULT LoadInstalledRtrMgrProtocolList(LPCTSTR pszMachine,
  341. DWORD dwTransportId, SRtrMgrProtocolCBList *pRmProtCBList, RouterInfo * pRouter);
  342. static HRESULT LoadInstalledRtrMgrProtocolList(LPCTSTR pszMachine,
  343. DWORD dwTransportId, SRtrMgrProtocolCBList *pRmProtCBList, IRouterInfo * pRouter);
  344. protected:
  345. // The router control block for this router. There's not too much
  346. // information here.
  347. // ----------------------------------------------------------------
  348. SRouterCB m_SRouterCB;
  349. // List of Router-Managers that are running on the router.
  350. // ----------------------------------------------------------------
  351. RmDataList m_RmList;
  352. // List of interfaces that have been added to the router.
  353. // WEAK-REF ptrs to IInterfaceInfo objects.
  354. // ----------------------------------------------------------------
  355. PInterfaceInfoList m_IfList;
  356. // Name of this machine.
  357. // ----------------------------------------------------------------
  358. CString m_stMachine;
  359. // MPR_CONFIG_HANDLE to the router
  360. // Obtained by MprAdminServerConnect();
  361. // ----------------------------------------------------------------
  362. MPR_CONFIG_HANDLE m_hMachineConfig;
  363. // MPR_SERVER_HANDLE to the router
  364. // Obtained by MprAdminServerConnect();
  365. // ----------------------------------------------------------------
  366. MPR_SERVER_HANDLE m_hMachineAdmin;
  367. // This is set to TRUE if we are to disconnect the machine handles.
  368. // ----------------------------------------------------------------
  369. BOOL m_bDisconnect;
  370. // This is the router type (LAN, WAN, RAS);
  371. // ----------------------------------------------------------------
  372. DWORD m_dwRouterType;
  373. // Version info for the router and machine.
  374. // ----------------------------------------------------------------
  375. RouterVersionInfo m_VersionInfo;
  376. // Pointer to the refresh object connected with this machine.
  377. // ----------------------------------------------------------------
  378. SPIRouterRefresh m_spRefreshObject;
  379. HWND m_hWndSync; // hwnd of the background hidden window
  380. SRtrMgrCBList m_RmCBList; // contains ptrs to RtrMgrCB objects
  381. SRtrMgrProtocolCBList m_RmProtCBList; // ptrs to RtrMgrProtocolCB objects
  382. SInterfaceCBList m_IfCBList; // ptrs to InterfaceCB objects
  383. AdviseDataList m_AdviseList; // list of advises
  384. DWORD m_dwFlags;
  385. HRESULT LoadRtrMgrList();
  386. HRESULT LoadInterfaceList();
  387. HRESULT TryToConnect(LPCWSTR pswzMachine, HANDLE hMachine);
  388. // Functions for merge support
  389. HRESULT MergeRtrMgrCB(IRouterInfo *pNewRouter);
  390. HRESULT MergeInterfaceCB(IRouterInfo *pNewRouter);
  391. HRESULT MergeRtrMgrProtocolCB(IRouterInfo *pNewRouter);
  392. HRESULT MergeRtrMgrs(IRouterInfo *pNewRouter);
  393. HRESULT MergeInterfaces(IRouterInfo *pNewRouter);
  394. SRtrMgrCB * FindRtrMgrCB(DWORD dwTransportId);
  395. SInterfaceCB * FindInterfaceCB(LPCTSTR pszInterfaceId);
  396. SRtrMgrProtocolCB * FindRtrMgrProtocolCB(DWORD dwTransportId, DWORD dwProtocolId);
  397. // Disconnect
  398. void Disconnect();
  399. // Overrides of CWeakRef functions
  400. virtual void OnLastStrongRef();
  401. virtual void ReviveStrongRef();
  402. // Critical section support
  403. CRITICAL_SECTION m_critsec;
  404. // Information for IRouterAdminAccess
  405. BOOL m_fIsAdminInfoSet;
  406. CString m_stUserName;
  407. CString m_stDomain;
  408. BYTE * m_pbPassword;
  409. int m_cPassword;
  410. };
  411. /*---------------------------------------------------------------------------
  412. Class: RtrMgrInfo
  413. ---------------------------------------------------------------------------*/
  414. class RtrMgrInfo :
  415. public IRtrMgrInfo,
  416. public CWeakRef
  417. {
  418. public:
  419. DeclareIUnknownMembers(IMPL)
  420. DeclareIRtrMgrInfoMembers(IMPL)
  421. RtrMgrInfo(DWORD dwTransportId, LPCTSTR pszTransportName,
  422. RouterInfo *pRouterInfo);
  423. virtual ~RtrMgrInfo();
  424. protected:
  425. SRtrMgrCB m_cb; // router-manager control block
  426. PRtrMgrProtocolInfoList m_RmProtList; // list of routing-protocols
  427. // CObList m_protList; // list of routing-protocols
  428. CString m_stMachine; // machine whose config is loaded
  429. HANDLE m_hMachineConfig; // handle to machine's router-config
  430. HANDLE m_hTransport; // handle to transport's config
  431. BOOL m_bDisconnect;
  432. AdviseDataList m_AdviseList; // list of advises
  433. DWORD m_dwFlags;
  434. // This will contain a weak/strong ref on the parent
  435. IRouterInfo * m_pRouterInfoParent;
  436. //--------------------------------------------------------------------
  437. // Functions: LoadRtrMgrInfo
  438. // SaveRtrMgrInfo
  439. //
  440. // The following handle loading and saving the routing-protocol list
  441. // for the router-manager in the correct format in the registry.
  442. //--------------------------------------------------------------------
  443. HRESULT LoadRtrMgrInfo(HANDLE hMachine,
  444. HANDLE hTransport
  445. );
  446. HRESULT SaveRtrMgrInfo(HANDLE hMachine,
  447. HANDLE hTransport,
  448. IInfoBase *pGlobalInfo,
  449. IInfoBase *pClientInfo,
  450. DWORD dwDeleteProtocolId);
  451. HRESULT TryToConnect(LPCWSTR pswzMachine, HANDLE *phMachine);
  452. HRESULT TryToGetAllHandles(LPCOLESTR pszMachine,
  453. HANDLE *phMachine,
  454. HANDLE *phTransport);
  455. // Disconnects this object
  456. void Disconnect();
  457. // Overrides of CWeakRef functions
  458. virtual void OnLastStrongRef();
  459. virtual void ReviveStrongRef();
  460. // Critical section support
  461. CRITICAL_SECTION m_critsec;
  462. };
  463. /*---------------------------------------------------------------------------
  464. Class: RtrMgrProtocolInfo
  465. ---------------------------------------------------------------------------*/
  466. class RtrMgrProtocolInfo :
  467. public IRtrMgrProtocolInfo,
  468. public CWeakRef
  469. {
  470. public:
  471. DeclareIUnknownMembers(IMPL)
  472. DeclareIRtrMgrProtocolInfoMembers(IMPL)
  473. RtrMgrProtocolInfo(DWORD dwProtocolId,
  474. LPCTSTR lpszId,
  475. DWORD dwTransportId,
  476. LPCTSTR lpszRm,
  477. RtrMgrInfo * pRmInfo);
  478. virtual ~RtrMgrProtocolInfo();
  479. HRESULT SetCB(const RtrMgrProtocolCB *pcb);
  480. protected:
  481. // This will contain a weak/strong ref on the parent
  482. IRtrMgrInfo * m_pRtrMgrInfoParent;
  483. SRtrMgrProtocolCB m_cb; // protocol control block
  484. AdviseDataList m_AdviseList; // list of advises
  485. DWORD m_dwFlags;
  486. // Disconnect
  487. void Disconnect();
  488. // Overrides of CWeakRef functions
  489. virtual void OnLastStrongRef();
  490. virtual void ReviveStrongRef();
  491. // Critical section support
  492. CRITICAL_SECTION m_critsec;
  493. };
  494. /*---------------------------------------------------------------------------
  495. Class: InterfaceInfo
  496. ---------------------------------------------------------------------------*/
  497. class InterfaceInfo :
  498. public IInterfaceInfo,
  499. public CWeakRef
  500. {
  501. public:
  502. DeclareIUnknownMembers(IMPL)
  503. DeclareIInterfaceInfoMembers(IMPL)
  504. InterfaceInfo(LPCTSTR lpszId,
  505. DWORD dwIfType,
  506. BOOL bEnable,
  507. DWORD dwBindFlags,
  508. RouterInfo* pRouterInfo);
  509. ~InterfaceInfo();
  510. static HRESULT FindInterfaceTitle(LPCTSTR pszMachine,
  511. LPCTSTR pszInterface,
  512. LPTSTR *ppszTitle);
  513. protected:
  514. // CInterfaceInfo m_CInterfaceInfo;
  515. SInterfaceCB m_cb; // interface control block
  516. PRtrMgrInterfaceInfoList m_RmIfList; // list of IRtrMgrInterfaceInfo
  517. // CObList m_rmIfList; // list of CRmInterfaceInfo
  518. CString m_stMachine; // machine whose config is loaded
  519. HANDLE m_hMachineConfig; // handle to machine's config
  520. HANDLE m_hInterface; // handle to interface-config
  521. BOOL m_bDisconnect;
  522. AdviseDataList m_AdviseList; // list of advises
  523. DWORD m_dwFlags;
  524. IRouterInfo * m_pRouterInfoParent;
  525. HRESULT LoadRtrMgrInterfaceList();
  526. HRESULT TryToConnect(LPCWSTR pszMachine, HANDLE *phMachine);
  527. HRESULT TryToGetIfHandle(HANDLE hMachine, LPCWSTR pswzInterface, HANDLE *phInterface);
  528. // Disconnect
  529. void Disconnect();
  530. // Overrides of CWeakRef functions
  531. virtual void OnLastStrongRef();
  532. virtual void ReviveStrongRef();
  533. // Critical section support
  534. CRITICAL_SECTION m_critsec;
  535. };
  536. /*---------------------------------------------------------------------------
  537. Class: RtrMgrInterfaceInfo
  538. ---------------------------------------------------------------------------*/
  539. class RtrMgrInterfaceInfo :
  540. public IRtrMgrInterfaceInfo,
  541. public CWeakRef
  542. {
  543. public:
  544. DeclareIUnknownMembers(IMPL)
  545. DeclareIRtrMgrInterfaceInfoMembers(IMPL)
  546. RtrMgrInterfaceInfo(DWORD dwTransportId,
  547. LPCTSTR lpszId,
  548. LPCTSTR lpszIfId,
  549. DWORD dwIfType,
  550. InterfaceInfo * pIfInfo);
  551. virtual ~RtrMgrInterfaceInfo();
  552. protected:
  553. // CRmInterfaceInfo m_CRmInterfaceInfo;
  554. SRtrMgrInterfaceCB m_cb; // router-manager control block
  555. PRtrMgrProtocolInterfaceInfoList m_RmProtIfList;
  556. // CObList m_protList; // list of CRmProtInterfaceInfo
  557. CString m_stMachine; // name of machine
  558. HANDLE m_hMachineConfig; // handle to machine's config
  559. HANDLE m_hInterface; // handle to interface-config
  560. HANDLE m_hIfTransport; // handle to transport-config
  561. BOOL m_bDisconnect;
  562. DWORD m_dwFlags; // state of this interface
  563. AdviseDataList m_AdviseList; // list of advises
  564. IInterfaceInfo * m_pInterfaceInfoParent;
  565. HRESULT LoadRtrMgrInterfaceInfo(HANDLE hMachine,
  566. HANDLE hInterface,
  567. HANDLE hIfTransport);
  568. HRESULT SaveRtrMgrInterfaceInfo(HANDLE hMachine,
  569. HANDLE hInterface,
  570. HANDLE hIfTransport,
  571. IInfoBase *pInterfaceInfoBase,
  572. DWORD dwDeleteProtocolId);
  573. HRESULT TryToGetAllHandles(LPCWSTR pszMachine,
  574. HANDLE *phMachine,
  575. HANDLE *phInterface,
  576. HANDLE *phTransport);
  577. HRESULT TryToConnect(LPCWSTR pswzMachine, HANDLE *phMachine);
  578. HRESULT TryToGetIfHandle(HANDLE hMachine, LPCWSTR pswzInterface, HANDLE *phInterface);
  579. // Disconnect
  580. void Disconnect();
  581. // Notification helper functions
  582. HRESULT NotifyOfRmProtIfAdd(IRtrMgrProtocolInterfaceInfo *pRmProtIf,
  583. IInterfaceInfo *pParentIf);
  584. // Overrides of CWeakRef functions
  585. virtual void OnLastStrongRef();
  586. virtual void ReviveStrongRef();
  587. // Critical section support
  588. CRITICAL_SECTION m_critsec;
  589. };
  590. /*---------------------------------------------------------------------------
  591. Class: RtrMgrProtocolInterfaceInfo
  592. ---------------------------------------------------------------------------*/
  593. class RtrMgrProtocolInterfaceInfo :
  594. public IRtrMgrProtocolInterfaceInfo,
  595. public CWeakRef
  596. {
  597. public:
  598. DeclareIUnknownMembers(IMPL)
  599. DeclareIRtrMgrProtocolInterfaceInfoMembers(IMPL)
  600. RtrMgrProtocolInterfaceInfo(DWORD dwProtocolId,
  601. LPCTSTR pszId,
  602. DWORD dwTransportId,
  603. LPCTSTR pszRmId,
  604. LPCTSTR pszIfId,
  605. DWORD dwIfType,
  606. RtrMgrInterfaceInfo *pRmIf);
  607. virtual ~RtrMgrProtocolInterfaceInfo();
  608. SRtrMgrProtocolInterfaceCB m_cb; // protocol control block
  609. protected:
  610. AdviseDataList m_AdviseList; // list of advises
  611. DWORD m_dwFlags;
  612. IRtrMgrInterfaceInfo * m_pRtrMgrInterfaceInfoParent;
  613. // Disconnect
  614. void Disconnect();
  615. // Overrides of CWeakRef functions
  616. virtual void OnLastStrongRef();
  617. virtual void ReviveStrongRef();
  618. // Critical section support
  619. CRITICAL_SECTION m_critsec;
  620. };
  621. #endif