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

me.bechberger.ebpf.bpf.raw.in6_pktinfo 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 in6_pktinfo {
 *     struct in6_addr ipi6_addr;
 *     int ipi6_ifindex;
 * }
 * }
 */
public class in6_pktinfo {

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

    private static final GroupLayout $LAYOUT = MemoryLayout.structLayout(
        in6_addr.layout().withName("ipi6_addr"),
        Lib.C_INT.withName("ipi6_ifindex")
    ).withName("in6_pktinfo");

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

    private static final GroupLayout ipi6_addr$LAYOUT = (GroupLayout)$LAYOUT.select(groupElement("ipi6_addr"));

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

    private static final long ipi6_addr$OFFSET = 0;

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

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

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

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

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

    private static final long ipi6_ifindex$OFFSET = 16;

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

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

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