00001
00002
00003
00004
00005
00006
00007
00008
00009
00010
00011
00012
00013
00014
00015
00016
00017
00018
00019
00020
00021
00022
00023
00024
00025
00026
00027
00028
00029
00030 #ifndef SCP_H
00031 #define SCP_H
00032
00033 #include "dcmtk/config/osconfig.h"
00034
00035 #include "dcmtk/oflog/oflog.h"
00036 #include "dcmtk/dcmdata/dctk.h"
00037 #include "dcmtk/dcmnet/dimse.h"
00038 #include "dcmtk/dcmnet/dcasccff.h"
00039 #include "dcmtk/dcmnet/dcasccfg.h"
00040
00041 #ifdef WITH_ZLIB
00042 #include <zlib.h>
00043 #endif
00044
00045 #ifdef WITH_OPENSSL
00046 #include "dcmtk/dcmtls/tlstrans.h"
00047 #include "dcmtk/dcmtls/tlslayer.h"
00048 #endif
00049
00050
00053 struct DcmProcessSlotType
00054 {
00056 DIC_NODENAME peerName;
00058 DIC_AE callingAETitle;
00060 DIC_AE calledAETitle;
00062 int processId;
00064 time_t startTime;
00066 OFBool hasStorageAbility;
00067 };
00068
00072 enum DcmSCPActionType
00073 {
00075 DCMSCP_ACTION_UNDEFINED,
00077 DCMSCP_ACTION_REFUSE_ASSOCIATION
00078 };
00079
00082 enum DcmRefuseReasonType
00083 {
00085 DCMSCP_TOO_MANY_ASSOCIATIONS,
00087 DCMSCP_CANNOT_FORK,
00089 DCMSCP_BAD_APPLICATION_CONTEXT_NAME,
00091 DCMSCP_BAD_APPLICATION_ENTITY_SERVICE,
00093 DCMSCP_FORCED,
00095 DCMSCP_NO_IMPLEMENTATION_CLASS_UID,
00097 DCMSCP_NO_PRESENTATION_CONTEXTS,
00099 DCMSCP_INTERNAL_ERROR
00100 };
00101
00106 struct DcmPresentationContextInfo
00107 {
00109 Uint8 presentationContextID;
00111 OFString abstractSyntax;
00113 Uint8 proposedSCRole;
00115 Uint8 acceptedSCRole;
00117 OFString acceptedTransferSyntax;
00118
00119 };
00120
00121
00130 class DcmSCP
00131 {
00132
00133 public:
00134
00137 DcmSCP();
00138
00141 virtual ~DcmSCP();
00142
00143 #ifdef _WIN32
00144
00148 OFCondition markAsForkedChild();
00149 #endif
00150
00155 virtual OFCondition listen();
00156
00157
00158
00159
00160
00161
00172 virtual OFCondition addPresentationContext(const OFString &abstractSyntax,
00173 const OFList<OFString> xferSyntaxes,
00174 const T_ASC_SC_ROLE role = ASC_SC_ROLE_DEFAULT,
00175 const OFString &profile = "DEFAULT");
00176
00181 void setPort(const Uint16 port);
00182
00188 void setAETitle(const OFString &aetitle);
00189
00196 void setRespondWithCalledAETitle(const OFBool useCalled);
00197
00203 virtual OFCondition loadAssociationCfgFile(const OFString &assocFile);
00204
00212 virtual OFCondition setAndCheckAssociationProfile(const OFString &profileName);
00213
00219 void forceAssociationRefuse(const OFBool doRefuse);
00220
00225 void setMaxReceivePDULength(const Uint32 maxRecPDU);
00226
00238 OFCondition enableMultiProcessMode(int argc = 0,
00239 char *argv[] = NULL);
00240
00245 void setMaxAssociations(const Uint16 maxAssocs);
00246
00256 void setDIMSEBlockingMode(const T_DIMSE_BlockingMode blockingMode);
00257
00262 void setDIMSETimeout(const Uint32 dimseTimeout);
00263
00267 void setACSETimeout(const Uint32 acseTimeout);
00268
00273 void setVerbosePCMode(const OFBool mode);
00274
00275
00276
00280 Uint16 getPort() const;
00281
00286 const OFString &getAETitle() const;
00287
00292 OFBool getRespondWithCalledAETitle() const;
00293
00297 OFBool getRefuseAssociation() const;
00298
00302 Uint32 getMaxReceivePDULength() const;
00303
00307 OFBool getSingleProcess() const;
00308
00316 Uint16 getMaxAssociations() const;
00317
00321 T_DIMSE_BlockingMode getDIMSEBlockingMode() const;
00322
00326 Uint32 getDIMSETimeout() const;
00327
00331 Uint32 getACSETimeout() const;
00332
00338 OFBool getVerbosePCMode() const;
00339
00340
00341
00347 OFBool isConnected() const;
00348
00353 Uint16 numAssociations() const;
00354
00359 OFString getCalledAETitle() const;
00360
00364 OFString getPeerAETitle() const;
00365
00369 OFString getPeerIP() const;
00370
00375 Uint32 getPeerMaxPDULength() const;
00376
00377
00378 protected:
00379
00380
00381
00382
00383
00384
00392 virtual OFCondition handleIncomingCommand(T_DIMSE_Message *incomingMsg,
00393 const DcmPresentationContextInfo &presContextInfo);
00394
00399 virtual void notifyAssociationRequest(const T_ASC_Parameters ¶ms,
00400 DcmSCPActionType &desiredAction);
00401
00405 virtual void notifyAssociationAcknowledge();
00406
00410 virtual void notifyReleaseRequest();
00411
00415 virtual void notifyAbortRequest();
00416
00420 virtual void notifyAssociationTermination();
00421
00426 virtual void notifyDIMSEError(const OFCondition &cond);
00427
00433 virtual OFBool stopAfterCurrentAssociation();
00434
00442 virtual OFCondition sendSTOREResponse(T_ASC_PresentationContextID presID,
00443 T_DIMSE_C_StoreRQ &reqMessage,
00444 T_DIMSE_C_StoreRSP &rspMessage,
00445 DcmDataset *statusDetail);
00446
00454 virtual OFCondition handleECHORequest(T_DIMSE_C_EchoRQ &reqMessage,
00455 T_ASC_PresentationContextID presID);
00456
00467 virtual OFCondition handleEVENTREPORTRequest(T_DIMSE_N_EventReportRQ &reqMessage,
00468 T_ASC_PresentationContextID presID,
00469 DcmDataset *&reqDataset,
00470 Uint16 &eventTypeID);
00471
00482 virtual Uint16 checkEVENTREPORTRequest(T_DIMSE_N_EventReportRQ &reqMessage,
00483 DcmDataset *reqDataset);
00484
00495 virtual OFBool calledAETitleAccepted(const OFString &callingAE,
00496 const OFString &calledAE);
00497
00498
00499
00500
00501
00502
00503
00512 virtual OFCondition waitForAssociation(T_ASC_Network *network);
00513
00519 virtual void cleanChildren();
00520
00528 virtual OFCondition negotiateAssociation();
00529
00534 virtual void addProcessToTable(int pid);
00535
00542 virtual void removeProcessFromTable(int pid);
00543
00548 virtual void refuseAssociation(DcmRefuseReasonType reason);
00549
00553 virtual void handleAssociation();
00554
00570 OFCondition sendDIMSEMessage(const T_ASC_PresentationContextID presID,
00571 T_DIMSE_Message *msg,
00572 DcmDataset *dataObject,
00573 DIMSE_ProgressCallback callback,
00574 void *callbackContext,
00575 DcmDataset **commandSet = NULL);
00576
00598 OFCondition receiveDIMSECommand(T_ASC_PresentationContextID *presID,
00599 T_DIMSE_Message *msg,
00600 DcmDataset **statusDetail,
00601 DcmDataset **commandSet = NULL,
00602 const Uint32 timeout = 0);
00603
00617 OFCondition receiveDIMSEDataset(T_ASC_PresentationContextID *presID,
00618 DcmDataset **dataObject,
00619 DIMSE_ProgressCallback callback,
00620 void *callbackContext);
00621
00622 private:
00623
00627 DcmSCP(const DcmSCP &src);
00628
00633 DcmSCP &operator=(const DcmSCP &src);
00634
00636 T_ASC_Association *m_assoc;
00637
00640 DcmAssociationConfiguration *m_assocConfig;
00641
00644 OFString m_assocCfgProfileName;
00645
00647 Uint16 m_port;
00648
00653 OFString m_aetitle;
00654
00657 OFBool m_refuseAssociation;
00658
00661 Uint32 m_maxReceivePDULength;
00662
00671 OFBool m_singleProcess;
00672
00675 OFBool m_forkedChild;
00676
00677 #ifdef _WIN32
00679 int m_cmd_argc;
00680
00682 char **m_cmd_argv;
00683 #endif
00684
00688 Uint16 m_maxAssociations;
00689
00695 T_DIMSE_BlockingMode m_blockMode;
00696
00699 Uint32 m_dimseTimeout;
00700
00703 Uint32 m_acseTimeout;
00704
00707 OFBool m_verbosePCMode;
00708
00711 OFList<DcmProcessSlotType *> m_processTable;
00712
00715 OFBool m_respondWithCalledAETitle;
00716
00719 void dropAndDestroyAssociation();
00720
00721 };
00722
00723 #endif // SCP_H
00724
00725
00726
00727
00728
00729
00730
00731
00732
00733
00734
00735
00736
00737
00738
00739
00740
00741
00742
00743
00744
00745
00746
00747
00748
00749
00750
00751
00752
00753
00754
00755
00756
00757