// DlgUDP.cpp : implementation file
//
#include "stdafx.h"
#include "Sniffer.h"
#include "DlgUDP.h"
#include ".\dlgudp.h"
#include "SnifferDoc.h"
// CDlgUDP dialog
IMPLEMENT_DYNAMIC(CDlgUDP, CDialog)
CDlgUDP::CDlgUDP(CDocument *p1, CWnd* pParent /*=NULL*/)
: CDialog(CDlgUDP::IDD, pParent)
, ip4ver(4)
, ip4hdl(5)
, ip4delay(FALSE)
, ip4thru(FALSE)
, ip4rely(FALSE)
, ip4precede(0)
, ip4length(0)
, ip4ident(0)
, ip4mayfrgm(FALSE)
, ip4lastfrgm(FALSE)
, ip4frgmoffs(0)
, ip4ttl(255)
, ip4proto(17)
, ip4saddr(_T(""))
, ip4daddr(_T(""))
, udpsport(0)
, udpdport(0)
, udplength(0)
, udpdata(_T(""))
{
pDoc = p1;
}
CDlgUDP::~CDlgUDP()
{
}
void CDlgUDP::DoDataExchange(CDataExchange* pDX)
{
CDialog::DoDataExchange(pDX);
DDX_Text(pDX, IDC_EDIT_VER, ip4ver);
DDV_MinMaxUInt(pDX, ip4ver, 0, 15);
DDX_Text(pDX, IDC_EDIT_HDL, ip4hdl);
DDV_MinMaxUInt(pDX, ip4hdl, 0, 15);
DDX_Check(pDX, IDC_CHECK_DELAY, ip4delay);
DDX_Check(pDX, IDC_CHECK_THRU, ip4thru);
DDX_Check(pDX, IDC_CHECK_RELY, ip4rely);
DDX_CBIndex(pDX, IDC_COMBO_PRECEDE, ip4precede);
DDX_Control(pDX, IDC_COMBO_PRECEDE, m_precedeCombo);
DDX_Text(pDX, IDC_EDIT_LEN, ip4length);
DDV_MinMaxUInt(pDX, ip4length, 0, 65535);
DDX_Text(pDX, IDC_EDIT_IDENT, ip4ident);
DDV_MinMaxUInt(pDX, ip4ident, 0, 65535);
DDX_Check(pDX, IDC_CHECK_FRAGM, ip4mayfrgm);
DDX_Check(pDX, IDC_CHECK_FRAGMLAST, ip4lastfrgm);
DDX_Text(pDX, IDC_EDIT_FOFFS, ip4frgmoffs);
DDV_MinMaxUInt(pDX, ip4frgmoffs, 0, 8191);
DDX_Text(pDX, IDC_EDIT_TTL, ip4ttl);
DDV_MinMaxUInt(pDX, ip4ttl, 0, 255);
DDX_Text(pDX, IDC_EDIT_PROTO, ip4proto);
DDX_Text(pDX, IDC_EDIT_SIP, ip4saddr);
DDX_Text(pDX, IDC_EDIT_DIP, ip4daddr);
DDX_Text(pDX, IDC_EDIT_SPORT, udpsport);
DDV_MinMaxUInt(pDX, udpsport, 0, 65535);
DDX_Text(pDX, IDC_EDIT_DPORT, udpdport);
DDV_MinMaxUInt(pDX, udpdport, 0, 65535);
DDX_Text(pDX, IDC_EDIT_UDPLEN, udplength);
DDV_MinMaxUInt(pDX, udplength, 0, 65535);
DDX_Text(pDX, IDC_EDIT_DATA, udpdata);
}
BEGIN_MESSAGE_MAP(CDlgUDP, CDialog)
ON_WM_CLOSE()
ON_BN_CLICKED(IDC_SENDUDP_BUTTON, OnBnClickedSendudpButton)
END_MESSAGE_MAP()
// CDlgUDP message handlers
void CDlgUDP::OnClose()
{
ShowWindow(SW_HIDE);
//CDialog::OnClose();
}
BOOL CDlgUDP::OnInitDialog()
{
CDialog::OnInitDialog();
// TODO: Add extra initialization here
/* char name[NI_MAXHOST];
if(gethostname(name,NI_MAXHOST) == 0)
{
hostent *host = gethostbyname(name);
if(host)
{
in_addr ip = *((in_addr *)host->h_addr_list[0]);
m_srcip = inet_ntoa(ip);
UpdateData(false);
}
}*/
RECT cr;
m_precedeCombo.GetClientRect(&cr);
m_precedeCombo.SetWindowPos(0, 0, 0, cr.right, cr.bottom + 12*10, SWP_NOMOVE | SWP_NOZORDER);
return TRUE; // return TRUE unless you set the focus to a control
// EXCEPTION: OCX Property Pages should return FALSE
}
void CDlgUDP::OnBnClickedSendudpButton()
{
UpdateData();
STATIC_DOWNCAST(CSnifferDoc, pDoc)->SendUDP();
}