Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Rename ringbuffer namespaces to be more accurate - tls to tcp and quic to udp #6344

Merged
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
4 changes: 2 additions & 2 deletions src/enclave/client_session.h
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,7 @@
#pragma once

#include "http/http_builder.h"
#include "tls/msg_types.h"
#include "tcp/msg_types.h"

namespace ccf
{
Expand Down Expand Up @@ -43,7 +43,7 @@ namespace ccf
const HandleErrorCallback e = nullptr)
{
RINGBUFFER_WRITE_MESSAGE(
::tls::tls_connect, to_host, client_session_id, hostname, service);
::tcp::tcp_connect, to_host, client_session_id, hostname, service);
handle_data_cb = f;
handle_error_cb = e;
}
Expand Down
32 changes: 17 additions & 15 deletions src/enclave/rpc_sessions.h
Original file line number Diff line number Diff line change
Expand Up @@ -16,14 +16,14 @@
// ok for now, as we only have an echo service for now
#include "http/responder_lookup.h"
#include "node/rpc/custom_protocol_subsystem.h"
#include "quic/msg_types.h"
#include "quic/quic_session.h"
#include "rpc_handler.h"
#include "tls/cert.h"
#include "tls/client.h"
#include "tls/context.h"
#include "tls/plaintext_server.h"
#include "tls/server.h"
#include "udp/msg_types.h"

#include <limits>
#include <map>
Expand Down Expand Up @@ -365,7 +365,7 @@ namespace ccf
listen_interface_id);

RINGBUFFER_WRITE_MESSAGE(
::tls::tls_stop, to_host, id, std::string("Session refused"));
::tcp::tcp_stop, to_host, id, std::string("Session refused"));
}
else if (
per_listen_interface.open_sessions >=
Expand All @@ -380,7 +380,7 @@ namespace ccf
per_listen_interface.max_open_sessions_hard);

RINGBUFFER_WRITE_MESSAGE(
::tls::tls_stop, to_host, id, std::string("Session refused"));
::tcp::tcp_stop, to_host, id, std::string("Session refused"));
}
else if (
per_listen_interface.open_sessions >=
Expand Down Expand Up @@ -449,7 +449,7 @@ namespace ccf
{
// We know it's a custom protocol, but the session creation function
// hasn't been registered yet, so we keep a nullptr until the first
// udp::inbound message.
// udp::udp_inbound message.
sessions.insert(
std::make_pair(id, std::make_pair(listen_interface_id, nullptr)));
}
Expand Down Expand Up @@ -600,14 +600,14 @@ namespace ccf
messaging::Dispatcher<ringbuffer::Message>& disp)
{
DISPATCHER_SET_MESSAGE_HANDLER(
disp, ::tls::tls_start, [this](const uint8_t* data, size_t size) {
disp, ::tcp::tcp_start, [this](const uint8_t* data, size_t size) {
auto [new_tls_id, listen_interface_name] =
ringbuffer::read_message<::tls::tls_start>(data, size);
ringbuffer::read_message<::tcp::tcp_start>(data, size);
accept(new_tls_id, listen_interface_name);
});

DISPATCHER_SET_MESSAGE_HANDLER(
disp, ::tls::tls_inbound, [this](const uint8_t* data, size_t size) {
disp, ::tcp::tcp_inbound, [this](const uint8_t* data, size_t size) {
auto id = serialized::peek<ccf::tls::ConnID>(data, size);

auto search = sessions.find(id);
Expand All @@ -622,27 +622,28 @@ namespace ccf
});

DISPATCHER_SET_MESSAGE_HANDLER(
disp, ::tls::tls_close, [this](const uint8_t* data, size_t size) {
auto [id] = ringbuffer::read_message<::tls::tls_close>(data, size);
disp, ::tcp::tcp_close, [this](const uint8_t* data, size_t size) {
auto [id] = ringbuffer::read_message<::tcp::tcp_close>(data, size);
remove_session(id);
});

DISPATCHER_SET_MESSAGE_HANDLER(
disp, udp::start, [this](const uint8_t* data, size_t size) {
disp, udp::udp_start, [this](const uint8_t* data, size_t size) {
auto [new_id, listen_interface_name] =
ringbuffer::read_message<udp::start>(data, size);
ringbuffer::read_message<udp::udp_start>(data, size);
accept(new_id, listen_interface_name, true);
});

DISPATCHER_SET_MESSAGE_HANDLER(
disp, udp::inbound, [this](const uint8_t* data, size_t size) {
disp, udp::udp_inbound, [this](const uint8_t* data, size_t size) {
auto id = serialized::peek<int64_t>(data, size);

auto search = sessions.find(id);
if (search == sessions.end())
{
LOG_DEBUG_FMT(
"Ignoring udp::inbound for unknown or refused session: {}", id);
"Ignoring udp::udp_inbound for unknown or refused session: {}",
id);
return;
}
else if (!search->second.second && custom_protocol_subsystem)
Expand All @@ -659,7 +660,8 @@ namespace ccf
{
LOG_DEBUG_FMT(
"Failure to create custom protocol session because of "
"unknown interface '{}', ignoring udp::inbound for session: "
"unknown interface '{}', ignoring udp::udp_inbound for "
"session: "
"{}",
interface_id,
id);
Expand All @@ -674,7 +676,7 @@ namespace ccf
{
LOG_DEBUG_FMT(
"Failure to create custom protocol session, ignoring "
"udp::inbound for session: {}",
"udp::udp_inbound for session: {}",
id);
return;
}
Expand Down
4 changes: 2 additions & 2 deletions src/enclave/session.h
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,7 @@

#include "ccf/node/session.h"
#include "ds/thread_messaging.h"
#include "tls/msg_types.h"
#include "tcp/msg_types.h"

#include <span>

Expand Down Expand Up @@ -34,7 +34,7 @@ namespace ccf
// that eventually invokes the virtual handle_incoming_data_thread()
void handle_incoming_data(std::span<const uint8_t> data) override
{
auto [_, body] = ringbuffer::read_message<::tls::tls_inbound>(data);
auto [_, body] = ringbuffer::read_message<::tcp::tcp_inbound>(data);

auto msg = std::make_unique<::threading::Tmsg<SendRecvMsg>>(
&handle_incoming_data_cb);
Expand Down
14 changes: 7 additions & 7 deletions src/enclave/tls_session.h
Original file line number Diff line number Diff line change
Expand Up @@ -7,8 +7,8 @@
#include "ds/ring_buffer.h"
#include "ds/thread_messaging.h"
#include "enclave/session.h"
#include "tcp/msg_types.h"
#include "tls/context.h"
#include "tls/msg_types.h"
#include "tls/tls.h"

#include <exception>
Expand All @@ -32,7 +32,7 @@ namespace ccf

protected:
ringbuffer::WriterPtr to_host;
::tls::ConnID session_id;
::tcp::ConnID session_id;
size_t execution_thread;

private:
Expand Down Expand Up @@ -87,7 +87,7 @@ namespace ccf

virtual ~TLSSession()
{
RINGBUFFER_WRITE_MESSAGE(::tls::tls_closed, to_host, session_id);
RINGBUFFER_WRITE_MESSAGE(::tcp::tcp_closed, to_host, session_id);
}

SessionStatus get_status() const
Expand Down Expand Up @@ -530,7 +530,7 @@ namespace ccf
case closed:
{
RINGBUFFER_WRITE_MESSAGE(
::tls::tls_stop,
::tcp::tcp_stop,
to_host,
session_id,
std::string("Session closed"));
Expand All @@ -540,15 +540,15 @@ namespace ccf
case authfail:
{
RINGBUFFER_WRITE_MESSAGE(
::tls::tls_stop,
::tcp::tcp_stop,
to_host,
session_id,
std::string("Authentication failed"));
}
case error:
{
RINGBUFFER_WRITE_MESSAGE(
::tls::tls_stop, to_host, session_id, std::string("Error"));
::tcp::tcp_stop, to_host, session_id, std::string("Error"));
break;
}

Expand All @@ -562,7 +562,7 @@ namespace ccf
{
// Either write all of the data or none of it.
auto wrote = RINGBUFFER_TRY_WRITE_MESSAGE(
::tls::tls_outbound,
::tcp::tcp_outbound,
to_host,
session_id,
serializer::ByteRange{buf, len});
Expand Down
42 changes: 21 additions & 21 deletions src/host/rpc_connections.h
Original file line number Diff line number Diff line change
Expand Up @@ -2,8 +2,8 @@
// Licensed under the Apache 2.0 License.
#pragma once

#include "../quic/msg_types.h"
#include "../tls/msg_types.h"
#include "../tcp/msg_types.h"
#include "../udp/msg_types.h"
#include "tcp.h"
#include "udp.h"

Expand Down Expand Up @@ -50,10 +50,10 @@ namespace asynchost
class ConnIDGenerator
{
public:
/// This is the same as ccf::tls::ConnID and quic::ConnID
/// This is the same as ccf::tls::ConnID and udp::ConnID
using ConnID = int64_t;
static_assert(std::is_same<::tls::ConnID, quic::ConnID>());
static_assert(std::is_same<::tls::ConnID, ConnID>());
static_assert(std::is_same<::tcp::ConnID, udp::ConnID>());
static_assert(std::is_same<::tcp::ConnID, ConnID>());

ConnIDGenerator() : next_id(1) {}

Expand Down Expand Up @@ -125,7 +125,7 @@ namespace asynchost
parent.mark_active(id);

RINGBUFFER_WRITE_MESSAGE(
::tls::tls_inbound,
::tcp::tcp_inbound,
parent.to_enclave,
id,
serializer::ByteRange{data, len});
Expand All @@ -143,7 +143,7 @@ namespace asynchost
{
if constexpr (isTCP<ConnType>())
{
RINGBUFFER_WRITE_MESSAGE(::tls::tls_close, parent.to_enclave, id);
RINGBUFFER_WRITE_MESSAGE(::tcp::tcp_close, parent.to_enclave, id);
}
}
};
Expand Down Expand Up @@ -189,14 +189,14 @@ namespace asynchost
if constexpr (isTCP<ConnType>())
{
RINGBUFFER_WRITE_MESSAGE(
::tls::tls_start, parent.to_enclave, peer_id, interface_name);
::tcp::tcp_start, parent.to_enclave, peer_id, interface_name);
return;
}

if constexpr (isUDP<ConnType>())
{
RINGBUFFER_WRITE_MESSAGE(
udp::start, parent.to_enclave, peer_id, interface_name);
udp::udp_start, parent.to_enclave, peer_id, interface_name);
return;
}
}
Expand All @@ -210,7 +210,7 @@ namespace asynchost

LOG_DEBUG_FMT("rpc udp read into ring buffer {}: {}", id, len);
RINGBUFFER_WRITE_MESSAGE(
udp::inbound,
udp::udp_inbound,
parent.to_enclave,
id,
addr_family,
Expand Down Expand Up @@ -345,7 +345,7 @@ namespace asynchost
// Invalidating the TCP socket will result in the handle being closed. No
// more messages will be read from or written to the TCP socket.
sockets[id] = nullptr;
RINGBUFFER_WRITE_MESSAGE(::tls::tls_close, to_enclave, id);
RINGBUFFER_WRITE_MESSAGE(::tcp::tcp_close, to_enclave, id);

return true;
}
Expand All @@ -367,9 +367,9 @@ namespace asynchost
messaging::Dispatcher<ringbuffer::Message>& disp)
{
DISPATCHER_SET_MESSAGE_HANDLER(
disp, ::tls::tls_outbound, [this](const uint8_t* data, size_t size) {
disp, ::tcp::tcp_outbound, [this](const uint8_t* data, size_t size) {
auto [id, body] =
ringbuffer::read_message<::tls::tls_outbound>(data, size);
ringbuffer::read_message<::tcp::tcp_outbound>(data, size);

ConnID connect_id = (ConnID)id;
LOG_DEBUG_FMT("rpc write from enclave {}: {}", connect_id, body.size);
Expand All @@ -378,9 +378,9 @@ namespace asynchost
});

DISPATCHER_SET_MESSAGE_HANDLER(
disp, ::tls::tls_connect, [this](const uint8_t* data, size_t size) {
disp, ::tcp::tcp_connect, [this](const uint8_t* data, size_t size) {
auto [id, host, port] =
ringbuffer::read_message<::tls::tls_connect>(data, size);
ringbuffer::read_message<::tcp::tcp_connect>(data, size);

LOG_DEBUG_FMT("rpc connect request from enclave {}", id);

Expand All @@ -396,17 +396,17 @@ namespace asynchost
});

DISPATCHER_SET_MESSAGE_HANDLER(
disp, ::tls::tls_stop, [this](const uint8_t* data, size_t size) {
disp, ::tcp::tcp_stop, [this](const uint8_t* data, size_t size) {
auto [id, msg] =
ringbuffer::read_message<::tls::tls_stop>(data, size);
ringbuffer::read_message<::tcp::tcp_stop>(data, size);

LOG_DEBUG_FMT("rpc stop from enclave {}, {}", id, msg);
stop(id);
});

DISPATCHER_SET_MESSAGE_HANDLER(
disp, ::tls::tls_closed, [this](const uint8_t* data, size_t size) {
auto [id] = ringbuffer::read_message<::tls::tls_closed>(data, size);
disp, ::tcp::tcp_closed, [this](const uint8_t* data, size_t size) {
auto [id] = ringbuffer::read_message<::tcp::tcp_closed>(data, size);

LOG_DEBUG_FMT("rpc closed from enclave {}", id);
close(id);
Expand All @@ -417,9 +417,9 @@ namespace asynchost
messaging::Dispatcher<ringbuffer::Message>& disp)
{
DISPATCHER_SET_MESSAGE_HANDLER(
disp, udp::outbound, [this](const uint8_t* data, size_t size) {
disp, udp::udp_outbound, [this](const uint8_t* data, size_t size) {
auto [id, addr_family, addr_data, body] =
ringbuffer::read_message<udp::outbound>(data, size);
ringbuffer::read_message<udp::udp_outbound>(data, size);

ConnID connect_id = (ConnID)id;
LOG_DEBUG_FMT("rpc write from enclave {}: {}", connect_id, body.size);
Expand Down
2 changes: 0 additions & 2 deletions src/http/error_reporter.h
Original file line number Diff line number Diff line change
Expand Up @@ -2,8 +2,6 @@
// Licensed under the Apache 2.0 License.
#pragma once

#include "tls/msg_types.h"

namespace http
{
class ErrorReporter
Expand Down
4 changes: 2 additions & 2 deletions src/http/http2_session.h
Original file line number Diff line number Diff line change
Expand Up @@ -18,10 +18,10 @@ namespace http
protected:
std::shared_ptr<ccf::TLSSession> tls_io;
std::shared_ptr<ErrorReporter> error_reporter;
::tls::ConnID session_id;
::tcp::ConnID session_id;

HTTP2Session(
::tls::ConnID session_id_,
::tcp::ConnID session_id_,
ringbuffer::AbstractWriterFactory& writer_factory,
std::unique_ptr<ccf::tls::Context> ctx,
const std::shared_ptr<ErrorReporter>& error_reporter = nullptr) :
Expand Down
Loading