mirror of
https://github.com/dolphin-emu/dolphin.git
synced 2025-04-15 20:42:41 +00:00
Common/Network: Ensure offsetof is valid
This commit is contained in:
parent
b7bd2a4001
commit
4efe1e7ca7
@ -7,6 +7,7 @@
|
|||||||
#include <optional>
|
#include <optional>
|
||||||
#include <string>
|
#include <string>
|
||||||
#include <string_view>
|
#include <string_view>
|
||||||
|
#include <type_traits>
|
||||||
#include <vector>
|
#include <vector>
|
||||||
|
|
||||||
#include "Common/CommonTypes.h"
|
#include "Common/CommonTypes.h"
|
||||||
@ -57,6 +58,7 @@ struct EthernetHeader
|
|||||||
u16 ethertype = 0;
|
u16 ethertype = 0;
|
||||||
};
|
};
|
||||||
static_assert(sizeof(EthernetHeader) == EthernetHeader::SIZE);
|
static_assert(sizeof(EthernetHeader) == EthernetHeader::SIZE);
|
||||||
|
static_assert(std::is_standard_layout_v<EthernetHeader>);
|
||||||
|
|
||||||
struct IPv4Header
|
struct IPv4Header
|
||||||
{
|
{
|
||||||
@ -79,6 +81,7 @@ struct IPv4Header
|
|||||||
IPAddress destination_addr{};
|
IPAddress destination_addr{};
|
||||||
};
|
};
|
||||||
static_assert(sizeof(IPv4Header) == IPv4Header::SIZE);
|
static_assert(sizeof(IPv4Header) == IPv4Header::SIZE);
|
||||||
|
static_assert(std::is_standard_layout_v<IPv4Header>);
|
||||||
|
|
||||||
struct TCPHeader
|
struct TCPHeader
|
||||||
{
|
{
|
||||||
@ -101,6 +104,7 @@ struct TCPHeader
|
|||||||
u16 urgent_pointer = 0;
|
u16 urgent_pointer = 0;
|
||||||
};
|
};
|
||||||
static_assert(sizeof(TCPHeader) == TCPHeader::SIZE);
|
static_assert(sizeof(TCPHeader) == TCPHeader::SIZE);
|
||||||
|
static_assert(std::is_standard_layout_v<TCPHeader>);
|
||||||
|
|
||||||
struct UDPHeader
|
struct UDPHeader
|
||||||
{
|
{
|
||||||
@ -117,6 +121,7 @@ struct UDPHeader
|
|||||||
u16 checksum = 0;
|
u16 checksum = 0;
|
||||||
};
|
};
|
||||||
static_assert(sizeof(UDPHeader) == UDPHeader::SIZE);
|
static_assert(sizeof(UDPHeader) == UDPHeader::SIZE);
|
||||||
|
static_assert(std::is_standard_layout_v<UDPHeader>);
|
||||||
|
|
||||||
#pragma pack(push, 1)
|
#pragma pack(push, 1)
|
||||||
struct ARPHeader
|
struct ARPHeader
|
||||||
|
Loading…
x
Reference in New Issue
Block a user