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.

808 lines
21 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_TEXT_INTERVAL,
  367. IDC_RIG_SPIN_INTERVAL,
  368. IDC_RIG_EDIT_INTERVAL,
  369. IDC_RIG_TEXT_MULTIPLIER,
  370. IDC_RIG_SPIN_MULTIPLIER,
  371. IDC_RIG_EDIT_MULTIPLIER,
  372. 0);
  373. SetDirty(TRUE);
  374. SetModified();
  375. }
  376. void RipInterfacePageGeneral::OnChangeEdit()
  377. {
  378. SetDirty(TRUE);
  379. SetModified();
  380. }
  381. void RipInterfacePageGeneral::ShowFilter(BOOL fOutputFilter)
  382. {
  383. AFX_MANAGE_STATE(AfxGetStaticModuleState());
  384. SPIInfoBase spInfoBase;
  385. RIP_IF_CONFIG * pic;
  386. HRESULT hr = hrOK;
  387. m_pRipIfPropSheet->GetInfoBase(&spInfoBase);
  388. CRouteFltDlg dlgFlt (fOutputFilter /* bOutputDlg */, spInfoBase, this);
  389. // Need to grab the Rip IF config struct out of the
  390. // infobase
  391. if (m_spIf)
  392. dlgFlt.m_sIfName = m_spIf->GetTitle();
  393. else
  394. dlgFlt.m_sIfName.LoadString(IDS_IPX_DIAL_IN_CLIENTS);
  395. try
  396. {
  397. if (dlgFlt.DoModal () == IDOK)
  398. {
  399. SetDirty(TRUE);
  400. SetModified();
  401. }
  402. }
  403. catch (CException *ex) {
  404. ex->ReportError ();
  405. ex->Delete ();
  406. }
  407. return;
  408. }
  409. void RipInterfacePageGeneral::OnInputFilter()
  410. {
  411. ShowFilter(FALSE);
  412. }
  413. void RipInterfacePageGeneral::OnOutputFilter()
  414. {
  415. ShowFilter(TRUE);
  416. }
  417. /*!--------------------------------------------------------------------------
  418. RipInterfacePageGeneral::OnApply
  419. -
  420. Author: KennT
  421. ---------------------------------------------------------------------------*/
  422. BOOL RipInterfacePageGeneral::OnApply()
  423. {
  424. BOOL fReturn;
  425. HRESULT hr = hrOK;
  426. INT i, item;
  427. RIP_IF_CONFIG * pic;
  428. SPIInfoBase spInfoBase;
  429. if ( m_pRipIfPropSheet->IsCancel() )
  430. {
  431. CancelApply();
  432. return TRUE;
  433. }
  434. m_pRipIfPropSheet->GetInfoBase(&spInfoBase);
  435. CORg( spInfoBase->GetData(IPX_PROTOCOL_RIP, 0, (PBYTE *) &pic) );
  436. // Save the admin state
  437. pic->RipIfInfo.AdminState = IsDlgButtonChecked(IDC_RIG_BTN_ADMIN_STATE) ?
  438. ADMIN_STATE_ENABLED : ADMIN_STATE_DISABLED;
  439. // Save the advertise routes
  440. pic->RipIfInfo.Supply = IsDlgButtonChecked(IDC_RIG_BTN_ADVERTISE_ROUTES) ?
  441. ADMIN_STATE_ENABLED : ADMIN_STATE_DISABLED;
  442. // Save the accept route ads
  443. pic->RipIfInfo.Listen = IsDlgButtonChecked(IDC_RIG_BTN_ACCEPT_ROUTE_ADS) ?
  444. ADMIN_STATE_ENABLED : ADMIN_STATE_DISABLED;
  445. // Save the update mode
  446. if (IsDlgButtonChecked(IDC_RIG_BTN_UPDATE_MODE_STANDARD))
  447. {
  448. pic->RipIfInfo.UpdateMode = IPX_STANDARD_UPDATE;
  449. }
  450. else if (IsDlgButtonChecked(IDC_RIG_BTN_UPDATE_MODE_NONE))
  451. {
  452. pic->RipIfInfo.UpdateMode = IPX_NO_UPDATE;
  453. }
  454. else
  455. pic->RipIfInfo.UpdateMode = IPX_AUTO_STATIC_UPDATE;
  456. // Save the interval and multiplier
  457. pic->RipIfInfo.PeriodicUpdateInterval = m_spinInterval.GetPos();
  458. pic->RipIfInfo.AgeIntervalMultiplier = m_spinMultiplier.GetPos();
  459. fReturn = RtrPropertyPage::OnApply();
  460. Error:
  461. if (!FHrSucceeded(hr))
  462. fReturn = FALSE;
  463. return fReturn;
  464. }
  465. /*---------------------------------------------------------------------------
  466. RipInterfaceProperties implementation
  467. ---------------------------------------------------------------------------*/
  468. RipInterfaceProperties::RipInterfaceProperties(ITFSNode *pNode,
  469. IComponentData *pComponentData,
  470. ITFSComponentData *pTFSCompData,
  471. LPCTSTR pszSheetName,
  472. CWnd *pParent,
  473. UINT iPage,
  474. BOOL fScopePane)
  475. : RtrPropertySheet(pNode, pComponentData, pTFSCompData,
  476. pszSheetName, pParent, iPage, fScopePane),
  477. m_pageGeneral(IDD_RIP_INTERFACE_GENERAL_PAGE),
  478. m_bNewInterface(FALSE)
  479. {
  480. m_spNode.Set(pNode);
  481. }
  482. /*!--------------------------------------------------------------------------
  483. RipInterfaceProperties::Init
  484. Initialize the property sheets. The general action here will be
  485. to initialize/add the various pages.
  486. Author: KennT
  487. ---------------------------------------------------------------------------*/
  488. HRESULT RipInterfaceProperties::Init(IInterfaceInfo *pIf,
  489. IRtrMgrInfo *pRm)
  490. {
  491. Assert(pRm);
  492. HRESULT hr = hrOK;
  493. IPXConnection * pIPXConn;
  494. SPITFSNode spParent;
  495. m_spRm.Set(pRm);
  496. m_spIf.Set(pIf);
  497. if (pIf)
  498. CORg( pIf->FindRtrMgrInterface(PID_IPX, &m_spRmIf) );
  499. m_spNode->GetParent(&spParent);
  500. Assert(spParent);
  501. // The pages are embedded members of the class
  502. // do not delete them.
  503. m_bAutoDeletePages = FALSE;
  504. // Do this here, because the init is called in the context
  505. // of the main thread
  506. pIPXConn = GET_RIP_NODEDATA(spParent);
  507. CORg( LoadInfoBase(pIPXConn) );
  508. m_pageGeneral.Init(this, m_spIf);
  509. AddPageToList((CPropertyPageBase*) &m_pageGeneral);
  510. Error:
  511. return hr;
  512. }
  513. /*!--------------------------------------------------------------------------
  514. RipInterfaceProperties::SaveSheetData
  515. -
  516. Author: KennT
  517. ---------------------------------------------------------------------------*/
  518. BOOL RipInterfaceProperties::SaveSheetData()
  519. {
  520. SPITFSNodeHandler spHandler;
  521. SPITFSNode spParent;
  522. Assert(m_spRm);
  523. BaseIPXResultNodeData * pNodeData;
  524. RIP_IF_CONFIG * pic;
  525. if (m_spInfoBase)
  526. {
  527. if (m_bClientInfoBase)
  528. {
  529. Assert(m_spRm);
  530. m_spRm->Save(m_spRm->GetMachineName(), 0, 0, NULL,
  531. m_spInfoBase, 0);
  532. }
  533. else
  534. {
  535. Assert(m_spRmIf);
  536. m_spRmIf->Save(m_spIf->GetMachineName(),
  537. NULL, NULL, NULL, m_spInfoBase, 0);
  538. }
  539. }
  540. if (m_bNewInterface)
  541. {
  542. m_spNode->SetVisibilityState(TFS_VIS_SHOW);
  543. m_spNode->Show();
  544. }
  545. // Force the node to do a resync
  546. m_spNode->GetParent(&spParent);
  547. spParent->GetHandler(&spHandler);
  548. spHandler->OnCommand(spParent, IDS_MENU_SYNC, CCT_RESULT,
  549. NULL, 0);
  550. // Windows NT Bugs : 133891, we have added this to the UI
  551. // we no longer consider this a new interface
  552. m_bNewInterface = FALSE;
  553. return TRUE;
  554. }
  555. /*!--------------------------------------------------------------------------
  556. RipInterfaceProperties::CancelSheetData
  557. -
  558. Author: KennT
  559. ---------------------------------------------------------------------------*/
  560. void RipInterfaceProperties::CancelSheetData()
  561. {
  562. if (m_bNewInterface && m_bClientInfoBase)
  563. {
  564. m_spNode->SetVisibilityState(TFS_VIS_DELETE);
  565. m_spRmIf->DeleteRtrMgrProtocolInterface(IPX_PROTOCOL_RIP, TRUE);
  566. }
  567. }
  568. /*!--------------------------------------------------------------------------
  569. RipInterfaceProperties::LoadInfoBase
  570. -
  571. Author: KennT
  572. ---------------------------------------------------------------------------*/
  573. HRESULT RipInterfaceProperties::LoadInfoBase(IPXConnection *pIPXConn)
  574. {
  575. Assert(pIPXConn);
  576. HRESULT hr = hrOK;
  577. HANDLE hTransport = NULL;
  578. LPCOLESTR pszInterfaceId = NULL;
  579. SPIInfoBase spInfoBase;
  580. BYTE * pDefault;
  581. // If configuring the client-interface, load the client-interface info,
  582. // otherwise, retrieve the interface being configured and load
  583. // its info.
  584. // The client interface doesn't have an ID
  585. if (m_spIf)
  586. pszInterfaceId = m_spIf->GetId();
  587. if (StrLenW(pszInterfaceId) == 0)
  588. {
  589. Assert(m_spRm);
  590. // Get the transport handle
  591. CWRg( ::MprConfigTransportGetHandle(pIPXConn->GetConfigHandle(),
  592. PID_IPX,
  593. &hTransport) );
  594. // Load the client interface info
  595. CORg( m_spRm->GetInfoBase(pIPXConn->GetConfigHandle(),
  596. hTransport,
  597. NULL,
  598. &spInfoBase) );
  599. m_bClientInfoBase = TRUE;
  600. }
  601. else
  602. {
  603. Assert(m_spRmIf);
  604. //
  605. // The parameters are all NULL so that we can use the
  606. // default RPC handles.
  607. //
  608. m_spRmIf->GetInfoBase(NULL, NULL, NULL, &spInfoBase);
  609. m_bClientInfoBase = FALSE;
  610. }
  611. if (!spInfoBase)
  612. {
  613. // No info was found for the inteface
  614. // allocate a new InfoBase instead
  615. CORg( CreateInfoBase(&spInfoBase) );
  616. }
  617. //
  618. // Check that there is a block for interface-status in the info,
  619. // and insert the default block if none is found.
  620. //
  621. if (spInfoBase->ProtocolExists(IPX_PROTOCOL_RIP) == hrFalse)
  622. {
  623. RIP_IF_CONFIG ric;
  624. // Setup the defaults for an interface
  625. if (m_spIf &&
  626. (m_spIf->GetInterfaceType() == ROUTER_IF_TYPE_DEDICATED))
  627. pDefault = g_pIpxRipLanInterfaceDefault;
  628. else
  629. pDefault = g_pIpxRipInterfaceDefault;
  630. CORg( spInfoBase->AddBlock(IPX_PROTOCOL_RIP,
  631. sizeof(RIP_IF_CONFIG),
  632. pDefault,
  633. 1 /* count */,
  634. TRUE /* bRemoveFirst */) );
  635. m_bNewInterface = TRUE;
  636. }
  637. m_spInfoBase.Set(spInfoBase);
  638. Error:
  639. return hr;
  640. }
  641. /*!--------------------------------------------------------------------------
  642. RipInterfaceProperties::GetInfoBase
  643. -
  644. Author: KennT
  645. ---------------------------------------------------------------------------*/
  646. HRESULT RipInterfaceProperties::GetInfoBase(IInfoBase **ppGlobalInfo)
  647. {
  648. *ppGlobalInfo = m_spInfoBase;
  649. if (*ppGlobalInfo)
  650. (*ppGlobalInfo)->AddRef();
  651. return hrOK;
  652. }