me.bechberger.ebpf.bpf.raw.tpacket_hdr 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 {
* unsigned long tp_status;
* unsigned int tp_len;
* unsigned int tp_snaplen;
* unsigned short tp_mac;
* unsigned short tp_net;
* unsigned int tp_sec;
* unsigned int tp_usec;
* }
* }
*/
public class tpacket_hdr {
tpacket_hdr() {
// Should not be called directly
}
private static final GroupLayout $LAYOUT = MemoryLayout.structLayout(
Lib.C_LONG.withName("tp_status"),
Lib.C_INT.withName("tp_len"),
Lib.C_INT.withName("tp_snaplen"),
Lib.C_SHORT.withName("tp_mac"),
Lib.C_SHORT.withName("tp_net"),
Lib.C_INT.withName("tp_sec"),
Lib.C_INT.withName("tp_usec"),
MemoryLayout.paddingLayout(4)
).withName("tpacket_hdr");
/**
* The layout of this struct
*/
public static final GroupLayout layout() {
return $LAYOUT;
}
private static final OfLong tp_status$LAYOUT = (OfLong)$LAYOUT.select(groupElement("tp_status"));
/**
* Layout for field:
* {@snippet lang=c :
* unsigned long tp_status
* }
*/
public static final OfLong tp_status$layout() {
return tp_status$LAYOUT;
}
private static final long tp_status$OFFSET = 0;
/**
* Offset for field:
* {@snippet lang=c :
* unsigned long tp_status
* }
*/
public static final long tp_status$offset() {
return tp_status$OFFSET;
}
/**
* Getter for field:
* {@snippet lang=c :
* unsigned long tp_status
* }
*/
public static long tp_status(MemorySegment struct) {
return struct.get(tp_status$LAYOUT, tp_status$OFFSET);
}
/**
* Setter for field:
* {@snippet lang=c :
* unsigned long tp_status
* }
*/
public static void tp_status(MemorySegment struct, long fieldValue) {
struct.set(tp_status$LAYOUT, tp_status$OFFSET, fieldValue);
}
private static final OfInt tp_len$LAYOUT = (OfInt)$LAYOUT.select(groupElement("tp_len"));
/**
* Layout for field:
* {@snippet lang=c :
* unsigned int tp_len
* }
*/
public static final OfInt tp_len$layout() {
return tp_len$LAYOUT;
}
private static final long tp_len$OFFSET = 8;
/**
* Offset for field:
* {@snippet lang=c :
* unsigned int tp_len
* }
*/
public static final long tp_len$offset() {
return tp_len$OFFSET;
}
/**
* Getter for field:
* {@snippet lang=c :
* unsigned int tp_len
* }
*/
public static int tp_len(MemorySegment struct) {
return struct.get(tp_len$LAYOUT, tp_len$OFFSET);
}
/**
* Setter for field:
* {@snippet lang=c :
* unsigned int tp_len
* }
*/
public static void tp_len(MemorySegment struct, int fieldValue) {
struct.set(tp_len$LAYOUT, tp_len$OFFSET, fieldValue);
}
private static final OfInt tp_snaplen$LAYOUT = (OfInt)$LAYOUT.select(groupElement("tp_snaplen"));
/**
* Layout for field:
* {@snippet lang=c :
* unsigned int tp_snaplen
* }
*/
public static final OfInt tp_snaplen$layout() {
return tp_snaplen$LAYOUT;
}
private static final long tp_snaplen$OFFSET = 12;
/**
* Offset for field:
* {@snippet lang=c :
* unsigned int tp_snaplen
* }
*/
public static final long tp_snaplen$offset() {
return tp_snaplen$OFFSET;
}
/**
* Getter for field:
* {@snippet lang=c :
* unsigned int tp_snaplen
* }
*/
public static int tp_snaplen(MemorySegment struct) {
return struct.get(tp_snaplen$LAYOUT, tp_snaplen$OFFSET);
}
/**
* Setter for field:
* {@snippet lang=c :
* unsigned int tp_snaplen
* }
*/
public static void tp_snaplen(MemorySegment struct, int fieldValue) {
struct.set(tp_snaplen$LAYOUT, tp_snaplen$OFFSET, fieldValue);
}
private static final OfShort tp_mac$LAYOUT = (OfShort)$LAYOUT.select(groupElement("tp_mac"));
/**
* Layout for field:
* {@snippet lang=c :
* unsigned short tp_mac
* }
*/
public static final OfShort tp_mac$layout() {
return tp_mac$LAYOUT;
}
private static final long tp_mac$OFFSET = 16;
/**
* Offset for field:
* {@snippet lang=c :
* unsigned short tp_mac
* }
*/
public static final long tp_mac$offset() {
return tp_mac$OFFSET;
}
/**
* Getter for field:
* {@snippet lang=c :
* unsigned short tp_mac
* }
*/
public static short tp_mac(MemorySegment struct) {
return struct.get(tp_mac$LAYOUT, tp_mac$OFFSET);
}
/**
* Setter for field:
* {@snippet lang=c :
* unsigned short tp_mac
* }
*/
public static void tp_mac(MemorySegment struct, short fieldValue) {
struct.set(tp_mac$LAYOUT, tp_mac$OFFSET, fieldValue);
}
private static final OfShort tp_net$LAYOUT = (OfShort)$LAYOUT.select(groupElement("tp_net"));
/**
* Layout for field:
* {@snippet lang=c :
* unsigned short tp_net
* }
*/
public static final OfShort tp_net$layout() {
return tp_net$LAYOUT;
}
private static final long tp_net$OFFSET = 18;
/**
* Offset for field:
* {@snippet lang=c :
* unsigned short tp_net
* }
*/
public static final long tp_net$offset() {
return tp_net$OFFSET;
}
/**
* Getter for field:
* {@snippet lang=c :
* unsigned short tp_net
* }
*/
public static short tp_net(MemorySegment struct) {
return struct.get(tp_net$LAYOUT, tp_net$OFFSET);
}
/**
* Setter for field:
* {@snippet lang=c :
* unsigned short tp_net
* }
*/
public static void tp_net(MemorySegment struct, short fieldValue) {
struct.set(tp_net$LAYOUT, tp_net$OFFSET, fieldValue);
}
private static final OfInt tp_sec$LAYOUT = (OfInt)$LAYOUT.select(groupElement("tp_sec"));
/**
* Layout for field:
* {@snippet lang=c :
* unsigned int tp_sec
* }
*/
public static final OfInt tp_sec$layout() {
return tp_sec$LAYOUT;
}
private static final long tp_sec$OFFSET = 20;
/**
* Offset for field:
* {@snippet lang=c :
* unsigned int tp_sec
* }
*/
public static final long tp_sec$offset() {
return tp_sec$OFFSET;
}
/**
* Getter for field:
* {@snippet lang=c :
* unsigned int tp_sec
* }
*/
public static int tp_sec(MemorySegment struct) {
return struct.get(tp_sec$LAYOUT, tp_sec$OFFSET);
}
/**
* Setter for field:
* {@snippet lang=c :
* unsigned int tp_sec
* }
*/
public static void tp_sec(MemorySegment struct, int fieldValue) {
struct.set(tp_sec$LAYOUT, tp_sec$OFFSET, fieldValue);
}
private static final OfInt tp_usec$LAYOUT = (OfInt)$LAYOUT.select(groupElement("tp_usec"));
/**
* Layout for field:
* {@snippet lang=c :
* unsigned int tp_usec
* }
*/
public static final OfInt tp_usec$layout() {
return tp_usec$LAYOUT;
}
private static final long tp_usec$OFFSET = 24;
/**
* Offset for field:
* {@snippet lang=c :
* unsigned int tp_usec
* }
*/
public static final long tp_usec$offset() {
return tp_usec$OFFSET;
}
/**
* Getter for field:
* {@snippet lang=c :
* unsigned int tp_usec
* }
*/
public static int tp_usec(MemorySegment struct) {
return struct.get(tp_usec$LAYOUT, tp_usec$OFFSET);
}
/**
* Setter for field:
* {@snippet lang=c :
* unsigned int tp_usec
* }
*/
public static void tp_usec(MemorySegment struct, int fieldValue) {
struct.set(tp_usec$LAYOUT, tp_usec$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);
}
}