\brief Create a BPF buffer based on the object map type.
| 158 | |
| 159 | /// \brief Create a BPF buffer based on the object map type. |
| 160 | std::unique_ptr<bpf_buffer> bpf_buffer__new(bpf_map *events) { |
| 161 | bpf_map_type map_type = bpf_map__type(events); |
| 162 | switch (map_type) { |
| 163 | case BPF_MAP_TYPE_PERF_EVENT_ARRAY: |
| 164 | return std::make_unique<perf_buffer_wrapper>(events); |
| 165 | case BPF_MAP_TYPE_RINGBUF: |
| 166 | return std::make_unique<ring_buffer_wrapper>(events); |
| 167 | default: |
| 168 | return nullptr; |
| 169 | } |
| 170 | } |
| 171 | |
| 172 | /// Get the file descriptor of a map by name. |
| 173 | int32_t wasm_bpf_program::bpf_map_fd_by_name(const char *name) { |