me.bechberger.ebpf.bpf.raw.bpf_sk_lookup 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_sk_lookup {
* union {
* union {
* struct bpf_sock *sk;
* __u64 : 64;
* };
* __u64 cookie;
* };
* __u32 family;
* __u32 protocol;
* __u32 remote_ip4;
* __u32 remote_ip6[4];
* __be16 remote_port;
* __u16 : 16;
* __u32 local_ip4;
* __u32 local_ip6[4];
* __u32 local_port;
* __u32 ingress_ifindex;
* }
* }
*/
public class bpf_sk_lookup {
bpf_sk_lookup() {
// Should not be called directly
}
private static final GroupLayout $LAYOUT = MemoryLayout.structLayout(
MemoryLayout.unionLayout(
MemoryLayout.unionLayout(
Lib.C_POINTER.withName("sk")
).withName("$anon$7368:3"),
Lib.C_LONG_LONG.withName("cookie")
).withName("$anon$7367:2"),
Lib.C_INT.withName("family"),
Lib.C_INT.withName("protocol"),
Lib.C_INT.withName("remote_ip4"),
MemoryLayout.sequenceLayout(4, Lib.C_INT).withName("remote_ip6"),
Lib.C_SHORT.withName("remote_port"),
MemoryLayout.paddingLayout(2),
Lib.C_INT.withName("local_ip4"),
MemoryLayout.sequenceLayout(4, Lib.C_INT).withName("local_ip6"),
Lib.C_INT.withName("local_port"),
Lib.C_INT.withName("ingress_ifindex"),
MemoryLayout.paddingLayout(4)
).withName("bpf_sk_lookup");
/**
* The layout of this struct
*/
public static final GroupLayout layout() {
return $LAYOUT;
}
private static final AddressLayout sk$LAYOUT = (AddressLayout)$LAYOUT.select(groupElement("$anon$7367:2"), groupElement("$anon$7368:3"), groupElement("sk"));
/**
* Layout for field:
* {@snippet lang=c :
* struct bpf_sock *sk
* }
*/
public static final AddressLayout sk$layout() {
return sk$LAYOUT;
}
private static final long sk$OFFSET = 0;
/**
* Offset for field:
* {@snippet lang=c :
* struct bpf_sock *sk
* }
*/
public static final long sk$offset() {
return sk$OFFSET;
}
/**
* Getter for field:
* {@snippet lang=c :
* struct bpf_sock *sk
* }
*/
public static MemorySegment sk(MemorySegment struct) {
return struct.get(sk$LAYOUT, sk$OFFSET);
}
/**
* Setter for field:
* {@snippet lang=c :
* struct bpf_sock *sk
* }
*/
public static void sk(MemorySegment struct, MemorySegment fieldValue) {
struct.set(sk$LAYOUT, sk$OFFSET, fieldValue);
}
private static final OfLong cookie$LAYOUT = (OfLong)$LAYOUT.select(groupElement("$anon$7367:2"), groupElement("cookie"));
/**
* Layout for field:
* {@snippet lang=c :
* __u64 cookie
* }
*/
public static final OfLong cookie$layout() {
return cookie$LAYOUT;
}
private static final long cookie$OFFSET = 0;
/**
* Offset for field:
* {@snippet lang=c :
* __u64 cookie
* }
*/
public static final long cookie$offset() {
return cookie$OFFSET;
}
/**
* Getter for field:
* {@snippet lang=c :
* __u64 cookie
* }
*/
public static long cookie(MemorySegment struct) {
return struct.get(cookie$LAYOUT, cookie$OFFSET);
}
/**
* Setter for field:
* {@snippet lang=c :
* __u64 cookie
* }
*/
public static void cookie(MemorySegment struct, long fieldValue) {
struct.set(cookie$LAYOUT, cookie$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 = 8;
/**
* 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 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 remote_ip4$LAYOUT = (OfInt)$LAYOUT.select(groupElement("remote_ip4"));
/**
* Layout for field:
* {@snippet lang=c :
* __u32 remote_ip4
* }
*/
public static final OfInt remote_ip4$layout() {
return remote_ip4$LAYOUT;
}
private static final long remote_ip4$OFFSET = 16;
/**
* Offset for field:
* {@snippet lang=c :
* __u32 remote_ip4
* }
*/
public static final long remote_ip4$offset() {
return remote_ip4$OFFSET;
}
/**
* Getter for field:
* {@snippet lang=c :
* __u32 remote_ip4
* }
*/
public static int remote_ip4(MemorySegment struct) {
return struct.get(remote_ip4$LAYOUT, remote_ip4$OFFSET);
}
/**
* Setter for field:
* {@snippet lang=c :
* __u32 remote_ip4
* }
*/
public static void remote_ip4(MemorySegment struct, int fieldValue) {
struct.set(remote_ip4$LAYOUT, remote_ip4$OFFSET, fieldValue);
}
private static final SequenceLayout remote_ip6$LAYOUT = (SequenceLayout)$LAYOUT.select(groupElement("remote_ip6"));
/**
* Layout for field:
* {@snippet lang=c :
* __u32 remote_ip6[4]
* }
*/
public static final SequenceLayout remote_ip6$layout() {
return remote_ip6$LAYOUT;
}
private static final long remote_ip6$OFFSET = 20;
/**
* Offset for field:
* {@snippet lang=c :
* __u32 remote_ip6[4]
* }
*/
public static final long remote_ip6$offset() {
return remote_ip6$OFFSET;
}
/**
* Getter for field:
* {@snippet lang=c :
* __u32 remote_ip6[4]
* }
*/
public static MemorySegment remote_ip6(MemorySegment struct) {
return struct.asSlice(remote_ip6$OFFSET, remote_ip6$LAYOUT.byteSize());
}
/**
* Setter for field:
* {@snippet lang=c :
* __u32 remote_ip6[4]
* }
*/
public static void remote_ip6(MemorySegment struct, MemorySegment fieldValue) {
MemorySegment.copy(fieldValue, 0L, struct, remote_ip6$OFFSET, remote_ip6$LAYOUT.byteSize());
}
private static long[] remote_ip6$DIMS = { 4 };
/**
* Dimensions for array field:
* {@snippet lang=c :
* __u32 remote_ip6[4]
* }
*/
public static long[] remote_ip6$dimensions() {
return remote_ip6$DIMS;
}
private static final VarHandle remote_ip6$ELEM_HANDLE = remote_ip6$LAYOUT.varHandle(sequenceElement());
/**
* Indexed getter for field:
* {@snippet lang=c :
* __u32 remote_ip6[4]
* }
*/
public static int remote_ip6(MemorySegment struct, long index0) {
return (int)remote_ip6$ELEM_HANDLE.get(struct, 0L, index0);
}
/**
* Indexed setter for field:
* {@snippet lang=c :
* __u32 remote_ip6[4]
* }
*/
public static void remote_ip6(MemorySegment struct, long index0, int fieldValue) {
remote_ip6$ELEM_HANDLE.set(struct, 0L, index0, fieldValue);
}
private static final OfShort remote_port$LAYOUT = (OfShort)$LAYOUT.select(groupElement("remote_port"));
/**
* Layout for field:
* {@snippet lang=c :
* __be16 remote_port
* }
*/
public static final OfShort remote_port$layout() {
return remote_port$LAYOUT;
}
private static final long remote_port$OFFSET = 36;
/**
* Offset for field:
* {@snippet lang=c :
* __be16 remote_port
* }
*/
public static final long remote_port$offset() {
return remote_port$OFFSET;
}
/**
* Getter for field:
* {@snippet lang=c :
* __be16 remote_port
* }
*/
public static short remote_port(MemorySegment struct) {
return struct.get(remote_port$LAYOUT, remote_port$OFFSET);
}
/**
* Setter for field:
* {@snippet lang=c :
* __be16 remote_port
* }
*/
public static void remote_port(MemorySegment struct, short fieldValue) {
struct.set(remote_port$LAYOUT, remote_port$OFFSET, fieldValue);
}
private static final OfInt local_ip4$LAYOUT = (OfInt)$LAYOUT.select(groupElement("local_ip4"));
/**
* Layout for field:
* {@snippet lang=c :
* __u32 local_ip4
* }
*/
public static final OfInt local_ip4$layout() {
return local_ip4$LAYOUT;
}
private static final long local_ip4$OFFSET = 40;
/**
* Offset for field:
* {@snippet lang=c :
* __u32 local_ip4
* }
*/
public static final long local_ip4$offset() {
return local_ip4$OFFSET;
}
/**
* Getter for field:
* {@snippet lang=c :
* __u32 local_ip4
* }
*/
public static int local_ip4(MemorySegment struct) {
return struct.get(local_ip4$LAYOUT, local_ip4$OFFSET);
}
/**
* Setter for field:
* {@snippet lang=c :
* __u32 local_ip4
* }
*/
public static void local_ip4(MemorySegment struct, int fieldValue) {
struct.set(local_ip4$LAYOUT, local_ip4$OFFSET, fieldValue);
}
private static final SequenceLayout local_ip6$LAYOUT = (SequenceLayout)$LAYOUT.select(groupElement("local_ip6"));
/**
* Layout for field:
* {@snippet lang=c :
* __u32 local_ip6[4]
* }
*/
public static final SequenceLayout local_ip6$layout() {
return local_ip6$LAYOUT;
}
private static final long local_ip6$OFFSET = 44;
/**
* Offset for field:
* {@snippet lang=c :
* __u32 local_ip6[4]
* }
*/
public static final long local_ip6$offset() {
return local_ip6$OFFSET;
}
/**
* Getter for field:
* {@snippet lang=c :
* __u32 local_ip6[4]
* }
*/
public static MemorySegment local_ip6(MemorySegment struct) {
return struct.asSlice(local_ip6$OFFSET, local_ip6$LAYOUT.byteSize());
}
/**
* Setter for field:
* {@snippet lang=c :
* __u32 local_ip6[4]
* }
*/
public static void local_ip6(MemorySegment struct, MemorySegment fieldValue) {
MemorySegment.copy(fieldValue, 0L, struct, local_ip6$OFFSET, local_ip6$LAYOUT.byteSize());
}
private static long[] local_ip6$DIMS = { 4 };
/**
* Dimensions for array field:
* {@snippet lang=c :
* __u32 local_ip6[4]
* }
*/
public static long[] local_ip6$dimensions() {
return local_ip6$DIMS;
}
private static final VarHandle local_ip6$ELEM_HANDLE = local_ip6$LAYOUT.varHandle(sequenceElement());
/**
* Indexed getter for field:
* {@snippet lang=c :
* __u32 local_ip6[4]
* }
*/
public static int local_ip6(MemorySegment struct, long index0) {
return (int)local_ip6$ELEM_HANDLE.get(struct, 0L, index0);
}
/**
* Indexed setter for field:
* {@snippet lang=c :
* __u32 local_ip6[4]
* }
*/
public static void local_ip6(MemorySegment struct, long index0, int fieldValue) {
local_ip6$ELEM_HANDLE.set(struct, 0L, index0, fieldValue);
}
private static final OfInt local_port$LAYOUT = (OfInt)$LAYOUT.select(groupElement("local_port"));
/**
* Layout for field:
* {@snippet lang=c :
* __u32 local_port
* }
*/
public static final OfInt local_port$layout() {
return local_port$LAYOUT;
}
private static final long local_port$OFFSET = 60;
/**
* Offset for field:
* {@snippet lang=c :
* __u32 local_port
* }
*/
public static final long local_port$offset() {
return local_port$OFFSET;
}
/**
* Getter for field:
* {@snippet lang=c :
* __u32 local_port
* }
*/
public static int local_port(MemorySegment struct) {
return struct.get(local_port$LAYOUT, local_port$OFFSET);
}
/**
* Setter for field:
* {@snippet lang=c :
* __u32 local_port
* }
*/
public static void local_port(MemorySegment struct, int fieldValue) {
struct.set(local_port$LAYOUT, local_port$OFFSET, fieldValue);
}
private static final OfInt ingress_ifindex$LAYOUT = (OfInt)$LAYOUT.select(groupElement("ingress_ifindex"));
/**
* Layout for field:
* {@snippet lang=c :
* __u32 ingress_ifindex
* }
*/
public static final OfInt ingress_ifindex$layout() {
return ingress_ifindex$LAYOUT;
}
private static final long ingress_ifindex$OFFSET = 64;
/**
* Offset for field:
* {@snippet lang=c :
* __u32 ingress_ifindex
* }
*/
public static final long ingress_ifindex$offset() {
return ingress_ifindex$OFFSET;
}
/**
* Getter for field:
* {@snippet lang=c :
* __u32 ingress_ifindex
* }
*/
public static int ingress_ifindex(MemorySegment struct) {
return struct.get(ingress_ifindex$LAYOUT, ingress_ifindex$OFFSET);
}
/**
* Setter for field:
* {@snippet lang=c :
* __u32 ingress_ifindex
* }
*/
public static void ingress_ifindex(MemorySegment struct, int fieldValue) {
struct.set(ingress_ifindex$LAYOUT, ingress_ifindex$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);
}
}