Mohammad Reza  Ramezani
Mohammad Reza Ramezani

Reputation: 772

pcap_open() not usable in libpcap

I want to create an application by libpcap in Qt in Kali linux. I create similar application in windows & does work.

I download & install libpcap. Now, Qt recognizes pcap.h but some functions & constants does not work. like as:

pcap_open - PCAP_OPENFLAG_PROMISCUOUS - pcap_findalldevs_ex - PCAP_SRC_IF_STRING - _snprintf_s.

The compiler errors similar as 'sth' was not declared in this scope. I use below headers but above errors apppear.

#define HAVE_REMOTE
#define WPCAP
#include <pcap.h>
#include <stdlib.h>
#include <sys/socket.h>
#include <netinet/in.h>
#include <arpa/inet.h>

Upvotes: 0

Views: 3630

Answers (3)

Mohammad Reza  Ramezani
Mohammad Reza Ramezani

Reputation: 772

I searched & found some functions in winpcap does not work in libpcap (As Guy Harris said).

For Qt programmer in linux, they have to add below code to .pro file:

LIBS += -L/usr/local/lib/ -lpcap

Upvotes: 0

user862787
user862787

Reputation:

WinPcap adds some APIs not available in libpcap (and versions of libpcap newer than the version upon which the latest WinPcap release is based have APIs not available in WinPcap).

pcap_open() is one of those APIs; it is NOT available in libpcap. You must either use pcap_open_live() or, in libpcap 1.x, pcap_create() and pcap_activate().

libpcap also doesn't currently support remote packet capture.

Upvotes: 2

Sigcont
Sigcont

Reputation: 715

add LIBS += -lpcap at the end of your .pro file. It will solve the issue.

Upvotes: 1

Related Questions