diff options
author | Subv <subv2112@gmail.com> | 2017-06-13 23:30:17 +0200 |
---|---|---|
committer | Subv <subv2112@gmail.com> | 2017-06-15 19:08:53 +0200 |
commit | 7efb64132db95ef787481026a22d5b8244627a04 (patch) | |
tree | ae735abc18b8b74634a34bbbed5c9f4243321790 /src/core/hle/service/nwm/uds_data.h | |
parent | Services/UDS: Set the proper bit in the ConnectionStatus structure when creating a network. (#2738) (diff) | |
download | yuzu-7efb64132db95ef787481026a22d5b8244627a04.tar yuzu-7efb64132db95ef787481026a22d5b8244627a04.tar.gz yuzu-7efb64132db95ef787481026a22d5b8244627a04.tar.bz2 yuzu-7efb64132db95ef787481026a22d5b8244627a04.tar.lz yuzu-7efb64132db95ef787481026a22d5b8244627a04.tar.xz yuzu-7efb64132db95ef787481026a22d5b8244627a04.tar.zst yuzu-7efb64132db95ef787481026a22d5b8244627a04.zip |
Diffstat (limited to '')
-rw-r--r-- | src/core/hle/service/nwm/uds_data.h | 80 |
1 files changed, 80 insertions, 0 deletions
diff --git a/src/core/hle/service/nwm/uds_data.h b/src/core/hle/service/nwm/uds_data.h new file mode 100644 index 000000000..0dd46bcb1 --- /dev/null +++ b/src/core/hle/service/nwm/uds_data.h @@ -0,0 +1,80 @@ +// Copyright 2017 Citra Emulator Project +// Licensed under GPLv2 or any later version +// Refer to the license.txt file included. + +#pragma once + +#include "common/common_types.h" +#include "common/swap.h" +#include "core/hle/service/service.h" + +namespace Service { +namespace NWM { + +enum class SAP : u8 { + SNAPExtensionUsed = 0xAA +}; + +enum class PDUControl : u8 { + UnnumberedInformation = 3 +}; + +enum class EtherType : u16 { + SecureData = 0x876D, + EAPoL = 0x888E +}; + +/* + * 802.2 header, UDS packets always use SNAP for these headers, + * which means the dsap and ssap are always SNAPExtensionUsed (0xAA) + * and the OUI is always 0. + */ +struct LLCHeader { + u8 dsap = static_cast<u8>(SAP::SNAPExtensionUsed); + u8 ssap = static_cast<u8>(SAP::SNAPExtensionUsed); + u8 control = static_cast<u8>(PDUControl::UnnumberedInformation); + std::array<u8, 3> OUI = {}; + u16_be protocol; +}; + +static_assert(sizeof(LLCHeader) == 8, "LLCHeader has the wrong size"); + +/* + * Nintendo SecureData header, every UDS packet contains one, + * it is used to store metadata about the transmission such as + * the source and destination network node ids. + */ +struct SecureDataHeader { + u16_be protocol_size; + INSERT_PADDING_BYTES(2); + u16_be securedata_size; + u8 is_management; + u8 data_channel; + u16_be sequence_number; + u16_be dest_node_id; + u16_be src_node_id; +}; + +static_assert(sizeof(SecureDataHeader) == 14, "SecureDataHeader has the wrong size"); + +/* + * The raw bytes of this structure are the CTR used in the encryption (AES-CTR) + * process used to generate the CCMP key for data frame encryption. + */ +struct DataFrameCryptoCTR { + u32_le wlan_comm_id; + u32_le network_id; + std::array<u8, 6> host_mac; + u16_le id; +}; + +static_assert(sizeof(DataFrameCryptoCTR) == 16, "DataFrameCryptoCTR has the wrong size"); + +/** + * Generates an encrypted 802.11 data frame starting at the CCMP IV. + * @returns The generated frame. + */ +std::vector<u8> GenerateDataFrame(const std::vector<u8>& data, u8 channel, u16 dest_node, u16 src_node, u16 sequence_number); + +} // namespace NWM +} // namespace Service |