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

me.bechberger.ebpf.bpf.raw.tcp_ao_getsockopt 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 tcp_ao_getsockopt {
 *     struct __kernel_sockaddr_storage addr;
 *     char alg_name[64];
 *     __u8 key[80];
 *     __u32 nkeys;
 *     __u16 is_current : 1;
 *     __u16 is_rnext : 1;
 *     __u16 get_all : 1;
 *     __u16 reserved : 13;
 *     __u8 sndid;
 *     __u8 rcvid;
 *     __u8 prefix;
 *     __u8 maclen;
 *     __u8 keyflags;
 *     __u8 keylen;
 *     __s32 ifindex;
 *     __u64 pkt_good;
 *     __u64 pkt_bad;
 * }
 * }
 */
public class tcp_ao_getsockopt {

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

    private static final GroupLayout $LAYOUT = MemoryLayout.structLayout(
        __kernel_sockaddr_storage.layout().withName("addr"),
        MemoryLayout.sequenceLayout(64, Lib.C_CHAR).withName("alg_name"),
        MemoryLayout.sequenceLayout(80, Lib.C_CHAR).withName("key"),
        Lib.C_INT.withName("nkeys"),
        MemoryLayout.paddingLayout(2),
        Lib.C_CHAR.withName("sndid"),
        Lib.C_CHAR.withName("rcvid"),
        Lib.C_CHAR.withName("prefix"),
        Lib.C_CHAR.withName("maclen"),
        Lib.C_CHAR.withName("keyflags"),
        Lib.C_CHAR.withName("keylen"),
        Lib.C_INT.withName("ifindex"),
        Lib.C_LONG_LONG.withName("pkt_good"),
        Lib.C_LONG_LONG.withName("pkt_bad")
    ).withName("tcp_ao_getsockopt");

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

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

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

    private static final long addr$OFFSET = 0;

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

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

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

    private static final SequenceLayout alg_name$LAYOUT = (SequenceLayout)$LAYOUT.select(groupElement("alg_name"));

    /**
     * Layout for field:
     * {@snippet lang=c :
     * char alg_name[64]
     * }
     */
    public static final SequenceLayout alg_name$layout() {
        return alg_name$LAYOUT;
    }

    private static final long alg_name$OFFSET = 128;

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

    /**
     * Getter for field:
     * {@snippet lang=c :
     * char alg_name[64]
     * }
     */
    public static MemorySegment alg_name(MemorySegment struct) {
        return struct.asSlice(alg_name$OFFSET, alg_name$LAYOUT.byteSize());
    }

    /**
     * Setter for field:
     * {@snippet lang=c :
     * char alg_name[64]
     * }
     */
    public static void alg_name(MemorySegment struct, MemorySegment fieldValue) {
        MemorySegment.copy(fieldValue, 0L, struct, alg_name$OFFSET, alg_name$LAYOUT.byteSize());
    }

    private static long[] alg_name$DIMS = { 64 };

    /**
     * Dimensions for array field:
     * {@snippet lang=c :
     * char alg_name[64]
     * }
     */
    public static long[] alg_name$dimensions() {
        return alg_name$DIMS;
    }
    private static final VarHandle alg_name$ELEM_HANDLE = alg_name$LAYOUT.varHandle(sequenceElement());

    /**
     * Indexed getter for field:
     * {@snippet lang=c :
     * char alg_name[64]
     * }
     */
    public static byte alg_name(MemorySegment struct, long index0) {
        return (byte)alg_name$ELEM_HANDLE.get(struct, 0L, index0);
    }

    /**
     * Indexed setter for field:
     * {@snippet lang=c :
     * char alg_name[64]
     * }
     */
    public static void alg_name(MemorySegment struct, long index0, byte fieldValue) {
        alg_name$ELEM_HANDLE.set(struct, 0L, index0, fieldValue);
    }

    private static final SequenceLayout key$LAYOUT = (SequenceLayout)$LAYOUT.select(groupElement("key"));

    /**
     * Layout for field:
     * {@snippet lang=c :
     * __u8 key[80]
     * }
     */
    public static final SequenceLayout key$layout() {
        return key$LAYOUT;
    }

    private static final long key$OFFSET = 192;

    /**
     * Offset for field:
     * {@snippet lang=c :
     * __u8 key[80]
     * }
     */
    public static final long key$offset() {
        return key$OFFSET;
    }

    /**
     * Getter for field:
     * {@snippet lang=c :
     * __u8 key[80]
     * }
     */
    public static MemorySegment key(MemorySegment struct) {
        return struct.asSlice(key$OFFSET, key$LAYOUT.byteSize());
    }

    /**
     * Setter for field:
     * {@snippet lang=c :
     * __u8 key[80]
     * }
     */
    public static void key(MemorySegment struct, MemorySegment fieldValue) {
        MemorySegment.copy(fieldValue, 0L, struct, key$OFFSET, key$LAYOUT.byteSize());
    }

    private static long[] key$DIMS = { 80 };

    /**
     * Dimensions for array field:
     * {@snippet lang=c :
     * __u8 key[80]
     * }
     */
    public static long[] key$dimensions() {
        return key$DIMS;
    }
    private static final VarHandle key$ELEM_HANDLE = key$LAYOUT.varHandle(sequenceElement());

    /**
     * Indexed getter for field:
     * {@snippet lang=c :
     * __u8 key[80]
     * }
     */
    public static byte key(MemorySegment struct, long index0) {
        return (byte)key$ELEM_HANDLE.get(struct, 0L, index0);
    }

    /**
     * Indexed setter for field:
     * {@snippet lang=c :
     * __u8 key[80]
     * }
     */
    public static void key(MemorySegment struct, long index0, byte fieldValue) {
        key$ELEM_HANDLE.set(struct, 0L, index0, fieldValue);
    }

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

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

    private static final long nkeys$OFFSET = 272;

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

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

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

    private static final OfByte sndid$LAYOUT = (OfByte)$LAYOUT.select(groupElement("sndid"));

    /**
     * Layout for field:
     * {@snippet lang=c :
     * __u8 sndid
     * }
     */
    public static final OfByte sndid$layout() {
        return sndid$LAYOUT;
    }

    private static final long sndid$OFFSET = 278;

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

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

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

    private static final OfByte rcvid$LAYOUT = (OfByte)$LAYOUT.select(groupElement("rcvid"));

    /**
     * Layout for field:
     * {@snippet lang=c :
     * __u8 rcvid
     * }
     */
    public static final OfByte rcvid$layout() {
        return rcvid$LAYOUT;
    }

    private static final long rcvid$OFFSET = 279;

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

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

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

    private static final OfByte prefix$LAYOUT = (OfByte)$LAYOUT.select(groupElement("prefix"));

    /**
     * Layout for field:
     * {@snippet lang=c :
     * __u8 prefix
     * }
     */
    public static final OfByte prefix$layout() {
        return prefix$LAYOUT;
    }

    private static final long prefix$OFFSET = 280;

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

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

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

    private static final OfByte maclen$LAYOUT = (OfByte)$LAYOUT.select(groupElement("maclen"));

    /**
     * Layout for field:
     * {@snippet lang=c :
     * __u8 maclen
     * }
     */
    public static final OfByte maclen$layout() {
        return maclen$LAYOUT;
    }

    private static final long maclen$OFFSET = 281;

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

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

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

    private static final OfByte keyflags$LAYOUT = (OfByte)$LAYOUT.select(groupElement("keyflags"));

    /**
     * Layout for field:
     * {@snippet lang=c :
     * __u8 keyflags
     * }
     */
    public static final OfByte keyflags$layout() {
        return keyflags$LAYOUT;
    }

    private static final long keyflags$OFFSET = 282;

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

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

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

    private static final OfByte keylen$LAYOUT = (OfByte)$LAYOUT.select(groupElement("keylen"));

    /**
     * Layout for field:
     * {@snippet lang=c :
     * __u8 keylen
     * }
     */
    public static final OfByte keylen$layout() {
        return keylen$LAYOUT;
    }

    private static final long keylen$OFFSET = 283;

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

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

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

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

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

    private static final long ifindex$OFFSET = 284;

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

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

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

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

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

    private static final long pkt_good$OFFSET = 288;

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

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

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

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

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

    private static final long pkt_bad$OFFSET = 296;

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

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

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