OFFIS DCMTK  Version 3.6.0
scp.h
1 /*
2  *
3  * Copyright (C) 2009-2010, 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: Michael Onken
17  *
18  * Purpose: General SCP class that can be used to implement derived SCP
19  * applications.
20  *
21  * Last Update: $Author: joergr $
22  * Update Date: $Date: 2010-10-14 13:17:22 $
23  * CVS/RCS Revision: $Revision: 1.9 $
24  * Status: $State: Exp $
25  *
26  * CVS/RCS Log at end of file
27  *
28  */
29 
30 #ifndef SCP_H
31 #define SCP_H
32 
33 #include "dcmtk/config/osconfig.h" /* make sure OS specific configuration is included first */
34 
35 #include "dcmtk/oflog/oflog.h"
36 #include "dcmtk/dcmdata/dctk.h" /* Covers most common dcmdata classes */
37 #include "dcmtk/dcmnet/dimse.h" /* DIMSE network layer */
38 #include "dcmtk/dcmnet/dcasccff.h" /* For reading a association config file */
39 #include "dcmtk/dcmnet/dcasccfg.h" /* For holding association cfg file infos */
40 
41 #ifdef WITH_ZLIB
42 #include <zlib.h> /* for zlibVersion() */
43 #endif
44 
45 #ifdef WITH_OPENSSL
46 #include "dcmtk/dcmtls/tlstrans.h"
47 #include "dcmtk/dcmtls/tlslayer.h"
48 #endif
49 
50 
54 {
56  DIC_NODENAME peerName;
60  DIC_AE calledAETitle;
62  int processId;
64  time_t startTime;
67 };
68 
72 enum DcmSCPActionType
73 {
75  DCMSCP_ACTION_UNDEFINED,
77  DCMSCP_ACTION_REFUSE_ASSOCIATION
78 };
79 
82 enum DcmRefuseReasonType
83 {
85  DCMSCP_TOO_MANY_ASSOCIATIONS,
87  DCMSCP_CANNOT_FORK,
89  DCMSCP_BAD_APPLICATION_CONTEXT_NAME,
91  DCMSCP_BAD_APPLICATION_ENTITY_SERVICE,
93  DCMSCP_FORCED,
95  DCMSCP_NO_IMPLEMENTATION_CLASS_UID,
97  DCMSCP_NO_PRESENTATION_CONTEXTS,
99  DCMSCP_INTERNAL_ERROR
100 };
101 
107 {
118  // Fields "reserved" and "result" not included from DUL_PRESENTATIONCONTEXT
119 };
120 
121 
130 class DcmSCP
131 {
132 
133 public:
134 
137  DcmSCP();
138 
141  virtual ~DcmSCP();
142 
143 #ifdef _WIN32
144 
148  OFCondition markAsForkedChild();
149 #endif
150 
155  virtual OFCondition listen();
156 
157 
158  /* ************************************************************* */
159  /* Set methods for configuring SCP behaviour */
160  /* ************************************************************* */
161 
172  virtual OFCondition addPresentationContext(const OFString &abstractSyntax,
173  const OFList<OFString> xferSyntaxes,
174  const T_ASC_SC_ROLE role = ASC_SC_ROLE_DEFAULT,
175  const OFString &profile = "DEFAULT");
176 
181  void setPort(const Uint16 port);
182 
188  void setAETitle(const OFString &aetitle);
189 
196  void setRespondWithCalledAETitle(const OFBool useCalled);
197 
203  virtual OFCondition loadAssociationCfgFile(const OFString &assocFile);
204 
212  virtual OFCondition setAndCheckAssociationProfile(const OFString &profileName);
213 
219  void forceAssociationRefuse(const OFBool doRefuse);
220 
225  void setMaxReceivePDULength(const Uint32 maxRecPDU);
226 
238  OFCondition enableMultiProcessMode(int argc = 0,
239  char *argv[] = NULL);
240 
245  void setMaxAssociations(const Uint16 maxAssocs);
246 
256  void setDIMSEBlockingMode(const T_DIMSE_BlockingMode blockingMode);
257 
262  void setDIMSETimeout(const Uint32 dimseTimeout);
263 
267  void setACSETimeout(const Uint32 acseTimeout);
268 
273  void setVerbosePCMode(const OFBool mode);
274 
275  /* Get methods for SCP settings */
276 
280  Uint16 getPort() const;
281 
286  const OFString &getAETitle() const;
287 
292  OFBool getRespondWithCalledAETitle() const;
293 
297  OFBool getRefuseAssociation() const;
298 
302  Uint32 getMaxReceivePDULength() const;
303 
307  OFBool getSingleProcess() const;
308 
316  Uint16 getMaxAssociations() const;
317 
321  T_DIMSE_BlockingMode getDIMSEBlockingMode() const;
322 
326  Uint32 getDIMSETimeout() const;
327 
331  Uint32 getACSETimeout() const;
332 
338  OFBool getVerbosePCMode() const;
339 
340  /* Get information about current association */
341 
347  OFBool isConnected() const;
348 
353  Uint16 numAssociations() const;
354 
359  OFString getCalledAETitle() const;
360 
364  OFString getPeerAETitle() const;
365 
369  OFString getPeerIP() const;
370 
375  Uint32 getPeerMaxPDULength() const;
376 
377 
378 protected:
379 
380  /* ***********************************************************************
381  * Functions particularly interesting for overwriting in derived classes
382  * ***********************************************************************
383  */
384 
393  const DcmPresentationContextInfo &presContextInfo);
394 
399  virtual void notifyAssociationRequest(const T_ASC_Parameters &params,
400  DcmSCPActionType &desiredAction);
401 
405  virtual void notifyAssociationAcknowledge();
406 
410  virtual void notifyReleaseRequest();
411 
415  virtual void notifyAbortRequest();
416 
420  virtual void notifyAssociationTermination();
421 
426  virtual void notifyDIMSEError(const OFCondition &cond);
427 
433  virtual OFBool stopAfterCurrentAssociation();
434 
442  virtual OFCondition sendSTOREResponse(T_ASC_PresentationContextID presID,
443  T_DIMSE_C_StoreRQ &reqMessage,
444  T_DIMSE_C_StoreRSP &rspMessage,
445  DcmDataset *statusDetail);
446 
454  virtual OFCondition handleECHORequest(T_DIMSE_C_EchoRQ &reqMessage,
455  T_ASC_PresentationContextID presID);
456 
468  T_ASC_PresentationContextID presID,
469  DcmDataset *&reqDataset,
470  Uint16 &eventTypeID);
471 
482  virtual Uint16 checkEVENTREPORTRequest(T_DIMSE_N_EventReportRQ &reqMessage,
483  DcmDataset *reqDataset);
484 
495  virtual OFBool calledAETitleAccepted(const OFString &callingAE,
496  const OFString &calledAE);
497 
498 
499  /* *********************************************************************
500  * Further functions and member variables
501  * *********************************************************************
502  */
503 
512  virtual OFCondition waitForAssociation(T_ASC_Network *network);
513 
519  virtual void cleanChildren();
520 
529 
534  virtual void addProcessToTable(int pid);
535 
542  virtual void removeProcessFromTable(int pid);
543 
548  virtual void refuseAssociation(DcmRefuseReasonType reason);
549 
553  virtual void handleAssociation();
554 
570  OFCondition sendDIMSEMessage(const T_ASC_PresentationContextID presID,
571  T_DIMSE_Message *msg,
572  DcmDataset *dataObject,
573  DIMSE_ProgressCallback callback,
574  void *callbackContext,
575  DcmDataset **commandSet = NULL);
576 
598  OFCondition receiveDIMSECommand(T_ASC_PresentationContextID *presID,
599  T_DIMSE_Message *msg,
600  DcmDataset **statusDetail,
601  DcmDataset **commandSet = NULL,
602  const Uint32 timeout = 0);
603 
617  OFCondition receiveDIMSEDataset(T_ASC_PresentationContextID *presID,
618  DcmDataset **dataObject,
619  DIMSE_ProgressCallback callback,
620  void *callbackContext);
621 
622 private:
623 
627  DcmSCP(const DcmSCP &src);
628 
633  DcmSCP &operator=(const DcmSCP &src);
634 
637 
641 
645 
647  Uint16 m_port;
648 
654 
658 
662 
672 
676 
677 #ifdef _WIN32
678  int m_cmd_argc;
680 
682  char **m_cmd_argv;
683 #endif
684 
689 
695  T_DIMSE_BlockingMode m_blockMode;
696 
700 
704 
708 
712 
716 
720 
721 };
722 
723 #endif // SCP_H
724 
725 
726 /*
727  * CVS/RCS Log:
728  * $Log: scp.h,v $
729  * Revision 1.9 2010-10-14 13:17:22 joergr
730  * Updated copyright header. Added reference to COPYRIGHT file.
731  *
732  * Revision 1.8 2010-10-07 12:54:07 joergr
733  * Fixed minor Doxygen API documentation issues (added backslash in order to
734  * avoid that the short description ends at the first period).
735  *
736  * Revision 1.7 2010-06-22 15:44:55 joergr
737  * Added support for handling N-EVENT-REPORT request.
738  * Added support for stopping after the current association is finished.
739  * Further code cleanup. Renamed some methods, variables, types and so on.
740  *
741  * Revision 1.6 2010-06-18 14:50:33 joergr
742  * Added support for the SCP/SCU role selection negotiation.
743  *
744  * Revision 1.5 2010-06-17 17:06:30 joergr
745  * Aligned SCP class with existing SCU class. Some further code cleanups.
746  * Changed default profile from "Default" to "DEFAULT". Revised documentation.
747  *
748  * Revision 1.4 2010-04-29 16:14:59 onken
749  * Added function for responding to storage requests to SCP class.
750  *
751  * Revision 1.3 2009-12-21 17:00:32 onken
752  * Fixed API documentation to keep doxygen quiet.
753  *
754  * Revision 1.1 2009-12-17 09:02:43 onken
755  * Added base classes for SCU and SCP implementations.
756  *
757  */
time_t startTime
Start time.
Definition: scp.h:64
OFString acceptedTransferSyntax
Transfer Syntax accepted for this Presentation Context (UID)
Definition: scp.h:117
OFBool getRespondWithCalledAETitle() const
Returns whether SCP uses the called AE Title from SCU requests to respond to connection requests inst...
const OFString & getAETitle() const
Returns SCP's own AE title.
Uint32 m_maxReceivePDULength
Maximum PDU size the SCP is able to receive.
Definition: scp.h:661
Uint8 proposedSCRole
SCP role as proposed from SCU.
Definition: scp.h:113
virtual void notifyAbortRequest()
Overwrite this function to be notified about an incoming association abort request.
virtual OFCondition addPresentationContext(const OFString &abstractSyntax, const OFList< OFString > xferSyntaxes, const T_ASC_SC_ROLE role=ASC_SC_ROLE_DEFAULT, const OFString &profile="DEFAULT")
Add abstract syntax to presentation contexts the SCP is able to negotiate with SCUs.
void setAETitle(const OFString &aetitle)
Set AETitle of the server.
Uint8 presentationContextID
Presentation Context ID as proposed by SCU.
Definition: scp.h:109
virtual OFBool stopAfterCurrentAssociation()
Overwrite this function to change the behavior of the listen() method.
OFCondition receiveDIMSECommand(T_ASC_PresentationContextID *presID, T_DIMSE_Message *msg, DcmDataset **statusDetail, DcmDataset **commandSet=NULL, const Uint32 timeout=0)
Receive DIMSE command (excluding dataset!) over the currently open association.
OFBool getRefuseAssociation() const
Returns whether SCP should refuse any association request no matter what the SCU proposes.
T_DIMSE_BlockingMode m_blockMode
Blocking mode for DIMSE operations.
Definition: scp.h:695
virtual void addProcessToTable(int pid)
This function adds a process to the table that stores process information (only relevant for multi-pr...
Base class for implementing a DICOM Service Class Provider (SCP).
Definition: scp.h:130
OFString m_aetitle
AETitle to be used for responding to SCU (default: DCMTK_SCP).
Definition: scp.h:653
Uint32 getPeerMaxPDULength() const
Returns maximum PDU size the communication peer (i.e. the SCU) is able to receive.
void setACSETimeout(const Uint32 acseTimeout)
Set the timeout used during ACSE messaging protocol.
DcmSCP & operator=(const DcmSCP &src)
Private undefined assignment operator.
virtual OFCondition handleEVENTREPORTRequest(T_DIMSE_N_EventReportRQ &reqMessage, T_ASC_PresentationContextID presID, DcmDataset *&reqDataset, Uint16 &eventTypeID)
Receives N-EVENT-REPORT request on the currently opened association and sends a corresponding respons...
OFBool m_forkedChild
Indicates, that this process was spawn as child from a parent process needed for multiprocess mode un...
Definition: scp.h:675
this class maintains a list of association negotiation profiles that can be addressed by symbolic key...
Definition: dcasccfg.h:45
DIC_AE calledAETitle
Called AE title.
Definition: scp.h:60
virtual OFCondition negotiateAssociation()
This function checks all presentation contexts proposed by the SCU whether they are supported or not...
virtual void cleanChildren()
This function takes care of removing items referring to (terminated) subprocess from the table which ...
virtual OFCondition handleIncomingCommand(T_DIMSE_Message *incomingMsg, const DcmPresentationContextInfo &presContextInfo)
Handle incoming command set and react accordingly, e.g. sending response via DIMSE_sendXXXResponse()...
void setRespondWithCalledAETitle(const OFBool useCalled)
Set SCP to use the called AETitle from the SCU request for the response, i.e. the SCP will always res...
DcmSCP()
Constructor.
OFBool getSingleProcess() const
Returns whether SCP is running in single or multi-process mode.
Uint16 m_port
Port on which the SCP is listening for association requests. The default port is 104.
Definition: scp.h:647
void setMaxAssociations(const Uint16 maxAssocs)
Set number of maximum simultanous associations.
DcmAssociationConfiguration * m_assocConfig
Association configuration.
Definition: scp.h:640
OFBool isConnected() const
Returns whether SCP is currently connected.
virtual OFBool calledAETitleAccepted(const OFString &callingAE, const OFString &calledAE)
Function that checks for each association request, whether the combination of calling and called AE t...
OFList< DcmProcessSlotType * > m_processTable
Table of processes for non-single process mode.
Definition: scp.h:711
Uint16 m_maxAssociations
Maximum number of association for multi-process mode.
Definition: scp.h:688
DIC_AE callingAETitle
Calling AE title.
Definition: scp.h:58
OFString m_assocCfgProfileName
Profile in association configuration that should be used.
Definition: scp.h:644
Structure representing single process in multi-process mode.
Definition: scp.h:53
virtual void notifyReleaseRequest()
Overwrite this function to be notified about an incoming association release request.
virtual OFCondition waitForAssociation(T_ASC_Network *network)
This function takes care of receiving, negotiating and accepting/refusing an association request...
Uint32 getDIMSETimeout() const
Returns DIMSE timeout (only applicable in blocking mode)
OFCondition receiveDIMSEDataset(T_ASC_PresentationContextID *presID, DcmDataset **dataObject, DIMSE_ProgressCallback callback, void *callbackContext)
Receives one dataset (of instance data) via network from another DICOM application.
void forceAssociationRefuse(const OFBool doRefuse)
Force every association request to be refused by SCP, no matter what the SCU is offering.
void setDIMSETimeout(const Uint32 dimseTimeout)
Set the timeout to be waited for incoming DIMSE message packets.
virtual OFCondition handleECHORequest(T_DIMSE_C_EchoRQ &reqMessage, T_ASC_PresentationContextID presID)
Standard handler for Verification Service Class (DICOM Echo).
OFBool m_respondWithCalledAETitle
If set, the AE Title as received in the request (called AE Title) is used in response (default: OFTru...
Definition: scp.h:715
Uint16 getPort() const
Returns TCP/IP port number SCP listens for new connection requests.
virtual void removeProcessFromTable(int pid)
This function removes one particular item from the table which stores all subprocess information...
virtual void notifyDIMSEError(const OFCondition &cond)
Overwrite this function to be notified when an association is terminated.
OFBool m_refuseAssociation
Indicates if the application shall refuse any association attempt regardless of what the SCU proposes...
Definition: scp.h:657
OFBool m_singleProcess
Indicates if SCP is run in single process mode or not.
Definition: scp.h:671
OFBool m_verbosePCMode
Verbose PC mode.
Definition: scp.h:707
OFString getPeerIP() const
Returns IP address of connected SCU.
DIC_NODENAME peerName
Name of peer.
Definition: scp.h:56
Uint16 getMaxAssociations() const
Returns number of maximum simultanous connections permitted.
void setMaxReceivePDULength(const Uint32 maxRecPDU)
Set maximum PDU size the SCP is able to receive.
T_ASC_Association * m_assoc
Current association run by this SCP.
Definition: scp.h:636
a class handling the DICOM dataset format (files without meta header)
Definition: dcdatset.h:46
OFBool getVerbosePCMode() const
Returns the verbose presentation context mode configured specifying whether details on the presentati...
void setPort(const Uint16 port)
Set SCP's TCP/IP listening port.
virtual void notifyAssociationRequest(const T_ASC_Parameters &params, DcmSCPActionType &desiredAction)
Overwrite this function to be notified about an incoming association request.
virtual OFCondition setAndCheckAssociationProfile(const OFString &profileName)
If an association profile should be selected, either by loading an associaton configuration file or u...
virtual Uint16 checkEVENTREPORTRequest(T_DIMSE_N_EventReportRQ &reqMessage, DcmDataset *reqDataset)
Check given N-EVENT-REPORT request and dataset for validity.
void setDIMSEBlockingMode(const T_DIMSE_BlockingMode blockingMode)
Set whether DIMSE messaging should be blocking or non-blocking.
T_DIMSE_BlockingMode getDIMSEBlockingMode() const
Returns whether receiving of DIMSE messages is done in blocking or unblocking mode.
Uint8 acceptedSCRole
Role acccepted by SCP for this Presentation Context.
Definition: scp.h:115
virtual void notifyAssociationAcknowledge()
Overwrite this function to be notified about an incoming association request.
void dropAndDestroyAssociation()
Drops association and clears internal structures to free memory.
virtual ~DcmSCP()
Virtual destructor, frees internal memory.
OFBool hasStorageAbility
Indicator if process has storage ability.
Definition: scp.h:66
virtual void handleAssociation()
This function takes care of handling the other DICOM application's request.
Uint16 numAssociations() const
Returns number of associations currently running.
virtual void notifyAssociationTermination()
Overwrite this function to be notified when an association is terminated.
virtual OFCondition sendSTOREResponse(T_ASC_PresentationContextID presID, T_DIMSE_C_StoreRQ &reqMessage, T_DIMSE_C_StoreRSP &rspMessage, DcmDataset *statusDetail)
Respond to storage request.
OFString getCalledAETitle() const
Returns AE Title the SCU used as called AE Title in associaton request.
virtual OFCondition loadAssociationCfgFile(const OFString &assocFile)
Loads association configuration file.
OFCondition enableMultiProcessMode(int argc=0, char *argv[]=NULL)
Enable multi-process mode for SCP.
void setVerbosePCMode(const OFBool mode)
Set whether to show presentation contexts in verbose or debug mode.
a simple string class that implements a subset of std::string.
Definition: ofstring.h:86
Uint32 getMaxReceivePDULength() const
Returns maximum PDU length configured to be received by SCP.
OFString abstractSyntax
Abstract Syntax name (UID) as proposed by SCU.
Definition: scp.h:111
OFCondition sendDIMSEMessage(const T_ASC_PresentationContextID presID, T_DIMSE_Message *msg, DcmDataset *dataObject, DIMSE_ProgressCallback callback, void *callbackContext, DcmDataset **commandSet=NULL)
Sends a DIMSE command and possibly also a dataset from a data object via network to another DICOM app...
Uint32 m_acseTimeout
Timeout for ACSE operations in seconds.
Definition: scp.h:703
Uint32 m_dimseTimeout
Timeout for DIMSE operations in seconds.
Definition: scp.h:699
virtual void refuseAssociation(DcmRefuseReasonType reason)
This function takes care of refusing an assocation request.
OFString getPeerAETitle() const
Returns AE Title (calling AE Title) the SCU used for association request.
Uint32 getACSETimeout() const
Returns ACSE timeout.
virtual OFCondition listen()
Starts providing the implemented services to SCUs.
int processId
Process ID.
Definition: scp.h:62
General purpose class for condition codes.
Definition: ofcond.h:305
Structure representing a single Presentation Context.
Definition: scp.h:106


Generated on Wed Dec 28 2016 for OFFIS DCMTK Version 3.6.0 by Doxygen 1.8.8