15#include <kcenon/network/facade/tcp_facade.h>
27std::unique_ptr<network::dicom_server>
35 if (config.
port == 0) {
46 return std::make_unique<network::dicom_server>(config);
56 if (config.
host.empty()) {
60 if (config.
port == 0) {
71 kcenon::network::facade::tcp_facade facade;
72 kcenon::network::facade::tcp_facade::client_config client_cfg;
73 client_cfg.host = config.
host;
74 client_cfg.port = config.
port;
75 client_cfg.client_id =
"pacs_client";
76 client_cfg.timeout = config.
timeout;
79 client_cfg.ca_cert_path = config.
tls.
ca_path.string();
84 if (client_result.is_err()) {
87 auto client = std::move(client_result.value());
90 std::promise<std::error_code> connect_promise;
91 auto connect_future = connect_promise.get_future();
95#if defined(__clang__) || defined(__GNUC__)
96#pragma GCC diagnostic push
97#pragma GCC diagnostic ignored "-Wdeprecated-declarations"
99 client->set_connected_callback([&connect_promise]() {
100 connect_promise.set_value(std::error_code{});
103 client->set_error_callback([&connect_promise](std::error_code ec) {
105 connect_promise.set_value(ec);
106 }
catch (
const std::future_error&) {
110#if defined(__clang__) || defined(__GNUC__)
111#pragma GCC diagnostic pop
115 auto start_result = client->start(config.
host, config.
port);
116 if (start_result.is_err()) {
121 auto status = connect_future.wait_for(config.
timeout);
122 if (status == std::future_status::timeout) {
123 (void)client->stop();
128 auto ec = connect_future.get();
130 (void)client->stop();
138 }
catch (
const std::exception& e) {
140 error_info(std::string(
"Connection failed: ") + e.what()));
147 std::chrono::milliseconds timeout) {
164 if (!std::filesystem::exists(config.
cert_path)) {
166 "TLS configuration error: certificate file not found: " +
171 if (!std::filesystem::exists(config.
key_path)) {
173 "TLS configuration error: key file not found: " +
178 if (!config.
ca_path.empty() && !std::filesystem::exists(config.
ca_path)) {
180 "TLS configuration error: CA certificate file not found: " +
188 "TLS configuration error: unsupported TLS version"));
200 std::shared_ptr<network_system::session::messaging_session> session) {
204 return std::make_shared<dicom_session>(std::move(session));
209 std::shared_ptr<network_system::session::secure_session> session) {
213 return std::make_shared<dicom_session>(std::move(session));
218 std::shared_ptr<kcenon::network::interfaces::i_session> session) {
222 return std::make_shared<dicom_session>(std::move(session));
Simple result type for error handling when common_system is unavailable.
static Result< std::monostate > configure_tls(const tls_config &config)
Configure TLS settings.
static std::unique_ptr< network::dicom_server > create_server(const network::server_config &config, const tls_config &tls_cfg={})
Create a DICOM server using network_system.
std::shared_ptr< dicom_session > session_ptr
Session pointer type.
static session_ptr wrap_session(std::shared_ptr< network_system::session::messaging_session > session)
Wrap a network_system session for DICOM communication.
static Result< session_ptr > connect(const connection_config &config)
Connect to a remote DICOM peer.
Multi-threaded DICOM server for handling multiple associations.
DICOM session wrapper for network_system sessions.
auto factory_result(kcenon::common::Result< T > result) -> kcenon::common::Result< T >
kcenon::common::Result< T > Result
Result type alias for PACS operations.
kcenon::common::error_info error_info
Error information type.
Adapter for integrating network_system for DICOM protocol.
Configuration for client connections.
std::string host
Remote host address.
std::chrono::milliseconds timeout
Connection timeout.
tls_config tls
TLS configuration (optional)
uint16_t port
Remote port.
Configuration for TLS/SSL secure transport.
bool enabled
Enable TLS for connections.
enum kcenon::pacs::integration::tls_config::tls_version min_version
bool is_valid() const noexcept
Check if TLS configuration is valid.
std::filesystem::path cert_path
Path to certificate file (PEM format)
std::filesystem::path ca_path
Path to CA certificate file for verification (optional)
bool verify_peer
Verify peer certificate.
std::filesystem::path key_path
Path to private key file (PEM format)
Configuration for DICOM server.
uint16_t port
Port to listen on (default: 11112, standard alternate DICOM port)
std::string ae_title
Application Entity Title for this server (16 chars max)