Mercurial > hg > orthanc
annotate OrthancFramework/Sources/DicomNetworking/Internals/MoveScp.cpp @ 5072:b23a4bb18065
replaced bzero() by memset()
author | Sebastien Jodogne <s.jodogne@gmail.com> |
---|---|
date | Mon, 15 Aug 2022 22:13:39 +0200 |
parents | 43e613a7756b |
children | 0ea402b4d901 |
rev | line source |
---|---|
0 | 1 /** |
62 | 2 * Orthanc - A Lightweight, RESTful DICOM Store |
1900 | 3 * Copyright (C) 2012-2016 Sebastien Jodogne, Medical Physics |
1288
6e7e5ed91c2d
upgrade to year 2015
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
831
diff
changeset
|
4 * Department, University Hospital of Liege, Belgium |
4870
43e613a7756b
upgrade to year 2022
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
4831
diff
changeset
|
5 * Copyright (C) 2017-2022 Osimis S.A., Belgium |
43e613a7756b
upgrade to year 2022
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
4831
diff
changeset
|
6 * Copyright (C) 2021-2022 Sebastien Jodogne, ICTEAM UCLouvain, Belgium |
0 | 7 * |
8 * 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
|
9 * 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
|
10 * 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
|
11 * the License, or (at your option) any later version. |
136 | 12 * |
0 | 13 * This program is distributed in the hope that it will be useful, but |
14 * WITHOUT ANY WARRANTY; without even the implied warranty of | |
15 * 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
|
16 * Lesser General Public License for more details. |
0 | 17 * |
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
|
18 * 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
|
19 * 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
|
20 * <http://www.gnu.org/licenses/>. |
0 | 21 **/ |
22 | |
23 | |
766
0a2f8c707c78
Fix missing licensing terms about reuse of some DCMTK code
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
722
diff
changeset
|
24 |
0a2f8c707c78
Fix missing licensing terms about reuse of some DCMTK code
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
722
diff
changeset
|
25 |
0a2f8c707c78
Fix missing licensing terms about reuse of some DCMTK code
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
722
diff
changeset
|
26 /*========================================================================= |
0a2f8c707c78
Fix missing licensing terms about reuse of some DCMTK code
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
722
diff
changeset
|
27 |
0a2f8c707c78
Fix missing licensing terms about reuse of some DCMTK code
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
722
diff
changeset
|
28 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:
722
diff
changeset
|
29 |
0a2f8c707c78
Fix missing licensing terms about reuse of some DCMTK code
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
722
diff
changeset
|
30 Program: DCMTK 3.6.0 |
0a2f8c707c78
Fix missing licensing terms about reuse of some DCMTK code
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
722
diff
changeset
|
31 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:
722
diff
changeset
|
32 |
0a2f8c707c78
Fix missing licensing terms about reuse of some DCMTK code
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
722
diff
changeset
|
33 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:
722
diff
changeset
|
34 All rights reserved. |
0a2f8c707c78
Fix missing licensing terms about reuse of some DCMTK code
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
722
diff
changeset
|
35 |
0a2f8c707c78
Fix missing licensing terms about reuse of some DCMTK code
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
722
diff
changeset
|
36 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:
722
diff
changeset
|
37 |
0a2f8c707c78
Fix missing licensing terms about reuse of some DCMTK code
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
722
diff
changeset
|
38 OFFIS e.V. |
0a2f8c707c78
Fix missing licensing terms about reuse of some DCMTK code
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
722
diff
changeset
|
39 R&D Division Health |
0a2f8c707c78
Fix missing licensing terms about reuse of some DCMTK code
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
722
diff
changeset
|
40 Escherweg 2 |
0a2f8c707c78
Fix missing licensing terms about reuse of some DCMTK code
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
722
diff
changeset
|
41 26121 Oldenburg, Germany |
0a2f8c707c78
Fix missing licensing terms about reuse of some DCMTK code
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
722
diff
changeset
|
42 |
0a2f8c707c78
Fix missing licensing terms about reuse of some DCMTK code
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
722
diff
changeset
|
43 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:
722
diff
changeset
|
44 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:
722
diff
changeset
|
45 are met: |
0a2f8c707c78
Fix missing licensing terms about reuse of some DCMTK code
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
722
diff
changeset
|
46 |
0a2f8c707c78
Fix missing licensing terms about reuse of some DCMTK code
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
722
diff
changeset
|
47 - 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:
722
diff
changeset
|
48 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:
722
diff
changeset
|
49 |
0a2f8c707c78
Fix missing licensing terms about reuse of some DCMTK code
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
722
diff
changeset
|
50 - 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:
722
diff
changeset
|
51 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:
722
diff
changeset
|
52 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:
722
diff
changeset
|
53 |
0a2f8c707c78
Fix missing licensing terms about reuse of some DCMTK code
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
722
diff
changeset
|
54 - 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:
722
diff
changeset
|
55 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:
722
diff
changeset
|
56 without specific prior written permission. |
0a2f8c707c78
Fix missing licensing terms about reuse of some DCMTK code
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
722
diff
changeset
|
57 |
0a2f8c707c78
Fix missing licensing terms about reuse of some DCMTK code
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
722
diff
changeset
|
58 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:
722
diff
changeset
|
59 "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:
722
diff
changeset
|
60 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:
722
diff
changeset
|
61 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:
722
diff
changeset
|
62 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:
722
diff
changeset
|
63 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:
722
diff
changeset
|
64 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:
722
diff
changeset
|
65 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:
722
diff
changeset
|
66 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:
722
diff
changeset
|
67 (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:
722
diff
changeset
|
68 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:
722
diff
changeset
|
69 |
0a2f8c707c78
Fix missing licensing terms about reuse of some DCMTK code
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
722
diff
changeset
|
70 =========================================================================*/ |
0a2f8c707c78
Fix missing licensing terms about reuse of some DCMTK code
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
722
diff
changeset
|
71 |
0a2f8c707c78
Fix missing licensing terms about reuse of some DCMTK code
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
722
diff
changeset
|
72 |
2382
7284093111b0
big reorganization to cleanly separate framework vs. server
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
2381
diff
changeset
|
73 #include "../../PrecompiledHeaders.h" |
0 | 74 #include "MoveScp.h" |
75 | |
76 #include <memory> | |
77 | |
2382
7284093111b0
big reorganization to cleanly separate framework vs. server
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
2381
diff
changeset
|
78 #include "../../DicomParsing/FromDcmtkBridge.h" |
7284093111b0
big reorganization to cleanly separate framework vs. server
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
2381
diff
changeset
|
79 #include "../../DicomParsing/ToDcmtkBridge.h" |
7284093111b0
big reorganization to cleanly separate framework vs. server
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
2381
diff
changeset
|
80 #include "../../Logging.h" |
7284093111b0
big reorganization to cleanly separate framework vs. server
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
2381
diff
changeset
|
81 #include "../../OrthancException.h" |
0 | 82 |
2222
21713ce8717b
Fix handling of Move Originator AET and ID in C-MOVE SCP
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
2131
diff
changeset
|
83 #include <boost/lexical_cast.hpp> |
21713ce8717b
Fix handling of Move Originator AET and ID in C-MOVE SCP
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
2131
diff
changeset
|
84 |
0 | 85 |
2723 | 86 /** |
87 * Macro specifying whether to apply the patch suggested in issue 66: | |
88 * "Orthanc responses C-MOVE with zero Move Originator Message ID" | |
4476
c1f36fd13730
migrate remaining links to issues in bitbucket to mercurial server
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
4437
diff
changeset
|
89 * https://bugs.orthanc-server.com/show_bug.cgi?id=66 |
2723 | 90 **/ |
91 | |
92 #define APPLY_FIX_ISSUE_66 1 | |
93 | |
94 | |
62 | 95 namespace Orthanc |
0 | 96 { |
97 namespace | |
98 { | |
99 struct MoveScpData | |
100 { | |
101 std::string target_; | |
102 IMoveRequestHandler* handler_; | |
103 DcmDataset* lastRequest_; | |
104 unsigned int subOperationCount_; | |
105 unsigned int failureCount_; | |
106 unsigned int warningCount_; | |
3712
2a170a8f1faf
replacing std::auto_ptr by std::unique_ptr
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
3704
diff
changeset
|
107 std::unique_ptr<IMoveRequestIterator> iterator_; |
1573
3309878b3e16
more information about the origin of requests submitted to the DICOM handlers
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
1486
diff
changeset
|
108 const std::string* remoteIp_; |
3309878b3e16
more information about the origin of requests submitted to the DICOM handlers
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
1486
diff
changeset
|
109 const std::string* remoteAet_; |
1799
4f01c9d73f02
calledAet made available to all the handlers
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
1786
diff
changeset
|
110 const std::string* calledAet_; |
0 | 111 }; |
112 | |
113 | |
2723 | 114 #if APPLY_FIX_ISSUE_66 != 1 |
2222
21713ce8717b
Fix handling of Move Originator AET and ID in C-MOVE SCP
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
2131
diff
changeset
|
115 static uint16_t GetMessageId(const DicomMap& message) |
21713ce8717b
Fix handling of Move Originator AET and ID in C-MOVE SCP
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
2131
diff
changeset
|
116 { |
21713ce8717b
Fix handling of Move Originator AET and ID in C-MOVE SCP
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
2131
diff
changeset
|
117 /** |
21713ce8717b
Fix handling of Move Originator AET and ID in C-MOVE SCP
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
2131
diff
changeset
|
118 * Retrieve the Message ID (0000,0110) for this C-MOVE request, if |
21713ce8717b
Fix handling of Move Originator AET and ID in C-MOVE SCP
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
2131
diff
changeset
|
119 * any. If present, this Message ID will be stored in the Move |
21713ce8717b
Fix handling of Move Originator AET and ID in C-MOVE SCP
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
2131
diff
changeset
|
120 * Originator Message ID (0000,1031) field of the C-MOVE response. |
21713ce8717b
Fix handling of Move Originator AET and ID in C-MOVE SCP
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
2131
diff
changeset
|
121 * http://dicom.nema.org/dicom/2013/output/chtml/part07/chapter_E.html |
21713ce8717b
Fix handling of Move Originator AET and ID in C-MOVE SCP
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
2131
diff
changeset
|
122 **/ |
21713ce8717b
Fix handling of Move Originator AET and ID in C-MOVE SCP
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
2131
diff
changeset
|
123 |
21713ce8717b
Fix handling of Move Originator AET and ID in C-MOVE SCP
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
2131
diff
changeset
|
124 const DicomValue* value = message.TestAndGetValue(DICOM_TAG_MESSAGE_ID); |
21713ce8717b
Fix handling of Move Originator AET and ID in C-MOVE SCP
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
2131
diff
changeset
|
125 |
21713ce8717b
Fix handling of Move Originator AET and ID in C-MOVE SCP
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
2131
diff
changeset
|
126 if (value != NULL && |
21713ce8717b
Fix handling of Move Originator AET and ID in C-MOVE SCP
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
2131
diff
changeset
|
127 !value->IsNull() && |
21713ce8717b
Fix handling of Move Originator AET and ID in C-MOVE SCP
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
2131
diff
changeset
|
128 !value->IsBinary()) |
21713ce8717b
Fix handling of Move Originator AET and ID in C-MOVE SCP
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
2131
diff
changeset
|
129 { |
21713ce8717b
Fix handling of Move Originator AET and ID in C-MOVE SCP
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
2131
diff
changeset
|
130 try |
21713ce8717b
Fix handling of Move Originator AET and ID in C-MOVE SCP
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
2131
diff
changeset
|
131 { |
21713ce8717b
Fix handling of Move Originator AET and ID in C-MOVE SCP
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
2131
diff
changeset
|
132 int tmp = boost::lexical_cast<int>(value->GetContent()); |
21713ce8717b
Fix handling of Move Originator AET and ID in C-MOVE SCP
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
2131
diff
changeset
|
133 if (tmp >= 0 && tmp <= 0xffff) |
21713ce8717b
Fix handling of Move Originator AET and ID in C-MOVE SCP
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
2131
diff
changeset
|
134 { |
21713ce8717b
Fix handling of Move Originator AET and ID in C-MOVE SCP
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
2131
diff
changeset
|
135 return static_cast<uint16_t>(tmp); |
21713ce8717b
Fix handling of Move Originator AET and ID in C-MOVE SCP
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
2131
diff
changeset
|
136 } |
21713ce8717b
Fix handling of Move Originator AET and ID in C-MOVE SCP
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
2131
diff
changeset
|
137 } |
21713ce8717b
Fix handling of Move Originator AET and ID in C-MOVE SCP
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
2131
diff
changeset
|
138 catch (boost::bad_lexical_cast&) |
21713ce8717b
Fix handling of Move Originator AET and ID in C-MOVE SCP
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
2131
diff
changeset
|
139 { |
4284
756126cd2219
moving all logs from DicomNetworking folder into the "dicom" category
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
4137
diff
changeset
|
140 CLOG(WARNING, DICOM) << "Cannot convert the Message ID (\"" << value->GetContent() |
756126cd2219
moving all logs from DicomNetworking folder into the "dicom" category
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
4137
diff
changeset
|
141 << "\") of an incoming C-MOVE request to an integer, assuming zero"; |
2222
21713ce8717b
Fix handling of Move Originator AET and ID in C-MOVE SCP
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
2131
diff
changeset
|
142 } |
21713ce8717b
Fix handling of Move Originator AET and ID in C-MOVE SCP
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
2131
diff
changeset
|
143 } |
21713ce8717b
Fix handling of Move Originator AET and ID in C-MOVE SCP
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
2131
diff
changeset
|
144 |
21713ce8717b
Fix handling of Move Originator AET and ID in C-MOVE SCP
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
2131
diff
changeset
|
145 return 0; |
21713ce8717b
Fix handling of Move Originator AET and ID in C-MOVE SCP
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
2131
diff
changeset
|
146 } |
2723 | 147 #endif |
2222
21713ce8717b
Fix handling of Move Originator AET and ID in C-MOVE SCP
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
2131
diff
changeset
|
148 |
21713ce8717b
Fix handling of Move Originator AET and ID in C-MOVE SCP
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
2131
diff
changeset
|
149 |
0 | 150 void MoveScpCallback( |
151 /* in */ | |
152 void *callbackData, | |
153 OFBool cancelled, | |
154 T_DIMSE_C_MoveRQ *request, | |
155 DcmDataset *requestIdentifiers, | |
156 int responseCount, | |
157 /* out */ | |
158 T_DIMSE_C_MoveRSP *response, | |
159 DcmDataset **responseIdentifiers, | |
160 DcmDataset **statusDetail) | |
161 { | |
4286
526bd8bad850
debug logs for C-MOVE and C-GET SCP
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
4284
diff
changeset
|
162 assert(response != NULL); |
526bd8bad850
debug logs for C-MOVE and C-GET SCP
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
4284
diff
changeset
|
163 assert(requestIdentifiers != NULL); |
526bd8bad850
debug logs for C-MOVE and C-GET SCP
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
4284
diff
changeset
|
164 |
5072
b23a4bb18065
replaced bzero() by memset()
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
4870
diff
changeset
|
165 memset(response, 0, sizeof(T_DIMSE_C_MoveRSP)); |
0 | 166 *statusDetail = NULL; |
167 *responseIdentifiers = NULL; | |
168 | |
656 | 169 MoveScpData& data = *reinterpret_cast<MoveScpData*>(callbackData); |
0 | 170 if (data.lastRequest_ == NULL) |
171 { | |
4286
526bd8bad850
debug logs for C-MOVE and C-GET SCP
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
4284
diff
changeset
|
172 { |
4288 | 173 std::stringstream s; // DcmObject::PrintHelper cannot be used with VS2008 |
174 requestIdentifiers->print(s); | |
4286
526bd8bad850
debug logs for C-MOVE and C-GET SCP
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
4284
diff
changeset
|
175 CLOG(TRACE, DICOM) << "Received C-MOVE Request:" << std::endl << s.str(); |
526bd8bad850
debug logs for C-MOVE and C-GET SCP
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
4284
diff
changeset
|
176 } |
526bd8bad850
debug logs for C-MOVE and C-GET SCP
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
4284
diff
changeset
|
177 |
1786
164d78911382
primitives to handle dicom worklists
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
1573
diff
changeset
|
178 DicomMap input; |
4137
6774605d4341
keep only one signature for FromDcmtkBridge::ExtractDicomSummary()
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
4136
diff
changeset
|
179 std::set<DicomTag> ignoreTagLength; |
6774605d4341
keep only one signature for FromDcmtkBridge::ExtractDicomSummary()
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
4136
diff
changeset
|
180 FromDcmtkBridge::ExtractDicomSummary(input, *requestIdentifiers, 0 /* don't truncate tags */, ignoreTagLength); |
0 | 181 |
182 try | |
183 { | |
2723 | 184 #if APPLY_FIX_ISSUE_66 == 1 |
185 uint16_t messageId = request->MessageID; | |
186 #else | |
187 // The line below was the implementation for Orthanc <= 1.3.2 | |
188 uint16_t messageId = GetMessageId(input); | |
189 #endif | |
190 | |
2222
21713ce8717b
Fix handling of Move Originator AET and ID in C-MOVE SCP
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
2131
diff
changeset
|
191 data.iterator_.reset(data.handler_->Handle(data.target_, input, *data.remoteIp_, *data.remoteAet_, |
2723 | 192 *data.calledAet_, messageId)); |
722 | 193 |
613 | 194 if (data.iterator_.get() == NULL) |
195 { | |
196 // Internal error! | |
197 response->DimseStatus = STATUS_MOVE_Failed_UnableToProcess; | |
198 return; | |
199 } | |
200 | |
0 | 201 data.subOperationCount_ = data.iterator_->GetSubOperationCount(); |
202 data.failureCount_ = 0; | |
203 data.warningCount_ = 0; | |
204 } | |
62 | 205 catch (OrthancException& e) |
0 | 206 { |
207 // Internal error! | |
4284
756126cd2219
moving all logs from DicomNetworking folder into the "dicom" category
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
4137
diff
changeset
|
208 CLOG(ERROR, DICOM) << "IMoveRequestHandler Failed: " << e.What(); |
0 | 209 response->DimseStatus = STATUS_MOVE_Failed_UnableToProcess; |
210 return; | |
211 } | |
212 | |
213 data.lastRequest_ = requestIdentifiers; | |
214 } | |
215 else if (data.lastRequest_ != requestIdentifiers) | |
216 { | |
217 // Internal error! | |
218 response->DimseStatus = STATUS_MOVE_Failed_UnableToProcess; | |
219 return; | |
220 } | |
221 | |
222 if (data.subOperationCount_ == 0) | |
223 { | |
224 response->DimseStatus = STATUS_Success; | |
225 } | |
226 else | |
227 { | |
228 IMoveRequestIterator::Status status; | |
229 | |
230 try | |
231 { | |
232 status = data.iterator_->DoNext(); | |
233 } | |
62 | 234 catch (OrthancException& e) |
0 | 235 { |
236 // Internal error! | |
4284
756126cd2219
moving all logs from DicomNetworking folder into the "dicom" category
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
4137
diff
changeset
|
237 CLOG(ERROR, DICOM) << "IMoveRequestHandler Failed: " << e.What(); |
0 | 238 response->DimseStatus = STATUS_MOVE_Failed_UnableToProcess; |
239 return; | |
240 } | |
241 | |
242 if (status == IMoveRequestIterator::Status_Failure) | |
243 { | |
244 data.failureCount_++; | |
245 } | |
246 else if (status == IMoveRequestIterator::Status_Warning) | |
247 { | |
248 data.warningCount_++; | |
249 } | |
250 | |
251 if (responseCount < static_cast<int>(data.subOperationCount_)) | |
252 { | |
253 response->DimseStatus = STATUS_Pending; | |
254 } | |
255 else | |
256 { | |
257 response->DimseStatus = STATUS_Success; | |
258 } | |
259 } | |
260 | |
261 response->NumberOfRemainingSubOperations = data.subOperationCount_ - responseCount; | |
262 response->NumberOfCompletedSubOperations = responseCount; | |
263 response->NumberOfFailedSubOperations = data.failureCount_; | |
264 response->NumberOfWarningSubOperations = data.warningCount_; | |
4692
e68edf92e5cc
C-MOVE SCP: added possible DIMSE status "Sub-operations Complete - One or more Failures"
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
4476
diff
changeset
|
265 |
e68edf92e5cc
C-MOVE SCP: added possible DIMSE status "Sub-operations Complete - One or more Failures"
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
4476
diff
changeset
|
266 if (data.failureCount_ != 0) |
e68edf92e5cc
C-MOVE SCP: added possible DIMSE status "Sub-operations Complete - One or more Failures"
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
4476
diff
changeset
|
267 { |
e68edf92e5cc
C-MOVE SCP: added possible DIMSE status "Sub-operations Complete - One or more Failures"
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
4476
diff
changeset
|
268 // Warning "Sub-operations Complete - One or more Failures" (0xB000) |
e68edf92e5cc
C-MOVE SCP: added possible DIMSE status "Sub-operations Complete - One or more Failures"
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
4476
diff
changeset
|
269 response->DimseStatus = STATUS_MOVE_Warning_SubOperationsCompleteOneOrMoreFailures; |
e68edf92e5cc
C-MOVE SCP: added possible DIMSE status "Sub-operations Complete - One or more Failures"
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
4476
diff
changeset
|
270 } |
0 | 271 } |
272 } | |
273 | |
274 | |
275 OFCondition Internals::moveScp(T_ASC_Association * assoc, | |
276 T_DIMSE_Message * msg, | |
277 T_ASC_PresentationContextID presID, | |
1573
3309878b3e16
more information about the origin of requests submitted to the DICOM handlers
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
1486
diff
changeset
|
278 IMoveRequestHandler& handler, |
3309878b3e16
more information about the origin of requests submitted to the DICOM handlers
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
1486
diff
changeset
|
279 const std::string& remoteIp, |
1799
4f01c9d73f02
calledAet made available to all the handlers
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
1786
diff
changeset
|
280 const std::string& remoteAet, |
3704
58f92b1c8061
Fix issue #167 (Job can't be cancelled - Handling of timeouts after established association)
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
3640
diff
changeset
|
281 const std::string& calledAet, |
58f92b1c8061
Fix issue #167 (Job can't be cancelled - Handling of timeouts after established association)
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
3640
diff
changeset
|
282 int timeout) |
0 | 283 { |
284 MoveScpData data; | |
285 data.target_ = std::string(msg->msg.CMoveRQ.MoveDestination); | |
286 data.lastRequest_ = NULL; | |
287 data.handler_ = &handler; | |
1573
3309878b3e16
more information about the origin of requests submitted to the DICOM handlers
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
1486
diff
changeset
|
288 data.remoteIp_ = &remoteIp; |
3309878b3e16
more information about the origin of requests submitted to the DICOM handlers
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
1486
diff
changeset
|
289 data.remoteAet_ = &remoteAet; |
1799
4f01c9d73f02
calledAet made available to all the handlers
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
1786
diff
changeset
|
290 data.calledAet_ = &calledAet; |
0 | 291 |
292 OFCondition cond = DIMSE_moveProvider(assoc, presID, &msg->msg.CMoveRQ, | |
293 MoveScpCallback, &data, | |
3704
58f92b1c8061
Fix issue #167 (Job can't be cancelled - Handling of timeouts after established association)
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
3640
diff
changeset
|
294 /*opt_blockMode*/ (timeout ? DIMSE_NONBLOCKING : DIMSE_BLOCKING), |
58f92b1c8061
Fix issue #167 (Job can't be cancelled - Handling of timeouts after established association)
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
3640
diff
changeset
|
295 /*opt_dimse_timeout*/ timeout); |
0 | 296 |
297 // if some error occured, dump corresponding information and remove the outfile if necessary | |
298 if (cond.bad()) | |
299 { | |
300 OFString temp_str; | |
4284
756126cd2219
moving all logs from DicomNetworking folder into the "dicom" category
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
4137
diff
changeset
|
301 CLOG(ERROR, DICOM) << "Move SCP Failed: " << cond.text(); |
0 | 302 } |
303 | |
304 return cond; | |
305 } | |
306 } |