jnetpcap.filter.bpf
Class BPFInstruction

java.lang.Object
  extended by jnetpcap.filter.bpf.BPFInstruction

public class BPFInstruction
extends java.lang.Object

A single instruction of a BPF binary program. This is the equivelement to an assembly instruction. The representation here is more java friendly.

Author:
Mark Bednarczyk, Sly Technologies, Inc.

Nested Class Summary
static class BPFInstruction.Symbol
           
 
Field Summary
 int code
           
 int jf
           
 int jt
           
 long k
           
 BPFInstruction.Symbol symbol
           
 
Constructor Summary
BPFInstruction(byte[] buf, int offset, java.nio.ByteOrder encoding)
          Initializes the instruction from raw buffer data.
BPFInstruction(java.nio.ByteBuffer buf, int offset)
          Initializes the instruction from raw buffer data.
BPFInstruction(int code, int jt, int jf, int k)
           
BPFInstruction(int code, int jt, int jf, long k)
           
 
Method Summary
 int getCode()
           
 int getJf()
           
 int getJt()
           
 long getK()
           
 java.lang.String toString()
           
 
Methods inherited from class java.lang.Object
equals, getClass, hashCode, notify, notifyAll, wait, wait, wait
 

Field Detail

symbol

public final BPFInstruction.Symbol symbol

code

public final int code

jt

public final int jt

jf

public final int jf

k

public final long k
Constructor Detail

BPFInstruction

public BPFInstruction(byte[] buf,
                      int offset,
                      java.nio.ByteOrder encoding)
               throws IllegalInstruction
Initializes the instruction from raw buffer data. Each instruction is 64-bits wide and has the following structure:
 
 struct bpf_insn { u_short code; u_char jt; u_char jf; bpf_int32 k; };
 
 

Parameters:
buf - buffer to extract the structure from
offset - offset within the buffer to read the structure
Throws:
IllegalInstruction

BPFInstruction

public BPFInstruction(int code,
                      int jt,
                      int jf,
                      int k)
               throws IllegalInstruction
Throws:
IllegalInstruction

BPFInstruction

public BPFInstruction(java.nio.ByteBuffer buf,
                      int offset)
Initializes the instruction from raw buffer data. Each instruction is 64-bits wide and has the following structure:
 
 struct bpf_insn { u_short code; u_char jt; u_char jf; bpf_int32 k; };
 
 

Parameters:
buf - buffer to extract the structure from
offset - offset within the buffer to read the structure

BPFInstruction

public BPFInstruction(int code,
                      int jt,
                      int jf,
                      long k)
Parameters:
code - BPF op code
jt - jump address
jf - jump address
k - base offset
Method Detail

getK

public final long getK()
Returns:
Returns the k.

getCode

public final int getCode()
Returns:
Returns the code.

getJf

public final int getJf()
Returns:
Returns the jf.

getJt

public final int getJt()
Returns:
Returns the jt.

toString

public java.lang.String toString()
Overrides:
toString in class java.lang.Object