me.bechberger.ebpf.bpf.raw.tpacket_hdr_v1 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 tpacket_hdr_v1 {
* __u32 block_status;
* __u32 num_pkts;
* __u32 offset_to_first_pkt;
* __u32 blk_len;
* __u64 seq_num;
* struct tpacket_bd_ts ts_first_pkt;
* struct tpacket_bd_ts ts_last_pkt;
* }
* }
*/
public class tpacket_hdr_v1 {
tpacket_hdr_v1() {
// Should not be called directly
}
private static final GroupLayout $LAYOUT = MemoryLayout.structLayout(
Lib.C_INT.withName("block_status"),
Lib.C_INT.withName("num_pkts"),
Lib.C_INT.withName("offset_to_first_pkt"),
Lib.C_INT.withName("blk_len"),
Lib.C_LONG_LONG.withName("seq_num"),
tpacket_bd_ts.layout().withName("ts_first_pkt"),
tpacket_bd_ts.layout().withName("ts_last_pkt")
).withName("tpacket_hdr_v1");
/**
* The layout of this struct
*/
public static final GroupLayout layout() {
return $LAYOUT;
}
private static final OfInt block_status$LAYOUT = (OfInt)$LAYOUT.select(groupElement("block_status"));
/**
* Layout for field:
* {@snippet lang=c :
* __u32 block_status
* }
*/
public static final OfInt block_status$layout() {
return block_status$LAYOUT;
}
private static final long block_status$OFFSET = 0;
/**
* Offset for field:
* {@snippet lang=c :
* __u32 block_status
* }
*/
public static final long block_status$offset() {
return block_status$OFFSET;
}
/**
* Getter for field:
* {@snippet lang=c :
* __u32 block_status
* }
*/
public static int block_status(MemorySegment struct) {
return struct.get(block_status$LAYOUT, block_status$OFFSET);
}
/**
* Setter for field:
* {@snippet lang=c :
* __u32 block_status
* }
*/
public static void block_status(MemorySegment struct, int fieldValue) {
struct.set(block_status$LAYOUT, block_status$OFFSET, fieldValue);
}
private static final OfInt num_pkts$LAYOUT = (OfInt)$LAYOUT.select(groupElement("num_pkts"));
/**
* Layout for field:
* {@snippet lang=c :
* __u32 num_pkts
* }
*/
public static final OfInt num_pkts$layout() {
return num_pkts$LAYOUT;
}
private static final long num_pkts$OFFSET = 4;
/**
* Offset for field:
* {@snippet lang=c :
* __u32 num_pkts
* }
*/
public static final long num_pkts$offset() {
return num_pkts$OFFSET;
}
/**
* Getter for field:
* {@snippet lang=c :
* __u32 num_pkts
* }
*/
public static int num_pkts(MemorySegment struct) {
return struct.get(num_pkts$LAYOUT, num_pkts$OFFSET);
}
/**
* Setter for field:
* {@snippet lang=c :
* __u32 num_pkts
* }
*/
public static void num_pkts(MemorySegment struct, int fieldValue) {
struct.set(num_pkts$LAYOUT, num_pkts$OFFSET, fieldValue);
}
private static final OfInt offset_to_first_pkt$LAYOUT = (OfInt)$LAYOUT.select(groupElement("offset_to_first_pkt"));
/**
* Layout for field:
* {@snippet lang=c :
* __u32 offset_to_first_pkt
* }
*/
public static final OfInt offset_to_first_pkt$layout() {
return offset_to_first_pkt$LAYOUT;
}
private static final long offset_to_first_pkt$OFFSET = 8;
/**
* Offset for field:
* {@snippet lang=c :
* __u32 offset_to_first_pkt
* }
*/
public static final long offset_to_first_pkt$offset() {
return offset_to_first_pkt$OFFSET;
}
/**
* Getter for field:
* {@snippet lang=c :
* __u32 offset_to_first_pkt
* }
*/
public static int offset_to_first_pkt(MemorySegment struct) {
return struct.get(offset_to_first_pkt$LAYOUT, offset_to_first_pkt$OFFSET);
}
/**
* Setter for field:
* {@snippet lang=c :
* __u32 offset_to_first_pkt
* }
*/
public static void offset_to_first_pkt(MemorySegment struct, int fieldValue) {
struct.set(offset_to_first_pkt$LAYOUT, offset_to_first_pkt$OFFSET, fieldValue);
}
private static final OfInt blk_len$LAYOUT = (OfInt)$LAYOUT.select(groupElement("blk_len"));
/**
* Layout for field:
* {@snippet lang=c :
* __u32 blk_len
* }
*/
public static final OfInt blk_len$layout() {
return blk_len$LAYOUT;
}
private static final long blk_len$OFFSET = 12;
/**
* Offset for field:
* {@snippet lang=c :
* __u32 blk_len
* }
*/
public static final long blk_len$offset() {
return blk_len$OFFSET;
}
/**
* Getter for field:
* {@snippet lang=c :
* __u32 blk_len
* }
*/
public static int blk_len(MemorySegment struct) {
return struct.get(blk_len$LAYOUT, blk_len$OFFSET);
}
/**
* Setter for field:
* {@snippet lang=c :
* __u32 blk_len
* }
*/
public static void blk_len(MemorySegment struct, int fieldValue) {
struct.set(blk_len$LAYOUT, blk_len$OFFSET, fieldValue);
}
private static final OfLong seq_num$LAYOUT = (OfLong)$LAYOUT.select(groupElement("seq_num"));
/**
* Layout for field:
* {@snippet lang=c :
* __u64 seq_num
* }
*/
public static final OfLong seq_num$layout() {
return seq_num$LAYOUT;
}
private static final long seq_num$OFFSET = 16;
/**
* Offset for field:
* {@snippet lang=c :
* __u64 seq_num
* }
*/
public static final long seq_num$offset() {
return seq_num$OFFSET;
}
/**
* Getter for field:
* {@snippet lang=c :
* __u64 seq_num
* }
*/
public static long seq_num(MemorySegment struct) {
return struct.get(seq_num$LAYOUT, seq_num$OFFSET);
}
/**
* Setter for field:
* {@snippet lang=c :
* __u64 seq_num
* }
*/
public static void seq_num(MemorySegment struct, long fieldValue) {
struct.set(seq_num$LAYOUT, seq_num$OFFSET, fieldValue);
}
private static final GroupLayout ts_first_pkt$LAYOUT = (GroupLayout)$LAYOUT.select(groupElement("ts_first_pkt"));
/**
* Layout for field:
* {@snippet lang=c :
* struct tpacket_bd_ts ts_first_pkt
* }
*/
public static final GroupLayout ts_first_pkt$layout() {
return ts_first_pkt$LAYOUT;
}
private static final long ts_first_pkt$OFFSET = 24;
/**
* Offset for field:
* {@snippet lang=c :
* struct tpacket_bd_ts ts_first_pkt
* }
*/
public static final long ts_first_pkt$offset() {
return ts_first_pkt$OFFSET;
}
/**
* Getter for field:
* {@snippet lang=c :
* struct tpacket_bd_ts ts_first_pkt
* }
*/
public static MemorySegment ts_first_pkt(MemorySegment struct) {
return struct.asSlice(ts_first_pkt$OFFSET, ts_first_pkt$LAYOUT.byteSize());
}
/**
* Setter for field:
* {@snippet lang=c :
* struct tpacket_bd_ts ts_first_pkt
* }
*/
public static void ts_first_pkt(MemorySegment struct, MemorySegment fieldValue) {
MemorySegment.copy(fieldValue, 0L, struct, ts_first_pkt$OFFSET, ts_first_pkt$LAYOUT.byteSize());
}
private static final GroupLayout ts_last_pkt$LAYOUT = (GroupLayout)$LAYOUT.select(groupElement("ts_last_pkt"));
/**
* Layout for field:
* {@snippet lang=c :
* struct tpacket_bd_ts ts_last_pkt
* }
*/
public static final GroupLayout ts_last_pkt$layout() {
return ts_last_pkt$LAYOUT;
}
private static final long ts_last_pkt$OFFSET = 32;
/**
* Offset for field:
* {@snippet lang=c :
* struct tpacket_bd_ts ts_last_pkt
* }
*/
public static final long ts_last_pkt$offset() {
return ts_last_pkt$OFFSET;
}
/**
* Getter for field:
* {@snippet lang=c :
* struct tpacket_bd_ts ts_last_pkt
* }
*/
public static MemorySegment ts_last_pkt(MemorySegment struct) {
return struct.asSlice(ts_last_pkt$OFFSET, ts_last_pkt$LAYOUT.byteSize());
}
/**
* Setter for field:
* {@snippet lang=c :
* struct tpacket_bd_ts ts_last_pkt
* }
*/
public static void ts_last_pkt(MemorySegment struct, MemorySegment fieldValue) {
MemorySegment.copy(fieldValue, 0L, struct, ts_last_pkt$OFFSET, ts_last_pkt$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);
}
}