1 /* 2 * 3 * Copyright (C) 1998-2018, OFFIS e.V. 4 * All rights reserved. See COPYRIGHT file for details. 5 * 6 * This software and supporting documentation were developed by 7 * 8 * OFFIS e.V. 9 * R&D Division Health 10 * Escherweg 2 11 * D-26121 Oldenburg, Germany 12 * 13 * 14 * Module: dcmnet 15 * 16 * Author: Marco Eichelberg 17 * 18 * Purpose: 19 * classes: DcmTransportLayer 20 * 21 */ 22 23 #ifndef DCMLAYER_H 24 #define DCMLAYER_H 25 26 #include "dcmtk/config/osconfig.h" /* make sure OS specific configuration is included first */ 27 28 #include "dcmtk/ofstd/oftypes.h" 29 #include "dcmtk/ofstd/ofstring.h" 30 31 #define INCLUDE_UNISTD 32 #include "dcmtk/ofstd/ofstdinc.h" 33 #include "dcmtk/ofstd/ofutil.h" 34 35 #include "dcmtk/dcmnet/dndefine.h" 36 #include "dcmtk/dcmnet/dntypes.h" 37 38 /** @file dcmlayer.h 39 * @brief type definitions and classes for transport connections 40 */ 41 42 /** this enum represents the result of a transport layer operation 43 * which may be a transparent TCP/IP or a secure TLS operation. 44 */ 45 enum DcmTransportLayerStatus 46 { 47 /** successful operation 48 */ 49 TCS_ok, 50 51 /** operation cannot be performed because transport connection 52 * object was not allocated. 53 */ 54 TCS_noConnection, 55 56 /** operation failed due to an error within the TLS protocol layer 57 */ 58 TCS_tlsError, 59 60 /** operation failed because an illegal parameter was passed 61 */ 62 TCS_illegalCall, 63 64 /** unspecified error 65 */ 66 TCS_unspecifiedError 67 }; 68 69 class DcmTransportConnection; 70 71 /** factory class which creates transport layer connections. 72 * Base class only supports transparent TCP connections, subclasses 73 * may also support secure transport layer connections. 74 */ 75 class DCMTK_DCMNET_EXPORT DcmTransportLayer 76 { 77 public: 78 79 /** constructor. 80 */ DcmTransportLayer()81 DcmTransportLayer() { /* empty */ } 82 83 /** move constructor. 84 * @param rhs an rvalue reference to another DcmTransportLayer object that 85 * will be moved. 86 */ DcmTransportLayer(OFrvalue_ref (DcmTransportLayer)rhs)87 DcmTransportLayer(OFrvalue_ref(DcmTransportLayer) rhs) { OFstatic_cast(void, rhs); } 88 89 /** move assignment. 90 * @param rhs an rvalue reference to another DcmTransportLayer object that will 91 * be move assigned. 92 * @return *this. 93 */ OFrvalue_ref(DcmTransportLayer)94 DcmTransportLayer& operator=(OFrvalue_ref(DcmTransportLayer) rhs) { OFstatic_cast(void, rhs); return *this; } 95 96 /// destructor 97 virtual ~DcmTransportLayer(); 98 99 /** factory method that returns a new transport connection for the 100 * given socket. Depending on the second parameter, either a transparent 101 * or a secure connection is established. If the object cannot be created 102 * (e. g. because no secure layer is available), returns NULL. 103 * @param openSocket TCP/IP socket to be used for the transport connection. 104 * the connection must already be established on socket level. If a non-null 105 * pointer is returned, the new connection object takes over control of the socket. 106 * @param useSecureLayer if true, a secure layer is used. If false, a 107 * transparent layer is used. 108 * @return pointer to new connection object if successful, NULL otherwise. 109 */ 110 virtual DcmTransportConnection *createConnection(DcmNativeSocketType openSocket, OFBool useSecureLayer); 111 112 private: 113 114 /// private undefined copy constructor 115 DcmTransportLayer(const DcmTransportLayer&); 116 117 /// private undefined assignment operator 118 DcmTransportLayer& operator=(const DcmTransportLayer&); 119 120 }; 121 122 123 #endif 124