【发布时间】:2017-07-30 14:13:31
【问题描述】:
我正在尝试将 NULL 传递给 pcap_loop() 函数,就像 tcpdump man 一样。
这是我要触发的回调函数:
void Home::gotPacket(u_char *args, const struct pcap_pkthdr *header,
const u_char *packet){
}
首先我尝试了这个:
pcap_loop(handle, 0, gotPacket, NULL);
其次,我尝试传递一个具有 NULL 值的变量:
u_char *arg = NULL;
pcap_loop(handle, 0, gotPacket, arg);
第一种和第二种方法都返回了这个错误:
error: invalid use of non-static member function
pcap_loop(handle, 0, gotPacket, NULL);
^
error: invalid use of non-static member function
pcap_loop(handle, 0, gotPacket, arg);
^
我该如何解决这个错误?提前感谢您的帮助!
【问题讨论】: