T
- A custom implementation of a PcapActivityListener
that
will be called back before all other registered listeners as long as it is passed as argument to the
readNextPcapEntry(PcapActivityListener)
method.public class PcapFileHandler<T extends PcapActivityListener> extends Object implements PcapHandler<T>
Multiple PcapActivityListener
may be registered with an instance of
this class, note however that the events will be dispatched sequentially in the listener registration order.
The only exception to this rule is a listener object that is passed directly as parameter to the
readNextPcapEntry(PcapActivityListener)
as this object will be the first one to receive a callback with
the appropriate PcapActivity
event.
Constructor and Description |
---|
PcapFileHandler(boolean sortByPcapTimestamp,
File... pcapFiles)
Instantiates a new pcap file handler using no Berkeley Packet Filter.
|
PcapFileHandler(File... pcapFiles)
Instantiates a new pcap file handler using no Berkeley Packet Filter and does not sort the input files.
|
PcapFileHandler(PcapFilter pcapFilter,
boolean sortByPcapTimestamp,
File... pcapFiles)
Instantiates a new pcap file handler using the passed Berkeley Packet Filter pcapFilter and a number of
input files.
|
Modifier and Type | Method and Description |
---|---|
void |
addPcapProcessor(T processor)
Adds a custom listener or processor to the set of already registered listeners.
|
void |
close()
Closes the underlying input streams (if not closed already) and releases any system resources associated
with it.
|
PcapActivity |
getCurrentPcapActivity()
A convenience method that provides a reference to the currently processed PcapActivity, i.e.
|
int |
getNumberOfInputFiles() |
boolean |
isSortByPcapTimestamp() |
boolean |
readNextPcapEntry(PcapActivityListener processor)
Read the next Pcap entry from the respective input stream.
|
void |
removePcapProcessor(T processor)
Removes a custom listener or processor from the set of already registered listeners.
|
public PcapFileHandler(PcapFilter pcapFilter, boolean sortByPcapTimestamp, File... pcapFiles)
pcapFilter
- the Berkeley Packet Filter to apply to all specified pcapFilessortByPcapTimestamp
- whether or not to sort the pcapFiles chronologically according to the first
encountered timestamp of the individual pcap entriespcapFiles
- the files to parse (must adhere to a PCAP specification supported by JNetPcap/libpcap)IllegalArgumentException
- if no input files are passedpublic PcapFileHandler(boolean sortByPcapTimestamp, File... pcapFiles)
sortByPcapTimestamp
- whether or not to sort the pcapFiles chronologically according to the first
encountered timestamp of the individual pcap entriespcapFiles
- the files to parse (must adhere to a PCAP specification supported by JNetPcap/libpcap)IllegalArgumentException
- if no input files are passedPcapFileHandler(PcapFilter, boolean, java.io.File...)
public PcapFileHandler(File... pcapFiles)
pcapFiles
- the files to parse (must adhere to a PCAP specification supported by JNetPcap/libpcap)IllegalArgumentException
- if no input files are passedPcapFileHandler(PcapFilter, boolean, java.io.File...)
public boolean readNextPcapEntry(PcapActivityListener processor)
PcapHandler
readNextPcapEntry
in interface PcapHandler<T extends PcapActivityListener>
processor
- A Pcap-Entry processor capable of handling the read PcapActivity.public void close()
PcapHandler
close
in interface PcapHandler<T extends PcapActivityListener>
close
in interface Closeable
close
in interface AutoCloseable
public PcapActivity getCurrentPcapActivity()
PcapHandler
getCurrentPcapActivity
in interface PcapHandler<T extends PcapActivityListener>
public void addPcapProcessor(T processor)
PcapHandler
addPcapProcessor
in interface PcapHandler<T extends PcapActivityListener>
processor
- a custom listener to decoded pcap entries and related eventspublic void removePcapProcessor(T processor)
PcapHandler
removePcapProcessor
in interface PcapHandler<T extends PcapActivityListener>
processor
- a registered listenerpublic int getNumberOfInputFiles()
public boolean isSortByPcapTimestamp()
Copyright © 2013–2015 Institute of networks and security. All rights reserved.