-2

: The result of pcap_findalldevs function :

Finding available devices ...

 1:eth0 -- (null)
 2:wlan0 -- (null)
 3:nflog -- Linux netfilter log (NFLOG) interface
 4:any -- Pseudo-device that captures on all interfaces
 5:lo -- (null)

I want to select wlan0. How can I do it ?

Thanks in advance Best regards

N.B
  • 31
  • 1
  • 8

1 Answers1

1

Did you see the man pages for pcap? You can pass an interface name to any of pcap_create or pcap_open_live. The interface name is in the name member of the pcap_if_t.

nneonneo
  • 171,345
  • 36
  • 312
  • 383
  • I did, actually I use if(device->next->name == "wlan0") with device is (pcap_if_t) struct // then process to display the device for example but nothing is hapening. – N.B Aug 18 '13 at 15:41
  • You can just do `pcap_create("wlan0", ...);`. No need for the `pcap_if_t` if you already know the interface name. – nneonneo Aug 18 '13 at 16:08
  • OK thanks nneonneo even if I preferred to select the device I want from the list of devices. I have a question wich has to do with JNetPcap for capturing packet with Java, and I need to run my testpcap.java with root privileges as I found in forums but I don't know how to process it. how could I run my application as I can do with the C programm (using sudo command ) could youtell me more about it ? thanks in advance – N.B Aug 18 '13 at 18:33
  • That's an entirely separate question. – nneonneo Aug 18 '13 at 19:36
  • Yes I know and I'm wondering if someone could help on finding the solution ? – N.B Aug 18 '13 at 21:18