public class Pcap
extends java.lang.Object
| Modifier and Type | Method and Description |
|---|---|
void |
close() |
PcapOutputStream |
createOutputStream(java.io.OutputStream out)
Create an
PcapOutputStream based on this Pcap. |
void |
loop(PacketHandler callback) |
static Pcap |
openStream(java.io.File file) |
static Pcap |
openStream(java.io.InputStream is)
Capture packets from the input stream
|
static Pcap |
openStream(java.io.InputStream is,
int bufferCapacity)
Capture packets from the input stream
|
static Pcap |
openStream(java.lang.String file) |
void |
setFilter(java.lang.String expression)
It is possible to specify a filter so that only packets that matches the
filter will be passed onto the registered
PacketHandler. |
public void setFilter(java.lang.String expression)
throws FilterParseException
PacketHandler.
E.g., to only accept packets of type sip with the Call-ID of "123" you
could pass in the following filter:
"sip.Call-ID == 123"expression - the expression. If the expression is null or the empty string,
it will silently be ignored.FilterParseException - in case the expression is not a valid filter expression.public void loop(PacketHandler callback) throws java.io.IOException, FramingException
java.io.IOExceptionFramingExceptionpublic PcapOutputStream createOutputStream(java.io.OutputStream out) throws java.lang.IllegalArgumentException
PcapOutputStream based on this Pcap. The new
PcapOutputStream is configured to use the same
PcapGlobalHeader as the Pcap is using which means that
you can just safely write frames back out to this
PcapOutputStream. Good for those applications that needs to
filter a Pcap and write out new files.out - java.lang.IllegalArgumentExceptionpublic static Pcap openStream(java.io.InputStream is) throws java.io.IOException
is - java.io.IOExceptionpublic static Pcap openStream(java.io.InputStream is, int bufferCapacity) throws java.io.IOException
is - bufferCapacity - Size of buffer, must be larger than PCAPs largest framesize. See SNAPLENGTH for tcpdump, et.al.java.io.IOExceptionpublic static Pcap openStream(java.io.File file) throws java.io.FileNotFoundException, java.io.IOException
file - the pcap filePcapjava.io.FileNotFoundException - in case the file doesn't exist.java.io.IOExceptionpublic static Pcap openStream(java.lang.String file) throws java.io.FileNotFoundException, java.io.IOException
file - java.io.FileNotFoundExceptionjava.io.IOExceptionpublic void close()
Copyright © 2018. All Rights Reserved.