Serenity Operating System
at master 38 lines 1.0 kB view raw
1/* 2 * Copyright (c) 2018-2020, Andreas Kling <kling@serenityos.org> 3 * 4 * SPDX-License-Identifier: BSD-2-Clause 5 */ 6 7#pragma once 8 9#include <AK/Endian.h> 10#include <AK/MACAddress.h> 11 12#pragma GCC diagnostic ignored "-Warray-bounds" 13 14class [[gnu::packed]] EthernetFrameHeader { 15public: 16 EthernetFrameHeader() = default; 17 ~EthernetFrameHeader() = default; 18 19 MACAddress destination() const { return m_destination; } 20 void set_destination(MACAddress const& address) { m_destination = address; } 21 22 MACAddress source() const { return m_source; } 23 void set_source(MACAddress const& address) { m_source = address; } 24 25 u16 ether_type() const { return m_ether_type; } 26 void set_ether_type(u16 ether_type) { m_ether_type = ether_type; } 27 28 void const* payload() const { return &m_payload[0]; } 29 void* payload() { return &m_payload[0]; } 30 31private: 32 MACAddress m_destination; 33 MACAddress m_source; 34 NetworkOrdered<u16> m_ether_type; 35 u32 m_payload[0]; 36}; 37 38static_assert(sizeof(EthernetFrameHeader) == 14);