comparison OrthancServer/Internals/MoveScp.cpp @ 2222:21713ce8717b

Fix handling of Move Originator AET and ID in C-MOVE SCP
author Sebastien Jodogne <s.jodogne@gmail.com>
date Tue, 13 Dec 2016 14:34:33 +0100
parents bb199bccdc45
children a3a65de1840f
comparison
equal deleted inserted replaced
2221:e7beca979562 2222:21713ce8717b
88 #include "../ToDcmtkBridge.h" 88 #include "../ToDcmtkBridge.h"
89 #include "../OrthancInitialization.h" 89 #include "../OrthancInitialization.h"
90 #include "../../Core/Logging.h" 90 #include "../../Core/Logging.h"
91 #include "../../Core/OrthancException.h" 91 #include "../../Core/OrthancException.h"
92 92
93 #include <boost/lexical_cast.hpp>
94
93 95
94 namespace Orthanc 96 namespace Orthanc
95 { 97 {
96 namespace 98 namespace
97 { 99 {
108 const std::string* remoteAet_; 110 const std::string* remoteAet_;
109 const std::string* calledAet_; 111 const std::string* calledAet_;
110 }; 112 };
111 113
112 114
115
116 static uint16_t GetMessageId(const DicomMap& message)
117 {
118 /**
119 * Retrieve the Message ID (0000,0110) for this C-MOVE request, if
120 * any. If present, this Message ID will be stored in the Move
121 * Originator Message ID (0000,1031) field of the C-MOVE response.
122 * http://dicom.nema.org/dicom/2013/output/chtml/part07/chapter_E.html
123 **/
124
125 const DicomValue* value = message.TestAndGetValue(DICOM_TAG_MESSAGE_ID);
126
127 if (value != NULL &&
128 !value->IsNull() &&
129 !value->IsBinary())
130 {
131 try
132 {
133 int tmp = boost::lexical_cast<int>(value->GetContent());
134 if (tmp >= 0 && tmp <= 0xffff)
135 {
136 return static_cast<uint16_t>(tmp);
137 }
138 }
139 catch (boost::bad_lexical_cast&)
140 {
141 LOG(WARNING) << "Cannot convert the Message ID (\"" << value->GetContent()
142 << "\") of an incoming C-MOVE request to an integer, assuming zero";
143 }
144 }
145
146 return 0;
147 }
148
149
150
113 void MoveScpCallback( 151 void MoveScpCallback(
114 /* in */ 152 /* in */
115 void *callbackData, 153 void *callbackData,
116 OFBool cancelled, 154 OFBool cancelled,
117 T_DIMSE_C_MoveRQ *request, 155 T_DIMSE_C_MoveRQ *request,
132 DicomMap input; 170 DicomMap input;
133 Configuration::ExtractDicomSummary(input, *requestIdentifiers); 171 Configuration::ExtractDicomSummary(input, *requestIdentifiers);
134 172
135 try 173 try
136 { 174 {
137 data.iterator_.reset(data.handler_->Handle(data.target_, input, 175 data.iterator_.reset(data.handler_->Handle(data.target_, input, *data.remoteIp_, *data.remoteAet_,
138 *data.remoteIp_, *data.remoteAet_, 176 *data.calledAet_, GetMessageId(input)));
139 *data.calledAet_, request->MessageID));
140 177
141 if (data.iterator_.get() == NULL) 178 if (data.iterator_.get() == NULL)
142 { 179 {
143 // Internal error! 180 // Internal error!
144 response->DimseStatus = STATUS_MOVE_Failed_UnableToProcess; 181 response->DimseStatus = STATUS_MOVE_Failed_UnableToProcess;