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

me.bechberger.ebpf.bpf.raw.tcp_diag_md5sig 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_diag_md5sig {
 *     __u8 tcpm_family;
 *     __u8 tcpm_prefixlen;
 *     __u16 tcpm_keylen;
 *     __be32 tcpm_addr[4];
 *     __u8 tcpm_key[80];
 * }
 * }
 */
public class tcp_diag_md5sig {

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

    private static final GroupLayout $LAYOUT = MemoryLayout.structLayout(
        Lib.C_CHAR.withName("tcpm_family"),
        Lib.C_CHAR.withName("tcpm_prefixlen"),
        Lib.C_SHORT.withName("tcpm_keylen"),
        MemoryLayout.sequenceLayout(4, Lib.C_INT).withName("tcpm_addr"),
        MemoryLayout.sequenceLayout(80, Lib.C_CHAR).withName("tcpm_key")
    ).withName("tcp_diag_md5sig");

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

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

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

    private static final long tcpm_family$OFFSET = 0;

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

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

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

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

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

    private static final long tcpm_prefixlen$OFFSET = 1;

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

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

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

    private static final OfShort tcpm_keylen$LAYOUT = (OfShort)$LAYOUT.select(groupElement("tcpm_keylen"));

    /**
     * Layout for field:
     * {@snippet lang=c :
     * __u16 tcpm_keylen
     * }
     */
    public static final OfShort tcpm_keylen$layout() {
        return tcpm_keylen$LAYOUT;
    }

    private static final long tcpm_keylen$OFFSET = 2;

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

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

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

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

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

    private static final long tcpm_addr$OFFSET = 4;

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

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

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

    private static long[] tcpm_addr$DIMS = { 4 };

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

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

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

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

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

    private static final long tcpm_key$OFFSET = 20;

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

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

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

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

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

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

    /**
     * Indexed setter for field:
     * {@snippet lang=c :
     * __u8 tcpm_key[80]
     * }
     */
    public static void tcpm_key(MemorySegment struct, long index0, byte fieldValue) {
        tcpm_key$ELEM_HANDLE.set(struct, 0L, index0, 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