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

me.bechberger.ebpf.bpf.raw.bpf_prog_query_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_prog_query_opts {
 *     size_t sz;
 *     __u32 query_flags;
 *     __u32 attach_flags;
 *     __u32 *prog_ids;
 *     union {
 *         __u32 prog_cnt;
 *         __u32 count;
 *     };
 *     __u32 *prog_attach_flags;
 *     __u32 *link_ids;
 *     __u32 *link_attach_flags;
 *     __u64 revision;
 *     size_t : 0;
 * }
 * }
 */
public class bpf_prog_query_opts {

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

    private static final GroupLayout $LAYOUT = MemoryLayout.structLayout(
        Lib.C_LONG.withName("sz"),
        Lib.C_INT.withName("query_flags"),
        Lib.C_INT.withName("attach_flags"),
        Lib.C_POINTER.withName("prog_ids"),
        MemoryLayout.unionLayout(
            Lib.C_INT.withName("prog_cnt"),
            Lib.C_INT.withName("count")
        ).withName("$anon$590:2"),
        MemoryLayout.paddingLayout(4),
        Lib.C_POINTER.withName("prog_attach_flags"),
        Lib.C_POINTER.withName("link_ids"),
        Lib.C_POINTER.withName("link_attach_flags"),
        Lib.C_LONG_LONG.withName("revision")
    ).withName("bpf_prog_query_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 query_flags$LAYOUT = (OfInt)$LAYOUT.select(groupElement("query_flags"));

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

    private static final long query_flags$OFFSET = 8;

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

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

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

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

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

    private static final long attach_flags$OFFSET = 12;

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

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

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

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

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

    private static final long prog_ids$OFFSET = 16;

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

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

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

    private static final OfInt prog_cnt$LAYOUT = (OfInt)$LAYOUT.select(groupElement("$anon$590:2"), groupElement("prog_cnt"));

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

    private static final long prog_cnt$OFFSET = 24;

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

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

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

    private static final OfInt count$LAYOUT = (OfInt)$LAYOUT.select(groupElement("$anon$590:2"), groupElement("count"));

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

    private static final long count$OFFSET = 24;

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

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

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

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

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

    private static final long prog_attach_flags$OFFSET = 32;

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

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

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

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

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

    private static final long link_ids$OFFSET = 40;

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

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

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

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

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

    private static final long link_attach_flags$OFFSET = 48;

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

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

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

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

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

    private static final long revision$OFFSET = 56;

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

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

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