KerRuleSettingDlg.cpp
上传用户:zhuzhu0204
上传日期:2020-07-13
资源大小:13165k
文件大小:3k
源码类别:
防火墙与安全工具
开发平台:
Visual C++
- // KerRuleSettingDlg.cpp : implementation file
- //
- #include "StdAfx.h"
- #include "MyFireWall.h"
- #include "KerRuleSettingDlg.h"
- #ifdef _DEBUG
- #define new DEBUG_NEW
- #undef THIS_FILE
- static char THIS_FILE[] = __FILE__;
- #endif
- /////////////////////////////////////////////////////////////////////////////
- // CKerRuleSettingDlg dialog
- CKerRuleSettingDlg::CKerRuleSettingDlg(CWnd* pParent /*=NULL*/)
- : CDialog(CKerRuleSettingDlg::IDD, pParent)
- {
- //{{AFX_DATA_INIT(CKerRuleSettingDlg)
- m_DestPort = 0;
- m_SourcePort = 0;
- //}}AFX_DATA_INIT
- }
- void CKerRuleSettingDlg::DoDataExchange(CDataExchange* pDX)
- {
- CDialog::DoDataExchange(pDX);
- //{{AFX_DATA_MAP(CKerRuleSettingDlg)
- DDX_Control(pDX, IDC_SOURCE_IPADDRESS, m_SourceIP);
- DDX_Control(pDX, IDC_DEST_IPADDRESS, m_DestIP);
- DDX_Control(pDX, IDC_STATE_COMBO, m_StateCombo);
- DDX_Control(pDX, IDC_PROTO_COMBO, m_ProtoCombo);
- DDX_Text(pDX, IDC_DEST_PORT, m_DestPort);
- DDX_Text(pDX, IDC_SOURCE_PORT, m_SourcePort);
- //}}AFX_DATA_MAP
- }
- BEGIN_MESSAGE_MAP(CKerRuleSettingDlg, CDialog)
- //{{AFX_MSG_MAP(CKerRuleSettingDlg)
- //}}AFX_MSG_MAP
- END_MESSAGE_MAP()
- /////////////////////////////////////////////////////////////////////////////
- // CKerRuleSettingDlg message handlers
- BOOL CKerRuleSettingDlg::OnInitDialog()
- {
- CDialog::OnInitDialog();
- // 初始化源IP和端口
- m_SourceIP.SetAddress(m_RuleItem.sourceIP);
- m_SourcePort = m_RuleItem.sourcePort;
- // 初始化目的IP和端口
- m_DestIP.SetAddress(m_RuleItem.destinationIP);
- m_DestPort = m_RuleItem.destinationPort;
- // 初始化协议类型
- m_ProtoCombo.SetItemData(m_ProtoCombo.AddString(L"全部"), 0);
- m_ProtoCombo.SetItemData(m_ProtoCombo.AddString(L"TCP"), IPPROTO_TCP);
- m_ProtoCombo.SetItemData(m_ProtoCombo.AddString(L"UDP"), IPPROTO_UDP);
- m_ProtoCombo.SetItemData(m_ProtoCombo.AddString(L"SMTP"), IPPROTO_IGMP);
- m_ProtoCombo.SetCurSel(0);
- // 初始化状态
- m_StateCombo.SetItemData(m_StateCombo.AddString(L"允许"), 0);
- m_StateCombo.SetItemData(m_StateCombo.AddString(L"拒绝"), 1);
- m_StateCombo.SetCurSel(0);
- // TODO: Add extra initialization here
- return TRUE; // return TRUE unless you set the focus to a control
- // EXCEPTION: OCX Property Pages should return FALSE
- }
- void CKerRuleSettingDlg::OnOK()
- {
- // TODO: Add extra validation here
- CString strTemp;
- // 设置源IP/端口
- m_SourceIP.GetAddress(m_RuleItem.sourceIP);
- m_RuleItem.sourcePort = GetDlgItemInt(IDC_SOURCE_PORT);
- // 设置目的IP/端口
- m_DestIP.GetAddress(m_RuleItem.destinationIP);
- m_RuleItem.destinationPort = GetDlgItemInt(IDC_DEST_PORT);
- // 设置协议
- m_RuleItem.protocol = (USHORT)m_ProtoCombo.GetItemData(m_ProtoCombo.GetCurSel());
- // 设置状态
- m_RuleItem.bDrop = (BOOLEAN)m_StateCombo.GetItemData(m_StateCombo.GetCurSel());
- CDialog::OnOK();
- }