net.fenyo.gnetwatch.activities
Class CaptureManager

java.lang.Object
  extended by net.fenyo.gnetwatch.activities.CaptureManager

public class CaptureManager
extends java.lang.Object

This class captures Ethernet frames using tethereal. A tethereal instance is spawned through a Capture instance, for each layer-2 interface.

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

Nested Class Summary
static interface CaptureManager.HandlePacket
           
 
Field Summary
private  java.util.List<Capture> capture_list
           
private  Config config
           
private  GUI gui
           
private  MultiMap listeners
           
private static Log log
           
 
Constructor Summary
CaptureManager(Config config)
          Constructor.
 
Method Summary
private  java.lang.String getGlobalFilter()
          Creates a filter that integrates every individual listener filters.
 void handlePacket(Document packet)
          Inform every listeners about the next frame.
 void registerListener(java.lang.String filter, CaptureManager.HandlePacket callback)
          Register a frame listener.
 void setGUI(GUI gui)
          Defines the GUI instance.
private  void startCapture(java.lang.String filter)
          Creates captures instances for each available interface.
private  void stopCapture()
          Stops every capture instances.
 void unRegisterAllListeners()
          Removes every listeners.
 void unRegisterListener(java.lang.String filter, CaptureManager.HandlePacket callback)
          Removes a frame listener.
 
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

config

private final Config config

gui

private GUI gui

capture_list

private final java.util.List<Capture> capture_list

listeners

private MultiMap listeners
Constructor Detail

CaptureManager

public CaptureManager(Config config)
Constructor. main thread.

Parameters:
config - configuration.
Method Detail

setGUI

public void setGUI(GUI gui)
Defines the GUI instance.

Parameters:
GUI - gui.

startCapture

private void startCapture(java.lang.String filter)
                   throws java.lang.InterruptedException
Creates captures instances for each available interface.

Parameters:
filter - tethereal filter.
Throws:
java.lang.InterruptedException - exception.

stopCapture

private void stopCapture()
                  throws java.lang.InterruptedException
Stops every capture instances.

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

getGlobalFilter

private java.lang.String getGlobalFilter()
Creates a filter that integrates every individual listener filters.

Parameters:
none. -
Returns:
String global filter.

registerListener

public void registerListener(java.lang.String filter,
                             CaptureManager.HandlePacket callback)
                      throws java.lang.InterruptedException
Register a frame listener.

Parameters:
filter - filter this listener is interested in.
callback - entry point for asynchronous call.
Throws:
java.lang.InterruptedException - exception.

unRegisterListener

public void unRegisterListener(java.lang.String filter,
                               CaptureManager.HandlePacket callback)
                        throws java.lang.InterruptedException
Removes a frame listener.

Parameters:
filter - filter this listener was interested in.
callback - entry point for asynchronous call.
Throws:
java.lang.InterruptedException - exception.

unRegisterAllListeners

public void unRegisterAllListeners()
                            throws java.lang.InterruptedException
Removes every listeners.

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

handlePacket

public void handlePacket(Document packet)
Inform every listeners about the next frame.

Parameters:
packet - next frame.