me.bechberger.ebpf.bpf.raw.ethhdr 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 ethhdr {
* unsigned char h_dest[6];
* unsigned char h_source[6];
* __be16 h_proto;
* }
* }
*/
public class ethhdr {
ethhdr() {
// Should not be called directly
}
private static final GroupLayout $LAYOUT = MemoryLayout.structLayout(
MemoryLayout.sequenceLayout(6, Lib.C_CHAR).withName("h_dest"),
MemoryLayout.sequenceLayout(6, Lib.C_CHAR).withName("h_source"),
Lib.align(Lib.C_SHORT, 1).withName("h_proto")
).withName("ethhdr");
/**
* The layout of this struct
*/
public static final GroupLayout layout() {
return $LAYOUT;
}
private static final SequenceLayout h_dest$LAYOUT = (SequenceLayout)$LAYOUT.select(groupElement("h_dest"));
/**
* Layout for field:
* {@snippet lang=c :
* unsigned char h_dest[6]
* }
*/
public static final SequenceLayout h_dest$layout() {
return h_dest$LAYOUT;
}
private static final long h_dest$OFFSET = 0;
/**
* Offset for field:
* {@snippet lang=c :
* unsigned char h_dest[6]
* }
*/
public static final long h_dest$offset() {
return h_dest$OFFSET;
}
/**
* Getter for field:
* {@snippet lang=c :
* unsigned char h_dest[6]
* }
*/
public static MemorySegment h_dest(MemorySegment struct) {
return struct.asSlice(h_dest$OFFSET, h_dest$LAYOUT.byteSize());
}
/**
* Setter for field:
* {@snippet lang=c :
* unsigned char h_dest[6]
* }
*/
public static void h_dest(MemorySegment struct, MemorySegment fieldValue) {
MemorySegment.copy(fieldValue, 0L, struct, h_dest$OFFSET, h_dest$LAYOUT.byteSize());
}
private static long[] h_dest$DIMS = { 6 };
/**
* Dimensions for array field:
* {@snippet lang=c :
* unsigned char h_dest[6]
* }
*/
public static long[] h_dest$dimensions() {
return h_dest$DIMS;
}
private static final VarHandle h_dest$ELEM_HANDLE = h_dest$LAYOUT.varHandle(sequenceElement());
/**
* Indexed getter for field:
* {@snippet lang=c :
* unsigned char h_dest[6]
* }
*/
public static byte h_dest(MemorySegment struct, long index0) {
return (byte)h_dest$ELEM_HANDLE.get(struct, 0L, index0);
}
/**
* Indexed setter for field:
* {@snippet lang=c :
* unsigned char h_dest[6]
* }
*/
public static void h_dest(MemorySegment struct, long index0, byte fieldValue) {
h_dest$ELEM_HANDLE.set(struct, 0L, index0, fieldValue);
}
private static final SequenceLayout h_source$LAYOUT = (SequenceLayout)$LAYOUT.select(groupElement("h_source"));
/**
* Layout for field:
* {@snippet lang=c :
* unsigned char h_source[6]
* }
*/
public static final SequenceLayout h_source$layout() {
return h_source$LAYOUT;
}
private static final long h_source$OFFSET = 6;
/**
* Offset for field:
* {@snippet lang=c :
* unsigned char h_source[6]
* }
*/
public static final long h_source$offset() {
return h_source$OFFSET;
}
/**
* Getter for field:
* {@snippet lang=c :
* unsigned char h_source[6]
* }
*/
public static MemorySegment h_source(MemorySegment struct) {
return struct.asSlice(h_source$OFFSET, h_source$LAYOUT.byteSize());
}
/**
* Setter for field:
* {@snippet lang=c :
* unsigned char h_source[6]
* }
*/
public static void h_source(MemorySegment struct, MemorySegment fieldValue) {
MemorySegment.copy(fieldValue, 0L, struct, h_source$OFFSET, h_source$LAYOUT.byteSize());
}
private static long[] h_source$DIMS = { 6 };
/**
* Dimensions for array field:
* {@snippet lang=c :
* unsigned char h_source[6]
* }
*/
public static long[] h_source$dimensions() {
return h_source$DIMS;
}
private static final VarHandle h_source$ELEM_HANDLE = h_source$LAYOUT.varHandle(sequenceElement());
/**
* Indexed getter for field:
* {@snippet lang=c :
* unsigned char h_source[6]
* }
*/
public static byte h_source(MemorySegment struct, long index0) {
return (byte)h_source$ELEM_HANDLE.get(struct, 0L, index0);
}
/**
* Indexed setter for field:
* {@snippet lang=c :
* unsigned char h_source[6]
* }
*/
public static void h_source(MemorySegment struct, long index0, byte fieldValue) {
h_source$ELEM_HANDLE.set(struct, 0L, index0, fieldValue);
}
private static final OfShort h_proto$LAYOUT = (OfShort)$LAYOUT.select(groupElement("h_proto"));
/**
* Layout for field:
* {@snippet lang=c :
* __be16 h_proto
* }
*/
public static final OfShort h_proto$layout() {
return h_proto$LAYOUT;
}
private static final long h_proto$OFFSET = 12;
/**
* Offset for field:
* {@snippet lang=c :
* __be16 h_proto
* }
*/
public static final long h_proto$offset() {
return h_proto$OFFSET;
}
/**
* Getter for field:
* {@snippet lang=c :
* __be16 h_proto
* }
*/
public static short h_proto(MemorySegment struct) {
return struct.get(h_proto$LAYOUT, h_proto$OFFSET);
}
/**
* Setter for field:
* {@snippet lang=c :
* __be16 h_proto
* }
*/
public static void h_proto(MemorySegment struct, short fieldValue) {
struct.set(h_proto$LAYOUT, h_proto$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);
}
}