nwm/uds_connection: specify endiannes for enum
This commit is contained in:
parent
16b36b6025
commit
e0336403ee
@ -15,7 +15,7 @@ constexpr u16 DefaultExtraCapabilities = 0x0431;
|
||||
|
||||
std::vector<u8> GenerateAuthenticationFrame(AuthenticationSeq seq) {
|
||||
AuthenticationFrame frame{};
|
||||
frame.auth_seq = static_cast<u16>(seq);
|
||||
frame.auth_seq = seq;
|
||||
|
||||
std::vector<u8> data(sizeof(frame));
|
||||
std::memcpy(data.data(), &frame, sizeof(frame));
|
||||
@ -27,7 +27,7 @@ AuthenticationSeq GetAuthenticationSeqNumber(const std::vector<u8>& body) {
|
||||
AuthenticationFrame frame;
|
||||
std::memcpy(&frame, body.data(), sizeof(frame));
|
||||
|
||||
return static_cast<AuthenticationSeq>(frame.auth_seq);
|
||||
return frame.auth_seq;
|
||||
}
|
||||
|
||||
/**
|
||||
@ -58,7 +58,7 @@ static std::vector<u8> GenerateSSIDTag(u32 network_id) {
|
||||
std::vector<u8> GenerateAssocResponseFrame(AssocStatus status, u16 association_id, u32 network_id) {
|
||||
AssociationResponseFrame frame{};
|
||||
frame.capabilities = DefaultExtraCapabilities;
|
||||
frame.status_code = static_cast<u16>(status);
|
||||
frame.status_code = status;
|
||||
// The association id is ORed with this magic value (0xC000)
|
||||
constexpr u16 AssociationIdMagic = 0xC000;
|
||||
frame.assoc_id = association_id | AssociationIdMagic;
|
||||
@ -80,8 +80,7 @@ std::tuple<AssocStatus, u16> GetAssociationResult(const std::vector<u8>& body) {
|
||||
memcpy(&frame, body.data(), sizeof(frame));
|
||||
|
||||
constexpr u16 AssociationIdMask = 0x3FFF;
|
||||
return std::make_tuple(static_cast<AssocStatus>(frame.status_code),
|
||||
frame.assoc_id & AssociationIdMask);
|
||||
return std::make_tuple(frame.status_code, frame.assoc_id & AssociationIdMask);
|
||||
}
|
||||
|
||||
} // namespace NWM
|
||||
|
@ -23,16 +23,16 @@ enum class AuthStatus : u16 { Successful = 0 };
|
||||
enum class AssocStatus : u16 { Successful = 0 };
|
||||
|
||||
struct AuthenticationFrame {
|
||||
u16_le auth_algorithm = static_cast<u16>(AuthAlgorithm::OpenSystem);
|
||||
u16_le auth_seq;
|
||||
u16_le status_code = static_cast<u16>(AuthStatus::Successful);
|
||||
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;
|
||||
u16_le status_code;
|
||||
enum_le<AssocStatus> status_code;
|
||||
u16_le assoc_id;
|
||||
};
|
||||
|
||||
|
Loading…
Reference in New Issue
Block a user