aboutsummaryrefslogtreecommitdiff
path: root/src/core/hle/service/nwm/uds_connection.h
blob: 423e33374ad2d9a5a024f595addbea55c2a686c1 (plain) (blame)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
// Copyright 2017 Citra Emulator Project
// Licensed under GPLv2 or any later version
// Refer to the license.txt file included.

#pragma once

#include <span>
#include <tuple>
#include <vector>
#include "common/common_types.h"
#include "common/swap.h"
#include "core/hle/service/service.h"

namespace Service::NWM {

/// Sequence number of the 802.11 authentication frames.
enum class AuthenticationSeq : u16 { SEQ1 = 1, SEQ2 = 2 };

enum class AuthAlgorithm : u16 { OpenSystem = 0 };

enum class AuthStatus : u16 { Successful = 0 };

enum class AssocStatus : u16 { Successful = 0 };

struct AuthenticationFrame {
    enum_le<AuthAlgorithm> auth_algorithm = AuthAlgorithm::OpenSystem;
    enum_le<AuthenticationSeq> auth_seq;
    enum_le<AuthStatus> status_code = AuthStatus::Successful;
};

static_assert(sizeof(AuthenticationFrame) == 6, "AuthenticationFrame has wrong size");

struct AssociationResponseFrame {
    u16_le capabilities;
    enum_le<AssocStatus> status_code;
    u16_le assoc_id;
};

static_assert(sizeof(AssociationResponseFrame) == 6, "AssociationResponseFrame has wrong size");

/// Generates an 802.11 authentication frame, starting at the frame body.
std::vector<u8> GenerateAuthenticationFrame(AuthenticationSeq seq);

/// Returns the sequence number from the body of an Authentication frame.
AuthenticationSeq GetAuthenticationSeqNumber(std::span<const u8> body);

/// Generates an 802.11 association response frame with the specified status, association id and
/// network id, starting at the frame body.
std::vector<u8> GenerateAssocResponseFrame(AssocStatus status, u16 association_id, u32 network_id);

/// Returns a tuple of (association status, association id) from the body of an AssociationResponse
/// frame.
std::tuple<AssocStatus, u16> GetAssociationResult(std::span<const u8> body);

} // namespace Service::NWM