All Downloads are FREE. Search and download functionalities are using the official Maven repository.

me.bechberger.ebpf.bpf.raw.bpf_map_create_opts Maven / Gradle / Ivy

The newest version!
// Generated by jextract

package me.bechberger.ebpf.bpf.raw;

import java.lang.invoke.*;
import java.lang.foreign.*;
import java.nio.ByteOrder;
import java.util.*;
import java.util.function.*;
import java.util.stream.*;

import static java.lang.foreign.ValueLayout.*;
import static java.lang.foreign.MemoryLayout.PathElement.*;

/**
 * {@snippet lang=c :
 * struct bpf_map_create_opts {
 *     size_t sz;
 *     __u32 btf_fd;
 *     __u32 btf_key_type_id;
 *     __u32 btf_value_type_id;
 *     __u32 btf_vmlinux_value_type_id;
 *     __u32 inner_map_fd;
 *     __u32 map_flags;
 *     __u64 map_extra;
 *     __u32 numa_node;
 *     __u32 map_ifindex;
 *     __s32 value_type_btf_obj_fd;
 *     __u32 token_fd;
 *     size_t : 0;
 * }
 * }
 */
public class bpf_map_create_opts {

    bpf_map_create_opts() {
        // Should not be called directly
    }

    private static final GroupLayout $LAYOUT = MemoryLayout.structLayout(
        Lib.C_LONG.withName("sz"),
        Lib.C_INT.withName("btf_fd"),
        Lib.C_INT.withName("btf_key_type_id"),
        Lib.C_INT.withName("btf_value_type_id"),
        Lib.C_INT.withName("btf_vmlinux_value_type_id"),
        Lib.C_INT.withName("inner_map_fd"),
        Lib.C_INT.withName("map_flags"),
        Lib.C_LONG_LONG.withName("map_extra"),
        Lib.C_INT.withName("numa_node"),
        Lib.C_INT.withName("map_ifindex"),
        Lib.C_INT.withName("value_type_btf_obj_fd"),
        Lib.C_INT.withName("token_fd")
    ).withName("bpf_map_create_opts");

    /**
     * The layout of this struct
     */
    public static final GroupLayout layout() {
        return $LAYOUT;
    }

    private static final OfLong sz$LAYOUT = (OfLong)$LAYOUT.select(groupElement("sz"));

    /**
     * Layout for field:
     * {@snippet lang=c :
     * size_t sz
     * }
     */
    public static final OfLong sz$layout() {
        return sz$LAYOUT;
    }

    private static final long sz$OFFSET = 0;

    /**
     * Offset for field:
     * {@snippet lang=c :
     * size_t sz
     * }
     */
    public static final long sz$offset() {
        return sz$OFFSET;
    }

    /**
     * Getter for field:
     * {@snippet lang=c :
     * size_t sz
     * }
     */
    public static long sz(MemorySegment struct) {
        return struct.get(sz$LAYOUT, sz$OFFSET);
    }

    /**
     * Setter for field:
     * {@snippet lang=c :
     * size_t sz
     * }
     */
    public static void sz(MemorySegment struct, long fieldValue) {
        struct.set(sz$LAYOUT, sz$OFFSET, fieldValue);
    }

    private static final OfInt btf_fd$LAYOUT = (OfInt)$LAYOUT.select(groupElement("btf_fd"));

    /**
     * Layout for field:
     * {@snippet lang=c :
     * __u32 btf_fd
     * }
     */
    public static final OfInt btf_fd$layout() {
        return btf_fd$LAYOUT;
    }

    private static final long btf_fd$OFFSET = 8;

    /**
     * Offset for field:
     * {@snippet lang=c :
     * __u32 btf_fd
     * }
     */
    public static final long btf_fd$offset() {
        return btf_fd$OFFSET;
    }

    /**
     * Getter for field:
     * {@snippet lang=c :
     * __u32 btf_fd
     * }
     */
    public static int btf_fd(MemorySegment struct) {
        return struct.get(btf_fd$LAYOUT, btf_fd$OFFSET);
    }

    /**
     * Setter for field:
     * {@snippet lang=c :
     * __u32 btf_fd
     * }
     */
    public static void btf_fd(MemorySegment struct, int fieldValue) {
        struct.set(btf_fd$LAYOUT, btf_fd$OFFSET, fieldValue);
    }

    private static final OfInt btf_key_type_id$LAYOUT = (OfInt)$LAYOUT.select(groupElement("btf_key_type_id"));

    /**
     * Layout for field:
     * {@snippet lang=c :
     * __u32 btf_key_type_id
     * }
     */
    public static final OfInt btf_key_type_id$layout() {
        return btf_key_type_id$LAYOUT;
    }

    private static final long btf_key_type_id$OFFSET = 12;

    /**
     * Offset for field:
     * {@snippet lang=c :
     * __u32 btf_key_type_id
     * }
     */
    public static final long btf_key_type_id$offset() {
        return btf_key_type_id$OFFSET;
    }

    /**
     * Getter for field:
     * {@snippet lang=c :
     * __u32 btf_key_type_id
     * }
     */
    public static int btf_key_type_id(MemorySegment struct) {
        return struct.get(btf_key_type_id$LAYOUT, btf_key_type_id$OFFSET);
    }

    /**
     * Setter for field:
     * {@snippet lang=c :
     * __u32 btf_key_type_id
     * }
     */
    public static void btf_key_type_id(MemorySegment struct, int fieldValue) {
        struct.set(btf_key_type_id$LAYOUT, btf_key_type_id$OFFSET, fieldValue);
    }

    private static final OfInt btf_value_type_id$LAYOUT = (OfInt)$LAYOUT.select(groupElement("btf_value_type_id"));

    /**
     * Layout for field:
     * {@snippet lang=c :
     * __u32 btf_value_type_id
     * }
     */
    public static final OfInt btf_value_type_id$layout() {
        return btf_value_type_id$LAYOUT;
    }

    private static final long btf_value_type_id$OFFSET = 16;

    /**
     * Offset for field:
     * {@snippet lang=c :
     * __u32 btf_value_type_id
     * }
     */
    public static final long btf_value_type_id$offset() {
        return btf_value_type_id$OFFSET;
    }

    /**
     * Getter for field:
     * {@snippet lang=c :
     * __u32 btf_value_type_id
     * }
     */
    public static int btf_value_type_id(MemorySegment struct) {
        return struct.get(btf_value_type_id$LAYOUT, btf_value_type_id$OFFSET);
    }

    /**
     * Setter for field:
     * {@snippet lang=c :
     * __u32 btf_value_type_id
     * }
     */
    public static void btf_value_type_id(MemorySegment struct, int fieldValue) {
        struct.set(btf_value_type_id$LAYOUT, btf_value_type_id$OFFSET, fieldValue);
    }

    private static final OfInt btf_vmlinux_value_type_id$LAYOUT = (OfInt)$LAYOUT.select(groupElement("btf_vmlinux_value_type_id"));

    /**
     * Layout for field:
     * {@snippet lang=c :
     * __u32 btf_vmlinux_value_type_id
     * }
     */
    public static final OfInt btf_vmlinux_value_type_id$layout() {
        return btf_vmlinux_value_type_id$LAYOUT;
    }

    private static final long btf_vmlinux_value_type_id$OFFSET = 20;

    /**
     * Offset for field:
     * {@snippet lang=c :
     * __u32 btf_vmlinux_value_type_id
     * }
     */
    public static final long btf_vmlinux_value_type_id$offset() {
        return btf_vmlinux_value_type_id$OFFSET;
    }

    /**
     * Getter for field:
     * {@snippet lang=c :
     * __u32 btf_vmlinux_value_type_id
     * }
     */
    public static int btf_vmlinux_value_type_id(MemorySegment struct) {
        return struct.get(btf_vmlinux_value_type_id$LAYOUT, btf_vmlinux_value_type_id$OFFSET);
    }

    /**
     * Setter for field:
     * {@snippet lang=c :
     * __u32 btf_vmlinux_value_type_id
     * }
     */
    public static void btf_vmlinux_value_type_id(MemorySegment struct, int fieldValue) {
        struct.set(btf_vmlinux_value_type_id$LAYOUT, btf_vmlinux_value_type_id$OFFSET, fieldValue);
    }

    private static final OfInt inner_map_fd$LAYOUT = (OfInt)$LAYOUT.select(groupElement("inner_map_fd"));

    /**
     * Layout for field:
     * {@snippet lang=c :
     * __u32 inner_map_fd
     * }
     */
    public static final OfInt inner_map_fd$layout() {
        return inner_map_fd$LAYOUT;
    }

    private static final long inner_map_fd$OFFSET = 24;

    /**
     * Offset for field:
     * {@snippet lang=c :
     * __u32 inner_map_fd
     * }
     */
    public static final long inner_map_fd$offset() {
        return inner_map_fd$OFFSET;
    }

    /**
     * Getter for field:
     * {@snippet lang=c :
     * __u32 inner_map_fd
     * }
     */
    public static int inner_map_fd(MemorySegment struct) {
        return struct.get(inner_map_fd$LAYOUT, inner_map_fd$OFFSET);
    }

    /**
     * Setter for field:
     * {@snippet lang=c :
     * __u32 inner_map_fd
     * }
     */
    public static void inner_map_fd(MemorySegment struct, int fieldValue) {
        struct.set(inner_map_fd$LAYOUT, inner_map_fd$OFFSET, fieldValue);
    }

    private static final OfInt map_flags$LAYOUT = (OfInt)$LAYOUT.select(groupElement("map_flags"));

    /**
     * Layout for field:
     * {@snippet lang=c :
     * __u32 map_flags
     * }
     */
    public static final OfInt map_flags$layout() {
        return map_flags$LAYOUT;
    }

    private static final long map_flags$OFFSET = 28;

    /**
     * Offset for field:
     * {@snippet lang=c :
     * __u32 map_flags
     * }
     */
    public static final long map_flags$offset() {
        return map_flags$OFFSET;
    }

    /**
     * Getter for field:
     * {@snippet lang=c :
     * __u32 map_flags
     * }
     */
    public static int map_flags(MemorySegment struct) {
        return struct.get(map_flags$LAYOUT, map_flags$OFFSET);
    }

    /**
     * Setter for field:
     * {@snippet lang=c :
     * __u32 map_flags
     * }
     */
    public static void map_flags(MemorySegment struct, int fieldValue) {
        struct.set(map_flags$LAYOUT, map_flags$OFFSET, fieldValue);
    }

    private static final OfLong map_extra$LAYOUT = (OfLong)$LAYOUT.select(groupElement("map_extra"));

    /**
     * Layout for field:
     * {@snippet lang=c :
     * __u64 map_extra
     * }
     */
    public static final OfLong map_extra$layout() {
        return map_extra$LAYOUT;
    }

    private static final long map_extra$OFFSET = 32;

    /**
     * Offset for field:
     * {@snippet lang=c :
     * __u64 map_extra
     * }
     */
    public static final long map_extra$offset() {
        return map_extra$OFFSET;
    }

    /**
     * Getter for field:
     * {@snippet lang=c :
     * __u64 map_extra
     * }
     */
    public static long map_extra(MemorySegment struct) {
        return struct.get(map_extra$LAYOUT, map_extra$OFFSET);
    }

    /**
     * Setter for field:
     * {@snippet lang=c :
     * __u64 map_extra
     * }
     */
    public static void map_extra(MemorySegment struct, long fieldValue) {
        struct.set(map_extra$LAYOUT, map_extra$OFFSET, fieldValue);
    }

    private static final OfInt numa_node$LAYOUT = (OfInt)$LAYOUT.select(groupElement("numa_node"));

    /**
     * Layout for field:
     * {@snippet lang=c :
     * __u32 numa_node
     * }
     */
    public static final OfInt numa_node$layout() {
        return numa_node$LAYOUT;
    }

    private static final long numa_node$OFFSET = 40;

    /**
     * Offset for field:
     * {@snippet lang=c :
     * __u32 numa_node
     * }
     */
    public static final long numa_node$offset() {
        return numa_node$OFFSET;
    }

    /**
     * Getter for field:
     * {@snippet lang=c :
     * __u32 numa_node
     * }
     */
    public static int numa_node(MemorySegment struct) {
        return struct.get(numa_node$LAYOUT, numa_node$OFFSET);
    }

    /**
     * Setter for field:
     * {@snippet lang=c :
     * __u32 numa_node
     * }
     */
    public static void numa_node(MemorySegment struct, int fieldValue) {
        struct.set(numa_node$LAYOUT, numa_node$OFFSET, fieldValue);
    }

    private static final OfInt map_ifindex$LAYOUT = (OfInt)$LAYOUT.select(groupElement("map_ifindex"));

    /**
     * Layout for field:
     * {@snippet lang=c :
     * __u32 map_ifindex
     * }
     */
    public static final OfInt map_ifindex$layout() {
        return map_ifindex$LAYOUT;
    }

    private static final long map_ifindex$OFFSET = 44;

    /**
     * Offset for field:
     * {@snippet lang=c :
     * __u32 map_ifindex
     * }
     */
    public static final long map_ifindex$offset() {
        return map_ifindex$OFFSET;
    }

    /**
     * Getter for field:
     * {@snippet lang=c :
     * __u32 map_ifindex
     * }
     */
    public static int map_ifindex(MemorySegment struct) {
        return struct.get(map_ifindex$LAYOUT, map_ifindex$OFFSET);
    }

    /**
     * Setter for field:
     * {@snippet lang=c :
     * __u32 map_ifindex
     * }
     */
    public static void map_ifindex(MemorySegment struct, int fieldValue) {
        struct.set(map_ifindex$LAYOUT, map_ifindex$OFFSET, fieldValue);
    }

    private static final OfInt value_type_btf_obj_fd$LAYOUT = (OfInt)$LAYOUT.select(groupElement("value_type_btf_obj_fd"));

    /**
     * Layout for field:
     * {@snippet lang=c :
     * __s32 value_type_btf_obj_fd
     * }
     */
    public static final OfInt value_type_btf_obj_fd$layout() {
        return value_type_btf_obj_fd$LAYOUT;
    }

    private static final long value_type_btf_obj_fd$OFFSET = 48;

    /**
     * Offset for field:
     * {@snippet lang=c :
     * __s32 value_type_btf_obj_fd
     * }
     */
    public static final long value_type_btf_obj_fd$offset() {
        return value_type_btf_obj_fd$OFFSET;
    }

    /**
     * Getter for field:
     * {@snippet lang=c :
     * __s32 value_type_btf_obj_fd
     * }
     */
    public static int value_type_btf_obj_fd(MemorySegment struct) {
        return struct.get(value_type_btf_obj_fd$LAYOUT, value_type_btf_obj_fd$OFFSET);
    }

    /**
     * Setter for field:
     * {@snippet lang=c :
     * __s32 value_type_btf_obj_fd
     * }
     */
    public static void value_type_btf_obj_fd(MemorySegment struct, int fieldValue) {
        struct.set(value_type_btf_obj_fd$LAYOUT, value_type_btf_obj_fd$OFFSET, fieldValue);
    }

    private static final OfInt token_fd$LAYOUT = (OfInt)$LAYOUT.select(groupElement("token_fd"));

    /**
     * Layout for field:
     * {@snippet lang=c :
     * __u32 token_fd
     * }
     */
    public static final OfInt token_fd$layout() {
        return token_fd$LAYOUT;
    }

    private static final long token_fd$OFFSET = 52;

    /**
     * Offset for field:
     * {@snippet lang=c :
     * __u32 token_fd
     * }
     */
    public static final long token_fd$offset() {
        return token_fd$OFFSET;
    }

    /**
     * Getter for field:
     * {@snippet lang=c :
     * __u32 token_fd
     * }
     */
    public static int token_fd(MemorySegment struct) {
        return struct.get(token_fd$LAYOUT, token_fd$OFFSET);
    }

    /**
     * Setter for field:
     * {@snippet lang=c :
     * __u32 token_fd
     * }
     */
    public static void token_fd(MemorySegment struct, int fieldValue) {
        struct.set(token_fd$LAYOUT, token_fd$OFFSET, fieldValue);
    }

    /**
     * Obtains a slice of {@code arrayParam} which selects the array element at {@code index}.
     * The returned segment has address {@code arrayParam.address() + index * layout().byteSize()}
     */
    public static MemorySegment asSlice(MemorySegment array, long index) {
        return array.asSlice(layout().byteSize() * index);
    }

    /**
     * The size (in bytes) of this struct
     */
    public static long sizeof() { return layout().byteSize(); }

    /**
     * Allocate a segment of size {@code layout().byteSize()} using {@code allocator}
     */
    public static MemorySegment allocate(SegmentAllocator allocator) {
        return allocator.allocate(layout());
    }

    /**
     * Allocate an array of size {@code elementCount} using {@code allocator}.
     * The returned segment has size {@code elementCount * layout().byteSize()}.
     */
    public static MemorySegment allocateArray(long elementCount, SegmentAllocator allocator) {
        return allocator.allocate(MemoryLayout.sequenceLayout(elementCount, layout()));
    }

    /**
     * Reinterprets {@code addr} using target {@code arena} and {@code cleanupAction} (if any).
     * The returned segment has size {@code layout().byteSize()}
     */
    public static MemorySegment reinterpret(MemorySegment addr, Arena arena, Consumer cleanup) {
        return reinterpret(addr, 1, arena, cleanup);
    }

    /**
     * Reinterprets {@code addr} using target {@code arena} and {@code cleanupAction} (if any).
     * The returned segment has size {@code elementCount * layout().byteSize()}
     */
    public static MemorySegment reinterpret(MemorySegment addr, long elementCount, Arena arena, Consumer cleanup) {
        return addr.reinterpret(layout().byteSize() * elementCount, arena, cleanup);
    }
}





© 2015 - 2024 Weber Informatics LLC | Privacy Policy