#pragma once #include #include // Manual big-endian reads instead of reinterpret_cast onto a packed // struct: network buffers from pcap aren't guaranteed aligned for // multi-byte integer types, so casting would be undefined behavior. namespace wireframe { inline std::uint16_t read_be16(std::span bytes, std::size_t offset) { return static_cast((bytes[offset] << 8) | bytes[offset + 1]); } inline std::uint32_t read_be32(std::span bytes, std::size_t offset) { return (static_cast(bytes[offset]) << 24) | (static_cast(bytes[offset + 1]) << 16) | (static_cast(bytes[offset + 2]) << 8) | static_cast(bytes[offset + 3]); } } // namespace wireframe