comparison OrthancServer/Internals/StoreScp.cpp @ 1573:3309878b3e16

more information about the origin of requests submitted to the DICOM handlers
author Sebastien Jodogne <s.jodogne@gmail.com>
date Tue, 25 Aug 2015 13:05:22 +0200
parents f967bdf8534e
children de1413733c97 14a32b2fa63e
comparison
equal deleted inserted replaced
1572:904096e7367e 1573:3309878b3e16
100 namespace 100 namespace
101 { 101 {
102 struct StoreCallbackData 102 struct StoreCallbackData
103 { 103 {
104 IStoreRequestHandler* handler; 104 IStoreRequestHandler* handler;
105 const std::string* remoteIp;
105 const char* remoteAET; 106 const char* remoteAET;
106 const char* calledAET; 107 const char* calledAET;
107 const char* modality; 108 const char* modality;
108 const char* affectedSOPInstanceUID; 109 const char* affectedSOPInstanceUID;
109 uint32_t messageID; 110 uint32_t messageID;
200 } 201 }
201 else 202 else
202 { 203 {
203 try 204 try
204 { 205 {
205 cbdata->handler->Handle(buffer, summary, dicomJson, cbdata->remoteAET, cbdata->calledAET); 206 cbdata->handler->Handle(buffer, summary, dicomJson, *cbdata->remoteIp, cbdata->remoteAET, cbdata->calledAET);
206 } 207 }
207 catch (OrthancException& e) 208 catch (OrthancException& e)
208 { 209 {
209 rsp->DimseStatus = STATUS_STORE_Refused_OutOfResources; 210 rsp->DimseStatus = STATUS_STORE_Refused_OutOfResources;
210 211
235 * the DIMSE command. 236 * the DIMSE command.
236 */ 237 */
237 OFCondition Internals::storeScp(T_ASC_Association * assoc, 238 OFCondition Internals::storeScp(T_ASC_Association * assoc,
238 T_DIMSE_Message * msg, 239 T_DIMSE_Message * msg,
239 T_ASC_PresentationContextID presID, 240 T_ASC_PresentationContextID presID,
240 IStoreRequestHandler& handler) 241 IStoreRequestHandler& handler,
242 const std::string& remoteIp)
241 { 243 {
242 OFCondition cond = EC_Normal; 244 OFCondition cond = EC_Normal;
243 T_DIMSE_C_StoreRQ *req; 245 T_DIMSE_C_StoreRQ *req;
244 246
245 // assign the actual information of the C-STORE-RQ command to a local variable 247 // assign the actual information of the C-STORE-RQ command to a local variable
246 req = &msg->msg.CStoreRQ; 248 req = &msg->msg.CStoreRQ;
247 249
248 // intialize some variables 250 // intialize some variables
249 StoreCallbackData callbackData; 251 StoreCallbackData data;
250 callbackData.handler = &handler; 252 data.handler = &handler;
251 callbackData.modality = dcmSOPClassUIDToModality(req->AffectedSOPClassUID/*, "UNKNOWN"*/); 253 data.remoteIp = &remoteIp;
252 if (callbackData.modality == NULL) 254 data.modality = dcmSOPClassUIDToModality(req->AffectedSOPClassUID/*, "UNKNOWN"*/);
253 callbackData.modality = "UNKNOWN"; 255 if (data.modality == NULL)
254 256 data.modality = "UNKNOWN";
255 callbackData.affectedSOPInstanceUID = req->AffectedSOPInstanceUID; 257
256 callbackData.messageID = req->MessageID; 258 data.affectedSOPInstanceUID = req->AffectedSOPInstanceUID;
259 data.messageID = req->MessageID;
257 if (assoc && assoc->params) 260 if (assoc && assoc->params)
258 { 261 {
259 callbackData.remoteAET = assoc->params->DULparams.callingAPTitle; 262 data.remoteAET = assoc->params->DULparams.callingAPTitle;
260 callbackData.calledAET = assoc->params->DULparams.calledAPTitle; 263 data.calledAET = assoc->params->DULparams.calledAPTitle;
261 } 264 }
262 else 265 else
263 { 266 {
264 callbackData.remoteAET = ""; 267 data.remoteAET = "";
265 callbackData.calledAET = ""; 268 data.calledAET = "";
266 } 269 }
267 270
268 DcmFileFormat dcmff; 271 DcmFileFormat dcmff;
269 272
270 // store SourceApplicationEntityTitle in metaheader 273 // store SourceApplicationEntityTitle in metaheader
276 279
277 // define an address where the information which will be received over the network will be stored 280 // define an address where the information which will be received over the network will be stored
278 DcmDataset *dset = dcmff.getDataset(); 281 DcmDataset *dset = dcmff.getDataset();
279 282
280 cond = DIMSE_storeProvider(assoc, presID, req, NULL, /*opt_useMetaheader*/OFFalse, &dset, 283 cond = DIMSE_storeProvider(assoc, presID, req, NULL, /*opt_useMetaheader*/OFFalse, &dset,
281 storeScpCallback, &callbackData, 284 storeScpCallback, &data,
282 /*opt_blockMode*/ DIMSE_BLOCKING, 285 /*opt_blockMode*/ DIMSE_BLOCKING,
283 /*opt_dimse_timeout*/ 0); 286 /*opt_dimse_timeout*/ 0);
284 287
285 // if some error occured, dump corresponding information and remove the outfile if necessary 288 // if some error occured, dump corresponding information and remove the outfile if necessary
286 if (cond.bad()) 289 if (cond.bad())