me.bechberger.ebpf.bpf.raw.btf_header 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 btf_header {
* __u16 magic;
* __u8 version;
* __u8 flags;
* __u32 hdr_len;
* __u32 type_off;
* __u32 type_len;
* __u32 str_off;
* __u32 str_len;
* }
* }
*/
public class btf_header {
btf_header() {
// Should not be called directly
}
private static final GroupLayout $LAYOUT = MemoryLayout.structLayout(
Lib.C_SHORT.withName("magic"),
Lib.C_CHAR.withName("version"),
Lib.C_CHAR.withName("flags"),
Lib.C_INT.withName("hdr_len"),
Lib.C_INT.withName("type_off"),
Lib.C_INT.withName("type_len"),
Lib.C_INT.withName("str_off"),
Lib.C_INT.withName("str_len")
).withName("btf_header");
/**
* The layout of this struct
*/
public static final GroupLayout layout() {
return $LAYOUT;
}
private static final OfShort magic$LAYOUT = (OfShort)$LAYOUT.select(groupElement("magic"));
/**
* Layout for field:
* {@snippet lang=c :
* __u16 magic
* }
*/
public static final OfShort magic$layout() {
return magic$LAYOUT;
}
private static final long magic$OFFSET = 0;
/**
* Offset for field:
* {@snippet lang=c :
* __u16 magic
* }
*/
public static final long magic$offset() {
return magic$OFFSET;
}
/**
* Getter for field:
* {@snippet lang=c :
* __u16 magic
* }
*/
public static short magic(MemorySegment struct) {
return struct.get(magic$LAYOUT, magic$OFFSET);
}
/**
* Setter for field:
* {@snippet lang=c :
* __u16 magic
* }
*/
public static void magic(MemorySegment struct, short fieldValue) {
struct.set(magic$LAYOUT, magic$OFFSET, fieldValue);
}
private static final OfByte version$LAYOUT = (OfByte)$LAYOUT.select(groupElement("version"));
/**
* Layout for field:
* {@snippet lang=c :
* __u8 version
* }
*/
public static final OfByte version$layout() {
return version$LAYOUT;
}
private static final long version$OFFSET = 2;
/**
* Offset for field:
* {@snippet lang=c :
* __u8 version
* }
*/
public static final long version$offset() {
return version$OFFSET;
}
/**
* Getter for field:
* {@snippet lang=c :
* __u8 version
* }
*/
public static byte version(MemorySegment struct) {
return struct.get(version$LAYOUT, version$OFFSET);
}
/**
* Setter for field:
* {@snippet lang=c :
* __u8 version
* }
*/
public static void version(MemorySegment struct, byte fieldValue) {
struct.set(version$LAYOUT, version$OFFSET, fieldValue);
}
private static final OfByte flags$LAYOUT = (OfByte)$LAYOUT.select(groupElement("flags"));
/**
* Layout for field:
* {@snippet lang=c :
* __u8 flags
* }
*/
public static final OfByte flags$layout() {
return flags$LAYOUT;
}
private static final long flags$OFFSET = 3;
/**
* Offset for field:
* {@snippet lang=c :
* __u8 flags
* }
*/
public static final long flags$offset() {
return flags$OFFSET;
}
/**
* Getter for field:
* {@snippet lang=c :
* __u8 flags
* }
*/
public static byte flags(MemorySegment struct) {
return struct.get(flags$LAYOUT, flags$OFFSET);
}
/**
* Setter for field:
* {@snippet lang=c :
* __u8 flags
* }
*/
public static void flags(MemorySegment struct, byte fieldValue) {
struct.set(flags$LAYOUT, flags$OFFSET, fieldValue);
}
private static final OfInt hdr_len$LAYOUT = (OfInt)$LAYOUT.select(groupElement("hdr_len"));
/**
* Layout for field:
* {@snippet lang=c :
* __u32 hdr_len
* }
*/
public static final OfInt hdr_len$layout() {
return hdr_len$LAYOUT;
}
private static final long hdr_len$OFFSET = 4;
/**
* Offset for field:
* {@snippet lang=c :
* __u32 hdr_len
* }
*/
public static final long hdr_len$offset() {
return hdr_len$OFFSET;
}
/**
* Getter for field:
* {@snippet lang=c :
* __u32 hdr_len
* }
*/
public static int hdr_len(MemorySegment struct) {
return struct.get(hdr_len$LAYOUT, hdr_len$OFFSET);
}
/**
* Setter for field:
* {@snippet lang=c :
* __u32 hdr_len
* }
*/
public static void hdr_len(MemorySegment struct, int fieldValue) {
struct.set(hdr_len$LAYOUT, hdr_len$OFFSET, fieldValue);
}
private static final OfInt type_off$LAYOUT = (OfInt)$LAYOUT.select(groupElement("type_off"));
/**
* Layout for field:
* {@snippet lang=c :
* __u32 type_off
* }
*/
public static final OfInt type_off$layout() {
return type_off$LAYOUT;
}
private static final long type_off$OFFSET = 8;
/**
* Offset for field:
* {@snippet lang=c :
* __u32 type_off
* }
*/
public static final long type_off$offset() {
return type_off$OFFSET;
}
/**
* Getter for field:
* {@snippet lang=c :
* __u32 type_off
* }
*/
public static int type_off(MemorySegment struct) {
return struct.get(type_off$LAYOUT, type_off$OFFSET);
}
/**
* Setter for field:
* {@snippet lang=c :
* __u32 type_off
* }
*/
public static void type_off(MemorySegment struct, int fieldValue) {
struct.set(type_off$LAYOUT, type_off$OFFSET, fieldValue);
}
private static final OfInt type_len$LAYOUT = (OfInt)$LAYOUT.select(groupElement("type_len"));
/**
* Layout for field:
* {@snippet lang=c :
* __u32 type_len
* }
*/
public static final OfInt type_len$layout() {
return type_len$LAYOUT;
}
private static final long type_len$OFFSET = 12;
/**
* Offset for field:
* {@snippet lang=c :
* __u32 type_len
* }
*/
public static final long type_len$offset() {
return type_len$OFFSET;
}
/**
* Getter for field:
* {@snippet lang=c :
* __u32 type_len
* }
*/
public static int type_len(MemorySegment struct) {
return struct.get(type_len$LAYOUT, type_len$OFFSET);
}
/**
* Setter for field:
* {@snippet lang=c :
* __u32 type_len
* }
*/
public static void type_len(MemorySegment struct, int fieldValue) {
struct.set(type_len$LAYOUT, type_len$OFFSET, fieldValue);
}
private static final OfInt str_off$LAYOUT = (OfInt)$LAYOUT.select(groupElement("str_off"));
/**
* Layout for field:
* {@snippet lang=c :
* __u32 str_off
* }
*/
public static final OfInt str_off$layout() {
return str_off$LAYOUT;
}
private static final long str_off$OFFSET = 16;
/**
* Offset for field:
* {@snippet lang=c :
* __u32 str_off
* }
*/
public static final long str_off$offset() {
return str_off$OFFSET;
}
/**
* Getter for field:
* {@snippet lang=c :
* __u32 str_off
* }
*/
public static int str_off(MemorySegment struct) {
return struct.get(str_off$LAYOUT, str_off$OFFSET);
}
/**
* Setter for field:
* {@snippet lang=c :
* __u32 str_off
* }
*/
public static void str_off(MemorySegment struct, int fieldValue) {
struct.set(str_off$LAYOUT, str_off$OFFSET, fieldValue);
}
private static final OfInt str_len$LAYOUT = (OfInt)$LAYOUT.select(groupElement("str_len"));
/**
* Layout for field:
* {@snippet lang=c :
* __u32 str_len
* }
*/
public static final OfInt str_len$layout() {
return str_len$LAYOUT;
}
private static final long str_len$OFFSET = 20;
/**
* Offset for field:
* {@snippet lang=c :
* __u32 str_len
* }
*/
public static final long str_len$offset() {
return str_len$OFFSET;
}
/**
* Getter for field:
* {@snippet lang=c :
* __u32 str_len
* }
*/
public static int str_len(MemorySegment struct) {
return struct.get(str_len$LAYOUT, str_len$OFFSET);
}
/**
* Setter for field:
* {@snippet lang=c :
* __u32 str_len
* }
*/
public static void str_len(MemorySegment struct, int fieldValue) {
struct.set(str_len$LAYOUT, str_len$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);
}
}