package capture; import net.sourceforge.jpcap.capture.PacketCapture; /** * Captures network traffic and passes it off to a handler. * * User: joe.hancock@gmail.com * Date: 29-Nov-2005 * Time: 20:06:58 */ class MainCapture { private String filter; private String device; public MainCapture(String device, String filter) { this.filter = filter; this.device = device; } /** * Initializes the network device and applies the filters. * * @throws Exception */ public void initCapture() throws Exception { PacketCapture captureDriver = new PacketCapture(); try { captureDriver.open(device, true); } catch (Exception e) { e.printStackTrace(); } captureDriver.setFilter(filter, true); captureDriver.addPacketListener(new AddressTCPPacketHandler()); captureDriver.capture(-1); } }