net.fenyo.gnetwatch.activities
Class Capture

java.lang.Object
  extended by net.fenyo.gnetwatch.activities.Capture
All Implemented Interfaces:
java.lang.Runnable

public class Capture
extends java.lang.Object
implements java.lang.Runnable

This class captures Ethernet frames using tethereal on a single layer-2 interface. The frames are parsed with SAX.

Version:
$Id: Capture.java,v 1.14 2008/04/15 23:58:17 fenyo Exp $
Author:
Alexandre Fenyo

Field Summary
private  java.lang.Thread capture_thread
           
private  ExternalCommand cmd
           
private  Config config
           
private  boolean forked
           
private static Log log
           
private  CaptureManager manager
           
private  boolean must_end
           
(package private)  SAXReader reader
           
 
Constructor Summary
Capture(Config config, CaptureManager manager, int device, java.lang.String filter)
          Constructor.
 
Method Summary
 void createCaptureThread()
          Starts the capture thread.
 void end()
          Stops the capture thread and waits for its end.
private  void handlePacket(java.lang.StringBuffer packet)
          Gives the next frame to the manager.
static java.lang.String[] listDevices()
          Lists all available devices.
 void run()
          Reads tethereal standard output and extracts frames one by one.
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Field Detail

log

private static Log log

reader

final SAXReader reader

config

private final Config config

cmd

private ExternalCommand cmd

manager

private CaptureManager manager

forked

private boolean forked

capture_thread

private java.lang.Thread capture_thread

must_end

private boolean must_end
Constructor Detail

Capture

public Capture(Config config,
               CaptureManager manager,
               int device,
               java.lang.String filter)
Constructor. GUI thread.

Parameters:
config - configuration.
manager - capture manager this instance works for.
device - device this instance captures frames from.
filter - capture filter to apply.
Method Detail

listDevices

public static java.lang.String[] listDevices()
                                      throws java.lang.InterruptedException
Lists all available devices.

Parameters:
none. -
Returns:
list of device names.
Throws:
java.lang.InterruptedException - exception.

createCaptureThread

public void createCaptureThread()
Starts the capture thread.

Parameters:
none. -

end

public void end()
         throws java.lang.InterruptedException
Stops the capture thread and waits for its end.

Parameters:
none. -
Throws:
java.lang.InterruptedException - exception.

handlePacket

private void handlePacket(java.lang.StringBuffer packet)
                   throws DocumentException
Gives the next frame to the manager.

Parameters:
packet - next frame.
Throws:
DocumentException - SAX parse exception.

run

public void run()
Reads tethereal standard output and extracts frames one by one.

Specified by:
run in interface java.lang.Runnable
Parameters:
none. -