annotate OrthancFramework/Sources/DicomNetworking/Internals/GetScp.cpp @ 5853:4d932683049d get-scu tip

very first implementation of C-Get SCU
author Alain Mazy <am@orthanc.team>
date Tue, 29 Oct 2024 17:25:49 +0100
parents f7adfb22e20e
children
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
5640
f7adfb22e20e updated copyright, as Orthanc Team now replaces Osimis
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 5485
diff changeset
5 * Copyright (C) 2017-2023 Osimis S.A., Belgium
f7adfb22e20e updated copyright, as Orthanc Team now replaces Osimis
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 5485
diff changeset
6 * Copyright (C) 2024-2024 Orthanc Team SRL, Belgium
5485
48b8dae6dc77 upgrade to year 2024
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 5185
diff changeset
7 * Copyright (C) 2021-2024 Sebastien Jodogne, ICTEAM UCLouvain, Belgium
3818
4f78da5613a1 Add C-GET SCP support
Stacy Loesch <stacy.loesch@varian.com>
parents:
diff changeset
8 *
4f78da5613a1 Add C-GET SCP support
Stacy Loesch <stacy.loesch@varian.com>
parents:
diff changeset
9 * 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
10 * 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
11 * 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
12 * 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
13 *
4f78da5613a1 Add C-GET SCP support
Stacy Loesch <stacy.loesch@varian.com>
parents:
diff changeset
14 * 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
15 * WITHOUT ANY WARRANTY; without even the implied warranty of
4f78da5613a1 Add C-GET SCP support
Stacy Loesch <stacy.loesch@varian.com>
parents:
diff changeset
16 * 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
17 * Lesser General Public License for more details.
3818
4f78da5613a1 Add C-GET SCP support
Stacy Loesch <stacy.loesch@varian.com>
parents:
diff changeset
18 *
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
19 * 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
20 * 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
21 * <http://www.gnu.org/licenses/>.
3818
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 /*=========================================================================
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 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
30
4f78da5613a1 Add C-GET SCP support
Stacy Loesch <stacy.loesch@varian.com>
parents:
diff changeset
31 Program: DCMTK 3.6.0
4f78da5613a1 Add C-GET SCP support
Stacy Loesch <stacy.loesch@varian.com>
parents:
diff changeset
32 Module: http://dicom.offis.de/dcmtk.php.en
4f78da5613a1 Add C-GET SCP support
Stacy Loesch <stacy.loesch@varian.com>
parents:
diff changeset
33
3953
620e87e9e816 c-get: fixing memory with failedUIDs_
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 3818
diff changeset
34 Copyright (C) 1994-2011, OFFIS e.V.
620e87e9e816 c-get: fixing memory with failedUIDs_
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 3818
diff changeset
35 All rights reserved.
3818
4f78da5613a1 Add C-GET SCP support
Stacy Loesch <stacy.loesch@varian.com>
parents:
diff changeset
36
3953
620e87e9e816 c-get: fixing memory with failedUIDs_
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 3818
diff changeset
37 This software and supporting documentation were developed by
3818
4f78da5613a1 Add C-GET SCP support
Stacy Loesch <stacy.loesch@varian.com>
parents:
diff changeset
38
4f78da5613a1 Add C-GET SCP support
Stacy Loesch <stacy.loesch@varian.com>
parents:
diff changeset
39 OFFIS e.V.
4f78da5613a1 Add C-GET SCP support
Stacy Loesch <stacy.loesch@varian.com>
parents:
diff changeset
40 R&D Division Health
4f78da5613a1 Add C-GET SCP support
Stacy Loesch <stacy.loesch@varian.com>
parents:
diff changeset
41 Escherweg 2
4f78da5613a1 Add C-GET SCP support
Stacy Loesch <stacy.loesch@varian.com>
parents:
diff changeset
42 26121 Oldenburg, Germany
4f78da5613a1 Add C-GET SCP support
Stacy Loesch <stacy.loesch@varian.com>
parents:
diff changeset
43
3953
620e87e9e816 c-get: fixing memory with failedUIDs_
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 3818
diff changeset
44 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
45 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
46 are met:
3818
4f78da5613a1 Add C-GET SCP support
Stacy Loesch <stacy.loesch@varian.com>
parents:
diff changeset
47
3953
620e87e9e816 c-get: fixing memory with failedUIDs_
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 3818
diff changeset
48 - 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
49 notice, this list of conditions and the following disclaimer.
4f78da5613a1 Add C-GET SCP support
Stacy Loesch <stacy.loesch@varian.com>
parents:
diff changeset
50
3953
620e87e9e816 c-get: fixing memory with failedUIDs_
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 3818
diff changeset
51 - 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
52 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
53 documentation and/or other materials provided with the distribution.
4f78da5613a1 Add C-GET SCP support
Stacy Loesch <stacy.loesch@varian.com>
parents:
diff changeset
54
3953
620e87e9e816 c-get: fixing memory with failedUIDs_
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 3818
diff changeset
55 - 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
56 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
57 without specific prior written permission.
4f78da5613a1 Add C-GET SCP support
Stacy Loesch <stacy.loesch@varian.com>
parents:
diff changeset
58
3953
620e87e9e816 c-get: fixing memory with failedUIDs_
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 3818
diff changeset
59 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
60 "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
61 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
62 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
63 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
64 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
65 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
66 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
67 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
68 (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
69 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
70
3953
620e87e9e816 c-get: fixing memory with failedUIDs_
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 3818
diff changeset
71 =========================================================================*/
3818
4f78da5613a1 Add C-GET SCP support
Stacy Loesch <stacy.loesch@varian.com>
parents:
diff changeset
72
4f78da5613a1 Add C-GET SCP support
Stacy Loesch <stacy.loesch@varian.com>
parents:
diff changeset
73
4f78da5613a1 Add C-GET SCP support
Stacy Loesch <stacy.loesch@varian.com>
parents:
diff changeset
74 #include "../../PrecompiledHeaders.h"
4f78da5613a1 Add C-GET SCP support
Stacy Loesch <stacy.loesch@varian.com>
parents:
diff changeset
75 #include <dcmtk/dcmnet/diutil.h>
4f78da5613a1 Add C-GET SCP support
Stacy Loesch <stacy.loesch@varian.com>
parents:
diff changeset
76 #include <dcmtk/dcmdata/dcdeftag.h>
4f78da5613a1 Add C-GET SCP support
Stacy Loesch <stacy.loesch@varian.com>
parents:
diff changeset
77 #include "GetScp.h"
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 <memory>
4f78da5613a1 Add C-GET SCP support
Stacy Loesch <stacy.loesch@varian.com>
parents:
diff changeset
80
4f78da5613a1 Add C-GET SCP support
Stacy Loesch <stacy.loesch@varian.com>
parents:
diff changeset
81 #include "../../DicomParsing/FromDcmtkBridge.h"
4f78da5613a1 Add C-GET SCP support
Stacy Loesch <stacy.loesch@varian.com>
parents:
diff changeset
82 #include "../../DicomParsing/ToDcmtkBridge.h"
4f78da5613a1 Add C-GET SCP support
Stacy Loesch <stacy.loesch@varian.com>
parents:
diff changeset
83 #include "../../Logging.h"
4f78da5613a1 Add C-GET SCP support
Stacy Loesch <stacy.loesch@varian.com>
parents:
diff changeset
84 #include "../../OrthancException.h"
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 #include <boost/lexical_cast.hpp>
4f78da5613a1 Add C-GET SCP support
Stacy Loesch <stacy.loesch@varian.com>
parents:
diff changeset
87
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 Orthanc
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 namespace
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 struct GetScpData
4f78da5613a1 Add C-GET SCP support
Stacy Loesch <stacy.loesch@varian.com>
parents:
diff changeset
94 {
4f78da5613a1 Add C-GET SCP support
Stacy Loesch <stacy.loesch@varian.com>
parents:
diff changeset
95 // Handle returns void.
4f78da5613a1 Add C-GET SCP support
Stacy Loesch <stacy.loesch@varian.com>
parents:
diff changeset
96 IGetRequestHandler* handler_;
4f78da5613a1 Add C-GET SCP support
Stacy Loesch <stacy.loesch@varian.com>
parents:
diff changeset
97 DcmDataset* lastRequest_;
4f78da5613a1 Add C-GET SCP support
Stacy Loesch <stacy.loesch@varian.com>
parents:
diff changeset
98 T_ASC_Association * assoc_;
4f78da5613a1 Add C-GET SCP support
Stacy Loesch <stacy.loesch@varian.com>
parents:
diff changeset
99
4f78da5613a1 Add C-GET SCP support
Stacy Loesch <stacy.loesch@varian.com>
parents:
diff changeset
100 std::string remoteIp_;
4f78da5613a1 Add C-GET SCP support
Stacy Loesch <stacy.loesch@varian.com>
parents:
diff changeset
101 std::string remoteAet_;
4f78da5613a1 Add C-GET SCP support
Stacy Loesch <stacy.loesch@varian.com>
parents:
diff changeset
102 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
103 int timeout_;
4258
6f5d4bfb2c90 C-GET SCP: Fix responses and handling of cancel
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 4200
diff changeset
104 bool canceled_;
3818
4f78da5613a1 Add C-GET SCP support
Stacy Loesch <stacy.loesch@varian.com>
parents:
diff changeset
105
4200
7112a8af0b63 cppcheck
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 4137
diff changeset
106 GetScpData() :
7112a8af0b63 cppcheck
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 4137
diff changeset
107 handler_(NULL),
7112a8af0b63 cppcheck
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 4137
diff changeset
108 lastRequest_(NULL),
7112a8af0b63 cppcheck
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 4137
diff changeset
109 assoc_(NULL),
4258
6f5d4bfb2c90 C-GET SCP: Fix responses and handling of cancel
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 4200
diff changeset
110 timeout_(0),
6f5d4bfb2c90 C-GET SCP: Fix responses and handling of cancel
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 4200
diff changeset
111 canceled_(false)
3818
4f78da5613a1 Add C-GET SCP support
Stacy Loesch <stacy.loesch@varian.com>
parents:
diff changeset
112 {
4f78da5613a1 Add C-GET SCP support
Stacy Loesch <stacy.loesch@varian.com>
parents:
diff changeset
113 };
4f78da5613a1 Add C-GET SCP support
Stacy Loesch <stacy.loesch@varian.com>
parents:
diff changeset
114 };
4f78da5613a1 Add C-GET SCP support
Stacy Loesch <stacy.loesch@varian.com>
parents:
diff changeset
115
3953
620e87e9e816 c-get: fixing memory with failedUIDs_
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 3818
diff changeset
116 static DcmDataset *BuildFailedInstanceList(const std::string& failedUIDs)
3818
4f78da5613a1 Add C-GET SCP support
Stacy Loesch <stacy.loesch@varian.com>
parents:
diff changeset
117 {
3953
620e87e9e816 c-get: fixing memory with failedUIDs_
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 3818
diff changeset
118 if (failedUIDs.empty())
620e87e9e816 c-get: fixing memory with failedUIDs_
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 3818
diff changeset
119 {
620e87e9e816 c-get: fixing memory with failedUIDs_
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 3818
diff changeset
120 return NULL;
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 else
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 std::unique_ptr<DcmDataset> rspIds(new DcmDataset());
620e87e9e816 c-get: fixing memory with failedUIDs_
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 3818
diff changeset
125
620e87e9e816 c-get: fixing memory with failedUIDs_
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 3818
diff changeset
126 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
127 {
3953
620e87e9e816 c-get: fixing memory with failedUIDs_
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 3818
diff changeset
128 throw OrthancException(ErrorCode_InternalError,
620e87e9e816 c-get: fixing memory with failedUIDs_
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 3818
diff changeset
129 "getSCP: failed to build DCM_FailedSOPInstanceUIDList");
3818
4f78da5613a1 Add C-GET SCP support
Stacy Loesch <stacy.loesch@varian.com>
parents:
diff changeset
130 }
3953
620e87e9e816 c-get: fixing memory with failedUIDs_
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 3818
diff changeset
131
620e87e9e816 c-get: fixing memory with failedUIDs_
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 3818
diff changeset
132 return rspIds.release();
3818
4f78da5613a1 Add C-GET SCP support
Stacy Loesch <stacy.loesch@varian.com>
parents:
diff changeset
133 }
4f78da5613a1 Add C-GET SCP support
Stacy Loesch <stacy.loesch@varian.com>
parents:
diff changeset
134 }
4f78da5613a1 Add C-GET SCP support
Stacy Loesch <stacy.loesch@varian.com>
parents:
diff changeset
135
4258
6f5d4bfb2c90 C-GET SCP: Fix responses and handling of cancel
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 4200
diff changeset
136
6f5d4bfb2c90 C-GET SCP: Fix responses and handling of cancel
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 4200
diff changeset
137 static void FillResponse(T_DIMSE_C_GetRSP& response,
6f5d4bfb2c90 C-GET SCP: Fix responses and handling of cancel
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 4200
diff changeset
138 DcmDataset** failedIdentifiers,
6f5d4bfb2c90 C-GET SCP: Fix responses and handling of cancel
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 4200
diff changeset
139 const IGetRequestHandler& handler)
6f5d4bfb2c90 C-GET SCP: Fix responses and handling of cancel
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 4200
diff changeset
140 {
6f5d4bfb2c90 C-GET SCP: Fix responses and handling of cancel
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 4200
diff changeset
141 response.DimseStatus = STATUS_Success;
6f5d4bfb2c90 C-GET SCP: Fix responses and handling of cancel
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 4200
diff changeset
142
6f5d4bfb2c90 C-GET SCP: Fix responses and handling of cancel
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 4200
diff changeset
143 size_t processedCount = (handler.GetCompletedCount() +
6f5d4bfb2c90 C-GET SCP: Fix responses and handling of cancel
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 4200
diff changeset
144 handler.GetFailedCount() +
6f5d4bfb2c90 C-GET SCP: Fix responses and handling of cancel
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 4200
diff changeset
145 handler.GetWarningCount());
6f5d4bfb2c90 C-GET SCP: Fix responses and handling of cancel
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 4200
diff changeset
146
6f5d4bfb2c90 C-GET SCP: Fix responses and handling of cancel
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 4200
diff changeset
147 if (processedCount > handler.GetSubOperationCount())
6f5d4bfb2c90 C-GET SCP: Fix responses and handling of cancel
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 4200
diff changeset
148 {
6f5d4bfb2c90 C-GET SCP: Fix responses and handling of cancel
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 4200
diff changeset
149 throw OrthancException(ErrorCode_InternalError);
6f5d4bfb2c90 C-GET SCP: Fix responses and handling of cancel
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 4200
diff changeset
150 }
6f5d4bfb2c90 C-GET SCP: Fix responses and handling of cancel
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 4200
diff changeset
151
6f5d4bfb2c90 C-GET SCP: Fix responses and handling of cancel
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 4200
diff changeset
152 response.NumberOfRemainingSubOperations = (handler.GetSubOperationCount() - processedCount);
6f5d4bfb2c90 C-GET SCP: Fix responses and handling of cancel
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 4200
diff changeset
153 response.NumberOfCompletedSubOperations = handler.GetCompletedCount();
6f5d4bfb2c90 C-GET SCP: Fix responses and handling of cancel
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 4200
diff changeset
154 response.NumberOfFailedSubOperations = handler.GetFailedCount();
6f5d4bfb2c90 C-GET SCP: Fix responses and handling of cancel
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 4200
diff changeset
155 response.NumberOfWarningSubOperations = handler.GetWarningCount();
6f5d4bfb2c90 C-GET SCP: Fix responses and handling of cancel
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 4200
diff changeset
156
6f5d4bfb2c90 C-GET SCP: Fix responses and handling of cancel
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 4200
diff changeset
157 // http://dicom.nema.org/medical/dicom/current/output/chtml/part04/sect_C.4.3.3.html
6f5d4bfb2c90 C-GET SCP: Fix responses and handling of cancel
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 4200
diff changeset
158
6f5d4bfb2c90 C-GET SCP: Fix responses and handling of cancel
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 4200
diff changeset
159 if (handler.GetFailedCount() > 0 ||
6f5d4bfb2c90 C-GET SCP: Fix responses and handling of cancel
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 4200
diff changeset
160 handler.GetWarningCount() > 0)
6f5d4bfb2c90 C-GET SCP: Fix responses and handling of cancel
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 4200
diff changeset
161 {
6f5d4bfb2c90 C-GET SCP: Fix responses and handling of cancel
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 4200
diff changeset
162 /**
6f5d4bfb2c90 C-GET SCP: Fix responses and handling of cancel
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 4200
diff changeset
163 * "Warning if one or more sub-operations were successfully
6f5d4bfb2c90 C-GET SCP: Fix responses and handling of cancel
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 4200
diff changeset
164 * completed and one or more sub-operations were unsuccessful
6f5d4bfb2c90 C-GET SCP: Fix responses and handling of cancel
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 4200
diff changeset
165 * or had a status of warning. Warning if all sub-operations
6f5d4bfb2c90 C-GET SCP: Fix responses and handling of cancel
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 4200
diff changeset
166 * had a status of Warning"
6f5d4bfb2c90 C-GET SCP: Fix responses and handling of cancel
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 4200
diff changeset
167 **/
6f5d4bfb2c90 C-GET SCP: Fix responses and handling of cancel
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 4200
diff changeset
168 response.DimseStatus = STATUS_GET_Warning_SubOperationsCompleteOneOrMoreFailures;
6f5d4bfb2c90 C-GET SCP: Fix responses and handling of cancel
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 4200
diff changeset
169 }
6f5d4bfb2c90 C-GET SCP: Fix responses and handling of cancel
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 4200
diff changeset
170
6f5d4bfb2c90 C-GET SCP: Fix responses and handling of cancel
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 4200
diff changeset
171 if (handler.GetFailedCount() > 0 &&
6f5d4bfb2c90 C-GET SCP: Fix responses and handling of cancel
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 4200
diff changeset
172 handler.GetFailedCount() == handler.GetSubOperationCount())
6f5d4bfb2c90 C-GET SCP: Fix responses and handling of cancel
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 4200
diff changeset
173 {
6f5d4bfb2c90 C-GET SCP: Fix responses and handling of cancel
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 4200
diff changeset
174 /**
6f5d4bfb2c90 C-GET SCP: Fix responses and handling of cancel
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 4200
diff changeset
175 * "Failure or Refused if all sub-operations were
6f5d4bfb2c90 C-GET SCP: Fix responses and handling of cancel
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 4200
diff changeset
176 * unsuccessful." => We choose to generate a "Refused - Out
6f5d4bfb2c90 C-GET SCP: Fix responses and handling of cancel
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 4200
diff changeset
177 * of Resources - Unable to perform suboperations" status.
6f5d4bfb2c90 C-GET SCP: Fix responses and handling of cancel
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 4200
diff changeset
178 */
6f5d4bfb2c90 C-GET SCP: Fix responses and handling of cancel
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 4200
diff changeset
179 response.DimseStatus = STATUS_GET_Refused_OutOfResourcesSubOperations;
6f5d4bfb2c90 C-GET SCP: Fix responses and handling of cancel
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 4200
diff changeset
180 }
6f5d4bfb2c90 C-GET SCP: Fix responses and handling of cancel
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 4200
diff changeset
181
6f5d4bfb2c90 C-GET SCP: Fix responses and handling of cancel
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 4200
diff changeset
182 *failedIdentifiers = BuildFailedInstanceList(handler.GetFailedUids());
6f5d4bfb2c90 C-GET SCP: Fix responses and handling of cancel
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 4200
diff changeset
183 }
6f5d4bfb2c90 C-GET SCP: Fix responses and handling of cancel
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 4200
diff changeset
184
6f5d4bfb2c90 C-GET SCP: Fix responses and handling of cancel
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 4200
diff changeset
185
3953
620e87e9e816 c-get: fixing memory with failedUIDs_
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 3818
diff changeset
186 static void GetScpCallback(
3818
4f78da5613a1 Add C-GET SCP support
Stacy Loesch <stacy.loesch@varian.com>
parents:
diff changeset
187 /* in */
4f78da5613a1 Add C-GET SCP support
Stacy Loesch <stacy.loesch@varian.com>
parents:
diff changeset
188 void *callbackData,
4f78da5613a1 Add C-GET SCP support
Stacy Loesch <stacy.loesch@varian.com>
parents:
diff changeset
189 OFBool cancelled,
4f78da5613a1 Add C-GET SCP support
Stacy Loesch <stacy.loesch@varian.com>
parents:
diff changeset
190 T_DIMSE_C_GetRQ *request,
4f78da5613a1 Add C-GET SCP support
Stacy Loesch <stacy.loesch@varian.com>
parents:
diff changeset
191 DcmDataset *requestIdentifiers,
4f78da5613a1 Add C-GET SCP support
Stacy Loesch <stacy.loesch@varian.com>
parents:
diff changeset
192 int responseCount,
4f78da5613a1 Add C-GET SCP support
Stacy Loesch <stacy.loesch@varian.com>
parents:
diff changeset
193 /* out */
4f78da5613a1 Add C-GET SCP support
Stacy Loesch <stacy.loesch@varian.com>
parents:
diff changeset
194 T_DIMSE_C_GetRSP *response,
4f78da5613a1 Add C-GET SCP support
Stacy Loesch <stacy.loesch@varian.com>
parents:
diff changeset
195 DcmDataset **responseIdentifiers,
4f78da5613a1 Add C-GET SCP support
Stacy Loesch <stacy.loesch@varian.com>
parents:
diff changeset
196 DcmDataset **statusDetail)
4f78da5613a1 Add C-GET SCP support
Stacy Loesch <stacy.loesch@varian.com>
parents:
diff changeset
197 {
4258
6f5d4bfb2c90 C-GET SCP: Fix responses and handling of cancel
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 4200
diff changeset
198 assert(response != NULL);
6f5d4bfb2c90 C-GET SCP: Fix responses and handling of cancel
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 4200
diff changeset
199 assert(responseIdentifiers != NULL);
4286
526bd8bad850 debug logs for C-MOVE and C-GET SCP
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 4284
diff changeset
200 assert(requestIdentifiers != NULL);
4258
6f5d4bfb2c90 C-GET SCP: Fix responses and handling of cancel
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 4200
diff changeset
201
5072
b23a4bb18065 replaced bzero() by memset()
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 4870
diff changeset
202 memset(response, 0, sizeof(T_DIMSE_C_GetRSP));
3818
4f78da5613a1 Add C-GET SCP support
Stacy Loesch <stacy.loesch@varian.com>
parents:
diff changeset
203 *statusDetail = NULL;
4f78da5613a1 Add C-GET SCP support
Stacy Loesch <stacy.loesch@varian.com>
parents:
diff changeset
204 *responseIdentifiers = NULL;
4f78da5613a1 Add C-GET SCP support
Stacy Loesch <stacy.loesch@varian.com>
parents:
diff changeset
205
4f78da5613a1 Add C-GET SCP support
Stacy Loesch <stacy.loesch@varian.com>
parents:
diff changeset
206 GetScpData& data = *reinterpret_cast<GetScpData*>(callbackData);
4f78da5613a1 Add C-GET SCP support
Stacy Loesch <stacy.loesch@varian.com>
parents:
diff changeset
207 if (data.lastRequest_ == NULL)
4f78da5613a1 Add C-GET SCP support
Stacy Loesch <stacy.loesch@varian.com>
parents:
diff changeset
208 {
4286
526bd8bad850 debug logs for C-MOVE and C-GET SCP
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 4284
diff changeset
209 {
4288
5b254bd435d3 fix for VS2008
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 4286
diff changeset
210 std::stringstream s; // DcmObject::PrintHelper cannot be used with VS2008
5b254bd435d3 fix for VS2008
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 4286
diff changeset
211 requestIdentifiers->print(s);
5b254bd435d3 fix for VS2008
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 4286
diff changeset
212 CLOG(TRACE, DICOM) << "Received C-GET Request:" << std::endl << s.str();
4286
526bd8bad850 debug logs for C-MOVE and C-GET SCP
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 4284
diff changeset
213 }
526bd8bad850 debug logs for C-MOVE and C-GET SCP
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 4284
diff changeset
214
3818
4f78da5613a1 Add C-GET SCP support
Stacy Loesch <stacy.loesch@varian.com>
parents:
diff changeset
215 DicomMap input;
4137
6774605d4341 keep only one signature for FromDcmtkBridge::ExtractDicomSummary()
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 4136
diff changeset
216 std::set<DicomTag> ignoreTagLength;
6774605d4341 keep only one signature for FromDcmtkBridge::ExtractDicomSummary()
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 4136
diff changeset
217 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
218
4f78da5613a1 Add C-GET SCP support
Stacy Loesch <stacy.loesch@varian.com>
parents:
diff changeset
219 try
4f78da5613a1 Add C-GET SCP support
Stacy Loesch <stacy.loesch@varian.com>
parents:
diff changeset
220 {
3959
76a24be12912 c-get: support of transcoding
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 3955
diff changeset
221 if (!data.handler_->Handle(
76a24be12912 c-get: support of transcoding
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 3955
diff changeset
222 input, data.remoteIp_, data.remoteAet_, data.calledAet_,
76a24be12912 c-get: support of transcoding
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 3955
diff changeset
223 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
224 {
4f78da5613a1 Add C-GET SCP support
Stacy Loesch <stacy.loesch@varian.com>
parents:
diff changeset
225 response->DimseStatus = STATUS_GET_Failed_UnableToProcess;
4f78da5613a1 Add C-GET SCP support
Stacy Loesch <stacy.loesch@varian.com>
parents:
diff changeset
226 return;
4f78da5613a1 Add C-GET SCP support
Stacy Loesch <stacy.loesch@varian.com>
parents:
diff changeset
227 }
4f78da5613a1 Add C-GET SCP support
Stacy Loesch <stacy.loesch@varian.com>
parents:
diff changeset
228 }
4f78da5613a1 Add C-GET SCP support
Stacy Loesch <stacy.loesch@varian.com>
parents:
diff changeset
229 catch (OrthancException& e)
4f78da5613a1 Add C-GET SCP support
Stacy Loesch <stacy.loesch@varian.com>
parents:
diff changeset
230 {
4f78da5613a1 Add C-GET SCP support
Stacy Loesch <stacy.loesch@varian.com>
parents:
diff changeset
231 // Internal error!
4284
756126cd2219 moving all logs from DicomNetworking folder into the "dicom" category
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 4258
diff changeset
232 CLOG(ERROR, DICOM) << "IGetRequestHandler Failed: " << e.What();
3818
4f78da5613a1 Add C-GET SCP support
Stacy Loesch <stacy.loesch@varian.com>
parents:
diff changeset
233 response->DimseStatus = STATUS_GET_Failed_UnableToProcess;
4f78da5613a1 Add C-GET SCP support
Stacy Loesch <stacy.loesch@varian.com>
parents:
diff changeset
234 return;
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
4f78da5613a1 Add C-GET SCP support
Stacy Loesch <stacy.loesch@varian.com>
parents:
diff changeset
237 data.lastRequest_ = requestIdentifiers;
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 else if (data.lastRequest_ != requestIdentifiers)
4f78da5613a1 Add C-GET SCP support
Stacy Loesch <stacy.loesch@varian.com>
parents:
diff changeset
240 {
4f78da5613a1 Add C-GET SCP support
Stacy Loesch <stacy.loesch@varian.com>
parents:
diff changeset
241 // Internal error!
4284
756126cd2219 moving all logs from DicomNetworking folder into the "dicom" category
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 4258
diff changeset
242 CLOG(ERROR, DICOM) << "IGetRequestHandler Failed: Internal error lastRequestIdentifier";
3818
4f78da5613a1 Add C-GET SCP support
Stacy Loesch <stacy.loesch@varian.com>
parents:
diff changeset
243 response->DimseStatus = STATUS_GET_Failed_UnableToProcess;
4f78da5613a1 Add C-GET SCP support
Stacy Loesch <stacy.loesch@varian.com>
parents:
diff changeset
244 return;
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
4258
6f5d4bfb2c90 C-GET SCP: Fix responses and handling of cancel
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 4200
diff changeset
247 if (data.canceled_)
3818
4f78da5613a1 Add C-GET SCP support
Stacy Loesch <stacy.loesch@varian.com>
parents:
diff changeset
248 {
4284
756126cd2219 moving all logs from DicomNetworking folder into the "dicom" category
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 4258
diff changeset
249 CLOG(ERROR, DICOM) << "IGetRequestHandler Failed: Cannot pursue a request that was canceled by the SCU";
4258
6f5d4bfb2c90 C-GET SCP: Fix responses and handling of cancel
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 4200
diff changeset
250 response->DimseStatus = STATUS_GET_Failed_UnableToProcess;
6f5d4bfb2c90 C-GET SCP: Fix responses and handling of cancel
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 4200
diff changeset
251 return;
6f5d4bfb2c90 C-GET SCP: Fix responses and handling of cancel
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 4200
diff changeset
252 }
6f5d4bfb2c90 C-GET SCP: Fix responses and handling of cancel
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 4200
diff changeset
253
6f5d4bfb2c90 C-GET SCP: Fix responses and handling of cancel
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 4200
diff changeset
254 if (data.handler_->GetSubOperationCount() ==
6f5d4bfb2c90 C-GET SCP: Fix responses and handling of cancel
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 4200
diff changeset
255 data.handler_->GetCompletedCount() +
6f5d4bfb2c90 C-GET SCP: Fix responses and handling of cancel
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 4200
diff changeset
256 data.handler_->GetFailedCount() +
6f5d4bfb2c90 C-GET SCP: Fix responses and handling of cancel
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 4200
diff changeset
257 data.handler_->GetWarningCount())
6f5d4bfb2c90 C-GET SCP: Fix responses and handling of cancel
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 4200
diff changeset
258 {
6f5d4bfb2c90 C-GET SCP: Fix responses and handling of cancel
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 4200
diff changeset
259 // We're all done
6f5d4bfb2c90 C-GET SCP: Fix responses and handling of cancel
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 4200
diff changeset
260 FillResponse(*response, responseIdentifiers, *data.handler_);
3818
4f78da5613a1 Add C-GET SCP support
Stacy Loesch <stacy.loesch@varian.com>
parents:
diff changeset
261 }
4f78da5613a1 Add C-GET SCP support
Stacy Loesch <stacy.loesch@varian.com>
parents:
diff changeset
262 else
4f78da5613a1 Add C-GET SCP support
Stacy Loesch <stacy.loesch@varian.com>
parents:
diff changeset
263 {
4258
6f5d4bfb2c90 C-GET SCP: Fix responses and handling of cancel
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 4200
diff changeset
264 bool isContinue;
6f5d4bfb2c90 C-GET SCP: Fix responses and handling of cancel
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 4200
diff changeset
265
3818
4f78da5613a1 Add C-GET SCP support
Stacy Loesch <stacy.loesch@varian.com>
parents:
diff changeset
266 try
4f78da5613a1 Add C-GET SCP support
Stacy Loesch <stacy.loesch@varian.com>
parents:
diff changeset
267 {
4258
6f5d4bfb2c90 C-GET SCP: Fix responses and handling of cancel
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 4200
diff changeset
268 isContinue = data.handler_->DoNext(data.assoc_);
3818
4f78da5613a1 Add C-GET SCP support
Stacy Loesch <stacy.loesch@varian.com>
parents:
diff changeset
269 }
4f78da5613a1 Add C-GET SCP support
Stacy Loesch <stacy.loesch@varian.com>
parents:
diff changeset
270 catch (OrthancException& e)
4f78da5613a1 Add C-GET SCP support
Stacy Loesch <stacy.loesch@varian.com>
parents:
diff changeset
271 {
4f78da5613a1 Add C-GET SCP support
Stacy Loesch <stacy.loesch@varian.com>
parents:
diff changeset
272 // Internal error!
4284
756126cd2219 moving all logs from DicomNetworking folder into the "dicom" category
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 4258
diff changeset
273 CLOG(ERROR, DICOM) << "IGetRequestHandler Failed: " << e.What();
4258
6f5d4bfb2c90 C-GET SCP: Fix responses and handling of cancel
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 4200
diff changeset
274 FillResponse(*response, responseIdentifiers, *data.handler_);
6f5d4bfb2c90 C-GET SCP: Fix responses and handling of cancel
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 4200
diff changeset
275
6f5d4bfb2c90 C-GET SCP: Fix responses and handling of cancel
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 4200
diff changeset
276 // Fix the status code that is computed by "FillResponse()"
3818
4f78da5613a1 Add C-GET SCP support
Stacy Loesch <stacy.loesch@varian.com>
parents:
diff changeset
277 response->DimseStatus = STATUS_GET_Failed_UnableToProcess;
4f78da5613a1 Add C-GET SCP support
Stacy Loesch <stacy.loesch@varian.com>
parents:
diff changeset
278 return;
4f78da5613a1 Add C-GET SCP support
Stacy Loesch <stacy.loesch@varian.com>
parents:
diff changeset
279 }
4258
6f5d4bfb2c90 C-GET SCP: Fix responses and handling of cancel
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 4200
diff changeset
280
6f5d4bfb2c90 C-GET SCP: Fix responses and handling of cancel
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 4200
diff changeset
281 FillResponse(*response, responseIdentifiers, *data.handler_);
6f5d4bfb2c90 C-GET SCP: Fix responses and handling of cancel
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 4200
diff changeset
282
6f5d4bfb2c90 C-GET SCP: Fix responses and handling of cancel
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 4200
diff changeset
283 if (isContinue)
3818
4f78da5613a1 Add C-GET SCP support
Stacy Loesch <stacy.loesch@varian.com>
parents:
diff changeset
284 {
4258
6f5d4bfb2c90 C-GET SCP: Fix responses and handling of cancel
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 4200
diff changeset
285 response->DimseStatus = STATUS_Pending;
3818
4f78da5613a1 Add C-GET SCP support
Stacy Loesch <stacy.loesch@varian.com>
parents:
diff changeset
286 }
4f78da5613a1 Add C-GET SCP support
Stacy Loesch <stacy.loesch@varian.com>
parents:
diff changeset
287 else
4f78da5613a1 Add C-GET SCP support
Stacy Loesch <stacy.loesch@varian.com>
parents:
diff changeset
288 {
4258
6f5d4bfb2c90 C-GET SCP: Fix responses and handling of cancel
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 4200
diff changeset
289 response->DimseStatus = STATUS_GET_Cancel_SubOperationsTerminatedDueToCancelIndication;
6f5d4bfb2c90 C-GET SCP: Fix responses and handling of cancel
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 4200
diff changeset
290 data.canceled_ = true;
3818
4f78da5613a1 Add C-GET SCP support
Stacy Loesch <stacy.loesch@varian.com>
parents:
diff changeset
291 }
4f78da5613a1 Add C-GET SCP support
Stacy Loesch <stacy.loesch@varian.com>
parents:
diff changeset
292 }
4f78da5613a1 Add C-GET SCP support
Stacy Loesch <stacy.loesch@varian.com>
parents:
diff changeset
293 }
4f78da5613a1 Add C-GET SCP support
Stacy Loesch <stacy.loesch@varian.com>
parents:
diff changeset
294 }
4f78da5613a1 Add C-GET SCP support
Stacy Loesch <stacy.loesch@varian.com>
parents:
diff changeset
295
4f78da5613a1 Add C-GET SCP support
Stacy Loesch <stacy.loesch@varian.com>
parents:
diff changeset
296 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
297 T_DIMSE_Message * msg,
620e87e9e816 c-get: fixing memory with failedUIDs_
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 3818
diff changeset
298 T_ASC_PresentationContextID presID,
620e87e9e816 c-get: fixing memory with failedUIDs_
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 3818
diff changeset
299 IGetRequestHandler& handler,
4200
7112a8af0b63 cppcheck
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 4137
diff changeset
300 const std::string& remoteIp,
7112a8af0b63 cppcheck
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 4137
diff changeset
301 const std::string& remoteAet,
7112a8af0b63 cppcheck
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 4137
diff changeset
302 const std::string& calledAet,
3953
620e87e9e816 c-get: fixing memory with failedUIDs_
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 3818
diff changeset
303 int timeout)
3818
4f78da5613a1 Add C-GET SCP support
Stacy Loesch <stacy.loesch@varian.com>
parents:
diff changeset
304 {
4f78da5613a1 Add C-GET SCP support
Stacy Loesch <stacy.loesch@varian.com>
parents:
diff changeset
305 GetScpData data;
4f78da5613a1 Add C-GET SCP support
Stacy Loesch <stacy.loesch@varian.com>
parents:
diff changeset
306 data.lastRequest_ = NULL;
4f78da5613a1 Add C-GET SCP support
Stacy Loesch <stacy.loesch@varian.com>
parents:
diff changeset
307 data.handler_ = &handler;
4f78da5613a1 Add C-GET SCP support
Stacy Loesch <stacy.loesch@varian.com>
parents:
diff changeset
308 data.assoc_ = assoc;
4f78da5613a1 Add C-GET SCP support
Stacy Loesch <stacy.loesch@varian.com>
parents:
diff changeset
309 data.remoteIp_ = remoteIp;
4f78da5613a1 Add C-GET SCP support
Stacy Loesch <stacy.loesch@varian.com>
parents:
diff changeset
310 data.remoteAet_ = remoteAet;
4f78da5613a1 Add C-GET SCP support
Stacy Loesch <stacy.loesch@varian.com>
parents:
diff changeset
311 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
312 data.timeout_ = timeout;
3818
4f78da5613a1 Add C-GET SCP support
Stacy Loesch <stacy.loesch@varian.com>
parents:
diff changeset
313
4f78da5613a1 Add C-GET SCP support
Stacy Loesch <stacy.loesch@varian.com>
parents:
diff changeset
314 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
315 GetScpCallback, &data,
620e87e9e816 c-get: fixing memory with failedUIDs_
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 3818
diff changeset
316 /*opt_blockMode*/ (timeout ? DIMSE_NONBLOCKING : DIMSE_BLOCKING),
620e87e9e816 c-get: fixing memory with failedUIDs_
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 3818
diff changeset
317 /*opt_dimse_timeout*/ timeout);
620e87e9e816 c-get: fixing memory with failedUIDs_
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 3818
diff changeset
318
3818
4f78da5613a1 Add C-GET SCP support
Stacy Loesch <stacy.loesch@varian.com>
parents:
diff changeset
319 // 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
320 if (cond.bad())
4f78da5613a1 Add C-GET SCP support
Stacy Loesch <stacy.loesch@varian.com>
parents:
diff changeset
321 {
4f78da5613a1 Add C-GET SCP support
Stacy Loesch <stacy.loesch@varian.com>
parents:
diff changeset
322 OFString temp_str;
4284
756126cd2219 moving all logs from DicomNetworking folder into the "dicom" category
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 4258
diff changeset
323 CLOG(ERROR, DICOM) << "Get SCP Failed: " << cond.text();
3818
4f78da5613a1 Add C-GET SCP support
Stacy Loesch <stacy.loesch@varian.com>
parents:
diff changeset
324 }
4f78da5613a1 Add C-GET SCP support
Stacy Loesch <stacy.loesch@varian.com>
parents:
diff changeset
325
4f78da5613a1 Add C-GET SCP support
Stacy Loesch <stacy.loesch@varian.com>
parents:
diff changeset
326 return cond;
4f78da5613a1 Add C-GET SCP support
Stacy Loesch <stacy.loesch@varian.com>
parents:
diff changeset
327 }
4f78da5613a1 Add C-GET SCP support
Stacy Loesch <stacy.loesch@varian.com>
parents:
diff changeset
328 }