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.

132 lines
3.1 KiB

  1. //============================================================================
  2. // Copyright(c) 1996, Microsoft Corporation
  3. //
  4. // File: ipxcfg.cpp
  5. //
  6. // History:
  7. // 08/30/96 Ram Cherala Created
  8. //
  9. // Implementation of IPX Packet Filters Configuration
  10. //============================================================================
  11. // ipxcfg.cpp : Defines the initialization routines for the DLL.
  12. //
  13. #include "stdafx.h"
  14. #include "rtrfiltr.h"
  15. #include "ipxfltr.h"
  16. #include "format.h"
  17. #ifdef _DEBUG
  18. #define new DEBUG_NEW
  19. #undef THIS_FILE
  20. static char THIS_FILE[] = __FILE__;
  21. #endif
  22. DWORD APIENTRY
  23. IpxFilterConfig(
  24. IN CWnd* pParent,
  25. IN LPCWSTR pwsMachineName,
  26. IN LPCWSTR pwsInterfaceName,
  27. IN DWORD dwFilterType // FILTER_INBOUND, FILTER_OUTBOUND
  28. ) {
  29. DWORD dwErr;
  30. HANDLE hMprConfig = NULL, hInterface = NULL, hIfTransport = NULL;
  31. TCHAR* pszMachine;
  32. SPIRouterInfo spRouterInfo;
  33. SPIRtrMgrInterfaceInfo spRmIf;
  34. SPIInfoBase spInfoBase;
  35. HRESULT hr = hrOK;
  36. //
  37. // Convert the machine name from Unicode
  38. //
  39. if (!pwsMachineName) { pszMachine = NULL; }
  40. else {
  41. pszMachine = (TCHAR *) alloca((StrLenW(pwsMachineName)+3) * sizeof(TCHAR));
  42. StrCpyTFromW(pszMachine, pwsMachineName);
  43. }
  44. // Connect to the server first
  45. dwErr = ::MprConfigServerConnect((LPWSTR)pwsMachineName, &hMprConfig);
  46. if (dwErr != NO_ERROR) { return dwErr; }
  47. // create a CRouterInfo object
  48. CreateRouterInfo(&spRouterInfo, NULL, pwsMachineName);
  49. if (!spRouterInfo) { return ERROR_NOT_ENOUGH_MEMORY; }
  50. CWaitCursor wait;
  51. // Now load the RouterInfo data from the registry
  52. hr = spRouterInfo->Load((LPCTSTR)pszMachine, hMprConfig);
  53. if (!FHrSucceeded(hr)) { return WIN32_FROM_HRESULT(hr); }
  54. // Get the pointer to the CRmInterfaceInfo object for the specified
  55. // protocol and interface
  56. LookupRtrMgrInterface(spRouterInfo,
  57. pwsInterfaceName,
  58. PID_IPX,
  59. &spRmIf);
  60. if (!spRmIf) { return ERROR_INVALID_DATA ;}
  61. // Load the data for the specified interface
  62. hr = spRmIf->Load(pszMachine, hMprConfig, NULL, NULL);
  63. if (!FHrSucceeded(hr)) { return WIN32_FROM_HRESULT(hr); }
  64. //
  65. // Display the IPX filter configuration dialog
  66. //
  67. spRmIf->GetInfoBase(hMprConfig, NULL, NULL, &spInfoBase);
  68. if (IpxFilterConfigInfoBase(pParent->GetSafeHwnd(), spInfoBase,
  69. spRmIf, dwFilterType) == hrOK)
  70. {
  71. hr = spRmIf->Save(pszMachine,
  72. hMprConfig,
  73. NULL,
  74. NULL,
  75. spInfoBase,
  76. 0);
  77. if (FHrSucceeded(hr))
  78. dwErr = ERROR_SUCCESS;
  79. else
  80. dwErr = WIN32_FROM_HRESULT(hr);
  81. }
  82. //
  83. // do clean up here and return
  84. //
  85. ::MprConfigServerDisconnect( hMprConfig );
  86. return dwErr;
  87. }
  88. HRESULT APIENTRY
  89. IpxFilterConfigInfoBase(
  90. IN HWND hwndParent,
  91. IN IInfoBase * pInfoBase,
  92. IN IRtrMgrInterfaceInfo *pRmIf,
  93. IN DWORD dwFilterType // FILTER_INBOUND, FILTER_OUTBOUND
  94. ) {
  95. HRESULT hr = hrOK;
  96. CIpxFilter dlg(CWnd::FromHandle(hwndParent), pInfoBase, dwFilterType);
  97. if( dlg.DoModal() == IDOK )
  98. {
  99. hr = hrOK;
  100. }
  101. else
  102. {
  103. hr = hrFalse;
  104. }
  105. return hr;
  106. }