Low-level BPF instruction encoding.
This namespace provides the fundamental BPF instruction encoding primitives. It defines:
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|
(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)
(instructions->bytes insns)Encode a sequence of instructions to bytes.
Encode a sequence of instructions to bytes.
(make-instruction opcode dst src offset imm)Create a BPF instruction.
Arguments:
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.
(make-ld-opcode size mode)Construct a load opcode.
Arguments:
Construct a load opcode. Arguments: - size: BPF_B, BPF_H, BPF_W, or BPF_DW - mode: BPF_IMM, BPF_MEM, BPF_ABS, BPF_IND
(make-opcode class src op)Construct an opcode from class, source, and operation.
Arguments:
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.)
(make-st-opcode size src)Construct a store opcode.
Arguments:
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)
(reg->num reg)Convert register keyword to number
Convert register keyword to number
(valid-imm32? i)Check if a value is a valid 32-bit immediate.
Check if a value is a valid 32-bit immediate.
(valid-instruction? insn)Check if an instruction record is valid.
Check if an instruction record is valid.
(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.
(valid-register? r)Check if a value is a valid register.
Check if a value is a valid register.
cljdoc builds & hosts documentation for Clojure/Script libraries
| Ctrl+k | Jump to recent docs |
| ← | Move to previous article |
| → | Move to next article |
| Ctrl+/ | Jump to the search field |