me.bechberger.ebpf.bpf.raw.bpf_tunnel_key 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 bpf_tunnel_key {
* __u32 tunnel_id;
* union {
* __u32 remote_ipv4;
* __u32 remote_ipv6[4];
* };
* __u8 tunnel_tos;
* __u8 tunnel_ttl;
* union {
* __u16 tunnel_ext;
* __be16 tunnel_flags;
* };
* __u32 tunnel_label;
* union {
* __u32 local_ipv4;
* __u32 local_ipv6[4];
* };
* }
* }
*/
public class bpf_tunnel_key {
bpf_tunnel_key() {
// Should not be called directly
}
private static final GroupLayout $LAYOUT = MemoryLayout.structLayout(
Lib.C_INT.withName("tunnel_id"),
MemoryLayout.unionLayout(
Lib.C_INT.withName("remote_ipv4"),
MemoryLayout.sequenceLayout(4, Lib.C_INT).withName("remote_ipv6")
).withName("$anon$6266:2"),
Lib.C_CHAR.withName("tunnel_tos"),
Lib.C_CHAR.withName("tunnel_ttl"),
MemoryLayout.unionLayout(
Lib.C_SHORT.withName("tunnel_ext"),
Lib.C_SHORT.withName("tunnel_flags")
).withName("$anon$6272:2"),
Lib.C_INT.withName("tunnel_label"),
MemoryLayout.unionLayout(
Lib.C_INT.withName("local_ipv4"),
MemoryLayout.sequenceLayout(4, Lib.C_INT).withName("local_ipv6")
).withName("$anon$6277:2")
).withName("bpf_tunnel_key");
/**
* The layout of this struct
*/
public static final GroupLayout layout() {
return $LAYOUT;
}
private static final OfInt tunnel_id$LAYOUT = (OfInt)$LAYOUT.select(groupElement("tunnel_id"));
/**
* Layout for field:
* {@snippet lang=c :
* __u32 tunnel_id
* }
*/
public static final OfInt tunnel_id$layout() {
return tunnel_id$LAYOUT;
}
private static final long tunnel_id$OFFSET = 0;
/**
* Offset for field:
* {@snippet lang=c :
* __u32 tunnel_id
* }
*/
public static final long tunnel_id$offset() {
return tunnel_id$OFFSET;
}
/**
* Getter for field:
* {@snippet lang=c :
* __u32 tunnel_id
* }
*/
public static int tunnel_id(MemorySegment struct) {
return struct.get(tunnel_id$LAYOUT, tunnel_id$OFFSET);
}
/**
* Setter for field:
* {@snippet lang=c :
* __u32 tunnel_id
* }
*/
public static void tunnel_id(MemorySegment struct, int fieldValue) {
struct.set(tunnel_id$LAYOUT, tunnel_id$OFFSET, fieldValue);
}
private static final OfInt remote_ipv4$LAYOUT = (OfInt)$LAYOUT.select(groupElement("$anon$6266:2"), groupElement("remote_ipv4"));
/**
* Layout for field:
* {@snippet lang=c :
* __u32 remote_ipv4
* }
*/
public static final OfInt remote_ipv4$layout() {
return remote_ipv4$LAYOUT;
}
private static final long remote_ipv4$OFFSET = 4;
/**
* Offset for field:
* {@snippet lang=c :
* __u32 remote_ipv4
* }
*/
public static final long remote_ipv4$offset() {
return remote_ipv4$OFFSET;
}
/**
* Getter for field:
* {@snippet lang=c :
* __u32 remote_ipv4
* }
*/
public static int remote_ipv4(MemorySegment struct) {
return struct.get(remote_ipv4$LAYOUT, remote_ipv4$OFFSET);
}
/**
* Setter for field:
* {@snippet lang=c :
* __u32 remote_ipv4
* }
*/
public static void remote_ipv4(MemorySegment struct, int fieldValue) {
struct.set(remote_ipv4$LAYOUT, remote_ipv4$OFFSET, fieldValue);
}
private static final SequenceLayout remote_ipv6$LAYOUT = (SequenceLayout)$LAYOUT.select(groupElement("$anon$6266:2"), groupElement("remote_ipv6"));
/**
* Layout for field:
* {@snippet lang=c :
* __u32 remote_ipv6[4]
* }
*/
public static final SequenceLayout remote_ipv6$layout() {
return remote_ipv6$LAYOUT;
}
private static final long remote_ipv6$OFFSET = 4;
/**
* Offset for field:
* {@snippet lang=c :
* __u32 remote_ipv6[4]
* }
*/
public static final long remote_ipv6$offset() {
return remote_ipv6$OFFSET;
}
/**
* Getter for field:
* {@snippet lang=c :
* __u32 remote_ipv6[4]
* }
*/
public static MemorySegment remote_ipv6(MemorySegment struct) {
return struct.asSlice(remote_ipv6$OFFSET, remote_ipv6$LAYOUT.byteSize());
}
/**
* Setter for field:
* {@snippet lang=c :
* __u32 remote_ipv6[4]
* }
*/
public static void remote_ipv6(MemorySegment struct, MemorySegment fieldValue) {
MemorySegment.copy(fieldValue, 0L, struct, remote_ipv6$OFFSET, remote_ipv6$LAYOUT.byteSize());
}
private static long[] remote_ipv6$DIMS = { 4 };
/**
* Dimensions for array field:
* {@snippet lang=c :
* __u32 remote_ipv6[4]
* }
*/
public static long[] remote_ipv6$dimensions() {
return remote_ipv6$DIMS;
}
private static final VarHandle remote_ipv6$ELEM_HANDLE = remote_ipv6$LAYOUT.varHandle(sequenceElement());
/**
* Indexed getter for field:
* {@snippet lang=c :
* __u32 remote_ipv6[4]
* }
*/
public static int remote_ipv6(MemorySegment struct, long index0) {
return (int)remote_ipv6$ELEM_HANDLE.get(struct, 0L, index0);
}
/**
* Indexed setter for field:
* {@snippet lang=c :
* __u32 remote_ipv6[4]
* }
*/
public static void remote_ipv6(MemorySegment struct, long index0, int fieldValue) {
remote_ipv6$ELEM_HANDLE.set(struct, 0L, index0, fieldValue);
}
private static final OfByte tunnel_tos$LAYOUT = (OfByte)$LAYOUT.select(groupElement("tunnel_tos"));
/**
* Layout for field:
* {@snippet lang=c :
* __u8 tunnel_tos
* }
*/
public static final OfByte tunnel_tos$layout() {
return tunnel_tos$LAYOUT;
}
private static final long tunnel_tos$OFFSET = 20;
/**
* Offset for field:
* {@snippet lang=c :
* __u8 tunnel_tos
* }
*/
public static final long tunnel_tos$offset() {
return tunnel_tos$OFFSET;
}
/**
* Getter for field:
* {@snippet lang=c :
* __u8 tunnel_tos
* }
*/
public static byte tunnel_tos(MemorySegment struct) {
return struct.get(tunnel_tos$LAYOUT, tunnel_tos$OFFSET);
}
/**
* Setter for field:
* {@snippet lang=c :
* __u8 tunnel_tos
* }
*/
public static void tunnel_tos(MemorySegment struct, byte fieldValue) {
struct.set(tunnel_tos$LAYOUT, tunnel_tos$OFFSET, fieldValue);
}
private static final OfByte tunnel_ttl$LAYOUT = (OfByte)$LAYOUT.select(groupElement("tunnel_ttl"));
/**
* Layout for field:
* {@snippet lang=c :
* __u8 tunnel_ttl
* }
*/
public static final OfByte tunnel_ttl$layout() {
return tunnel_ttl$LAYOUT;
}
private static final long tunnel_ttl$OFFSET = 21;
/**
* Offset for field:
* {@snippet lang=c :
* __u8 tunnel_ttl
* }
*/
public static final long tunnel_ttl$offset() {
return tunnel_ttl$OFFSET;
}
/**
* Getter for field:
* {@snippet lang=c :
* __u8 tunnel_ttl
* }
*/
public static byte tunnel_ttl(MemorySegment struct) {
return struct.get(tunnel_ttl$LAYOUT, tunnel_ttl$OFFSET);
}
/**
* Setter for field:
* {@snippet lang=c :
* __u8 tunnel_ttl
* }
*/
public static void tunnel_ttl(MemorySegment struct, byte fieldValue) {
struct.set(tunnel_ttl$LAYOUT, tunnel_ttl$OFFSET, fieldValue);
}
private static final OfShort tunnel_ext$LAYOUT = (OfShort)$LAYOUT.select(groupElement("$anon$6272:2"), groupElement("tunnel_ext"));
/**
* Layout for field:
* {@snippet lang=c :
* __u16 tunnel_ext
* }
*/
public static final OfShort tunnel_ext$layout() {
return tunnel_ext$LAYOUT;
}
private static final long tunnel_ext$OFFSET = 22;
/**
* Offset for field:
* {@snippet lang=c :
* __u16 tunnel_ext
* }
*/
public static final long tunnel_ext$offset() {
return tunnel_ext$OFFSET;
}
/**
* Getter for field:
* {@snippet lang=c :
* __u16 tunnel_ext
* }
*/
public static short tunnel_ext(MemorySegment struct) {
return struct.get(tunnel_ext$LAYOUT, tunnel_ext$OFFSET);
}
/**
* Setter for field:
* {@snippet lang=c :
* __u16 tunnel_ext
* }
*/
public static void tunnel_ext(MemorySegment struct, short fieldValue) {
struct.set(tunnel_ext$LAYOUT, tunnel_ext$OFFSET, fieldValue);
}
private static final OfShort tunnel_flags$LAYOUT = (OfShort)$LAYOUT.select(groupElement("$anon$6272:2"), groupElement("tunnel_flags"));
/**
* Layout for field:
* {@snippet lang=c :
* __be16 tunnel_flags
* }
*/
public static final OfShort tunnel_flags$layout() {
return tunnel_flags$LAYOUT;
}
private static final long tunnel_flags$OFFSET = 22;
/**
* Offset for field:
* {@snippet lang=c :
* __be16 tunnel_flags
* }
*/
public static final long tunnel_flags$offset() {
return tunnel_flags$OFFSET;
}
/**
* Getter for field:
* {@snippet lang=c :
* __be16 tunnel_flags
* }
*/
public static short tunnel_flags(MemorySegment struct) {
return struct.get(tunnel_flags$LAYOUT, tunnel_flags$OFFSET);
}
/**
* Setter for field:
* {@snippet lang=c :
* __be16 tunnel_flags
* }
*/
public static void tunnel_flags(MemorySegment struct, short fieldValue) {
struct.set(tunnel_flags$LAYOUT, tunnel_flags$OFFSET, fieldValue);
}
private static final OfInt tunnel_label$LAYOUT = (OfInt)$LAYOUT.select(groupElement("tunnel_label"));
/**
* Layout for field:
* {@snippet lang=c :
* __u32 tunnel_label
* }
*/
public static final OfInt tunnel_label$layout() {
return tunnel_label$LAYOUT;
}
private static final long tunnel_label$OFFSET = 24;
/**
* Offset for field:
* {@snippet lang=c :
* __u32 tunnel_label
* }
*/
public static final long tunnel_label$offset() {
return tunnel_label$OFFSET;
}
/**
* Getter for field:
* {@snippet lang=c :
* __u32 tunnel_label
* }
*/
public static int tunnel_label(MemorySegment struct) {
return struct.get(tunnel_label$LAYOUT, tunnel_label$OFFSET);
}
/**
* Setter for field:
* {@snippet lang=c :
* __u32 tunnel_label
* }
*/
public static void tunnel_label(MemorySegment struct, int fieldValue) {
struct.set(tunnel_label$LAYOUT, tunnel_label$OFFSET, fieldValue);
}
private static final OfInt local_ipv4$LAYOUT = (OfInt)$LAYOUT.select(groupElement("$anon$6277:2"), groupElement("local_ipv4"));
/**
* Layout for field:
* {@snippet lang=c :
* __u32 local_ipv4
* }
*/
public static final OfInt local_ipv4$layout() {
return local_ipv4$LAYOUT;
}
private static final long local_ipv4$OFFSET = 28;
/**
* Offset for field:
* {@snippet lang=c :
* __u32 local_ipv4
* }
*/
public static final long local_ipv4$offset() {
return local_ipv4$OFFSET;
}
/**
* Getter for field:
* {@snippet lang=c :
* __u32 local_ipv4
* }
*/
public static int local_ipv4(MemorySegment struct) {
return struct.get(local_ipv4$LAYOUT, local_ipv4$OFFSET);
}
/**
* Setter for field:
* {@snippet lang=c :
* __u32 local_ipv4
* }
*/
public static void local_ipv4(MemorySegment struct, int fieldValue) {
struct.set(local_ipv4$LAYOUT, local_ipv4$OFFSET, fieldValue);
}
private static final SequenceLayout local_ipv6$LAYOUT = (SequenceLayout)$LAYOUT.select(groupElement("$anon$6277:2"), groupElement("local_ipv6"));
/**
* Layout for field:
* {@snippet lang=c :
* __u32 local_ipv6[4]
* }
*/
public static final SequenceLayout local_ipv6$layout() {
return local_ipv6$LAYOUT;
}
private static final long local_ipv6$OFFSET = 28;
/**
* Offset for field:
* {@snippet lang=c :
* __u32 local_ipv6[4]
* }
*/
public static final long local_ipv6$offset() {
return local_ipv6$OFFSET;
}
/**
* Getter for field:
* {@snippet lang=c :
* __u32 local_ipv6[4]
* }
*/
public static MemorySegment local_ipv6(MemorySegment struct) {
return struct.asSlice(local_ipv6$OFFSET, local_ipv6$LAYOUT.byteSize());
}
/**
* Setter for field:
* {@snippet lang=c :
* __u32 local_ipv6[4]
* }
*/
public static void local_ipv6(MemorySegment struct, MemorySegment fieldValue) {
MemorySegment.copy(fieldValue, 0L, struct, local_ipv6$OFFSET, local_ipv6$LAYOUT.byteSize());
}
private static long[] local_ipv6$DIMS = { 4 };
/**
* Dimensions for array field:
* {@snippet lang=c :
* __u32 local_ipv6[4]
* }
*/
public static long[] local_ipv6$dimensions() {
return local_ipv6$DIMS;
}
private static final VarHandle local_ipv6$ELEM_HANDLE = local_ipv6$LAYOUT.varHandle(sequenceElement());
/**
* Indexed getter for field:
* {@snippet lang=c :
* __u32 local_ipv6[4]
* }
*/
public static int local_ipv6(MemorySegment struct, long index0) {
return (int)local_ipv6$ELEM_HANDLE.get(struct, 0L, index0);
}
/**
* Indexed setter for field:
* {@snippet lang=c :
* __u32 local_ipv6[4]
* }
*/
public static void local_ipv6(MemorySegment struct, long index0, int fieldValue) {
local_ipv6$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);
}
}