Mercurial > hg > orthanc
annotate OrthancFramework/Sources/DicomNetworking/Internals/StoreScp.cpp @ 4439:5209a9ff6e38
configuration options for DICOM TLS in Orthanc SCP
author | Sebastien Jodogne <s.jodogne@gmail.com> |
---|---|
date | Thu, 07 Jan 2021 18:18:39 +0100 |
parents | d9473bd5ed43 |
children | e3e759cbd19c |
rev | line source |
---|---|
0 | 1 /** |
62 | 2 * Orthanc - A Lightweight, RESTful DICOM Store |
1900 | 3 * Copyright (C) 2012-2016 Sebastien Jodogne, Medical Physics |
1288
6e7e5ed91c2d
upgrade to year 2015
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
1285
diff
changeset
|
4 * Department, University Hospital of Liege, Belgium |
4437
d9473bd5ed43
upgrade to year 2021
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
4284
diff
changeset
|
5 * Copyright (C) 2017-2021 Osimis S.A., Belgium |
0 | 6 * |
7 * This program is free software: you can redistribute it and/or | |
4119
bf7b9edf6b81
re-licensing the OrthancFramework to LGPL, in order to license Stone of Orthanc under LGPL
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
4044
diff
changeset
|
8 * modify it under the terms of the GNU Lesser General Public License |
bf7b9edf6b81
re-licensing the OrthancFramework to LGPL, in order to license Stone of Orthanc under LGPL
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
4044
diff
changeset
|
9 * as published by the Free Software Foundation, either version 3 of |
bf7b9edf6b81
re-licensing the OrthancFramework to LGPL, in order to license Stone of Orthanc under LGPL
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
4044
diff
changeset
|
10 * the License, or (at your option) any later version. |
136 | 11 * |
0 | 12 * This program is distributed in the hope that it will be useful, but |
13 * WITHOUT ANY WARRANTY; without even the implied warranty of | |
14 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU | |
4119
bf7b9edf6b81
re-licensing the OrthancFramework to LGPL, in order to license Stone of Orthanc under LGPL
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
4044
diff
changeset
|
15 * Lesser General Public License for more details. |
0 | 16 * |
4119
bf7b9edf6b81
re-licensing the OrthancFramework to LGPL, in order to license Stone of Orthanc under LGPL
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
4044
diff
changeset
|
17 * You should have received a copy of the GNU Lesser General Public |
bf7b9edf6b81
re-licensing the OrthancFramework to LGPL, in order to license Stone of Orthanc under LGPL
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
4044
diff
changeset
|
18 * License along with this program. If not, see |
bf7b9edf6b81
re-licensing the OrthancFramework to LGPL, in order to license Stone of Orthanc under LGPL
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
4044
diff
changeset
|
19 * <http://www.gnu.org/licenses/>. |
0 | 20 **/ |
21 | |
22 | |
766
0a2f8c707c78
Fix missing licensing terms about reuse of some DCMTK code
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
730
diff
changeset
|
23 |
0a2f8c707c78
Fix missing licensing terms about reuse of some DCMTK code
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
730
diff
changeset
|
24 |
0a2f8c707c78
Fix missing licensing terms about reuse of some DCMTK code
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
730
diff
changeset
|
25 /*========================================================================= |
0a2f8c707c78
Fix missing licensing terms about reuse of some DCMTK code
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
730
diff
changeset
|
26 |
0a2f8c707c78
Fix missing licensing terms about reuse of some DCMTK code
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
730
diff
changeset
|
27 This file is based on portions of the following project: |
0a2f8c707c78
Fix missing licensing terms about reuse of some DCMTK code
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
730
diff
changeset
|
28 |
0a2f8c707c78
Fix missing licensing terms about reuse of some DCMTK code
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
730
diff
changeset
|
29 Program: DCMTK 3.6.0 |
0a2f8c707c78
Fix missing licensing terms about reuse of some DCMTK code
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
730
diff
changeset
|
30 Module: http://dicom.offis.de/dcmtk.php.en |
0a2f8c707c78
Fix missing licensing terms about reuse of some DCMTK code
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
730
diff
changeset
|
31 |
4284
756126cd2219
moving all logs from DicomNetworking folder into the "dicom" category
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
4140
diff
changeset
|
32 Copyright (C) 1994-2011, OFFIS e.V. |
756126cd2219
moving all logs from DicomNetworking folder into the "dicom" category
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
4140
diff
changeset
|
33 All rights reserved. |
766
0a2f8c707c78
Fix missing licensing terms about reuse of some DCMTK code
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
730
diff
changeset
|
34 |
4284
756126cd2219
moving all logs from DicomNetworking folder into the "dicom" category
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
4140
diff
changeset
|
35 This software and supporting documentation were developed by |
766
0a2f8c707c78
Fix missing licensing terms about reuse of some DCMTK code
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
730
diff
changeset
|
36 |
0a2f8c707c78
Fix missing licensing terms about reuse of some DCMTK code
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
730
diff
changeset
|
37 OFFIS e.V. |
0a2f8c707c78
Fix missing licensing terms about reuse of some DCMTK code
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
730
diff
changeset
|
38 R&D Division Health |
0a2f8c707c78
Fix missing licensing terms about reuse of some DCMTK code
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
730
diff
changeset
|
39 Escherweg 2 |
0a2f8c707c78
Fix missing licensing terms about reuse of some DCMTK code
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
730
diff
changeset
|
40 26121 Oldenburg, Germany |
0a2f8c707c78
Fix missing licensing terms about reuse of some DCMTK code
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
730
diff
changeset
|
41 |
4284
756126cd2219
moving all logs from DicomNetworking folder into the "dicom" category
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
4140
diff
changeset
|
42 Redistribution and use in source and binary forms, with or without |
756126cd2219
moving all logs from DicomNetworking folder into the "dicom" category
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
4140
diff
changeset
|
43 modification, are permitted provided that the following conditions |
756126cd2219
moving all logs from DicomNetworking folder into the "dicom" category
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
4140
diff
changeset
|
44 are met: |
766
0a2f8c707c78
Fix missing licensing terms about reuse of some DCMTK code
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
730
diff
changeset
|
45 |
4284
756126cd2219
moving all logs from DicomNetworking folder into the "dicom" category
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
4140
diff
changeset
|
46 - Redistributions of source code must retain the above copyright |
766
0a2f8c707c78
Fix missing licensing terms about reuse of some DCMTK code
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
730
diff
changeset
|
47 notice, this list of conditions and the following disclaimer. |
0a2f8c707c78
Fix missing licensing terms about reuse of some DCMTK code
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
730
diff
changeset
|
48 |
4284
756126cd2219
moving all logs from DicomNetworking folder into the "dicom" category
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
4140
diff
changeset
|
49 - Redistributions in binary form must reproduce the above copyright |
766
0a2f8c707c78
Fix missing licensing terms about reuse of some DCMTK code
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
730
diff
changeset
|
50 notice, this list of conditions and the following disclaimer in the |
0a2f8c707c78
Fix missing licensing terms about reuse of some DCMTK code
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
730
diff
changeset
|
51 documentation and/or other materials provided with the distribution. |
0a2f8c707c78
Fix missing licensing terms about reuse of some DCMTK code
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
730
diff
changeset
|
52 |
4284
756126cd2219
moving all logs from DicomNetworking folder into the "dicom" category
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
4140
diff
changeset
|
53 - Neither the name of OFFIS nor the names of its contributors may be |
766
0a2f8c707c78
Fix missing licensing terms about reuse of some DCMTK code
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
730
diff
changeset
|
54 used to endorse or promote products derived from this software |
0a2f8c707c78
Fix missing licensing terms about reuse of some DCMTK code
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
730
diff
changeset
|
55 without specific prior written permission. |
0a2f8c707c78
Fix missing licensing terms about reuse of some DCMTK code
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
730
diff
changeset
|
56 |
4284
756126cd2219
moving all logs from DicomNetworking folder into the "dicom" category
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
4140
diff
changeset
|
57 THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS |
756126cd2219
moving all logs from DicomNetworking folder into the "dicom" category
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
4140
diff
changeset
|
58 "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT |
756126cd2219
moving all logs from DicomNetworking folder into the "dicom" category
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
4140
diff
changeset
|
59 LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR |
756126cd2219
moving all logs from DicomNetworking folder into the "dicom" category
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
4140
diff
changeset
|
60 A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT |
756126cd2219
moving all logs from DicomNetworking folder into the "dicom" category
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
4140
diff
changeset
|
61 HOLDER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, |
756126cd2219
moving all logs from DicomNetworking folder into the "dicom" category
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
4140
diff
changeset
|
62 SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT |
756126cd2219
moving all logs from DicomNetworking folder into the "dicom" category
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
4140
diff
changeset
|
63 LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, |
756126cd2219
moving all logs from DicomNetworking folder into the "dicom" category
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
4140
diff
changeset
|
64 DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY |
756126cd2219
moving all logs from DicomNetworking folder into the "dicom" category
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
4140
diff
changeset
|
65 THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT |
756126cd2219
moving all logs from DicomNetworking folder into the "dicom" category
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
4140
diff
changeset
|
66 (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE |
756126cd2219
moving all logs from DicomNetworking folder into the "dicom" category
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
4140
diff
changeset
|
67 OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. |
766
0a2f8c707c78
Fix missing licensing terms about reuse of some DCMTK code
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
730
diff
changeset
|
68 |
4284
756126cd2219
moving all logs from DicomNetworking folder into the "dicom" category
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
4140
diff
changeset
|
69 =========================================================================*/ |
766
0a2f8c707c78
Fix missing licensing terms about reuse of some DCMTK code
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
730
diff
changeset
|
70 |
0a2f8c707c78
Fix missing licensing terms about reuse of some DCMTK code
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
730
diff
changeset
|
71 |
2382
7284093111b0
big reorganization to cleanly separate framework vs. server
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
2381
diff
changeset
|
72 #include "../../PrecompiledHeaders.h" |
0 | 73 #include "StoreScp.h" |
74 | |
3118 | 75 #if !defined(DCMTK_VERSION_NUMBER) |
76 # error The macro DCMTK_VERSION_NUMBER must be defined | |
77 #endif | |
78 | |
2382
7284093111b0
big reorganization to cleanly separate framework vs. server
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
2381
diff
changeset
|
79 #include "../../DicomParsing/FromDcmtkBridge.h" |
7284093111b0
big reorganization to cleanly separate framework vs. server
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
2381
diff
changeset
|
80 #include "../../DicomParsing/ToDcmtkBridge.h" |
7284093111b0
big reorganization to cleanly separate framework vs. server
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
2381
diff
changeset
|
81 #include "../../OrthancException.h" |
7284093111b0
big reorganization to cleanly separate framework vs. server
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
2381
diff
changeset
|
82 #include "../../Logging.h" |
0 | 83 |
84 #include <dcmtk/dcmdata/dcfilefo.h> | |
85 #include <dcmtk/dcmdata/dcmetinf.h> | |
86 #include <dcmtk/dcmdata/dcostrmb.h> | |
87 #include <dcmtk/dcmdata/dcdeftag.h> | |
88 #include <dcmtk/dcmnet/diutil.h> | |
89 | |
90 | |
62 | 91 namespace Orthanc |
0 | 92 { |
93 namespace | |
94 { | |
95 struct StoreCallbackData | |
96 { | |
97 IStoreRequestHandler* handler; | |
1573
3309878b3e16
more information about the origin of requests submitted to the DICOM handlers
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
1486
diff
changeset
|
98 const std::string* remoteIp; |
1285
5730f374e4e6
Access to called AET and remote AET from Lua scripts
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
1004
diff
changeset
|
99 const char* remoteAET; |
5730f374e4e6
Access to called AET and remote AET from Lua scripts
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
1004
diff
changeset
|
100 const char* calledAET; |
0 | 101 const char* modality; |
102 const char* affectedSOPInstanceUID; | |
103 uint32_t messageID; | |
104 }; | |
105 | |
730
309e686b41e7
better logging about nonexistent tags
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
689
diff
changeset
|
106 |
0 | 107 static void |
108 storeScpCallback( | |
109 void *callbackData, | |
110 T_DIMSE_StoreProgress *progress, | |
111 T_DIMSE_C_StoreRQ *req, | |
112 char * /*imageFileName*/, DcmDataset **imageDataSet, | |
113 T_DIMSE_C_StoreRSP *rsp, | |
114 DcmDataset **statusDetail) | |
115 /* | |
116 * This function.is used to indicate progress when storescp receives instance data over the | |
117 * network. On the final call to this function (identified by progress->state == DIMSE_StoreEnd) | |
118 * this function will store the data set which was received over the network to a file. | |
119 * Earlier calls to this function will simply cause some information to be dumped to stdout. | |
120 * | |
121 * Parameters: | |
122 * callbackData - [in] data for this callback function | |
123 * progress - [in] The state of progress. (identifies if this is the initial or final call | |
124 * to this function, or a call in between these two calls. | |
125 * req - [in] The original store request message. | |
126 * imageFileName - [in] The path to and name of the file the information shall be written to. | |
127 * imageDataSet - [in] The data set which shall be stored in the image file | |
128 * rsp - [inout] the C-STORE-RSP message (will be sent after the call to this function) | |
129 * statusDetail - [inout] This variable can be used to capture detailed information with regard to | |
130 * the status information which is captured in the status element (0000,0900). Note | |
131 * that this function does specify any such information, the pointer will be set to NULL. | |
132 */ | |
133 { | |
134 StoreCallbackData *cbdata = OFstatic_cast(StoreCallbackData *, callbackData); | |
135 | |
136 DIC_UI sopClass; | |
137 DIC_UI sopInstance; | |
138 | |
139 // if this is the final call of this function, save the data which was received to a file | |
140 // (note that we could also save the image somewhere else, put it in database, etc.) | |
141 if (progress->state == DIMSE_StoreEnd) | |
142 { | |
143 OFString tmpStr; | |
144 | |
145 // do not send status detail information | |
146 *statusDetail = NULL; | |
147 | |
148 // Concerning the following line: an appropriate status code is already set in the resp structure, | |
149 // it need not be success. For example, if the caller has already detected an out of resources problem | |
150 // then the status will reflect this. The callback function is still called to allow cleanup. | |
151 //rsp->DimseStatus = STATUS_Success; | |
152 | |
153 // we want to write the received information to a file only if this information | |
154 // is present and the options opt_bitPreserving and opt_ignore are not set. | |
155 if ((imageDataSet != NULL) && (*imageDataSet != NULL)) | |
156 { | |
157 DicomMap summary; | |
158 Json::Value dicomJson; | |
291
4d7469f72a0b
embedding of dicom dictionaries
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
194
diff
changeset
|
159 std::string buffer; |
0 | 160 |
161 try | |
162 { | |
2409
e4045b3c9772
ignore-length argument if retrieving DICOM tags
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
2382
diff
changeset
|
163 std::set<DicomTag> ignoreTagLength; |
4140
0ddc5297a8ab
centralization of default parameters for JSON/DicomMap conversions from DCMTK
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
4137
diff
changeset
|
164 |
0ddc5297a8ab
centralization of default parameters for JSON/DicomMap conversions from DCMTK
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
4137
diff
changeset
|
165 // TODO => Parameters in class "DicomServer" |
4137
6774605d4341
keep only one signature for FromDcmtkBridge::ExtractDicomSummary()
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
4136
diff
changeset
|
166 FromDcmtkBridge::ExtractDicomSummary(summary, **imageDataSet, ORTHANC_MAXIMUM_TAG_LENGTH, ignoreTagLength); |
4140
0ddc5297a8ab
centralization of default parameters for JSON/DicomMap conversions from DCMTK
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
4137
diff
changeset
|
167 FromDcmtkBridge::ExtractDicomAsJson(dicomJson, **imageDataSet, DicomToJsonFormat_Full, |
0ddc5297a8ab
centralization of default parameters for JSON/DicomMap conversions from DCMTK
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
4137
diff
changeset
|
168 DicomToJsonFlags_Default, ORTHANC_MAXIMUM_TAG_LENGTH, ignoreTagLength); |
0 | 169 |
1004
a226e0959d8b
DicomInstanceToStore
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
831
diff
changeset
|
170 if (!FromDcmtkBridge::SaveToMemoryBuffer(buffer, **imageDataSet)) |
0 | 171 { |
4284
756126cd2219
moving all logs from DicomNetworking folder into the "dicom" category
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
4140
diff
changeset
|
172 CLOG(ERROR, DICOM) << "cannot write DICOM file to memory"; |
0 | 173 rsp->DimseStatus = STATUS_STORE_Refused_OutOfResources; |
174 } | |
175 } | |
176 catch (...) | |
177 { | |
178 rsp->DimseStatus = STATUS_STORE_Refused_OutOfResources; | |
179 } | |
180 | |
181 // check the image to make sure it is consistent, i.e. that its sopClass and sopInstance correspond | |
182 // to those mentioned in the request. If not, set the status in the response message variable. | |
1333
732b6a4ed541
clang warning removal
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
1288
diff
changeset
|
183 if (rsp->DimseStatus == STATUS_Success) |
0 | 184 { |
185 // which SOP class and SOP instance ? | |
3118 | 186 |
187 #if DCMTK_VERSION_NUMBER >= 364 | |
188 if (!DU_findSOPClassAndInstanceInDataSet(*imageDataSet, sopClass, sizeof(sopClass), | |
189 sopInstance, sizeof(sopInstance), /*opt_correctUIDPadding*/ OFFalse)) | |
190 #else | |
4284
756126cd2219
moving all logs from DicomNetworking folder into the "dicom" category
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
4140
diff
changeset
|
191 if (!DU_findSOPClassAndInstanceInDataSet(*imageDataSet, sopClass, sopInstance, /*opt_correctUIDPadding*/ OFFalse)) |
3118 | 192 #endif |
4284
756126cd2219
moving all logs from DicomNetworking folder into the "dicom" category
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
4140
diff
changeset
|
193 { |
3118 | 194 //LOG4CPP_ERROR(Internals::GetLogger(), "bad DICOM file: " << fileName); |
195 rsp->DimseStatus = STATUS_STORE_Error_CannotUnderstand; | |
4284
756126cd2219
moving all logs from DicomNetworking folder into the "dicom" category
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
4140
diff
changeset
|
196 } |
756126cd2219
moving all logs from DicomNetworking folder into the "dicom" category
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
4140
diff
changeset
|
197 else if (strcmp(sopClass, req->AffectedSOPClassUID) != 0) |
756126cd2219
moving all logs from DicomNetworking folder into the "dicom" category
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
4140
diff
changeset
|
198 { |
756126cd2219
moving all logs from DicomNetworking folder into the "dicom" category
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
4140
diff
changeset
|
199 rsp->DimseStatus = STATUS_STORE_Error_DataSetDoesNotMatchSOPClass; |
756126cd2219
moving all logs from DicomNetworking folder into the "dicom" category
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
4140
diff
changeset
|
200 } |
756126cd2219
moving all logs from DicomNetworking folder into the "dicom" category
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
4140
diff
changeset
|
201 else if (strcmp(sopInstance, req->AffectedSOPInstanceUID) != 0) |
756126cd2219
moving all logs from DicomNetworking folder into the "dicom" category
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
4140
diff
changeset
|
202 { |
756126cd2219
moving all logs from DicomNetworking folder into the "dicom" category
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
4140
diff
changeset
|
203 rsp->DimseStatus = STATUS_STORE_Error_DataSetDoesNotMatchSOPClass; |
756126cd2219
moving all logs from DicomNetworking folder into the "dicom" category
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
4140
diff
changeset
|
204 } |
756126cd2219
moving all logs from DicomNetworking folder into the "dicom" category
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
4140
diff
changeset
|
205 else |
0 | 206 { |
4284
756126cd2219
moving all logs from DicomNetworking folder into the "dicom" category
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
4140
diff
changeset
|
207 try |
756126cd2219
moving all logs from DicomNetworking folder into the "dicom" category
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
4140
diff
changeset
|
208 { |
756126cd2219
moving all logs from DicomNetworking folder into the "dicom" category
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
4140
diff
changeset
|
209 cbdata->handler->Handle(buffer, summary, dicomJson, *cbdata->remoteIp, cbdata->remoteAET, cbdata->calledAET); |
756126cd2219
moving all logs from DicomNetworking folder into the "dicom" category
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
4140
diff
changeset
|
210 } |
756126cd2219
moving all logs from DicomNetworking folder into the "dicom" category
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
4140
diff
changeset
|
211 catch (OrthancException& e) |
756126cd2219
moving all logs from DicomNetworking folder into the "dicom" category
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
4140
diff
changeset
|
212 { |
756126cd2219
moving all logs from DicomNetworking folder into the "dicom" category
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
4140
diff
changeset
|
213 rsp->DimseStatus = STATUS_STORE_Refused_OutOfResources; |
730
309e686b41e7
better logging about nonexistent tags
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
689
diff
changeset
|
214 |
4284
756126cd2219
moving all logs from DicomNetworking folder into the "dicom" category
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
4140
diff
changeset
|
215 if (e.GetErrorCode() == ErrorCode_InexistentTag) |
756126cd2219
moving all logs from DicomNetworking folder into the "dicom" category
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
4140
diff
changeset
|
216 { |
756126cd2219
moving all logs from DicomNetworking folder into the "dicom" category
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
4140
diff
changeset
|
217 summary.LogMissingTagsForStore(); |
756126cd2219
moving all logs from DicomNetworking folder into the "dicom" category
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
4140
diff
changeset
|
218 } |
756126cd2219
moving all logs from DicomNetworking folder into the "dicom" category
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
4140
diff
changeset
|
219 else |
756126cd2219
moving all logs from DicomNetworking folder into the "dicom" category
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
4140
diff
changeset
|
220 { |
756126cd2219
moving all logs from DicomNetworking folder into the "dicom" category
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
4140
diff
changeset
|
221 CLOG(ERROR, DICOM) << "Exception while storing DICOM: " << e.What(); |
756126cd2219
moving all logs from DicomNetworking folder into the "dicom" category
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
4140
diff
changeset
|
222 } |
730
309e686b41e7
better logging about nonexistent tags
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
689
diff
changeset
|
223 } |
0 | 224 } |
225 } | |
226 } | |
227 } | |
228 } | |
229 } | |
230 | |
231 /* | |
232 * This function processes a DIMSE C-STORE-RQ commmand that was | |
233 * received over the network connection. | |
234 * | |
235 * Parameters: | |
236 * assoc - [in] The association (network connection to another DICOM application). | |
237 * msg - [in] The DIMSE C-STORE-RQ message that was received. | |
238 * presID - [in] The ID of the presentation context which was specified in the PDV which contained | |
239 * the DIMSE command. | |
240 */ | |
241 OFCondition Internals::storeScp(T_ASC_Association * assoc, | |
242 T_DIMSE_Message * msg, | |
243 T_ASC_PresentationContextID presID, | |
1573
3309878b3e16
more information about the origin of requests submitted to the DICOM handlers
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
1486
diff
changeset
|
244 IStoreRequestHandler& handler, |
3704
58f92b1c8061
Fix issue #167 (Job can't be cancelled - Handling of timeouts after established association)
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
3640
diff
changeset
|
245 const std::string& remoteIp, |
58f92b1c8061
Fix issue #167 (Job can't be cancelled - Handling of timeouts after established association)
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
3640
diff
changeset
|
246 int timeout) |
0 | 247 { |
248 OFCondition cond = EC_Normal; | |
249 T_DIMSE_C_StoreRQ *req; | |
250 | |
251 // assign the actual information of the C-STORE-RQ command to a local variable | |
252 req = &msg->msg.CStoreRQ; | |
253 | |
254 // intialize some variables | |
1573
3309878b3e16
more information about the origin of requests submitted to the DICOM handlers
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
1486
diff
changeset
|
255 StoreCallbackData data; |
3309878b3e16
more information about the origin of requests submitted to the DICOM handlers
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
1486
diff
changeset
|
256 data.handler = &handler; |
3309878b3e16
more information about the origin of requests submitted to the DICOM handlers
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
1486
diff
changeset
|
257 data.remoteIp = &remoteIp; |
3309878b3e16
more information about the origin of requests submitted to the DICOM handlers
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
1486
diff
changeset
|
258 data.modality = dcmSOPClassUIDToModality(req->AffectedSOPClassUID/*, "UNKNOWN"*/); |
3309878b3e16
more information about the origin of requests submitted to the DICOM handlers
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
1486
diff
changeset
|
259 if (data.modality == NULL) |
3309878b3e16
more information about the origin of requests submitted to the DICOM handlers
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
1486
diff
changeset
|
260 data.modality = "UNKNOWN"; |
101 | 261 |
1573
3309878b3e16
more information about the origin of requests submitted to the DICOM handlers
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
1486
diff
changeset
|
262 data.affectedSOPInstanceUID = req->AffectedSOPInstanceUID; |
3309878b3e16
more information about the origin of requests submitted to the DICOM handlers
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
1486
diff
changeset
|
263 data.messageID = req->MessageID; |
0 | 264 if (assoc && assoc->params) |
265 { | |
1573
3309878b3e16
more information about the origin of requests submitted to the DICOM handlers
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
1486
diff
changeset
|
266 data.remoteAET = assoc->params->DULparams.callingAPTitle; |
3309878b3e16
more information about the origin of requests submitted to the DICOM handlers
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
1486
diff
changeset
|
267 data.calledAET = assoc->params->DULparams.calledAPTitle; |
0 | 268 } |
269 else | |
270 { | |
1573
3309878b3e16
more information about the origin of requests submitted to the DICOM handlers
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
1486
diff
changeset
|
271 data.remoteAET = ""; |
3309878b3e16
more information about the origin of requests submitted to the DICOM handlers
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
1486
diff
changeset
|
272 data.calledAET = ""; |
0 | 273 } |
274 | |
275 DcmFileFormat dcmff; | |
276 | |
277 // store SourceApplicationEntityTitle in metaheader | |
278 if (assoc && assoc->params) | |
279 { | |
280 const char *aet = assoc->params->DULparams.callingAPTitle; | |
281 if (aet) dcmff.getMetaInfo()->putAndInsertString(DCM_SourceApplicationEntityTitle, aet); | |
282 } | |
283 | |
284 // define an address where the information which will be received over the network will be stored | |
285 DcmDataset *dset = dcmff.getDataset(); | |
286 | |
287 cond = DIMSE_storeProvider(assoc, presID, req, NULL, /*opt_useMetaheader*/OFFalse, &dset, | |
1573
3309878b3e16
more information about the origin of requests submitted to the DICOM handlers
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
1486
diff
changeset
|
288 storeScpCallback, &data, |
3704
58f92b1c8061
Fix issue #167 (Job can't be cancelled - Handling of timeouts after established association)
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
3640
diff
changeset
|
289 /*opt_blockMode*/ (timeout ? DIMSE_NONBLOCKING : DIMSE_BLOCKING), |
58f92b1c8061
Fix issue #167 (Job can't be cancelled - Handling of timeouts after established association)
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
3640
diff
changeset
|
290 /*opt_dimse_timeout*/ timeout); |
0 | 291 |
292 // if some error occured, dump corresponding information and remove the outfile if necessary | |
293 if (cond.bad()) | |
294 { | |
295 OFString temp_str; | |
4284
756126cd2219
moving all logs from DicomNetworking folder into the "dicom" category
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
4140
diff
changeset
|
296 CLOG(ERROR, DICOM) << "Store SCP Failed: " << cond.text(); |
0 | 297 } |
298 | |
299 // return return value | |
300 return cond; | |
301 } | |
302 } |