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.

137 lines
3.3 KiB

  1. /**********************************************************************/
  2. /** Microsoft Windows/NT **/
  3. /** Copyright(c) Microsoft Corporation, 1997 - 1997 **/
  4. /**********************************************************************/
  5. /*
  6. AddExcl.cpp
  7. Dialog to add an exclusion range
  8. FILE HISTORY:
  9. */
  10. #include "stdafx.h"
  11. #include "scope.h"
  12. #include "mscope.h"
  13. #include "addexcl.h"
  14. #ifdef _DEBUG
  15. #define new DEBUG_NEW
  16. #undef THIS_FILE
  17. static char THIS_FILE[] = __FILE__;
  18. #endif
  19. /////////////////////////////////////////////////////////////////////////////
  20. // CAddExclusion dialog
  21. CAddExclusion::CAddExclusion(ITFSNode * pScopeNode,
  22. BOOL bMulticast,
  23. CWnd* pParent /*=NULL*/)
  24. : CBaseDialog(CAddExclusion::IDD, pParent)
  25. {
  26. //{{AFX_DATA_INIT(CAddExclusion)
  27. // NOTE: the ClassWizard will add member initialization here
  28. //}}AFX_DATA_INIT
  29. m_spScopeNode.Set(pScopeNode);
  30. m_bMulticast = bMulticast;
  31. }
  32. void CAddExclusion::DoDataExchange(CDataExchange* pDX)
  33. {
  34. CBaseDialog::DoDataExchange(pDX);
  35. //{{AFX_DATA_MAP(CAddExclusion)
  36. // NOTE: the ClassWizard will add DDX and DDV calls here
  37. //}}AFX_DATA_MAP
  38. DDX_Control(pDX, IDC_IPADDR_EXCLUSION_FROM, m_ipaStart);
  39. DDX_Control(pDX, IDC_IPADDR_EXCLUSION_TO, m_ipaEnd);
  40. }
  41. BEGIN_MESSAGE_MAP(CAddExclusion, CBaseDialog)
  42. //{{AFX_MSG_MAP(CAddExclusion)
  43. //}}AFX_MSG_MAP
  44. END_MESSAGE_MAP()
  45. /////////////////////////////////////////////////////////////////////////////
  46. // CAddExclusion message handlers
  47. BOOL CAddExclusion::OnInitDialog()
  48. {
  49. CBaseDialog::OnInitDialog();
  50. return TRUE; // return TRUE unless you set the focus to a control
  51. // EXCEPTION: OCX Property Pages should return FALSE
  52. }
  53. void CAddExclusion::OnOK()
  54. {
  55. CDhcpIpRange dhcpExclusionRange;
  56. DWORD dwStart, dwEnd, dwError = 0;
  57. m_ipaStart.GetAddress(&dwStart);
  58. dhcpExclusionRange.SetAddr(dwStart, TRUE);
  59. m_ipaEnd.GetAddress(&dwEnd);
  60. if (!dwEnd)
  61. dwEnd = dwStart;
  62. dhcpExclusionRange.SetAddr(dwEnd, FALSE);
  63. BEGIN_WAIT_CURSOR;
  64. dwError = IsValidExclusion(dhcpExclusionRange);
  65. if (dwError != 0)
  66. {
  67. ::DhcpMessageBox(dwError);
  68. return;
  69. }
  70. dwError = AddExclusion(dhcpExclusionRange);
  71. END_WAIT_CURSOR;
  72. if (dwError != 0)
  73. {
  74. ::DhcpMessageBox(dwError);
  75. return;
  76. }
  77. m_ipaStart.ClearAddress();
  78. m_ipaEnd.ClearAddress();
  79. m_ipaStart.SetFocus();
  80. //CBaseDialog::OnOK();
  81. }
  82. DWORD
  83. CAddExclusion::IsValidExclusion(CDhcpIpRange & dhcpExclusionRange)
  84. {
  85. if (m_bMulticast)
  86. {
  87. CDhcpMScope * pScope = GETHANDLER(CDhcpMScope, m_spScopeNode);
  88. return pScope->IsValidExclusion(dhcpExclusionRange);
  89. }
  90. else
  91. {
  92. CDhcpScope * pScope = GETHANDLER(CDhcpScope, m_spScopeNode);
  93. return pScope->IsValidExclusion(dhcpExclusionRange);
  94. }
  95. }
  96. DWORD
  97. CAddExclusion::AddExclusion(CDhcpIpRange & dhcpExclusionRange)
  98. {
  99. if (m_bMulticast)
  100. {
  101. CDhcpMScope * pScope = GETHANDLER(CDhcpMScope, m_spScopeNode);
  102. return pScope->AddExclusion(dhcpExclusionRange, TRUE);
  103. }
  104. else
  105. {
  106. CDhcpScope * pScope = GETHANDLER(CDhcpScope, m_spScopeNode);
  107. return pScope->AddExclusion(dhcpExclusionRange, TRUE);
  108. }
  109. }