BPF.Instruction (BPF v0.1.1)
View SourceClassic BPF instruction definitions and encoding.
BPF has a simple instruction set with:
- A: 32-bit accumulator
- X: 32-bit index register
- M[0-15]: 16 x 32-bit scratch memory slots
Each instruction is represented as a tuple. Examples:
{:ld, :b, [:k, 0]}- load byte at offset 0 into A{:add, 4}- add 4 to A{:jmp, :jeq, :k, 5, 1, 0}- if A == 5, skip 1, else skip 0:txa- copy X to A{:ret, :k, 0xFFFFFFFF}- return constant
Summary
Functions
Encode an instruction tuple to its binary representation.
Encode an instruction to its 8-byte binary format.
Types
@type t() :: :atom | tuple()