0
votes

I'm using libpcap to write a sniffer program .. For starters i referred to tutorials on the net from various programmer on how to write Basic Sniffer program using Libpcap .. which captures Packets only from the Ethernet connection ...

And i've been searching a lot on How to write a program using libpcap to capture packets from the wifi connection .... but i'm not getting anything which can help me ...

Do i need to do some settings in my system to make sure that libpcap can capture the packet...because the method pcap_lookupdev points to the default device which is eth0

1

1 Answers

1
votes

You either need to hardcode the name of the Wi-Fi device (probably wlan0) into your program, or give it a UI option (command-line flag, etc.) to let the user specify the device on which to capture traffic.

There is no setting on your system that will change the device returned by pcap_lookupdev().

Tcpdump and Wireshark/TShark/etc. have a -i command-line option to specify the device on which to capture, and Wireshark has a GUI dialog to allow the user to specify it. They don't rely on pcap_lookupdev() if the user specifies the device explicitly.

Note that if you're capturing on Wi-Fi, you will, by default, only capture traffic to and from your machine. If you want to capture all the traffic on your network, including traffic to and from other machines, you will need to capture in monitor mode; newer versions of libpcap have APIs to support that, but they're only guaranteed to work on OS X (for various complicated reasons, they may or may not work on Linux, which, given the device name eth0, I assume you're using; until that's fixed, you'd need to use something such as aircrack-ng to turn on monitor mode - see the WLAN capture setup page section on Linux in the Wireshark Wiki for informationon that).