org.jnetstream.filter.bpf
Class BPFInstruction
java.lang.Object
org.jnetstream.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.
|
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)
|
| Methods inherited from class java.lang.Object |
clone, equals, finalize, getClass, hashCode, notify, notifyAll, wait, wait, wait |
code
public final int code
jf
public final int jf
jt
public final int jt
k
public final long k
symbol
public final BPFInstruction.Symbol symbol
BPFInstruction
public BPFInstruction(byte[] buf,
int offset,
java.nio.ByteOrder encoding)
throws IllegalInstructionException
- 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 fromoffset - offset within the buffer to read the structure
- Throws:
IllegalInstructionException
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 fromoffset - offset within the buffer to read the structure
BPFInstruction
public BPFInstruction(int code,
int jt,
int jf,
int k)
throws IllegalInstructionException
- Throws:
IllegalInstructionException
BPFInstruction
public BPFInstruction(int code,
int jt,
int jf,
long k)
- Parameters:
code - BPF op codejt - jump addressjf - jump addressk - base offset
encodeToBinary
public static byte[] encodeToBinary(BPFInstruction[] inst)
- Converts an array of BPF instructions to a binary program stored in a
buffer.
- Parameters:
inst - instruction array to do the conversion of
- Returns:
- buffer containing the converted binary bpf program
encodeToBinary
public byte[] encodeToBinary()
- Returns:
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.
getK
public final long getK()
- Returns:
- Returns the k.
toString
public java.lang.String toString()
- Overrides:
toString in class java.lang.Object