⭐ 欢迎来到虫虫下载站! | 📦 资源下载 📁 资源专辑 ℹ️ 关于我们
⭐ 虫虫下载站

📄 ping_tab.cpp

📁 嵌入式Linux环境下的网络安全检测软件
💻 CPP
字号:
#include "ping_tab.h"PingTab::PingTab(QWidget *parent)    : QWidget(parent){	Ping_start = new QPushButton( this, "Ping_start" );	Ping_start->setGeometry( QRect( 40, 250, 60, 30 ) ); 	Ping_start->setText( tr( "Start" ) );	Ping_clear = new QPushButton( this, "Ping_clear" );	Ping_clear->setGeometry( QRect( 140, 250, 60, 30 ) ); 	Ping_clear->setText( tr( "Clear" ) );	IPAddress_lineedit = new QLineEdit( this, "IPAddress_lineedit" );	IPAddress_lineedit->setGeometry( QRect( 90, 10, 110, 23 ) ); 	IPAddress_lineedit->setText( tr( "127.0.0.1" ) );	ping_ip_label = new QLabel( this, "ping_ip_label" );	ping_ip_label->setGeometry( QRect( 20, 10, 41, 31 ) ); 	ping_ip_label->setText( tr( "IP Addr:" ) );	ip_Eth_lineedit = new QLineEdit( this, "ip_Eth_lineedit" );	ip_Eth_lineedit->setEnabled( FALSE );	ip_Eth_lineedit->setGeometry( QRect( 90, 40, 90, 23 ) ); 	ip_Eth_lineedit->setText( tr( "eth0" ) );	ip_eth_check = new QCheckBox( this, "ip_eth_check" );	ip_eth_check->setGeometry( QRect( 20, 40, 50, 20 ) ); 	ip_eth_check->setText( tr( "eth:" ) );	disp_IP = new QListView( this, "disp_IP" );	disp_IP->addColumn( tr( "Seq" ) );	disp_IP->setGeometry( QRect( 10, 70, 210, 170 ) ); 	connect( Ping_start, SIGNAL( clicked() ), this, SLOT( start_ping() ) );	connect( Ping_clear, SIGNAL( clicked() ), this, SLOT( clear_ping() ) );	connect( ip_eth_check, SIGNAL( clicked() ), this, SLOT( enableEth() ) );	disp_IP->setSorting(1, FALSE);	libnet = NULL;	pcap = NULL;	local_loopback = "127.0.0.1";	stopped = FALSE;	   }PingTab::~PingTab(){// 	free(local_loopback);// 	libnet_destroy(libnet);// 	pcap_close(pcap);}void PingTab::run(){	while(!stopped)	{		initialize();	//		ping_run();		sleep(1);	}	stopped = FALSE;}void PingTab::stop(){	stopped = TRUE;}void PingTab::display(QString output){	list_item = new QListViewItem(disp_IP);	list_item -> setText(0, output);}void PingTab::start_ping(){	if(running())	{		stop();		Ping_start->setText(tr("Start"));	}	else	{		start();		Ping_start->setText(tr("Stop"));	}}void PingTab::clear_ping(){	disp_IP->clear();}void PingTab::quit(){	libnet_destroy(libnet);	pcap_close(pcap);	exit();}void PingTab::enableEth(){  	if(ip_eth_check->isChecked())	{		ip_Eth_lineedit->setEnabled(TRUE);	}	else	{		ip_Eth_lineedit->setEnabled(FALSE);	}}void PingTab::initialize(){		struct bpf_program filter_code;	//杩囨护缁撴瀯	bpf_u_int32 local_net, netmask;	//pcap瀹氫箟鐨勬湰鏈虹綉缁滃彿鍜屾帺鐮

⌨️ 快捷键说明

复制代码 Ctrl + C
搜索代码 Ctrl + F
全屏模式 F11
切换主题 Ctrl + Shift + D
显示快捷键 ?
增大字号 Ctrl + =
减小字号 Ctrl + -