annotate OrthancFramework/Sources/DicomNetworking/Internals/GetScp.cpp @ 4224:38d446c9ee1d

fix
author Sebastien Jodogne <s.jodogne@gmail.com>
date Wed, 30 Sep 2020 17:59:09 +0200
parents 7112a8af0b63
children 6f5d4bfb2c90
Ignore whitespace changes - Everywhere: Within whitespace: At end of lines:
rev   line source
3818
4f78da5613a1 Add C-GET SCP support
Stacy Loesch <stacy.loesch@varian.com>
parents:
diff changeset
1 /**
4f78da5613a1 Add C-GET SCP support
Stacy Loesch <stacy.loesch@varian.com>
parents:
diff changeset
2 * Orthanc - A Lightweight, RESTful DICOM Store
4f78da5613a1 Add C-GET SCP support
Stacy Loesch <stacy.loesch@varian.com>
parents:
diff changeset
3 * Copyright (C) 2012-2016 Sebastien Jodogne, Medical Physics
4f78da5613a1 Add C-GET SCP support
Stacy Loesch <stacy.loesch@varian.com>
parents:
diff changeset
4 * Department, University Hospital of Liege, Belgium
3970
4d1dcdf5c57e fix date in some files
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 3959
diff changeset
5 * Copyright (C) 2017-2020 Osimis S.A., Belgium
3818
4f78da5613a1 Add C-GET SCP support
Stacy Loesch <stacy.loesch@varian.com>
parents:
diff changeset
6 *
4f78da5613a1 Add C-GET SCP support
Stacy Loesch <stacy.loesch@varian.com>
parents:
diff changeset
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.
3818
4f78da5613a1 Add C-GET SCP support
Stacy Loesch <stacy.loesch@varian.com>
parents:
diff changeset
11 *
4f78da5613a1 Add C-GET SCP support
Stacy Loesch <stacy.loesch@varian.com>
parents:
diff changeset
12 * This program is distributed in the hope that it will be useful, but
4f78da5613a1 Add C-GET SCP support
Stacy Loesch <stacy.loesch@varian.com>
parents:
diff changeset
13 * WITHOUT ANY WARRANTY; without even the implied warranty of
4f78da5613a1 Add C-GET SCP support
Stacy Loesch <stacy.loesch@varian.com>
parents:
diff changeset
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.
3818
4f78da5613a1 Add C-GET SCP support
Stacy Loesch <stacy.loesch@varian.com>
parents:
diff changeset
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/>.
3818
4f78da5613a1 Add C-GET SCP support
Stacy Loesch <stacy.loesch@varian.com>
parents:
diff changeset
20 **/
4f78da5613a1 Add C-GET SCP support
Stacy Loesch <stacy.loesch@varian.com>
parents:
diff changeset
21
4f78da5613a1 Add C-GET SCP support
Stacy Loesch <stacy.loesch@varian.com>
parents:
diff changeset
22
4f78da5613a1 Add C-GET SCP support
Stacy Loesch <stacy.loesch@varian.com>
parents:
diff changeset
23
4f78da5613a1 Add C-GET SCP support
Stacy Loesch <stacy.loesch@varian.com>
parents:
diff changeset
24
4f78da5613a1 Add C-GET SCP support
Stacy Loesch <stacy.loesch@varian.com>
parents:
diff changeset
25 /*=========================================================================
4f78da5613a1 Add C-GET SCP support
Stacy Loesch <stacy.loesch@varian.com>
parents:
diff changeset
26
4f78da5613a1 Add C-GET SCP support
Stacy Loesch <stacy.loesch@varian.com>
parents:
diff changeset
27 This file is based on portions of the following project:
4f78da5613a1 Add C-GET SCP support
Stacy Loesch <stacy.loesch@varian.com>
parents:
diff changeset
28
4f78da5613a1 Add C-GET SCP support
Stacy Loesch <stacy.loesch@varian.com>
parents:
diff changeset
29 Program: DCMTK 3.6.0
4f78da5613a1 Add C-GET SCP support
Stacy Loesch <stacy.loesch@varian.com>
parents:
diff changeset
30 Module: http://dicom.offis.de/dcmtk.php.en
4f78da5613a1 Add C-GET SCP support
Stacy Loesch <stacy.loesch@varian.com>
parents:
diff changeset
31
3953
620e87e9e816 c-get: fixing memory with failedUIDs_
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 3818
diff changeset
32 Copyright (C) 1994-2011, OFFIS e.V.
620e87e9e816 c-get: fixing memory with failedUIDs_
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 3818
diff changeset
33 All rights reserved.
3818
4f78da5613a1 Add C-GET SCP support
Stacy Loesch <stacy.loesch@varian.com>
parents:
diff changeset
34
3953
620e87e9e816 c-get: fixing memory with failedUIDs_
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 3818
diff changeset
35 This software and supporting documentation were developed by
3818
4f78da5613a1 Add C-GET SCP support
Stacy Loesch <stacy.loesch@varian.com>
parents:
diff changeset
36
4f78da5613a1 Add C-GET SCP support
Stacy Loesch <stacy.loesch@varian.com>
parents:
diff changeset
37 OFFIS e.V.
4f78da5613a1 Add C-GET SCP support
Stacy Loesch <stacy.loesch@varian.com>
parents:
diff changeset
38 R&D Division Health
4f78da5613a1 Add C-GET SCP support
Stacy Loesch <stacy.loesch@varian.com>
parents:
diff changeset
39 Escherweg 2
4f78da5613a1 Add C-GET SCP support
Stacy Loesch <stacy.loesch@varian.com>
parents:
diff changeset
40 26121 Oldenburg, Germany
4f78da5613a1 Add C-GET SCP support
Stacy Loesch <stacy.loesch@varian.com>
parents:
diff changeset
41
3953
620e87e9e816 c-get: fixing memory with failedUIDs_
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 3818
diff changeset
42 Redistribution and use in source and binary forms, with or without
620e87e9e816 c-get: fixing memory with failedUIDs_
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 3818
diff changeset
43 modification, are permitted provided that the following conditions
620e87e9e816 c-get: fixing memory with failedUIDs_
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 3818
diff changeset
44 are met:
3818
4f78da5613a1 Add C-GET SCP support
Stacy Loesch <stacy.loesch@varian.com>
parents:
diff changeset
45
3953
620e87e9e816 c-get: fixing memory with failedUIDs_
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 3818
diff changeset
46 - Redistributions of source code must retain the above copyright
3818
4f78da5613a1 Add C-GET SCP support
Stacy Loesch <stacy.loesch@varian.com>
parents:
diff changeset
47 notice, this list of conditions and the following disclaimer.
4f78da5613a1 Add C-GET SCP support
Stacy Loesch <stacy.loesch@varian.com>
parents:
diff changeset
48
3953
620e87e9e816 c-get: fixing memory with failedUIDs_
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 3818
diff changeset
49 - Redistributions in binary form must reproduce the above copyright
3818
4f78da5613a1 Add C-GET SCP support
Stacy Loesch <stacy.loesch@varian.com>
parents:
diff changeset
50 notice, this list of conditions and the following disclaimer in the
4f78da5613a1 Add C-GET SCP support
Stacy Loesch <stacy.loesch@varian.com>
parents:
diff changeset
51 documentation and/or other materials provided with the distribution.
4f78da5613a1 Add C-GET SCP support
Stacy Loesch <stacy.loesch@varian.com>
parents:
diff changeset
52
3953
620e87e9e816 c-get: fixing memory with failedUIDs_
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 3818
diff changeset
53 - Neither the name of OFFIS nor the names of its contributors may be
3818
4f78da5613a1 Add C-GET SCP support
Stacy Loesch <stacy.loesch@varian.com>
parents:
diff changeset
54 used to endorse or promote products derived from this software
4f78da5613a1 Add C-GET SCP support
Stacy Loesch <stacy.loesch@varian.com>
parents:
diff changeset
55 without specific prior written permission.
4f78da5613a1 Add C-GET SCP support
Stacy Loesch <stacy.loesch@varian.com>
parents:
diff changeset
56
3953
620e87e9e816 c-get: fixing memory with failedUIDs_
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 3818
diff changeset
57 THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS
620e87e9e816 c-get: fixing memory with failedUIDs_
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 3818
diff changeset
58 "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT
620e87e9e816 c-get: fixing memory with failedUIDs_
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 3818
diff changeset
59 LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR
620e87e9e816 c-get: fixing memory with failedUIDs_
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 3818
diff changeset
60 A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT
620e87e9e816 c-get: fixing memory with failedUIDs_
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 3818
diff changeset
61 HOLDER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL,
620e87e9e816 c-get: fixing memory with failedUIDs_
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 3818
diff changeset
62 SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT
620e87e9e816 c-get: fixing memory with failedUIDs_
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 3818
diff changeset
63 LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE,
620e87e9e816 c-get: fixing memory with failedUIDs_
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 3818
diff changeset
64 DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY
620e87e9e816 c-get: fixing memory with failedUIDs_
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 3818
diff changeset
65 THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
620e87e9e816 c-get: fixing memory with failedUIDs_
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 3818
diff changeset
66 (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE
620e87e9e816 c-get: fixing memory with failedUIDs_
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 3818
diff changeset
67 OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
3818
4f78da5613a1 Add C-GET SCP support
Stacy Loesch <stacy.loesch@varian.com>
parents:
diff changeset
68
3953
620e87e9e816 c-get: fixing memory with failedUIDs_
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 3818
diff changeset
69 =========================================================================*/
3818
4f78da5613a1 Add C-GET SCP support
Stacy Loesch <stacy.loesch@varian.com>
parents:
diff changeset
70
4f78da5613a1 Add C-GET SCP support
Stacy Loesch <stacy.loesch@varian.com>
parents:
diff changeset
71
4f78da5613a1 Add C-GET SCP support
Stacy Loesch <stacy.loesch@varian.com>
parents:
diff changeset
72 #include "../../PrecompiledHeaders.h"
4f78da5613a1 Add C-GET SCP support
Stacy Loesch <stacy.loesch@varian.com>
parents:
diff changeset
73 #include <dcmtk/dcmnet/diutil.h>
4f78da5613a1 Add C-GET SCP support
Stacy Loesch <stacy.loesch@varian.com>
parents:
diff changeset
74 #include <dcmtk/dcmdata/dcdeftag.h>
4f78da5613a1 Add C-GET SCP support
Stacy Loesch <stacy.loesch@varian.com>
parents:
diff changeset
75 #include "GetScp.h"
4f78da5613a1 Add C-GET SCP support
Stacy Loesch <stacy.loesch@varian.com>
parents:
diff changeset
76
4f78da5613a1 Add C-GET SCP support
Stacy Loesch <stacy.loesch@varian.com>
parents:
diff changeset
77 #include <memory>
4f78da5613a1 Add C-GET SCP support
Stacy Loesch <stacy.loesch@varian.com>
parents:
diff changeset
78
4f78da5613a1 Add C-GET SCP support
Stacy Loesch <stacy.loesch@varian.com>
parents:
diff changeset
79 #include "../../DicomParsing/FromDcmtkBridge.h"
4f78da5613a1 Add C-GET SCP support
Stacy Loesch <stacy.loesch@varian.com>
parents:
diff changeset
80 #include "../../DicomParsing/ToDcmtkBridge.h"
4f78da5613a1 Add C-GET SCP support
Stacy Loesch <stacy.loesch@varian.com>
parents:
diff changeset
81 #include "../../Logging.h"
4f78da5613a1 Add C-GET SCP support
Stacy Loesch <stacy.loesch@varian.com>
parents:
diff changeset
82 #include "../../OrthancException.h"
4f78da5613a1 Add C-GET SCP support
Stacy Loesch <stacy.loesch@varian.com>
parents:
diff changeset
83
4f78da5613a1 Add C-GET SCP support
Stacy Loesch <stacy.loesch@varian.com>
parents:
diff changeset
84 #include <boost/lexical_cast.hpp>
4f78da5613a1 Add C-GET SCP support
Stacy Loesch <stacy.loesch@varian.com>
parents:
diff changeset
85
4f78da5613a1 Add C-GET SCP support
Stacy Loesch <stacy.loesch@varian.com>
parents:
diff changeset
86
4f78da5613a1 Add C-GET SCP support
Stacy Loesch <stacy.loesch@varian.com>
parents:
diff changeset
87 namespace Orthanc
4f78da5613a1 Add C-GET SCP support
Stacy Loesch <stacy.loesch@varian.com>
parents:
diff changeset
88 {
4f78da5613a1 Add C-GET SCP support
Stacy Loesch <stacy.loesch@varian.com>
parents:
diff changeset
89 namespace
4f78da5613a1 Add C-GET SCP support
Stacy Loesch <stacy.loesch@varian.com>
parents:
diff changeset
90 {
4f78da5613a1 Add C-GET SCP support
Stacy Loesch <stacy.loesch@varian.com>
parents:
diff changeset
91 struct GetScpData
4f78da5613a1 Add C-GET SCP support
Stacy Loesch <stacy.loesch@varian.com>
parents:
diff changeset
92 {
4f78da5613a1 Add C-GET SCP support
Stacy Loesch <stacy.loesch@varian.com>
parents:
diff changeset
93 // Handle returns void.
4f78da5613a1 Add C-GET SCP support
Stacy Loesch <stacy.loesch@varian.com>
parents:
diff changeset
94 IGetRequestHandler* handler_;
4f78da5613a1 Add C-GET SCP support
Stacy Loesch <stacy.loesch@varian.com>
parents:
diff changeset
95 DcmDataset* lastRequest_;
4f78da5613a1 Add C-GET SCP support
Stacy Loesch <stacy.loesch@varian.com>
parents:
diff changeset
96 T_ASC_Association * assoc_;
4f78da5613a1 Add C-GET SCP support
Stacy Loesch <stacy.loesch@varian.com>
parents:
diff changeset
97
4f78da5613a1 Add C-GET SCP support
Stacy Loesch <stacy.loesch@varian.com>
parents:
diff changeset
98 std::string remoteIp_;
4f78da5613a1 Add C-GET SCP support
Stacy Loesch <stacy.loesch@varian.com>
parents:
diff changeset
99 std::string remoteAet_;
4f78da5613a1 Add C-GET SCP support
Stacy Loesch <stacy.loesch@varian.com>
parents:
diff changeset
100 std::string calledAet_;
3955
66879215cbf3 C-GET: add timeout, fix uninitalized priority, support multiple resources
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 3954
diff changeset
101 int timeout_;
3818
4f78da5613a1 Add C-GET SCP support
Stacy Loesch <stacy.loesch@varian.com>
parents:
diff changeset
102
4200
7112a8af0b63 cppcheck
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 4137
diff changeset
103 GetScpData() :
7112a8af0b63 cppcheck
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 4137
diff changeset
104 handler_(NULL),
7112a8af0b63 cppcheck
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 4137
diff changeset
105 lastRequest_(NULL),
7112a8af0b63 cppcheck
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 4137
diff changeset
106 assoc_(NULL),
7112a8af0b63 cppcheck
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 4137
diff changeset
107 timeout_(0)
3818
4f78da5613a1 Add C-GET SCP support
Stacy Loesch <stacy.loesch@varian.com>
parents:
diff changeset
108 {
4f78da5613a1 Add C-GET SCP support
Stacy Loesch <stacy.loesch@varian.com>
parents:
diff changeset
109 };
4f78da5613a1 Add C-GET SCP support
Stacy Loesch <stacy.loesch@varian.com>
parents:
diff changeset
110 };
4f78da5613a1 Add C-GET SCP support
Stacy Loesch <stacy.loesch@varian.com>
parents:
diff changeset
111
3953
620e87e9e816 c-get: fixing memory with failedUIDs_
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 3818
diff changeset
112 static DcmDataset *BuildFailedInstanceList(const std::string& failedUIDs)
3818
4f78da5613a1 Add C-GET SCP support
Stacy Loesch <stacy.loesch@varian.com>
parents:
diff changeset
113 {
3953
620e87e9e816 c-get: fixing memory with failedUIDs_
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 3818
diff changeset
114 if (failedUIDs.empty())
620e87e9e816 c-get: fixing memory with failedUIDs_
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 3818
diff changeset
115 {
620e87e9e816 c-get: fixing memory with failedUIDs_
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 3818
diff changeset
116 return NULL;
620e87e9e816 c-get: fixing memory with failedUIDs_
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 3818
diff changeset
117 }
620e87e9e816 c-get: fixing memory with failedUIDs_
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 3818
diff changeset
118 else
3818
4f78da5613a1 Add C-GET SCP support
Stacy Loesch <stacy.loesch@varian.com>
parents:
diff changeset
119 {
3953
620e87e9e816 c-get: fixing memory with failedUIDs_
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 3818
diff changeset
120 std::unique_ptr<DcmDataset> rspIds(new DcmDataset());
620e87e9e816 c-get: fixing memory with failedUIDs_
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 3818
diff changeset
121
620e87e9e816 c-get: fixing memory with failedUIDs_
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 3818
diff changeset
122 if (!DU_putStringDOElement(rspIds.get(), DCM_FailedSOPInstanceUIDList, failedUIDs.c_str()))
3818
4f78da5613a1 Add C-GET SCP support
Stacy Loesch <stacy.loesch@varian.com>
parents:
diff changeset
123 {
3953
620e87e9e816 c-get: fixing memory with failedUIDs_
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 3818
diff changeset
124 throw OrthancException(ErrorCode_InternalError,
620e87e9e816 c-get: fixing memory with failedUIDs_
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 3818
diff changeset
125 "getSCP: failed to build DCM_FailedSOPInstanceUIDList");
3818
4f78da5613a1 Add C-GET SCP support
Stacy Loesch <stacy.loesch@varian.com>
parents:
diff changeset
126 }
3953
620e87e9e816 c-get: fixing memory with failedUIDs_
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 3818
diff changeset
127
620e87e9e816 c-get: fixing memory with failedUIDs_
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 3818
diff changeset
128 return rspIds.release();
3818
4f78da5613a1 Add C-GET SCP support
Stacy Loesch <stacy.loesch@varian.com>
parents:
diff changeset
129 }
4f78da5613a1 Add C-GET SCP support
Stacy Loesch <stacy.loesch@varian.com>
parents:
diff changeset
130 }
4f78da5613a1 Add C-GET SCP support
Stacy Loesch <stacy.loesch@varian.com>
parents:
diff changeset
131
3953
620e87e9e816 c-get: fixing memory with failedUIDs_
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 3818
diff changeset
132 static void GetScpCallback(
3818
4f78da5613a1 Add C-GET SCP support
Stacy Loesch <stacy.loesch@varian.com>
parents:
diff changeset
133 /* in */
4f78da5613a1 Add C-GET SCP support
Stacy Loesch <stacy.loesch@varian.com>
parents:
diff changeset
134 void *callbackData,
4f78da5613a1 Add C-GET SCP support
Stacy Loesch <stacy.loesch@varian.com>
parents:
diff changeset
135 OFBool cancelled,
4f78da5613a1 Add C-GET SCP support
Stacy Loesch <stacy.loesch@varian.com>
parents:
diff changeset
136 T_DIMSE_C_GetRQ *request,
4f78da5613a1 Add C-GET SCP support
Stacy Loesch <stacy.loesch@varian.com>
parents:
diff changeset
137 DcmDataset *requestIdentifiers,
4f78da5613a1 Add C-GET SCP support
Stacy Loesch <stacy.loesch@varian.com>
parents:
diff changeset
138 int responseCount,
4f78da5613a1 Add C-GET SCP support
Stacy Loesch <stacy.loesch@varian.com>
parents:
diff changeset
139 /* out */
4f78da5613a1 Add C-GET SCP support
Stacy Loesch <stacy.loesch@varian.com>
parents:
diff changeset
140 T_DIMSE_C_GetRSP *response,
4f78da5613a1 Add C-GET SCP support
Stacy Loesch <stacy.loesch@varian.com>
parents:
diff changeset
141 DcmDataset **responseIdentifiers,
4f78da5613a1 Add C-GET SCP support
Stacy Loesch <stacy.loesch@varian.com>
parents:
diff changeset
142 DcmDataset **statusDetail)
4f78da5613a1 Add C-GET SCP support
Stacy Loesch <stacy.loesch@varian.com>
parents:
diff changeset
143 {
4f78da5613a1 Add C-GET SCP support
Stacy Loesch <stacy.loesch@varian.com>
parents:
diff changeset
144 bzero(response, sizeof(T_DIMSE_C_GetRSP));
4f78da5613a1 Add C-GET SCP support
Stacy Loesch <stacy.loesch@varian.com>
parents:
diff changeset
145 *statusDetail = NULL;
4f78da5613a1 Add C-GET SCP support
Stacy Loesch <stacy.loesch@varian.com>
parents:
diff changeset
146 *responseIdentifiers = NULL;
4f78da5613a1 Add C-GET SCP support
Stacy Loesch <stacy.loesch@varian.com>
parents:
diff changeset
147
4f78da5613a1 Add C-GET SCP support
Stacy Loesch <stacy.loesch@varian.com>
parents:
diff changeset
148 GetScpData& data = *reinterpret_cast<GetScpData*>(callbackData);
4f78da5613a1 Add C-GET SCP support
Stacy Loesch <stacy.loesch@varian.com>
parents:
diff changeset
149 if (data.lastRequest_ == NULL)
4f78da5613a1 Add C-GET SCP support
Stacy Loesch <stacy.loesch@varian.com>
parents:
diff changeset
150 {
4f78da5613a1 Add C-GET SCP support
Stacy Loesch <stacy.loesch@varian.com>
parents:
diff changeset
151 DicomMap input;
4137
6774605d4341 keep only one signature for FromDcmtkBridge::ExtractDicomSummary()
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 4136
diff changeset
152 std::set<DicomTag> ignoreTagLength;
6774605d4341 keep only one signature for FromDcmtkBridge::ExtractDicomSummary()
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 4136
diff changeset
153 FromDcmtkBridge::ExtractDicomSummary(input, *requestIdentifiers, 0 /* don't truncate tags */, ignoreTagLength);
3818
4f78da5613a1 Add C-GET SCP support
Stacy Loesch <stacy.loesch@varian.com>
parents:
diff changeset
154
4f78da5613a1 Add C-GET SCP support
Stacy Loesch <stacy.loesch@varian.com>
parents:
diff changeset
155 try
4f78da5613a1 Add C-GET SCP support
Stacy Loesch <stacy.loesch@varian.com>
parents:
diff changeset
156 {
3959
76a24be12912 c-get: support of transcoding
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 3955
diff changeset
157 if (!data.handler_->Handle(
76a24be12912 c-get: support of transcoding
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 3955
diff changeset
158 input, data.remoteIp_, data.remoteAet_, data.calledAet_,
76a24be12912 c-get: support of transcoding
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 3955
diff changeset
159 data.timeout_ < 0 ? 0 : static_cast<uint32_t>(data.timeout_)))
3818
4f78da5613a1 Add C-GET SCP support
Stacy Loesch <stacy.loesch@varian.com>
parents:
diff changeset
160 {
4f78da5613a1 Add C-GET SCP support
Stacy Loesch <stacy.loesch@varian.com>
parents:
diff changeset
161 response->DimseStatus = STATUS_GET_Failed_UnableToProcess;
4f78da5613a1 Add C-GET SCP support
Stacy Loesch <stacy.loesch@varian.com>
parents:
diff changeset
162 return;
4f78da5613a1 Add C-GET SCP support
Stacy Loesch <stacy.loesch@varian.com>
parents:
diff changeset
163 }
4f78da5613a1 Add C-GET SCP support
Stacy Loesch <stacy.loesch@varian.com>
parents:
diff changeset
164 }
4f78da5613a1 Add C-GET SCP support
Stacy Loesch <stacy.loesch@varian.com>
parents:
diff changeset
165 catch (OrthancException& e)
4f78da5613a1 Add C-GET SCP support
Stacy Loesch <stacy.loesch@varian.com>
parents:
diff changeset
166 {
4f78da5613a1 Add C-GET SCP support
Stacy Loesch <stacy.loesch@varian.com>
parents:
diff changeset
167 // Internal error!
4f78da5613a1 Add C-GET SCP support
Stacy Loesch <stacy.loesch@varian.com>
parents:
diff changeset
168 LOG(ERROR) << "IGetRequestHandler Failed: " << e.What();
4f78da5613a1 Add C-GET SCP support
Stacy Loesch <stacy.loesch@varian.com>
parents:
diff changeset
169 response->DimseStatus = STATUS_GET_Failed_UnableToProcess;
4f78da5613a1 Add C-GET SCP support
Stacy Loesch <stacy.loesch@varian.com>
parents:
diff changeset
170 return;
4f78da5613a1 Add C-GET SCP support
Stacy Loesch <stacy.loesch@varian.com>
parents:
diff changeset
171 }
4f78da5613a1 Add C-GET SCP support
Stacy Loesch <stacy.loesch@varian.com>
parents:
diff changeset
172
4f78da5613a1 Add C-GET SCP support
Stacy Loesch <stacy.loesch@varian.com>
parents:
diff changeset
173 data.lastRequest_ = requestIdentifiers;
4f78da5613a1 Add C-GET SCP support
Stacy Loesch <stacy.loesch@varian.com>
parents:
diff changeset
174 }
4f78da5613a1 Add C-GET SCP support
Stacy Loesch <stacy.loesch@varian.com>
parents:
diff changeset
175 else if (data.lastRequest_ != requestIdentifiers)
4f78da5613a1 Add C-GET SCP support
Stacy Loesch <stacy.loesch@varian.com>
parents:
diff changeset
176 {
4f78da5613a1 Add C-GET SCP support
Stacy Loesch <stacy.loesch@varian.com>
parents:
diff changeset
177 // Internal error!
4f78da5613a1 Add C-GET SCP support
Stacy Loesch <stacy.loesch@varian.com>
parents:
diff changeset
178 LOG(ERROR) << "IGetRequestHandler Failed: Internal error lastRequestIdentifier";
4f78da5613a1 Add C-GET SCP support
Stacy Loesch <stacy.loesch@varian.com>
parents:
diff changeset
179 response->DimseStatus = STATUS_GET_Failed_UnableToProcess;
4f78da5613a1 Add C-GET SCP support
Stacy Loesch <stacy.loesch@varian.com>
parents:
diff changeset
180 return;
4f78da5613a1 Add C-GET SCP support
Stacy Loesch <stacy.loesch@varian.com>
parents:
diff changeset
181 }
4f78da5613a1 Add C-GET SCP support
Stacy Loesch <stacy.loesch@varian.com>
parents:
diff changeset
182
3954
67b457283499 coding style
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 3953
diff changeset
183 if (data.handler_->GetRemainingCount() == 0)
3818
4f78da5613a1 Add C-GET SCP support
Stacy Loesch <stacy.loesch@varian.com>
parents:
diff changeset
184 {
4f78da5613a1 Add C-GET SCP support
Stacy Loesch <stacy.loesch@varian.com>
parents:
diff changeset
185 response->DimseStatus = STATUS_Success;
4f78da5613a1 Add C-GET SCP support
Stacy Loesch <stacy.loesch@varian.com>
parents:
diff changeset
186 }
4f78da5613a1 Add C-GET SCP support
Stacy Loesch <stacy.loesch@varian.com>
parents:
diff changeset
187 else
4f78da5613a1 Add C-GET SCP support
Stacy Loesch <stacy.loesch@varian.com>
parents:
diff changeset
188 {
4f78da5613a1 Add C-GET SCP support
Stacy Loesch <stacy.loesch@varian.com>
parents:
diff changeset
189 IGetRequestHandler::Status status;
4f78da5613a1 Add C-GET SCP support
Stacy Loesch <stacy.loesch@varian.com>
parents:
diff changeset
190
4f78da5613a1 Add C-GET SCP support
Stacy Loesch <stacy.loesch@varian.com>
parents:
diff changeset
191 try
4f78da5613a1 Add C-GET SCP support
Stacy Loesch <stacy.loesch@varian.com>
parents:
diff changeset
192 {
4f78da5613a1 Add C-GET SCP support
Stacy Loesch <stacy.loesch@varian.com>
parents:
diff changeset
193 status = data.handler_->DoNext(data.assoc_);
4f78da5613a1 Add C-GET SCP support
Stacy Loesch <stacy.loesch@varian.com>
parents:
diff changeset
194 }
4f78da5613a1 Add C-GET SCP support
Stacy Loesch <stacy.loesch@varian.com>
parents:
diff changeset
195 catch (OrthancException& e)
4f78da5613a1 Add C-GET SCP support
Stacy Loesch <stacy.loesch@varian.com>
parents:
diff changeset
196 {
4f78da5613a1 Add C-GET SCP support
Stacy Loesch <stacy.loesch@varian.com>
parents:
diff changeset
197 // Internal error!
4f78da5613a1 Add C-GET SCP support
Stacy Loesch <stacy.loesch@varian.com>
parents:
diff changeset
198 LOG(ERROR) << "IGetRequestHandler Failed: " << e.What();
4f78da5613a1 Add C-GET SCP support
Stacy Loesch <stacy.loesch@varian.com>
parents:
diff changeset
199 response->DimseStatus = STATUS_GET_Failed_UnableToProcess;
4f78da5613a1 Add C-GET SCP support
Stacy Loesch <stacy.loesch@varian.com>
parents:
diff changeset
200 return;
4f78da5613a1 Add C-GET SCP support
Stacy Loesch <stacy.loesch@varian.com>
parents:
diff changeset
201 }
4f78da5613a1 Add C-GET SCP support
Stacy Loesch <stacy.loesch@varian.com>
parents:
diff changeset
202
4f78da5613a1 Add C-GET SCP support
Stacy Loesch <stacy.loesch@varian.com>
parents:
diff changeset
203 if (status == STATUS_Success)
4f78da5613a1 Add C-GET SCP support
Stacy Loesch <stacy.loesch@varian.com>
parents:
diff changeset
204 {
3954
67b457283499 coding style
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 3953
diff changeset
205 if (responseCount < static_cast<int>(data.handler_->GetRemainingCount()))
3818
4f78da5613a1 Add C-GET SCP support
Stacy Loesch <stacy.loesch@varian.com>
parents:
diff changeset
206 {
4f78da5613a1 Add C-GET SCP support
Stacy Loesch <stacy.loesch@varian.com>
parents:
diff changeset
207 response->DimseStatus = STATUS_Pending;
4f78da5613a1 Add C-GET SCP support
Stacy Loesch <stacy.loesch@varian.com>
parents:
diff changeset
208 }
4f78da5613a1 Add C-GET SCP support
Stacy Loesch <stacy.loesch@varian.com>
parents:
diff changeset
209 else
4f78da5613a1 Add C-GET SCP support
Stacy Loesch <stacy.loesch@varian.com>
parents:
diff changeset
210 {
4f78da5613a1 Add C-GET SCP support
Stacy Loesch <stacy.loesch@varian.com>
parents:
diff changeset
211 response->DimseStatus = STATUS_Success;
4f78da5613a1 Add C-GET SCP support
Stacy Loesch <stacy.loesch@varian.com>
parents:
diff changeset
212 }
4f78da5613a1 Add C-GET SCP support
Stacy Loesch <stacy.loesch@varian.com>
parents:
diff changeset
213 }
4f78da5613a1 Add C-GET SCP support
Stacy Loesch <stacy.loesch@varian.com>
parents:
diff changeset
214 else
4f78da5613a1 Add C-GET SCP support
Stacy Loesch <stacy.loesch@varian.com>
parents:
diff changeset
215 {
4f78da5613a1 Add C-GET SCP support
Stacy Loesch <stacy.loesch@varian.com>
parents:
diff changeset
216 response->DimseStatus = STATUS_GET_Failed_UnableToProcess;
4f78da5613a1 Add C-GET SCP support
Stacy Loesch <stacy.loesch@varian.com>
parents:
diff changeset
217
3954
67b457283499 coding style
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 3953
diff changeset
218 if (data.handler_->GetFailedCount() > 0 ||
67b457283499 coding style
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 3953
diff changeset
219 data.handler_->GetWarningCount() > 0)
3818
4f78da5613a1 Add C-GET SCP support
Stacy Loesch <stacy.loesch@varian.com>
parents:
diff changeset
220 {
4f78da5613a1 Add C-GET SCP support
Stacy Loesch <stacy.loesch@varian.com>
parents:
diff changeset
221 response->DimseStatus = STATUS_GET_Warning_SubOperationsCompleteOneOrMoreFailures;
4f78da5613a1 Add C-GET SCP support
Stacy Loesch <stacy.loesch@varian.com>
parents:
diff changeset
222 }
3954
67b457283499 coding style
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 3953
diff changeset
223
3818
4f78da5613a1 Add C-GET SCP support
Stacy Loesch <stacy.loesch@varian.com>
parents:
diff changeset
224 /*
3953
620e87e9e816 c-get: fixing memory with failedUIDs_
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 3818
diff changeset
225 * if all the sub-operations failed then we need to generate
620e87e9e816 c-get: fixing memory with failedUIDs_
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 3818
diff changeset
226 * a failed or refused status. cf. DICOM part 4, C.4.3.3.1
620e87e9e816 c-get: fixing memory with failedUIDs_
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 3818
diff changeset
227 * we choose to generate a "Refused - Out of Resources -
620e87e9e816 c-get: fixing memory with failedUIDs_
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 3818
diff changeset
228 * Unable to perform suboperations" status.
3818
4f78da5613a1 Add C-GET SCP support
Stacy Loesch <stacy.loesch@varian.com>
parents:
diff changeset
229 */
3954
67b457283499 coding style
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 3953
diff changeset
230 if ((data.handler_->GetFailedCount() > 0) &&
67b457283499 coding style
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 3953
diff changeset
231 ((data.handler_->GetCompletedCount() +
67b457283499 coding style
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 3953
diff changeset
232 data.handler_->GetWarningCount()) == 0))
3818
4f78da5613a1 Add C-GET SCP support
Stacy Loesch <stacy.loesch@varian.com>
parents:
diff changeset
233 {
4f78da5613a1 Add C-GET SCP support
Stacy Loesch <stacy.loesch@varian.com>
parents:
diff changeset
234 response->DimseStatus = STATUS_GET_Refused_OutOfResourcesSubOperations;
4f78da5613a1 Add C-GET SCP support
Stacy Loesch <stacy.loesch@varian.com>
parents:
diff changeset
235 }
4f78da5613a1 Add C-GET SCP support
Stacy Loesch <stacy.loesch@varian.com>
parents:
diff changeset
236
3954
67b457283499 coding style
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 3953
diff changeset
237 *responseIdentifiers = BuildFailedInstanceList(data.handler_->GetFailedUids());
3818
4f78da5613a1 Add C-GET SCP support
Stacy Loesch <stacy.loesch@varian.com>
parents:
diff changeset
238 }
4f78da5613a1 Add C-GET SCP support
Stacy Loesch <stacy.loesch@varian.com>
parents:
diff changeset
239 }
4f78da5613a1 Add C-GET SCP support
Stacy Loesch <stacy.loesch@varian.com>
parents:
diff changeset
240
3954
67b457283499 coding style
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 3953
diff changeset
241 response->NumberOfRemainingSubOperations = data.handler_->GetRemainingCount();
67b457283499 coding style
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 3953
diff changeset
242 response->NumberOfCompletedSubOperations = data.handler_->GetCompletedCount();
67b457283499 coding style
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 3953
diff changeset
243 response->NumberOfFailedSubOperations = data.handler_->GetFailedCount();
67b457283499 coding style
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 3953
diff changeset
244 response->NumberOfWarningSubOperations = data.handler_->GetWarningCount();
3818
4f78da5613a1 Add C-GET SCP support
Stacy Loesch <stacy.loesch@varian.com>
parents:
diff changeset
245 }
4f78da5613a1 Add C-GET SCP support
Stacy Loesch <stacy.loesch@varian.com>
parents:
diff changeset
246 }
4f78da5613a1 Add C-GET SCP support
Stacy Loesch <stacy.loesch@varian.com>
parents:
diff changeset
247
4f78da5613a1 Add C-GET SCP support
Stacy Loesch <stacy.loesch@varian.com>
parents:
diff changeset
248 OFCondition Internals::getScp(T_ASC_Association * assoc,
3953
620e87e9e816 c-get: fixing memory with failedUIDs_
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 3818
diff changeset
249 T_DIMSE_Message * msg,
620e87e9e816 c-get: fixing memory with failedUIDs_
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 3818
diff changeset
250 T_ASC_PresentationContextID presID,
620e87e9e816 c-get: fixing memory with failedUIDs_
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 3818
diff changeset
251 IGetRequestHandler& handler,
4200
7112a8af0b63 cppcheck
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 4137
diff changeset
252 const std::string& remoteIp,
7112a8af0b63 cppcheck
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 4137
diff changeset
253 const std::string& remoteAet,
7112a8af0b63 cppcheck
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 4137
diff changeset
254 const std::string& calledAet,
3953
620e87e9e816 c-get: fixing memory with failedUIDs_
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 3818
diff changeset
255 int timeout)
3818
4f78da5613a1 Add C-GET SCP support
Stacy Loesch <stacy.loesch@varian.com>
parents:
diff changeset
256 {
4f78da5613a1 Add C-GET SCP support
Stacy Loesch <stacy.loesch@varian.com>
parents:
diff changeset
257 GetScpData data;
4f78da5613a1 Add C-GET SCP support
Stacy Loesch <stacy.loesch@varian.com>
parents:
diff changeset
258 data.lastRequest_ = NULL;
4f78da5613a1 Add C-GET SCP support
Stacy Loesch <stacy.loesch@varian.com>
parents:
diff changeset
259 data.handler_ = &handler;
4f78da5613a1 Add C-GET SCP support
Stacy Loesch <stacy.loesch@varian.com>
parents:
diff changeset
260 data.assoc_ = assoc;
4f78da5613a1 Add C-GET SCP support
Stacy Loesch <stacy.loesch@varian.com>
parents:
diff changeset
261 data.remoteIp_ = remoteIp;
4f78da5613a1 Add C-GET SCP support
Stacy Loesch <stacy.loesch@varian.com>
parents:
diff changeset
262 data.remoteAet_ = remoteAet;
4f78da5613a1 Add C-GET SCP support
Stacy Loesch <stacy.loesch@varian.com>
parents:
diff changeset
263 data.calledAet_ = calledAet;
3955
66879215cbf3 C-GET: add timeout, fix uninitalized priority, support multiple resources
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 3954
diff changeset
264 data.timeout_ = timeout;
3818
4f78da5613a1 Add C-GET SCP support
Stacy Loesch <stacy.loesch@varian.com>
parents:
diff changeset
265
4f78da5613a1 Add C-GET SCP support
Stacy Loesch <stacy.loesch@varian.com>
parents:
diff changeset
266 OFCondition cond = DIMSE_getProvider(assoc, presID, &msg->msg.CGetRQ,
3953
620e87e9e816 c-get: fixing memory with failedUIDs_
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 3818
diff changeset
267 GetScpCallback, &data,
620e87e9e816 c-get: fixing memory with failedUIDs_
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 3818
diff changeset
268 /*opt_blockMode*/ (timeout ? DIMSE_NONBLOCKING : DIMSE_BLOCKING),
620e87e9e816 c-get: fixing memory with failedUIDs_
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 3818
diff changeset
269 /*opt_dimse_timeout*/ timeout);
620e87e9e816 c-get: fixing memory with failedUIDs_
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 3818
diff changeset
270
3818
4f78da5613a1 Add C-GET SCP support
Stacy Loesch <stacy.loesch@varian.com>
parents:
diff changeset
271 // if some error occured, dump corresponding information and remove the outfile if necessary
4f78da5613a1 Add C-GET SCP support
Stacy Loesch <stacy.loesch@varian.com>
parents:
diff changeset
272 if (cond.bad())
4f78da5613a1 Add C-GET SCP support
Stacy Loesch <stacy.loesch@varian.com>
parents:
diff changeset
273 {
4f78da5613a1 Add C-GET SCP support
Stacy Loesch <stacy.loesch@varian.com>
parents:
diff changeset
274 OFString temp_str;
4f78da5613a1 Add C-GET SCP support
Stacy Loesch <stacy.loesch@varian.com>
parents:
diff changeset
275 LOG(ERROR) << "Get SCP Failed: " << cond.text();
4f78da5613a1 Add C-GET SCP support
Stacy Loesch <stacy.loesch@varian.com>
parents:
diff changeset
276 }
4f78da5613a1 Add C-GET SCP support
Stacy Loesch <stacy.loesch@varian.com>
parents:
diff changeset
277
4f78da5613a1 Add C-GET SCP support
Stacy Loesch <stacy.loesch@varian.com>
parents:
diff changeset
278 return cond;
4f78da5613a1 Add C-GET SCP support
Stacy Loesch <stacy.loesch@varian.com>
parents:
diff changeset
279 }
4f78da5613a1 Add C-GET SCP support
Stacy Loesch <stacy.loesch@varian.com>
parents:
diff changeset
280 }