// SPDX-License-Identifier: Apache-2.0
// Copyright Authors of Hubble

syntax = "proto3";

package tetragon;

option go_package = "github.com/cilium/tetragon/api/v1/tetragon";

enum BpfCmd {
  /* Create a map and return a file descriptor that refers to the
     map. */
  BPF_MAP_CREATE = 0;

  /* Look up an element with a given key in the map referred to
     by the file descriptor map_fd. */
  BPF_MAP_LOOKUP_ELEM = 1;

  /* Create or update an element (key/value pair) in a specified map. */
  BPF_MAP_UPDATE_ELEM = 2;

  /* Look up and delete an element by key in a specified map. */
  BPF_MAP_DELETE_ELEM = 3;

  /* Look up an element by key in a specified map and return the key
     of the next element. Can be used to iterate over all elements
     in the map. */
  BPF_MAP_GET_NEXT_KEY = 4;

  /* Verify and load an eBPF program, returning a new file descriptor
     associated with the program. */
  BPF_PROG_LOAD = 5;

  /* Pin an eBPF program or map referred by the specified bpf_fd
     to the provided pathname on the filesystem. */
  BPF_OBJ_PIN = 6;

  /* Open a file descriptor for the eBPF object pinned to the
     specified pathname. */
  BPF_OBJ_GET = 7;

  /* Attach an eBPF program to a target_fd at the specified
     attach_type hook. */
  BPF_PROG_ATTACH = 8;

  /* Detach the eBPF program associated with the target_fd at the
     hook specified by attach_type. */
  BPF_PROG_DETACH = 9;

  /* Run the eBPF program associated with the prog_fd a repeat
     number of times against a provided program context ctx_in and
     data data_in, and return the modified program context
     ctx_out, data_out (for example, packet data), result of the
     execution retval, and duration of the test run. */
  BPF_PROG_TEST_RUN = 10;

  /* Fetch the next eBPF program currently loaded into the kernel. */
  BPF_PROG_GET_NEXT_ID = 11;

  /* Fetch the next eBPF map currently loaded into the kernel. */
  BPF_MAP_GET_NEXT_ID = 12;

  /* Open a file descriptor for the eBPF program corresponding to prog_id. */
  BPF_PROG_GET_FD_BY_ID = 13;

  /* Open a file descriptor for the eBPF map corresponding to map_id. */
  BPF_MAP_GET_FD_BY_ID = 14;

  /* Obtain information about the eBPF object corresponding to bpf_fd. */
  BPF_OBJ_GET_INFO_BY_FD = 15;

  /* Obtain information about eBPF programs associated with the specified
     attach_type hook. */
  BPF_PROG_QUERY = 16;

  /* Attach an eBPF program to a tracepoint *name* to access kernel
     internal arguments of the tracepoint in their raw form. */
  BPF_RAW_TRACEPOINT_OPEN = 17;

  /* Verify and load BPF Type Format (BTF) metadata into the kernel,
     returning a new file descriptor associated with the metadata. */
  BPF_BTF_LOAD = 18;

  /* Open a file descriptor for the BPF Type Format (BTF)
     corresponding to btf_id. */
  BPF_BTF_GET_FD_BY_ID = 19;

  /* Obtain information about eBPF programs associated with the target
     process identified by pid and fd. */
  BPF_TASK_FD_QUERY = 20;

  /* Look up an element with the given key in the map referred to
     by the file descriptor fd, and if found, delete the element. */
  BPF_MAP_LOOKUP_AND_DELETE_ELEM = 21;

  /* Freeze the permissions of the specified map. */
  BPF_MAP_FREEZE = 22;

  /* Fetch the next BPF Type Format (BTF) object currently loaded into
     the kernel. */
  BPF_BTF_GET_NEXT_ID = 23;

  /* Iterate and fetch multiple elements in a map. */
  BPF_MAP_LOOKUP_BATCH = 24;

  /* Iterate and delete all elements in a map. */
  BPF_MAP_LOOKUP_AND_DELETE_BATCH = 25;

  /* Update multiple elements in a map by key. */
  BPF_MAP_UPDATE_BATCH = 26;

  /* Delete multiple elements in a map by key. */
  BPF_MAP_DELETE_BATCH = 27;

  /* Attach an eBPF program to a target_fd at the specified
     attach_type hook and return a file descriptor handle for
     managing the link. */
  BPF_LINK_CREATE = 28;

  /* Update the eBPF program in the specified link_fd to
     new_prog_fd. */
  BPF_LINK_UPDATE = 29;

  /* Open a file descriptor for the eBPF Link corresponding to
     link_id. */
  BPF_LINK_GET_FD_BY_ID = 30;

  /* Fetch the next eBPF link currently loaded into the kernel. */
  BPF_LINK_GET_NEXT_ID = 31;

  /* Enable eBPF runtime statistics gathering. */
  BPF_ENABLE_STATS = 32;

  /* Create an iterator on top of the specified link_fd (as
     previously created using BPF_LINK_CREATE) and return a
     file descriptor that can be used to trigger the iteration. */
  BPF_ITER_CREATE = 33;

  /* Forcefully detach the specified link_fd from its corresponding
     attachment point. */
  BPF_LINK_DETACH = 34;

  /* Bind a map to the lifetime of an eBPF program. */
  BPF_PROG_BIND_MAP = 35;

  /* Create BPF token with embedded information about what can be
     passed as an extra parameter to various bpf() syscall commands
     to grant BPF subsystem functionality to unprivileged processes. */
  BPF_TOKEN_CREATE = 36;
}

enum BpfProgramType {
  BPF_PROG_TYPE_UNSPEC = 0;
  BPF_PROG_TYPE_SOCKET_FILTER = 1;
  BPF_PROG_TYPE_KPROBE = 2;
  BPF_PROG_TYPE_SCHED_CLS = 3;
  BPF_PROG_TYPE_SCHED_ACT = 4;
  BPF_PROG_TYPE_TRACEPOINT = 5;
  BPF_PROG_TYPE_XDP = 6;
  BPF_PROG_TYPE_PERF_EVENT = 7;
  BPF_PROG_TYPE_CGROUP_SKB = 8;
  BPF_PROG_TYPE_CGROUP_SOCK = 9;
  BPF_PROG_TYPE_LWT_IN = 10;
  BPF_PROG_TYPE_LWT_OUT = 11;
  BPF_PROG_TYPE_LWT_XMIT = 12;
  BPF_PROG_TYPE_SOCK_OPS = 13;
  BPF_PROG_TYPE_SK_SKB = 14;
  BPF_PROG_TYPE_CGROUP_DEVICE = 15;
  BPF_PROG_TYPE_SK_MSG = 16;
  BPF_PROG_TYPE_RAW_TRACEPOINT = 17;
  BPF_PROG_TYPE_CGROUP_SOCK_ADDR = 18;
  BPF_PROG_TYPE_LWT_SEG6LOCAL = 19;
  BPF_PROG_TYPE_LIRC_MODE2 = 20;
  BPF_PROG_TYPE_SK_REUSEPORT = 21;
  BPF_PROG_TYPE_FLOW_DISSECTOR = 22;
  BPF_PROG_TYPE_CGROUP_SYSCTL = 23;
  BPF_PROG_TYPE_RAW_TRACEPOINT_WRITABLE = 24;
  BPF_PROG_TYPE_CGROUP_SOCKOPT = 25;
  BPF_PROG_TYPE_TRACING = 26;
  BPF_PROG_TYPE_STRUCT_OPS = 27;
  BPF_PROG_TYPE_EXT = 28;
  BPF_PROG_TYPE_LSM = 29;
  BPF_PROG_TYPE_SK_LOOKUP = 30;
  BPF_PROG_TYPE_SYSCALL = 31;
  BPF_PROG_TYPE_NETFILTER = 32;
}
