All Downloads are FREE. Search and download functionalities are using the official Maven repository.

me.bechberger.ebpf.bpf.raw.icmp6hdr Maven / Gradle / Ivy

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 icmp6hdr {
 *     __u8 icmp6_type;
 *     __u8 icmp6_code;
 *     __sum16 icmp6_cksum;
 *     union {
 *         __be32 un_data32[1];
 *         __be16 un_data16[2];
 *         __u8 un_data8[4];
 *         struct icmpv6_echo {
 *             __be16 identifier;
 *             __be16 sequence;
 *         } u_echo;
 *         struct icmpv6_nd_advt {
 *             __u32 reserved : 5;
 *             __u32 override : 1;
 *             __u32 solicited : 1;
 *             __u32 router : 1;
 *             __u32 reserved2 : 24;
 *         } u_nd_advt;
 *         struct icmpv6_nd_ra {
 *             __u8 hop_limit;
 *             __u8 reserved : 3;
 *             __u8 router_pref : 2;
 *             __u8 home_agent : 1;
 *             __u8 other : 1;
 *             __u8 managed : 1;
 *             __be16 rt_lifetime;
 *         } u_nd_ra;
 *     } icmp6_dataun;
 * }
 * }
 */
public class icmp6hdr {

    icmp6hdr() {
        // Should not be called directly
    }

    private static final GroupLayout $LAYOUT = MemoryLayout.structLayout(
        Lib.C_CHAR.withName("icmp6_type"),
        Lib.C_CHAR.withName("icmp6_code"),
        Lib.C_SHORT.withName("icmp6_cksum"),
        icmp6hdr.icmp6_dataun.layout().withName("icmp6_dataun")
    ).withName("icmp6hdr");

    /**
     * The layout of this struct
     */
    public static final GroupLayout layout() {
        return $LAYOUT;
    }

    private static final OfByte icmp6_type$LAYOUT = (OfByte)$LAYOUT.select(groupElement("icmp6_type"));

    /**
     * Layout for field:
     * {@snippet lang=c :
     * __u8 icmp6_type
     * }
     */
    public static final OfByte icmp6_type$layout() {
        return icmp6_type$LAYOUT;
    }

    private static final long icmp6_type$OFFSET = 0;

    /**
     * Offset for field:
     * {@snippet lang=c :
     * __u8 icmp6_type
     * }
     */
    public static final long icmp6_type$offset() {
        return icmp6_type$OFFSET;
    }

    /**
     * Getter for field:
     * {@snippet lang=c :
     * __u8 icmp6_type
     * }
     */
    public static byte icmp6_type(MemorySegment struct) {
        return struct.get(icmp6_type$LAYOUT, icmp6_type$OFFSET);
    }

    /**
     * Setter for field:
     * {@snippet lang=c :
     * __u8 icmp6_type
     * }
     */
    public static void icmp6_type(MemorySegment struct, byte fieldValue) {
        struct.set(icmp6_type$LAYOUT, icmp6_type$OFFSET, fieldValue);
    }

    private static final OfByte icmp6_code$LAYOUT = (OfByte)$LAYOUT.select(groupElement("icmp6_code"));

    /**
     * Layout for field:
     * {@snippet lang=c :
     * __u8 icmp6_code
     * }
     */
    public static final OfByte icmp6_code$layout() {
        return icmp6_code$LAYOUT;
    }

    private static final long icmp6_code$OFFSET = 1;

    /**
     * Offset for field:
     * {@snippet lang=c :
     * __u8 icmp6_code
     * }
     */
    public static final long icmp6_code$offset() {
        return icmp6_code$OFFSET;
    }

    /**
     * Getter for field:
     * {@snippet lang=c :
     * __u8 icmp6_code
     * }
     */
    public static byte icmp6_code(MemorySegment struct) {
        return struct.get(icmp6_code$LAYOUT, icmp6_code$OFFSET);
    }

    /**
     * Setter for field:
     * {@snippet lang=c :
     * __u8 icmp6_code
     * }
     */
    public static void icmp6_code(MemorySegment struct, byte fieldValue) {
        struct.set(icmp6_code$LAYOUT, icmp6_code$OFFSET, fieldValue);
    }

    private static final OfShort icmp6_cksum$LAYOUT = (OfShort)$LAYOUT.select(groupElement("icmp6_cksum"));

    /**
     * Layout for field:
     * {@snippet lang=c :
     * __sum16 icmp6_cksum
     * }
     */
    public static final OfShort icmp6_cksum$layout() {
        return icmp6_cksum$LAYOUT;
    }

    private static final long icmp6_cksum$OFFSET = 2;

    /**
     * Offset for field:
     * {@snippet lang=c :
     * __sum16 icmp6_cksum
     * }
     */
    public static final long icmp6_cksum$offset() {
        return icmp6_cksum$OFFSET;
    }

    /**
     * Getter for field:
     * {@snippet lang=c :
     * __sum16 icmp6_cksum
     * }
     */
    public static short icmp6_cksum(MemorySegment struct) {
        return struct.get(icmp6_cksum$LAYOUT, icmp6_cksum$OFFSET);
    }

    /**
     * Setter for field:
     * {@snippet lang=c :
     * __sum16 icmp6_cksum
     * }
     */
    public static void icmp6_cksum(MemorySegment struct, short fieldValue) {
        struct.set(icmp6_cksum$LAYOUT, icmp6_cksum$OFFSET, fieldValue);
    }

    /**
     * {@snippet lang=c :
     * union {
     *     __be32 un_data32[1];
     *     __be16 un_data16[2];
     *     __u8 un_data8[4];
     *     struct icmpv6_echo {
     *         __be16 identifier;
     *         __be16 sequence;
     *     } u_echo;
     *     struct icmpv6_nd_advt {
     *         __u32 reserved : 5;
     *         __u32 override : 1;
     *         __u32 solicited : 1;
     *         __u32 router : 1;
     *         __u32 reserved2 : 24;
     *     } u_nd_advt;
     *     struct icmpv6_nd_ra {
     *         __u8 hop_limit;
     *         __u8 reserved : 3;
     *         __u8 router_pref : 2;
     *         __u8 home_agent : 1;
     *         __u8 other : 1;
     *         __u8 managed : 1;
     *         __be16 rt_lifetime;
     *     } u_nd_ra;
     * }
     * }
     */
    public static class icmp6_dataun {

        icmp6_dataun() {
            // Should not be called directly
        }

        private static final GroupLayout $LAYOUT = MemoryLayout.unionLayout(
            MemoryLayout.sequenceLayout(1, Lib.C_INT).withName("un_data32"),
            MemoryLayout.sequenceLayout(2, Lib.C_SHORT).withName("un_data16"),
            MemoryLayout.sequenceLayout(4, Lib.C_CHAR).withName("un_data8"),
            icmp6hdr.icmp6_dataun.icmpv6_echo.layout().withName("u_echo"),
            icmp6hdr.icmp6_dataun.icmpv6_nd_advt.layout().withName("u_nd_advt"),
            icmp6hdr.icmp6_dataun.icmpv6_nd_ra.layout().withName("u_nd_ra")
        ).withName("$anon$15:2");

        /**
         * The layout of this union
         */
        public static final GroupLayout layout() {
            return $LAYOUT;
        }

        private static final SequenceLayout un_data32$LAYOUT = (SequenceLayout)$LAYOUT.select(groupElement("un_data32"));

        /**
         * Layout for field:
         * {@snippet lang=c :
         * __be32 un_data32[1]
         * }
         */
        public static final SequenceLayout un_data32$layout() {
            return un_data32$LAYOUT;
        }

        private static final long un_data32$OFFSET = 0;

        /**
         * Offset for field:
         * {@snippet lang=c :
         * __be32 un_data32[1]
         * }
         */
        public static final long un_data32$offset() {
            return un_data32$OFFSET;
        }

        /**
         * Getter for field:
         * {@snippet lang=c :
         * __be32 un_data32[1]
         * }
         */
        public static MemorySegment un_data32(MemorySegment union) {
            return union.asSlice(un_data32$OFFSET, un_data32$LAYOUT.byteSize());
        }

        /**
         * Setter for field:
         * {@snippet lang=c :
         * __be32 un_data32[1]
         * }
         */
        public static void un_data32(MemorySegment union, MemorySegment fieldValue) {
            MemorySegment.copy(fieldValue, 0L, union, un_data32$OFFSET, un_data32$LAYOUT.byteSize());
        }

        private static long[] un_data32$DIMS = { 1 };

        /**
         * Dimensions for array field:
         * {@snippet lang=c :
         * __be32 un_data32[1]
         * }
         */
        public static long[] un_data32$dimensions() {
            return un_data32$DIMS;
        }
        private static final VarHandle un_data32$ELEM_HANDLE = un_data32$LAYOUT.varHandle(sequenceElement());

        /**
         * Indexed getter for field:
         * {@snippet lang=c :
         * __be32 un_data32[1]
         * }
         */
        public static int un_data32(MemorySegment union, long index0) {
            return (int)un_data32$ELEM_HANDLE.get(union, 0L, index0);
        }

        /**
         * Indexed setter for field:
         * {@snippet lang=c :
         * __be32 un_data32[1]
         * }
         */
        public static void un_data32(MemorySegment union, long index0, int fieldValue) {
            un_data32$ELEM_HANDLE.set(union, 0L, index0, fieldValue);
        }

        private static final SequenceLayout un_data16$LAYOUT = (SequenceLayout)$LAYOUT.select(groupElement("un_data16"));

        /**
         * Layout for field:
         * {@snippet lang=c :
         * __be16 un_data16[2]
         * }
         */
        public static final SequenceLayout un_data16$layout() {
            return un_data16$LAYOUT;
        }

        private static final long un_data16$OFFSET = 0;

        /**
         * Offset for field:
         * {@snippet lang=c :
         * __be16 un_data16[2]
         * }
         */
        public static final long un_data16$offset() {
            return un_data16$OFFSET;
        }

        /**
         * Getter for field:
         * {@snippet lang=c :
         * __be16 un_data16[2]
         * }
         */
        public static MemorySegment un_data16(MemorySegment union) {
            return union.asSlice(un_data16$OFFSET, un_data16$LAYOUT.byteSize());
        }

        /**
         * Setter for field:
         * {@snippet lang=c :
         * __be16 un_data16[2]
         * }
         */
        public static void un_data16(MemorySegment union, MemorySegment fieldValue) {
            MemorySegment.copy(fieldValue, 0L, union, un_data16$OFFSET, un_data16$LAYOUT.byteSize());
        }

        private static long[] un_data16$DIMS = { 2 };

        /**
         * Dimensions for array field:
         * {@snippet lang=c :
         * __be16 un_data16[2]
         * }
         */
        public static long[] un_data16$dimensions() {
            return un_data16$DIMS;
        }
        private static final VarHandle un_data16$ELEM_HANDLE = un_data16$LAYOUT.varHandle(sequenceElement());

        /**
         * Indexed getter for field:
         * {@snippet lang=c :
         * __be16 un_data16[2]
         * }
         */
        public static short un_data16(MemorySegment union, long index0) {
            return (short)un_data16$ELEM_HANDLE.get(union, 0L, index0);
        }

        /**
         * Indexed setter for field:
         * {@snippet lang=c :
         * __be16 un_data16[2]
         * }
         */
        public static void un_data16(MemorySegment union, long index0, short fieldValue) {
            un_data16$ELEM_HANDLE.set(union, 0L, index0, fieldValue);
        }

        private static final SequenceLayout un_data8$LAYOUT = (SequenceLayout)$LAYOUT.select(groupElement("un_data8"));

        /**
         * Layout for field:
         * {@snippet lang=c :
         * __u8 un_data8[4]
         * }
         */
        public static final SequenceLayout un_data8$layout() {
            return un_data8$LAYOUT;
        }

        private static final long un_data8$OFFSET = 0;

        /**
         * Offset for field:
         * {@snippet lang=c :
         * __u8 un_data8[4]
         * }
         */
        public static final long un_data8$offset() {
            return un_data8$OFFSET;
        }

        /**
         * Getter for field:
         * {@snippet lang=c :
         * __u8 un_data8[4]
         * }
         */
        public static MemorySegment un_data8(MemorySegment union) {
            return union.asSlice(un_data8$OFFSET, un_data8$LAYOUT.byteSize());
        }

        /**
         * Setter for field:
         * {@snippet lang=c :
         * __u8 un_data8[4]
         * }
         */
        public static void un_data8(MemorySegment union, MemorySegment fieldValue) {
            MemorySegment.copy(fieldValue, 0L, union, un_data8$OFFSET, un_data8$LAYOUT.byteSize());
        }

        private static long[] un_data8$DIMS = { 4 };

        /**
         * Dimensions for array field:
         * {@snippet lang=c :
         * __u8 un_data8[4]
         * }
         */
        public static long[] un_data8$dimensions() {
            return un_data8$DIMS;
        }
        private static final VarHandle un_data8$ELEM_HANDLE = un_data8$LAYOUT.varHandle(sequenceElement());

        /**
         * Indexed getter for field:
         * {@snippet lang=c :
         * __u8 un_data8[4]
         * }
         */
        public static byte un_data8(MemorySegment union, long index0) {
            return (byte)un_data8$ELEM_HANDLE.get(union, 0L, index0);
        }

        /**
         * Indexed setter for field:
         * {@snippet lang=c :
         * __u8 un_data8[4]
         * }
         */
        public static void un_data8(MemorySegment union, long index0, byte fieldValue) {
            un_data8$ELEM_HANDLE.set(union, 0L, index0, fieldValue);
        }

        /**
         * {@snippet lang=c :
         * struct icmpv6_echo {
         *     __be16 identifier;
         *     __be16 sequence;
         * }
         * }
         */
        public static class icmpv6_echo {

            icmpv6_echo() {
                // Should not be called directly
            }

            private static final GroupLayout $LAYOUT = MemoryLayout.structLayout(
                Lib.C_SHORT.withName("identifier"),
                Lib.C_SHORT.withName("sequence")
            ).withName("icmpv6_echo");

            /**
             * The layout of this struct
             */
            public static final GroupLayout layout() {
                return $LAYOUT;
            }

            private static final OfShort identifier$LAYOUT = (OfShort)$LAYOUT.select(groupElement("identifier"));

            /**
             * Layout for field:
             * {@snippet lang=c :
             * __be16 identifier
             * }
             */
            public static final OfShort identifier$layout() {
                return identifier$LAYOUT;
            }

            private static final long identifier$OFFSET = 0;

            /**
             * Offset for field:
             * {@snippet lang=c :
             * __be16 identifier
             * }
             */
            public static final long identifier$offset() {
                return identifier$OFFSET;
            }

            /**
             * Getter for field:
             * {@snippet lang=c :
             * __be16 identifier
             * }
             */
            public static short identifier(MemorySegment struct) {
                return struct.get(identifier$LAYOUT, identifier$OFFSET);
            }

            /**
             * Setter for field:
             * {@snippet lang=c :
             * __be16 identifier
             * }
             */
            public static void identifier(MemorySegment struct, short fieldValue) {
                struct.set(identifier$LAYOUT, identifier$OFFSET, fieldValue);
            }

            private static final OfShort sequence$LAYOUT = (OfShort)$LAYOUT.select(groupElement("sequence"));

            /**
             * Layout for field:
             * {@snippet lang=c :
             * __be16 sequence
             * }
             */
            public static final OfShort sequence$layout() {
                return sequence$LAYOUT;
            }

            private static final long sequence$OFFSET = 2;

            /**
             * Offset for field:
             * {@snippet lang=c :
             * __be16 sequence
             * }
             */
            public static final long sequence$offset() {
                return sequence$OFFSET;
            }

            /**
             * Getter for field:
             * {@snippet lang=c :
             * __be16 sequence
             * }
             */
            public static short sequence(MemorySegment struct) {
                return struct.get(sequence$LAYOUT, sequence$OFFSET);
            }

            /**
             * Setter for field:
             * {@snippet lang=c :
             * __be16 sequence
             * }
             */
            public static void sequence(MemorySegment struct, short fieldValue) {
                struct.set(sequence$LAYOUT, sequence$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);
            }
        }

        private static final GroupLayout u_echo$LAYOUT = (GroupLayout)$LAYOUT.select(groupElement("u_echo"));

        /**
         * Layout for field:
         * {@snippet lang=c :
         * struct icmpv6_echo u_echo
         * }
         */
        public static final GroupLayout u_echo$layout() {
            return u_echo$LAYOUT;
        }

        private static final long u_echo$OFFSET = 0;

        /**
         * Offset for field:
         * {@snippet lang=c :
         * struct icmpv6_echo u_echo
         * }
         */
        public static final long u_echo$offset() {
            return u_echo$OFFSET;
        }

        /**
         * Getter for field:
         * {@snippet lang=c :
         * struct icmpv6_echo u_echo
         * }
         */
        public static MemorySegment u_echo(MemorySegment union) {
            return union.asSlice(u_echo$OFFSET, u_echo$LAYOUT.byteSize());
        }

        /**
         * Setter for field:
         * {@snippet lang=c :
         * struct icmpv6_echo u_echo
         * }
         */
        public static void u_echo(MemorySegment union, MemorySegment fieldValue) {
            MemorySegment.copy(fieldValue, 0L, union, u_echo$OFFSET, u_echo$LAYOUT.byteSize());
        }

        /**
         * {@snippet lang=c :
         * struct icmpv6_nd_advt {
         *     __u32 reserved : 5;
         *     __u32 override : 1;
         *     __u32 solicited : 1;
         *     __u32 router : 1;
         *     __u32 reserved2 : 24;
         * }
         * }
         */
        public static class icmpv6_nd_advt {

            icmpv6_nd_advt() {
                // Should not be called directly
            }

            private static final GroupLayout $LAYOUT = MemoryLayout.structLayout(
                MemoryLayout.paddingLayout(4)
            ).withName("icmpv6_nd_advt");

            /**
             * The layout of this struct
             */
            public static final GroupLayout layout() {
                return $LAYOUT;
            }

            /**
             * 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);
            }
        }

        private static final GroupLayout u_nd_advt$LAYOUT = (GroupLayout)$LAYOUT.select(groupElement("u_nd_advt"));

        /**
         * Layout for field:
         * {@snippet lang=c :
         * struct icmpv6_nd_advt u_nd_advt
         * }
         */
        public static final GroupLayout u_nd_advt$layout() {
            return u_nd_advt$LAYOUT;
        }

        private static final long u_nd_advt$OFFSET = 0;

        /**
         * Offset for field:
         * {@snippet lang=c :
         * struct icmpv6_nd_advt u_nd_advt
         * }
         */
        public static final long u_nd_advt$offset() {
            return u_nd_advt$OFFSET;
        }

        /**
         * Getter for field:
         * {@snippet lang=c :
         * struct icmpv6_nd_advt u_nd_advt
         * }
         */
        public static MemorySegment u_nd_advt(MemorySegment union) {
            return union.asSlice(u_nd_advt$OFFSET, u_nd_advt$LAYOUT.byteSize());
        }

        /**
         * Setter for field:
         * {@snippet lang=c :
         * struct icmpv6_nd_advt u_nd_advt
         * }
         */
        public static void u_nd_advt(MemorySegment union, MemorySegment fieldValue) {
            MemorySegment.copy(fieldValue, 0L, union, u_nd_advt$OFFSET, u_nd_advt$LAYOUT.byteSize());
        }

        /**
         * {@snippet lang=c :
         * struct icmpv6_nd_ra {
         *     __u8 hop_limit;
         *     __u8 reserved : 3;
         *     __u8 router_pref : 2;
         *     __u8 home_agent : 1;
         *     __u8 other : 1;
         *     __u8 managed : 1;
         *     __be16 rt_lifetime;
         * }
         * }
         */
        public static class icmpv6_nd_ra {

            icmpv6_nd_ra() {
                // Should not be called directly
            }

            private static final GroupLayout $LAYOUT = MemoryLayout.structLayout(
                Lib.C_CHAR.withName("hop_limit"),
                MemoryLayout.paddingLayout(1),
                Lib.C_SHORT.withName("rt_lifetime")
            ).withName("icmpv6_nd_ra");

            /**
             * The layout of this struct
             */
            public static final GroupLayout layout() {
                return $LAYOUT;
            }

            private static final OfByte hop_limit$LAYOUT = (OfByte)$LAYOUT.select(groupElement("hop_limit"));

            /**
             * Layout for field:
             * {@snippet lang=c :
             * __u8 hop_limit
             * }
             */
            public static final OfByte hop_limit$layout() {
                return hop_limit$LAYOUT;
            }

            private static final long hop_limit$OFFSET = 0;

            /**
             * Offset for field:
             * {@snippet lang=c :
             * __u8 hop_limit
             * }
             */
            public static final long hop_limit$offset() {
                return hop_limit$OFFSET;
            }

            /**
             * Getter for field:
             * {@snippet lang=c :
             * __u8 hop_limit
             * }
             */
            public static byte hop_limit(MemorySegment struct) {
                return struct.get(hop_limit$LAYOUT, hop_limit$OFFSET);
            }

            /**
             * Setter for field:
             * {@snippet lang=c :
             * __u8 hop_limit
             * }
             */
            public static void hop_limit(MemorySegment struct, byte fieldValue) {
                struct.set(hop_limit$LAYOUT, hop_limit$OFFSET, fieldValue);
            }

            private static final OfShort rt_lifetime$LAYOUT = (OfShort)$LAYOUT.select(groupElement("rt_lifetime"));

            /**
             * Layout for field:
             * {@snippet lang=c :
             * __be16 rt_lifetime
             * }
             */
            public static final OfShort rt_lifetime$layout() {
                return rt_lifetime$LAYOUT;
            }

            private static final long rt_lifetime$OFFSET = 2;

            /**
             * Offset for field:
             * {@snippet lang=c :
             * __be16 rt_lifetime
             * }
             */
            public static final long rt_lifetime$offset() {
                return rt_lifetime$OFFSET;
            }

            /**
             * Getter for field:
             * {@snippet lang=c :
             * __be16 rt_lifetime
             * }
             */
            public static short rt_lifetime(MemorySegment struct) {
                return struct.get(rt_lifetime$LAYOUT, rt_lifetime$OFFSET);
            }

            /**
             * Setter for field:
             * {@snippet lang=c :
             * __be16 rt_lifetime
             * }
             */
            public static void rt_lifetime(MemorySegment struct, short fieldValue) {
                struct.set(rt_lifetime$LAYOUT, rt_lifetime$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);
            }
        }

        private static final GroupLayout u_nd_ra$LAYOUT = (GroupLayout)$LAYOUT.select(groupElement("u_nd_ra"));

        /**
         * Layout for field:
         * {@snippet lang=c :
         * struct icmpv6_nd_ra u_nd_ra
         * }
         */
        public static final GroupLayout u_nd_ra$layout() {
            return u_nd_ra$LAYOUT;
        }

        private static final long u_nd_ra$OFFSET = 0;

        /**
         * Offset for field:
         * {@snippet lang=c :
         * struct icmpv6_nd_ra u_nd_ra
         * }
         */
        public static final long u_nd_ra$offset() {
            return u_nd_ra$OFFSET;
        }

        /**
         * Getter for field:
         * {@snippet lang=c :
         * struct icmpv6_nd_ra u_nd_ra
         * }
         */
        public static MemorySegment u_nd_ra(MemorySegment union) {
            return union.asSlice(u_nd_ra$OFFSET, u_nd_ra$LAYOUT.byteSize());
        }

        /**
         * Setter for field:
         * {@snippet lang=c :
         * struct icmpv6_nd_ra u_nd_ra
         * }
         */
        public static void u_nd_ra(MemorySegment union, MemorySegment fieldValue) {
            MemorySegment.copy(fieldValue, 0L, union, u_nd_ra$OFFSET, u_nd_ra$LAYOUT.byteSize());
        }

        /**
         * 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 union
         */
        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);
        }
    }

    private static final GroupLayout icmp6_dataun$LAYOUT = (GroupLayout)$LAYOUT.select(groupElement("icmp6_dataun"));

    /**
     * Layout for field:
     * {@snippet lang=c :
     * union {
     *     __be32 un_data32[1];
     *     __be16 un_data16[2];
     *     __u8 un_data8[4];
     *     struct icmpv6_echo {
     *         __be16 identifier;
     *         __be16 sequence;
     *     } u_echo;
     *     struct icmpv6_nd_advt {
     *         __u32 reserved : 5;
     *         __u32 override : 1;
     *         __u32 solicited : 1;
     *         __u32 router : 1;
     *         __u32 reserved2 : 24;
     *     } u_nd_advt;
     *     struct icmpv6_nd_ra {
     *         __u8 hop_limit;
     *         __u8 reserved : 3;
     *         __u8 router_pref : 2;
     *         __u8 home_agent : 1;
     *         __u8 other : 1;
     *         __u8 managed : 1;
     *         __be16 rt_lifetime;
     *     } u_nd_ra;
     * } icmp6_dataun
     * }
     */
    public static final GroupLayout icmp6_dataun$layout() {
        return icmp6_dataun$LAYOUT;
    }

    private static final long icmp6_dataun$OFFSET = 4;

    /**
     * Offset for field:
     * {@snippet lang=c :
     * union {
     *     __be32 un_data32[1];
     *     __be16 un_data16[2];
     *     __u8 un_data8[4];
     *     struct icmpv6_echo {
     *         __be16 identifier;
     *         __be16 sequence;
     *     } u_echo;
     *     struct icmpv6_nd_advt {
     *         __u32 reserved : 5;
     *         __u32 override : 1;
     *         __u32 solicited : 1;
     *         __u32 router : 1;
     *         __u32 reserved2 : 24;
     *     } u_nd_advt;
     *     struct icmpv6_nd_ra {
     *         __u8 hop_limit;
     *         __u8 reserved : 3;
     *         __u8 router_pref : 2;
     *         __u8 home_agent : 1;
     *         __u8 other : 1;
     *         __u8 managed : 1;
     *         __be16 rt_lifetime;
     *     } u_nd_ra;
     * } icmp6_dataun
     * }
     */
    public static final long icmp6_dataun$offset() {
        return icmp6_dataun$OFFSET;
    }

    /**
     * Getter for field:
     * {@snippet lang=c :
     * union {
     *     __be32 un_data32[1];
     *     __be16 un_data16[2];
     *     __u8 un_data8[4];
     *     struct icmpv6_echo {
     *         __be16 identifier;
     *         __be16 sequence;
     *     } u_echo;
     *     struct icmpv6_nd_advt {
     *         __u32 reserved : 5;
     *         __u32 override : 1;
     *         __u32 solicited : 1;
     *         __u32 router : 1;
     *         __u32 reserved2 : 24;
     *     } u_nd_advt;
     *     struct icmpv6_nd_ra {
     *         __u8 hop_limit;
     *         __u8 reserved : 3;
     *         __u8 router_pref : 2;
     *         __u8 home_agent : 1;
     *         __u8 other : 1;
     *         __u8 managed : 1;
     *         __be16 rt_lifetime;
     *     } u_nd_ra;
     * } icmp6_dataun
     * }
     */
    public static MemorySegment icmp6_dataun(MemorySegment struct) {
        return struct.asSlice(icmp6_dataun$OFFSET, icmp6_dataun$LAYOUT.byteSize());
    }

    /**
     * Setter for field:
     * {@snippet lang=c :
     * union {
     *     __be32 un_data32[1];
     *     __be16 un_data16[2];
     *     __u8 un_data8[4];
     *     struct icmpv6_echo {
     *         __be16 identifier;
     *         __be16 sequence;
     *     } u_echo;
     *     struct icmpv6_nd_advt {
     *         __u32 reserved : 5;
     *         __u32 override : 1;
     *         __u32 solicited : 1;
     *         __u32 router : 1;
     *         __u32 reserved2 : 24;
     *     } u_nd_advt;
     *     struct icmpv6_nd_ra {
     *         __u8 hop_limit;
     *         __u8 reserved : 3;
     *         __u8 router_pref : 2;
     *         __u8 home_agent : 1;
     *         __u8 other : 1;
     *         __u8 managed : 1;
     *         __be16 rt_lifetime;
     *     } u_nd_ra;
     * } icmp6_dataun
     * }
     */
    public static void icmp6_dataun(MemorySegment struct, MemorySegment fieldValue) {
        MemorySegment.copy(fieldValue, 0L, struct, icmp6_dataun$OFFSET, icmp6_dataun$LAYOUT.byteSize());
    }

    /**
     * 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);
    }
}





© 2015 - 2024 Weber Informatics LLC | Privacy Policy