Help with ERROR On Android: "socket: Operation not permitted.."

2 replies [Last post]
Telematica
Offline
Joined: 07/12/2012

I'm trying to use jnetpcap in Android, it's my first time using the library ..
I installed the libjnetpcap.so and the jnetpcap.jar in my application. I also ran the application as root.

When using the library, it returns me several errors, for example when I try to make
Pcap pcap = Pcap.openLive (device.getName (), snaplen, flags, timeout, errbuf);

This returns this error "socket: Operation not permitted.." I don't know how to fix it.
Can anyone help me, please? It's Urgent.

lixianyu
Offline
Joined: 01/02/2012
You can use tcpdump to catch paket.

Six months past, no one can resolved it.
I use 'tcpdump' to catch paket, and use jnetpcap to pases pcap files.

Telematica
Offline
Joined: 07/12/2012
After making the capturing of

After making the capturing of the packets with "tcpdump" and saving it to a "output.pcap" file, i tried to use jnetpcap to manipulate the packets ..
This is the code i used:

final ArrayList packets = new ArrayList();
Pcap packet = Pcap.openOffline("/sdcard/output.pcap", errbuf);

JPacketHandler handler = new JPacketHandler() {

// Defining the action that will be performed each time a packet is
// read for the file.
//@Override
public void nextPacket(JPacket packet, String user) {
packets.add(packet);
}
packet.dispatch(-1, handler, null);
packet.close();

and here are the errors it returns:

android.os.Looper.loop(Looper.java: 123)
android.os.Handler.dispatchMessage(Handler.java:99)
jnetpcap.Pcap.dispatch(Unknown Source)
....

Comment viewing options

Select your preferred way to display the comments and click "Save settings" to activate your changes.