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

me.bechberger.ebpf.bpf.raw.sk_msg_md 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 sk_msg_md {
 *     union {
 *         void *data;
 *         __u64 : 64;
 *     };
 *     union {
 *         void *data_end;
 *         __u64 : 64;
 *     };
 *     __u32 family;
 *     __u32 remote_ip4;
 *     __u32 local_ip4;
 *     __u32 remote_ip6[4];
 *     __u32 local_ip6[4];
 *     __u32 remote_port;
 *     __u32 local_port;
 *     __u32 size;
 *     union {
 *         struct bpf_sock *sk;
 *         __u64 : 64;
 *     };
 * }
 * }
 */
public class sk_msg_md {

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

    private static final GroupLayout $LAYOUT = MemoryLayout.structLayout(
        MemoryLayout.unionLayout(
            Lib.C_POINTER.withName("data")
        ).withName("$anon$6488:2"),
        MemoryLayout.unionLayout(
            Lib.C_POINTER.withName("data_end")
        ).withName("$anon$6489:2"),
        Lib.C_INT.withName("family"),
        Lib.C_INT.withName("remote_ip4"),
        Lib.C_INT.withName("local_ip4"),
        MemoryLayout.sequenceLayout(4, Lib.C_INT).withName("remote_ip6"),
        MemoryLayout.sequenceLayout(4, Lib.C_INT).withName("local_ip6"),
        Lib.C_INT.withName("remote_port"),
        Lib.C_INT.withName("local_port"),
        Lib.C_INT.withName("size"),
        MemoryLayout.unionLayout(
            Lib.C_POINTER.withName("sk")
        ).withName("$anon$6500:2")
    ).withName("sk_msg_md");

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

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

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

    private static final long data$OFFSET = 0;

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

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

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

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

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

    private static final long data_end$OFFSET = 8;

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

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

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

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

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

    private static final long family$OFFSET = 16;

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

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

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

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

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

    private static final long remote_ip4$OFFSET = 20;

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

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

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

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

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

    private static final long local_ip4$OFFSET = 24;

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

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

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

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

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

    private static final long remote_ip6$OFFSET = 28;

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

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

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

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

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

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

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

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

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

    private static final long local_ip6$OFFSET = 44;

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

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

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

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

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

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

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

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

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

    private static final long remote_port$OFFSET = 60;

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

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

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

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

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

    private static final long local_port$OFFSET = 64;

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

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

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

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

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

    private static final long size$OFFSET = 68;

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

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

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

    private static final AddressLayout sk$LAYOUT = (AddressLayout)$LAYOUT.select(groupElement("$anon$6500: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 = 72;

    /**
     * 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);
    }

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