libpcap:未检测到无线设备

Sid*_*ant 1 c pcap libpcap

我想捕获从我的机器出来的数据包,我正在使用libpcap(版本1.0.0-1).问题是,像这样的基本程序 -

#include <stdio.h>
#include <pcap.h>

int main(int argc, char *argv[]) {
    char *dev, errbuf[PCAP_ERRBUF_SIZE];
    dev = pcap_lookupdev(errbuf);
    if (dev == NULL) {
        fprintf(stderr, "%s\n", errbuf);
        return (2);
    }
    printf("Device : %s\n", dev);
    return (0);
}
Run Code Online (Sandbox Code Playgroud)

似乎没有显示无线接口.每次我编译并运行程序时,它都会检测到eth0.我怎样才能捕获无线接口呢?

小智 5

pcap_lookupdev()返回系统上的默认网络设备,通常是列出的第一个设备.pcap_findalldevs()返回系统中所有设备的枚举,您可以使用它来选择设备并从中捕获.