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

me.bechberger.ebpf.bpf.raw.icmp_ext_echo_iio 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 icmp_ext_echo_iio {
 *     struct icmp_extobj_hdr extobj_hdr;
 *     union {
 *         char name[16];
 *         __be32 ifindex;
 *         struct {
 *             struct icmp_ext_echo_ctype3_hdr ctype3_hdr;
 *             union {
 *                 __be32 ipv4_addr;
 *                 struct in6_addr ipv6_addr;
 *             } ip_addr;
 *         } addr;
 *     } ident;
 * }
 * }
 */
public class icmp_ext_echo_iio {

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

    private static final GroupLayout $LAYOUT = MemoryLayout.structLayout(
        icmp_extobj_hdr.layout().withName("extobj_hdr"),
        icmp_ext_echo_iio.ident.layout().withName("ident")
    ).withName("icmp_ext_echo_iio");

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

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

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

    private static final long extobj_hdr$OFFSET = 0;

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

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

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

    /**
     * {@snippet lang=c :
     * union {
     *     char name[16];
     *     __be32 ifindex;
     *     struct {
     *         struct icmp_ext_echo_ctype3_hdr ctype3_hdr;
     *         union {
     *             __be32 ipv4_addr;
     *             struct in6_addr ipv6_addr;
     *         } ip_addr;
     *     } addr;
     * }
     * }
     */
    public static class ident {

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

        private static final GroupLayout $LAYOUT = MemoryLayout.unionLayout(
            MemoryLayout.sequenceLayout(16, Lib.C_CHAR).withName("name"),
            Lib.C_INT.withName("ifindex"),
            icmp_ext_echo_iio.ident.addr.layout().withName("addr")
        ).withName("$anon$150:2");

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

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

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

        private static final long name$OFFSET = 0;

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

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

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

        private static long[] name$DIMS = { 16 };

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

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

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

        private static final OfInt ifindex$LAYOUT = (OfInt)$LAYOUT.select(groupElement("ifindex"));

        /**
         * Layout for field:
         * {@snippet lang=c :
         * __be32 ifindex
         * }
         */
        public static final OfInt ifindex$layout() {
            return ifindex$LAYOUT;
        }

        private static final long ifindex$OFFSET = 0;

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

        /**
         * Getter for field:
         * {@snippet lang=c :
         * __be32 ifindex
         * }
         */
        public static int ifindex(MemorySegment union) {
            return union.get(ifindex$LAYOUT, ifindex$OFFSET);
        }

        /**
         * Setter for field:
         * {@snippet lang=c :
         * __be32 ifindex
         * }
         */
        public static void ifindex(MemorySegment union, int fieldValue) {
            union.set(ifindex$LAYOUT, ifindex$OFFSET, fieldValue);
        }

        /**
         * {@snippet lang=c :
         * struct {
         *     struct icmp_ext_echo_ctype3_hdr ctype3_hdr;
         *     union {
         *         __be32 ipv4_addr;
         *         struct in6_addr ipv6_addr;
         *     } ip_addr;
         * }
         * }
         */
        public static class addr {

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

            private static final GroupLayout $LAYOUT = MemoryLayout.structLayout(
                icmp_ext_echo_ctype3_hdr.layout().withName("ctype3_hdr"),
                icmp_ext_echo_iio.ident.addr.ip_addr.layout().withName("ip_addr")
            ).withName("$anon$153:3");

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

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

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

            private static final long ctype3_hdr$OFFSET = 0;

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

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

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

            /**
             * {@snippet lang=c :
             * union {
             *     __be32 ipv4_addr;
             *     struct in6_addr ipv6_addr;
             * }
             * }
             */
            public static class ip_addr {

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

                private static final GroupLayout $LAYOUT = MemoryLayout.unionLayout(
                    Lib.C_INT.withName("ipv4_addr"),
                    in6_addr.layout().withName("ipv6_addr")
                ).withName("$anon$155:4");

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

                private static final OfInt ipv4_addr$LAYOUT = (OfInt)$LAYOUT.select(groupElement("ipv4_addr"));

                /**
                 * Layout for field:
                 * {@snippet lang=c :
                 * __be32 ipv4_addr
                 * }
                 */
                public static final OfInt ipv4_addr$layout() {
                    return ipv4_addr$LAYOUT;
                }

                private static final long ipv4_addr$OFFSET = 0;

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

                /**
                 * Getter for field:
                 * {@snippet lang=c :
                 * __be32 ipv4_addr
                 * }
                 */
                public static int ipv4_addr(MemorySegment union) {
                    return union.get(ipv4_addr$LAYOUT, ipv4_addr$OFFSET);
                }

                /**
                 * Setter for field:
                 * {@snippet lang=c :
                 * __be32 ipv4_addr
                 * }
                 */
                public static void ipv4_addr(MemorySegment union, int fieldValue) {
                    union.set(ipv4_addr$LAYOUT, ipv4_addr$OFFSET, fieldValue);
                }

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

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

                private static final long ipv6_addr$OFFSET = 0;

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

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

                /**
                 * Setter for field:
                 * {@snippet lang=c :
                 * struct in6_addr ipv6_addr
                 * }
                 */
                public static void ipv6_addr(MemorySegment union, MemorySegment fieldValue) {
                    MemorySegment.copy(fieldValue, 0L, union, ipv6_addr$OFFSET, ipv6_addr$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 ip_addr$LAYOUT = (GroupLayout)$LAYOUT.select(groupElement("ip_addr"));

            /**
             * Layout for field:
             * {@snippet lang=c :
             * union {
             *     __be32 ipv4_addr;
             *     struct in6_addr ipv6_addr;
             * } ip_addr
             * }
             */
            public static final GroupLayout ip_addr$layout() {
                return ip_addr$LAYOUT;
            }

            private static final long ip_addr$OFFSET = 4;

            /**
             * Offset for field:
             * {@snippet lang=c :
             * union {
             *     __be32 ipv4_addr;
             *     struct in6_addr ipv6_addr;
             * } ip_addr
             * }
             */
            public static final long ip_addr$offset() {
                return ip_addr$OFFSET;
            }

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

            /**
             * Setter for field:
             * {@snippet lang=c :
             * union {
             *     __be32 ipv4_addr;
             *     struct in6_addr ipv6_addr;
             * } ip_addr
             * }
             */
            public static void ip_addr(MemorySegment struct, MemorySegment fieldValue) {
                MemorySegment.copy(fieldValue, 0L, struct, ip_addr$OFFSET, ip_addr$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);
            }
        }

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

        /**
         * Layout for field:
         * {@snippet lang=c :
         * struct {
         *     struct icmp_ext_echo_ctype3_hdr ctype3_hdr;
         *     union {
         *         __be32 ipv4_addr;
         *         struct in6_addr ipv6_addr;
         *     } ip_addr;
         * } addr
         * }
         */
        public static final GroupLayout addr$layout() {
            return addr$LAYOUT;
        }

        private static final long addr$OFFSET = 0;

        /**
         * Offset for field:
         * {@snippet lang=c :
         * struct {
         *     struct icmp_ext_echo_ctype3_hdr ctype3_hdr;
         *     union {
         *         __be32 ipv4_addr;
         *         struct in6_addr ipv6_addr;
         *     } ip_addr;
         * } addr
         * }
         */
        public static final long addr$offset() {
            return addr$OFFSET;
        }

        /**
         * Getter for field:
         * {@snippet lang=c :
         * struct {
         *     struct icmp_ext_echo_ctype3_hdr ctype3_hdr;
         *     union {
         *         __be32 ipv4_addr;
         *         struct in6_addr ipv6_addr;
         *     } ip_addr;
         * } addr
         * }
         */
        public static MemorySegment addr(MemorySegment union) {
            return union.asSlice(addr$OFFSET, addr$LAYOUT.byteSize());
        }

        /**
         * Setter for field:
         * {@snippet lang=c :
         * struct {
         *     struct icmp_ext_echo_ctype3_hdr ctype3_hdr;
         *     union {
         *         __be32 ipv4_addr;
         *         struct in6_addr ipv6_addr;
         *     } ip_addr;
         * } addr
         * }
         */
        public static void addr(MemorySegment union, MemorySegment fieldValue) {
            MemorySegment.copy(fieldValue, 0L, union, addr$OFFSET, addr$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 ident$LAYOUT = (GroupLayout)$LAYOUT.select(groupElement("ident"));

    /**
     * Layout for field:
     * {@snippet lang=c :
     * union {
     *     char name[16];
     *     __be32 ifindex;
     *     struct {
     *         struct icmp_ext_echo_ctype3_hdr ctype3_hdr;
     *         union {
     *             __be32 ipv4_addr;
     *             struct in6_addr ipv6_addr;
     *         } ip_addr;
     *     } addr;
     * } ident
     * }
     */
    public static final GroupLayout ident$layout() {
        return ident$LAYOUT;
    }

    private static final long ident$OFFSET = 4;

    /**
     * Offset for field:
     * {@snippet lang=c :
     * union {
     *     char name[16];
     *     __be32 ifindex;
     *     struct {
     *         struct icmp_ext_echo_ctype3_hdr ctype3_hdr;
     *         union {
     *             __be32 ipv4_addr;
     *             struct in6_addr ipv6_addr;
     *         } ip_addr;
     *     } addr;
     * } ident
     * }
     */
    public static final long ident$offset() {
        return ident$OFFSET;
    }

    /**
     * Getter for field:
     * {@snippet lang=c :
     * union {
     *     char name[16];
     *     __be32 ifindex;
     *     struct {
     *         struct icmp_ext_echo_ctype3_hdr ctype3_hdr;
     *         union {
     *             __be32 ipv4_addr;
     *             struct in6_addr ipv6_addr;
     *         } ip_addr;
     *     } addr;
     * } ident
     * }
     */
    public static MemorySegment ident(MemorySegment struct) {
        return struct.asSlice(ident$OFFSET, ident$LAYOUT.byteSize());
    }

    /**
     * Setter for field:
     * {@snippet lang=c :
     * union {
     *     char name[16];
     *     __be32 ifindex;
     *     struct {
     *         struct icmp_ext_echo_ctype3_hdr ctype3_hdr;
     *         union {
     *             __be32 ipv4_addr;
     *             struct in6_addr ipv6_addr;
     *         } ip_addr;
     *     } addr;
     * } ident
     * }
     */
    public static void ident(MemorySegment struct, MemorySegment fieldValue) {
        MemorySegment.copy(fieldValue, 0L, struct, ident$OFFSET, ident$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