org.jnetpcap
Class PcapBpfProgram

java.lang.Object
  extended by org.jnetpcap.PcapBpfProgram

public class PcapBpfProgram
extends java.lang.Object

Class peered with native bpf_program structure. Instance of a compiled Berkley Packet Filter program. The program is an interpreted binary byte program. Most modern unix and windows systems have a BPF interpreter builtin and execute the code very efficiently, close to the source of the capture and use the filter to permit or reject packets early.

Special note:
There also 2 private constructors which allow the object to be initialized in Java space with a BPF program. The corresponding native C structures are created and can be passed to Pcap.setFilter method. At this time, the constructors are kept private for further testing. At some point these private constructors will be made public and will allow outside filters to be used with Pcap capture sessions.

Author:
Mark Bednarczyk, Sly Technologies, Inc.

Constructor Summary
PcapBpfProgram()
          Special constructor that allows creation of empty object ready for initialization.
 
Method Summary
protected  void finalize()
          Cleans up JNI resources and releases any unreleased BPF programs in native land.
 long getInstruction(int index)
          Retrieves a single BPF instruction which is 8 bytes long and is encoded into the long interger returned.
 int getInstructionCount()
          Gets the exact number of BPF instructions within this program.
 
Methods inherited from class java.lang.Object
clone, equals, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Constructor Detail

PcapBpfProgram

public PcapBpfProgram()
Special constructor that allows creation of empty object ready for initialization. The object is only suitable for passing to Pcap.compile or Pcap.compileNoPcap which will initiliaze it. Using any of the getter methods before the PcapBpfProgram object is succesfully initialized will result in IllegalStateException being thrown.

See Also:
Pcap.compile(PcapBpfProgram, String, int, int), Pcap.compileNoPcap(int, int, PcapBpfProgram, String, int, int)
Method Detail

finalize

protected void finalize()
Cleans up JNI resources and releases any unreleased BPF programs in native land.

Overrides:
finalize in class java.lang.Object

getInstructionCount

public int getInstructionCount()
Gets the exact number of BPF instructions within this program.

Returns:
number of 8 byte instructions within this program

getInstruction

public long getInstruction(int index)
Retrieves a single BPF instruction which is 8 bytes long and is encoded into the long interger returned.

Parameters:
index - index of the instruction
Returns:
entire instruction