00001 /* 00002 * 00003 * Copyright (C) 2008-2010, OFFIS e.V. 00004 * All rights reserved. See COPYRIGHT file for details. 00005 * 00006 * This software and supporting documentation were developed by 00007 * 00008 * OFFIS e.V. 00009 * R&D Division Health 00010 * Escherweg 2 00011 * D-26121 Oldenburg, Germany 00012 * 00013 * 00014 * Module: dcmnet 00015 * 00016 * Author: Michael Onken 00017 * 00018 * Purpose: Base class for Service Class Users (SCUs) 00019 * 00020 * Last Update: $Author: joergr $ 00021 * Update Date: $Date: 2010-10-14 13:17:22 $ 00022 * CVS/RCS Revision: $Revision: 1.13 $ 00023 * Status: $State: Exp $ 00024 * 00025 * CVS/RCS Log at end of file 00026 * 00027 */ 00028 00029 #ifndef SCU_H 00030 #define SCU_H 00031 00032 #include "dcmtk/config/osconfig.h" /* make sure OS specific configuration is included first */ 00033 00034 #include "dcmtk/dcmdata/dctk.h" /* Covers most common dcmdata classes */ 00035 #include "dcmtk/dcmnet/dcompat.h" 00036 #include "dcmtk/dcmnet/dimse.h" /* DIMSE network layer */ 00037 #include "dcmtk/dcmnet/dcasccff.h" /* For reading a association config file */ 00038 #include "dcmtk/dcmnet/dcasccfg.h" /* For holding association cfg file infos */ 00039 00040 #ifdef WITH_ZLIB 00041 #include <zlib.h> /* for zlibVersion() */ 00042 #endif 00043 00044 00047 enum DcmCloseAssociationType 00048 { 00050 DCMSCU_RELEASE_ASSOCIATION, 00052 DCMSCU_ABORT_ASSOCIATION, 00054 DCMSCU_PEER_REQUESTED_RELEASE, 00056 DCMSCU_PEER_ABORTED_ASSOCIATION 00057 }; 00058 00059 00062 class FINDResponse 00063 { 00064 00065 public: 00066 00068 FINDResponse(); 00069 00071 virtual ~FINDResponse(); 00072 00074 Uint16 m_messageIDRespondedTo; 00075 00076 // Mandatory response field 00077 OFString m_affectedSOPClassUID; 00078 00080 DcmDataset *m_dataset; 00081 00083 Uint16 m_status; 00084 }; 00085 00086 00089 class FINDResponses 00090 { 00091 00092 public: 00093 FINDResponses(); 00094 virtual ~FINDResponses(); 00095 Uint32 numResults() const; 00096 void add(FINDResponse *rsp); 00097 OFListIterator(FINDResponse *) begin(); 00098 OFListIterator(FINDResponse *) end(); 00099 00100 private: 00101 OFList<FINDResponse *> m_responses; 00102 }; 00103 00110 class DcmSCU 00111 { 00112 00113 public: 00114 00117 DcmSCU(); 00118 00121 virtual ~DcmSCU(); 00122 00129 OFCondition addPresentationContext(const OFString &abstractSyntax, 00130 const OFList<OFString> &xferSyntaxes); 00131 00135 virtual OFCondition initNetwork(); 00136 00142 virtual OFCondition negotiateAssociation(); 00143 00151 T_ASC_PresentationContextID findPresentationContextID(const OFString &abstractSyntax, 00152 const OFString &transferSyntax); 00153 00160 virtual OFCondition sendECHORequest(const T_ASC_PresentationContextID presID); 00161 00190 virtual OFCondition sendSTORERequest(const T_ASC_PresentationContextID presID, 00191 const OFString &dicomFile, 00192 DcmDataset *dset, 00193 DcmDataset *&rspCommandSet, 00194 DcmDataset *&rspStatusDetail, 00195 Uint16 &rspStatusCode); 00196 00209 virtual OFCondition sendFINDRequest(T_ASC_PresentationContextID presID, 00210 DcmDataset *queryKeys, 00211 FINDResponses *responses); 00212 00223 virtual OFCondition handleFINDResponse(Uint16 presContextID, 00224 FINDResponse *response, 00225 OFBool &waitForNextResponse); 00226 00234 virtual OFCondition sendCANCELRequest(Uint16 presContextID); 00235 00249 virtual OFCondition sendACTIONRequest(const T_ASC_PresentationContextID presID, 00250 const OFString &sopInstanceUID, 00251 const Uint16 actionTypeID, 00252 DcmDataset *reqDataset, 00253 Uint16 &rspStatusCode); 00254 00265 virtual OFCondition handleEVENTREPORTRequest(DcmDataset *&reqDataset, 00266 Uint16 &eventTypeID, 00267 const int timeout = 0); 00268 00272 virtual void closeAssociation(const DcmCloseAssociationType closeType); 00273 00274 /* Set methods */ 00275 00279 void setMaxReceivePDULength(const unsigned long maxRecPDU); 00280 00284 void setDIMSEBlockingMode(const T_DIMSE_BlockingMode blockingMode); 00285 00289 void setAETitle(const OFString &myAETtitle); 00290 00294 void setPeerHostName(const OFString &peerHostName); 00295 00299 void setPeerAETitle(const OFString &peerAETitle); 00300 00304 void setPeerPort(const Uint16 peerPort); 00305 00311 void setDIMSETimeout(const Uint32 dimseTimeout); 00312 00317 void setACSETimeout(const Uint32 acseTimeout); 00318 00323 void setAssocConfigFileAndProfile(const OFString &filename, 00324 const OFString &profile); 00325 00330 void setVerbosePCMode(const OFBool mode); 00331 00332 /* Get methods */ 00333 00337 OFBool isConnected() const; 00338 00342 Uint32 getMaxReceivePDULength() const; 00343 00347 T_DIMSE_BlockingMode getDIMSEBlockingMode() const; 00348 00352 const OFString &getAETitle() const; 00353 00357 const OFString &getPeerHostName() const; 00358 00362 const OFString &getPeerAETitle() const; 00363 00367 Uint16 getPeerPort() const; 00368 00373 Uint32 getDIMSETimeout() const; 00374 00379 Uint32 getACSETimeout() const; 00380 00386 OFBool getVerbosePCMode() const; 00387 00391 OFBool getTLSEnabled() const; 00392 00393 protected: 00394 00410 OFCondition sendDIMSEMessage(const T_ASC_PresentationContextID presID, 00411 T_DIMSE_Message *msg, 00412 DcmDataset *dataObject, 00413 DIMSE_ProgressCallback callback, 00414 void *callbackContext, 00415 DcmDataset **commandSet = NULL); 00416 00426 OFCondition getDatasetInfo(DcmDataset *dataset, 00427 OFString &sopClassUID, 00428 OFString &sopInstanceUID, 00429 E_TransferSyntax &transferSyntax); 00430 00431 00436 OFCondition useSecureConnection(DcmTransportLayer *tlayer); 00437 00459 OFCondition receiveDIMSECommand(T_ASC_PresentationContextID *presID, 00460 T_DIMSE_Message *msg, 00461 DcmDataset **statusDetail, 00462 DcmDataset **commandSet = NULL, 00463 const Uint32 timeout = 0); 00464 00478 OFCondition receiveDIMSEDataset(T_ASC_PresentationContextID *presID, 00479 DcmDataset **dataObject, 00480 DIMSE_ProgressCallback callback, 00481 void *callbackContext); 00482 00491 void findPresentationContext(const T_ASC_PresentationContextID presID, 00492 OFString &abstractSyntax, 00493 OFString &transferSyntax); 00494 00505 virtual Uint16 checkEVENTREPORTRequest(T_DIMSE_N_EventReportRQ &request, 00506 DcmDataset *reqDataset); 00507 00508 private: 00509 00513 DcmSCU(const DcmSCU &src); 00514 00519 DcmSCU &operator=(const DcmSCU &src); 00520 00522 T_ASC_Association *m_assoc; 00523 00525 T_ASC_Network *m_net; 00526 00528 T_ASC_Parameters *m_params; 00529 00531 OFString m_assocConfigFilename; 00532 00534 OFString m_assocConfigProfile; 00535 00538 struct DcmSCUPresContext { 00540 OFString abstractSyntaxName; 00542 OFList<OFString> transferSyntaxes; 00543 }; 00544 00546 OFList<DcmSCUPresContext> m_presContexts; 00547 00549 OFString m_assocConfigFile; 00550 00552 T_DIMSE_Message *m_openDIMSERequest; 00553 00555 Uint32 m_maxReceivePDULength; 00556 00558 T_DIMSE_BlockingMode m_blockMode; 00559 00561 OFString m_ourAETitle; 00562 00564 OFString m_peer; 00565 00567 OFString m_peerAETitle; 00568 00570 Uint16 m_peerPort; 00571 00573 Uint32 m_dimseTimeout; 00574 00576 Uint32 m_acseTimeout; 00577 00579 OFBool m_verbosePCMode; 00580 00584 Uint16 nextMessageID(); 00585 00586 }; 00587 00588 #endif // SCU_H 00589 00590 00591 /* 00592 ** CVS Log 00593 ** $Log: scu.h,v $ 00594 ** Revision 1.13 2010-10-14 13:17:22 joergr 00595 ** Updated copyright header. Added reference to COPYRIGHT file. 00596 ** 00597 ** Revision 1.12 2010-10-07 12:54:07 joergr 00598 ** Fixed minor Doxygen API documentation issues (added backslash in order to 00599 ** avoid that the short description ends at the first period). 00600 ** 00601 ** Revision 1.11 2010-06-24 09:21:54 joergr 00602 ** Revised comment to make clear that the parameter "presID" shall never be 0 00603 ** for the sendACTIONRequest() method. 00604 ** 00605 ** Revision 1.10 2010-06-22 15:45:27 joergr 00606 ** Introduced new enumeration type to be used for closeAssociation(). 00607 ** Further code cleanup. Renamed some methods, variables, types and so on. 00608 ** 00609 ** Revision 1.9 2010-06-17 17:11:27 joergr 00610 ** Added preliminary support for N-EVENT-REPORT to DcmSCU. Some further code 00611 ** cleanups and enhancements. Renamed some methods. Revised documentation. 00612 ** 00613 ** Revision 1.8 2010-06-09 16:09:01 joergr 00614 ** Added preliminary support for N-ACTION to DcmSCU. Some further code cleanups 00615 ** and enhancements. 00616 ** 00617 ** Revision 1.7 2010-06-08 17:54:12 onken 00618 ** Added C-FIND functionality to DcmSCU. Some code cleanups. Fixed 00619 ** memory leak sometimes occuring during association configuration. 00620 ** 00621 ** Revision 1.6 2010-04-29 16:13:28 onken 00622 ** Made SCU class independent from dcmtls, i.e. outsourced TLS API. Added 00623 ** direct API support for sending C-STORE requests. Further API changes and 00624 ** some bugs fixed. 00625 ** 00626 ** Revision 1.5 2009-12-21 17:00:32 onken 00627 ** Fixed API documentation to keep doxygen quiet. 00628 ** 00629 ** Revision 1.4 2009-12-21 15:33:55 onken 00630 ** Added documentation and refactored / enhanced some code. 00631 ** 00632 ** Revision 1.3 2009-12-17 09:12:10 onken 00633 ** Fixed other scu and scp base class compile issues. 00634 ** 00635 ** Revision 1.2 2009-12-17 09:05:15 onken 00636 ** Fixed typo resulting in build failure. 00637 ** 00638 ** Revision 1.1 2009-12-17 09:02:44 onken 00639 ** Added base classes for SCU and SCP implementations. 00640 ** 00641 ** Revision 1.2 2009-12-02 14:26:05 uli 00642 ** Stop including dcdebug.h which was removed. 00643 ** 00644 ** Revision 1.1 2008-09-29 13:51:52 onken 00645 ** Initial checkin of module dcmppscu implementing an MPPS commandline client. 00646 ** 00647 */