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

me.bechberger.ebpf.bpf.raw.tpacket3_hdr 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 tpacket3_hdr {
 *     __u32 tp_next_offset;
 *     __u32 tp_sec;
 *     __u32 tp_nsec;
 *     __u32 tp_snaplen;
 *     __u32 tp_len;
 *     __u32 tp_status;
 *     __u16 tp_mac;
 *     __u16 tp_net;
 *     union {
 *         struct tpacket_hdr_variant1 hv1;
 *     };
 *     __u8 tp_padding[8];
 * }
 * }
 */
public class tpacket3_hdr {

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

    private static final GroupLayout $LAYOUT = MemoryLayout.structLayout(
        Lib.C_INT.withName("tp_next_offset"),
        Lib.C_INT.withName("tp_sec"),
        Lib.C_INT.withName("tp_nsec"),
        Lib.C_INT.withName("tp_snaplen"),
        Lib.C_INT.withName("tp_len"),
        Lib.C_INT.withName("tp_status"),
        Lib.C_SHORT.withName("tp_mac"),
        Lib.C_SHORT.withName("tp_net"),
        MemoryLayout.unionLayout(
            tpacket_hdr_variant1.layout().withName("hv1")
        ).withName("$anon$179:2"),
        MemoryLayout.sequenceLayout(8, Lib.C_CHAR).withName("tp_padding")
    ).withName("tpacket3_hdr");

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

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

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

    private static final long tp_next_offset$OFFSET = 0;

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

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

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

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

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

    private static final long tp_sec$OFFSET = 4;

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

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

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

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

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

    private static final long tp_nsec$OFFSET = 8;

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

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

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

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

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

    private static final long tp_snaplen$OFFSET = 12;

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

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

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

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

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

    private static final long tp_len$OFFSET = 16;

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

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

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

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

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

    private static final long tp_status$OFFSET = 20;

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

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

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

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

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

    private static final long tp_mac$OFFSET = 24;

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

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

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

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

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

    private static final long tp_net$OFFSET = 26;

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

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

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

    private static final GroupLayout hv1$LAYOUT = (GroupLayout)$LAYOUT.select(groupElement("$anon$179:2"), groupElement("hv1"));

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

    private static final long hv1$OFFSET = 28;

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

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

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

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

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

    private static final long tp_padding$OFFSET = 40;

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

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

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

    private static long[] tp_padding$DIMS = { 8 };

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

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

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