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.

172 lines
4.2 KiB

  1. //============================================================================
  2. // Copyright(c) 1996, Microsoft Corporation
  3. //
  4. // File: rtrfiltr.cpp
  5. //
  6. // History:
  7. // 08/30/96 Ram Cherala Created
  8. //
  9. // Implementation of Router Packet Filters Configuration
  10. // Defines initialization routines for the rtrfiltr.dll
  11. //============================================================================
  12. #include "stdafx.h"
  13. #include "rtrfiltr.h"
  14. #include "mprfltr.h"
  15. #include "ipaddr.h"
  16. #include "dialog.h"
  17. #ifdef _DEBUG
  18. #define new DEBUG_NEW
  19. #undef THIS_FILE
  20. static char THIS_FILE[] = __FILE__;
  21. #endif
  22. /////////////////////////////////////////////////////////////////////////////
  23. // CRtrfiltrApp
  24. BEGIN_MESSAGE_MAP(CRtrfiltrApp, CWinApp)
  25. //{{AFX_MSG_MAP(CRtrfiltrApp)
  26. // NOTE - the ClassWizard will add and remove mapping macros here.
  27. // DO NOT EDIT what you see in these blocks of generated code!
  28. //}}AFX_MSG_MAP
  29. END_MESSAGE_MAP()
  30. /////////////////////////////////////////////////////////////////////////////
  31. // CRtrfiltrApp construction
  32. CRtrfiltrApp::CRtrfiltrApp()
  33. {
  34. // TODO: add construction code here,
  35. // Place all significant initialization in InitInstance
  36. }
  37. /////////////////////////////////////////////////////////////////////////////
  38. // The one and only CRtrfiltrApp object
  39. CRtrfiltrApp theApp;
  40. BOOL CRtrfiltrApp::InitInstance()
  41. {
  42. BOOL bRet = CWinApp::InitInstance();
  43. // Setup the proper help file
  44. free((void *) m_pszHelpFilePath);
  45. m_pszHelpFilePath = _tcsdup(_T("mprsnap.hlp"));
  46. // Setup the global help function
  47. extern DWORD * RtrfiltrSnapHelpMap(DWORD dwIDD);
  48. SetGlobalHelpMapFunction(RtrfiltrSnapHelpMap);
  49. // initialize IP address control once
  50. if (bRet)
  51. {
  52. if (m_pszHelpFilePath != NULL)
  53. free((void*)m_pszHelpFilePath);
  54. m_pszHelpFilePath = _tcsdup(_T("mprsnap.hlp"));
  55. // IpAddrInit(AfxGetInstanceHandle(), 0, 0);
  56. IPAddrInit(AfxGetInstanceHandle());
  57. // InitCommonLibrary ();
  58. }
  59. return bRet;
  60. }
  61. //----------------------------------------------------------------------------
  62. // Function: MprUIFilterConfig
  63. //
  64. // Called to configure Filter for the transport interface.
  65. //----------------------------------------------------------------------------
  66. DWORD APIENTRY
  67. MprUIFilterConfig(
  68. IN CWnd* pParent,
  69. IN LPCWSTR pwsMachineName,
  70. IN LPCWSTR pwsInterfaceName,
  71. IN DWORD dwTransportId,
  72. IN DWORD dwFilterType // FILTER_INBOUND, FILTER_OUTBOUND
  73. ) {
  74. DWORD dwErr = NO_ERROR;
  75. AFX_MANAGE_STATE(AfxGetStaticModuleState());
  76. // TODO IPX filter config will pass in NULL for the interface name
  77. // to configure filters for Client Interface. Ignore this for now
  78. // and add code to deal with IPX Client interface config.
  79. if(pwsInterfaceName == NULL)
  80. return dwErr;
  81. switch ( dwTransportId ) {
  82. case PID_IP:
  83. dwErr = IpFilterConfig( pParent,
  84. pwsMachineName,
  85. pwsInterfaceName,
  86. dwFilterType );
  87. break;
  88. case PID_IPX:
  89. dwErr = IpxFilterConfig( pParent,
  90. pwsMachineName,
  91. pwsInterfaceName,
  92. dwFilterType );
  93. break;
  94. default:
  95. dwErr = ERROR_INVALID_PARAMETER;
  96. }
  97. return dwErr;
  98. }
  99. HRESULT APIENTRY
  100. MprUIFilterConfigInfoBase(
  101. IN HWND hwndParent,
  102. IN IInfoBase * pInfoBase,
  103. IN IRtrMgrInterfaceInfo *pRmIf,
  104. IN DWORD dwTransportId,
  105. IN DWORD dwFilterType // FILTER_INBOUND, FILTER_OUTBOUND
  106. ) {
  107. AFX_MANAGE_STATE(AfxGetStaticModuleState());
  108. HRESULT hr = hrOK;
  109. COM_PROTECT_TRY
  110. {
  111. if (pInfoBase == NULL)
  112. CORg(E_INVALIDARG);
  113. // TODO IPX filter config will pass in NULL for the interface name
  114. // to configure filters for Client Interface. Ignore this for now
  115. // and add code to deal with IPX Client interface config.
  116. switch ( dwTransportId )
  117. {
  118. case PID_IP:
  119. hr = IpFilterConfigInfoBase( hwndParent,
  120. pInfoBase,
  121. pRmIf,
  122. dwFilterType );
  123. break;
  124. case PID_IPX:
  125. hr = IpxFilterConfigInfoBase( hwndParent,
  126. pInfoBase,
  127. pRmIf,
  128. dwFilterType );
  129. break;
  130. default:
  131. hr = E_INVALIDARG;
  132. }
  133. COM_PROTECT_ERROR_LABEL;
  134. }
  135. COM_PROTECT_CATCH;
  136. return hr;
  137. }