Skip to content

Commit 05fc30c

Browse files
committed
feat: add experimental TLS domain and Network transport lease
1 parent 1a5a935 commit 05fc30c

25 files changed

Lines changed: 5525 additions & 26 deletions

‎CMakeLists.txt‎

Lines changed: 35 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -161,6 +161,8 @@ option(VIX_ENABLE_SANITIZERS "Enable ASan+UBSan (GCC/Clang only)"
161161
option(VIX_BUILD_EXAMPLES "Build umbrella examples in ./examples" ON)
162162
option(VIX_BUILD_TESTS "Build Vix SDK package and domain tests" OFF)
163163
option(VIX_BUILD_NETWORK "Build the Network domain when its provider is available" ON)
164+
option(VIX_BUILD_TLS_I0B_TESTS "Build the private Linux TLS-I0-B feasibility tests" OFF)
165+
option(VIX_BUILD_TLS_EXPERIMENTAL "Build the uninstalled experimental TLS Domain" OFF)
164166

165167
function(vix_apply_canonical_warnings target)
166168
if (NOT VIX_ENABLE_WARNINGS OR NOT TARGET "${target}")
@@ -183,7 +185,7 @@ endfunction()
183185
function(vix_apply_canonical_warnings_recursively directory)
184186
get_property(_vix_targets DIRECTORY "${directory}" PROPERTY BUILDSYSTEM_TARGETS)
185187
foreach(_vix_target IN LISTS _vix_targets)
186-
if (_vix_target MATCHES "^vix_(standard|files|process|network|concurrency)(_|$)")
188+
if (_vix_target MATCHES "^vix_(standard|files|process|network|concurrency|tls_i0b|tls_experimental)(_|$)")
187189
vix_apply_canonical_warnings("${_vix_target}")
188190
endif()
189191
endforeach()
@@ -221,6 +223,38 @@ else()
221223
set(VIX_HAS_NETWORK FALSE)
222224
endif()
223225

226+
# TLS is explicitly experimental and is never installed/exported. Its current
227+
# lease and runtime qualification is Linux-only; ordinary Vix configurations
228+
# do not discover or link OpenSSL.
229+
if (VIX_BUILD_TLS_EXPERIMENTAL OR VIX_BUILD_TLS_I0B_TESTS)
230+
if (NOT VIX_HAS_NETWORK OR NOT CMAKE_SYSTEM_NAME STREQUAL "Linux")
231+
message(FATAL_ERROR "Experimental TLS currently requires the Linux Network provider.")
232+
endif()
233+
find_package(OpenSSL 3 REQUIRED COMPONENTS SSL Crypto)
234+
add_library(vix_tls_experimental STATIC
235+
domains/tls/src/OpenSslDriver.cpp
236+
domains/tls/src/PrivateChannel.cpp
237+
domains/tls/src/TlsConfig.cpp
238+
domains/tls/src/TlsChannel.cpp)
239+
add_library(vix::tls_experimental ALIAS vix_tls_experimental)
240+
target_compile_features(vix_tls_experimental PUBLIC cxx_std_20)
241+
target_include_directories(vix_tls_experimental
242+
PUBLIC
243+
$<BUILD_INTERFACE:${CMAKE_SOURCE_DIR}/domains/tls/include>
244+
PRIVATE
245+
${CMAKE_SOURCE_DIR}/domains/tls/src
246+
${CMAKE_SOURCE_DIR}/domains/network/src)
247+
target_link_libraries(vix_tls_experimental
248+
PUBLIC vix::network vix::standard
249+
PRIVATE OpenSSL::SSL OpenSSL::Crypto)
250+
if (VIX_BUILD_TLS_I0B_TESTS)
251+
if (NOT VIX_BUILD_TESTS)
252+
message(FATAL_ERROR "VIX_BUILD_TLS_I0B_TESTS requires VIX_BUILD_TESTS.")
253+
endif()
254+
add_subdirectory(domains/tls/tests tls_i0b_tests)
255+
endif()
256+
endif()
257+
224258
# Apply diagnostics only to the canonical Vix domain targets and their owned
225259
# tests. Third-party targets and exported consumer usage requirements are not
226260
# affected.

‎domains/concurrency/tests/CMakeLists.txt‎

Lines changed: 8 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,3 +1,11 @@
1+
# Assertions must remain active in test binaries, including Release.
2+
# Production libraries retain their normal NDEBUG configuration.
3+
if(MSVC)
4+
add_compile_options(/UNDEBUG)
5+
elseif(CMAKE_CXX_COMPILER_ID MATCHES "GNU|Clang")
6+
add_compile_options(-UNDEBUG)
7+
endif()
8+
19
if (CMAKE_SYSTEM_NAME STREQUAL "WASI")
210
if (NOT VIX_WASMTIME_EXECUTABLE OR NOT EXISTS "${VIX_WASMTIME_EXECUTABLE}")
311
message(FATAL_ERROR "WASI Concurrency capability test requires VIX_WASMTIME_EXECUTABLE.")

‎domains/files/tests/CMakeLists.txt‎

Lines changed: 8 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,3 +1,11 @@
1+
# Assertions must remain active in test binaries, including Release.
2+
# Production libraries retain their normal NDEBUG configuration.
3+
if(MSVC)
4+
add_compile_options(/UNDEBUG)
5+
elseif(CMAKE_CXX_COMPILER_ID MATCHES "GNU|Clang")
6+
add_compile_options(-UNDEBUG)
7+
endif()
8+
19
add_executable(vix_files_test files_test.cpp)
210
target_compile_features(vix_files_test PRIVATE cxx_std_20)
311
target_link_libraries(vix_files_test PRIVATE vix::files)

‎domains/network/include/vix/network/Errors.hpp‎

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -22,4 +22,7 @@ namespace vix::network
2222
inline constexpr auto operation_in_progress = vix::ErrorIdentity::define<"vix.network">(32);
2323
inline constexpr auto write_shutdown = vix::ErrorIdentity::define<"vix.network">(33);
2424
inline constexpr auto address_in_use = vix::ErrorIdentity::define<"vix.network">(34);
25+
// The TCP transport has been exclusively transferred to a private Network
26+
// owner; an already-created ordinary operation cannot use it.
27+
inline constexpr auto transport_owned = vix::ErrorIdentity::define<"vix.network">(35);
2528
}

‎domains/network/src/Engine.hpp‎

Lines changed: 37 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -14,6 +14,7 @@
1414
#include <memory>
1515
#include <mutex>
1616
#include <optional>
17+
#include <span>
1718
#include <vector>
1819
#include <variant>
1920
#include <utility>
@@ -215,8 +216,33 @@ namespace vix::network::detail
215216
private:
216217
std::shared_ptr<ProviderCore> provider_;
217218
};
219+
class TcpConnectionState;
218220
template <class T>
219221
class OperationRecord;
222+
class TcpTransportLease
223+
{
224+
public:
225+
TcpTransportLease() noexcept = default;
226+
TcpTransportLease(TcpTransportLease &&) noexcept;
227+
TcpTransportLease(const TcpTransportLease &) = delete;
228+
TcpTransportLease &operator=(TcpTransportLease &&) = delete;
229+
TcpTransportLease &operator=(const TcpTransportLease &) = delete;
230+
~TcpTransportLease();
231+
232+
// Private Network operations authorized by this lease. This class lives
233+
// only in the non-installed engine header, not in the public API.
234+
vix::network::Operation<std::size_t> receive(std::span<std::byte>, OperationOptions = {});
235+
vix::network::Operation<void> send(std::span<const std::byte>, OperationOptions = {});
236+
vix::Result<void> shutdown_write() noexcept;
237+
// Permanently close a claimed transport. Network defers descriptor close
238+
// until active child operations have retired.
239+
void close() noexcept;
240+
241+
private:
242+
explicit TcpTransportLease(std::shared_ptr<TcpConnectionState>) noexcept;
243+
std::shared_ptr<TcpConnectionState> state_;
244+
friend class NetworkAccess;
245+
};
220246
class NetworkAccess
221247
{
222248
public:
@@ -245,7 +271,18 @@ namespace vix::network::detail
245271
static void capture_next_receive_record_for_test(const TcpConnection &, std::shared_ptr<OperationRecord<std::size_t>> &);
246272
static void capture_next_send_record_for_test(const TcpConnection &, std::shared_ptr<OperationRecord<void>> &);
247273
static TransportCountersForTest transport_counters_for_test(const TcpConnection &);
274+
static TransportCountersForTest transport_counters_for_test(const TcpTransportLease &);
275+
// Private TLS integration: returns the provider retained by an exclusive
276+
// transport lease without exposing its native descriptor.
277+
static std::shared_ptr<ProviderCore> provider_for_tls_lease(const TcpTransportLease &) noexcept;
248278
static TcpConnection from_handoff(NativeSocket, ProviderResourceLease);
279+
// Experimental, engine-private ownership transfer. Engine.hpp is not an
280+
// installed header; ordinary SDK consumers cannot access this entrypoint.
281+
static vix::Result<TcpTransportLease> claim_tcp_for_tls(TcpConnection &&);
282+
#ifdef VIX_NETWORK_TEST_CAPTURE
283+
static void set_before_native_receive_hook_for_test(const TcpConnection &,
284+
void (*)(void *) noexcept, void *) noexcept;
285+
#endif
249286
};
250287
// Compatibility spelling for private focused tests only. It is not in any
251288
// installed public header.

0 commit comments

Comments
 (0)