KerRuleSettingDlg.cpp
上传用户:zhuzhu0204
上传日期:2020-07-13
资源大小:13165k
文件大小:3k
开发平台:

Visual C++

  1. // KerRuleSettingDlg.cpp : implementation file
  2. //
  3. #include "StdAfx.h"
  4. #include "MyFireWall.h"
  5. #include "KerRuleSettingDlg.h"
  6. #ifdef _DEBUG
  7. #define new DEBUG_NEW
  8. #undef THIS_FILE
  9. static char THIS_FILE[] = __FILE__;
  10. #endif
  11. /////////////////////////////////////////////////////////////////////////////
  12. // CKerRuleSettingDlg dialog
  13. CKerRuleSettingDlg::CKerRuleSettingDlg(CWnd* pParent /*=NULL*/)
  14. : CDialog(CKerRuleSettingDlg::IDD, pParent)
  15. {
  16. //{{AFX_DATA_INIT(CKerRuleSettingDlg)
  17. m_DestPort = 0;
  18. m_SourcePort = 0;
  19. //}}AFX_DATA_INIT
  20. }
  21. void CKerRuleSettingDlg::DoDataExchange(CDataExchange* pDX)
  22. {
  23. CDialog::DoDataExchange(pDX);
  24. //{{AFX_DATA_MAP(CKerRuleSettingDlg)
  25. DDX_Control(pDX, IDC_SOURCE_IPADDRESS, m_SourceIP);
  26. DDX_Control(pDX, IDC_DEST_IPADDRESS, m_DestIP);
  27. DDX_Control(pDX, IDC_STATE_COMBO, m_StateCombo);
  28. DDX_Control(pDX, IDC_PROTO_COMBO, m_ProtoCombo);
  29. DDX_Text(pDX, IDC_DEST_PORT, m_DestPort);
  30. DDX_Text(pDX, IDC_SOURCE_PORT, m_SourcePort);
  31. //}}AFX_DATA_MAP
  32. }
  33. BEGIN_MESSAGE_MAP(CKerRuleSettingDlg, CDialog)
  34. //{{AFX_MSG_MAP(CKerRuleSettingDlg)
  35. //}}AFX_MSG_MAP
  36. END_MESSAGE_MAP()
  37. /////////////////////////////////////////////////////////////////////////////
  38. // CKerRuleSettingDlg message handlers
  39. BOOL CKerRuleSettingDlg::OnInitDialog() 
  40. {
  41. CDialog::OnInitDialog();
  42. // 初始化源IP和端口
  43. m_SourceIP.SetAddress(m_RuleItem.sourceIP);
  44. m_SourcePort = m_RuleItem.sourcePort;
  45. // 初始化目的IP和端口
  46. m_DestIP.SetAddress(m_RuleItem.destinationIP);
  47. m_DestPort = m_RuleItem.destinationPort;
  48. // 初始化协议类型
  49. m_ProtoCombo.SetItemData(m_ProtoCombo.AddString(L"全部"), 0);
  50. m_ProtoCombo.SetItemData(m_ProtoCombo.AddString(L"TCP"),  IPPROTO_TCP);
  51. m_ProtoCombo.SetItemData(m_ProtoCombo.AddString(L"UDP"),  IPPROTO_UDP);
  52. m_ProtoCombo.SetItemData(m_ProtoCombo.AddString(L"SMTP"), IPPROTO_IGMP);
  53. m_ProtoCombo.SetCurSel(0);
  54. // 初始化状态
  55. m_StateCombo.SetItemData(m_StateCombo.AddString(L"允许"), 0);
  56. m_StateCombo.SetItemData(m_StateCombo.AddString(L"拒绝"), 1);
  57. m_StateCombo.SetCurSel(0);
  58. // TODO: Add extra initialization here
  59. return TRUE;  // return TRUE unless you set the focus to a control
  60.               // EXCEPTION: OCX Property Pages should return FALSE
  61. }
  62. void CKerRuleSettingDlg::OnOK() 
  63. {
  64. // TODO: Add extra validation here
  65. CString strTemp;
  66. // 设置源IP/端口
  67. m_SourceIP.GetAddress(m_RuleItem.sourceIP);
  68. m_RuleItem.sourcePort = GetDlgItemInt(IDC_SOURCE_PORT);
  69. // 设置目的IP/端口
  70. m_DestIP.GetAddress(m_RuleItem.destinationIP);
  71. m_RuleItem.destinationPort = GetDlgItemInt(IDC_DEST_PORT);
  72. // 设置协议
  73. m_RuleItem.protocol = (USHORT)m_ProtoCombo.GetItemData(m_ProtoCombo.GetCurSel());
  74. // 设置状态
  75. m_RuleItem.bDrop = (BOOLEAN)m_StateCombo.GetItemData(m_StateCombo.GetCurSel());
  76. CDialog::OnOK();
  77. }