Mercurial > hg > orthanc
annotate OrthancServer/Internals/CommandDispatcher.cpp @ 983:80d4f1618b33 plugins
Sample plugin to replace DCMTK by GDCM when decoding images
author | Sebastien Jodogne <s.jodogne@gmail.com> |
---|---|
date | Tue, 01 Jul 2014 12:01:58 +0200 |
parents | 84513f2ee1f3 |
children | 01414536c930 |
rev | line source |
---|---|
0 | 1 /** |
62 | 2 * Orthanc - A Lightweight, RESTful DICOM Store |
689 | 3 * Copyright (C) 2012-2014 Medical Physics Department, CHU of Liege, |
0 | 4 * Belgium |
5 * | |
6 * This program is free software: you can redistribute it and/or | |
7 * modify it under the terms of the GNU General Public License as | |
8 * published by the Free Software Foundation, either version 3 of the | |
9 * License, or (at your option) any later version. | |
136 | 10 * |
11 * In addition, as a special exception, the copyright holders of this | |
12 * program give permission to link the code of its release with the | |
13 * OpenSSL project's "OpenSSL" library (or with modified versions of it | |
14 * that use the same license as the "OpenSSL" library), and distribute | |
15 * the linked executables. You must obey the GNU General Public License | |
16 * in all respects for all of the code used other than "OpenSSL". If you | |
17 * modify file(s) with this exception, you may extend this exception to | |
18 * your version of the file(s), but you are not obligated to do so. If | |
19 * you do not wish to do so, delete this exception statement from your | |
20 * version. If you delete this exception statement from all source files | |
21 * in the program, then also delete it here. | |
0 | 22 * |
23 * This program is distributed in the hope that it will be useful, but | |
24 * WITHOUT ANY WARRANTY; without even the implied warranty of | |
25 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU | |
26 * General Public License for more details. | |
27 * | |
28 * You should have received a copy of the GNU General Public License | |
29 * along with this program. If not, see <http://www.gnu.org/licenses/>. | |
30 **/ | |
31 | |
32 | |
766
0a2f8c707c78
Fix missing licensing terms about reuse of some DCMTK code
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
690
diff
changeset
|
33 |
0a2f8c707c78
Fix missing licensing terms about reuse of some DCMTK code
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
690
diff
changeset
|
34 |
0a2f8c707c78
Fix missing licensing terms about reuse of some DCMTK code
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
690
diff
changeset
|
35 /*========================================================================= |
0a2f8c707c78
Fix missing licensing terms about reuse of some DCMTK code
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
690
diff
changeset
|
36 |
0a2f8c707c78
Fix missing licensing terms about reuse of some DCMTK code
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
690
diff
changeset
|
37 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:
690
diff
changeset
|
38 |
0a2f8c707c78
Fix missing licensing terms about reuse of some DCMTK code
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
690
diff
changeset
|
39 Program: DCMTK 3.6.0 |
0a2f8c707c78
Fix missing licensing terms about reuse of some DCMTK code
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
690
diff
changeset
|
40 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:
690
diff
changeset
|
41 |
0a2f8c707c78
Fix missing licensing terms about reuse of some DCMTK code
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
690
diff
changeset
|
42 Copyright (C) 1994-2011, OFFIS e.V. |
0a2f8c707c78
Fix missing licensing terms about reuse of some DCMTK code
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
690
diff
changeset
|
43 All rights reserved. |
0a2f8c707c78
Fix missing licensing terms about reuse of some DCMTK code
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
690
diff
changeset
|
44 |
0a2f8c707c78
Fix missing licensing terms about reuse of some DCMTK code
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
690
diff
changeset
|
45 This software and supporting documentation were developed by |
0a2f8c707c78
Fix missing licensing terms about reuse of some DCMTK code
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
690
diff
changeset
|
46 |
0a2f8c707c78
Fix missing licensing terms about reuse of some DCMTK code
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
690
diff
changeset
|
47 OFFIS e.V. |
0a2f8c707c78
Fix missing licensing terms about reuse of some DCMTK code
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
690
diff
changeset
|
48 R&D Division Health |
0a2f8c707c78
Fix missing licensing terms about reuse of some DCMTK code
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
690
diff
changeset
|
49 Escherweg 2 |
0a2f8c707c78
Fix missing licensing terms about reuse of some DCMTK code
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
690
diff
changeset
|
50 26121 Oldenburg, Germany |
0a2f8c707c78
Fix missing licensing terms about reuse of some DCMTK code
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
690
diff
changeset
|
51 |
0a2f8c707c78
Fix missing licensing terms about reuse of some DCMTK code
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
690
diff
changeset
|
52 Redistribution and use in source and binary forms, with or without |
0a2f8c707c78
Fix missing licensing terms about reuse of some DCMTK code
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
690
diff
changeset
|
53 modification, are permitted provided that the following conditions |
0a2f8c707c78
Fix missing licensing terms about reuse of some DCMTK code
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
690
diff
changeset
|
54 are met: |
0a2f8c707c78
Fix missing licensing terms about reuse of some DCMTK code
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
690
diff
changeset
|
55 |
0a2f8c707c78
Fix missing licensing terms about reuse of some DCMTK code
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
690
diff
changeset
|
56 - Redistributions of source code must retain the above copyright |
0a2f8c707c78
Fix missing licensing terms about reuse of some DCMTK code
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
690
diff
changeset
|
57 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:
690
diff
changeset
|
58 |
0a2f8c707c78
Fix missing licensing terms about reuse of some DCMTK code
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
690
diff
changeset
|
59 - Redistributions in binary form must reproduce the above copyright |
0a2f8c707c78
Fix missing licensing terms about reuse of some DCMTK code
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
690
diff
changeset
|
60 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:
690
diff
changeset
|
61 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:
690
diff
changeset
|
62 |
0a2f8c707c78
Fix missing licensing terms about reuse of some DCMTK code
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
690
diff
changeset
|
63 - Neither the name of OFFIS nor the names of its contributors may be |
0a2f8c707c78
Fix missing licensing terms about reuse of some DCMTK code
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
690
diff
changeset
|
64 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:
690
diff
changeset
|
65 without specific prior written permission. |
0a2f8c707c78
Fix missing licensing terms about reuse of some DCMTK code
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
690
diff
changeset
|
66 |
0a2f8c707c78
Fix missing licensing terms about reuse of some DCMTK code
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
690
diff
changeset
|
67 THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS |
0a2f8c707c78
Fix missing licensing terms about reuse of some DCMTK code
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
690
diff
changeset
|
68 "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT |
0a2f8c707c78
Fix missing licensing terms about reuse of some DCMTK code
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
690
diff
changeset
|
69 LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR |
0a2f8c707c78
Fix missing licensing terms about reuse of some DCMTK code
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
690
diff
changeset
|
70 A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT |
0a2f8c707c78
Fix missing licensing terms about reuse of some DCMTK code
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
690
diff
changeset
|
71 HOLDER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, |
0a2f8c707c78
Fix missing licensing terms about reuse of some DCMTK code
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
690
diff
changeset
|
72 SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT |
0a2f8c707c78
Fix missing licensing terms about reuse of some DCMTK code
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
690
diff
changeset
|
73 LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, |
0a2f8c707c78
Fix missing licensing terms about reuse of some DCMTK code
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
690
diff
changeset
|
74 DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY |
0a2f8c707c78
Fix missing licensing terms about reuse of some DCMTK code
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
690
diff
changeset
|
75 THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT |
0a2f8c707c78
Fix missing licensing terms about reuse of some DCMTK code
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
690
diff
changeset
|
76 (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE |
0a2f8c707c78
Fix missing licensing terms about reuse of some DCMTK code
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
690
diff
changeset
|
77 OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. |
0a2f8c707c78
Fix missing licensing terms about reuse of some DCMTK code
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
690
diff
changeset
|
78 |
0a2f8c707c78
Fix missing licensing terms about reuse of some DCMTK code
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
690
diff
changeset
|
79 =========================================================================*/ |
0a2f8c707c78
Fix missing licensing terms about reuse of some DCMTK code
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
690
diff
changeset
|
80 |
0a2f8c707c78
Fix missing licensing terms about reuse of some DCMTK code
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
690
diff
changeset
|
81 |
831
84513f2ee1f3
pch for unit tests and server
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
824
diff
changeset
|
82 #include "../PrecompiledHeadersServer.h" |
0 | 83 #include "CommandDispatcher.h" |
84 | |
85 #include "FindScp.h" | |
86 #include "StoreScp.h" | |
87 #include "MoveScp.h" | |
88 #include "../../Core/Toolbox.h" | |
89 | |
90 #include <dcmtk/dcmnet/dcasccfg.h> /* for class DcmAssociationConfiguration */ | |
101 | 91 #include <boost/lexical_cast.hpp> |
102
7593b57dc1bf
switch to google log
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
101
diff
changeset
|
92 #include <glog/logging.h> |
0 | 93 |
503 | 94 #define ORTHANC_PROMISCUOUS 1 |
95 | |
0 | 96 static OFBool opt_rejectWithoutImplementationUID = OFFalse; |
97 | |
98 | |
503 | 99 |
100 #if ORTHANC_PROMISCUOUS == 1 | |
101 static | |
102 DUL_PRESENTATIONCONTEXT * | |
103 findPresentationContextID(LST_HEAD * head, | |
104 T_ASC_PresentationContextID presentationContextID) | |
105 { | |
106 DUL_PRESENTATIONCONTEXT *pc; | |
107 LST_HEAD **l; | |
108 OFBool found = OFFalse; | |
109 | |
110 if (head == NULL) | |
111 return NULL; | |
112 | |
113 l = &head; | |
114 if (*l == NULL) | |
115 return NULL; | |
116 | |
117 pc = OFstatic_cast(DUL_PRESENTATIONCONTEXT *, LST_Head(l)); | |
118 (void)LST_Position(l, OFstatic_cast(LST_NODE *, pc)); | |
119 | |
120 while (pc && !found) { | |
121 if (pc->presentationContextID == presentationContextID) { | |
122 found = OFTrue; | |
123 } else { | |
124 pc = OFstatic_cast(DUL_PRESENTATIONCONTEXT *, LST_Next(l)); | |
125 } | |
126 } | |
127 return pc; | |
128 } | |
129 | |
130 | |
131 /** accept all presenstation contexts for unknown SOP classes, | |
132 * i.e. UIDs appearing in the list of abstract syntaxes | |
133 * where no corresponding name is defined in the UID dictionary. | |
134 * @param params pointer to association parameters structure | |
135 * @param transferSyntax transfer syntax to accept | |
136 * @param acceptedRole SCU/SCP role to accept | |
137 */ | |
138 static OFCondition acceptUnknownContextsWithTransferSyntax( | |
139 T_ASC_Parameters * params, | |
140 const char* transferSyntax, | |
141 T_ASC_SC_ROLE acceptedRole) | |
142 { | |
143 OFCondition cond = EC_Normal; | |
144 int n, i, k; | |
145 DUL_PRESENTATIONCONTEXT *dpc; | |
146 T_ASC_PresentationContext pc; | |
147 OFBool accepted = OFFalse; | |
148 OFBool abstractOK = OFFalse; | |
149 | |
150 n = ASC_countPresentationContexts(params); | |
151 for (i = 0; i < n; i++) | |
152 { | |
153 cond = ASC_getPresentationContext(params, i, &pc); | |
154 if (cond.bad()) return cond; | |
155 abstractOK = OFFalse; | |
156 accepted = OFFalse; | |
157 | |
158 if (dcmFindNameOfUID(pc.abstractSyntax) == NULL) | |
159 { | |
160 abstractOK = OFTrue; | |
161 | |
162 /* check the transfer syntax */ | |
163 for (k = 0; (k < OFstatic_cast(int, pc.transferSyntaxCount)) && !accepted; k++) | |
164 { | |
165 if (strcmp(pc.proposedTransferSyntaxes[k], transferSyntax) == 0) | |
166 { | |
167 accepted = OFTrue; | |
168 } | |
169 } | |
170 } | |
171 | |
172 if (accepted) | |
173 { | |
174 cond = ASC_acceptPresentationContext( | |
175 params, pc.presentationContextID, | |
176 transferSyntax, acceptedRole); | |
177 if (cond.bad()) return cond; | |
178 } else { | |
179 T_ASC_P_ResultReason reason; | |
180 | |
181 /* do not refuse if already accepted */ | |
182 dpc = findPresentationContextID(params->DULparams.acceptedPresentationContext, | |
183 pc.presentationContextID); | |
184 if ((dpc == NULL) || ((dpc != NULL) && (dpc->result != ASC_P_ACCEPTANCE))) | |
185 { | |
186 | |
187 if (abstractOK) { | |
188 reason = ASC_P_TRANSFERSYNTAXESNOTSUPPORTED; | |
189 } else { | |
190 reason = ASC_P_ABSTRACTSYNTAXNOTSUPPORTED; | |
191 } | |
192 /* | |
193 * If previously this presentation context was refused | |
194 * because of bad transfer syntax let it stay that way. | |
195 */ | |
196 if ((dpc != NULL) && (dpc->result == ASC_P_TRANSFERSYNTAXESNOTSUPPORTED)) | |
197 reason = ASC_P_TRANSFERSYNTAXESNOTSUPPORTED; | |
198 | |
199 cond = ASC_refusePresentationContext(params, pc.presentationContextID, reason); | |
200 if (cond.bad()) return cond; | |
201 } | |
202 } | |
203 } | |
204 return EC_Normal; | |
205 } | |
206 | |
207 | |
208 /** accept all presenstation contexts for unknown SOP classes, | |
209 * i.e. UIDs appearing in the list of abstract syntaxes | |
210 * where no corresponding name is defined in the UID dictionary. | |
211 * This method is passed a list of "preferred" transfer syntaxes. | |
212 * @param params pointer to association parameters structure | |
213 * @param transferSyntax transfer syntax to accept | |
214 * @param acceptedRole SCU/SCP role to accept | |
215 */ | |
216 static OFCondition acceptUnknownContextsWithPreferredTransferSyntaxes( | |
217 T_ASC_Parameters * params, | |
218 const char* transferSyntaxes[], int transferSyntaxCount, | |
219 T_ASC_SC_ROLE acceptedRole = ASC_SC_ROLE_DEFAULT) | |
220 { | |
221 OFCondition cond = EC_Normal; | |
222 /* | |
223 ** Accept in the order "least wanted" to "most wanted" transfer | |
224 ** syntax. Accepting a transfer syntax will override previously | |
225 ** accepted transfer syntaxes. | |
226 */ | |
227 for (int i = transferSyntaxCount - 1; i >= 0; i--) | |
228 { | |
229 cond = acceptUnknownContextsWithTransferSyntax(params, transferSyntaxes[i], acceptedRole); | |
230 if (cond.bad()) return cond; | |
231 } | |
232 return cond; | |
233 } | |
234 #endif | |
235 | |
236 | |
62 | 237 namespace Orthanc |
0 | 238 { |
239 namespace Internals | |
240 { | |
241 OFCondition AssociationCleanup(T_ASC_Association *assoc) | |
242 { | |
243 OFString temp_str; | |
244 OFCondition cond = ASC_dropSCPAssociation(assoc); | |
245 if (cond.bad()) | |
246 { | |
102
7593b57dc1bf
switch to google log
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
101
diff
changeset
|
247 LOG(FATAL) << cond.text(); |
0 | 248 return cond; |
249 } | |
250 | |
251 cond = ASC_destroyAssociation(&assoc); | |
252 if (cond.bad()) | |
253 { | |
102
7593b57dc1bf
switch to google log
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
101
diff
changeset
|
254 LOG(FATAL) << cond.text(); |
0 | 255 return cond; |
256 } | |
257 | |
258 return cond; | |
259 } | |
260 | |
261 | |
262 | |
263 CommandDispatcher* AcceptAssociation(const DicomServer& server, T_ASC_Network *net) | |
264 { | |
265 DcmAssociationConfiguration asccfg; | |
266 char buf[BUFSIZ]; | |
267 T_ASC_Association *assoc; | |
268 OFCondition cond; | |
269 OFString sprofile; | |
270 OFString temp_str; | |
271 | |
272 std::vector<const char*> knownAbstractSyntaxes; | |
273 | |
274 // For C-STORE | |
275 if (server.HasStoreRequestHandlerFactory()) | |
276 { | |
277 knownAbstractSyntaxes.push_back(UID_VerificationSOPClass); | |
278 } | |
279 | |
280 // For C-FIND | |
281 if (server.HasFindRequestHandlerFactory()) | |
282 { | |
283 knownAbstractSyntaxes.push_back(UID_FINDPatientRootQueryRetrieveInformationModel); | |
284 knownAbstractSyntaxes.push_back(UID_FINDStudyRootQueryRetrieveInformationModel); | |
285 } | |
286 | |
287 // For C-MOVE | |
288 if (server.HasMoveRequestHandlerFactory()) | |
289 { | |
290 knownAbstractSyntaxes.push_back(UID_MOVEStudyRootQueryRetrieveInformationModel); | |
665 | 291 knownAbstractSyntaxes.push_back(UID_MOVEPatientRootQueryRetrieveInformationModel); |
0 | 292 } |
293 | |
294 cond = ASC_receiveAssociation(net, &assoc, | |
295 /*opt_maxPDU*/ ASC_DEFAULTMAXPDU, | |
296 NULL, NULL, | |
297 /*opt_secureConnection*/ OFFalse, | |
298 DUL_NOBLOCK, 1); | |
299 | |
300 if (cond == DUL_NOASSOCIATIONREQUEST) | |
301 { | |
302 // Timeout | |
303 AssociationCleanup(assoc); | |
304 return NULL; | |
305 } | |
306 | |
307 // if some kind of error occured, take care of it | |
308 if (cond.bad()) | |
309 { | |
102
7593b57dc1bf
switch to google log
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
101
diff
changeset
|
310 LOG(ERROR) << "Receiving Association failed: " << cond.text(); |
0 | 311 // no matter what kind of error occurred, we need to do a cleanup |
312 AssociationCleanup(assoc); | |
313 return NULL; | |
314 } | |
315 | |
102
7593b57dc1bf
switch to google log
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
101
diff
changeset
|
316 LOG(INFO) << "Association Received"; |
0 | 317 |
661
d233b5090105
accept more transfer syntaxes for C-Store SCP, write meta-header when receiving files
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
620
diff
changeset
|
318 std::vector<const char*> transferSyntaxes; |
d233b5090105
accept more transfer syntaxes for C-Store SCP, write meta-header when receiving files
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
620
diff
changeset
|
319 |
d233b5090105
accept more transfer syntaxes for C-Store SCP, write meta-header when receiving files
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
620
diff
changeset
|
320 // This is the list of the transfer syntaxes that were supported up to Orthanc 0.7.1 |
d233b5090105
accept more transfer syntaxes for C-Store SCP, write meta-header when receiving files
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
620
diff
changeset
|
321 transferSyntaxes.push_back(UID_LittleEndianExplicitTransferSyntax); |
d233b5090105
accept more transfer syntaxes for C-Store SCP, write meta-header when receiving files
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
620
diff
changeset
|
322 transferSyntaxes.push_back(UID_BigEndianExplicitTransferSyntax); |
d233b5090105
accept more transfer syntaxes for C-Store SCP, write meta-header when receiving files
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
620
diff
changeset
|
323 transferSyntaxes.push_back(UID_LittleEndianImplicitTransferSyntax); |
665 | 324 |
325 // New transfer syntaxes supported since Orthanc 0.7.2 | |
661
d233b5090105
accept more transfer syntaxes for C-Store SCP, write meta-header when receiving files
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
620
diff
changeset
|
326 transferSyntaxes.push_back(UID_DeflatedExplicitVRLittleEndianTransferSyntax); |
d233b5090105
accept more transfer syntaxes for C-Store SCP, write meta-header when receiving files
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
620
diff
changeset
|
327 transferSyntaxes.push_back(UID_JPEGProcess1TransferSyntax); |
d233b5090105
accept more transfer syntaxes for C-Store SCP, write meta-header when receiving files
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
620
diff
changeset
|
328 transferSyntaxes.push_back(UID_JPEGProcess2_4TransferSyntax); |
d233b5090105
accept more transfer syntaxes for C-Store SCP, write meta-header when receiving files
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
620
diff
changeset
|
329 transferSyntaxes.push_back(UID_JPEGProcess3_5TransferSyntax); |
d233b5090105
accept more transfer syntaxes for C-Store SCP, write meta-header when receiving files
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
620
diff
changeset
|
330 transferSyntaxes.push_back(UID_JPEGProcess6_8TransferSyntax); |
d233b5090105
accept more transfer syntaxes for C-Store SCP, write meta-header when receiving files
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
620
diff
changeset
|
331 transferSyntaxes.push_back(UID_JPEGProcess7_9TransferSyntax); |
d233b5090105
accept more transfer syntaxes for C-Store SCP, write meta-header when receiving files
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
620
diff
changeset
|
332 transferSyntaxes.push_back(UID_JPEGProcess10_12TransferSyntax); |
d233b5090105
accept more transfer syntaxes for C-Store SCP, write meta-header when receiving files
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
620
diff
changeset
|
333 transferSyntaxes.push_back(UID_JPEGProcess11_13TransferSyntax); |
d233b5090105
accept more transfer syntaxes for C-Store SCP, write meta-header when receiving files
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
620
diff
changeset
|
334 transferSyntaxes.push_back(UID_JPEGProcess14TransferSyntax); |
d233b5090105
accept more transfer syntaxes for C-Store SCP, write meta-header when receiving files
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
620
diff
changeset
|
335 transferSyntaxes.push_back(UID_JPEGProcess15TransferSyntax); |
d233b5090105
accept more transfer syntaxes for C-Store SCP, write meta-header when receiving files
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
620
diff
changeset
|
336 transferSyntaxes.push_back(UID_JPEGProcess16_18TransferSyntax); |
d233b5090105
accept more transfer syntaxes for C-Store SCP, write meta-header when receiving files
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
620
diff
changeset
|
337 transferSyntaxes.push_back(UID_JPEGProcess17_19TransferSyntax); |
d233b5090105
accept more transfer syntaxes for C-Store SCP, write meta-header when receiving files
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
620
diff
changeset
|
338 transferSyntaxes.push_back(UID_JPEGProcess20_22TransferSyntax); |
d233b5090105
accept more transfer syntaxes for C-Store SCP, write meta-header when receiving files
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
620
diff
changeset
|
339 transferSyntaxes.push_back(UID_JPEGProcess21_23TransferSyntax); |
d233b5090105
accept more transfer syntaxes for C-Store SCP, write meta-header when receiving files
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
620
diff
changeset
|
340 transferSyntaxes.push_back(UID_JPEGProcess24_26TransferSyntax); |
d233b5090105
accept more transfer syntaxes for C-Store SCP, write meta-header when receiving files
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
620
diff
changeset
|
341 transferSyntaxes.push_back(UID_JPEGProcess25_27TransferSyntax); |
d233b5090105
accept more transfer syntaxes for C-Store SCP, write meta-header when receiving files
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
620
diff
changeset
|
342 transferSyntaxes.push_back(UID_JPEGProcess28TransferSyntax); |
d233b5090105
accept more transfer syntaxes for C-Store SCP, write meta-header when receiving files
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
620
diff
changeset
|
343 transferSyntaxes.push_back(UID_JPEGProcess29TransferSyntax); |
d233b5090105
accept more transfer syntaxes for C-Store SCP, write meta-header when receiving files
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
620
diff
changeset
|
344 transferSyntaxes.push_back(UID_JPEGProcess14SV1TransferSyntax); |
d233b5090105
accept more transfer syntaxes for C-Store SCP, write meta-header when receiving files
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
620
diff
changeset
|
345 transferSyntaxes.push_back(UID_JPEGLSLosslessTransferSyntax); |
d233b5090105
accept more transfer syntaxes for C-Store SCP, write meta-header when receiving files
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
620
diff
changeset
|
346 transferSyntaxes.push_back(UID_JPEGLSLossyTransferSyntax); |
d233b5090105
accept more transfer syntaxes for C-Store SCP, write meta-header when receiving files
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
620
diff
changeset
|
347 transferSyntaxes.push_back(UID_JPEG2000LosslessOnlyTransferSyntax); |
d233b5090105
accept more transfer syntaxes for C-Store SCP, write meta-header when receiving files
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
620
diff
changeset
|
348 transferSyntaxes.push_back(UID_JPEG2000TransferSyntax); |
d233b5090105
accept more transfer syntaxes for C-Store SCP, write meta-header when receiving files
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
620
diff
changeset
|
349 transferSyntaxes.push_back(UID_JPEG2000Part2MulticomponentImageCompressionLosslessOnlyTransferSyntax); |
d233b5090105
accept more transfer syntaxes for C-Store SCP, write meta-header when receiving files
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
620
diff
changeset
|
350 transferSyntaxes.push_back(UID_JPEG2000Part2MulticomponentImageCompressionTransferSyntax); |
d233b5090105
accept more transfer syntaxes for C-Store SCP, write meta-header when receiving files
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
620
diff
changeset
|
351 transferSyntaxes.push_back(UID_JPIPReferencedTransferSyntax); |
d233b5090105
accept more transfer syntaxes for C-Store SCP, write meta-header when receiving files
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
620
diff
changeset
|
352 transferSyntaxes.push_back(UID_JPIPReferencedDeflateTransferSyntax); |
d233b5090105
accept more transfer syntaxes for C-Store SCP, write meta-header when receiving files
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
620
diff
changeset
|
353 transferSyntaxes.push_back(UID_MPEG2MainProfileAtMainLevelTransferSyntax); |
d233b5090105
accept more transfer syntaxes for C-Store SCP, write meta-header when receiving files
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
620
diff
changeset
|
354 transferSyntaxes.push_back(UID_MPEG2MainProfileAtHighLevelTransferSyntax); |
d233b5090105
accept more transfer syntaxes for C-Store SCP, write meta-header when receiving files
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
620
diff
changeset
|
355 transferSyntaxes.push_back(UID_RLELosslessTransferSyntax); |
0 | 356 |
357 /* accept the Verification SOP Class if presented */ | |
661
d233b5090105
accept more transfer syntaxes for C-Store SCP, write meta-header when receiving files
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
620
diff
changeset
|
358 cond = ASC_acceptContextsWithPreferredTransferSyntaxes( assoc->params, &knownAbstractSyntaxes[0], knownAbstractSyntaxes.size(), &transferSyntaxes[0], transferSyntaxes.size()); |
0 | 359 if (cond.bad()) |
360 { | |
102
7593b57dc1bf
switch to google log
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
101
diff
changeset
|
361 LOG(INFO) << cond.text(); |
0 | 362 AssociationCleanup(assoc); |
363 return NULL; | |
364 } | |
365 | |
366 /* the array of Storage SOP Class UIDs comes from dcuid.h */ | |
661
d233b5090105
accept more transfer syntaxes for C-Store SCP, write meta-header when receiving files
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
620
diff
changeset
|
367 cond = ASC_acceptContextsWithPreferredTransferSyntaxes( assoc->params, dcmAllStorageSOPClassUIDs, numberOfAllDcmStorageSOPClassUIDs, &transferSyntaxes[0], transferSyntaxes.size()); |
0 | 368 if (cond.bad()) |
369 { | |
102
7593b57dc1bf
switch to google log
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
101
diff
changeset
|
370 LOG(INFO) << cond.text(); |
0 | 371 AssociationCleanup(assoc); |
372 return NULL; | |
373 } | |
374 | |
503 | 375 #if ORTHANC_PROMISCUOUS == 1 |
376 /* accept everything not known not to be a storage SOP class */ | |
377 cond = acceptUnknownContextsWithPreferredTransferSyntaxes( | |
661
d233b5090105
accept more transfer syntaxes for C-Store SCP, write meta-header when receiving files
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
620
diff
changeset
|
378 assoc->params, &transferSyntaxes[0], transferSyntaxes.size()); |
503 | 379 if (cond.bad()) |
380 { | |
381 LOG(INFO) << cond.text(); | |
382 AssociationCleanup(assoc); | |
383 return NULL; | |
384 } | |
385 #endif | |
386 | |
0 | 387 /* set our app title */ |
388 ASC_setAPTitles(assoc->params, NULL, NULL, server.GetApplicationEntityTitle().c_str()); | |
389 | |
390 /* acknowledge or reject this association */ | |
391 cond = ASC_getApplicationContextName(assoc->params, buf); | |
392 if ((cond.bad()) || strcmp(buf, UID_StandardApplicationContext) != 0) | |
393 { | |
394 /* reject: the application context name is not supported */ | |
395 T_ASC_RejectParameters rej = | |
396 { | |
397 ASC_RESULT_REJECTEDPERMANENT, | |
398 ASC_SOURCE_SERVICEUSER, | |
399 ASC_REASON_SU_APPCONTEXTNAMENOTSUPPORTED | |
400 }; | |
401 | |
102
7593b57dc1bf
switch to google log
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
101
diff
changeset
|
402 LOG(INFO) << "Association Rejected: Bad Application Context Name: " << buf; |
0 | 403 cond = ASC_rejectAssociation(assoc, &rej); |
404 if (cond.bad()) | |
405 { | |
102
7593b57dc1bf
switch to google log
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
101
diff
changeset
|
406 LOG(INFO) << cond.text(); |
0 | 407 } |
408 AssociationCleanup(assoc); | |
409 return NULL; | |
410 } | |
620
4aa6f0d79947
security filter for dicom requests
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
503
diff
changeset
|
411 |
4aa6f0d79947
security filter for dicom requests
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
503
diff
changeset
|
412 std::string callingIP; |
4aa6f0d79947
security filter for dicom requests
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
503
diff
changeset
|
413 std::string callingTitle; |
0 | 414 |
415 /* check the AETs */ | |
416 { | |
417 DIC_AE callingTitle_C; | |
418 DIC_AE calledTitle_C; | |
419 DIC_AE callingIP_C; | |
420 DIC_AE calledIP_C; | |
421 if (ASC_getAPTitles(assoc->params, callingTitle_C, calledTitle_C, NULL).bad() || | |
422 ASC_getPresentationAddresses(assoc->params, callingIP_C, calledIP_C).bad()) | |
423 { | |
424 T_ASC_RejectParameters rej = | |
425 { | |
426 ASC_RESULT_REJECTEDPERMANENT, | |
427 ASC_SOURCE_SERVICEUSER, | |
428 ASC_REASON_SU_NOREASON | |
429 }; | |
430 ASC_rejectAssociation(assoc, &rej); | |
431 AssociationCleanup(assoc); | |
432 return NULL; | |
433 } | |
434 | |
620
4aa6f0d79947
security filter for dicom requests
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
503
diff
changeset
|
435 callingIP = std::string(/*OFSTRING_GUARD*/(callingIP_C)); |
4aa6f0d79947
security filter for dicom requests
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
503
diff
changeset
|
436 callingTitle = std::string(/*OFSTRING_GUARD*/(callingTitle_C)); |
101 | 437 std::string calledTitle(/*OFSTRING_GUARD*/(calledTitle_C)); |
0 | 438 |
690
2e67366aab83
case-insensitive matching of Application Entity Titles
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
689
diff
changeset
|
439 if (!server.IsMyAETitle(calledTitle)) |
0 | 440 { |
441 T_ASC_RejectParameters rej = | |
442 { | |
443 ASC_RESULT_REJECTEDPERMANENT, | |
444 ASC_SOURCE_SERVICEUSER, | |
445 ASC_REASON_SU_CALLEDAETITLENOTRECOGNIZED | |
446 }; | |
447 ASC_rejectAssociation(assoc, &rej); | |
448 AssociationCleanup(assoc); | |
449 return NULL; | |
450 } | |
451 | |
452 if (server.HasApplicationEntityFilter() && | |
620
4aa6f0d79947
security filter for dicom requests
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
503
diff
changeset
|
453 !server.GetApplicationEntityFilter().IsAllowedConnection(callingIP, callingTitle)) |
0 | 454 { |
455 T_ASC_RejectParameters rej = | |
456 { | |
457 ASC_RESULT_REJECTEDPERMANENT, | |
458 ASC_SOURCE_SERVICEUSER, | |
459 ASC_REASON_SU_CALLINGAETITLENOTRECOGNIZED | |
460 }; | |
461 ASC_rejectAssociation(assoc, &rej); | |
462 AssociationCleanup(assoc); | |
463 return NULL; | |
464 } | |
465 } | |
466 | |
467 if (opt_rejectWithoutImplementationUID && strlen(assoc->params->theirImplementationClassUID) == 0) | |
468 { | |
469 /* reject: the no implementation Class UID provided */ | |
470 T_ASC_RejectParameters rej = | |
471 { | |
472 ASC_RESULT_REJECTEDPERMANENT, | |
473 ASC_SOURCE_SERVICEUSER, | |
474 ASC_REASON_SU_NOREASON | |
475 }; | |
476 | |
102
7593b57dc1bf
switch to google log
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
101
diff
changeset
|
477 LOG(INFO) << "Association Rejected: No Implementation Class UID provided"; |
0 | 478 cond = ASC_rejectAssociation(assoc, &rej); |
479 if (cond.bad()) | |
480 { | |
102
7593b57dc1bf
switch to google log
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
101
diff
changeset
|
481 LOG(INFO) << cond.text(); |
0 | 482 } |
483 AssociationCleanup(assoc); | |
484 return NULL; | |
485 } | |
486 | |
487 { | |
488 cond = ASC_acknowledgeAssociation(assoc); | |
489 if (cond.bad()) | |
490 { | |
102
7593b57dc1bf
switch to google log
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
101
diff
changeset
|
491 LOG(ERROR) << cond.text(); |
0 | 492 AssociationCleanup(assoc); |
493 return NULL; | |
494 } | |
102
7593b57dc1bf
switch to google log
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
101
diff
changeset
|
495 LOG(INFO) << "Association Acknowledged (Max Send PDV: " << assoc->sendPDVLength << ")"; |
0 | 496 if (ASC_countAcceptedPresentationContexts(assoc->params) == 0) |
102
7593b57dc1bf
switch to google log
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
101
diff
changeset
|
497 LOG(INFO) << " (but no valid presentation contexts)"; |
0 | 498 } |
499 | |
620
4aa6f0d79947
security filter for dicom requests
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
503
diff
changeset
|
500 IApplicationEntityFilter* filter = server.HasApplicationEntityFilter() ? &server.GetApplicationEntityFilter() : NULL; |
4aa6f0d79947
security filter for dicom requests
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
503
diff
changeset
|
501 return new CommandDispatcher(server, assoc, callingIP, callingTitle, filter); |
0 | 502 } |
503 | |
504 bool CommandDispatcher::Step() | |
505 /* | |
506 * This function receives DIMSE commmands over the network connection | |
507 * and handles these commands correspondingly. Note that in case of | |
508 * storscp only C-ECHO-RQ and C-STORE-RQ commands can be processed. | |
509 */ | |
510 { | |
511 bool finished = false; | |
512 | |
513 // receive a DIMSE command over the network, with a timeout of 1 second | |
514 DcmDataset *statusDetail = NULL; | |
515 T_ASC_PresentationContextID presID = 0; | |
516 T_DIMSE_Message msg; | |
517 | |
518 OFCondition cond = DIMSE_receiveCommand(assoc_, DIMSE_NONBLOCKING, 1, &presID, &msg, &statusDetail); | |
519 elapsedTimeSinceLastCommand_++; | |
520 | |
521 // if the command which was received has extra status | |
522 // detail information, dump this information | |
523 if (statusDetail != NULL) | |
524 { | |
101 | 525 //LOG4CPP_WARN(Internals::GetLogger(), "Status Detail:" << OFendl << DcmObject::PrintHelper(*statusDetail)); |
0 | 526 delete statusDetail; |
527 } | |
528 | |
529 if (cond == DIMSE_OUTOFRESOURCES) | |
530 { | |
531 finished = true; | |
532 } | |
533 else if (cond == DIMSE_NODATAAVAILABLE) | |
534 { | |
535 // Timeout due to DIMSE_NONBLOCKING | |
536 if (clientTimeout_ != 0 && | |
537 elapsedTimeSinceLastCommand_ >= clientTimeout_) | |
538 { | |
539 // This timeout is actually a client timeout | |
540 finished = true; | |
541 } | |
542 } | |
543 else if (cond == EC_Normal) | |
544 { | |
545 // Reset the client timeout counter | |
546 elapsedTimeSinceLastCommand_ = 0; | |
547 | |
620
4aa6f0d79947
security filter for dicom requests
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
503
diff
changeset
|
548 // Convert the type of request to Orthanc's internal type |
4aa6f0d79947
security filter for dicom requests
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
503
diff
changeset
|
549 bool supported = false; |
4aa6f0d79947
security filter for dicom requests
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
503
diff
changeset
|
550 DicomRequestType request; |
0 | 551 switch (msg.CommandField) |
552 { | |
620
4aa6f0d79947
security filter for dicom requests
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
503
diff
changeset
|
553 case DIMSE_C_ECHO_RQ: |
4aa6f0d79947
security filter for dicom requests
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
503
diff
changeset
|
554 request = DicomRequestType_Echo; |
4aa6f0d79947
security filter for dicom requests
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
503
diff
changeset
|
555 supported = true; |
4aa6f0d79947
security filter for dicom requests
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
503
diff
changeset
|
556 break; |
4aa6f0d79947
security filter for dicom requests
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
503
diff
changeset
|
557 |
4aa6f0d79947
security filter for dicom requests
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
503
diff
changeset
|
558 case DIMSE_C_STORE_RQ: |
4aa6f0d79947
security filter for dicom requests
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
503
diff
changeset
|
559 request = DicomRequestType_Store; |
4aa6f0d79947
security filter for dicom requests
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
503
diff
changeset
|
560 supported = true; |
4aa6f0d79947
security filter for dicom requests
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
503
diff
changeset
|
561 break; |
4aa6f0d79947
security filter for dicom requests
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
503
diff
changeset
|
562 |
4aa6f0d79947
security filter for dicom requests
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
503
diff
changeset
|
563 case DIMSE_C_MOVE_RQ: |
4aa6f0d79947
security filter for dicom requests
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
503
diff
changeset
|
564 request = DicomRequestType_Move; |
4aa6f0d79947
security filter for dicom requests
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
503
diff
changeset
|
565 supported = true; |
4aa6f0d79947
security filter for dicom requests
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
503
diff
changeset
|
566 break; |
4aa6f0d79947
security filter for dicom requests
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
503
diff
changeset
|
567 |
4aa6f0d79947
security filter for dicom requests
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
503
diff
changeset
|
568 case DIMSE_C_FIND_RQ: |
4aa6f0d79947
security filter for dicom requests
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
503
diff
changeset
|
569 request = DicomRequestType_Find; |
4aa6f0d79947
security filter for dicom requests
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
503
diff
changeset
|
570 supported = true; |
4aa6f0d79947
security filter for dicom requests
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
503
diff
changeset
|
571 break; |
0 | 572 |
620
4aa6f0d79947
security filter for dicom requests
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
503
diff
changeset
|
573 default: |
4aa6f0d79947
security filter for dicom requests
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
503
diff
changeset
|
574 // we cannot handle this kind of message |
4aa6f0d79947
security filter for dicom requests
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
503
diff
changeset
|
575 cond = DIMSE_BADCOMMANDTYPE; |
4aa6f0d79947
security filter for dicom requests
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
503
diff
changeset
|
576 LOG(ERROR) << "cannot handle command: 0x" << std::hex << msg.CommandField; |
4aa6f0d79947
security filter for dicom requests
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
503
diff
changeset
|
577 break; |
4aa6f0d79947
security filter for dicom requests
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
503
diff
changeset
|
578 } |
4aa6f0d79947
security filter for dicom requests
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
503
diff
changeset
|
579 |
0 | 580 |
620
4aa6f0d79947
security filter for dicom requests
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
503
diff
changeset
|
581 // Check whether this request is allowed by the security filter |
4aa6f0d79947
security filter for dicom requests
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
503
diff
changeset
|
582 if (supported && |
4aa6f0d79947
security filter for dicom requests
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
503
diff
changeset
|
583 filter_ != NULL && |
4aa6f0d79947
security filter for dicom requests
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
503
diff
changeset
|
584 !filter_->IsAllowedRequest(callingIP_, callingAETitle_, request)) |
4aa6f0d79947
security filter for dicom requests
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
503
diff
changeset
|
585 { |
4aa6f0d79947
security filter for dicom requests
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
503
diff
changeset
|
586 LOG(ERROR) << EnumerationToString(request) |
4aa6f0d79947
security filter for dicom requests
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
503
diff
changeset
|
587 << " requests are disallowed for the AET \"" |
4aa6f0d79947
security filter for dicom requests
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
503
diff
changeset
|
588 << callingAETitle_ << "\""; |
4aa6f0d79947
security filter for dicom requests
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
503
diff
changeset
|
589 cond = DIMSE_BADCOMMANDTYPE; |
4aa6f0d79947
security filter for dicom requests
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
503
diff
changeset
|
590 supported = false; |
4aa6f0d79947
security filter for dicom requests
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
503
diff
changeset
|
591 } |
4aa6f0d79947
security filter for dicom requests
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
503
diff
changeset
|
592 |
4aa6f0d79947
security filter for dicom requests
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
503
diff
changeset
|
593 // in case we received a supported message, process this command |
4aa6f0d79947
security filter for dicom requests
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
503
diff
changeset
|
594 if (supported) |
4aa6f0d79947
security filter for dicom requests
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
503
diff
changeset
|
595 { |
4aa6f0d79947
security filter for dicom requests
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
503
diff
changeset
|
596 // If anything goes wrong, there will be a "BADCOMMANDTYPE" answer |
4aa6f0d79947
security filter for dicom requests
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
503
diff
changeset
|
597 cond = DIMSE_BADCOMMANDTYPE; |
4aa6f0d79947
security filter for dicom requests
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
503
diff
changeset
|
598 |
4aa6f0d79947
security filter for dicom requests
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
503
diff
changeset
|
599 switch (request) |
0 | 600 { |
620
4aa6f0d79947
security filter for dicom requests
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
503
diff
changeset
|
601 case DicomRequestType_Echo: |
4aa6f0d79947
security filter for dicom requests
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
503
diff
changeset
|
602 cond = EchoScp(assoc_, &msg, presID); |
4aa6f0d79947
security filter for dicom requests
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
503
diff
changeset
|
603 break; |
4aa6f0d79947
security filter for dicom requests
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
503
diff
changeset
|
604 |
4aa6f0d79947
security filter for dicom requests
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
503
diff
changeset
|
605 case DicomRequestType_Store: |
4aa6f0d79947
security filter for dicom requests
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
503
diff
changeset
|
606 if (server_.HasStoreRequestHandlerFactory()) // Should always be true |
4aa6f0d79947
security filter for dicom requests
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
503
diff
changeset
|
607 { |
4aa6f0d79947
security filter for dicom requests
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
503
diff
changeset
|
608 std::auto_ptr<IStoreRequestHandler> handler |
4aa6f0d79947
security filter for dicom requests
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
503
diff
changeset
|
609 (server_.GetStoreRequestHandlerFactory().ConstructStoreRequestHandler()); |
4aa6f0d79947
security filter for dicom requests
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
503
diff
changeset
|
610 cond = Internals::storeScp(assoc_, &msg, presID, *handler); |
4aa6f0d79947
security filter for dicom requests
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
503
diff
changeset
|
611 } |
4aa6f0d79947
security filter for dicom requests
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
503
diff
changeset
|
612 break; |
0 | 613 |
620
4aa6f0d79947
security filter for dicom requests
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
503
diff
changeset
|
614 case DicomRequestType_Move: |
4aa6f0d79947
security filter for dicom requests
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
503
diff
changeset
|
615 if (server_.HasMoveRequestHandlerFactory()) // Should always be true |
4aa6f0d79947
security filter for dicom requests
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
503
diff
changeset
|
616 { |
4aa6f0d79947
security filter for dicom requests
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
503
diff
changeset
|
617 std::auto_ptr<IMoveRequestHandler> handler |
4aa6f0d79947
security filter for dicom requests
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
503
diff
changeset
|
618 (server_.GetMoveRequestHandlerFactory().ConstructMoveRequestHandler()); |
4aa6f0d79947
security filter for dicom requests
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
503
diff
changeset
|
619 cond = Internals::moveScp(assoc_, &msg, presID, *handler); |
4aa6f0d79947
security filter for dicom requests
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
503
diff
changeset
|
620 } |
4aa6f0d79947
security filter for dicom requests
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
503
diff
changeset
|
621 break; |
4aa6f0d79947
security filter for dicom requests
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
503
diff
changeset
|
622 |
4aa6f0d79947
security filter for dicom requests
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
503
diff
changeset
|
623 case DicomRequestType_Find: |
4aa6f0d79947
security filter for dicom requests
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
503
diff
changeset
|
624 if (server_.HasFindRequestHandlerFactory()) // Should always be true |
4aa6f0d79947
security filter for dicom requests
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
503
diff
changeset
|
625 { |
4aa6f0d79947
security filter for dicom requests
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
503
diff
changeset
|
626 std::auto_ptr<IFindRequestHandler> handler |
4aa6f0d79947
security filter for dicom requests
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
503
diff
changeset
|
627 (server_.GetFindRequestHandlerFactory().ConstructFindRequestHandler()); |
665 | 628 cond = Internals::findScp(assoc_, &msg, presID, *handler, callingAETitle_); |
620
4aa6f0d79947
security filter for dicom requests
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
503
diff
changeset
|
629 } |
4aa6f0d79947
security filter for dicom requests
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
503
diff
changeset
|
630 break; |
4aa6f0d79947
security filter for dicom requests
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
503
diff
changeset
|
631 |
4aa6f0d79947
security filter for dicom requests
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
503
diff
changeset
|
632 default: |
4aa6f0d79947
security filter for dicom requests
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
503
diff
changeset
|
633 // Should never happen |
4aa6f0d79947
security filter for dicom requests
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
503
diff
changeset
|
634 break; |
0 | 635 } |
636 } | |
637 } | |
638 else | |
639 { | |
640 // Bad status, which indicates the closing of the connection by | |
641 // the peer or a network error | |
642 finished = true; | |
665 | 643 |
667
aa2ab67d913d
log error to log info
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
665
diff
changeset
|
644 LOG(INFO) << cond.text(); |
0 | 645 } |
646 | |
647 if (finished) | |
648 { | |
649 if (cond == DUL_PEERREQUESTEDRELEASE) | |
650 { | |
102
7593b57dc1bf
switch to google log
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
101
diff
changeset
|
651 LOG(INFO) << "Association Release"; |
0 | 652 ASC_acknowledgeRelease(assoc_); |
653 } | |
654 else if (cond == DUL_PEERABORTEDASSOCIATION) | |
655 { | |
102
7593b57dc1bf
switch to google log
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
101
diff
changeset
|
656 LOG(INFO) << "Association Aborted"; |
0 | 657 } |
658 else | |
659 { | |
660 OFString temp_str; | |
102
7593b57dc1bf
switch to google log
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
101
diff
changeset
|
661 LOG(ERROR) << "DIMSE failure (aborting association): " << cond.text(); |
0 | 662 /* some kind of error so abort the association */ |
663 ASC_abortAssociation(assoc_); | |
664 } | |
665 } | |
666 | |
667 return !finished; | |
668 } | |
669 | |
670 | |
671 OFCondition EchoScp( T_ASC_Association * assoc, T_DIMSE_Message * msg, T_ASC_PresentationContextID presID) | |
672 { | |
673 OFString temp_str; | |
102
7593b57dc1bf
switch to google log
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
101
diff
changeset
|
674 LOG(INFO) << "Received Echo Request"; |
7593b57dc1bf
switch to google log
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
101
diff
changeset
|
675 //LOG(DEBUG) << DIMSE_dumpMessage(temp_str, msg->msg.CEchoRQ, DIMSE_INCOMING, NULL, presID)); |
0 | 676 |
677 /* the echo succeeded !! */ | |
678 OFCondition cond = DIMSE_sendEchoResponse(assoc, presID, &msg->msg.CEchoRQ, STATUS_Success, NULL); | |
679 if (cond.bad()) | |
680 { | |
102
7593b57dc1bf
switch to google log
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
101
diff
changeset
|
681 LOG(ERROR) << "Echo SCP Failed: " << cond.text(); |
0 | 682 } |
683 return cond; | |
684 } | |
685 } | |
686 } |