From 4153da3c16d184a1e6ffa15d2c504c6e3f6b0e1f Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Roman=20Smr=C5=BE?= Date: Sat, 19 Aug 2023 09:42:34 +0200 Subject: Network: move secure channel to protocol module --- src/network/protocol.h | 35 +++++++++++++++++++++++++++++++++++ 1 file changed, 35 insertions(+) (limited to 'src/network/protocol.h') diff --git a/src/network/protocol.h b/src/network/protocol.h index 4794ba6..88abf67 100644 --- a/src/network/protocol.h +++ b/src/network/protocol.h @@ -1,5 +1,7 @@ #pragma once +#include "channel.h" + #include #include @@ -45,6 +47,12 @@ public: PollResult poll(); + using ChannelState = variant, + shared_ptr, + Stored, + unique_ptr>; + Connection connect(sockaddr_in6 addr); bool recvfrom(vector & buffer, sockaddr_in6 & addr); @@ -84,6 +92,9 @@ public: void close(); + // temporary: + ChannelState & channel(); + private: unique_ptr p; }; @@ -121,4 +132,28 @@ struct NetworkProtocol::Header const vector items; }; +class ReplyBuilder +{ +public: + void header(NetworkProtocol::Header::Item &&); + void body(const Ref &); + + const vector & header() const { return mheader; } + vector body() const; + +private: + vector mheader; + vector mbody; +}; + +struct WaitingRef +{ + const Storage storage; + const PartialRef ref; + vector missing; + + optional check(); + optional check(ReplyBuilder &); +}; + } -- cgit v1.2.3