diff options
Diffstat (limited to '')
| -rw-r--r-- | src/input_common/udp/protocol.cpp | 12 |
1 files changed, 6 insertions, 6 deletions
diff --git a/src/input_common/udp/protocol.cpp b/src/input_common/udp/protocol.cpp index 16da706d5..a982ac49d 100644 --- a/src/input_common/udp/protocol.cpp +++ b/src/input_common/udp/protocol.cpp | |||
| @@ -32,21 +32,21 @@ namespace Response { | |||
| 32 | std::optional<Type> Validate(u8* data, std::size_t size) { | 32 | std::optional<Type> Validate(u8* data, std::size_t size) { |
| 33 | if (size < sizeof(Header)) { | 33 | if (size < sizeof(Header)) { |
| 34 | LOG_DEBUG(Input, "Invalid UDP packet received"); | 34 | LOG_DEBUG(Input, "Invalid UDP packet received"); |
| 35 | return {}; | 35 | return std::nullopt; |
| 36 | } | 36 | } |
| 37 | Header header{}; | 37 | Header header{}; |
| 38 | std::memcpy(&header, data, sizeof(Header)); | 38 | std::memcpy(&header, data, sizeof(Header)); |
| 39 | if (header.magic != SERVER_MAGIC) { | 39 | if (header.magic != SERVER_MAGIC) { |
| 40 | LOG_ERROR(Input, "UDP Packet has an unexpected magic value"); | 40 | LOG_ERROR(Input, "UDP Packet has an unexpected magic value"); |
| 41 | return {}; | 41 | return std::nullopt; |
| 42 | } | 42 | } |
| 43 | if (header.protocol_version != PROTOCOL_VERSION) { | 43 | if (header.protocol_version != PROTOCOL_VERSION) { |
| 44 | LOG_ERROR(Input, "UDP Packet protocol mismatch"); | 44 | LOG_ERROR(Input, "UDP Packet protocol mismatch"); |
| 45 | return {}; | 45 | return std::nullopt; |
| 46 | } | 46 | } |
| 47 | if (header.type < Type::Version || header.type > Type::PadData) { | 47 | if (header.type < Type::Version || header.type > Type::PadData) { |
| 48 | LOG_ERROR(Input, "UDP Packet is an unknown type"); | 48 | LOG_ERROR(Input, "UDP Packet is an unknown type"); |
| 49 | return {}; | 49 | return std::nullopt; |
| 50 | } | 50 | } |
| 51 | 51 | ||
| 52 | // Packet size must equal sizeof(Header) + sizeof(Data) | 52 | // Packet size must equal sizeof(Header) + sizeof(Data) |
| @@ -59,7 +59,7 @@ std::optional<Type> Validate(u8* data, std::size_t size) { | |||
| 59 | Input, | 59 | Input, |
| 60 | "UDP Packet payload length doesn't match. Received: {} PayloadLength: {} Expected: {}", | 60 | "UDP Packet payload length doesn't match. Received: {} PayloadLength: {} Expected: {}", |
| 61 | size, header.payload_length, data_len + sizeof(Type)); | 61 | size, header.payload_length, data_len + sizeof(Type)); |
| 62 | return {}; | 62 | return std::nullopt; |
| 63 | } | 63 | } |
| 64 | 64 | ||
| 65 | const u32 crc32 = header.crc; | 65 | const u32 crc32 = header.crc; |
| @@ -70,7 +70,7 @@ std::optional<Type> Validate(u8* data, std::size_t size) { | |||
| 70 | result.process_bytes(data, data_len + sizeof(Header)); | 70 | result.process_bytes(data, data_len + sizeof(Header)); |
| 71 | if (crc32 != result.checksum()) { | 71 | if (crc32 != result.checksum()) { |
| 72 | LOG_ERROR(Input, "UDP Packet CRC check failed. Offset: {}", offsetof(Header, crc)); | 72 | LOG_ERROR(Input, "UDP Packet CRC check failed. Offset: {}", offsetof(Header, crc)); |
| 73 | return {}; | 73 | return std::nullopt; |
| 74 | } | 74 | } |
| 75 | return header.type; | 75 | return header.type; |
| 76 | } | 76 | } |