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