我有一个小程序来显示设备和捕获任何数据包,使用GUI.I使用QT Designer和Netbeans 6.9绘制GUI,但问题来自我尝试实现信号/插槽.基本上当选择组合框时, QlineEdit将显示所选设备的MAC地址.错误:
Object::connect: No such signal QComboBox::selectedDev(int) in MainGUI.cpp:21
Object::connect: (sender name: 'comboBox')
Object::connect: (receiver name: 'MYMACBOX')
Run Code Online (Sandbox Code Playgroud)
MainGUI.h
#ifndef _MAINGUI_H
#define _MAINGUI_H
#include "ui_MainGUI.h"
class MainGUI : public QDialog {
Q_OBJECT
public:
MainGUI();
virtual ~MainGUI();
void displayDevices();
void selectedValue();
public slots:
void showmac(int);
signals:
void selectedDev(int);
private:
Ui::MainGUI widget;
};
Run Code Online (Sandbox Code Playgroud)
MainGUI.cpp
#include "MainGUI.h"
#include "pcapCapture.h"
#include <pcap.h>
#include <iostream>
MainGUI::MainGUI() // constructor
{
widget.setupUi(this);
//show devices here
QObject::connect(widget.comboBox,SIGNAL(selectedDev(int)),widget.MYMACBOX,SLOT(showmac(int)));
}
void MainGUI::showmac(int value)
{
//show MAC address here
} …Run Code Online (Sandbox Code Playgroud) 我试图将我的设备设置为监控模式,我知道它能够处于监控模式,执行"iwconfig wlan0模式监控"工作,我运行我的代码,我可以从任何地方捕获数据包.
问题是在libpcap中它根本无法将我的设备设置为监控模式(没有输入上述命令行).在手动连接到接入点之前,我无法捕获任何数据包.
pcap_t *handler = pcap_create("wlan0",errbuff);
if(pcap_set_rfmon(handler,1)==0 )
{
std::cout << "monitor mode enabled" << std::endl;
}
handler=pcap_open_live ("wlan0", 2048,0,512,errbuff);
int status = pcap_activate(handler); //it returns 0 here.
Run Code Online (Sandbox Code Playgroud)
这是一个代码问题,还是pcap库的问题?有没有人成功将他们的设备设置为监控模式而不使用命令行?我正在使用Realtek2500 btw.