me.bechberger.ebpf.bpf.raw.in6_addr Maven / Gradle / Ivy
Go to download
Show more of this group Show more artifacts with this name
Show all versions of rawbpf Show documentation
Show all versions of rawbpf Show documentation
Raw Panama bindings for libbpf generated for jextract on 64-bit Linux
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_addr {
* union {
* __u8 u6_addr8[16];
* __be16 u6_addr16[8];
* __be32 u6_addr32[4];
* } in6_u;
* }
* }
*/
public class in6_addr {
in6_addr() {
// Should not be called directly
}
private static final GroupLayout $LAYOUT = MemoryLayout.structLayout(
in6_addr.in6_u.layout().withName("in6_u")
).withName("in6_addr");
/**
* The layout of this struct
*/
public static final GroupLayout layout() {
return $LAYOUT;
}
/**
* {@snippet lang=c :
* union {
* __u8 u6_addr8[16];
* __be16 u6_addr16[8];
* __be32 u6_addr32[4];
* }
* }
*/
public static class in6_u {
in6_u() {
// Should not be called directly
}
private static final GroupLayout $LAYOUT = MemoryLayout.unionLayout(
MemoryLayout.sequenceLayout(16, Lib.C_CHAR).withName("u6_addr8"),
MemoryLayout.sequenceLayout(8, Lib.C_SHORT).withName("u6_addr16"),
MemoryLayout.sequenceLayout(4, Lib.C_INT).withName("u6_addr32")
).withName("$anon$34:2");
/**
* The layout of this union
*/
public static final GroupLayout layout() {
return $LAYOUT;
}
private static final SequenceLayout u6_addr8$LAYOUT = (SequenceLayout)$LAYOUT.select(groupElement("u6_addr8"));
/**
* Layout for field:
* {@snippet lang=c :
* __u8 u6_addr8[16]
* }
*/
public static final SequenceLayout u6_addr8$layout() {
return u6_addr8$LAYOUT;
}
private static final long u6_addr8$OFFSET = 0;
/**
* Offset for field:
* {@snippet lang=c :
* __u8 u6_addr8[16]
* }
*/
public static final long u6_addr8$offset() {
return u6_addr8$OFFSET;
}
/**
* Getter for field:
* {@snippet lang=c :
* __u8 u6_addr8[16]
* }
*/
public static MemorySegment u6_addr8(MemorySegment union) {
return union.asSlice(u6_addr8$OFFSET, u6_addr8$LAYOUT.byteSize());
}
/**
* Setter for field:
* {@snippet lang=c :
* __u8 u6_addr8[16]
* }
*/
public static void u6_addr8(MemorySegment union, MemorySegment fieldValue) {
MemorySegment.copy(fieldValue, 0L, union, u6_addr8$OFFSET, u6_addr8$LAYOUT.byteSize());
}
private static long[] u6_addr8$DIMS = { 16 };
/**
* Dimensions for array field:
* {@snippet lang=c :
* __u8 u6_addr8[16]
* }
*/
public static long[] u6_addr8$dimensions() {
return u6_addr8$DIMS;
}
private static final VarHandle u6_addr8$ELEM_HANDLE = u6_addr8$LAYOUT.varHandle(sequenceElement());
/**
* Indexed getter for field:
* {@snippet lang=c :
* __u8 u6_addr8[16]
* }
*/
public static byte u6_addr8(MemorySegment union, long index0) {
return (byte)u6_addr8$ELEM_HANDLE.get(union, 0L, index0);
}
/**
* Indexed setter for field:
* {@snippet lang=c :
* __u8 u6_addr8[16]
* }
*/
public static void u6_addr8(MemorySegment union, long index0, byte fieldValue) {
u6_addr8$ELEM_HANDLE.set(union, 0L, index0, fieldValue);
}
private static final SequenceLayout u6_addr16$LAYOUT = (SequenceLayout)$LAYOUT.select(groupElement("u6_addr16"));
/**
* Layout for field:
* {@snippet lang=c :
* __be16 u6_addr16[8]
* }
*/
public static final SequenceLayout u6_addr16$layout() {
return u6_addr16$LAYOUT;
}
private static final long u6_addr16$OFFSET = 0;
/**
* Offset for field:
* {@snippet lang=c :
* __be16 u6_addr16[8]
* }
*/
public static final long u6_addr16$offset() {
return u6_addr16$OFFSET;
}
/**
* Getter for field:
* {@snippet lang=c :
* __be16 u6_addr16[8]
* }
*/
public static MemorySegment u6_addr16(MemorySegment union) {
return union.asSlice(u6_addr16$OFFSET, u6_addr16$LAYOUT.byteSize());
}
/**
* Setter for field:
* {@snippet lang=c :
* __be16 u6_addr16[8]
* }
*/
public static void u6_addr16(MemorySegment union, MemorySegment fieldValue) {
MemorySegment.copy(fieldValue, 0L, union, u6_addr16$OFFSET, u6_addr16$LAYOUT.byteSize());
}
private static long[] u6_addr16$DIMS = { 8 };
/**
* Dimensions for array field:
* {@snippet lang=c :
* __be16 u6_addr16[8]
* }
*/
public static long[] u6_addr16$dimensions() {
return u6_addr16$DIMS;
}
private static final VarHandle u6_addr16$ELEM_HANDLE = u6_addr16$LAYOUT.varHandle(sequenceElement());
/**
* Indexed getter for field:
* {@snippet lang=c :
* __be16 u6_addr16[8]
* }
*/
public static short u6_addr16(MemorySegment union, long index0) {
return (short)u6_addr16$ELEM_HANDLE.get(union, 0L, index0);
}
/**
* Indexed setter for field:
* {@snippet lang=c :
* __be16 u6_addr16[8]
* }
*/
public static void u6_addr16(MemorySegment union, long index0, short fieldValue) {
u6_addr16$ELEM_HANDLE.set(union, 0L, index0, fieldValue);
}
private static final SequenceLayout u6_addr32$LAYOUT = (SequenceLayout)$LAYOUT.select(groupElement("u6_addr32"));
/**
* Layout for field:
* {@snippet lang=c :
* __be32 u6_addr32[4]
* }
*/
public static final SequenceLayout u6_addr32$layout() {
return u6_addr32$LAYOUT;
}
private static final long u6_addr32$OFFSET = 0;
/**
* Offset for field:
* {@snippet lang=c :
* __be32 u6_addr32[4]
* }
*/
public static final long u6_addr32$offset() {
return u6_addr32$OFFSET;
}
/**
* Getter for field:
* {@snippet lang=c :
* __be32 u6_addr32[4]
* }
*/
public static MemorySegment u6_addr32(MemorySegment union) {
return union.asSlice(u6_addr32$OFFSET, u6_addr32$LAYOUT.byteSize());
}
/**
* Setter for field:
* {@snippet lang=c :
* __be32 u6_addr32[4]
* }
*/
public static void u6_addr32(MemorySegment union, MemorySegment fieldValue) {
MemorySegment.copy(fieldValue, 0L, union, u6_addr32$OFFSET, u6_addr32$LAYOUT.byteSize());
}
private static long[] u6_addr32$DIMS = { 4 };
/**
* Dimensions for array field:
* {@snippet lang=c :
* __be32 u6_addr32[4]
* }
*/
public static long[] u6_addr32$dimensions() {
return u6_addr32$DIMS;
}
private static final VarHandle u6_addr32$ELEM_HANDLE = u6_addr32$LAYOUT.varHandle(sequenceElement());
/**
* Indexed getter for field:
* {@snippet lang=c :
* __be32 u6_addr32[4]
* }
*/
public static int u6_addr32(MemorySegment union, long index0) {
return (int)u6_addr32$ELEM_HANDLE.get(union, 0L, index0);
}
/**
* Indexed setter for field:
* {@snippet lang=c :
* __be32 u6_addr32[4]
* }
*/
public static void u6_addr32(MemorySegment union, long index0, int fieldValue) {
u6_addr32$ELEM_HANDLE.set(union, 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 union
*/
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);
}
}
private static final GroupLayout in6_u$LAYOUT = (GroupLayout)$LAYOUT.select(groupElement("in6_u"));
/**
* Layout for field:
* {@snippet lang=c :
* union {
* __u8 u6_addr8[16];
* __be16 u6_addr16[8];
* __be32 u6_addr32[4];
* } in6_u
* }
*/
public static final GroupLayout in6_u$layout() {
return in6_u$LAYOUT;
}
private static final long in6_u$OFFSET = 0;
/**
* Offset for field:
* {@snippet lang=c :
* union {
* __u8 u6_addr8[16];
* __be16 u6_addr16[8];
* __be32 u6_addr32[4];
* } in6_u
* }
*/
public static final long in6_u$offset() {
return in6_u$OFFSET;
}
/**
* Getter for field:
* {@snippet lang=c :
* union {
* __u8 u6_addr8[16];
* __be16 u6_addr16[8];
* __be32 u6_addr32[4];
* } in6_u
* }
*/
public static MemorySegment in6_u(MemorySegment struct) {
return struct.asSlice(in6_u$OFFSET, in6_u$LAYOUT.byteSize());
}
/**
* Setter for field:
* {@snippet lang=c :
* union {
* __u8 u6_addr8[16];
* __be16 u6_addr16[8];
* __be32 u6_addr32[4];
* } in6_u
* }
*/
public static void in6_u(MemorySegment struct, MemorySegment fieldValue) {
MemorySegment.copy(fieldValue, 0L, struct, in6_u$OFFSET, in6_u$LAYOUT.byteSize());
}
/**
* 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);
}
}