me.bechberger.ebpf.bpf.raw.bpf_sock 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_sock {
* __u32 bound_dev_if;
* __u32 family;
* __u32 type;
* __u32 protocol;
* __u32 mark;
* __u32 priority;
* __u32 src_ip4;
* __u32 src_ip6[4];
* __u32 src_port;
* __be16 dst_port;
* __u16 : 16;
* __u32 dst_ip4;
* __u32 dst_ip6[4];
* __u32 state;
* __s32 rx_queue_mapping;
* }
* }
*/
public class bpf_sock {
bpf_sock() {
// Should not be called directly
}
private static final GroupLayout $LAYOUT = MemoryLayout.structLayout(
Lib.C_INT.withName("bound_dev_if"),
Lib.C_INT.withName("family"),
Lib.C_INT.withName("type"),
Lib.C_INT.withName("protocol"),
Lib.C_INT.withName("mark"),
Lib.C_INT.withName("priority"),
Lib.C_INT.withName("src_ip4"),
MemoryLayout.sequenceLayout(4, Lib.C_INT).withName("src_ip6"),
Lib.C_INT.withName("src_port"),
Lib.C_SHORT.withName("dst_port"),
MemoryLayout.paddingLayout(2),
Lib.C_INT.withName("dst_ip4"),
MemoryLayout.sequenceLayout(4, Lib.C_INT).withName("dst_ip6"),
Lib.C_INT.withName("state"),
Lib.C_INT.withName("rx_queue_mapping")
).withName("bpf_sock");
/**
* The layout of this struct
*/
public static final GroupLayout layout() {
return $LAYOUT;
}
private static final OfInt bound_dev_if$LAYOUT = (OfInt)$LAYOUT.select(groupElement("bound_dev_if"));
/**
* Layout for field:
* {@snippet lang=c :
* __u32 bound_dev_if
* }
*/
public static final OfInt bound_dev_if$layout() {
return bound_dev_if$LAYOUT;
}
private static final long bound_dev_if$OFFSET = 0;
/**
* Offset for field:
* {@snippet lang=c :
* __u32 bound_dev_if
* }
*/
public static final long bound_dev_if$offset() {
return bound_dev_if$OFFSET;
}
/**
* Getter for field:
* {@snippet lang=c :
* __u32 bound_dev_if
* }
*/
public static int bound_dev_if(MemorySegment struct) {
return struct.get(bound_dev_if$LAYOUT, bound_dev_if$OFFSET);
}
/**
* Setter for field:
* {@snippet lang=c :
* __u32 bound_dev_if
* }
*/
public static void bound_dev_if(MemorySegment struct, int fieldValue) {
struct.set(bound_dev_if$LAYOUT, bound_dev_if$OFFSET, fieldValue);
}
private static final OfInt family$LAYOUT = (OfInt)$LAYOUT.select(groupElement("family"));
/**
* Layout for field:
* {@snippet lang=c :
* __u32 family
* }
*/
public static final OfInt family$layout() {
return family$LAYOUT;
}
private static final long family$OFFSET = 4;
/**
* Offset for field:
* {@snippet lang=c :
* __u32 family
* }
*/
public static final long family$offset() {
return family$OFFSET;
}
/**
* Getter for field:
* {@snippet lang=c :
* __u32 family
* }
*/
public static int family(MemorySegment struct) {
return struct.get(family$LAYOUT, family$OFFSET);
}
/**
* Setter for field:
* {@snippet lang=c :
* __u32 family
* }
*/
public static void family(MemorySegment struct, int fieldValue) {
struct.set(family$LAYOUT, family$OFFSET, fieldValue);
}
private static final OfInt type$LAYOUT = (OfInt)$LAYOUT.select(groupElement("type"));
/**
* Layout for field:
* {@snippet lang=c :
* __u32 type
* }
*/
public static final OfInt type$layout() {
return type$LAYOUT;
}
private static final long type$OFFSET = 8;
/**
* Offset for field:
* {@snippet lang=c :
* __u32 type
* }
*/
public static final long type$offset() {
return type$OFFSET;
}
/**
* Getter for field:
* {@snippet lang=c :
* __u32 type
* }
*/
public static int type(MemorySegment struct) {
return struct.get(type$LAYOUT, type$OFFSET);
}
/**
* Setter for field:
* {@snippet lang=c :
* __u32 type
* }
*/
public static void type(MemorySegment struct, int fieldValue) {
struct.set(type$LAYOUT, type$OFFSET, fieldValue);
}
private static final OfInt protocol$LAYOUT = (OfInt)$LAYOUT.select(groupElement("protocol"));
/**
* Layout for field:
* {@snippet lang=c :
* __u32 protocol
* }
*/
public static final OfInt protocol$layout() {
return protocol$LAYOUT;
}
private static final long protocol$OFFSET = 12;
/**
* Offset for field:
* {@snippet lang=c :
* __u32 protocol
* }
*/
public static final long protocol$offset() {
return protocol$OFFSET;
}
/**
* Getter for field:
* {@snippet lang=c :
* __u32 protocol
* }
*/
public static int protocol(MemorySegment struct) {
return struct.get(protocol$LAYOUT, protocol$OFFSET);
}
/**
* Setter for field:
* {@snippet lang=c :
* __u32 protocol
* }
*/
public static void protocol(MemorySegment struct, int fieldValue) {
struct.set(protocol$LAYOUT, protocol$OFFSET, fieldValue);
}
private static final OfInt mark$LAYOUT = (OfInt)$LAYOUT.select(groupElement("mark"));
/**
* Layout for field:
* {@snippet lang=c :
* __u32 mark
* }
*/
public static final OfInt mark$layout() {
return mark$LAYOUT;
}
private static final long mark$OFFSET = 16;
/**
* Offset for field:
* {@snippet lang=c :
* __u32 mark
* }
*/
public static final long mark$offset() {
return mark$OFFSET;
}
/**
* Getter for field:
* {@snippet lang=c :
* __u32 mark
* }
*/
public static int mark(MemorySegment struct) {
return struct.get(mark$LAYOUT, mark$OFFSET);
}
/**
* Setter for field:
* {@snippet lang=c :
* __u32 mark
* }
*/
public static void mark(MemorySegment struct, int fieldValue) {
struct.set(mark$LAYOUT, mark$OFFSET, fieldValue);
}
private static final OfInt priority$LAYOUT = (OfInt)$LAYOUT.select(groupElement("priority"));
/**
* Layout for field:
* {@snippet lang=c :
* __u32 priority
* }
*/
public static final OfInt priority$layout() {
return priority$LAYOUT;
}
private static final long priority$OFFSET = 20;
/**
* Offset for field:
* {@snippet lang=c :
* __u32 priority
* }
*/
public static final long priority$offset() {
return priority$OFFSET;
}
/**
* Getter for field:
* {@snippet lang=c :
* __u32 priority
* }
*/
public static int priority(MemorySegment struct) {
return struct.get(priority$LAYOUT, priority$OFFSET);
}
/**
* Setter for field:
* {@snippet lang=c :
* __u32 priority
* }
*/
public static void priority(MemorySegment struct, int fieldValue) {
struct.set(priority$LAYOUT, priority$OFFSET, fieldValue);
}
private static final OfInt src_ip4$LAYOUT = (OfInt)$LAYOUT.select(groupElement("src_ip4"));
/**
* Layout for field:
* {@snippet lang=c :
* __u32 src_ip4
* }
*/
public static final OfInt src_ip4$layout() {
return src_ip4$LAYOUT;
}
private static final long src_ip4$OFFSET = 24;
/**
* Offset for field:
* {@snippet lang=c :
* __u32 src_ip4
* }
*/
public static final long src_ip4$offset() {
return src_ip4$OFFSET;
}
/**
* Getter for field:
* {@snippet lang=c :
* __u32 src_ip4
* }
*/
public static int src_ip4(MemorySegment struct) {
return struct.get(src_ip4$LAYOUT, src_ip4$OFFSET);
}
/**
* Setter for field:
* {@snippet lang=c :
* __u32 src_ip4
* }
*/
public static void src_ip4(MemorySegment struct, int fieldValue) {
struct.set(src_ip4$LAYOUT, src_ip4$OFFSET, fieldValue);
}
private static final SequenceLayout src_ip6$LAYOUT = (SequenceLayout)$LAYOUT.select(groupElement("src_ip6"));
/**
* Layout for field:
* {@snippet lang=c :
* __u32 src_ip6[4]
* }
*/
public static final SequenceLayout src_ip6$layout() {
return src_ip6$LAYOUT;
}
private static final long src_ip6$OFFSET = 28;
/**
* Offset for field:
* {@snippet lang=c :
* __u32 src_ip6[4]
* }
*/
public static final long src_ip6$offset() {
return src_ip6$OFFSET;
}
/**
* Getter for field:
* {@snippet lang=c :
* __u32 src_ip6[4]
* }
*/
public static MemorySegment src_ip6(MemorySegment struct) {
return struct.asSlice(src_ip6$OFFSET, src_ip6$LAYOUT.byteSize());
}
/**
* Setter for field:
* {@snippet lang=c :
* __u32 src_ip6[4]
* }
*/
public static void src_ip6(MemorySegment struct, MemorySegment fieldValue) {
MemorySegment.copy(fieldValue, 0L, struct, src_ip6$OFFSET, src_ip6$LAYOUT.byteSize());
}
private static long[] src_ip6$DIMS = { 4 };
/**
* Dimensions for array field:
* {@snippet lang=c :
* __u32 src_ip6[4]
* }
*/
public static long[] src_ip6$dimensions() {
return src_ip6$DIMS;
}
private static final VarHandle src_ip6$ELEM_HANDLE = src_ip6$LAYOUT.varHandle(sequenceElement());
/**
* Indexed getter for field:
* {@snippet lang=c :
* __u32 src_ip6[4]
* }
*/
public static int src_ip6(MemorySegment struct, long index0) {
return (int)src_ip6$ELEM_HANDLE.get(struct, 0L, index0);
}
/**
* Indexed setter for field:
* {@snippet lang=c :
* __u32 src_ip6[4]
* }
*/
public static void src_ip6(MemorySegment struct, long index0, int fieldValue) {
src_ip6$ELEM_HANDLE.set(struct, 0L, index0, fieldValue);
}
private static final OfInt src_port$LAYOUT = (OfInt)$LAYOUT.select(groupElement("src_port"));
/**
* Layout for field:
* {@snippet lang=c :
* __u32 src_port
* }
*/
public static final OfInt src_port$layout() {
return src_port$LAYOUT;
}
private static final long src_port$OFFSET = 44;
/**
* Offset for field:
* {@snippet lang=c :
* __u32 src_port
* }
*/
public static final long src_port$offset() {
return src_port$OFFSET;
}
/**
* Getter for field:
* {@snippet lang=c :
* __u32 src_port
* }
*/
public static int src_port(MemorySegment struct) {
return struct.get(src_port$LAYOUT, src_port$OFFSET);
}
/**
* Setter for field:
* {@snippet lang=c :
* __u32 src_port
* }
*/
public static void src_port(MemorySegment struct, int fieldValue) {
struct.set(src_port$LAYOUT, src_port$OFFSET, fieldValue);
}
private static final OfShort dst_port$LAYOUT = (OfShort)$LAYOUT.select(groupElement("dst_port"));
/**
* Layout for field:
* {@snippet lang=c :
* __be16 dst_port
* }
*/
public static final OfShort dst_port$layout() {
return dst_port$LAYOUT;
}
private static final long dst_port$OFFSET = 48;
/**
* Offset for field:
* {@snippet lang=c :
* __be16 dst_port
* }
*/
public static final long dst_port$offset() {
return dst_port$OFFSET;
}
/**
* Getter for field:
* {@snippet lang=c :
* __be16 dst_port
* }
*/
public static short dst_port(MemorySegment struct) {
return struct.get(dst_port$LAYOUT, dst_port$OFFSET);
}
/**
* Setter for field:
* {@snippet lang=c :
* __be16 dst_port
* }
*/
public static void dst_port(MemorySegment struct, short fieldValue) {
struct.set(dst_port$LAYOUT, dst_port$OFFSET, fieldValue);
}
private static final OfInt dst_ip4$LAYOUT = (OfInt)$LAYOUT.select(groupElement("dst_ip4"));
/**
* Layout for field:
* {@snippet lang=c :
* __u32 dst_ip4
* }
*/
public static final OfInt dst_ip4$layout() {
return dst_ip4$LAYOUT;
}
private static final long dst_ip4$OFFSET = 52;
/**
* Offset for field:
* {@snippet lang=c :
* __u32 dst_ip4
* }
*/
public static final long dst_ip4$offset() {
return dst_ip4$OFFSET;
}
/**
* Getter for field:
* {@snippet lang=c :
* __u32 dst_ip4
* }
*/
public static int dst_ip4(MemorySegment struct) {
return struct.get(dst_ip4$LAYOUT, dst_ip4$OFFSET);
}
/**
* Setter for field:
* {@snippet lang=c :
* __u32 dst_ip4
* }
*/
public static void dst_ip4(MemorySegment struct, int fieldValue) {
struct.set(dst_ip4$LAYOUT, dst_ip4$OFFSET, fieldValue);
}
private static final SequenceLayout dst_ip6$LAYOUT = (SequenceLayout)$LAYOUT.select(groupElement("dst_ip6"));
/**
* Layout for field:
* {@snippet lang=c :
* __u32 dst_ip6[4]
* }
*/
public static final SequenceLayout dst_ip6$layout() {
return dst_ip6$LAYOUT;
}
private static final long dst_ip6$OFFSET = 56;
/**
* Offset for field:
* {@snippet lang=c :
* __u32 dst_ip6[4]
* }
*/
public static final long dst_ip6$offset() {
return dst_ip6$OFFSET;
}
/**
* Getter for field:
* {@snippet lang=c :
* __u32 dst_ip6[4]
* }
*/
public static MemorySegment dst_ip6(MemorySegment struct) {
return struct.asSlice(dst_ip6$OFFSET, dst_ip6$LAYOUT.byteSize());
}
/**
* Setter for field:
* {@snippet lang=c :
* __u32 dst_ip6[4]
* }
*/
public static void dst_ip6(MemorySegment struct, MemorySegment fieldValue) {
MemorySegment.copy(fieldValue, 0L, struct, dst_ip6$OFFSET, dst_ip6$LAYOUT.byteSize());
}
private static long[] dst_ip6$DIMS = { 4 };
/**
* Dimensions for array field:
* {@snippet lang=c :
* __u32 dst_ip6[4]
* }
*/
public static long[] dst_ip6$dimensions() {
return dst_ip6$DIMS;
}
private static final VarHandle dst_ip6$ELEM_HANDLE = dst_ip6$LAYOUT.varHandle(sequenceElement());
/**
* Indexed getter for field:
* {@snippet lang=c :
* __u32 dst_ip6[4]
* }
*/
public static int dst_ip6(MemorySegment struct, long index0) {
return (int)dst_ip6$ELEM_HANDLE.get(struct, 0L, index0);
}
/**
* Indexed setter for field:
* {@snippet lang=c :
* __u32 dst_ip6[4]
* }
*/
public static void dst_ip6(MemorySegment struct, long index0, int fieldValue) {
dst_ip6$ELEM_HANDLE.set(struct, 0L, index0, fieldValue);
}
private static final OfInt state$LAYOUT = (OfInt)$LAYOUT.select(groupElement("state"));
/**
* Layout for field:
* {@snippet lang=c :
* __u32 state
* }
*/
public static final OfInt state$layout() {
return state$LAYOUT;
}
private static final long state$OFFSET = 72;
/**
* Offset for field:
* {@snippet lang=c :
* __u32 state
* }
*/
public static final long state$offset() {
return state$OFFSET;
}
/**
* Getter for field:
* {@snippet lang=c :
* __u32 state
* }
*/
public static int state(MemorySegment struct) {
return struct.get(state$LAYOUT, state$OFFSET);
}
/**
* Setter for field:
* {@snippet lang=c :
* __u32 state
* }
*/
public static void state(MemorySegment struct, int fieldValue) {
struct.set(state$LAYOUT, state$OFFSET, fieldValue);
}
private static final OfInt rx_queue_mapping$LAYOUT = (OfInt)$LAYOUT.select(groupElement("rx_queue_mapping"));
/**
* Layout for field:
* {@snippet lang=c :
* __s32 rx_queue_mapping
* }
*/
public static final OfInt rx_queue_mapping$layout() {
return rx_queue_mapping$LAYOUT;
}
private static final long rx_queue_mapping$OFFSET = 76;
/**
* Offset for field:
* {@snippet lang=c :
* __s32 rx_queue_mapping
* }
*/
public static final long rx_queue_mapping$offset() {
return rx_queue_mapping$OFFSET;
}
/**
* Getter for field:
* {@snippet lang=c :
* __s32 rx_queue_mapping
* }
*/
public static int rx_queue_mapping(MemorySegment struct) {
return struct.get(rx_queue_mapping$LAYOUT, rx_queue_mapping$OFFSET);
}
/**
* Setter for field:
* {@snippet lang=c :
* __s32 rx_queue_mapping
* }
*/
public static void rx_queue_mapping(MemorySegment struct, int fieldValue) {
struct.set(rx_queue_mapping$LAYOUT, rx_queue_mapping$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);
}
}