SourceForge Jpcap

net.sourceforge.jpcap.capture
Class CaptureDevice

java.lang.Object
  extended by net.sourceforge.jpcap.capture.CaptureDevice

public class CaptureDevice
extends Object

Encapsulates a capture-capable device.

NB there is no support for supplying the MAC address of a capture device. In Java 6, you can get it this way:


 NetworkInterface nwif = NetworkInterface.getByInetAddress(captureDevice.getAddresses()[0].getAddress());
 byte[] macAddress = nwif.getHardwareAddress();

Since:
2.0.0
Version:
$Revision: 1.1 $
Author:
Esmond Pitt

Nested Class Summary
static class CaptureDevice.Address
          The Address class encapsulates addressing information for a CaptureDevice.
 
Field Summary
static int PCAP_IF_LOOPBACK
          Loopback bitmask.
 
Constructor Summary
protected CaptureDevice(String name, String description, int network, int netmask, int flags, CaptureDevice.Address[] addresses)
          Construct a new instance of CaptureDevice.
 
Method Summary
 boolean equals(Object other)
           
 CaptureDevice.Address[] getAddresses()
          Return the address information for the device.
 String getDescription()
          Get the device description.
 String getName()
          Get the device name.
 int hashCode()
           
 boolean isLoopback()
          Return true if the device is a loopback device.
 String toString()
           
 
Methods inherited from class java.lang.Object
clone, finalize, getClass, notify, notifyAll, wait, wait, wait
 

Field Detail

PCAP_IF_LOOPBACK

public static final int PCAP_IF_LOOPBACK
Loopback bitmask. Must match the declaration in pcap.h.

See Also:
Constant Field Values
Constructor Detail

CaptureDevice

protected CaptureDevice(String name,
                        String description,
                        int network,
                        int netmask,
                        int flags,
                        CaptureDevice.Address[] addresses)
Construct a new instance of CaptureDevice. This constructor is used by JNI code.

Parameters:
name - Device name.
description - Device description if available, or null.
network - Network, from pcap_lookupnet(), corrected to host byte order
netmask - Netmask, from pcap_lookupnet(), corrected to host byte order
flags - pcap_if_t.flags.
addresses - Addresses of this interface
Method Detail

toString

public String toString()
Overrides:
toString in class Object

getName

public String getName()
Get the device name. This is the attribute that is passed to PacketCaptureCapable.open(java.lang.String, boolean).

Returns:
the device name.

getDescription

public String getDescription()
Get the device description.

Returns:
the device description.

isLoopback

public boolean isLoopback()
Return true if the device is a loopback device.

Returns:
true if the device is a loopback device.

getAddresses

public CaptureDevice.Address[] getAddresses()
Return the address information for the device.

Returns:
the addressing information for the device.

hashCode

public int hashCode()
Overrides:
hashCode in class Object

equals

public boolean equals(Object other)
Overrides:
equals in class Object

Copyright © Patrick Charles & Jonas Lehmann, 2001; Esmond Pitt, 2008.