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

me.bechberger.ebpf.bpf.raw.xdp_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 xdp_md {
 *     __u32 data;
 *     __u32 data_end;
 *     __u32 data_meta;
 *     __u32 ingress_ifindex;
 *     __u32 rx_queue_index;
 *     __u32 egress_ifindex;
 * }
 * }
 */
public class xdp_md {

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

    private static final GroupLayout $LAYOUT = MemoryLayout.structLayout(
        Lib.C_INT.withName("data"),
        Lib.C_INT.withName("data_end"),
        Lib.C_INT.withName("data_meta"),
        Lib.C_INT.withName("ingress_ifindex"),
        Lib.C_INT.withName("rx_queue_index"),
        Lib.C_INT.withName("egress_ifindex")
    ).withName("xdp_md");

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

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

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

    private static final long data$OFFSET = 0;

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

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

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

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

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

    private static final long data_end$OFFSET = 4;

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

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

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

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

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

    private static final long data_meta$OFFSET = 8;

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

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

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

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

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

    private static final long ingress_ifindex$OFFSET = 12;

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

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

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

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

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

    private static final long rx_queue_index$OFFSET = 16;

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

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

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

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

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

    private static final long egress_ifindex$OFFSET = 20;

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

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

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