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

me.bechberger.ebpf.bpf.raw.bpf_sockopt 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_sockopt {
 *     union {
 *         struct bpf_sock *sk;
 *         __u64 : 64;
 *     };
 *     union {
 *         void *optval;
 *         __u64 : 64;
 *     };
 *     union {
 *         void *optval_end;
 *         __u64 : 64;
 *     };
 *     __s32 level;
 *     __s32 optname;
 *     __s32 optlen;
 *     __s32 retval;
 * }
 * }
 */
public class bpf_sockopt {

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

    private static final GroupLayout $LAYOUT = MemoryLayout.structLayout(
        MemoryLayout.unionLayout(
            Lib.C_POINTER.withName("sk")
        ).withName("$anon$7350:2"),
        MemoryLayout.unionLayout(
            Lib.C_POINTER.withName("optval")
        ).withName("$anon$7351:2"),
        MemoryLayout.unionLayout(
            Lib.C_POINTER.withName("optval_end")
        ).withName("$anon$7352:2"),
        Lib.C_INT.withName("level"),
        Lib.C_INT.withName("optname"),
        Lib.C_INT.withName("optlen"),
        Lib.C_INT.withName("retval")
    ).withName("bpf_sockopt");

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

    private static final AddressLayout sk$LAYOUT = (AddressLayout)$LAYOUT.select(groupElement("$anon$7350:2"), groupElement("sk"));

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

    private static final long sk$OFFSET = 0;

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

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

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

    private static final AddressLayout optval$LAYOUT = (AddressLayout)$LAYOUT.select(groupElement("$anon$7351:2"), groupElement("optval"));

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

    private static final long optval$OFFSET = 8;

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

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

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

    private static final AddressLayout optval_end$LAYOUT = (AddressLayout)$LAYOUT.select(groupElement("$anon$7352:2"), groupElement("optval_end"));

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

    private static final long optval_end$OFFSET = 16;

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

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

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

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

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

    private static final long level$OFFSET = 24;

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

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

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

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

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

    private static final long optname$OFFSET = 28;

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

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

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

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

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

    private static final long optlen$OFFSET = 32;

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

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

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

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

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

    private static final long retval$OFFSET = 36;

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

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

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