Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Read addresses for interfaces #11

Closed
pm2002 opened this issue Dec 9, 2013 · 9 comments
Closed

Read addresses for interfaces #11

pm2002 opened this issue Dec 9, 2013 · 9 comments
Labels

Comments

@pm2002
Copy link

pm2002 commented Dec 9, 2013

Here a simple test case iterating all interfaces and all related addresses:

    List<PcapNetworkInterface> allDevs = Pcaps.findAllDevs();
    System.out.println("number of devices: " + allDevs.size());
    for (PcapNetworkInterface device : allDevs) {
        System.out.println(device);

        List<PcapAddress> addresses = device.getAddresses();
        System.out.println("number of addresses: " + addresses.size());
        for (PcapAddress address : addresses) {
            System.out.println("\t" + address);
        }
    }

Shouldn't that return anything? Actually I don't get any address for one of the interfaces. It only returns:
"number of addresses: 0"
for all network interfaces. Even the one's, that are connected!

Is this a bug of Pcap4J or did I miss anything?

@kaitoy
Copy link
Owner

kaitoy commented Dec 13, 2013

Your code looks correct. I'm not sure where the cause is, but I've ever seen the same issue when I tried Pcap4J with WinPcap installed just before the try. At that time the issue was resolved by rebooting Windows. You may be able to resolve it by rebooting.
And,try to install wireshark and see ip addresses of the network interfaces using it. If it also doesn't show any ip addresses, the cause is in pcap library, not in Pcap4J.

@pm2002
Copy link
Author

pm2002 commented Feb 19, 2014

I'm actually using Mac OS X, not Windows and have Wireshark installed and working. When using tcpdump everything works as expected, but when executing the test above it still returns number of addresses: 0!

@pm2002
Copy link
Author

pm2002 commented Feb 19, 2014

Even tomute's Mac OS X test you have linked on your page (see: here: http://tomute.hateblo.jp/entry/2013/01/27/003209) is mentioning the same problem. Do you have any ideas how to fix that?

@kaitoy
Copy link
Owner

kaitoy commented Feb 26, 2014

It seems to be a defect in pcap4j. I don't have Mac OS X now but I'll investigate the defect somehow.

@kaitoy
Copy link
Owner

kaitoy commented Feb 28, 2014

Fixed. Not tested on Mac OS X but on FreeBSD. Please build pcap4j from the latest source and try it on Mac OS X.

@pm2002
Copy link
Author

pm2002 commented Feb 28, 2014

It's working now! Please provide Central Repository maven dependency for the fixed code. Thanks for fast action. Thumbs up

@kaitoy
Copy link
Owner

kaitoy commented Mar 3, 2014

Thanks for the try. But I found some more problems around IP address discovery. I will fix them and register the fixed pcap4j with the central repository hopefully in the next week.

@pm2002
Copy link
Author

pm2002 commented Mar 3, 2014

I'm looking forward to that :)

@kaitoy
Copy link
Owner

kaitoy commented Mar 8, 2014

Done!

@pm2002 pm2002 closed this as completed Mar 20, 2014
@kaitoy kaitoy added the bug label Jun 4, 2015
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Projects
None yet
Development

No branches or pull requests

2 participants