Liking cljdoc? Tell your friends :D

clj-ebpf.dsl.instructions

Low-level BPF instruction encoding.

This namespace provides the fundamental BPF instruction encoding primitives. It defines:

  • Instruction format constants
  • Opcode construction
  • Single instruction encoding
  • Register definitions

BPF instructions are 64-bit: |immediate:32|offset:16|src_reg:4|dst_reg:4|opcode:8|

Low-level BPF instruction encoding.

This namespace provides the fundamental BPF instruction encoding primitives.
It defines:
- Instruction format constants
- Opcode construction
- Single instruction encoding
- Register definitions

BPF instructions are 64-bit:
|immediate:32|offset:16|src_reg:4|dst_reg:4|opcode:8|
raw docstring

BPF_ABSclj

source

BPF_ADDclj

source

BPF_ALUclj

source

BPF_ALU64clj

source

BPF_ANDclj

source

BPF_ARSHclj

source

BPF_ATOMICclj

source

BPF_ATOMIC_ADDclj

source

BPF_ATOMIC_ANDclj

source

BPF_ATOMIC_CMPXCHGclj

source

BPF_ATOMIC_FETCHclj

source

BPF_ATOMIC_ORclj

source

BPF_ATOMIC_XCHGclj

source

BPF_ATOMIC_XORclj

source

BPF_Bclj

source

BPF_CALLclj

source

BPF_DIVclj

source

BPF_DWclj

source

BPF_ENDclj

source

BPF_EXITclj

source

BPF_Hclj

source

BPF_IMMclj

source

BPF_INDclj

source

BPF_JAclj

source

BPF_JEQclj

source

BPF_JGEclj

source

BPF_JGTclj

source

BPF_JLEclj

source

BPF_JLTclj

source

BPF_JMPclj

source

BPF_JMP32clj

source

BPF_JNEclj

source

BPF_JSETclj

source

BPF_JSGEclj

source

BPF_JSGTclj

source

BPF_JSLEclj

source

BPF_JSLTclj

source

BPF_Kclj

source

BPF_LDclj

source

BPF_LDXclj

source

BPF_LSHclj

source

BPF_MEMclj

source

BPF_MODclj

source

BPF_MOVclj

source

BPF_MULclj

source

BPF_NEGclj

source

BPF_ORclj

source

BPF_RSHclj

source

BPF_STclj

source

BPF_STXclj

source

BPF_SUBclj

source

BPF_Wclj

source

BPF_Xclj

source

BPF_XORclj

source

instruction->bytesclj

(instruction->bytes {:keys [opcode dst src offset imm]})

Encode an instruction to 8 bytes (little-endian).

BPF instruction format: Byte 0: opcode Byte 1: dst:4 | src:4 Bytes 2-3: offset (little-endian) Bytes 4-7: immediate (little-endian)

Encode an instruction to 8 bytes (little-endian).

BPF instruction format:
Byte 0: opcode
Byte 1: dst:4 | src:4
Bytes 2-3: offset (little-endian)
Bytes 4-7: immediate (little-endian)
sourceraw docstring

instructions->bytesclj

(instructions->bytes insns)

Encode a sequence of instructions to bytes.

Encode a sequence of instructions to bytes.
sourceraw docstring

make-instructionclj

(make-instruction opcode dst src offset imm)

Create a BPF instruction.

Arguments:

  • opcode: Instruction opcode
  • dst: Destination register (0-10)
  • src: Source register (0-10)
  • offset: 16-bit signed offset
  • imm: 32-bit immediate value

Returns an Instruction record.

Create a BPF instruction.

Arguments:
- opcode: Instruction opcode
- dst: Destination register (0-10)
- src: Source register (0-10)
- offset: 16-bit signed offset
- imm: 32-bit immediate value

Returns an Instruction record.
sourceraw docstring

make-ld-opcodeclj

(make-ld-opcode size mode)

Construct a load opcode.

Arguments:

  • size: BPF_B, BPF_H, BPF_W, or BPF_DW
  • mode: BPF_IMM, BPF_MEM, BPF_ABS, BPF_IND
Construct a load opcode.

Arguments:
- size: BPF_B, BPF_H, BPF_W, or BPF_DW
- mode: BPF_IMM, BPF_MEM, BPF_ABS, BPF_IND
sourceraw docstring

make-opcodeclj

(make-opcode class src op)

Construct an opcode from class, source, and operation.

Arguments:

  • class: BPF_ALU, BPF_ALU64, BPF_JMP, etc.
  • src: BPF_K (immediate) or BPF_X (register)
  • op: Operation code (BPF_ADD, BPF_JEQ, etc.)
Construct an opcode from class, source, and operation.

Arguments:
- class: BPF_ALU, BPF_ALU64, BPF_JMP, etc.
- src: BPF_K (immediate) or BPF_X (register)
- op: Operation code (BPF_ADD, BPF_JEQ, etc.)
sourceraw docstring

make-st-opcodeclj

(make-st-opcode size src)

Construct a store opcode.

Arguments:

  • size: BPF_B, BPF_H, BPF_W, or BPF_DW
  • src: BPF_K (from immediate) or BPF_X (from register)
Construct a store opcode.

Arguments:
- size: BPF_B, BPF_H, BPF_W, or BPF_DW
- src: BPF_K (from immediate) or BPF_X (from register)
sourceraw docstring

reg->numclj

(reg->num reg)

Convert register keyword to number

Convert register keyword to number
sourceraw docstring

registersclj

BPF register mapping

BPF register mapping
sourceraw docstring

valid-imm32?clj

(valid-imm32? i)

Check if a value is a valid 32-bit immediate.

Check if a value is a valid 32-bit immediate.
sourceraw docstring

valid-instruction?clj

(valid-instruction? insn)

Check if an instruction record is valid.

Check if an instruction record is valid.
sourceraw docstring

valid-offset?clj

(valid-offset? o)

Check if a value is a valid 16-bit signed offset.

Check if a value is a valid 16-bit signed offset.
sourceraw docstring

valid-register?clj

(valid-register? r)

Check if a value is a valid register.

Check if a value is a valid register.
sourceraw docstring

cljdoc builds & hosts documentation for Clojure/Script libraries

Keyboard shortcuts
Ctrl+kJump to recent docs
Move to previous article
Move to next article
Ctrl+/Jump to the search field
× close