Ubuntu pcap_lookupdev()已被弃用。如何解决

Ubuntu pcap_lookupdev()已被弃用。如何解决,ubuntu,tcpdump,libpcap,Ubuntu,Tcpdump,Libpcap,由于lookupdev在libcap>=1.9中已被弃用,我在v1.8中编写的代码中遇到了一个错误。我还没能解决它。 建议我使用pcap_findalldevs,但我得到一个错误 int sniffARPPackets(char* gateway, char* gateway_ipp) { } 这是代码。为什么不推荐使用它 引用pcap_lookupdev手册页: BUGS The pointer returned by pcap_lookupdev() points to a s

由于lookupdev在libcap>=1.9中已被弃用,我在v1.8中编写的代码中遇到了一个错误。我还没能解决它。 建议我使用pcap_findalldevs,但我得到一个错误

int sniffARPPackets(char* gateway, char* gateway_ipp)
{

}

这是代码。

为什么不推荐使用它

引用pcap_lookupdev手册页:

BUGS
   The pointer returned by pcap_lookupdev() points  to  a  static  buffer;
   subsequent  calls  to  pcap_lookupdev() in the same thread, or calls to
   pcap_lookupdev() in another thread, may overwrite that buffer.

   In WinPcap, this function may return a UTF-16  string  rather  than  an
   ASCII or UTF-8 string.
DESCRIPTION
   This  interface  is  obsoleted  by  pcap_findalldevs(3PCAP).  To find a
   default device on which to capture, call pcap_findalldevs() and, if the
   list  it  returns  is not empty, use the first device in the list.  (If
   the list is empty, there are no devices on which capture is  possible.)
你应该怎么做

引用pcap_lookupdev手册页:

BUGS
   The pointer returned by pcap_lookupdev() points  to  a  static  buffer;
   subsequent  calls  to  pcap_lookupdev() in the same thread, or calls to
   pcap_lookupdev() in another thread, may overwrite that buffer.

   In WinPcap, this function may return a UTF-16  string  rather  than  an
   ASCII or UTF-8 string.
DESCRIPTION
   This  interface  is  obsoleted  by  pcap_findalldevs(3PCAP).  To find a
   default device on which to capture, call pcap_findalldevs() and, if the
   list  it  returns  is not empty, use the first device in the list.  (If
   the list is empty, there are no devices on which capture is  possible.)
在除Windows以外的所有平台上,
pcap\u lookupdev()
调用
pcap\u findalldevs()
并返回第一个设备(除非它是环回设备),因此如果
pcap\u findalldevs()
不工作,
pcap\u lookupdev()
也不会工作。使用
pcap\u findalldevs()
会出现什么错误