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

me.bechberger.ebpf.bpf.raw.bpf_iter_link_info 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 :
 * union bpf_iter_link_info {
 *     struct {
 *         __u32 map_fd;
 *     } map;
 *     struct {
 *         enum bpf_cgroup_iter_order order;
 *         __u32 cgroup_fd;
 *         __u64 cgroup_id;
 *     } cgroup;
 *     struct {
 *         __u32 tid;
 *         __u32 pid;
 *         __u32 pid_fd;
 *     } task;
 * }
 * }
 */
public class bpf_iter_link_info {

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

    private static final GroupLayout $LAYOUT = MemoryLayout.unionLayout(
        bpf_iter_link_info.map.layout().withName("map"),
        bpf_iter_link_info.cgroup.layout().withName("cgroup"),
        bpf_iter_link_info.task.layout().withName("task")
    ).withName("bpf_iter_link_info");

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

    /**
     * {@snippet lang=c :
     * struct {
     *     __u32 map_fd;
     * }
     * }
     */
    public static class map {

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

        private static final GroupLayout $LAYOUT = MemoryLayout.structLayout(
            Lib.C_INT.withName("map_fd")
        ).withName("$anon$122:2");

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

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

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

        private static final long map_fd$OFFSET = 0;

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

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

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

    private static final GroupLayout map$LAYOUT = (GroupLayout)$LAYOUT.select(groupElement("map"));

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

    private static final long map$OFFSET = 0;

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

    /**
     * Getter for field:
     * {@snippet lang=c :
     * struct {
     *     __u32 map_fd;
     * } map
     * }
     */
    public static MemorySegment map(MemorySegment union) {
        return union.asSlice(map$OFFSET, map$LAYOUT.byteSize());
    }

    /**
     * Setter for field:
     * {@snippet lang=c :
     * struct {
     *     __u32 map_fd;
     * } map
     * }
     */
    public static void map(MemorySegment union, MemorySegment fieldValue) {
        MemorySegment.copy(fieldValue, 0L, union, map$OFFSET, map$LAYOUT.byteSize());
    }

    /**
     * {@snippet lang=c :
     * struct {
     *     enum bpf_cgroup_iter_order order;
     *     __u32 cgroup_fd;
     *     __u64 cgroup_id;
     * }
     * }
     */
    public static class cgroup {

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

        private static final GroupLayout $LAYOUT = MemoryLayout.structLayout(
            Lib.C_INT.withName("order"),
            Lib.C_INT.withName("cgroup_fd"),
            Lib.C_LONG_LONG.withName("cgroup_id")
        ).withName("$anon$125:2");

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

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

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

        private static final long order$OFFSET = 0;

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

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

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

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

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

        private static final long cgroup_fd$OFFSET = 4;

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

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

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

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

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

        private static final long cgroup_id$OFFSET = 8;

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

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

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

    private static final GroupLayout cgroup$LAYOUT = (GroupLayout)$LAYOUT.select(groupElement("cgroup"));

    /**
     * Layout for field:
     * {@snippet lang=c :
     * struct {
     *     enum bpf_cgroup_iter_order order;
     *     __u32 cgroup_fd;
     *     __u64 cgroup_id;
     * } cgroup
     * }
     */
    public static final GroupLayout cgroup$layout() {
        return cgroup$LAYOUT;
    }

    private static final long cgroup$OFFSET = 0;

    /**
     * Offset for field:
     * {@snippet lang=c :
     * struct {
     *     enum bpf_cgroup_iter_order order;
     *     __u32 cgroup_fd;
     *     __u64 cgroup_id;
     * } cgroup
     * }
     */
    public static final long cgroup$offset() {
        return cgroup$OFFSET;
    }

    /**
     * Getter for field:
     * {@snippet lang=c :
     * struct {
     *     enum bpf_cgroup_iter_order order;
     *     __u32 cgroup_fd;
     *     __u64 cgroup_id;
     * } cgroup
     * }
     */
    public static MemorySegment cgroup(MemorySegment union) {
        return union.asSlice(cgroup$OFFSET, cgroup$LAYOUT.byteSize());
    }

    /**
     * Setter for field:
     * {@snippet lang=c :
     * struct {
     *     enum bpf_cgroup_iter_order order;
     *     __u32 cgroup_fd;
     *     __u64 cgroup_id;
     * } cgroup
     * }
     */
    public static void cgroup(MemorySegment union, MemorySegment fieldValue) {
        MemorySegment.copy(fieldValue, 0L, union, cgroup$OFFSET, cgroup$LAYOUT.byteSize());
    }

    /**
     * {@snippet lang=c :
     * struct {
     *     __u32 tid;
     *     __u32 pid;
     *     __u32 pid_fd;
     * }
     * }
     */
    public static class task {

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

        private static final GroupLayout $LAYOUT = MemoryLayout.structLayout(
            Lib.C_INT.withName("tid"),
            Lib.C_INT.withName("pid"),
            Lib.C_INT.withName("pid_fd")
        ).withName("$anon$137:2");

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

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

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

        private static final long tid$OFFSET = 0;

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

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

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

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

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

        private static final long pid$OFFSET = 4;

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

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

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

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

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

        private static final long pid_fd$OFFSET = 8;

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

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

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

    private static final GroupLayout task$LAYOUT = (GroupLayout)$LAYOUT.select(groupElement("task"));

    /**
     * Layout for field:
     * {@snippet lang=c :
     * struct {
     *     __u32 tid;
     *     __u32 pid;
     *     __u32 pid_fd;
     * } task
     * }
     */
    public static final GroupLayout task$layout() {
        return task$LAYOUT;
    }

    private static final long task$OFFSET = 0;

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

    /**
     * Getter for field:
     * {@snippet lang=c :
     * struct {
     *     __u32 tid;
     *     __u32 pid;
     *     __u32 pid_fd;
     * } task
     * }
     */
    public static MemorySegment task(MemorySegment union) {
        return union.asSlice(task$OFFSET, task$LAYOUT.byteSize());
    }

    /**
     * Setter for field:
     * {@snippet lang=c :
     * struct {
     *     __u32 tid;
     *     __u32 pid;
     *     __u32 pid_fd;
     * } task
     * }
     */
    public static void task(MemorySegment union, MemorySegment fieldValue) {
        MemorySegment.copy(fieldValue, 0L, union, task$OFFSET, task$LAYOUT.byteSize());
    }

    /**
     * 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 union
     */
    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