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.

806 lines
20 KiB

  1. /**********************************************************************/
  2. /** Microsoft Windows/NT **/
  3. /** Copyright(c) Microsoft Corporation, 1997 - 1999 **/
  4. /**********************************************************************/
  5. /*
  6. ripprop.cpp
  7. Dhcp Relay node property sheet and property pages
  8. FILE HISTORY:
  9. */
  10. #include "stdafx.h"
  11. #include "rtrutil.h" // smart MPR handle pointers
  12. #include "format.h" // FormatNumber function
  13. #include "ripprop.h"
  14. #include "ripview.h"
  15. #include "ipxutil.h" // RipModeToCString
  16. #include "ipxconn.h"
  17. #include "globals.h" // IPX defaults
  18. #include "rtfltdlg.h" // RouteFilterDlg
  19. extern "C"
  20. {
  21. #include "routprot.h"
  22. };
  23. /*---------------------------------------------------------------------------
  24. RipPageGeneral
  25. ---------------------------------------------------------------------------*/
  26. BEGIN_MESSAGE_MAP(RipPageGeneral, RtrPropertyPage)
  27. //{{AFX_MSG_MAP(RipPageGeneral)
  28. ON_BN_CLICKED(IDC_RGG_BTN_LOG_ERROR, OnButtonClicked)
  29. ON_BN_CLICKED(IDC_RGG_BTN_LOG_INFO, OnButtonClicked)
  30. ON_BN_CLICKED(IDC_RGG_BTN_LOG_NONE, OnButtonClicked)
  31. ON_BN_CLICKED(IDC_RGG_BTN_LOG_WARN, OnButtonClicked)
  32. //}}AFX_MSG_MAP
  33. END_MESSAGE_MAP()
  34. /*!--------------------------------------------------------------------------
  35. RipPageGeneral::Init
  36. -
  37. Author: KennT
  38. ---------------------------------------------------------------------------*/
  39. HRESULT RipPageGeneral::Init(RipProperties *pPropSheet)
  40. {
  41. m_pRipPropSheet = pPropSheet;
  42. return hrOK;
  43. }
  44. /*!--------------------------------------------------------------------------
  45. RipPageGeneral::OnInitDialog
  46. -
  47. Author: KennT
  48. ---------------------------------------------------------------------------*/
  49. BOOL RipPageGeneral::OnInitDialog()
  50. {
  51. HRESULT hr= hrOK;
  52. SPIInfoBase spInfoBase;
  53. RIP_GLOBAL_INFO* pGlobal;
  54. DWORD * pdw;
  55. int i;
  56. RtrPropertyPage::OnInitDialog();
  57. //
  58. // Load the existing global-config
  59. //
  60. CORg( m_pRipPropSheet->GetInfoBase(&spInfoBase) );
  61. //
  62. // Retrieve the IPRIP block from the global-config
  63. //
  64. CORg( spInfoBase->GetData(IPX_PROTOCOL_RIP, 0, (PBYTE *) &pGlobal) );
  65. //
  66. // Initialize the error-level buttons
  67. //
  68. SetErrorLevelButtons(pGlobal->EventLogMask);
  69. SetDirty(FALSE);
  70. Error:
  71. if (!FHrSucceeded(hr))
  72. Cancel();
  73. return FHrSucceeded(hr) ? TRUE : FALSE;
  74. }
  75. /*!--------------------------------------------------------------------------
  76. RipPageGeneral::DoDataExchange
  77. -
  78. Author: KennT
  79. ---------------------------------------------------------------------------*/
  80. void RipPageGeneral::DoDataExchange(CDataExchange *pDX)
  81. {
  82. RtrPropertyPage::DoDataExchange(pDX);
  83. //{{AFX_DATA_MAP(RipPageGeneral)
  84. //}}AFX_DATA_MAP
  85. }
  86. /*!--------------------------------------------------------------------------
  87. RipPageGeneral::OnApply
  88. -
  89. Author: KennT
  90. ---------------------------------------------------------------------------*/
  91. BOOL RipPageGeneral::OnApply()
  92. {
  93. BOOL fReturn;
  94. HRESULT hr = hrOK;
  95. RIP_GLOBAL_INFO * prgi;
  96. SPIInfoBase spInfoBase;
  97. if ( m_pRipPropSheet->IsCancel() )
  98. {
  99. CancelApply();
  100. return TRUE;
  101. }
  102. m_pRipPropSheet->GetInfoBase(&spInfoBase);
  103. // Retrieve the existing IPRIP block from the global-config
  104. CORg( spInfoBase->GetData(IPX_PROTOCOL_RIP, 0, (BYTE **) &prgi) );
  105. // Save the error level
  106. prgi->EventLogMask = QueryErrorLevelButtons();
  107. fReturn = RtrPropertyPage::OnApply();
  108. Error:
  109. if (!FHrSucceeded(hr))
  110. fReturn = FALSE;
  111. return fReturn;
  112. }
  113. void RipPageGeneral::SetErrorLevelButtons(DWORD dwErrorLevel)
  114. {
  115. switch (dwErrorLevel)
  116. {
  117. case 0:
  118. CheckDlgButton(IDC_RGG_BTN_LOG_NONE, TRUE);
  119. break;
  120. case EVENTLOG_ERROR_TYPE:
  121. CheckDlgButton(IDC_RGG_BTN_LOG_ERROR, TRUE);
  122. break;
  123. case EVENTLOG_ERROR_TYPE | EVENTLOG_WARNING_TYPE:
  124. CheckDlgButton(IDC_RGG_BTN_LOG_WARN, TRUE);
  125. break;
  126. case EVENTLOG_ERROR_TYPE | EVENTLOG_WARNING_TYPE | EVENTLOG_INFORMATION_TYPE:
  127. default:
  128. CheckDlgButton(IDC_RGG_BTN_LOG_INFO, TRUE);
  129. break;
  130. }
  131. }
  132. DWORD RipPageGeneral::QueryErrorLevelButtons()
  133. {
  134. if (IsDlgButtonChecked(IDC_RGG_BTN_LOG_INFO))
  135. return EVENTLOG_INFORMATION_TYPE |
  136. EVENTLOG_WARNING_TYPE |
  137. EVENTLOG_ERROR_TYPE;
  138. else if (IsDlgButtonChecked(IDC_RGG_BTN_LOG_WARN))
  139. return EVENTLOG_WARNING_TYPE |
  140. EVENTLOG_ERROR_TYPE;
  141. else if (IsDlgButtonChecked(IDC_RGG_BTN_LOG_ERROR))
  142. return EVENTLOG_ERROR_TYPE;
  143. else
  144. return 0;
  145. }
  146. void RipPageGeneral::OnButtonClicked()
  147. {
  148. SetDirty(TRUE);
  149. SetModified();
  150. }
  151. /*---------------------------------------------------------------------------
  152. RipProperties implementation
  153. ---------------------------------------------------------------------------*/
  154. RipProperties::RipProperties(ITFSNode *pNode,
  155. IComponentData *pComponentData,
  156. ITFSComponentData *pTFSCompData,
  157. LPCTSTR pszSheetName,
  158. CWnd *pParent,
  159. UINT iPage,
  160. BOOL fScopePane)
  161. : RtrPropertySheet(pNode, pComponentData, pTFSCompData,
  162. pszSheetName, pParent, iPage, fScopePane),
  163. m_pageGeneral(IDD_RIP_GLOBAL_GENERAL_PAGE)
  164. {
  165. m_spNode.Set(pNode);
  166. }
  167. /*!--------------------------------------------------------------------------
  168. RipProperties::Init
  169. Initialize the property sheets. The general action here will be
  170. to initialize/add the various pages.
  171. Author: KennT
  172. ---------------------------------------------------------------------------*/
  173. HRESULT RipProperties::Init(IRtrMgrInfo *pRm)
  174. {
  175. Assert(pRm);
  176. HRESULT hr = hrOK;
  177. IPXConnection * pIPXConn;
  178. m_spRm.Set(pRm);
  179. pIPXConn = GET_RIP_NODEDATA(m_spNode);
  180. // The pages are embedded members of the class
  181. // do not delete them.
  182. m_bAutoDeletePages = FALSE;
  183. // Do this here, because the init is called in the context
  184. // of the main thread
  185. CORg( LoadInfoBase(pIPXConn) );
  186. m_pageGeneral.Init(this);
  187. AddPageToList((CPropertyPageBase*) &m_pageGeneral);
  188. Error:
  189. return hr;
  190. }
  191. /*!--------------------------------------------------------------------------
  192. RipProperties::SaveSheetData
  193. -
  194. Author: KennT
  195. ---------------------------------------------------------------------------*/
  196. BOOL RipProperties::SaveSheetData()
  197. {
  198. Assert(m_spRm);
  199. // Save the global info
  200. // We don't need to pass in the hMachine, hTransport since they
  201. // got set up in the Load call.
  202. m_spRm->Save(m_spRm->GetMachineName(),
  203. 0, 0, m_spInfoBase, NULL, 0);
  204. return TRUE;
  205. }
  206. /*!--------------------------------------------------------------------------
  207. RipProperties::LoadInfoBase
  208. -
  209. Author: KennT
  210. ---------------------------------------------------------------------------*/
  211. HRESULT RipProperties::LoadInfoBase(IPXConnection *pIPXConn)
  212. {
  213. Assert(pIPXConn);
  214. HRESULT hr = hrOK;
  215. HANDLE hTransport = NULL;
  216. SPIInfoBase spInfoBase;
  217. // Get the transport handle
  218. CWRg( ::MprConfigTransportGetHandle(pIPXConn->GetConfigHandle(),
  219. PID_IPX,
  220. &hTransport) );
  221. CORg( m_spRm->GetInfoBase(pIPXConn->GetConfigHandle(),
  222. hTransport, &spInfoBase, NULL) );
  223. Assert(spInfoBase);
  224. // Retrieve the current block for IP_RIP
  225. // Adding the default block if none is found.
  226. if (!FHrOK(spInfoBase->ProtocolExists(IPX_PROTOCOL_RIP)))
  227. {
  228. RIP_GLOBAL_INFO rgi;
  229. rgi.EventLogMask = EVENTLOG_ERROR_TYPE;
  230. CORg( spInfoBase->AddBlock(IPX_PROTOCOL_RIP,
  231. sizeof(rgi),
  232. (PBYTE) &rgi, 1, TRUE) );
  233. }
  234. m_spInfoBase = spInfoBase.Transfer();
  235. Error:
  236. return hr;
  237. }
  238. /*!--------------------------------------------------------------------------
  239. RipProperties::GetInfoBase
  240. -
  241. Author: KennT
  242. ---------------------------------------------------------------------------*/
  243. HRESULT RipProperties::GetInfoBase(IInfoBase **ppGlobalInfo)
  244. {
  245. *ppGlobalInfo = m_spInfoBase;
  246. if (*ppGlobalInfo)
  247. (*ppGlobalInfo)->AddRef();
  248. return hrOK;
  249. }
  250. /*---------------------------------------------------------------------------
  251. RipInterfacePageGeneral
  252. ---------------------------------------------------------------------------*/
  253. BEGIN_MESSAGE_MAP(RipInterfacePageGeneral, RtrPropertyPage)
  254. //{{AFX_MSG_MAP(RipInterfacePageGeneral)
  255. ON_BN_CLICKED(IDC_RIG_BTN_ADMIN_STATE, OnButtonClicked)
  256. ON_BN_CLICKED(IDC_RIG_BTN_ADVERTISE_ROUTES, OnButtonClicked)
  257. ON_BN_CLICKED(IDC_RIG_BTN_ACCEPT_ROUTE_ADS, OnButtonClicked)
  258. ON_BN_CLICKED(IDC_RIG_BTN_UPDATE_MODE_STANDARD, OnUpdateButtonClicked)
  259. ON_BN_CLICKED(IDC_RIG_BTN_UPDATE_MODE_NONE, OnUpdateButtonClicked)
  260. ON_BN_CLICKED(IDC_RIG_BTN_UPDATE_MODE_AUTOSTATIC, OnUpdateButtonClicked)
  261. ON_BN_CLICKED(IDC_RIG_BTN_INPUT_FILTERS, OnInputFilter)
  262. ON_BN_CLICKED(IDC_RIG_BTN_OUTPUT_FILTERS, OnOutputFilter)
  263. ON_EN_CHANGE(IDC_RIG_EDIT_INTERVAL, OnChangeEdit)
  264. ON_EN_CHANGE(IDC_RIG_EDIT_MULTIPLIER, OnChangeEdit)
  265. //}}AFX_MSG_MAP
  266. END_MESSAGE_MAP()
  267. void RipInterfacePageGeneral::DoDataExchange(CDataExchange *pDX)
  268. {
  269. RtrPropertyPage::DoDataExchange(pDX);
  270. //{{AFX_DATA_MAP(RipInterfacePageGeneral)
  271. DDX_Control(pDX, IDC_RIG_SPIN_INTERVAL, m_spinInterval);
  272. DDX_Control(pDX, IDC_RIG_SPIN_MULTIPLIER, m_spinMultiplier);
  273. //}}AFX_DATA_MAP
  274. }
  275. /*!--------------------------------------------------------------------------
  276. RipInterfacePageGeneral::Init
  277. -
  278. Author: KennT
  279. ---------------------------------------------------------------------------*/
  280. HRESULT RipInterfacePageGeneral::Init(RipInterfaceProperties *pPropSheet,
  281. IInterfaceInfo *pIf)
  282. {
  283. m_pRipIfPropSheet = pPropSheet;
  284. m_spIf.Set(pIf);
  285. return hrOK;
  286. }
  287. /*!--------------------------------------------------------------------------
  288. RipInterfacePageGeneral::OnInitDialog
  289. -
  290. Author: KennT
  291. ---------------------------------------------------------------------------*/
  292. BOOL RipInterfacePageGeneral::OnInitDialog()
  293. {
  294. HRESULT hr= hrOK;
  295. SPIInfoBase spInfoBase;
  296. RIP_IF_CONFIG* pIfConfig;
  297. int i, count, item;
  298. CString sItem;
  299. RtrPropertyPage::OnInitDialog();
  300. //
  301. // Initialize controls
  302. //
  303. m_spinInterval.SetRange(0, 32767);
  304. m_spinInterval.SetBuddy(GetDlgItem(IDC_RIG_EDIT_INTERVAL));
  305. m_spinMultiplier.SetRange(0, 32767);
  306. m_spinMultiplier.SetBuddy(GetDlgItem(IDC_RIG_EDIT_MULTIPLIER));
  307. //
  308. // Load the existing global-config
  309. //
  310. CORg( m_pRipIfPropSheet->GetInfoBase(&spInfoBase) );
  311. //
  312. // Retrieve the IPRIP block from the global-config
  313. //
  314. CORg( spInfoBase->GetData(IPX_PROTOCOL_RIP, 0, (PBYTE *) &pIfConfig) );
  315. //
  316. // Set the spin-controls
  317. //
  318. m_spinInterval.SetPos(pIfConfig->RipIfInfo.PeriodicUpdateInterval);
  319. m_spinMultiplier.SetPos(pIfConfig->RipIfInfo.AgeIntervalMultiplier);
  320. CheckDlgButton(IDC_RIG_BTN_ADMIN_STATE,
  321. pIfConfig->RipIfInfo.AdminState == ADMIN_STATE_ENABLED);
  322. CheckDlgButton(IDC_RIG_BTN_ADVERTISE_ROUTES,
  323. pIfConfig->RipIfInfo.Supply == ADMIN_STATE_ENABLED);
  324. CheckDlgButton(IDC_RIG_BTN_ACCEPT_ROUTE_ADS,
  325. pIfConfig->RipIfInfo.Listen == ADMIN_STATE_ENABLED);
  326. switch (pIfConfig->RipIfInfo.UpdateMode)
  327. {
  328. case IPX_STANDARD_UPDATE:
  329. CheckDlgButton(IDC_RIG_BTN_UPDATE_MODE_STANDARD, TRUE);
  330. break;
  331. case IPX_NO_UPDATE:
  332. CheckDlgButton(IDC_RIG_BTN_UPDATE_MODE_NONE, TRUE);
  333. break;
  334. case IPX_AUTO_STATIC_UPDATE:
  335. CheckDlgButton(IDC_RIG_BTN_UPDATE_MODE_AUTOSTATIC, TRUE);
  336. break;
  337. default:
  338. break;
  339. }
  340. OnUpdateButtonClicked();
  341. // If this is a new interface, we need to force the change
  342. // through if the user hits ok.
  343. SetDirty(m_pRipIfPropSheet->m_bNewInterface ? TRUE : FALSE);
  344. Error:
  345. if (!FHrSucceeded(hr))
  346. Cancel();
  347. return FHrSucceeded(hr) ? TRUE : FALSE;
  348. }
  349. void RipInterfacePageGeneral::OnButtonClicked()
  350. {
  351. SetDirty(TRUE);
  352. SetModified();
  353. }
  354. void RipInterfacePageGeneral::OnUpdateButtonClicked()
  355. {
  356. BOOL fStandard = IsDlgButtonChecked(IDC_RIG_BTN_UPDATE_MODE_STANDARD);
  357. if (fStandard &&
  358. (m_spinInterval.GetPos() == 0) &&
  359. (m_spinMultiplier.GetPos() == 0))
  360. {
  361. m_spinInterval.SetPos(IPX_UPDATE_INTERVAL_DEFVAL);
  362. m_spinMultiplier.SetPos(3);
  363. }
  364. MultiEnableWindow(GetSafeHwnd(),
  365. fStandard,
  366. IDC_RIG_SPIN_INTERVAL,
  367. IDC_RIG_EDIT_INTERVAL,
  368. IDC_RIG_SPIN_MULTIPLIER,
  369. IDC_RIG_EDIT_MULTIPLIER,
  370. 0);
  371. SetDirty(TRUE);
  372. SetModified();
  373. }
  374. void RipInterfacePageGeneral::OnChangeEdit()
  375. {
  376. SetDirty(TRUE);
  377. SetModified();
  378. }
  379. void RipInterfacePageGeneral::ShowFilter(BOOL fOutputFilter)
  380. {
  381. AFX_MANAGE_STATE(AfxGetStaticModuleState());
  382. SPIInfoBase spInfoBase;
  383. RIP_IF_CONFIG * pic;
  384. HRESULT hr = hrOK;
  385. m_pRipIfPropSheet->GetInfoBase(&spInfoBase);
  386. CRouteFltDlg dlgFlt (fOutputFilter /* bOutputDlg */, spInfoBase, this);
  387. // Need to grab the Rip IF config struct out of the
  388. // infobase
  389. if (m_spIf)
  390. dlgFlt.m_sIfName = m_spIf->GetTitle();
  391. else
  392. dlgFlt.m_sIfName.LoadString(IDS_IPX_DIAL_IN_CLIENTS);
  393. try
  394. {
  395. if (dlgFlt.DoModal () == IDOK)
  396. {
  397. SetDirty(TRUE);
  398. SetModified();
  399. }
  400. }
  401. catch (CException *ex) {
  402. ex->ReportError ();
  403. ex->Delete ();
  404. }
  405. return;
  406. }
  407. void RipInterfacePageGeneral::OnInputFilter()
  408. {
  409. ShowFilter(FALSE);
  410. }
  411. void RipInterfacePageGeneral::OnOutputFilter()
  412. {
  413. ShowFilter(TRUE);
  414. }
  415. /*!--------------------------------------------------------------------------
  416. RipInterfacePageGeneral::OnApply
  417. -
  418. Author: KennT
  419. ---------------------------------------------------------------------------*/
  420. BOOL RipInterfacePageGeneral::OnApply()
  421. {
  422. BOOL fReturn;
  423. HRESULT hr = hrOK;
  424. INT i, item;
  425. RIP_IF_CONFIG * pic;
  426. SPIInfoBase spInfoBase;
  427. if ( m_pRipIfPropSheet->IsCancel() )
  428. {
  429. CancelApply();
  430. return TRUE;
  431. }
  432. m_pRipIfPropSheet->GetInfoBase(&spInfoBase);
  433. CORg( spInfoBase->GetData(IPX_PROTOCOL_RIP, 0, (PBYTE *) &pic) );
  434. // Save the admin state
  435. pic->RipIfInfo.AdminState = IsDlgButtonChecked(IDC_RIG_BTN_ADMIN_STATE) ?
  436. ADMIN_STATE_ENABLED : ADMIN_STATE_DISABLED;
  437. // Save the advertise routes
  438. pic->RipIfInfo.Supply = IsDlgButtonChecked(IDC_RIG_BTN_ADVERTISE_ROUTES) ?
  439. ADMIN_STATE_ENABLED : ADMIN_STATE_DISABLED;
  440. // Save the accept route ads
  441. pic->RipIfInfo.Listen = IsDlgButtonChecked(IDC_RIG_BTN_ACCEPT_ROUTE_ADS) ?
  442. ADMIN_STATE_ENABLED : ADMIN_STATE_DISABLED;
  443. // Save the update mode
  444. if (IsDlgButtonChecked(IDC_RIG_BTN_UPDATE_MODE_STANDARD))
  445. {
  446. pic->RipIfInfo.UpdateMode = IPX_STANDARD_UPDATE;
  447. }
  448. else if (IsDlgButtonChecked(IDC_RIG_BTN_UPDATE_MODE_NONE))
  449. {
  450. pic->RipIfInfo.UpdateMode = IPX_NO_UPDATE;
  451. }
  452. else
  453. pic->RipIfInfo.UpdateMode = IPX_AUTO_STATIC_UPDATE;
  454. // Save the interval and multiplier
  455. pic->RipIfInfo.PeriodicUpdateInterval = m_spinInterval.GetPos();
  456. pic->RipIfInfo.AgeIntervalMultiplier = m_spinMultiplier.GetPos();
  457. fReturn = RtrPropertyPage::OnApply();
  458. Error:
  459. if (!FHrSucceeded(hr))
  460. fReturn = FALSE;
  461. return fReturn;
  462. }
  463. /*---------------------------------------------------------------------------
  464. RipInterfaceProperties implementation
  465. ---------------------------------------------------------------------------*/
  466. RipInterfaceProperties::RipInterfaceProperties(ITFSNode *pNode,
  467. IComponentData *pComponentData,
  468. ITFSComponentData *pTFSCompData,
  469. LPCTSTR pszSheetName,
  470. CWnd *pParent,
  471. UINT iPage,
  472. BOOL fScopePane)
  473. : RtrPropertySheet(pNode, pComponentData, pTFSCompData,
  474. pszSheetName, pParent, iPage, fScopePane),
  475. m_pageGeneral(IDD_RIP_INTERFACE_GENERAL_PAGE),
  476. m_bNewInterface(FALSE)
  477. {
  478. m_spNode.Set(pNode);
  479. }
  480. /*!--------------------------------------------------------------------------
  481. RipInterfaceProperties::Init
  482. Initialize the property sheets. The general action here will be
  483. to initialize/add the various pages.
  484. Author: KennT
  485. ---------------------------------------------------------------------------*/
  486. HRESULT RipInterfaceProperties::Init(IInterfaceInfo *pIf,
  487. IRtrMgrInfo *pRm)
  488. {
  489. Assert(pRm);
  490. HRESULT hr = hrOK;
  491. IPXConnection * pIPXConn;
  492. SPITFSNode spParent;
  493. m_spRm.Set(pRm);
  494. m_spIf.Set(pIf);
  495. if (pIf)
  496. CORg( pIf->FindRtrMgrInterface(PID_IPX, &m_spRmIf) );
  497. m_spNode->GetParent(&spParent);
  498. Assert(spParent);
  499. // The pages are embedded members of the class
  500. // do not delete them.
  501. m_bAutoDeletePages = FALSE;
  502. // Do this here, because the init is called in the context
  503. // of the main thread
  504. pIPXConn = GET_RIP_NODEDATA(spParent);
  505. CORg( LoadInfoBase(pIPXConn) );
  506. m_pageGeneral.Init(this, m_spIf);
  507. AddPageToList((CPropertyPageBase*) &m_pageGeneral);
  508. Error:
  509. return hr;
  510. }
  511. /*!--------------------------------------------------------------------------
  512. RipInterfaceProperties::SaveSheetData
  513. -
  514. Author: KennT
  515. ---------------------------------------------------------------------------*/
  516. BOOL RipInterfaceProperties::SaveSheetData()
  517. {
  518. SPITFSNodeHandler spHandler;
  519. SPITFSNode spParent;
  520. Assert(m_spRm);
  521. BaseIPXResultNodeData * pNodeData;
  522. RIP_IF_CONFIG * pic;
  523. if (m_spInfoBase)
  524. {
  525. if (m_bClientInfoBase)
  526. {
  527. Assert(m_spRm);
  528. m_spRm->Save(m_spRm->GetMachineName(), 0, 0, NULL,
  529. m_spInfoBase, 0);
  530. }
  531. else
  532. {
  533. Assert(m_spRmIf);
  534. m_spRmIf->Save(m_spIf->GetMachineName(),
  535. NULL, NULL, NULL, m_spInfoBase, 0);
  536. }
  537. }
  538. if (m_bNewInterface)
  539. {
  540. m_spNode->SetVisibilityState(TFS_VIS_SHOW);
  541. m_spNode->Show();
  542. }
  543. // Force the node to do a resync
  544. m_spNode->GetParent(&spParent);
  545. spParent->GetHandler(&spHandler);
  546. spHandler->OnCommand(spParent, IDS_MENU_SYNC, CCT_RESULT,
  547. NULL, 0);
  548. // Windows NT Bugs : 133891, we have added this to the UI
  549. // we no longer consider this a new interface
  550. m_bNewInterface = FALSE;
  551. return TRUE;
  552. }
  553. /*!--------------------------------------------------------------------------
  554. RipInterfaceProperties::CancelSheetData
  555. -
  556. Author: KennT
  557. ---------------------------------------------------------------------------*/
  558. void RipInterfaceProperties::CancelSheetData()
  559. {
  560. if (m_bNewInterface && m_bClientInfoBase)
  561. {
  562. m_spNode->SetVisibilityState(TFS_VIS_DELETE);
  563. m_spRmIf->DeleteRtrMgrProtocolInterface(IPX_PROTOCOL_RIP, TRUE);
  564. }
  565. }
  566. /*!--------------------------------------------------------------------------
  567. RipInterfaceProperties::LoadInfoBase
  568. -
  569. Author: KennT
  570. ---------------------------------------------------------------------------*/
  571. HRESULT RipInterfaceProperties::LoadInfoBase(IPXConnection *pIPXConn)
  572. {
  573. Assert(pIPXConn);
  574. HRESULT hr = hrOK;
  575. HANDLE hTransport = NULL;
  576. LPCOLESTR pszInterfaceId = NULL;
  577. SPIInfoBase spInfoBase;
  578. BYTE * pDefault;
  579. // If configuring the client-interface, load the client-interface info,
  580. // otherwise, retrieve the interface being configured and load
  581. // its info.
  582. // The client interface doesn't have an ID
  583. if (m_spIf)
  584. pszInterfaceId = m_spIf->GetId();
  585. if (StrLenW(pszInterfaceId) == 0)
  586. {
  587. Assert(m_spRm);
  588. // Get the transport handle
  589. CWRg( ::MprConfigTransportGetHandle(pIPXConn->GetConfigHandle(),
  590. PID_IPX,
  591. &hTransport) );
  592. // Load the client interface info
  593. CORg( m_spRm->GetInfoBase(pIPXConn->GetConfigHandle(),
  594. hTransport,
  595. NULL,
  596. &spInfoBase) );
  597. m_bClientInfoBase = TRUE;
  598. }
  599. else
  600. {
  601. Assert(m_spRmIf);
  602. //
  603. // The parameters are all NULL so that we can use the
  604. // default RPC handles.
  605. //
  606. m_spRmIf->GetInfoBase(NULL, NULL, NULL, &spInfoBase);
  607. m_bClientInfoBase = FALSE;
  608. }
  609. if (!spInfoBase)
  610. {
  611. // No info was found for the inteface
  612. // allocate a new InfoBase instead
  613. CORg( CreateInfoBase(&spInfoBase) );
  614. }
  615. //
  616. // Check that there is a block for interface-status in the info,
  617. // and insert the default block if none is found.
  618. //
  619. if (spInfoBase->ProtocolExists(IPX_PROTOCOL_RIP) == hrFalse)
  620. {
  621. RIP_IF_CONFIG ric;
  622. // Setup the defaults for an interface
  623. if (m_spIf &&
  624. (m_spIf->GetInterfaceType() == ROUTER_IF_TYPE_DEDICATED))
  625. pDefault = g_pIpxRipLanInterfaceDefault;
  626. else
  627. pDefault = g_pIpxRipInterfaceDefault;
  628. CORg( spInfoBase->AddBlock(IPX_PROTOCOL_RIP,
  629. sizeof(RIP_IF_CONFIG),
  630. pDefault,
  631. 1 /* count */,
  632. TRUE /* bRemoveFirst */) );
  633. m_bNewInterface = TRUE;
  634. }
  635. m_spInfoBase.Set(spInfoBase);
  636. Error:
  637. return hr;
  638. }
  639. /*!--------------------------------------------------------------------------
  640. RipInterfaceProperties::GetInfoBase
  641. -
  642. Author: KennT
  643. ---------------------------------------------------------------------------*/
  644. HRESULT RipInterfaceProperties::GetInfoBase(IInfoBase **ppGlobalInfo)
  645. {
  646. *ppGlobalInfo = m_spInfoBase;
  647. if (*ppGlobalInfo)
  648. (*ppGlobalInfo)->AddRef();
  649. return hrOK;
  650. }