MaeBPFC.Codegen (maebpf_c v0.1.0)

Copy Markdown View Source

Lowers a structured %MaeBPF.IR.Module{} (built-in MaeBPF.Plugs.*, MaeBPFC.Plugs.TLSSNI, global/3, c_preamble/1, and ~BPFC"""...""" inline C blocks) into clean, warning-free C CO-RE eBPF source.

Supports two header modes via header_mode::

  • :vmlinux - #include "vmlinux.h", <bpf/bpf_helpers.h>, and <bpf/bpf_endian.h> for full Linux CO-RE compilation.
  • :standalone - self-contained portable BPF UAPI types, map macros, helper declarations, and bpf_iter_num ksym externs so clang -target bpf compiles valid Linux EM_BPF ELF64 + BTF objects even on macOS or minimal Linux hosts without vmlinux.h / libbpf-dev.

Summary

Functions

Generates C eBPF source code for a normalized %MaeBPF.IR.Module{}.

Functions

generate(ir, opts \\ [])

@spec generate(MaeBPF.IR.Module.t(), keyword()) :: {:ok, String.t()}

Generates C eBPF source code for a normalized %MaeBPF.IR.Module{}.

Options:

  • :header_mode - :vmlinux or :standalone (default :standalone)
  • :includes - extra header strings emitted as #include "..." or #include <...>
  • :debug_trace - emit per-plug debug RingBuf events (default false)