me.bechberger.ebpf.bpf.raw.bpf_xfrm_state 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_xfrm_state {
* __u32 reqid;
* __u32 spi;
* __u16 family;
* __u16 ext;
* union {
* __u32 remote_ipv4;
* __u32 remote_ipv6[4];
* };
* }
* }
*/
public class bpf_xfrm_state {
bpf_xfrm_state() {
// Should not be called directly
}
private static final GroupLayout $LAYOUT = MemoryLayout.structLayout(
Lib.C_INT.withName("reqid"),
Lib.C_INT.withName("spi"),
Lib.C_SHORT.withName("family"),
Lib.C_SHORT.withName("ext"),
MemoryLayout.unionLayout(
Lib.C_INT.withName("remote_ipv4"),
MemoryLayout.sequenceLayout(4, Lib.C_INT).withName("remote_ipv6")
).withName("$anon$6291:2")
).withName("bpf_xfrm_state");
/**
* The layout of this struct
*/
public static final GroupLayout layout() {
return $LAYOUT;
}
private static final OfInt reqid$LAYOUT = (OfInt)$LAYOUT.select(groupElement("reqid"));
/**
* Layout for field:
* {@snippet lang=c :
* __u32 reqid
* }
*/
public static final OfInt reqid$layout() {
return reqid$LAYOUT;
}
private static final long reqid$OFFSET = 0;
/**
* Offset for field:
* {@snippet lang=c :
* __u32 reqid
* }
*/
public static final long reqid$offset() {
return reqid$OFFSET;
}
/**
* Getter for field:
* {@snippet lang=c :
* __u32 reqid
* }
*/
public static int reqid(MemorySegment struct) {
return struct.get(reqid$LAYOUT, reqid$OFFSET);
}
/**
* Setter for field:
* {@snippet lang=c :
* __u32 reqid
* }
*/
public static void reqid(MemorySegment struct, int fieldValue) {
struct.set(reqid$LAYOUT, reqid$OFFSET, fieldValue);
}
private static final OfInt spi$LAYOUT = (OfInt)$LAYOUT.select(groupElement("spi"));
/**
* Layout for field:
* {@snippet lang=c :
* __u32 spi
* }
*/
public static final OfInt spi$layout() {
return spi$LAYOUT;
}
private static final long spi$OFFSET = 4;
/**
* Offset for field:
* {@snippet lang=c :
* __u32 spi
* }
*/
public static final long spi$offset() {
return spi$OFFSET;
}
/**
* Getter for field:
* {@snippet lang=c :
* __u32 spi
* }
*/
public static int spi(MemorySegment struct) {
return struct.get(spi$LAYOUT, spi$OFFSET);
}
/**
* Setter for field:
* {@snippet lang=c :
* __u32 spi
* }
*/
public static void spi(MemorySegment struct, int fieldValue) {
struct.set(spi$LAYOUT, spi$OFFSET, fieldValue);
}
private static final OfShort family$LAYOUT = (OfShort)$LAYOUT.select(groupElement("family"));
/**
* Layout for field:
* {@snippet lang=c :
* __u16 family
* }
*/
public static final OfShort family$layout() {
return family$LAYOUT;
}
private static final long family$OFFSET = 8;
/**
* Offset for field:
* {@snippet lang=c :
* __u16 family
* }
*/
public static final long family$offset() {
return family$OFFSET;
}
/**
* Getter for field:
* {@snippet lang=c :
* __u16 family
* }
*/
public static short family(MemorySegment struct) {
return struct.get(family$LAYOUT, family$OFFSET);
}
/**
* Setter for field:
* {@snippet lang=c :
* __u16 family
* }
*/
public static void family(MemorySegment struct, short fieldValue) {
struct.set(family$LAYOUT, family$OFFSET, fieldValue);
}
private static final OfShort ext$LAYOUT = (OfShort)$LAYOUT.select(groupElement("ext"));
/**
* Layout for field:
* {@snippet lang=c :
* __u16 ext
* }
*/
public static final OfShort ext$layout() {
return ext$LAYOUT;
}
private static final long ext$OFFSET = 10;
/**
* Offset for field:
* {@snippet lang=c :
* __u16 ext
* }
*/
public static final long ext$offset() {
return ext$OFFSET;
}
/**
* Getter for field:
* {@snippet lang=c :
* __u16 ext
* }
*/
public static short ext(MemorySegment struct) {
return struct.get(ext$LAYOUT, ext$OFFSET);
}
/**
* Setter for field:
* {@snippet lang=c :
* __u16 ext
* }
*/
public static void ext(MemorySegment struct, short fieldValue) {
struct.set(ext$LAYOUT, ext$OFFSET, fieldValue);
}
private static final OfInt remote_ipv4$LAYOUT = (OfInt)$LAYOUT.select(groupElement("$anon$6291: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 = 12;
/**
* 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$6291: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 = 12;
/**
* 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);
}
/**
* 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);
}
}