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