#pragma once #include #include namespace eth { using mac_addr = std::array; static constexpr mac_addr MAC_BROADCAST = {0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF}; static constexpr uint16_t ETH_ARP = __builtin_bswap16(0x0806); static constexpr uint16_t ETH_IPV4 = __builtin_bswap16(0x0800); struct __attribute__((packed)) header { mac_addr dst; mac_addr src; uint16_t ethertype; }; static_assert(sizeof(header) == 14); template void prepend(Buf& buf, const mac_addr& dst, const mac_addr& src, uint16_t ethertype) { auto* h = buf.template prepend
(); h->dst = dst; h->src = src; h->ethertype = ethertype; } } // namespace eth