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

me.bechberger.ebpf.bpf.raw.bpf_flow_keys 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 bpf_flow_keys {
 *     __u16 nhoff;
 *     __u16 thoff;
 *     __u16 addr_proto;
 *     __u8 is_frag;
 *     __u8 is_first_frag;
 *     __u8 is_encap;
 *     __u8 ip_proto;
 *     __be16 n_proto;
 *     __be16 sport;
 *     __be16 dport;
 *     union {
 *         struct {
 *             __be32 ipv4_src;
 *             __be32 ipv4_dst;
 *         };
 *         struct {
 *             __u32 ipv6_src[4];
 *             __u32 ipv6_dst[4];
 *         };
 *     };
 *     __u32 flags;
 *     __be32 flow_label;
 * }
 * }
 */
public class bpf_flow_keys {

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

    private static final GroupLayout $LAYOUT = MemoryLayout.structLayout(
        Lib.C_SHORT.withName("nhoff"),
        Lib.C_SHORT.withName("thoff"),
        Lib.C_SHORT.withName("addr_proto"),
        Lib.C_CHAR.withName("is_frag"),
        Lib.C_CHAR.withName("is_first_frag"),
        Lib.C_CHAR.withName("is_encap"),
        Lib.C_CHAR.withName("ip_proto"),
        Lib.C_SHORT.withName("n_proto"),
        Lib.C_SHORT.withName("sport"),
        Lib.C_SHORT.withName("dport"),
        MemoryLayout.unionLayout(
            MemoryLayout.structLayout(
                Lib.C_INT.withName("ipv4_src"),
                Lib.C_INT.withName("ipv4_dst")
            ).withName("$anon$7276:3"),
            MemoryLayout.structLayout(
                MemoryLayout.sequenceLayout(4, Lib.C_INT).withName("ipv6_src"),
                MemoryLayout.sequenceLayout(4, Lib.C_INT).withName("ipv6_dst")
            ).withName("$anon$7280:3")
        ).withName("$anon$7275:2"),
        Lib.C_INT.withName("flags"),
        Lib.C_INT.withName("flow_label")
    ).withName("bpf_flow_keys");

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

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

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

    private static final long nhoff$OFFSET = 0;

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

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

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

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

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

    private static final long thoff$OFFSET = 2;

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

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

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

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

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

    private static final long addr_proto$OFFSET = 4;

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

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

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

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

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

    private static final long is_frag$OFFSET = 6;

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

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

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

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

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

    private static final long is_first_frag$OFFSET = 7;

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

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

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

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

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

    private static final long is_encap$OFFSET = 8;

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

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

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

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

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

    private static final long ip_proto$OFFSET = 9;

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

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

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

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

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

    private static final long n_proto$OFFSET = 10;

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

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

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

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

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

    private static final long sport$OFFSET = 12;

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

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

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

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

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

    private static final long dport$OFFSET = 14;

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

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

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

    private static final OfInt ipv4_src$LAYOUT = (OfInt)$LAYOUT.select(groupElement("$anon$7275:2"), groupElement("$anon$7276:3"), groupElement("ipv4_src"));

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

    private static final long ipv4_src$OFFSET = 16;

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

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

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

    private static final OfInt ipv4_dst$LAYOUT = (OfInt)$LAYOUT.select(groupElement("$anon$7275:2"), groupElement("$anon$7276:3"), groupElement("ipv4_dst"));

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

    private static final long ipv4_dst$OFFSET = 20;

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

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

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

    private static final SequenceLayout ipv6_src$LAYOUT = (SequenceLayout)$LAYOUT.select(groupElement("$anon$7275:2"), groupElement("$anon$7280:3"), groupElement("ipv6_src"));

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

    private static final long ipv6_src$OFFSET = 16;

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

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

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

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

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

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

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

    private static final SequenceLayout ipv6_dst$LAYOUT = (SequenceLayout)$LAYOUT.select(groupElement("$anon$7275:2"), groupElement("$anon$7280:3"), groupElement("ipv6_dst"));

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

    private static final long ipv6_dst$OFFSET = 32;

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

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

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

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

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

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

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

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

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

    private static final long flags$OFFSET = 48;

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

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

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

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

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

    private static final long flow_label$OFFSET = 52;

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

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

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