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

me.bechberger.ebpf.bpf.raw.bpf_object_open_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_object_open_opts {
 *     size_t sz;
 *     const char *object_name;
 *     bool relaxed_maps;
 *     const char *pin_root_path;
 *     __u32 : 32;
 *     const char *kconfig;
 *     const char *btf_custom_path;
 *     char *kernel_log_buf;
 *     size_t kernel_log_size;
 *     __u32 kernel_log_level;
 *     const char *bpf_token_path;
 *     size_t : 0;
 * }
 * }
 */
public class bpf_object_open_opts {

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

    private static final GroupLayout $LAYOUT = MemoryLayout.structLayout(
        Lib.C_LONG.withName("sz"),
        Lib.C_POINTER.withName("object_name"),
        Lib.C_BOOL.withName("relaxed_maps"),
        MemoryLayout.paddingLayout(7),
        Lib.C_POINTER.withName("pin_root_path"),
        MemoryLayout.paddingLayout(8),
        Lib.C_POINTER.withName("kconfig"),
        Lib.C_POINTER.withName("btf_custom_path"),
        Lib.C_POINTER.withName("kernel_log_buf"),
        Lib.C_LONG.withName("kernel_log_size"),
        Lib.C_INT.withName("kernel_log_level"),
        MemoryLayout.paddingLayout(4),
        Lib.C_POINTER.withName("bpf_token_path")
    ).withName("bpf_object_open_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 AddressLayout object_name$LAYOUT = (AddressLayout)$LAYOUT.select(groupElement("object_name"));

    /**
     * Layout for field:
     * {@snippet lang=c :
     * const char *object_name
     * }
     */
    public static final AddressLayout object_name$layout() {
        return object_name$LAYOUT;
    }

    private static final long object_name$OFFSET = 8;

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

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

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

    private static final OfBoolean relaxed_maps$LAYOUT = (OfBoolean)$LAYOUT.select(groupElement("relaxed_maps"));

    /**
     * Layout for field:
     * {@snippet lang=c :
     * bool relaxed_maps
     * }
     */
    public static final OfBoolean relaxed_maps$layout() {
        return relaxed_maps$LAYOUT;
    }

    private static final long relaxed_maps$OFFSET = 16;

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

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

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

    private static final AddressLayout pin_root_path$LAYOUT = (AddressLayout)$LAYOUT.select(groupElement("pin_root_path"));

    /**
     * Layout for field:
     * {@snippet lang=c :
     * const char *pin_root_path
     * }
     */
    public static final AddressLayout pin_root_path$layout() {
        return pin_root_path$LAYOUT;
    }

    private static final long pin_root_path$OFFSET = 24;

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

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

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

    private static final AddressLayout kconfig$LAYOUT = (AddressLayout)$LAYOUT.select(groupElement("kconfig"));

    /**
     * Layout for field:
     * {@snippet lang=c :
     * const char *kconfig
     * }
     */
    public static final AddressLayout kconfig$layout() {
        return kconfig$LAYOUT;
    }

    private static final long kconfig$OFFSET = 40;

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

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

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

    private static final AddressLayout btf_custom_path$LAYOUT = (AddressLayout)$LAYOUT.select(groupElement("btf_custom_path"));

    /**
     * Layout for field:
     * {@snippet lang=c :
     * const char *btf_custom_path
     * }
     */
    public static final AddressLayout btf_custom_path$layout() {
        return btf_custom_path$LAYOUT;
    }

    private static final long btf_custom_path$OFFSET = 48;

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

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

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

    private static final AddressLayout kernel_log_buf$LAYOUT = (AddressLayout)$LAYOUT.select(groupElement("kernel_log_buf"));

    /**
     * Layout for field:
     * {@snippet lang=c :
     * char *kernel_log_buf
     * }
     */
    public static final AddressLayout kernel_log_buf$layout() {
        return kernel_log_buf$LAYOUT;
    }

    private static final long kernel_log_buf$OFFSET = 56;

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

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

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

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

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

    private static final long kernel_log_size$OFFSET = 64;

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

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

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

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

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

    private static final long kernel_log_level$OFFSET = 72;

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

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

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

    private static final AddressLayout bpf_token_path$LAYOUT = (AddressLayout)$LAYOUT.select(groupElement("bpf_token_path"));

    /**
     * Layout for field:
     * {@snippet lang=c :
     * const char *bpf_token_path
     * }
     */
    public static final AddressLayout bpf_token_path$layout() {
        return bpf_token_path$LAYOUT;
    }

    private static final long bpf_token_path$OFFSET = 80;

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

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

    /**
     * Setter for field:
     * {@snippet lang=c :
     * const char *bpf_token_path
     * }
     */
    public static void bpf_token_path(MemorySegment struct, MemorySegment fieldValue) {
        struct.set(bpf_token_path$LAYOUT, bpf_token_path$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