ELF (Executable and Linkable Format) parser for BPF programs
ELF (Executable and Linkable Format) parser for BPF programs
(create-maps-from-elf path)Create all BPF maps defined in ELF file
Parameters:
Returns map of {map-name -> BpfMap}
Example: (create-maps-from-elf "filter.o") ;; => {"my_map" #clj_ebpf.maps.BpfMap{...}}
Create all BPF maps defined in ELF file
Parameters:
- path: Path to ELF file
Returns map of {map-name -> BpfMap}
Example:
(create-maps-from-elf "filter.o")
;; => {"my_map" #clj_ebpf.maps.BpfMap{...}}(get-map-def elf-file name)Get BPF map definition by name
Parameters:
Returns BpfMapDef record or nil
Get BPF map definition by name Parameters: - elf-file: Parsed ELF file - name: Map name Returns BpfMapDef record or nil
(get-program elf-file name-or-idx)Get BPF program by name or index
Parameters:
Returns BpfProgram record or nil
Get BPF program by name or index Parameters: - elf-file: Parsed ELF file - name-or-idx: Program name (string) or index (integer) Returns BpfProgram record or nil
(inspect-elf path)Inspect ELF file and return summary information
Parameters:
Returns map with:
Example: (inspect-elf "filter.o") ;; => {:programs [{:name "xdp_filter" :type :xdp :size 128}] ;; :maps [{:name "my_map" :type 1 :key-size 4 ...}] ;; :license "GPL" ;; :version 0}
Inspect ELF file and return summary information
Parameters:
- path: Path to ELF file
Returns map with:
- :programs - List of program info
- :maps - List of map info
- :license - License string
- :version - Kernel version
Example:
(inspect-elf "filter.o")
;; => {:programs [{:name "xdp_filter" :type :xdp :size 128}]
;; :maps [{:name "my_map" :type 1 :key-size 4 ...}]
;; :license "GPL"
;; :version 0}(list-maps elf-file)List all BPF map definitions in ELF file
Returns vector of maps with :name, :type, :key-size, :value-size, :max-entries
List all BPF map definitions in ELF file Returns vector of maps with :name, :type, :key-size, :value-size, :max-entries
(list-programs elf-file)List all BPF programs in ELF file
Returns vector of maps with :name, :section, :type, :size
List all BPF programs in ELF file Returns vector of maps with :name, :section, :type, :size
(load-elf-program-and-maps path program-name)Load BPF program and create all maps from ELF file
Parameters:
Returns map with:
Example: (let [{:keys [program-fd maps]} (load-elf-program-and-maps "filter.o" "xdp_filter")] (println "Program FD:" program-fd) (println "Maps:" (keys maps)))
Load BPF program and create all maps from ELF file
Parameters:
- path: Path to ELF file
- program-name: Name of program to load
Returns map with:
- :program-fd - Program file descriptor
- :maps - Map of {map-name -> BpfMap}
Example:
(let [{:keys [program-fd maps]} (load-elf-program-and-maps "filter.o" "xdp_filter")]
(println "Program FD:" program-fd)
(println "Maps:" (keys maps)))(load-program-from-elf path program-name & options)Load a BPF program from ELF file
Parameters:
Returns program file descriptor
Example: (load-program-from-elf "filter.o" "xdp_filter")
Load a BPF program from ELF file Parameters: - path: Path to ELF file - program-name: Name of program to load (or index) - options: Additional options for program loading Returns program file descriptor Example: (load-program-from-elf "filter.o" "xdp_filter")
(parse-elf-file path)Parse ELF file and extract BPF programs and maps
Parameters:
Returns ElfFile record with:
Parse ELF file and extract BPF programs and maps Parameters: - path: Path to ELF file Returns ElfFile record with: - header: ELF header - sections: Vector of section headers - programs: Vector of BPF programs - maps: Vector of BPF map definitions - license: License string - version: Kernel version
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 |