diff --git a/Kernel/Net/EthernetFrameHeader.h b/Kernel/Net/EthernetFrameHeader.h index 8468d0b588d11f1..c1cb75dc34dc9bb 100644 --- a/Kernel/Net/EthernetFrameHeader.h +++ b/Kernel/Net/EthernetFrameHeader.h @@ -32,7 +32,7 @@ class [[gnu::packed]] EthernetFrameHeader { MACAddress m_destination; MACAddress m_source; NetworkOrdered m_ether_type; - u32 m_payload[0]; + u8 m_payload[0]; }; static_assert(sizeof(EthernetFrameHeader) == 14); diff --git a/Kernel/Net/ICMP.h b/Kernel/Net/ICMP.h index 99656db7e319d03..b7f3fd0aa2debfd 100644 --- a/Kernel/Net/ICMP.h +++ b/Kernel/Net/ICMP.h @@ -30,14 +30,14 @@ class [[gnu::packed]] ICMPHeader { u16 checksum() const { return m_checksum; } void set_checksum(u16 w) { m_checksum = w; } - void const* payload() const { return this + 1; } - void* payload() { return this + 1; } + void const* payload() const { return &m_payload[0]; } + void* payload() { return &m_payload[0]; } private: u8 m_type { 0 }; u8 m_code { 0 }; NetworkOrdered m_checksum { 0 }; - // NOTE: The rest of the header is 4 bytes + u8 m_payload[0]; }; static_assert(AssertSize()); @@ -46,6 +46,8 @@ struct [[gnu::packed]] ICMPEchoPacket { ICMPHeader header; NetworkOrdered identifier; NetworkOrdered sequence_number; - void* payload() { return this + 1; } - void const* payload() const { return this + 1; } + u8 m_payload[0]; + + void* payload() { return &m_payload[0]; } + void const* payload() const { return &m_payload[0]; } }; diff --git a/Kernel/Net/IP/IPv4.h b/Kernel/Net/IP/IPv4.h index 62977e6b788e84f..0daee35ccdae4d5 100644 --- a/Kernel/Net/IP/IPv4.h +++ b/Kernel/Net/IP/IPv4.h @@ -51,8 +51,8 @@ class [[gnu::packed]] IPv4Packet { IPv4Address const& destination() const { return m_destination; } void set_destination(IPv4Address const& address) { m_destination = address; } - void* payload() { return this + 1; } - void const* payload() const { return this + 1; } + void* payload() { return &m_payload[0]; } + void const* payload() const { return &m_payload[0]; } u16 flags_and_fragment() const { return m_flags_and_fragment; } u16 fragment_offset() const { return ((u16)m_flags_and_fragment & 0x1fff); } @@ -97,6 +97,7 @@ class [[gnu::packed]] IPv4Packet { NetworkOrdered m_checksum; IPv4Address m_source; IPv4Address m_destination; + u8 m_payload[0]; }; static_assert(AssertSize()); diff --git a/Kernel/Net/UDP.h b/Kernel/Net/UDP.h index bcbc6e8cbef5061..23f691bccc4e01b 100644 --- a/Kernel/Net/UDP.h +++ b/Kernel/Net/UDP.h @@ -27,14 +27,15 @@ class [[gnu::packed]] UDPPacket { u16 checksum() const { return m_checksum; } void set_checksum(u16 checksum) { m_checksum = checksum; } - void const* payload() const { return this + 1; } - void* payload() { return this + 1; } + void const* payload() const { return &m_payload[0]; } + void* payload() { return &m_payload[0]; } private: NetworkOrdered m_source_port; NetworkOrdered m_destination_port; NetworkOrdered m_length; NetworkOrdered m_checksum; + u8 m_payload[0]; }; static_assert(sizeof(UDPPacket) == 8);