|
|||||||||
| PREV CLASS NEXT CLASS | FRAMES NO FRAMES | ||||||||
| SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD |
java.lang.Object org.jnetpcap.Pcap
public class Pcap
This class is the main class peered with native pcap_t
structure
in libpcap and winpcap library implementations. It provides a direct mapping
of various library methods from Java.
Pcap
class provides several static methods which allow discovery
of networking interfaces and then subsequently open up either
openLive
, openDead
or openOffline
pcap
capture sessions. In all 3 cases a Pcap
object is returned. The
object is backed by a C pcap_t
structure outside of java VM
address space. Any non-static operations on the Pcap
object, are
translated using java JNI API into corresponding Libpcap C calls and the
appropriate pcap_t
C structure is supplied to complete the call.
After acquiring a Pcap
object from above mentioned static
methods, you must call on close()
call to release any Libpcap
resources and the backing C structure. The Pcap
object does
implicitly call the close()
method from its finalize()
method,
but that will only happen when the Pcap
is garbage collected.
Its best practice to remember to always call on close()
when
Pcap
object and capture session is no longer needed.
If Pcap
object is closed and any of its non-static methods are
called on, after the close, IllegalStateException
will be thrown.
StringBuilder errbuf = new StringBuilder(); List<PcapIf> ifs = new ArrayList<PcapIf>(); // Will hold list of devices int statusCode = Pcap.findAllDevs(ifs, errbuf); if (statusCode != Pcap.OK) { System.out.println("Error occurred: " + errbuf.toString()); return; } // We have a list of PcapIf devices to work with now.
Note: the return value from findAllDevs(java.util.List
is an integer result
code, just like in the C counter part. The ifs
list is filled in
with all the network devices as found from the corresponding C structure
pcap_if
linked list returned from the C function call
findAllDevs.
Now that we have a list of devices, we we print out the list of them and ask the user to pick one to open for capture:
for (int i = 0; i < ifs.size(); i++) { System.out.println("#" + i + ": " + ifs.get(i).getName()); } String l = System.in.readline().trim(); Integer i = Integer.valueOf(l); PcapIf netInterface = ifs.get(i);
openLive(String, int, int, int, StringBuilder)
:
int snaplen = 2048; // Truncate packet at this size int promiscous = Pcap.MODE_PROMISCUOUS; int timeout = 60 * 1000; // In milliseconds Pcap pcap = Pcap.openLive(netInterface.getName(), snaplen, promiscous, timeout, errbuf);Last argument is a buffer that will hold an error string, if error occures. On error
openLive
will return null.
PcapBpfProgram filter = new PcapBpfProgram(); String expression = "port 23" int optimize = 0; // 1 means true, 0 means false int netmask = 0; int r = pcap.compile(PcapBpfProgram, String, int, int)(filter, expression, optimize, netmask); if (r != Pcap.OK) { System.out.println("Filter error: " + pcap.getErr()); } pcap.setFilter(filter);
If filter expression contained a syntax error, the return code will be -1 and
exact error message can be retrieved using getErr()
method.
Note of caution: the PcapBpfProgram
at the top of the
previous code section, can not be accessed until successfully filled in with
values in the pcap.compile(PcapBpfProgram, String, int, int)
code. If you try and access any of its methods an
IllegalStateException
will be thrown. Only after a successful
call to compile(PcapBpfProgram, String, int, int)
does the
object become usable. The object is peered with C structure and until
properly initialized, can not be accessed from java.
PcapHandler<PrintStream> handler = new PcapHandler<PrintStream>() { public void newPacket(PrintStream out, int caplen, int len, int seconds, int usecs, ByteBuffer buffer) { out.println("Packet captured on: " + new Date(seconds * 1000).toString()); } }; int cnt = 10; // Capture packet count PrintStream out = System.out; // Our custom object to send into the handler pcap.loop(cnt, handler, out); // Each packet will be dispatched to the handler pcap.close();
This sets up PCAP to capture 10 packets and notify our handler of each packet as each one is captured. Then after 10 packets the loop exits and we call pcap.close() to free up all the resources and we can safely throw away our pcap object. Also you may be curious why we pass System.out as userData to the loop handler. This is simply to demonstrate the typical usage for this kind of parameter. In our case we could easily pass a different PrintStream bound to lets say a network socket and our handler would produce output to it.
Alternative way of capturing packets from any of the open pcap sessions is to
use dispatch(int, PcapPacketHandler, Object)
method, which works
very similarly to loop(int, PcapPacketHandler, Object)
. You can also
use next(PcapHeader, JBuffer)
and
nextEx(PcapHeader, JBuffer)
methods which will deliver 1 packet at a
time.
The packet data is delivered in a java.nio.ByteBuffer
. The data
is not copied into the buffer, but a direct byte buffer is allocated and
wrapped around the packet data as returned from libpcap. No in memory copies
are performed, so if the native operating system supports no-copy packet
captures, the packet are delivered to Java without copies. Only a single
ByteBuffer object allocation is incurred.
lookupDev
,
lookupNet
. Also any methods that return FILE *
since that is not appropriate for java environment.
Pcap
class does not provide any multithreading capabilities. As
a pure wrapper for native libpcap library, Pcap
does
not provide any additional locking or multithreaded paradigms. The most
suggesting method is the breakloop()
, which can only be used from
another thread. This is the extent of Pcap
's multithreading
capabilities and threads have to be synchronized externally. Extreme care
must be taken, to ensure that no two methods are in use at the same time,
with the exception of breakloop()
. For example, calling on
close()
while a loop is still in progress will cause
libpcap libpcap to crash or core-dump which will also crash the
entire Java VM.
#isPcap100Supported
for more information.
| Nested Class Summary | |
|---|---|
static class |
Pcap.Direction
Enum table which specifies in which direction should pcap capture packets on a capture device. |
| Field Summary | |
|---|---|
static int |
DEFAULT_JPACKET_BUFFER_SIZE
Default JBufferSize used by loop and dispatch methods that utilize this type of buffer. |
static int |
DEFAULT_PROMISC
Default capture promiscous mode to be used (default:. |
static int |
DEFAULT_SNAPLEN
Default capture SNAP len to be used (default: 65536). |
static int |
DEFAULT_TIMEOUT
Default capture timeout (default: 0). |
static int |
DISPATCH_BUFFER_FULL
Value of packet count argument for dispatch method call
which indicates that only as many packets should be returned as will fit
in a single buffer , unless an error occured or breakloop
call was used to interrupt the dispatcher. |
static int |
ERROR
generic error code. |
static int |
ERROR_ACTIVATED
the operation can't be performed on already activated captures. |
static int |
ERROR_BREAK
loop terminated by pcap_breakloop. |
static int |
ERROR_IFACE_NOT_UP
if the capture source is not up. |
static int |
ERROR_NO_SUCH_DEVICE
if the capture source specified when the handle was created doesn't exist. |
static int |
ERROR_NOT_ACTIVATED
the capture needs to be activated. |
static int |
ERROR_NOT_RFMON
operation supported only in monitor mode. |
static int |
ERROR_PERM_DENIED
if the process doesn't have permission to open the capture source. |
static int |
ERROR_RFMON_NOTSUP
if monitor mode was specified but the capture source doesn't support monitor mode. |
static int |
IN
Direction constant for use with setDirection
which indicates the inbound direction. |
static int |
INOUT
Direction constant for use with setDirection
which indicates both in and out directions. |
static java.lang.String |
JNETPCAP_LIBRARY_NAME
Name of the native library that wraps around libpcap and extensions. |
static java.lang.String |
LIBRARY
The Constant LIBRARY. |
static int |
LOOP_INFINATE
Deprecated. use LOOP_INFINITE due to misspelled name |
static int |
LOOP_INFINITE
Value of packet count argument for loop method call which
indicates that the loop should never exit, unless an error occured or
breakloop call was used to interrupt the dispatcher. |
static int |
LOOP_INTERRUPTED
Deprecated. use ERROR_BREAK |
static int |
MODE_BLOCKING
Flag which can be used with setNonBlock method to set the
previously opened pcap descriptor into 'blocking' mode. |
static int |
MODE_NON_BLOCKING
Flag which can be used with setNonBlock method to set the
previously opened pcap descriptor into 'non-blocking' mode. |
static int |
MODE_NON_PROMISCUOUS
Flag used with openLive to specify that the interface should
not be put into promisuous mode, but only if poassible. |
static int |
MODE_PROMISCUOUS
Flag used with openLive to specify that the interface should
be put into promisuous mode. |
static int |
NEXT_EX_EOF
Exit code for nextEx method which indicates that pcap
reached end of file while reading a 'savefile'. |
static int |
NEXT_EX_NOT_OK
Exit code for nextEx method which indicates failure of some
kind. |
static int |
NEXT_EX_OK
Exit code for nextEx method which indicates success. |
static int |
NEXT_EX_TIMEDOUT
Exit code for nextEx method which indicates timeout has
expired before a packet was captured. |
static int |
NOT_OK
Deprecated. use ERROR or WARNING |
static int |
OK
Pcap status return code for most of the methods defined here. |
static int |
OUT
Direction constant for use with setDirection
which indicates the outbound direction. |
static java.lang.String |
PCAP_LIBRARY
The Constant PCAP_LIBRARY. |
static boolean |
PCAP100_LOAD_STATUS
The Constant PCAP100_LOAD_STATUS. |
static java.lang.String |
PCAP100_WRAPPER
The Constant PCAP100_WRAPPER. |
static int |
WARNING
on success with any other warning. |
static int |
WARNING_PROMISC_NOT_SUP
on success on a device that doesn't support promiscuous mode if promiscuous mode was requested. |
static java.lang.String |
WINPCAP_LIBRARY
The Constant WINPCAP_LIBRARY. |
| Constructor Summary | |
|---|---|
Pcap()
Pcap object can only be created by calling one of the static. |
| Method Summary | ||
|---|---|---|
int |
activate()
Is used to activate a packet capture handle to look at packets on the network, with the options that were set on the handle being in effect. |
|
void |
breakloop()
set a flag that will force pcap_dispatch() or pcap_loop() to return rather than looping. |
|
int |
canSetRfmon()
Check whether monitor mode can be set for a not-yet-activated capture handle. |
|
protected void |
checkIsActive()
Checks if the current Pcap structure is active and open. |
|
void |
close()
pcap_close() closes the files associated with p and deallocates resources. |
|
static int |
compile(int snaplen,
int dlt,
PcapBpfProgram program,
java.lang.String str,
int optimize,
int netmask)
Deprecated. use #compileNopcap(int, int, PcapBpfProgram, String, int, int) |
|
int |
compile(PcapBpfProgram program,
java.lang.String str,
int optimize,
int netmask)
Compile a packet filter, converting a high level filtering expression in to a progra that can be interpreted by the kernel-level filtering engine. |
|
static int |
compileNoPcap(int snaplen,
int dlt,
PcapBpfProgram program,
java.lang.String str,
int optimize,
int netmask)
Compile a packet filter without the need of opening an adapter. |
|
static Pcap |
create(java.lang.String device,
java.lang.StringBuilder errbuf)
pcap_create() is used to create a packet capture handle to look at packets on the network. |
|
int |
datalink()
Returns the link layer of an adapter. |
|
static int |
datalinkNameToVal(java.lang.String name)
Translates a data link type name, which is a DLT_ name with the DLT_ removed, to the corresponding data link type value. |
|
static java.lang.String |
datalinkValToDescription(int dlt)
Translates a data link type value to a short description of that data link type. |
|
static java.lang.String |
datalinkValToName(int dlt)
Translates a data link type value to the corresponding data link type name. |
|
|
dispatch(int cnt,
ByteBufferHandler<T> handler,
T user)
Collect a group of packets. |
|
|
dispatch(int cnt,
int id,
JPacketHandler<T> handler,
T user)
Collect a group of packets. |
|
|
dispatch(int cnt,
int id,
PcapPacketHandler<T> handler,
T user)
Collect a group of packets. |
|
|
dispatch(int cnt,
JBufferHandler<T> handler,
T user)
Collect a group of packets. |
|
|
dispatch(int cnt,
JPacketHandler<T> handler,
T user)
Collect a group of packets. |
|
|
dispatch(int cnt,
JPacketHandler<T> handler,
T user,
JScanner scanner)
Collect a group of packets. |
|
int |
dispatch(int cnt,
PcapDumper dumper)
A specialized dispatch method that utilizes a fast native dumper without entering java environment. |
|
|
dispatch(int cnt,
PcapHandler<T> handler,
T user)
Deprecated. user of PcapHandler has been replaced with ByteBufferHandler |
|
|
dispatch(int cnt,
PcapPacketHandler<T> handler,
T user)
Deprecated. user of PcapHandler has been replaced with ByteBufferHandler |
|
|
dispatch(int cnt,
PcapPacketHandler<T> handler,
T user,
JScanner scanner)
Deprecated. user of PcapHandler has been replaced with ByteBufferHandler |
|
PcapDumper |
dumpOpen(java.lang.String fname)
Open a file to write packets. |
|
protected void |
finalize()
Cleanup before we're GCed. |
|
static int |
findAllDevs(java.util.List<PcapIf> alldevs,
java.lang.StringBuilder errbuf)
pcap_findalldevs() constructs a list of network devices that can be opened with pcap_open_live(). |
|
static void |
freeAllDevs(java.util.List<PcapIf> alldevs,
byte[] errbuf)
Deprecated. use of byte[] errbuf is discouraged |
|
static void |
freeAllDevs(java.util.List<PcapIf> alldevs,
java.lang.StringBuilder errbuf)
This method does nothing. |
|
static void |
freecode(PcapBpfProgram program)
This frees up the code structures, but does not released the peered base bpf_program peer structure. |
|
java.lang.String |
getErr()
return the error text pertaining to the last pcap library error. |
|
int |
getNonBlock(java.lang.StringBuilder errbuf)
pcap_getnonblock() returns the current ``non-blocking'' state of the capture descriptor; it always returns 0 on ``savefiles''. |
|
static java.lang.Error |
getPcap080LoadError()
Gets the pcap080 load error. |
|
int |
inject(byte[] buf)
This method allows to send a raw packet to the network. |
|
int |
inject(byte[] buf,
int offset,
int length)
This method allows to send a raw packet to the network. |
|
int |
inject(java.nio.ByteBuffer buf)
This method allows to send a raw packet to the network. |
|
int |
inject(JBuffer buf,
int start,
int len)
Private method to perform work. |
|
static boolean |
isCreateSupported()
Deprecated. use #isPcap100Supported instead |
|
static boolean |
isInjectSupported()
Checks if the current platform has support for pcap_inject call. |
|
static boolean |
isLoaded(java.lang.String methodName,
java.lang.Class<?>... parameterTypes)
Checks if is loaded. |
|
static boolean |
isPcap080Loaded()
Checks if pcap080 API is loaded. |
|
static boolean |
isPcap100Loaded()
Checks if the current version of libpcap installed on the system supports libpcap 1.0.0 API calls. |
|
static boolean |
isSendPacketSupported()
Checks if the current platform has support for pcap_sendpacket call. |
|
int |
isSwapped()
returns true if the current savefile uses a different byte order than the current system. |
|
static java.lang.String |
libVersion()
Returns a pointer to a string giving information about the version of the libpcap library being used; note that it contains more information than just a version number. |
|
static java.lang.String |
lookupDev(java.lang.StringBuilder errbuf)
Returns a network device suitable for use with openLive and
lookupNet . |
|
static int |
lookupNet(java.lang.String device,
JNumber netp,
JNumber maskp,
java.lang.StringBuilder errbuf)
Determines the network number and mask associated with the network device. |
|
static int |
lookupNet(java.lang.String device,
PcapInteger netp,
PcapInteger maskp,
java.lang.StringBuilder errbuf)
Deprecated. use of PcapInteger has been deprecated |
|
|
loop(int cnt,
ByteBufferHandler<T> handler,
T user)
Collect a group of packets. |
|
|
loop(int cnt,
int id,
JPacketHandler<T> handler,
T user)
Collect a group of packets. |
|
|
loop(int cnt,
int id,
PcapPacketHandler<T> handler,
T user)
Collect a group of packets. |
|
|
loop(int cnt,
JBufferHandler<T> handler,
T user)
Collect a group of packets. |
|
|
loop(int cnt,
JPacketHandler<T> handler,
T user)
Collect a group of packets. |
|
|
loop(int cnt,
JPacketHandler<T> handler,
T user,
JScanner scanner)
Collect a group of packets. |
|
int |
loop(int cnt,
PcapDumper dumper)
A specialized loop method that utilizes a fast native dumper without entering java environment. |
|
|
loop(int cnt,
PcapHandler<T> handler,
T user)
Deprecated. use of PcapHandler has been replaced with ByteBufferHandler |
|
|
loop(int cnt,
PcapPacketHandler<T> handler,
T user)
Collect a group of packets. |
|
|
loop(int cnt,
PcapPacketHandler<T> handler,
T user,
JScanner scanner)
Collect a group of packets. |
|
int |
majorVersion()
Return the major version number of the pcap library used to write the savefile. |
|
int |
minorVersion()
Return the minor version number of the pcap library used to write the savefile. |
|
JBuffer |
next(PcapHeader pkt_header,
JBuffer buffer)
Return the next available packet. |
|
java.nio.ByteBuffer |
next(PcapPktHdr pkt_header)
Deprecated. use of PcapPktHdr has been replaced with PcapHeader |
|
int |
nextEx(PcapHeader pkt_header,
JBuffer buffer)
Read a packet from an interface or from an offline capture. |
|
int |
nextEx(PcapPacket packet)
Read a packet from an interface or from an offline capture. |
|
int |
nextEx(PcapPktHdr pkt_header,
PcapPktBuffer buffer)
Deprecated. use PcapHeader and PcapPktBuffer has been deprecated |
|
static Pcap |
openDead(int linktype,
int snaplen)
Create a pcap_t structure without starting a capture. |
|
static Pcap |
openLive(java.lang.String device,
int snaplen,
int promisc,
int timeout,
java.lang.StringBuilder errbuf)
Open a live capture associated with the specified network interface device. |
|
static Pcap |
openOffline(java.lang.String fname,
java.lang.StringBuilder errbuf)
Open a savefile in the tcpdump/libpcap format to read packets. |
|
int |
sendPacket(byte[] buf)
This method allows to send a raw packet to the network. |
|
int |
sendPacket(byte[] buf,
int offset,
int length)
This method allows to send a raw packet to the network. |
|
int |
sendPacket(java.nio.ByteBuffer buf)
This method allows to send a raw packet to the network. |
|
int |
sendPacket(JBuffer buf)
This method allows to send a raw packet to the network. |
|
int |
setBufferSize(long size)
sets the buffer size that will be used on a capture handle when the handle is activated to buffer_size, which is in units of bytes. |
|
int |
setDatalink(int dlt)
Set the current data link type of the pcap descriptor to the type specified by dlt. |
|
int |
setDirection(int dir)
Set the direction for which packets will be captured. |
|
int |
setDirection(Pcap.Direction dir)
Set the direction for which packets will be captured. |
|
int |
setFilter(PcapBpfProgram program)
Associate a filter to a capture. |
|
int |
setNonBlock(int nonBlock,
java.lang.StringBuilder errbuf)
pcap_setnonblock() puts a capture descriptor, opened with pcap_open_live(), into ``non-blocking'' mode, or takes it out of ``non-blocking'' mode, depending on whether the nonblock argument is non-zero or zero. |
|
int |
setPromisc(int promisc)
Set promiscuous mode for a not-yet-activated capture handle. |
|
int |
setRfmon(int rfmon)
Set monitor mode for a not-yet-activated capture handle. |
|
int |
setSnaplen(int snaplen)
Set the snapshot length for a not-yet-activated capture handle. |
|
int |
setTimeout(int timeout)
Set the read timeout for a not-yet-activated capture handle. |
|
int |
snapshot()
Return the dimension of the packet portion (in bytes) that is delivered to the application. |
|
int |
stats(PcapStat stats)
Returns statistics on the current capture. |
|
java.lang.String |
toString()
Prints libVersion that Pcap is based on. |
| Methods inherited from class java.lang.Object |
|---|
clone, equals, getClass, hashCode, notify, notifyAll, wait, wait, wait |
| Field Detail |
|---|
public static final int DEFAULT_JPACKET_BUFFER_SIZE
public static final int DEFAULT_PROMISC
public static final int DEFAULT_SNAPLEN
public static final int DEFAULT_TIMEOUT
public static final int DISPATCH_BUFFER_FULL
dispatch
method call
which indicates that only as many packets should be returned as will fit
in a single buffer , unless an error occured or breakloop
call was used to interrupt the dispatcher. Note, that this constant is
only appropriate value for dispatch
method call. Loop method
uses LOOP_INFINITE for something similar, but definately not identical to
this option.
public static final int ERROR
public static final int ERROR_ACTIVATED
public static final int ERROR_BREAK
public static final int ERROR_IFACE_NOT_UP
public static final int ERROR_NO_SUCH_DEVICE
public static final int ERROR_NOT_ACTIVATED
public static final int ERROR_NOT_RFMON
public static final int ERROR_PERM_DENIED
public static final int ERROR_RFMON_NOTSUP
public static final int IN
setDirection
which indicates the inbound direction. @since 1.4
public static final int INOUT
setDirection
which indicates both in and out directions. @since 1.4
public static final java.lang.String JNETPCAP_LIBRARY_NAME
public static final java.lang.String LIBRARY
@Deprecated public static final int LOOP_INFINATE
LOOP_INFINITE
due to misspelled nameloop
method call which
indicates that the loop should never exit, unless an error occured or
breakloop
call was used to interrupt the dispatcher. Note,
that this constant is not appropriate value for dispatch
method call, which has a different meaning.
public static final int LOOP_INFINITE
loop
method call which
indicates that the loop should never exit, unless an error occured or
breakloop
call was used to interrupt the dispatcher. Note,
that this constant is not appropriate value for dispatch
method call, which has a different meaning.
@Deprecated public static final int LOOP_INTERRUPTED
ERROR_BREAK
loop
and dispatch
methods. This status code indicates that the the dispatcher was
interrupted by a call to breakloop
call.
public static final int MODE_BLOCKING
setNonBlock
method to set the
previously opened pcap descriptor into 'blocking' mode. The flag can also
be the return code from getNonBlock
. The flag has no affect
on 'savefiles'.
public static final int MODE_NON_BLOCKING
setNonBlock
method to set the
previously opened pcap descriptor into 'non-blocking' mode. The flag can
also be the return code from getNonBlock
. The flag has no
affect on 'savefiles'.
public static final int MODE_NON_PROMISCUOUS
openLive
to specify that the interface should
not be put into promisuous mode, but only if poassible. Note, the even
though the flag is specified, the interface could still be opened in
promiscous mode for other reasons, such as a different process had
already put the interface into promiscuous mode.
public static final int MODE_PROMISCUOUS
openLive
to specify that the interface should
be put into promisuous mode.
public static final int NEXT_EX_EOF
nextEx
method which indicates that pcap
reached end of file while reading a 'savefile'.
public static final int NEXT_EX_NOT_OK
nextEx
method which indicates failure of some
kind. Use getErr()
to retrieve the error message.
public static final int NEXT_EX_OK
nextEx
method which indicates success.
public static final int NEXT_EX_TIMEDOUT
nextEx
method which indicates timeout has
expired before a packet was captured. The packet header and packet buffer
do no point to any valid data.
@Deprecated public static final int NOT_OK
ERROR
or WARNING
public static final int OK
public static final int OUT
setDirection
which indicates the outbound direction. @since 1.4
public static final java.lang.String PCAP_LIBRARY
public static final boolean PCAP100_LOAD_STATUS
public static final java.lang.String PCAP100_WRAPPER
public static final int WARNING
public static final int WARNING_PROMISC_NOT_SUP
public static final java.lang.String WINPCAP_LIBRARY
| Constructor Detail |
|---|
public Pcap()
openLive(java.lang.String, int, int, int, java.lang.StringBuilder)
methods.
| Method Detail |
|---|
@Deprecated public static int compile(int snaplen, int dlt, PcapBpfProgram program, java.lang.String str, int optimize, int netmask)
#compileNopcap(int, int, PcapBpfProgram, String, int, int)
Compile a packet filter without the need of opening an adapter. This function converts an high level filtering expression (see Filtering expression syntax) in a program that can be interpreted by the kernel-level filtering engine.
snaplen
- generate code to truncate packets to this length upon a matchdlt
- the first header type within the packet, or data link type of
the interfaceprogram
- initially empty, but after the method call will contain the
compile(PcapBpfProgram, String, int, int)d BPF programstr
- a string containing the textual expression to be
compile(PcapBpfProgram, String, int, int)doptimize
- 1 means to do optimizations, any other value means nonetmask
- netmask needed to determine the broadcast address
program
compile(PcapBpfProgram, String, int, int)
_nopcap() is
similar to compile(PcapBpfProgram, String, int, int)
()
except that instead of passing a pcap structure, one passes the
snaplen and linktype explicitly. It is intended to be used for
compiling filters for direct BPF usage, without necessarily
having called pcap_open(). (
compile(PcapBpfProgram, String, int, int)
_nopcap() is a
wrapper around pcap_open_dead(),
compile(PcapBpfProgram, String, int, int)
(), and
pcap_close(); the latter three routines can be used directly in
order to get the error text for a compilation error.)
Look at the Filtering expression syntax section for details on the str parameter.
public static int compileNoPcap(int snaplen, int dlt, PcapBpfProgram program, java.lang.String str, int optimize, int netmask)
Compile a packet filter without the need of opening an adapter. This function converts an high level filtering expression (see Filtering expression syntax) in a program that can be interpreted by the kernel-level filtering engine.
snaplen
- generate code to truncate packets to this length upon a matchdlt
- the first header type within the packet, or data link type of
the interfaceprogram
- initially empty, but after the method call will contain the
compile(PcapBpfProgram, String, int, int)d BPF programstr
- a string containing the textual expression to be
compile(PcapBpfProgram, String, int, int)doptimize
- 1 means to do optimizations, any other value means nonetmask
- netmask needed to determine the broadcast address
program
compile(PcapBpfProgram, String, int, int)
_nopcap() is
similar to compile(PcapBpfProgram, String, int, int)
()
except that instead of passing a pcap structure, one passes the
snaplen and linktype explicitly. It is intended to be used for
compiling filters for direct BPF usage, without necessarily
having called pcap_open(). (
compile(PcapBpfProgram, String, int, int)
_nopcap() is a
wrapper around pcap_open_dead(),
compile(PcapBpfProgram, String, int, int)
(), and
pcap_close(); the latter three routines can be used directly in
order to get the error text for a compilation error.)
Look at the Filtering expression syntax section for details on the str parameter.
public static Pcap create(java.lang.String device, java.lang.StringBuilder errbuf)
device
- a string that specifies the network device to open; on Linux
systems with 2.2 or later kernels, a source argument of "any"
or NULL can be used to capture packets from all interfaces.errbuf
- If NULL is returned, errbuf is filled in with an appropriate
error mes' sage
activate()
call#isPcap100Supported()
public static int datalinkNameToVal(java.lang.String name)
name
- data link type name
public static java.lang.String datalinkValToDescription(int dlt)
dlt
- data link type value
public static java.lang.String datalinkValToName(int dlt)
dlt
- data link type value
public static int findAllDevs(java.util.List<PcapIf> alldevs, java.lang.StringBuilder errbuf)
alldevs
- the list is filled in with PcapIf
interface
objects; the list must not be immutableerrbuf
- error buffer containing error message as a string on failure
@Deprecated public static void freeAllDevs(java.util.List<PcapIf> alldevs, byte[] errbuf)
alldevs
- is set to point to the first element of the list; each element
of the list is of type PcapIferrbuf
- error buffer containing error message as a string on failurefreeAllDevs(List, StringBuilder)
public static void freeAllDevs(java.util.List<PcapIf> alldevs, java.lang.StringBuilder errbuf)
alldevs
- is set to point to the first element of the list; each element
of the list is of type PcapIferrbuf
- error buffer containing error message as a string on failurepublic static void freecode(PcapBpfProgram program)
program
- program to free up the backend resources forpublic static java.lang.Error getPcap080LoadError()
@Deprecated public static boolean isCreateSupported()
#isPcap100Supported
instead
#isPcap100Supported()
public static boolean isInjectSupported()
inject(byte[])
is supported, otherwise notinject(byte[])
public static boolean isLoaded(java.lang.String methodName, java.lang.Class<?>... parameterTypes)
methodName
- the method nameparameterTypes
- the parameter types
public static boolean isPcap080Loaded()
public static boolean isPcap100Loaded()
This call is optional, normally the system packager ensures that the appropriate versions of the prerequisite libraries are installed. However it is never guarranteed how the user will setup their environmet. This call ensures that the programmer can handle even the extreme case, where installed libpcap version does not support libpcap 1.0.0 API calls.
If this method evaluates to false, meaning that API calls are not available, all libpcap 1.0.0 related calls will throw
UnsatisfiedLinkError
.
Example:
StringBuilder errbuf = new StringBuilder(); List<PcapIf> alldevs = new ArrayList<PcapIf>(); int snaplen = 64 * 1024; int promisc = Pcap.MODE_PROMISCUOUS; int timeout = Pcap.DEFAULT_TIMEOUT; int bufsize = 128 * 1024 * 1024; int direction = Pcap.INOUT; Pcap.findAllDevs(alldevs, errbuf); String device = alldevs.get(0).getName(); Pcap pcap; if (Pcap.isPcap100Supported()) { pcap = Pcap.create(device, errbuf); pcap.setSnaplen(snaplen); pcap.setTimeout(timeout); pcap.setPromisc(promisc); pcap.setBufferSize(bufsize); pcap.setDirection(direction); pcap.activate(); } else { pcap = Pcap.openLive(device, promisc, timeout, errbuf); } pcap.close();
Pcap100
,
activate()
,
create(java.lang.String, java.lang.StringBuilder)
,
canSetRfmon()
,
setBufferSize(long)
,
setDirection(int)
,
setDirection(org.jnetpcap.Pcap.Direction)
,
setPromisc(int)
,
setRfmon(int)
,
setSnaplen(int)
,
setTimeout(int)
public static boolean isSendPacketSupported()
sendPacket(byte[])
is supported, otherwise
notsendPacket(byte[])
public static java.lang.String libVersion()
public static java.lang.String lookupDev(java.lang.StringBuilder errbuf)
openLive
and
lookupNet
.
errbuf
- if there is an error, errbuf is filled with appropriate
message
public static int lookupNet(java.lang.String device, JNumber netp, JNumber maskp, java.lang.StringBuilder errbuf)
Note: this method is deprecated in pcap as it can not be used to pass back information about IP v6 addresses.
device
- device to do the lookup onnetp
- object which will contain the value of network addressmaskp
- object which will contain the value of network netmaskerrbuf
- any error messages if return value is -1
@Deprecated public static int lookupNet(java.lang.String device, PcapInteger netp, PcapInteger maskp, java.lang.StringBuilder errbuf)
Note: this method is deprecated in pcap as it can not be used to pass back information about IP v6 addresses.
device
- device to do the lookup onnetp
- object which will contain the value of network addressmaskp
- object which will contain the value of network netmaskerrbuf
- any error messages if return value is -1
lookupNet(String, JNumber, JNumber, StringBuilder)
public static Pcap openDead(int linktype, int snaplen)
linktype
- pcap DLT link type integer valuesnaplen
- filters generated using the pcap structure will truncate
captured packets to this length
public static Pcap openLive(java.lang.String device, int snaplen, int promisc, int timeout, java.lang.StringBuilder errbuf)
Open a live capture associated with the specified network interface device. pcap_open_live() is used to obtain a packet capture descriptor to look at packets on the network. device is a string that specifies the network device to open; on Linux systems with 2.2 or later kernels, a device argument of "any" or NULL can be used to capture packets from all interfaces. snaplen specifies the maximum number of bytes to capture. If this value is less than the size of a packet that is captured, only the first snaplen bytes of that packet will be captured and provided as packet data. A value of 65535 should be sufficient, on most if not all networks, to capture all the data available from the packet. promisc specifies if the interface is to be put into promiscuous mode. (Note that even if this parameter is false, the interface could well be in promiscuous mode for some other reason.)
For now, this doesn't work on the "any" device; if an argument of "any" or NULL is supplied, the promisc flag is ignored. to_ms specifies the read timeout in milliseconds. The read timeout is used to arrange that the read not necessarily return immediately when a packet is seen, but that it wait for some amount of time to allow more packets to arrive and to read multiple packets from the OS kernel in one operation. Not all platforms support a read timeout; on platforms that don't, the read timeout is ignored. A zero value for to_ms, on platforms that support a read timeout, will cause a read to wait forever to allow enough packets to arrive, with no timeout. errbuf is used to return error or warning text. It will be set to error text when pcap_open_live() fails and returns NULL. errbuf may also be set to warning text when pcap_open_live() succeds; to detect this case the caller should store a zero-length string in errbuf before calling pcap_open_live() and display the warning to the user if errbuf is no longer a zero-length string.
Special note about snaplen
argument. The behaviour of
this argument may be suprizing to some. The argument
is only
applied when there is a filter set using setFilter
method
after the openLive
call. Otherwise snaplen, even non zero is
ignored. This is the behavior of all BSD systems utilizing BPF and
WinPcap. This may change in the future, but that is the current behavior.
(For more detailed explanation and discussion please see jNetPcap website
and its FAQs.)
device
- buffer containing a C, '\0' terminated string with the the
name of the devicesnaplen
- amount of data to capture per packet; (see special note in doc
comments about when this argument is ignored even when
non-zero)promisc
- 1 means open in promiscious mode, a 0 means non-propmiscoustimeout
- timeout in mserrbuf
- a buffer that will contain any error messages if the call to
open failed
pcap_t
C structure as
returned by native libpcap call to openpublic static Pcap openOffline(java.lang.String fname, java.lang.StringBuilder errbuf)
fname
- filename of the pcap fileerrbuf
- any error messages in UTC8 encoding
public int activate()
WARNING_PROMISC_NOT_SUP
on success on a device that
doesn't support promiscuous mode if promiscuous mode was
requested, WARNING
on success with any other warning,
ERROR_ACTIVATED
if the handle has already been
activated, ERROR_NO_SUCH_DEVICE
if the capture source
specified when the handle was created doesn't exist,
ERROR_PERM_DENIED
if the process doesn't have permission
to open the capture source, ERROR_RFMON_NOTSUP
if
monitor mode was specified but the capture source doesn't support
monitor mode, ERROR_IFACE_NOT_UP
if the capture source
is not up, and ERROR
if another error occurred.
If WARNING
or ERROR
is returned,
getErr()
gets the message describing the warning or
error. If WARNING_PROMISC_NOT_SUP
,
ERROR_NO_SUCH_DEVICE
, or ERROR_PERM_DENIED
is
returned, getErr()
gets the message giving additional
details about the problem that might be useful for debugging the
problem if it's unexpected.
#isPcap100Supported()
public void breakloop()
set a flag that will force pcap_dispatch() or pcap_loop() to return rather than looping. They will return the number of packets that have been processed so far, or -2 if no packets have been processed so far. This routine is safe to use inside a signal handler on UNIX or a console control handler on Windows, as it merely sets a flag that is checked within the loop. The flag is checked in loops reading packets from the OS - a signal by itself will not necessarily terminate those loops - as well as in loops processing a set of packets returned by the OS. Note that if you are catching signals on UNIX systems that support restarting system calls after a signal, and calling pcap_breakloop() in the signal handler, you must specify, when catching those signals, that system calls should NOT be restarted by that signal. Otherwise, if the signal interrupted a call reading packets in a live capture, when your signal handler returns after calling pcap_breakloop(), the call will be restarted, and the loop will not terminate until more packets arrive and the call completes.
Note: pcap_next() will, on some platforms, loop reading packets from the OS; that loop will not necessarily be terminated by a signal, so pcap_breakloop() should be used to terminate packet processing even if pcap_next() is being used. pcap_breakloop() does not guarantee that no further packets will be processed by pcap_dispatch() or pcap_loop() after it is called; at most one more packet might be processed. If -2 is returned from pcap_dispatch() or pcap_loop(), the flag is cleared, so a subsequent call will resume reading packets. If a positive number is returned, the flag is not cleared, so a subsequent call will return -2 and clear the flag.
public int canSetRfmon()
ERROR_NO_SUCH_DEVICE
if the device
specified when the handle was created doesn't exist,
ERROR_ACTIVATED
if called on a capture handle that has
been activated, or ERROR
if an error occurred. If
ERROR
is returned, getErr()
gets the error
text.#isPcap100Supported()
protected void checkIsActive() throws PcapClosedException
PcapClosedException
- if pcap_t structure has been deallocated, another words if
Pcap.close has already been called.public void close()
public int compile(PcapBpfProgram program, java.lang.String str, int optimize, int netmask)
program
- initially empty, but after the method call will contain the
compile(PcapBpfProgram, String, int, int)d BPF programstr
- a string containing the textual expression to be
compile(PcapBpfProgram, String, int, int)doptimize
- 1 means to do optimizations, any other value means nonetmask
- netmask needed to determine the broadcast address
getErr()
may be used to display the error text.public int datalink()
public <T> int dispatch(int cnt, ByteBufferHandler<T> handler, T user)
Collect a group of packets. pcap_dispatch() is used to collect and process packets. cnt specifies the maximum number of packets to process before returning. This is not a minimum number; when reading a live capture, only one bufferful of packets is read at a time, so fewer than cnt packets may be processed. A cnt of -1 processes all the packets received in one buffer when reading a live capture, or all the packets in the file when reading a ``savefile''. callback specifies a routine to be called with three arguments: a u_char pointer which is passed in from pcap_dispatch(), a const struct pcap_pkthdr pointer, and a const u_char pointer to the first caplen (as given in the struct pcap_pkthdr a pointer to which is passed to the callback routine) bytes of data from the packet (which won't necessarily be the entire packet; to capture the entire packet, you will have to provide a value for snaplen in your call to pcap_open_live() that is sufficiently large to get all of the packet's data - a value of 65535 should be sufficient on most if not all networks).
The number of packets read is returned. 0 is returned if no packets were
read from a live capture (if, for example, they were discarded because
they didn't pass the packet filter, or if, on platforms that support a
read timeout that starts before any packets arrive, the timeout expires
before any packets arrive, or if the file descriptor for the capture
device is in non-blocking mode and no packets were available to be read)
or if no more packets are available in a ``savefile.'' A return of -1
indicates an error in which case getErr()
() may be used to
display the error text. A return of -2 indicates that the loop terminated
due to a call to pcap_breakloop() before any packets were processed. If
your application uses pcap_breakloop(), make sure that you explicitly
check for -1 and -2, rather than just checking for a return value < 0.
Note: when reading a live capture, pcap_dispatch() will not necessarily return when the read times out; on some platforms, the read timeout isn't supported, and, on other platforms, the timer doesn't start until at least one packet arrives. This means that the read timeout should NOT be used in, for example, an interactive application, to allow the packet capture loop to ``poll'' for user input periodically, as there's no guarantee that pcap_dispatch() will return after the timeout expires.
T
- handler's user object typecnt
- number of packets to readhandler
- called when packet arrives for each packetuser
- opaque user object
public <T> int dispatch(int cnt, int id, JPacketHandler<T> handler, T user)
Collect a group of packets. pcap_dispatch() is used to collect and process packets. cnt specifies the maximum number of packets to process before returning. This is not a minimum number; when reading a live capture, only one bufferful of packets is read at a time, so fewer than cnt packets may be processed. A cnt of -1 processes all the packets received in one buffer when reading a live capture, or all the packets in the file when reading a ``savefile''. callback specifies a routine to be called with three arguments: a u_char pointer which is passed in from pcap_dispatch(), a const struct pcap_pkthdr pointer, and a const u_char pointer to the first caplen (as given in the struct pcap_pkthdr a pointer to which is passed to the callback routine) bytes of data from the packet (which won't necessarily be the entire packet; to capture the entire packet, you will have to provide a value for snaplen in your call to pcap_open_live() that is sufficiently large to get all of the packet's data - a value of 65535 should be sufficient on most if not all networks).
The number of packets read is returned. 0 is returned if no packets were
read from a live capture (if, for example, they were discarded because
they didn't pass the packet filter, or if, on platforms that support a
read timeout that starts before any packets arrive, the timeout expires
before any packets arrive, or if the file descriptor for the capture
device is in non-blocking mode and no packets were available to be read)
or if no more packets are available in a ``savefile.'' A return of -1
indicates an error in which case getErr()
() may be used to
display the error text. A return of -2 indicates that the loop terminated
due to a call to pcap_breakloop() before any packets were processed. If
your application uses pcap_breakloop(), make sure that you explicitly
check for -1 and -2, rather than just checking for a return value < 0.
Note: when reading a live capture, pcap_dispatch() will not necessarily return when the read times out; on some platforms, the read timeout isn't supported, and, on other platforms, the timer doesn't start until at least one packet arrives. This means that the read timeout should NOT be used in, for example, an interactive application, to allow the packet capture loop to ``poll'' for user input periodically, as there's no guarantee that pcap_dispatch() will return after the timeout expires.
This implementation of disptach method performs a scan of the packet
buffer as it is delivered by libpcap. The scanned information is recorded
in native scanner structures which are then peered with a JPacket object
instance. The receiver of the dispatched packets
JPacketHandler.nextPacket
receives fully decoded packets.
This method provides its own thread-local JScanner
and
default shared JPacket
instance. The same packet is
dispatched to the user with the state of the packet being changed between
each dispatch. If the user requires the packet state to persist longer
than a single iteration of the dispatcher, the delivered packets state
must either be peered with a different packet (only copied by reference)
or the entire contents and state must be copied to a new packet (a deep
copy). The shallow copy by reference persists longer, but not
indefinately. It persist as long as libpcap internal large capture buffer
doesn't wrap around. The same goes for JScanner's internal scan buffer,
it too persists until the state information exhausts the buffer and the
buffer is wrapped around to the begining as well overriding any
information in the scan buffer. If there are still any packets that
reference that scan buffer information, once that information is
overriden by the latest scan, the original scan information is gone
forever and will guarrantee that any old packets still pointing at the
scan buffer will have incorrect infromation.
JPacket
class provides methods which allow deep copy of the
packet data and state to be made to a new permanent location. This
mechanism works in conjuction of JMemoryPool
class which
facilitates native memory management on large scale. Once the packet data
and state are deep copied to new memory location, that packet can stay
permanently in memory. The memory will only be released when all the java
object references to that memory are garbage collected. The memory is
deallocated automatically.
T
- user data typecnt
- number of packets to processid
- numerical protocol ID found in JProtocol.ID constant and in
JRegisteryhandler
- user supplied packet handleruser
- a custom opaque user object
public <T> int dispatch(int cnt, int id, PcapPacketHandler<T> handler, T user)
This implementation of disptach method performs a scan of the packet
buffer as it is delivered by libpcap. The scanned information is recorded
in native scanner structures which are then peered with a JPacket object
instance. The receiver of the dispatched packets
JPacketHandler.nextPacket
receives fully decoded packets.
This method provides its own thread-local JScanner
and
default shared JPacket
instance. The same packet is
dispatched to the user with the state of the packet being changed between
each dispatch. If the user requires the packet state to persist longer
than a single iteration of the dispatcher, the delivered packets state
must either be peered with a different packet (only copied by reference)
or the entire contents and state must be copied to a new packet (a deep
copy). The shallow copy by reference persists longer, but not
indefinately. It persist as long as libpcap internal large capture buffer
doesn't wrap around. The same goes for JScanner's internal scan buffer,
it too persists until the state information exhausts the buffer and the
buffer is wrapped around to the begining as well overriding any
information in the scan buffer. If there are still any packets that
reference that scan buffer information, once that information is
overriden by the latest scan, the original scan information is gone
forever and will guarrantee that any old packets still pointing at the
scan buffer will have incorrect infromation.
JPacket
class provides methods which allow deep copy of the
packet data and state to be made to a new permanent location. This
mechanism works in conjuction of JMemoryPool
class which
facilitates native memory management on large scale. Once the packet data
and state are deep copied to new memory location, that packet can stay
permanently in memory. The memory will only be released when all the java
object references to that memory are garbage collected. The memory is
deallocated automatically.
This method derrives the numerical protocol ID for the data link header
automatically using Pcap.datalink()
value returned.
T
- user data typecnt
- number of packets to processid
- numerical protocol ID found in JProtocol.ID constant and in
JRegisteryhandler
- user supplied packet handleruser
- a custom opaque user object
public <T> int dispatch(int cnt, JBufferHandler<T> handler, T user)
Collect a group of packets. pcap_dispatch() is used to collect and process packets. cnt specifies the maximum number of packets to process before returning. This is not a minimum number; when reading a live capture, only one bufferful of packets is read at a time, so fewer than cnt packets may be processed. A cnt of -1 processes all the packets received in one buffer when reading a live capture, or all the packets in the file when reading a ``savefile''. callback specifies a routine to be called with three arguments: a u_char pointer which is passed in from pcap_dispatch(), a const struct pcap_pkthdr pointer, and a const u_char pointer to the first caplen (as given in the struct pcap_pkthdr a pointer to which is passed to the callback routine) bytes of data from the packet (which won't necessarily be the entire packet; to capture the entire packet, you will have to provide a value for snaplen in your call to pcap_open_live() that is sufficiently large to get all of the packet's data - a value of 65535 should be sufficient on most if not all networks).
The number of packets read is returned. 0 is returned if no packets were
read from a live capture (if, for example, they were discarded because
they didn't pass the packet filter, or if, on platforms that support a
read timeout that starts before any packets arrive, the timeout expires
before any packets arrive, or if the file descriptor for the capture
device is in non-blocking mode and no packets were available to be read)
or if no more packets are available in a ``savefile.'' A return of -1
indicates an error in which case getErr()
() may be used to
display the error text. A return of -2 indicates that the loop terminated
due to a call to pcap_breakloop() before any packets were processed. If
your application uses pcap_breakloop(), make sure that you explicitly
check for -1 and -2, rather than just checking for a return value < 0.
Note: when reading a live capture, pcap_dispatch() will not necessarily return when the read times out; on some platforms, the read timeout isn't supported, and, on other platforms, the timer doesn't start until at least one packet arrives. This means that the read timeout should NOT be used in, for example, an interactive application, to allow the packet capture loop to ``poll'' for user input periodically, as there's no guarantee that pcap_dispatch() will return after the timeout expires.
T
- handler's user object typecnt
- number of packets to readhandler
- called when packet arrives for each packetuser
- opaque user object
public <T> int dispatch(int cnt, JPacketHandler<T> handler, T user)
Collect a group of packets. pcap_dispatch() is used to collect and process packets. cnt specifies the maximum number of packets to process before returning. This is not a minimum number; when reading a live capture, only one bufferful of packets is read at a time, so fewer than cnt packets may be processed. A cnt of -1 processes all the packets received in one buffer when reading a live capture, or all the packets in the file when reading a ``savefile''. callback specifies a routine to be called with three arguments: a u_char pointer which is passed in from pcap_dispatch(), a const struct pcap_pkthdr pointer, and a const u_char pointer to the first caplen (as given in the struct pcap_pkthdr a pointer to which is passed to the callback routine) bytes of data from the packet (which won't necessarily be the entire packet; to capture the entire packet, you will have to provide a value for snaplen in your call to pcap_open_live() that is sufficiently large to get all of the packet's data - a value of 65535 should be sufficient on most if not all networks).
The number of packets read is returned. 0 is returned if no packets were
read from a live capture (if, for example, they were discarded because
they didn't pass the packet filter, or if, on platforms that support a
read timeout that starts before any packets arrive, the timeout expires
before any packets arrive, or if the file descriptor for the capture
device is in non-blocking mode and no packets were available to be read)
or if no more packets are available in a ``savefile.'' A return of -1
indicates an error in which case getErr()
() may be used to
display the error text. A return of -2 indicates that the loop terminated
due to a call to pcap_breakloop() before any packets were processed. If
your application uses pcap_breakloop(), make sure that you explicitly
check for -1 and -2, rather than just checking for a return value < 0.
Note: when reading a live capture, pcap_dispatch() will not necessarily return when the read times out; on some platforms, the read timeout isn't supported, and, on other platforms, the timer doesn't start until at least one packet arrives. This means that the read timeout should NOT be used in, for example, an interactive application, to allow the packet capture loop to ``poll'' for user input periodically, as there's no guarantee that pcap_dispatch() will return after the timeout expires.
This implementation of disptach method performs a scan of the packet
buffer as it is delivered by libpcap. The scanned information is recorded
in native scanner structures which are then peered with a JPacket object
instance. The receiver of the dispatched packets
JPacketHandler.nextPacket
receives fully decoded packets.
This method provides its own thread-local JScanner
and
default shared JPacket
instance. The same packet is
dispatched to the user with the state of the packet being changed between
each dispatch. If the user requires the packet state to persist longer
than a single iteration of the dispatcher, the delivered packets state
must either be peered with a different packet (only copied by reference)
or the entire contents and state must be copied to a new packet (a deep
copy). The shallow copy by reference persists longer, but not
indefinately. It persist as long as libpcap internal large capture buffer
doesn't wrap around. The same goes for JScanner's internal scan buffer,
it too persists until the state information exhausts the buffer and the
buffer is wrapped around to the begining as well overriding any
information in the scan buffer. If there are still any packets that
reference that scan buffer information, once that information is
overriden by the latest scan, the original scan information is gone
forever and will guarrantee that any old packets still pointing at the
scan buffer will have incorrect infromation.
JPacket
class provides methods which allow deep copy of the
packet data and state to be made to a new permanent location. This
mechanism works in conjuction of JMemoryPool
class which
facilitates native memory management on large scale. Once the packet data
and state are deep copied to new memory location, that packet can stay
permanently in memory. The memory will only be released when all the java
object references to that memory are garbage collected. The memory is
deallocated automatically.
This method derrives the numerical protocol ID for the data link header
automatically using Pcap.datalink()
value returned.
T
- user data typecnt
- number of packets to processhandler
- user supplied packet handleruser
- a custom opaque user object
public <T> int dispatch(int cnt, JPacketHandler<T> handler, T user, JScanner scanner)
Collect a group of packets. pcap_dispatch() is used to collect and process packets. cnt specifies the maximum number of packets to process before returning. This is not a minimum number; when reading a live capture, only one bufferful of packets is read at a time, so fewer than cnt packets may be processed. A cnt of -1 processes all the packets received in one buffer when reading a live capture, or all the packets in the file when reading a ``savefile''. callback specifies a routine to be called with three arguments: a u_char pointer which is passed in from pcap_dispatch(), a const struct pcap_pkthdr pointer, and a const u_char pointer to the first caplen (as given in the struct pcap_pkthdr a pointer to which is passed to the callback routine) bytes of data from the packet (which won't necessarily be the entire packet; to capture the entire packet, you will have to provide a value for snaplen in your call to pcap_open_live() that is sufficiently large to get all of the packet's data - a value of 65535 should be sufficient on most if not all networks).
The number of packets read is returned. 0 is returned if no packets were
read from a live capture (if, for example, they were discarded because
they didn't pass the packet filter, or if, on platforms that support a
read timeout that starts before any packets arrive, the timeout expires
before any packets arrive, or if the file descriptor for the capture
device is in non-blocking mode and no packets were available to be read)
or if no more packets are available in a ``savefile.'' A return of -1
indicates an error in which case or getErr()
() may be used to
display the error text. A return of -2 indicates that the loop terminated
due to a call to pcap_breakloop() before any packets were processed. If
your application uses pcap_breakloop(), make sure that you explicitly
check for -1 and -2, rather than just checking for a return value < 0.
Note: when reading a live capture, pcap_dispatch() will not necessarily return when the read times out; on some platforms, the read timeout isn't supported, and, on other platforms, the timer doesn't start until at least one packet arrives. This means that the read timeout should NOT be used in, for example, an interactive application, to allow the packet capture loop to ``poll'' for user input periodically, as there's no guarantee that pcap_dispatch() will return after the timeout expires.
This implementation of disptach method performs a scan of the packet
buffer as it is delivered by libpcap. The scanned information is recorded
in native scanner structures which are then peered with a JPacket object
instance. The receiver of the dispatched packets
JPacketHandler.nextPacket
receives fully decoded packets.
This method provides its own thread-local JScanner
and
default shared JPacket
instance. The same packet is
dispatched to the user with the state of the packet being changed between
each dispatch. If the user requires the packet state to persist longer
than a single iteration of the dispatcher, the delivered packets state
must either be peered with a different packet (only copied by reference)
or the entire contents and state must be copied to a new packet (a deep
copy). The shallow copy by reference persists longer, but not
indefinately. It persist as long as libpcap internal large capture buffer
doesn't wrap around. The same goes for JScanner's internal scan buffer,
it too persists until the state information exhausts the buffer and the
buffer is wrapped around to the begining as well overriding any
information in the scan buffer. If there are still any packets that
reference that scan buffer information, once that information is
overriden by the latest scan, the original scan information is gone
forever and will guarrantee that any old packets still pointing at the
scan buffer will have incorrect infromation.
JPacket
class provides methods which allow deep copy of the
packet data and state to be made to a new permanent location. This
mechanism works in conjuction of JMemoryPool
class which
facilitates native memory management on large scale. Once the packet data
and state are deep copied to new memory location, that packet can stay
permanently in memory. The memory will only be released when all the java
object references to that memory are garbage collected. The memory is
deallocated automatically.
This method derrives the numerical protocol ID for the data link header
automatically using Pcap.datalink()
value returned.
T
- user data typecnt
- number of packets to processhandler
- user supplied packet handleruser
- a custom opaque user objectscanner
- user supplied custom packet scanner
public int dispatch(int cnt, PcapDumper dumper)
cnt
- number of packets to readdumper
- open pcap dumper to dump all packets to
@Deprecated public <T> int dispatch(int cnt, PcapHandler<T> handler, T user)
The number of packets read is returned. 0 is returned if no packets were
read from a live capture (if, for example, they were discarded because
they didn't pass the packet filter, or if, on platforms that support a
read timeout that starts before any packets arrive, the timeout expires
before any packets arrive, or if the file descriptor for the capture
device is in non-blocking mode and no packets were available to be read)
or if no more packets are available in a ``savefile.'' A return of -1
indicates an error in which case getErr()
() may be used to
display the error text. A return of -2 indicates that the loop terminated
due to a call to pcap_breakloop() before any packets were processed. If
your application uses pcap_breakloop(), make sure that you explicitly
check for -1 and -2, rather than just checking for a return value < 0.
Note: when reading a live capture, pcap_dispatch() will not necessarily return when the read times out; on some platforms, the read timeout isn't supported, and, on other platforms, the timer doesn't start until at least one packet arrives. This means that the read timeout should NOT be used in, for example, an interactive application, to allow the packet capture loop to ``poll'' for user input periodically, as there's no guarantee that pcap_dispatch() will return after the timeout expires.
T
- handler's user object typecnt
- number of packets to readhandler
- called when packet arrives for each packetuser
- opaque user object
ByteBufferHandler
@Deprecated public <T> int dispatch(int cnt, PcapPacketHandler<T> handler, T user)
The number of packets read is returned. 0 is returned if no packets were
read from a live capture (if, for example, they were discarded because
they didn't pass the packet filter, or if, on platforms that support a
read timeout that starts before any packets arrive, the timeout expires
before any packets arrive, or if the file descriptor for the capture
device is in non-blocking mode and no packets were available to be read)
or if no more packets are available in a ``savefile.'' A return of -1
indicates an error in which case getErr()
() may be used to
display the error text. A return of -2 indicates that the loop terminated
due to a call to pcap_breakloop() before any packets were processed. If
your application uses pcap_breakloop(), make sure that you explicitly
check for -1 and -2, rather than just checking for a return value < 0.
Note: when reading a live capture, pcap_dispatch() will not necessarily return when the read times out; on some platforms, the read timeout isn't supported, and, on other platforms, the timer doesn't start until at least one packet arrives. This means that the read timeout should NOT be used in, for example, an interactive application, to allow the packet capture loop to ``poll'' for user input periodically, as there's no guarantee that pcap_dispatch() will return after the timeout expires.
T
- handler's user object typecnt
- number of packets to readhandler
- called when packet arrives for each packetuser
- opaque user object
ByteBufferHandler
@Deprecated public <T> int dispatch(int cnt, PcapPacketHandler<T> handler, T user, JScanner scanner)
The number of packets read is returned. 0 is returned if no packets were
read from a live capture (if, for example, they were discarded because
they didn't pass the packet filter, or if, on platforms that support a
read timeout that starts before any packets arrive, the timeout expires
before any packets arrive, or if the file descriptor for the capture
device is in non-blocking mode and no packets were available to be read)
or if no more packets are available in a ``savefile.'' A return of -1
indicates an error in which case getErr()
() may be used to
display the error text. A return of -2 indicates that the loop terminated
due to a call to pcap_breakloop() before any packets were processed. If
your application uses pcap_breakloop(), make sure that you explicitly
check for -1 and -2, rather than just checking for a return value < 0.
Note: when reading a live capture, pcap_dispatch() will not necessarily return when the read times out; on some platforms, the read timeout isn't supported, and, on other platforms, the timer doesn't start until at least one packet arrives. This means that the read timeout should NOT be used in, for example, an interactive application, to allow the packet capture loop to ``poll'' for user input periodically, as there's no guarantee that pcap_dispatch() will return after the timeout expires.
T
- handler's user object typecnt
- number of packets to readhandler
- called when packet arrives for each packetuser
- opaque user objectscanner
- a custom user quick-scanner for parsing headers within the
packet
ByteBufferHandler
public PcapDumper dumpOpen(java.lang.String fname)
dumpOpen
method is called
to open a "savefile" for writing. The name '-' is a synonym for stdout.
fname
- specifies the name of the file to open; currently the libpcap
option to open stdout by using "-" as a string, is not
supported by jNetPcap
getErr
method
to retrieve the error messageprotected void finalize()
finalize
in class java.lang.Object
public java.lang.String getErr()
Note: the pointer Return will no longer point to a valid error message string after the pcap_t passed to it is closed; you must use or copy the string before closing the pcap_t.
public int getNonBlock(java.lang.StringBuilder errbuf)
errbuf
- error buffer where error message will be stored on error
setNonBlock(int, StringBuilder)
public int inject(byte[] buf)
buf
- contains the data of the packet to send (including the various
protocol headers)
public int inject(byte[] buf, int offset, int length)
buf
- contains the data of the packet to send (including the various
protocol headers)offset
- offset of the first index into the byte arraylength
- amount of data to write from the offset
public int inject(java.nio.ByteBuffer buf)
buf
- contains the data of the packet to send (including the various
protocol headers); the buffer should be a direct buffer; array
based buffers will be copied into a direct buffer
public int inject(JBuffer buf, int start, int len)
buf
- buffer contains raw data to sendstart
- offset into the bufferlen
- number of bytes to send
public int isSwapped()
public <T> int loop(int cnt, ByteBufferHandler<T> handler, T user)
T
- handler's user object typecnt
- number of packets to readhandler
- called when packet arrives for each packetuser
- opaque user object
public <T> int loop(int cnt, int id, JPacketHandler<T> handler, T user)
This implementation of disptach method performs a scan of the packet
buffer as it is delivered by libpcap. The scanned information is recorded
in native scanner structures which are then peered with a JPacket object
instance. The receiver of the dispatched packets
JPacketHandler.nextPacket
receives fully decoded packets.
This method provides its own thread-local JScanner
and
default shared JPacket
instance. The same packet is
dispatched to the user with the state of the packet being changed between
each dispatch. If the user requires the packet state to persist longer
than a single iteration of the dispatcher, the delivered packets state
must either be peered with a different packet (only copied by reference)
or the entire contents and state must be copied to a new packet (a deep
copy). The shallow copy by reference persists longer, but not
indefinately. It persist as long as libpcap internal large capture buffer
doesn't wrap around. The same goes for JScanner's internal scan buffer,
it too persists until the state information exhausts the buffer and the
buffer is wrapped around to the begining as well overriding any
information in the scan buffer. If there are still any packets that
reference that scan buffer information, once that information is
overriden by the latest scan, the original scan information is gone
forever and will guarrantee that any old packets still pointing at the
scan buffer will have incorrect infromation.
JPacket
class provides methods which allow deep copy of the
packet data and state to be made to a new permanent location. This
mechanism works in conjuction of JMemoryPool
class which
facilitates native memory management on large scale. Once the packet data
and state are deep copied to new memory location, that packet can stay
permanently in memory. The memory will only be released when all the java
object references to that memory are garbage collected. The memory is
deallocated automatically.
This method derrives the numerical protocol ID for the data link header
automatically using Pcap.datalink()
value returned.
T
- user data typecnt
- number of packets to processid
- numerical protocol ID found in JProtocol.ID constant and in
JRegisteryhandler
- user supplied packet handleruser
- a custom opaque user object
public <T> int loop(int cnt, int id, PcapPacketHandler<T> handler, T user)
This implementation of disptach method performs a scan of the packet
buffer as it is delivered by libpcap. The scanned information is recorded
in native scanner structures which are then peered with a JPacket object
instance. The receiver of the dispatched packets
JPacketHandler.nextPacket
receives fully decoded packets.
This method provides its own thread-local JScanner
and
default shared JPacket
instance. The same packet is
dispatched to the user with the state of the packet being changed between
each dispatch. If the user requires the packet state to persist longer
than a single iteration of the dispatcher, the delivered packets state
must either be peered with a different packet (only copied by reference)
or the entire contents and state must be copied to a new packet (a deep
copy). The shallow copy by reference persists longer, but not
indefinately. It persist as long as libpcap internal large capture buffer
doesn't wrap around. The same goes for JScanner's internal scan buffer,
it too persists until the state information exhausts the buffer and the
buffer is wrapped around to the begining as well overriding any
information in the scan buffer. If there are still any packets that
reference that scan buffer information, once that information is
overriden by the latest scan, the original scan information is gone
forever and will guarrantee that any old packets still pointing at the
scan buffer will have incorrect infromation.
JPacket
class provides methods which allow deep copy of the
packet data and state to be made to a new permanent location. This
mechanism works in conjuction of JMemoryPool
class which
facilitates native memory management on large scale. Once the packet data
and state are deep copied to new memory location, that packet can stay
permanently in memory. The memory will only be released when all the java
object references to that memory are garbage collected. The memory is
deallocated automatically.
This method derrives the numerical protocol ID for the data link header
automatically using Pcap.datalink()
value returned.
T
- user data typecnt
- number of packets to processid
- numerical protocol ID found in JProtocol.ID constant and in
JRegisteryhandler
- user supplied packet handleruser
- a custom opaque user object
public <T> int loop(int cnt, JBufferHandler<T> handler, T user)
T
- handler's user object typecnt
- number of packets to readhandler
- called when packet arrives for each packetuser
- opaque user object
public <T> int loop(int cnt, JPacketHandler<T> handler, T user)
This implementation of disptach method performs a scan of the packet
buffer as it is delivered by libpcap. The scanned information is recorded
in native scanner structures which are then peered with a JPacket object
instance. The receiver of the dispatched packets
JPacketHandler.nextPacket
receives fully decoded packets.
This method provides its own thread-local JScanner
and
default shared JPacket
instance. The same packet is
dispatched to the user with the state of the packet being changed between
each dispatch. If the user requires the packet state to persist longer
than a single iteration of the dispatcher, the delivered packets state
must either be peered with a different packet (only copied by reference)
or the entire contents and state must be copied to a new packet (a deep
copy). The shallow copy by reference persists longer, but not
indefinately. It persist as long as libpcap internal large capture buffer
doesn't wrap around. The same goes for JScanner's internal scan buffer,
it too persists until the state information exhausts the buffer and the
buffer is wrapped around to the begining as well overriding any
information in the scan buffer. If there are still any packets that
reference that scan buffer information, once that information is
overriden by the latest scan, the original scan information is gone
forever and will guarrantee that any old packets still pointing at the
scan buffer will have incorrect infromation.
JPacket
class provides methods which allow deep copy of the
packet data and state to be made to a new permanent location. This
mechanism works in conjuction of JMemoryPool
class which
facilitates native memory management on large scale. Once the packet data
and state are deep copied to new memory location, that packet can stay
permanently in memory. The memory will only be released when all the java
object references to that memory are garbage collected. The memory is
deallocated automatically.
T
- user data typecnt
- number of packets to processhandler
- user supplied packet handleruser
- a custom opaque user object
public <T> int loop(int cnt, JPacketHandler<T> handler, T user, JScanner scanner)
This implementation of disptach method performs a scan of the packet
buffer as it is delivered by libpcap. The scanned information is recorded
in native scanner structures which are then peered with a JPacket object
instance. The receiver of the dispatched packets
JPacketHandler.nextPacket
receives fully decoded packets.
This method provides its own thread-local JScanner
and
default shared JPacket
instance. The same packet is
dispatched to the user with the state of the packet being changed between
each dispatch. If the user requires the packet state to persist longer
than a single iteration of the dispatcher, the delivered packets state
must either be peered with a different packet (only copied by reference)
or the entire contents and state must be copied to a new packet (a deep
copy). The shallow copy by reference persists longer, but not
indefinately. It persist as long as libpcap internal large capture buffer
doesn't wrap around. The same goes for JScanner's internal scan buffer,
it too persists until the state information exhausts the buffer and the
buffer is wrapped around to the begining as well overriding any
information in the scan buffer. If there are still any packets that
reference that scan buffer information, once that information is
overriden by the latest scan, the original scan information is gone
forever and will guarrantee that any old packets still pointing at the
scan buffer will have incorrect infromation.
JPacket
class provides methods which allow deep copy of the
packet data and state to be made to a new permanent location. This
mechanism works in conjuction of JMemoryPool
class which
facilitates native memory management on large scale. Once the packet data
and state are deep copied to new memory location, that packet can stay
permanently in memory. The memory will only be released when all the java
object references to that memory are garbage collected. The memory is
deallocated automatically.
T
- user data typecnt
- number of packets to processhandler
- user supplied packet handleruser
- a custom opaque user objectscanner
- user supplied custom packet scanner
public int loop(int cnt, PcapDumper dumper)
cnt
- number of packets to readdumper
- open pcap dumper to dump all packets to
@Deprecated public <T> int loop(int cnt, PcapHandler<T> handler, T user)
T
- handler's user object typecnt
- number of packets to readhandler
- called when packet arrives for each packetuser
- opaque user object
ByteBufferHandler
public <T> int loop(int cnt, PcapPacketHandler<T> handler, T user)
This implementation of disptach method performs a scan of the packet
buffer as it is delivered by libpcap. The scanned information is recorded
in native scanner structures which are then peered with a JPacket object
instance. The receiver of the dispatched packets
JPacketHandler.nextPacket
receives fully decoded packets.
This method provides its own thread-local JScanner
and
default shared JPacket
instance. The same packet is
dispatched to the user with the state of the packet being changed between
each dispatch. If the user requires the packet state to persist longer
than a single iteration of the dispatcher, the delivered packets state
must either be peered with a different packet (only copied by reference)
or the entire contents and state must be copied to a new packet (a deep
copy). The shallow copy by reference persists longer, but not
indefinately. It persist as long as libpcap internal large capture buffer
doesn't wrap around. The same goes for JScanner's internal scan buffer,
it too persists until the state information exhausts the buffer and the
buffer is wrapped around to the begining as well overriding any
information in the scan buffer. If there are still any packets that
reference that scan buffer information, once that information is
overriden by the latest scan, the original scan information is gone
forever and will guarrantee that any old packets still pointing at the
scan buffer will have incorrect infromation.
JPacket
class provides methods which allow deep copy of the
packet data and state to be made to a new permanent location. This
mechanism works in conjuction of JMemoryPool
class which
facilitates native memory management on large scale. Once the packet data
and state are deep copied to new memory location, that packet can stay
permanently in memory. The memory will only be released when all the java
object references to that memory are garbage collected. The memory is
deallocated automatically.
T
- user data typecnt
- number of packets to processhandler
- user supplied packet handleruser
- a custom opaque user object
public <T> int loop(int cnt, PcapPacketHandler<T> handler, T user, JScanner scanner)
This implementation of disptach method performs a scan of the packet
buffer as it is delivered by libpcap. The scanned information is recorded
in native scanner structures which are then peered with a JPacket object
instance. The receiver of the dispatched packets
JPacketHandler.nextPacket
receives fully decoded packets.
This method provides its own thread-local JScanner
and
default shared JPacket
instance. The same packet is
dispatched to the user with the state of the packet being changed between
each dispatch. If the user requires the packet state to persist longer
than a single iteration of the dispatcher, the delivered packets state
must either be peered with a different packet (only copied by reference)
or the entire contents and state must be copied to a new packet (a deep
copy). The shallow copy by reference persists longer, but not
indefinately. It persist as long as libpcap internal large capture buffer
doesn't wrap around. The same goes for JScanner's internal scan buffer,
it too persists until the state information exhausts the buffer and the
buffer is wrapped around to the begining as well overriding any
information in the scan buffer. If there are still any packets that
reference that scan buffer information, once that information is
overriden by the latest scan, the original scan information is gone
forever and will guarrantee that any old packets still pointing at the
scan buffer will have incorrect infromation.
JPacket
class provides methods which allow deep copy of the
packet data and state to be made to a new permanent location. This
mechanism works in conjuction of JMemoryPool
class which
facilitates native memory management on large scale. Once the packet data
and state are deep copied to new memory location, that packet can stay
permanently in memory. The memory will only be released when all the java
object references to that memory are garbage collected. The memory is
deallocated automatically.
T
- user data typecnt
- number of packets to processhandler
- user supplied packet handleruser
- a custom opaque user objectscanner
- user supplied custom packet scanner
public int majorVersion()
public int minorVersion()
public JBuffer next(PcapHeader pkt_header, JBuffer buffer)
pkt_header
- a packet header that will be initialized to corresponding C
structure captured valuesbuffer
- a buffer that will be peered with returned buffer from libpcap
@Deprecated public java.nio.ByteBuffer next(PcapPktHdr pkt_header)
pkt_header
- a packet header that will be initialized to corresponding C
structure captured values
PcapHeader
public int nextEx(PcapHeader pkt_header, JBuffer buffer)
pkt_header
- a packet header that will be initialized to corresponding C
structure captured valuesbuffer
- buffer containing packet data or null if error occured
public int nextEx(PcapPacket packet)
Read a packet from an interface or from an offline capture. This function is used to retrieve the next available packet, bypassing the callback method traditionally provided by libpcap. The packet that is supplied as formal parameter, is used to peer, not copy, with the header and buffer of the next packet returned from libpcap. The supplied packet's PcapHeader is used to peer with the libpcap provided header and the packet object itself is used to peer with the libpcap provided packet buffer.
The packet contents will point at libpcap buffer space which is not permanent. If packet contents are to be referenced on more permanent basis, it will be neccessary to copy the contents to a new packet. Here is a short example:
Pcap pcap = ...; // From somewhere PcapPacket packet = new PcapPacket(JMemory.POINTER); while (nextEx(packet) == Pcap.NEXT_EX_OK) { PcapPacket copy = new PcapPacket(packet); // Make the copy and new obj }
packet
- packet that will be peered with the next libpcap returned
packet
@Deprecated public int nextEx(PcapPktHdr pkt_header, PcapPktBuffer buffer)
pkt_header
- a packet header that will be initialized to corresponding C
structure captured valuesbuffer
- buffer containing packet data or null if error occured
PcapHeader
,
JBuffer
public int sendPacket(byte[] buf)
buf
- contains the data of the packet to send (including the various
protocol headers)
public int sendPacket(byte[] buf, int offset, int length)
buf
- contains the data of the packet to send (including the various
protocol headers)offset
- offset of the first index into the byte arraylength
- amount of data to write from the offset
public int sendPacket(java.nio.ByteBuffer buf)
buf
- contains the data of the packet to send (including the various
protocol headers); the buffer should be a direct buffer; array
based buffers will be copied into a direct buffer
public int sendPacket(JBuffer buf)
buf
- contains the data of the packet to send (including the various
protocol headers); the buffer should be a direct buffer; array
based buffers will be copied into a direct buffer
public int setBufferSize(long size)
size
- size that will be used on a capture handle
ERROR_ACTIVATED
if called on a capture
handle that has been activated.#isPcap100Supported()
public int setDatalink(int dlt)
dlt
- new dlt
public int setDirection(Pcap.Direction dir)
setDirection()
is used to specify a direction that packets
will be captured. dir is one of the constants Pcap.Direction.IN
,
dir
- direction that packets will be captured.
ERROR
on failure. If
Pcap.Direction.OUT
or Pcap.Direction.INOUT
.
Pcap.Direction.IN
will only capture packets received by the
device, Pcap.Direction.OUT
will only capture packets sent by
the device and Pcap.Direction.INOUT
will capture packets
received by or sent by the device. Pcap.Direction.INOUT
is the
default setting if this function is not called.
pcap_setdirection() isn't necessarily fully supported on all
platforms; some platforms might return an error for all values,
and some other platforms might not support Pcap.Direction.OUT
.
This operation is not supported if a "savefile" is being read.
ERROR
is returned, getErr()
gets the error
text.#isPcap100Supported()
public int setDirection(int dir)
setDirection()
is used to specify a direction that packets
will be captured. dir is one of the constants Pcap.Direction.IN
,
dir
- direction that packets will be captured.
ERROR
on failure. If
Pcap.Direction.OUT
or Pcap.Direction.INOUT
.
Pcap.Direction.IN
will only capture packets received by the
device, Pcap.Direction.OUT
will only capture packets sent by
the device and Pcap.Direction.INOUT
will capture packets
received by or sent by the device. Pcap.Direction.INOUT
is the
default setting if this function is not called.
pcap_setdirection() isn't necessarily fully supported on all
platforms; some platforms might return an error for all values,
and some other platforms might not support Pcap.Direction.OUT
.
This operation is not supported if a "savefile" is being read.
This method is private since native method uses specific pcap_direction_t enum structure to make the call and java int doesn't provide the proper typesafety. This is why we use a public method first requiring a java enum type, and convert that to appropriate native integer value.
ERROR
is returned, getErr()
gets the error
text.#isPcap100Supported()
public int setFilter(PcapBpfProgram program)
compile(PcapBpfProgram, String, int, int)
.
-1 is returned on failure, in which case getErr()
() may be used
to display the error text; 0 is returned on success.
program
- the program
getErr()
() may
be used to display the error text; 0 is returned on successpublic int setNonBlock(int nonBlock, java.lang.StringBuilder errbuf)
nonBlock
- a non negative value means to set in non blocking modeerrbuf
- error buffer where error message will be stored on error
getNonBlock(StringBuilder)
public int setPromisc(int promisc)
promisc
- if promisc is non-zero, promiscuous mode will be set,
otherwise it will not be set
ERROR_ACTIVATED
if called on a
capture handle that has been activated#isPcap100Supported()
public int setRfmon(int rfmon)
rfmon
- sets whether monitor mode should be set on a capture handle
when the handle is activated. If rfmon is non-zero, monitor
mode will be set, otherwise it will not be set.
ERROR_ACTIVATED
if called on a
capture handle that has been activated#isPcap100Supported()
public int setSnaplen(int snaplen)
snaplen
- snapshot length
ERROR_ACTIVATED
if called on a
capture handle that has been activated#isPcap100Supported()
public int setTimeout(int timeout)
timeout
- timeout value in milli seconds
ERROR_ACTIVATED
if called on a
capture handle that has been activated#isPcap100Supported()
public int snapshot()
setSnaplen(int)
or
openLive(String, int, int, int, StringBuilder)
was
called, for a live capture, or the snapshot length from the
capture file, for a "savefile".openLive(String, int, int, int, StringBuilder)
public int stats(PcapStat stats)
stats
- PcapStat object to fill in
getErr
to retrieve the
error messagepublic java.lang.String toString()
toString
in class java.lang.Object
|
|||||||||
| PREV CLASS NEXT CLASS | FRAMES NO FRAMES | ||||||||
| SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD |


TITLE 2: HAWAIIAN HOMES COMMISSION
§201. Definitions. (a) When used in this title:
"Commission" means the Hawaiian homes commission.
"Fund" means the Hawaiian home loan fund.
"Hawaiian home lands" means all lands given the status of Hawaiian home lands under the provisions of section 204 of this title.
"Irrigated pastoral land" means land not in the description of the agricultural land but which, through irrigation, is capable of carrying more livestock the year through than first-class pastoral land.
"Native Hawaiian" means any descendant of not less than one-half part of the blood of the races inhabiting the Hawaiian Islands previous to 1778.
"Public land" has the same meaning as defined in paragraph (3) of subdivision (a) of section 73 of the Hawaiian Organic Act.
"State" means the State of Hawaii.
"Tract" means any tract of Hawaiian home lands leased, as authorized by section 207 of this title, or any portion of the tract.
(b) Any term defined or described in section 347 or 351 of the Revised Laws of Hawaii of 1915, except a term defined in subsection (a) of this section, shall, whenever used in this title, have the same meaning as given by such definition or description. [Am Jun.8, 1954, c 321, §2, 68 Stat 263; am L 1963, c 207, §5(a); am L 1997, c 197, §1]
Revision Note
Definitions rearranged pursuant to §23G-15.
Law Journals and Reviews
The Lum Court and Native Hawaiian Rights. 14 UH L. Rev. 377.
The Crown Lands Trust: Who Were, Who Are, the Beneficiaries? 38 UH L. Rev. 213 (2016).
Case Notes
Native Hawaiians have no standing to challenge constitutionality of Act on equal protection grounds as they would be asserting the rights of non-Hawaiian third parties. 795 F. Supp. 1009.


# {{ recipeTitle }}
{{ gettext('## Ingredients:') }}
{% for ingred in recipeIngreds %}
{{ ingred }}
{% endfor %}
{{ gettext('## Directions:') }}
{% for instruct in recipeInstruct %}
{{ instruct }}
{% endfor %}
{{ Error }}
{{ gettext('Convert recipes to Markdown.') }}
{{ gettext('Enter an URL and press "Submit"') }}
{{ gettext('Want to save recipes from a website? Want to convert them to Markdown automatically? recipe.md lets you save recipes as Markdwown files easily.') }}
{{ gettext('If something is broken:') }}


Bears
There are three kinds of bears, the grizzly bear, the bear, and the bear. Bears spend most of their time or . They look very , but if you make them , they might bite your .
There are three kinds of bears, the grizzly bear, the bear, and the bear. Bears spend most of their time or . They look very , but if you make them , they might bite your .


Unanimous offers many oppourtunities for all kinds of work.
Jump straight to the front-line of production. Members of the Work Force are what gives Unanimous its backbone. Make an impact in Unanimous's global activities.
Service members provide essentials for our Work Force and Administration. Goods, transportation, and maintenance are all necessary for a nation to function.
Have what it takes to lead the first coporate nation in history? Administrative personel are key leaders in developing Unanimous's latest most-advanced technologies like Elite Status and Civil Credit.


Saturday 4.16.16
4:30 - 10:00 PM
150 Wagner Rd
Sonoma California
A shuttle will be provided for transportation to and from the wedding site.
The Sonoma pickup and dropoff location is the City Hall parking lot in the center of the square.
The shuttle runs from Sonoma to the Wedding Venue at 300pm and 345pm.
The shuttle runs from the Wedding Venue to Sonoma at 900pm, 930pm and 1000pm.
Drive to Sonoma California
Fly into Oakland or San Francisco California, then drive to Sonoma
We recommend people stay within walking distance of Sonoma Plaza.
If you need any other information regarding our wedding, please contact either Heath or Kaleen.


three.js
- original algorithm from THREE.ShapeUtils
earcut.js
- earcut triangulation library
poly2tri.js
- poly2tri triangulation library
libtess.js
- libtess tesselation library
Select a shape:
Load


Video: Watch Google Lens Bring The Pokémon Sword And Shield Japanese Box Art To Life
The future is here
by Liam DoolanThe Pokémon Company is promoting the release of Sword and Shield on the Nintendo Switch in Japan with the assistance of Google Lens.
In case you didn't know, this is a mobile application that allows you to "search what you see" and "understand the world around you" using just a camera or a photo, according to the official description on Google Play.
If you scan the Japanese physical box of Pokémon Sword or Shield, the augmented tech will then play a special video over the top of the artwork.
Have you used this mobile app before? Did you even purchase a hard copy of Sword or Shield? Comment below.
[via twitter.com]


--- layout: default title: Quite Francly 2017 ---
In 2017 all of our wines were destemmed cold soaked for 4 days. Yeast was pitched and the wines were fermented on skins with stems. Wines were pressed after 4 months on skins. They were racked 3 times but not filtered.
This wine was out prestige wine and thus is composed only of free run and aged exclusively in new american oak.


Browse through our list of Home Decor Items.
Flash Sale on Living Room and Bedroom Furniture.
Bring the best out of the masterchef in you!
Red hot deals at affordable prices. Check out our clearance section for more details.
Browse through our list of Home Decor Items.
Flash Sale on Living Room and Bedroom Furniture.
Bring the best out of the masterchef in you!
Red hot deals at affordable prices. Check out our clearance section for more details.
Browse through our list of Home Decor Items.
Flash Sale on Living Room and Bedroom Furniture.
Bring the best out of the masterchef in you!
Red hot deals at affordable prices. Check out our clearance section for more details.


After this I looked, and behold, a great multitude that no one could number, from every nation, from all tribes and peoples and languages, standing before the throne and before the Lamb, clothed in white robes, with palm branches in their hands,
View the Scripture atBiblegateway.com
Gondi
Madya
Toda
Mavilan Tulu
Kuvi
Alukurumba
Halbi
Veliankaadu Irula
Vettakaadu Irula
Kunjappanai Irula
Kotha
Badaga
Chambyali
Hariyanvi
Badhrawahi


Constructor
new CompositionEngine(viewEngine: ViewEngine, viewLocator: ViewLocator): CompositionEngine
Creates an instance of the CompositionEngine.
Parameters
viewEngine: ViewEngine
viewLocator: ViewLocator


{% extends "global/Page.html" %} {% load otree static %} {% block title %} Now, please make a choice {% endblock %} {% block scripts %} {% endblock %} {% block styles %} {% endblock %} {% block content %}
Make a choice by clicking one of the two options below.
Competition will start once you and your two opponents have made your choices.
Please make a choice:
I want to learn the scores my opponents obtained in Part 1
I do not want to learn the scores my opponents obtained in Part 1
If you do not submit your answer within {{ pageTimeoutWording }}, you will not be allowed to participate in the remainder of the study.


% const { language, name, tag: { appleTouchStartup: appleTouchStartupTags = [], graph: graphTags = [], graphImage: graphImageTags = [], icon: iconTags = [], link: linkTags = [], meta: metaTags = [], }, } = manifest const serviceWorkerUrl = documentUrl('serviceWorker') %>
Not installable
Installing
Installed
Running as an app


Contents
$XORG_PREFIX
/share/fonts/100dpi, $XORG_PREFIX
/share/fonts/75dpi, $XORG_PREFIX
/share/fonts/misc
Xorg's ancestor (X11R1, in 1987) at first only provided bitmap fonts, with a tool (bdftopcf) to assist in their installation. With the introduction of xorg-server-1.19.0 and libXfont2 many people will not need them. There are still a few old packages which might require, or benefit from, these deprecated fonts and so the following packages are shown here.
The font-adobe-100dpi package installs 100 dots per inch versions of Courier, Helvetica, New Century Schoolbook and Times fonts.
The remaining font packages here provide 75dpi versions of those fonts, and various miscellaneous fonts - mostly for legacy encodings. Those are primarily to silence warnings when testing Xorg. In previous versions of BLFS a lot more legacy fonts were installed.
Please consult the BLFS-7.10 book at http://www.linuxfromscratch.org/blfs/view/7.10/x/x7font.html if you wish to install any of those other fonts.
This package is known to build and work properly using an LFS-9.1 platform.
Download (HTTP): https://www.x.org/pub/individual/
Download (FTP): ftp://ftp.x.org/pub/individual/
Download size: 4.2 MB
Estimated disk space required: 30 MB
Estimated build time: 0.3 SBU
User Notes: http://wiki.linuxfromscratch.org/blfs/wiki/Xorg7Legacy
First, create a list of files to be downloaded. This file will also be used to verify the integrity of the downloads when complete:
cat > legacy.dat << "EOF"
2a455d3c02390597feb9cefb3fe97a45 app/ bdftopcf-1.1.tar.bz2
1347c3031b74c9e91dc4dfa53b12f143 font/ font-adobe-100dpi-1.0.3.tar.bz2
6c9f26c92393c0756f3e8d614713495b font/ font-adobe-75dpi-1.0.3.tar.bz2
cb7b57d7800fd9e28ec35d85761ed278 font/ font-jis-misc-1.0.3.tar.bz2
0571bf77f8fab465a5454569d9989506 font/ font-daewoo-misc-1.0.3.tar.bz2
a2401caccbdcf5698e001784dbd43f1a font/ font-isas-misc-1.0.3.tar.bz2
c88eb44b3b903d79fb44b860a213e623 font/ font-misc-misc-1.1.2.tar.bz2
EOF
To download the needed files using wget, use the following commands:
mkdir legacy && cd legacy && grep -v '^#' ../legacy.dat | awk '{print $2$3}' | wget -i- -c \ -B https://www.x.org/pub/individual/ && grep -v '^#' ../legacy.dat | awk '{print $1 " " $3}' > ../legacy.md5 && md5sum -c ../legacy.md5
When installing multiple packages in a script, the installation needs to be done as the root user. There are three general options that can be used to do this:
Run the entire script as the root user (not recommended).
Use the sudo command from the Sudo-1.8.31p1 package.
Use su -c "command arguments" (quotes required) which will ask for the root password for every iteration of the loop.
One way to handle this situation is to create a short bash function that automatically selects the appropriate method. Once the command is set in the environment, it does not need to be set again.
as_root() { if [ $EUID = 0 ]; then $* elif [ -x /usr/bin/sudo ]; then sudo $* else su -c \\"$*\\" fi } export -f as_root
First, start a subshell that will exit on error:
bash -e
Install all of the packages by running the following commands:
for package in $(grep -v '^#' ../legacy.md5 | awk '{print $2}') do packagedir=${package%.tar.bz2} tar -xf $package pushd $packagedir ./configure $XORG_CONFIG make as_root make install popd rm -rf $packagedir as_root /sbin/ldconfig done
Finally, exit the shell that was started earlier:
exit
$XORG_PREFIX
/share/fonts/100dpi, $XORG_PREFIX
/share/fonts/75dpi, $XORG_PREFIX
/share/fonts/misc
Last updated on 2020-03-21 06:02:56 -0500