Fix Query - related compilation warnings and errors

dependabot/npm_and_yarn/Src/WebController/UI/websocket-extensions-0.1.4
Grzegorz Rychlik 2020-02-20 16:57:03 +01:00
parent 34c73a078a
commit a5e517f9f2
10 changed files with 32 additions and 18 deletions

View File

@ -76,7 +76,7 @@ namespace MWR::C3
}
/// Get proper map member for type T.
template <typename T> auto& GetMap() { static_assert(false, "Template type not supported."); }
template <typename T> auto& GetMap() = delete;
template <> auto& GetMap<AbstractChannel>() { return m_Channels; }
template <> auto& GetMap<AbstractPeripheral>() { return m_Peripherals; }
template <> auto& GetMap<AbstractConnector>() { return m_Connectors; }

View File

@ -8,7 +8,6 @@ namespace MWR::C3::Core
// Typedefs and constants.
using ProceduresUnderlyingType = std::int8_t; ///< Underlying type for Procedure number field.
using SequenceNumberFieldUnderlyingType = std::uint32_t; /// Underlying type for Query/Response sequence numbers (including type bits = 2 bits).
static constexpr unsigned s_SequenceNumberBitLength = sizeof SequenceNumberFieldUnderlyingType * 8 - 2; ///< Number of bits sequence number occupy in the SequenceNumberType type.
/// Abstract class for all Queries.
struct BaseQuery
@ -83,7 +82,7 @@ namespace MWR::C3::Core
using SequenceNumberFieldUnderlyingType = std::uint32_t;
/// Number of bits sequence number occupy in the SequenceNumberType type.
static constexpr unsigned s_SequenceNumberBitLength = sizeof SequenceNumberFieldUnderlyingType * 8 - 2;
static constexpr unsigned s_SequenceNumberBitLength = sizeof(SequenceNumberFieldUnderlyingType) * 8 - 2;
/// Sequence number
const SequenceNumberFieldUnderlyingType m_SequenceNumber;

View File

@ -34,6 +34,10 @@ namespace MWR::C3::Core
virtual void OnPacketReceived(ByteView packet, std::shared_ptr<DeviceBridge> sender);
protected:
/// Expose all base classes `On` methods.
using ProceduresN2N::RequestHandler::On;
using ProceduresS2G::RequestHandler::On;
/// A protected ctor.
/// @param callbackOnLog callback fired whenever a new Log entry is being added.
/// @param decryptionKey Relay's private asymmetric key.

View File

@ -284,7 +284,7 @@ void MWR::C3::Core::GateRelay::DetachDevice(DeviceId const& iidOfDeviceToDetach)
}
////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////
void MWR::C3::Core::GateRelay::On(ProceduresN2N::InitializeRouteQuery&& query)
void MWR::C3::Core::GateRelay::On(ProceduresN2N::InitializeRouteQuery query)
{
auto decryptedPacket = query.GetQueryPacket(this->m_AuthenticationKey, this->m_DecryptionKey);
auto readView = ByteView{ decryptedPacket };
@ -308,7 +308,7 @@ void MWR::C3::Core::GateRelay::On(ProceduresN2N::InitializeRouteQuery&& query)
}
////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////
void MWR::C3::Core::GateRelay::On(ProceduresS2G::InitializeRouteQuery&& query)
void MWR::C3::Core::GateRelay::On(ProceduresS2G::InitializeRouteQuery query)
{
// whole message.
auto decryptedPacket = query.GetQueryPacket(m_AuthenticationKey, m_DecryptionKey);

View File

@ -104,13 +104,17 @@ namespace MWR::C3::Core
/// @param senderPeripheral Interface that is sending the Command.
void PostCommandToConnector(ByteView command, std::shared_ptr<DeviceBridge> senderPeripheral) override;
/// Expose all base classes `On` methods.
using ProceduresG2X::RequestHandler::On;
using Relay::On;
/// Handler fired when a N2N::InitializeRoute Procedure Query arrives.
/// @param query object representing the Query.
void On(ProceduresN2N::InitializeRouteQuery&& query) override;
void On(ProceduresN2N::InitializeRouteQuery query) override;
/// Handler fired when a S2G::InitializeRoute Procedure Query arrives.
/// @param query object representing the Query.
void On(ProceduresS2G::InitializeRouteQuery&& query) override;
void On(ProceduresS2G::InitializeRouteQuery query) override;
/// Handler fired when a N2N::ChannelIdExchangeStep1 Procedure Query arrives.
/// Gateway opens a new channel and sends parameters to relay.

View File

@ -188,7 +188,7 @@ void MWR::C3::Core::NodeRelay::NegotiateChannel(std::shared_ptr<DeviceBridge> co
}
////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////
void MWR::C3::Core::NodeRelay::On(ProceduresN2N::InitializeRouteQuery&& query)
void MWR::C3::Core::NodeRelay::On(ProceduresN2N::InitializeRouteQuery query)
{
// Retrieve GRC.
auto grc = GetGatewayReturnChannel();
@ -201,7 +201,7 @@ void MWR::C3::Core::NodeRelay::On(ProceduresN2N::InitializeRouteQuery&& query)
}
////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////
void MWR::C3::Core::NodeRelay::On(ProceduresS2G::InitializeRouteQuery&& query)
void MWR::C3::Core::NodeRelay::On(ProceduresS2G::InitializeRouteQuery query)
{
throw std::logic_error{ OBF("Wrong recipient.") };
}

View File

@ -57,13 +57,17 @@ namespace MWR::C3::Core
/// @param channel Interface that will be used to send the packet.
void PostCommandToConnector(ByteView command, std::shared_ptr<DeviceBridge> channel) override;
/// Expose all base classes `On` methods.
using Relay::On;
using ProceduresG2X::RequestHandler::On;
/// Handler fired when a N2N::InitializeRoute Procedure Query arrives.
/// @param query object representing the Query.
void On(ProceduresN2N::InitializeRouteQuery&& query) override;
void On(ProceduresN2N::InitializeRouteQuery query) override;
/// Handler fired when a N2N::InitializeRoute Procedure arrives.
/// @param query object representing the Query.
void On(ProceduresS2G::InitializeRouteQuery&& query) override;
void On(ProceduresS2G::InitializeRouteQuery query) override;
/// Handler fired when a G2X::AddRoute Procedure Query arrives.
/// @param query object representing the Query.

View File

@ -184,7 +184,7 @@ namespace MWR::C3::Core
struct RequestHandler
{
/// Declaration of support for InitializeRouteQuery Request.
virtual void On(InitializeRouteQuery&&) = 0;
virtual void On(InitializeRouteQuery) = 0;
/// Declaration of support for ChannelIdExchangeStep1 Request.
virtual void On(ChannelIdExchangeStep1) = 0;
@ -461,7 +461,7 @@ namespace MWR::C3::Core
struct RequestHandler
{
/// Declaration of support for InitializeRouteQuery Request.
virtual void On(InitializeRouteQuery&&) = 0;
virtual void On(InitializeRouteQuery) = 0;
/// Default empty handler for AddDeviceResponse Request.
virtual void On(AddDeviceResponse) {};

View File

@ -31,7 +31,7 @@ namespace MWR::C3::Core::ProceduresG2X
: BaseQuery{ responseType }
, m_Propagation{ propagation }
, m_ReceiverRid{ receiverRid }
, m_GatewayPrivateSignature{ gatewayPrivateSignature }
, m_GatewayPrivateSignature{ &gatewayPrivateSignature }
{
}
@ -51,11 +51,12 @@ namespace MWR::C3::Core::ProceduresG2X
/// @return buffer containing whole packet.
ByteVector ComposeQueryPacket() const override
{
return CompileProtocolHeader().Concat(Crypto::SignMessage(m_ReceiverRid.ToByteVector().Concat(GetQueryHeader()).Concat(m_QueryPacketBody), m_GatewayPrivateSignature));
assert(m_GatewayPrivateSignature);
return CompileProtocolHeader().Concat(Crypto::SignMessage(m_ReceiverRid.ToByteVector().Concat(GetQueryHeader()).Concat(m_QueryPacketBody), *m_GatewayPrivateSignature));
}
protected:
Crypto::PrivateSignature const& m_GatewayPrivateSignature; ///< Gateway signature used to sign the query.
const Crypto::PrivateSignature* const m_GatewayPrivateSignature; ///< Gateway signature used to sign the query.
ByteVector m_QueryPacketBody; ///< Whole Query packet along with all the headers.
private:
@ -122,7 +123,7 @@ namespace MWR::C3::Core::ProceduresG2X
}
/// Forwarded constructors.
using Query::Query;
using Query<ProcedureNumber>::Query;
};
/// Helper to template creating Queries to Route
@ -132,7 +133,7 @@ namespace MWR::C3::Core::ProceduresG2X
{
/// Forwarded constructors.
using Query::Query;
using Query<ProcedureNumber>::Query;
};
////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////

View File

@ -21,6 +21,8 @@ namespace MWR::C3::Core
virtual void DetachDevice(DeviceId const& iidOfDeviceToDetach);
protected:
using Distributor::On;
/// A protected constructor. @see Distributor::Distributor.
/// @param callbackOnLog callback fired whenever a new Log entry is being added.
/// @param interfaceFactory reference to Interface factory.