1 /* 2 * 3 * Copyright (C) 1994-2020, OFFIS e.V. 4 * All rights reserved. See COPYRIGHT file for details. 5 * 6 * This software and supporting documentation were partly developed by 7 * 8 * OFFIS e.V. 9 * R&D Division Health 10 * Escherweg 2 11 * D-26121 Oldenburg, Germany 12 * 13 * For further copyrights, see the following paragraphs. 14 * 15 */ 16 17 /* 18 ** Copyright (C) 1993/1994, OFFIS, Oldenburg University and CERIUM 19 ** 20 ** This software and supporting documentation were 21 ** developed by 22 ** 23 ** Institut OFFIS 24 ** Bereich Kommunikationssysteme 25 ** Westerstr. 10-12 26 ** 26121 Oldenburg, Germany 27 ** 28 ** Fachbereich Informatik 29 ** Abteilung Prozessinformatik 30 ** Carl von Ossietzky Universitaet Oldenburg 31 ** Ammerlaender Heerstr. 114-118 32 ** 26111 Oldenburg, Germany 33 ** 34 ** CERIUM 35 ** Laboratoire SIM 36 ** Faculte de Medecine 37 ** 2 Avenue du Pr. Leon Bernard 38 ** 35043 Rennes Cedex, France 39 ** 40 ** for CEN/TC251/WG4 as a contribution to the Radiological 41 ** Society of North America (RSNA) 1993 Digital Imaging and 42 ** Communications in Medicine (DICOM) Demonstration. 43 ** 44 ** THIS SOFTWARE IS MADE AVAILABLE, AS IS, AND NEITHER OFFIS, 45 ** OLDENBURG UNIVERSITY NOR CERIUM MAKE ANY WARRANTY REGARDING 46 ** THE SOFTWARE, ITS PERFORMANCE, ITS MERCHANTABILITY OR 47 ** FITNESS FOR ANY PARTICULAR USE, FREEDOM FROM ANY COMPUTER 48 ** DISEASES OR ITS CONFORMITY TO ANY SPECIFICATION. THE 49 ** ENTIRE RISK AS TO QUALITY AND PERFORMANCE OF THE SOFTWARE 50 ** IS WITH THE USER. 51 ** 52 ** Copyright of the software and supporting documentation 53 ** is, unless otherwise stated, jointly owned by OFFIS, 54 ** Oldenburg University and CERIUM and free access is hereby 55 ** granted as a license to use this software, copy this 56 ** software and prepare derivative works based upon this 57 ** software. However, any distribution of this software 58 ** source code or supporting documentation or derivative 59 ** works (source code and supporting documentation) must 60 ** include the three paragraphs of this copyright notice. 61 ** 62 */ 63 64 /* 65 ** 66 ** Author: Andrew Hewett Created: 03-06-93 67 ** 68 ** Module: dimse 69 ** 70 ** Purpose: 71 ** This file contains the routines which provide dimse layer services 72 ** for DICOM applications. 73 ** 74 ** Module Prefix: DIMSE_ 75 ** 76 */ 77 78 79 #ifndef DIMSE_H 80 #define DIMSE_H 81 82 /* 83 * Required Include Files. 84 */ 85 86 #include "dcmtk/config/osconfig.h" /* make sure OS specific configuration is included first */ 87 88 #include "dcmtk/dcmnet/dicom.h" 89 #include "dcmtk/dcmnet/lst.h" 90 #include "dcmtk/dcmnet/cond.h" 91 #include "dcmtk/dcmnet/dul.h" 92 #include "dcmtk/dcmnet/assoc.h" 93 #include "dcmtk/dcmdata/dcdatset.h" 94 #include "dcmtk/ofstd/ofglobal.h" 95 96 class DcmOutputFileStream; 97 98 // include this file in doxygen documentation 99 100 /** @file dimse.h 101 * @brief type definitions, constants, global variables and functions for the dcmnet/dimse module 102 */ 103 104 /** Global flag to enable/disable workaround code for some buggy Store SCUs 105 * in DIMSE_storeProvider(). If enabled, an illegal space-padding in the 106 * Affected SOP Instance UID field of the C-STORE-RQ message is retained 107 * in the corresponding C-STORE-RSP message. 108 * To enable the workaround, this flag must be set to OFTrue and 109 * dcmEnableAutomaticInputDataCorrection must be set to OFFalse 110 * (see declaration in dcmdata/include/dcobject.h). 111 */ 112 extern DCMTK_DCMNET_EXPORT OFGlobal<OFBool> dcmPeerRequiresExactUIDCopy; /* default OFFalse */ 113 114 /** global flag allowing to restrict the maximum size of outgoing 115 * P-DATA PDUs to a value less than the maximum supported by the 116 * remote application entity or this library. May be useful 117 * if there is an interaction between PDU size and other network 118 * layers, e. g. TLS, IP or below. 119 */ 120 extern DCMTK_DCMNET_EXPORT OFGlobal<Uint32> dcmMaxOutgoingPDUSize; /* default 2^32-1 */ 121 122 123 /* 124 * General Status Codes. 125 */ 126 #define STATUS_Success 0x0000 127 #define STATUS_Pending 0xff00 // deprecated, will be removed in a future version 128 129 /* 130 * Status Classes (see DICOM PS3.7 Annex C). 131 */ 132 #define DICOM_SUCCESS_STATUS(status) ((status) == 0x0000) 133 #define DICOM_FAILURE_STATUS(status) ((((status) & 0xf000) == 0xa000) || (((status) & 0xf000) == 0xc000) || ((((status) & 0xff00) == 0x0100) && ((status) != 0x0107) && ((status) != 0x0116)) || (((status) & 0xff00) == 0x0200)) 134 #define DICOM_WARNING_STATUS(status) ((((status) & 0xf000) == 0xb000) || ((status) == 0x0001) || ((status) == 0x0107) || ((status) == 0x0116)) 135 #define DICOM_CANCEL_STATUS(status) ((status) == 0xfe00) 136 #define DICOM_PENDING_STATUS(status) (((status) == 0xff00) || ((status) == 0xff01)) 137 #define DICOM_STANDARD_STATUS(status) (((status) == 0x0000) || ((status) == 0x0001) || (((status) & 0xff00) == 0x0100) || (((status) & 0xff00) == 0x0200) || (((status) & 0xf000) == 0xa000) || (((status) & 0xf000) == 0xb000) || (((status) & 0xf000) == 0xc000) || ((status) == 0xfe00) || ((status) == 0xff00) || ((status) == 0xff01)) 138 139 /* 140 * Service Class Specific Status Codes. 141 * NOTE: some codes are only significant in the high byte or high nibble (4 bits). 142 */ 143 144 /* General C-ECHO Codes */ 145 #define STATUS_ECHO_Success 0x0000 146 #define STATUS_ECHO_Refused_SOPClassNotSupported 0x0122 147 #define STATUS_ECHO_DuplicateInvocation 0x0210 148 #define STATUS_ECHO_UnrecognizedOperation 0x0211 149 #define STATUS_ECHO_MistypedArgument 0x0212 150 151 /* General C-STORE Codes */ 152 #define STATUS_STORE_Success 0x0000 153 #define STATUS_STORE_Refused_SOPClassNotSupported 0x0122 154 #define STATUS_STORE_Refused_NotAuthorized 0x0124 155 #define STATUS_STORE_InvalidSOPClass 0x0117 156 #define STATUS_STORE_DuplicateInvocation 0x0210 157 #define STATUS_STORE_UnrecognizedOperation 0x0211 158 #define STATUS_STORE_MistypedArgument 0x0212 159 /* Service Class Specific C-STORE Codes (Storage) */ 160 #define STATUS_STORE_Refused_OutOfResources /* high byte */ 0xa700 161 #define STATUS_STORE_Error_DataSetDoesNotMatchSOPClass /* high byte */ 0xa900 162 #define STATUS_STORE_Error_CannotUnderstand /* high nibble */ 0xc000 163 #define STATUS_STORE_Warning_CoercionOfDataElements 0xb000 164 #define STATUS_STORE_Warning_DataSetDoesNotMatchSOPClass 0xb007 165 #define STATUS_STORE_Warning_ElementsDiscarded 0xb006 166 167 /* General C-FIND Codes */ 168 #define STATUS_FIND_Success 0x0000 169 #define STATUS_FIND_Refused_SOPClassNotSupported 0x0122 170 #define STATUS_FIND_Cancel 0xfe00 171 /* Service Class Specific C-FIND Codes */ 172 /* (Query/Retrieve, Modality Worklist Management, Relevant Patient Information Query) */ 173 #define STATUS_FIND_Success_MatchingIsComplete 0x0000 174 #define STATUS_FIND_Refused_OutOfResources 0xa700 175 #define STATUS_FIND_Failed_IdentifierDoesNotMatchSOPClass 0xa900 // deprecated, will be removed in a future version 176 #define STATUS_FIND_Error_DataSetDoesNotMatchSOPClass 0xa900 177 #define STATUS_FIND_Failed_UnableToProcess /* high nibble */ 0xc000 178 #define STATUS_FIND_Failed_MoreThanOneMatchFound 0xc100 179 #define STATUS_FIND_Failed_UnableToSupportRequestedTemplate 0xc200 180 #define STATUS_FIND_Cancel_MatchingTerminatedDueToCancelRequest 0xfe00 181 #define STATUS_FIND_Pending_MatchesAreContinuing 0xff00 182 #define STATUS_FIND_Pending_WarningUnsupportedOptionalKeys 0xff01 183 184 /* General C-MOVE Codes */ 185 #define STATUS_MOVE_Success 0x0000 186 #define STATUS_MOVE_Refused_SOPClassNotSupported 0x0122 187 #define STATUS_MOVE_Refused_NotAuthorized 0x0124 188 #define STATUS_MOVE_Cancel 0xfe00 189 #define STATUS_MOVE_DuplicateInvocation 0x0210 190 #define STATUS_MOVE_UnrecognizedOperation 0x0211 191 #define STATUS_MOVE_MistypedArgument 0x0212 192 /* Service Class Specific C-MOVE Codes */ 193 /* (Query/Retrieve, Composite Instance Root Retrieve) */ 194 #define STATUS_MOVE_Success_SubOperationsCompleteNoFailures 0x0000 195 #define STATUS_MOVE_Refused_OutOfResourcesNumberOfMatches 0xa701 196 #define STATUS_MOVE_Refused_OutOfResourcesSubOperations 0xa702 197 #define STATUS_MOVE_Refused_MoveDestinationUnknown 0xa801 198 #define STATUS_MOVE_Failed_SOPClassNotSupported 0x0122 // deprecated, will be removed in a future version 199 #define STATUS_MOVE_Failed_MoveDestinationUnknown 0xa801 // deprecated, will be removed in a future version 200 #define STATUS_MOVE_Failed_IdentifierDoesNotMatchSOPClass 0xa900 // deprecated, will be removed in a future version 201 #define STATUS_MOVE_Error_DataSetDoesNotMatchSOPClass 0xa900 202 #define STATUS_MOVE_Failed_NoneOfTheFramesWereFoundInSOPInstance 0xaa00 203 #define STATUS_MOVE_Failed_UnableToCreateNewObjectForThisSOPClass 0xaa01 204 #define STATUS_MOVE_Failed_UnableToExtractFrames 0xaa02 205 #define STATUS_MOVE_Failed_TimeBasedRequestForNonTimeBasedSOPInstance 0xaa03 206 #define STATUS_MOVE_Failed_InvalidRequest 0xaa04 207 #define STATUS_MOVE_Failed_UnableToProcess /* high nibble */ 0xc000 208 #define STATUS_MOVE_Cancel_SubOperationsTerminatedDueToCancelIndication 0xfe00 209 #define STATUS_MOVE_Warning_SubOperationsCompleteOneOrMoreFailures 0xb000 210 #define STATUS_MOVE_Pending_SubOperationsAreContinuing 0xff00 211 212 /* General C-GET Codes */ 213 #define STATUS_GET_Success 0x0000 214 #define STATUS_GET_Refused_SOPClassNotSupported 0x0122 215 #define STATUS_GET_Cancel 0xfe00 216 #define STATUS_GET_DuplicateInvocation 0x0210 217 #define STATUS_GET_UnrecognizedOperation 0x0211 218 #define STATUS_GET_MistypedArgument 0x0212 219 /* Service Class Specific C-GET Codes */ 220 /* (Query/Retrieve, Composite Instance Root Retrieve and others) */ 221 #define STATUS_GET_Success_SubOperationsCompleteNoFailures 0x0000 222 #define STATUS_GET_Refused_OutOfResourcesNumberOfMatches 0xa701 223 #define STATUS_GET_Refused_OutOfResourcesSubOperations 0xa702 224 #define STATUS_GET_Failed_SOPClassNotSupported 0x0122 // deprecated, will be removed in a future version 225 #define STATUS_GET_Failed_IdentifierDoesNotMatchSOPClass 0xa900 // deprecated, will be removed in a future version 226 #define STATUS_GET_Error_DataSetDoesNotMatchSOPClass 0xa900 227 #define STATUS_GET_Failed_NoneOfTheFramesWereFoundInSOPInstance 0xaa00 228 #define STATUS_GET_Failed_UnableToCreateNewObjectForThisSOPClass 0xaa01 229 #define STATUS_GET_Failed_UnableToExtractFrames 0xaa02 230 #define STATUS_GET_Failed_TimeBasedRequestForNonTimeBasedSOPInstance 0xaa03 231 #define STATUS_GET_Failed_InvalidRequest 0xaa04 232 #define STATUS_GET_Failed_UnableToProcess /* high nibble */ 0xc000 233 #define STATUS_GET_Cancel_SubOperationsTerminatedDueToCancelIndication 0xfe00 234 #define STATUS_GET_Warning_SubOperationsCompleteOneOrMoreFailures 0xb000 235 #define STATUS_GET_Pending_SubOperationsAreContinuing 0xff00 236 237 /* General DIMSE-N Codes */ 238 #define STATUS_N_Success 0x0000 239 #define STATUS_N_Refused_NotAuthorized 0x0124 240 #define STATUS_N_Cancel 0xfe00 241 #define STATUS_N_AttributeListError 0x0107 242 #define STATUS_N_SOPClassNotSupported 0x0122 243 #define STATUS_N_ClassInstanceConflict 0x0119 244 #define STATUS_N_DuplicateSOPInstance 0x0111 245 #define STATUS_N_DuplicateInvocation 0x0210 246 #define STATUS_N_InvalidArgumentValue 0x0115 247 #define STATUS_N_InvalidAttributeValue 0x0106 248 #define STATUS_N_AttributeValueOutOfRange 0x0116 249 #define STATUS_N_InvalidObjectInstance 0x0117 // deprecated, will be removed in a future version 250 #define STATUS_N_InvalidSOPInstance 0x0117 251 #define STATUS_N_MissingAttribute 0x0120 252 #define STATUS_N_MissingAttributeValue 0x0121 253 #define STATUS_N_MistypedArgument 0x0212 254 #define STATUS_N_NoSuchAction 0x0123 255 #define STATUS_N_NoSuchArgument 0x0114 256 #define STATUS_N_NoSuchAttribute 0x0105 257 #define STATUS_N_NoSuchEventType 0x0113 258 #define STATUS_N_NoSuchObjectInstance 0x0112 // deprecated, will be removed in a future version 259 #define STATUS_N_NoSuchSOPInstance 0x0112 260 #define STATUS_N_NoSuchSOPClass 0x0118 261 #define STATUS_N_ProcessingFailure 0x0110 262 #define STATUS_N_ResourceLimitation 0x0213 263 #define STATUS_N_UnrecognizedOperation 0x0211 264 /* the following Codes are used by multiple Services */ 265 #define STATUS_N_Warning_RequestedOptionalAttributesNotSupported 0x0001 266 267 /* Service Class Specific DIMSE-N Codes */ 268 /* (Print Management) */ 269 #define STATUS_N_PRINT_BFS_Warn_MemoryAllocation 0xb600 270 #define STATUS_N_PRINT_BFS_Warn_NoSessionPrinting 0xb601 271 #define STATUS_N_PRINT_BFS_Warn_EmptyPage 0xb602 272 #define STATUS_N_PRINT_BFB_Warn_EmptyPage 0xb603 273 #define STATUS_N_PRINT_BFS_BFB_IB_Warn_ImageDemagnified 0xb604 274 #define STATUS_N_PRINT_BFS_BFB_IB_Warn_ImageCropped 0xb609 275 #define STATUS_N_PRINT_BFS_BFB_IB_Warn_ImageDecimated 0xb60a 276 #define STATUS_N_PRINT_BFS_Fail_NoFilmBox 0xc600 277 #define STATUS_N_PRINT_BFS_Fail_PrintQueueFull 0xc601 278 #define STATUS_N_PRINT_BFB_Fail_PrintQueueFull 0xc602 279 #define STATUS_N_PRINT_BFS_BFB_Fail_ImageSize 0xc603 280 #define STATUS_N_PRINT_BFS_BFB_Fail_PositionCollision 0xc604 // retired, see DICOM PS3.4 281 #define STATUS_N_PRINT_BFS_BFB_Fail_CombinedImageSize 0xc613 282 #define STATUS_N_PRINT_IB_Warn_MinMaxDensity 0xb605 283 #define STATUS_N_PRINT_IB_Fail_InsufficientMemory 0xc605 284 #define STATUS_N_PRINT_IB_Fail_MoreThanOneVOILUT 0xc606 285 /* (Modality Performed Procedure Step Retrieve) */ 286 #define STATUS_N_MPPS_Warning_RequestedOptionalAttributesNotSupported 0x0001 287 /* (Application Event Logging) */ 288 #define STATUS_N_LOG_Failure_ProceduralLoggingNotAvailable 0xc101 289 #define STATUS_N_LOG_Failure_EventInformationDoesNotMatchTemplate 0xc102 290 #define STATUS_N_LOG_Failure_CannotMatchEventToCurrentStudy 0xc103 291 #define STATUS_N_LOG_Failure_IDsInconsistentInMatchingCurrentStudy 0xc104 292 #define STATUS_N_LOG_Warning_SynchronizationFrameOfReferenceDoesNotMatch 0xb101 293 #define STATUS_N_LOG_Warning_StudyInstanceUIDCoercion 0xb102 294 #define STATUS_N_LOG_Warning_IDsInconsistentInMatchingCurrentStudy 0xb104 295 /* (Media Creation Management) */ 296 #define STATUS_N_MEDIA_Failed_MediaCreationActionAlreadyReceived 0xa510 297 #define STATUS_N_MEDIA_Failed_MediaCreationRequestAlreadyCompleted 0xc201 298 #define STATUS_N_MEDIA_Failed_MediaCreationRequestAlreadyInProgress 0xc202 299 #define STATUS_N_MEDIA_Failed_CancellationDenied 0xc203 300 #define STATUS_N_MEDIA_Warning_RequestedOptionalAttributesNotSupported 0x0001 301 302 // --- TODO (DIMSE-N) --- 303 304 // the following Services use different DIMSE Status Code meanings for 305 // each SOP Class, including standard Codes such as 0x0000 (Success): 306 307 /* (Unified Procedure Step) */ 308 /* (RT Machine Verification) */ 309 310 311 /* 312 * Type Definitions. 313 */ 314 315 316 /* 317 * DIMSE Command Codes (Request and Response). 318 */ 319 typedef enum { /* DIC_US */ 320 DIMSE_NOTHING = 0x0000, /* none of the rest !! */ 321 DIMSE_C_STORE_RQ = 0x0001, /* also known as C_SEND_RQ */ 322 DIMSE_C_STORE_RSP = 0x8001, /* also known as C_SEND_RSP */ 323 DIMSE_C_GET_RQ = 0x0010, 324 DIMSE_C_GET_RSP = 0x8010, 325 DIMSE_C_FIND_RQ = 0x0020, 326 DIMSE_C_FIND_RSP = 0x8020, 327 DIMSE_C_MOVE_RQ = 0x0021, 328 DIMSE_C_MOVE_RSP = 0x8021, 329 DIMSE_C_ECHO_RQ = 0x0030, 330 DIMSE_C_ECHO_RSP = 0x8030, 331 DIMSE_C_CANCEL_RQ = 0x0fff, 332 /* there is no DIMSE_C_CANCEL_RSP */ 333 334 DIMSE_N_EVENT_REPORT_RQ = 0x0100, 335 DIMSE_N_EVENT_REPORT_RSP = 0x8100, 336 DIMSE_N_GET_RQ = 0x0110, 337 DIMSE_N_GET_RSP = 0x8110, 338 DIMSE_N_SET_RQ = 0x0120, 339 DIMSE_N_SET_RSP = 0x8120, 340 DIMSE_N_ACTION_RQ = 0x0130, 341 DIMSE_N_ACTION_RSP = 0x8130, 342 DIMSE_N_CREATE_RQ = 0x0140, 343 DIMSE_N_CREATE_RSP = 0x8140, 344 DIMSE_N_DELETE_RQ = 0x0150, 345 DIMSE_N_DELETE_RSP = 0x8150 346 } T_DIMSE_Command; 347 348 /* 349 * DIMSE Data Set Type Codes. 350 */ 351 352 typedef enum { /* DIC_US */ 353 DIMSE_DATASET_PRESENT = 0x0001, /* anything other than 0x0101 */ 354 DIMSE_DATASET_NULL = 0x0101 355 } T_DIMSE_DataSetType; 356 357 /* 358 * DIMSE Priority Codes. 359 */ 360 361 typedef enum { /* DIC_US */ 362 DIMSE_PRIORITY_LOW = 0x0002, 363 DIMSE_PRIORITY_MEDIUM = 0x0000, 364 DIMSE_PRIORITY_HIGH = 0x0001 365 } T_DIMSE_Priority; 366 367 /* 368 * DIMSE Blocking Modes (reading). 369 */ 370 371 typedef enum { 372 DIMSE_BLOCKING, 373 DIMSE_NONBLOCKING 374 } T_DIMSE_BlockingMode; 375 376 377 /* 378 * DIMSE Messages. 379 * 380 */ 381 382 /* C-STORE */ 383 384 struct DCMTK_DCMNET_EXPORT T_DIMSE_C_StoreRQ { 385 DIC_US MessageID; /* M */ 386 DIC_UI AffectedSOPClassUID; /* M */ 387 T_DIMSE_Priority Priority; /* M */ 388 T_DIMSE_DataSetType DataSetType; /* M */ 389 DIC_UI AffectedSOPInstanceUID; /* M */ 390 DIC_AE MoveOriginatorApplicationEntityTitle; /* U */ 391 DIC_US MoveOriginatorID; /* U */ 392 /* DataSet provided as argument to DIMSE functions */ /* M */ 393 unsigned int opts; /* which optional items are set */ 394 #define O_STORE_MOVEORIGINATORAETITLE 0x0001 395 #define O_STORE_MOVEORIGINATORID 0x0002 396 /* the following flag is set on incoming C-STORE requests if 397 * the SOP instance UID is (incorrectly) padded with a space 398 * character. Will only be detected if the dcmdata flag 399 * dcmEnableAutomaticInputDataCorrection is false. 400 */ 401 #define O_STORE_RQ_BLANK_PADDING 0x0008 402 }; 403 404 struct DCMTK_DCMNET_EXPORT T_DIMSE_C_StoreRSP { 405 DIC_US MessageIDBeingRespondedTo; /* M */ 406 DIC_UI AffectedSOPClassUID; /* U(=) */ 407 T_DIMSE_DataSetType DataSetType; /* M */ 408 DIC_US DimseStatus; /* M */ 409 DIC_UI AffectedSOPInstanceUID; /* U(=) */ 410 unsigned int opts; /* which optional items are set */ 411 #define O_STORE_AFFECTEDSOPCLASSUID 0x0001 412 #define O_STORE_AFFECTEDSOPINSTANCEUID 0x0002 413 /* peer requires an exact copy of the SOP instance UID 414 * as it was sent in the C-STORE-RQ, 415 * including any illegal trailing space padding. 416 */ 417 #define O_STORE_PEER_REQUIRES_EXACT_UID_COPY 0x0004 418 /* SOP instance UID in C-STORE-RQ was space padded. */ 419 #define O_STORE_RSP_BLANK_PADDING 0x0008 420 } ; 421 422 /* C-ECHO */ 423 424 struct DCMTK_DCMNET_EXPORT T_DIMSE_C_EchoRQ { 425 DIC_US MessageID; /* M */ 426 DIC_UI AffectedSOPClassUID; /* M */ 427 T_DIMSE_DataSetType DataSetType; /* M */ 428 } ; 429 430 struct DCMTK_DCMNET_EXPORT T_DIMSE_C_EchoRSP { 431 DIC_US MessageIDBeingRespondedTo; /* M */ 432 DIC_UI AffectedSOPClassUID; /* U(=) */ 433 T_DIMSE_DataSetType DataSetType; /* M */ 434 DIC_US DimseStatus; /* M */ 435 unsigned int opts; /* which optional items are set */ 436 #define O_ECHO_AFFECTEDSOPCLASSUID 0x0001 437 } ; 438 439 /* C-FIND */ 440 441 struct DCMTK_DCMNET_EXPORT T_DIMSE_C_FindRQ { 442 DIC_US MessageID; /* M */ 443 DIC_UI AffectedSOPClassUID; /* M */ 444 T_DIMSE_Priority Priority; /* M */ 445 T_DIMSE_DataSetType DataSetType; /* M */ 446 /* Identifier provided as argument to DIMSE functions *//* M */ 447 } ; 448 449 struct DCMTK_DCMNET_EXPORT T_DIMSE_C_FindRSP { 450 DIC_US MessageIDBeingRespondedTo; /* M */ 451 DIC_UI AffectedSOPClassUID; /* U(=) */ 452 T_DIMSE_DataSetType DataSetType; /* M */ 453 DIC_US DimseStatus; /* M */ 454 /* Identifier provided as argument to DIMSE functions *//* C */ 455 unsigned int opts; /* which optional items are set */ 456 #define O_FIND_AFFECTEDSOPCLASSUID 0x0001 457 } ; 458 459 /* C-GET */ 460 461 struct DCMTK_DCMNET_EXPORT T_DIMSE_C_GetRQ { 462 DIC_US MessageID; /* M */ 463 DIC_UI AffectedSOPClassUID; /* M */ 464 T_DIMSE_Priority Priority; /* M */ 465 T_DIMSE_DataSetType DataSetType; /* M */ 466 /* Identifier provided as argument to DIMSE functions *//* M */ 467 } ; 468 469 struct DCMTK_DCMNET_EXPORT T_DIMSE_C_GetRSP { 470 DIC_US MessageIDBeingRespondedTo; /* M */ 471 DIC_UI AffectedSOPClassUID; /* U(=) */ 472 T_DIMSE_DataSetType DataSetType; /* M */ 473 DIC_US DimseStatus; /* M */ 474 DIC_US NumberOfRemainingSubOperations; /* C */ 475 DIC_US NumberOfCompletedSubOperations; /* C */ 476 DIC_US NumberOfFailedSubOperations; /* C */ 477 DIC_US NumberOfWarningSubOperations; /* C */ 478 unsigned int opts; /* which optional items are set */ 479 #define O_GET_AFFECTEDSOPCLASSUID 0x0001 480 #define O_GET_NUMBEROFREMAININGSUBOPERATIONS 0x0002 481 #define O_GET_NUMBEROFCOMPLETEDSUBOPERATIONS 0x0004 482 #define O_GET_NUMBEROFFAILEDSUBOPERATIONS 0x0008 483 #define O_GET_NUMBEROFWARNINGSUBOPERATIONS 0x0010 484 } ; 485 486 /* C-MOVE */ 487 488 struct DCMTK_DCMNET_EXPORT T_DIMSE_C_MoveRQ { 489 DIC_US MessageID; /* M */ 490 DIC_UI AffectedSOPClassUID; /* M */ 491 T_DIMSE_Priority Priority; /* M */ 492 T_DIMSE_DataSetType DataSetType; /* M */ 493 DIC_AE MoveDestination; /* M */ 494 /* Identifier provided as argument to DIMSE functions *//* M */ 495 } ; 496 497 struct DCMTK_DCMNET_EXPORT T_DIMSE_C_MoveRSP { 498 DIC_US MessageIDBeingRespondedTo; /* M */ 499 DIC_UI AffectedSOPClassUID; /* U(=) */ 500 T_DIMSE_DataSetType DataSetType; /* M */ 501 DIC_US DimseStatus; /* M */ 502 DIC_US NumberOfRemainingSubOperations; /* C */ 503 DIC_US NumberOfCompletedSubOperations; /* C */ 504 DIC_US NumberOfFailedSubOperations; /* C */ 505 DIC_US NumberOfWarningSubOperations; /* C */ 506 unsigned int opts; /* which optional items are set */ 507 #define O_MOVE_AFFECTEDSOPCLASSUID 0x0001 508 #define O_MOVE_NUMBEROFREMAININGSUBOPERATIONS 0x0002 509 #define O_MOVE_NUMBEROFCOMPLETEDSUBOPERATIONS 0x0004 510 #define O_MOVE_NUMBEROFFAILEDSUBOPERATIONS 0x0008 511 #define O_MOVE_NUMBEROFWARNINGSUBOPERATIONS 0x0010 512 } ; 513 514 515 /* C-CANCEL */ 516 517 struct DCMTK_DCMNET_EXPORT T_DIMSE_C_CancelRQ { 518 DIC_US MessageIDBeingRespondedTo; /* M */ 519 T_DIMSE_DataSetType DataSetType; /* M */ 520 } ; 521 522 523 /* N-EVENT-REPORT */ 524 525 struct DCMTK_DCMNET_EXPORT T_DIMSE_N_EventReportRQ { 526 DIC_US MessageID; /* M */ 527 DIC_UI AffectedSOPClassUID; /* M */ 528 DIC_UI AffectedSOPInstanceUID; /* M */ 529 T_DIMSE_DataSetType DataSetType; /* M */ 530 DIC_US EventTypeID; /* M */ 531 /* EventInformation provided as argument to DIMSE functions *//* U */ 532 } ; 533 534 struct DCMTK_DCMNET_EXPORT T_DIMSE_N_EventReportRSP { 535 DIC_US MessageIDBeingRespondedTo; /* M */ 536 DIC_UI AffectedSOPClassUID; /* U(=) */ 537 DIC_US DimseStatus; /* M */ 538 DIC_UI AffectedSOPInstanceUID; /* U(=) */ 539 T_DIMSE_DataSetType DataSetType; /* M */ 540 DIC_US EventTypeID; /* C(=) */ 541 /* EventReply provided as argument to DIMSE functions *//* C */ 542 unsigned int opts; /* which optional items are set */ 543 #define O_NEVENTREPORT_AFFECTEDSOPCLASSUID 0x0001 544 #define O_NEVENTREPORT_AFFECTEDSOPINSTANCEUID 0x0002 545 #define O_NEVENTREPORT_EVENTTYPEID 0x0004 546 } ; 547 548 /* N-GET */ 549 550 struct DCMTK_DCMNET_EXPORT T_DIMSE_N_GetRQ { 551 DIC_US MessageID; /* M */ 552 DIC_UI RequestedSOPClassUID; /* M */ 553 DIC_UI RequestedSOPInstanceUID; /* M */ 554 T_DIMSE_DataSetType DataSetType; /* M */ 555 /* 556 * In the following array, the attributes to get should be coded 557 * in pairs along the array (e.g. {g,e,g,e,g,e,...}). The ListCount 558 * variable should contain the number of 'DIC_US' values in the 559 * array (not the number of pairs). 560 */ 561 int ListCount; 562 DIC_US *AttributeIdentifierList; /* U */ 563 } ; 564 565 struct DCMTK_DCMNET_EXPORT T_DIMSE_N_GetRSP { 566 DIC_US MessageIDBeingRespondedTo; /* M */ 567 DIC_UI AffectedSOPClassUID; /* U */ 568 DIC_US DimseStatus; /* M */ 569 DIC_UI AffectedSOPInstanceUID; /* U */ 570 T_DIMSE_DataSetType DataSetType; /* M */ 571 /* AttributeList provided as argument to DIMSE functions *//* C */ 572 unsigned int opts; /* which optional items are set */ 573 #define O_NGET_AFFECTEDSOPCLASSUID 0x0001 574 #define O_NGET_AFFECTEDSOPINSTANCEUID 0x0002 575 } ; 576 577 /* N-SET */ 578 579 struct DCMTK_DCMNET_EXPORT T_DIMSE_N_SetRQ { 580 DIC_US MessageID; /* M */ 581 DIC_UI RequestedSOPClassUID; /* M */ 582 DIC_UI RequestedSOPInstanceUID; /* M */ 583 T_DIMSE_DataSetType DataSetType; /* M */ 584 /* ModificationList provided as argument to DIMSE functions *//* M */ 585 } ; 586 587 struct DCMTK_DCMNET_EXPORT T_DIMSE_N_SetRSP { 588 DIC_US MessageIDBeingRespondedTo; /* M */ 589 DIC_UI AffectedSOPClassUID; /* U */ 590 DIC_US DimseStatus; /* M */ 591 DIC_UI AffectedSOPInstanceUID; /* U */ 592 T_DIMSE_DataSetType DataSetType; /* M */ 593 /* AttributeList provided as argument to DIMSE functions *//* U */ 594 unsigned int opts; /* which optional items are set */ 595 #define O_NSET_AFFECTEDSOPCLASSUID 0x0001 596 #define O_NSET_AFFECTEDSOPINSTANCEUID 0x0002 597 } ; 598 599 /* N-ACTION */ 600 601 struct DCMTK_DCMNET_EXPORT T_DIMSE_N_ActionRQ { 602 DIC_US MessageID; /* M */ 603 DIC_UI RequestedSOPClassUID; /* M */ 604 DIC_UI RequestedSOPInstanceUID; /* M */ 605 DIC_US ActionTypeID; /* M */ 606 T_DIMSE_DataSetType DataSetType; /* M */ 607 /* ActionInformation provided as argument to DIMSE functions *//* U */ 608 } ; 609 610 struct DCMTK_DCMNET_EXPORT T_DIMSE_N_ActionRSP { 611 DIC_US MessageIDBeingRespondedTo; /* M */ 612 DIC_UI AffectedSOPClassUID; /* U */ 613 DIC_US DimseStatus; /* M */ 614 DIC_UI AffectedSOPInstanceUID; /* U */ 615 DIC_US ActionTypeID; /* C(=) */ 616 T_DIMSE_DataSetType DataSetType; /* M */ 617 /* ActionReply provided as argument to DIMSE functions *//* C */ 618 unsigned int opts; /* which optional items are set */ 619 #define O_NACTION_AFFECTEDSOPCLASSUID 0x0001 620 #define O_NACTION_AFFECTEDSOPINSTANCEUID 0x0002 621 #define O_NACTION_ACTIONTYPEID 0x0004 622 } ; 623 624 /* N-CREATE */ 625 626 struct DCMTK_DCMNET_EXPORT T_DIMSE_N_CreateRQ { 627 DIC_US MessageID; /* M */ 628 DIC_UI AffectedSOPClassUID; /* M */ 629 DIC_UI AffectedSOPInstanceUID; /* U */ 630 T_DIMSE_DataSetType DataSetType; /* M */ 631 /* AttributeList provided as argument to DIMSE functions *//* M */ 632 unsigned int opts; /* which optional items are set */ 633 #define O_NCREATE_AFFECTEDSOPINSTANCEUID 0x0002 634 } ; 635 636 struct DCMTK_DCMNET_EXPORT T_DIMSE_N_CreateRSP { 637 DIC_US MessageIDBeingRespondedTo; /* M */ 638 DIC_UI AffectedSOPClassUID; /* U(=) */ 639 DIC_US DimseStatus; /* M */ 640 DIC_UI AffectedSOPInstanceUID; /* C */ 641 T_DIMSE_DataSetType DataSetType; /* M */ 642 /* AttributeList provided as argument to DIMSE functions *//* U */ 643 unsigned int opts; /* which optional items are set */ 644 #define O_NCREATE_AFFECTEDSOPCLASSUID 0x0001 645 #define O_NCREATE_AFFECTEDSOPINSTANCEUID 0x0002 646 } ; 647 648 /* N-DELETE */ 649 650 struct DCMTK_DCMNET_EXPORT T_DIMSE_N_DeleteRQ { 651 DIC_US MessageID; /* M */ 652 DIC_UI RequestedSOPClassUID; /* M */ 653 DIC_UI RequestedSOPInstanceUID; /* M */ 654 T_DIMSE_DataSetType DataSetType; /* M */ 655 } ; 656 657 struct DCMTK_DCMNET_EXPORT T_DIMSE_N_DeleteRSP { 658 DIC_US MessageIDBeingRespondedTo; /* M */ 659 DIC_UI AffectedSOPClassUID; /* U */ 660 DIC_US DimseStatus; /* M */ 661 DIC_UI AffectedSOPInstanceUID; /* U */ 662 T_DIMSE_DataSetType DataSetType; /* M */ 663 unsigned int opts; /* which optional items are set */ 664 #define O_NDELETE_AFFECTEDSOPCLASSUID 0x0001 665 #define O_NDELETE_AFFECTEDSOPINSTANCEUID 0x0002 666 } ; 667 668 669 670 /* 671 * Composite DIMSE Message 672 */ 673 674 struct DCMTK_DCMNET_EXPORT T_DIMSE_Message { 675 T_DIMSE_Command CommandField; /* M */ 676 677 union { 678 /* requests */ 679 T_DIMSE_C_StoreRQ CStoreRQ; 680 T_DIMSE_C_EchoRQ CEchoRQ; 681 T_DIMSE_C_FindRQ CFindRQ; 682 T_DIMSE_C_GetRQ CGetRQ; 683 T_DIMSE_C_MoveRQ CMoveRQ; 684 T_DIMSE_C_CancelRQ CCancelRQ; 685 T_DIMSE_N_EventReportRQ NEventReportRQ; 686 T_DIMSE_N_GetRQ NGetRQ; 687 T_DIMSE_N_SetRQ NSetRQ; 688 T_DIMSE_N_ActionRQ NActionRQ; 689 T_DIMSE_N_CreateRQ NCreateRQ; 690 T_DIMSE_N_DeleteRQ NDeleteRQ; 691 692 /* responses */ 693 T_DIMSE_C_StoreRSP CStoreRSP; 694 T_DIMSE_C_EchoRSP CEchoRSP; 695 T_DIMSE_C_FindRSP CFindRSP; 696 T_DIMSE_C_GetRSP CGetRSP; 697 T_DIMSE_C_MoveRSP CMoveRSP; 698 T_DIMSE_N_EventReportRSP NEventReportRSP; 699 T_DIMSE_N_GetRSP NGetRSP; 700 T_DIMSE_N_SetRSP NSetRSP; 701 T_DIMSE_N_ActionRSP NActionRSP; 702 T_DIMSE_N_CreateRSP NCreateRSP; 703 T_DIMSE_N_DeleteRSP NDeleteRSP; 704 } msg; 705 706 }; 707 708 709 /* 710 * Global Variables 711 */ 712 713 /* 714 * Define global defaults for data encoding when sending out data-sets. 715 * These can be adjusted to allow variants to be tested. 716 */ 717 718 extern DCMTK_DCMNET_EXPORT E_GrpLenEncoding g_dimse_send_groupLength_encoding; /* default: EGL_recalcGL */ 719 extern DCMTK_DCMNET_EXPORT E_EncodingType g_dimse_send_sequenceType_encoding; /* default: EET_ExplicitLength */ 720 721 /* 722 * If this global flag is set to OFTrue, all DIMSE messages sent or received 723 * are stored in files with the name 724 * "dimse-TTT-DDD-XXXX.dcm" or "dimse-TTT-DDD-XXXX-YY.dcm", where 725 * TTT is "cmd" for a command set, or "dat" for a data set 726 * DDD is "snd" for data sent, or "rcv" for data received 727 * XXXX is a counter, starting at 1 (global for all associations) 728 * YY is an additional counter used if multiple datasets follow a single command set 729 * The files are in implicit VR little endian encoding, without meta-header. 730 */ 731 732 extern DCMTK_DCMNET_EXPORT OFBool g_dimse_save_dimse_data; /* default: OFFalse */ 733 734 /* 735 * Public Function Prototypes 736 */ 737 738 739 /* 740 * High Level DIMSE Messaging. 741 */ 742 743 /* 744 * General Information. 745 * 746 * Many of the DIMSE routines take parameters for a blocking mode 747 * and a timeout. In all cases, these parameters are only used 748 * when receiving commands or data sets (reading). There are no blocking 749 * and timeout options for send operations. 750 * When receiving commands or data sets: 751 * If the parameter blockMode is DIMSE_BLOCKING, the DIMSE routine 752 * will wait until a response arrives before returning. 753 * If the parameter blockMode is DIMSE_NONBLOCKING then the DIMSE routine 754 * will wait at most timeout seconds for a response and if no response arrives 755 * will return DIMSE_NODATAAVAILABLE. In both cases waiting will be 756 * interrupted by association release, and abort messages, or network 757 * disruption. 758 */ 759 760 761 /* 762 * Verification Service Class 763 */ 764 765 DCMTK_DCMNET_EXPORT OFCondition 766 DIMSE_echoUser( 767 /* in */ 768 T_ASC_Association *assoc, DIC_US msgId, 769 /* blocking info for response */ 770 T_DIMSE_BlockingMode blockMode, int timeout, 771 /* out */ 772 DIC_US *status, 773 /* if a pointer to a DcmDataset instance is passed in this variable, 774 * then any status detail information from the C-ECHO-RSP message will 775 * be returned in this dataset. 776 */ 777 DcmDataset **statusDetail); 778 779 DCMTK_DCMNET_EXPORT OFCondition 780 DIMSE_sendEchoResponse(T_ASC_Association * assoc, 781 T_ASC_PresentationContextID presID, 782 const T_DIMSE_C_EchoRQ *request, DIC_US status, DcmDataset *statusDetail); 783 784 785 /* 786 * Storage Service Class 787 */ 788 789 typedef enum { 790 DIMSE_StoreBegin, /* before data set */ 791 DIMSE_StoreProgressing, /* during data set */ 792 DIMSE_StoreEnd /* after data set */ 793 } T_DIMSE_StoreProgressState; 794 795 struct DCMTK_DCMNET_EXPORT T_DIMSE_StoreProgress { /* progress structure for store callback routines */ 796 T_DIMSE_StoreProgressState state; /* current state */ 797 long callbackCount; /* callback execution count */ 798 long progressBytes; /* sent/received so far */ 799 long totalBytes; /* total/estimated total to send/receive */ 800 } ; 801 802 803 typedef void (*DIMSE_StoreUserCallback)( 804 void *callbackData, 805 T_DIMSE_StoreProgress *progress, 806 T_DIMSE_C_StoreRQ *request /* original store request */ 807 ); 808 809 struct DCMTK_DCMNET_EXPORT T_DIMSE_DetectedCancelParameters { 810 OFBool cancelEncountered; 811 T_ASC_PresentationContextID presId; 812 T_DIMSE_C_CancelRQ req; 813 } ; 814 815 DCMTK_DCMNET_EXPORT OFCondition 816 DIMSE_storeUser( 817 /* in */ 818 T_ASC_Association *assoc, T_ASC_PresentationContextID presId, 819 T_DIMSE_C_StoreRQ *request, 820 const char *imageFileName, DcmDataset *imageDataSet, 821 DIMSE_StoreUserCallback callback, void *callbackData, 822 /* blocking info for response */ 823 T_DIMSE_BlockingMode blockMode, int timeout, 824 /* out */ 825 T_DIMSE_C_StoreRSP *response, 826 /* if a pointer to a DcmDataset instance is passed in this variable, 827 * then any status detail information from the C-STORE-RSP message will 828 * be returned in this dataset. 829 */ 830 DcmDataset **statusDetail, 831 T_DIMSE_DetectedCancelParameters *checkForCancelParams = NULL, 832 /* in */ 833 long imageFileTotalBytes=0); 834 835 typedef void (*DIMSE_StoreProviderCallback)( 836 /* in */ 837 void *callbackData, 838 T_DIMSE_StoreProgress *progress, /* progress state */ 839 T_DIMSE_C_StoreRQ *request, /* original store request */ 840 char *imageFileName, DcmDataset **imageDataSet, /* being received into */ 841 /* in/out */ 842 T_DIMSE_C_StoreRSP *response, /* final store response */ 843 /* out. The callback can assign a pointer to a dataset here and insert 844 * status detail attributes which will be added to the C-STORE-RSP message. 845 * The ownership of the DcmDataset instance is not transferred, and it is 846 * the responsibility of the library user to delete the instance after 847 * the call to DIMSE_storeProvider() has completed. 848 */ 849 DcmDataset **statusDetail); 850 851 DCMTK_DCMNET_EXPORT OFCondition 852 DIMSE_storeProvider(/* in */ 853 T_ASC_Association *assoc, 854 T_ASC_PresentationContextID presIdCmd, 855 T_DIMSE_C_StoreRQ *request, 856 const char* imageFileName, int writeMetaheader, 857 DcmDataset **imageDataSet, 858 DIMSE_StoreProviderCallback callback, void *callbackData, 859 /* blocking info for data set */ 860 T_DIMSE_BlockingMode blockMode, int timeout); 861 862 DCMTK_DCMNET_EXPORT OFCondition 863 DIMSE_sendStoreResponse(T_ASC_Association * assoc, 864 T_ASC_PresentationContextID presID, 865 const T_DIMSE_C_StoreRQ *request, /* send response to this request */ 866 T_DIMSE_C_StoreRSP *response, /* response structure */ 867 DcmDataset *statusDetail); 868 869 /* 870 * Query/Retrieve Service Class (FIND) 871 */ 872 873 874 typedef void (*DIMSE_FindUserCallback)( 875 /* in */ 876 void *callbackData, 877 T_DIMSE_C_FindRQ *request, /* original find request */ 878 int responseCount, /* number of responses so far*/ 879 T_DIMSE_C_FindRSP *response, /* pending response received */ 880 DcmDataset *responseIdentifiers /* pending response identifiers */ 881 ); 882 883 DCMTK_DCMNET_EXPORT OFCondition 884 DIMSE_findUser( 885 /* in */ 886 T_ASC_Association *assoc, 887 T_ASC_PresentationContextID presID, 888 T_DIMSE_C_FindRQ *request, DcmDataset *requestIdentifiers, 889 int &responseCount, 890 DIMSE_FindUserCallback callback, void *callbackData, 891 /* blocking info for response */ 892 T_DIMSE_BlockingMode blockMode, int timeout, 893 /* out */ 894 T_DIMSE_C_FindRSP *response, 895 /* if a pointer to a DcmDataset instance is passed in this variable, 896 * then any status detail information from the C-FIND-RSP message will 897 * be returned in this dataset. 898 */ 899 DcmDataset **statusDetail); 900 901 typedef void (*DIMSE_FindProviderCallback)( 902 /* in */ 903 void *callbackData, 904 OFBool cancelled, T_DIMSE_C_FindRQ *request, 905 DcmDataset *requestIdentifiers, int responseCount, 906 /* out */ 907 T_DIMSE_C_FindRSP *response, 908 DcmDataset **responseIdentifiers, 909 /* out. The callback can assign a pointer to a dataset here and insert 910 * status detail attributes which will be added to the C-FIND-RSP message. 911 * The ownership of the DcmDataset instance is not transferred, and it is 912 * the responsibility of the library user to delete the instance after 913 * the call to DIMSE_storeProvider() has completed. 914 */ 915 DcmDataset **statusDetail); 916 917 DCMTK_DCMNET_EXPORT OFCondition 918 DIMSE_findProvider( 919 /* in */ 920 T_ASC_Association *assoc, 921 T_ASC_PresentationContextID presIdCmd, 922 T_DIMSE_C_FindRQ *request, 923 DIMSE_FindProviderCallback callback, void *callbackData, 924 /* blocking info for data set */ 925 T_DIMSE_BlockingMode blockMode, int timeout); 926 927 DCMTK_DCMNET_EXPORT OFCondition 928 DIMSE_sendFindResponse(T_ASC_Association * assoc, 929 T_ASC_PresentationContextID presID, 930 const T_DIMSE_C_FindRQ *request, 931 T_DIMSE_C_FindRSP *response, DcmDataset *responseIdentifiers, 932 DcmDataset *statusDetail); 933 934 /* 935 * Query/Retrieve Service Class (MOVE) 936 */ 937 938 typedef void (*DIMSE_MoveUserCallback)( 939 /* in */ 940 void *callbackData, 941 T_DIMSE_C_MoveRQ *request, 942 int responseCount, T_DIMSE_C_MoveRSP *response); 943 944 typedef void (*DIMSE_SubOpProviderCallback)(void *subOpCallbackData, 945 T_ASC_Network *net, T_ASC_Association **subOpAssoc); 946 947 DCMTK_DCMNET_EXPORT OFCondition 948 DIMSE_moveUser( 949 /* in */ 950 T_ASC_Association *assoc, 951 T_ASC_PresentationContextID presID, 952 T_DIMSE_C_MoveRQ *request, 953 DcmDataset *requestIdentifiers, 954 DIMSE_MoveUserCallback callback, void *callbackData, 955 /* blocking info for response */ 956 T_DIMSE_BlockingMode blockMode, int timeout, 957 /* sub-operation provider callback */ 958 T_ASC_Network *net, 959 DIMSE_SubOpProviderCallback subOpCallback, void *subOpCallbackData, 960 /* out */ 961 T_DIMSE_C_MoveRSP *response, 962 /* if a pointer to a DcmDataset instance is passed in this variable, 963 * then any status detail information from the C-MOVE-RSP message will 964 * be returned in this dataset. 965 */ 966 DcmDataset **statusDetail, 967 DcmDataset **responseIdentifers, 968 OFBool ignorePendingDatasets = OFFalse); 969 970 typedef void (*DIMSE_MoveProviderCallback)( 971 /* in */ 972 void *callbackData, 973 OFBool cancelled, T_DIMSE_C_MoveRQ *request, 974 DcmDataset *requestIdentifiers, int responseCount, 975 /* out */ 976 T_DIMSE_C_MoveRSP *response, 977 /* out. The callback can assign a pointer to a dataset here and insert 978 * status detail attributes which will be added to the C-MOVE-RSP message. 979 * The ownership of the DcmDataset instance is not transferred, and it is 980 * the responsibility of the library user to delete the instance after 981 * the call to DIMSE_storeProvider() has completed. 982 */ 983 DcmDataset **statusDetail, 984 DcmDataset **responseIdentifiers); 985 986 DCMTK_DCMNET_EXPORT OFCondition 987 DIMSE_moveProvider( 988 /* in */ 989 T_ASC_Association *assoc, 990 T_ASC_PresentationContextID presIdCmd, 991 T_DIMSE_C_MoveRQ *request, 992 DIMSE_MoveProviderCallback callback, void *callbackData, 993 /* blocking info for data set */ 994 T_DIMSE_BlockingMode blockMode, int timeout); 995 996 DCMTK_DCMNET_EXPORT OFCondition 997 DIMSE_sendMoveResponse(T_ASC_Association * assoc, 998 T_ASC_PresentationContextID presID, const T_DIMSE_C_MoveRQ *request, 999 T_DIMSE_C_MoveRSP *response, DcmDataset *rspIds, 1000 DcmDataset *statusDetail); 1001 1002 /* 1003 * Query/Retrieve Service Class (GET) 1004 */ 1005 1006 typedef void (*DIMSE_GetUserCallback)( 1007 /* in */ 1008 void *callbackData, 1009 T_DIMSE_C_GetRQ *request, 1010 int responseCount, T_DIMSE_C_GetRSP *response); 1011 1012 typedef void (*DIMSE_SubOpProviderCallback)(void *subOpCallbackData, 1013 T_ASC_Network *net, T_ASC_Association **subOpAssoc); 1014 1015 DCMTK_DCMNET_EXPORT OFCondition 1016 DIMSE_getUser( 1017 /* in */ 1018 T_ASC_Association *assoc, 1019 T_ASC_PresentationContextID presID, 1020 T_DIMSE_C_GetRQ *request, 1021 DcmDataset *requestIdentifiers, 1022 DIMSE_GetUserCallback callback, void *callbackData, 1023 /* blocking info for response */ 1024 T_DIMSE_BlockingMode blockMode, int timeout, 1025 /* sub-operation provider callback */ 1026 T_ASC_Network *net, 1027 DIMSE_SubOpProviderCallback subOpCallback, void *subOpCallbackData, 1028 /* out */ 1029 T_DIMSE_C_GetRSP *response, 1030 /* if a pointer to a DcmDataset instance is passed in this variable, 1031 * then any status detail information from the C-GET-RSP message will 1032 * be returned in this dataset. 1033 */ 1034 DcmDataset **statusDetail, 1035 DcmDataset **responseIdentifers); 1036 1037 typedef void (*DIMSE_GetProviderCallback)( 1038 /* in */ 1039 void *callbackData, 1040 OFBool cancelled, T_DIMSE_C_GetRQ *request, 1041 DcmDataset *requestIdentifiers, int responseCount, 1042 /* out */ 1043 T_DIMSE_C_GetRSP *response, 1044 /* out. The callback can assign a pointer to a dataset here and insert 1045 * status detail attributes which will be added to the C-GET-RSP message. 1046 * The ownership of the DcmDataset instance is not transferred, and it is 1047 * the responsibility of the library user to delete the instance after 1048 * the call to DIMSE_storeProvider() has completed. 1049 */ 1050 DcmDataset **statusDetail, 1051 DcmDataset **responseIdentifiers); 1052 1053 DCMTK_DCMNET_EXPORT OFCondition 1054 DIMSE_getProvider( 1055 /* in */ 1056 T_ASC_Association *assoc, 1057 T_ASC_PresentationContextID presIdCmd, 1058 T_DIMSE_C_GetRQ *request, 1059 DIMSE_GetProviderCallback callback, void *callbackData, 1060 /* blocking info for data set */ 1061 T_DIMSE_BlockingMode blockMode, int timeout); 1062 1063 DCMTK_DCMNET_EXPORT OFCondition 1064 DIMSE_sendGetResponse(T_ASC_Association * assoc, 1065 T_ASC_PresentationContextID presID, const T_DIMSE_C_GetRQ *request, 1066 T_DIMSE_C_GetRSP *response, DcmDataset *rspIds, 1067 DcmDataset *statusDetail); 1068 1069 /* 1070 * Query/Retrieve Service Class (CANCEL) 1071 */ 1072 1073 DCMTK_DCMNET_EXPORT OFCondition 1074 DIMSE_sendCancelRequest(T_ASC_Association * assoc, 1075 T_ASC_PresentationContextID presId, DIC_US msgId); 1076 1077 DCMTK_DCMNET_EXPORT OFCondition 1078 DIMSE_checkForCancelRQ(T_ASC_Association * assoc, 1079 T_ASC_PresentationContextID presId, DIC_US msgId); 1080 1081 1082 /**** 1083 * 1084 * Low Level DIMSE Messaging 1085 * With the exception of DIMSE_receiveCommand, 1086 * the following function are only intended for use if you 1087 * wish to implement an alternative interface to the 1088 * higher level routines provided above. 1089 * Service call providers will have to use DIMSE_receiveCommand 1090 * before calling the appropriate provider routine declared above. 1091 * 1092 */ 1093 1094 1095 typedef void (*DIMSE_ProgressCallback)(void *callbackContext, 1096 unsigned long byteCount); 1097 1098 /** send a DIMSE command and possibly also instance data from a file via network to another 1099 * DICOM application. 1100 * @param assoc The association (network connection to another DICOM application). 1101 * @param presId The ID of the presentation context which shall be used 1102 * @param msg Structure that represents a certain DIMSE command which shall be sent. 1103 * @param statusDetail Detailed information with regard to the status information which is captured 1104 * in the status element (0000,0900). Note that the value for element (0000,0900) 1105 * is contained in this variable. 1106 * @param dataFileName The name of the file that contains the instance data which shall be sent to 1107 * the other DICOM application, NULL; if there is none. 1108 * @param callback Pointer to a function which shall be called to indicate progress. 1109 * @param callbackContext pointer to opaque object passed to the callback 1110 * @param commandSet [out] If this parameter is not NULL 1111 * it will return a copy of the DIMSE command which is sent to the other 1112 * DICOM application. 1113 * @return EC_Normal if successful, an error code otherwise. 1114 */ 1115 DCMTK_DCMNET_EXPORT OFCondition 1116 DIMSE_sendMessageUsingFileData(T_ASC_Association *association, 1117 T_ASC_PresentationContextID presID, 1118 T_DIMSE_Message *msg, DcmDataset *statusDetail, 1119 const char* dataFileName, 1120 DIMSE_ProgressCallback callback, 1121 void *callbackContext, 1122 DcmDataset **commandSet=NULL); 1123 1124 1125 /** send a DIMSE command and possibly also instance data from a data object via network 1126 * to another DICOM application. 1127 * @param assoc The association (network connection to another DICOM application). 1128 * @param presId The ID of the presentation context which shall be used 1129 * @param msg Structure that represents a certain DIMSE command which shall be sent. 1130 * @param statusDetail Detailed information with regard to the status information which is captured 1131 * in the status element (0000,0900). Note that the value for element (0000,0900) 1132 * is contained in this variable. 1133 * @param dataObject The instance data which shall be sent to the other DICOM application, 1134 * NULL, if there is none 1135 * @param callback Pointer to a function which shall be called to indicate progress. 1136 * @param callbackContext pointer to opaque object passed to the callback 1137 * @param commandSet [out] If this parameter is not NULL 1138 * it will return a copy of the DIMSE command which is sent to the other 1139 * DICOM application. 1140 * @return EC_Normal if successful, an error code otherwise. 1141 */ 1142 DCMTK_DCMNET_EXPORT OFCondition 1143 DIMSE_sendMessageUsingMemoryData(T_ASC_Association *association, 1144 T_ASC_PresentationContextID presID, 1145 T_DIMSE_Message *msg, DcmDataset *statusDetail, 1146 DcmDataset *dataObject, 1147 DIMSE_ProgressCallback callback, 1148 void *callbackContext, 1149 DcmDataset **commandSet=NULL); 1150 1151 /** receive a DIMSE command via network from another DICOM application. 1152 * @param assoc The association (network connection to another DICOM application). 1153 * @param blocking The blocking mode for reading data (either DIMSE_BLOCKING or DIMSE_NONBLOCKING) 1154 * @param timeout Timeout interval for receiving data. If the blocking mode is DIMSE_NONBLOCKING 1155 * and we are trying to read data from the incoming socket stream and no data has 1156 * been received after timeout seconds, an error will be reported. 1157 * @param presId [out] Contains in the end the ID of the presentation context which was specified in the DIMSE command. 1158 * @param msg [out] Contains in the end information which represents a certain DIMSE command which was received. 1159 * @param statusDetail [out] If a non-NULL value is passed this variable will in the end contain detailed 1160 * information with regard to the status information which is captured in the status 1161 * element (0000,0900). Note that the value for element (0000,0900) is not contained 1162 * in this return value but in msg. For details on the structure of this object, see 1163 * DICOM standard (year 2000) part 7, annex C) (or the corresponding section in a later 1164 * version of the standard.) 1165 * @param commandSet [out] If this parameter is not NULL 1166 * it will return a copy of the DIMSE command which was received from the other 1167 * DICOM application. 1168 * @return EC_Normal if successful, an error code otherwise. 1169 */ 1170 DCMTK_DCMNET_EXPORT OFCondition 1171 DIMSE_receiveCommand(T_ASC_Association *association, 1172 T_DIMSE_BlockingMode blocking, 1173 int timeout, 1174 T_ASC_PresentationContextID *presID, 1175 T_DIMSE_Message *msg, 1176 DcmDataset **statusDetail, 1177 DcmDataset **commandSet=NULL); 1178 1179 /** receive one data set (of instance data) via network from another DICOM application and store in memory 1180 * @param assoc The association (network connection to another DICOM application). 1181 * @param blocking The blocking mode for receiving data (either DIMSE_BLOCKING or DIMSE_NONBLOCKING) 1182 * @param timeout Timeout interval for receiving data (if the blocking mode is DIMSE_NONBLOCKING). 1183 * @param presID [out] Contains in the end the ID of the presentation context which was used in the PDVs 1184 * that were received on the network. If the PDVs show different presentation context 1185 * IDs, this function will return an error. 1186 * @param dataObject [out] Contains in the end the information which was received over the network. 1187 * Note that this function assumes that either imageFileName or imageDataSet does not equal NULL. 1188 * @param callback Pointer to a function which shall be called to indicate progress. 1189 * @param callbackData Pointer to data which shall be passed to the progress indicating function 1190 * @return EC_Normal if successful, an error code otherwise. 1191 */ 1192 DCMTK_DCMNET_EXPORT OFCondition 1193 DIMSE_receiveDataSetInMemory(T_ASC_Association *association, 1194 T_DIMSE_BlockingMode blocking, 1195 int timeout, 1196 T_ASC_PresentationContextID *presID, 1197 DcmDataset **dataObject, 1198 DIMSE_ProgressCallback callback, 1199 void *callbackContext); 1200 1201 /** create a DICOM file, populate the meta-header from the content of the given 1202 * C-STORE request, and return an ouput stream that can be used to store the 1203 * dataset associated with the C-STORE request message. This function is used 1204 * in conjunction with DIMSE_receiveDataSetInFile() to directly "stream" incoming 1205 * DICOM datasets to file without storing them in memory and without passing 1206 * them through the dcmdata parser. 1207 * @param filename filename of file to be created 1208 * @param request C-STORE request message from which the meta-header is populated 1209 * @param assoc association network association over which the C-STORE request 1210 * was received. Used to populate the aetitles in the metaheader. 1211 * @param presIdCmd presentation context ID of the C-STORE message, determines 1212 * the transfer syntax 1213 * @param writeMetaheader write file with/without metaheader 1214 * @param filestream pointer to output stream returned in this variable upon success. 1215 * @return EC_Normal if successful, an error code otherwise. 1216 */ 1217 DCMTK_DCMNET_EXPORT OFCondition 1218 DIMSE_createFilestream( 1219 /* in */ 1220 const OFFilename &filename, 1221 const T_DIMSE_C_StoreRQ *request, 1222 const T_ASC_Association *assoc, 1223 T_ASC_PresentationContextID presIdCmd, 1224 int writeMetaheader, 1225 /* out */ 1226 DcmOutputFileStream **filestream); 1227 1228 /** receive one data set (of instance data) via network from another DICOM application and store in file. 1229 * @param assoc The association (network connection to another DICOM application). 1230 * @param blocking The blocking mode for receiving data (either DIMSE_BLOCKING or DIMSE_NONBLOCKING) 1231 * @param timeout Timeout interval for receiving data (if the blocking mode is DIMSE_NONBLOCKING). 1232 * @param presID [out] Contains in the end the ID of the presentation context which was used in the PDVs 1233 * that were received on the network. If the PDVs show different presentation context 1234 * IDs, this function will return an error. 1235 * @param filestream output stream to which the incoming dataset is written 1236 * @param dataObject [out] Contains in the end the information which was received over the network. 1237 * Note that this function assumes that either imageFileName or imageDataSet does not equal NULL. 1238 * @param callback Pointer to a function which shall be called to indicate progress. 1239 * @param callbackData Pointer to data which shall be passed to the progress indicating function 1240 * @return EC_Normal if successful, an error code otherwise. 1241 */ 1242 DCMTK_DCMNET_EXPORT OFCondition 1243 DIMSE_receiveDataSetInFile(T_ASC_Association *assoc, 1244 T_DIMSE_BlockingMode blocking, int timeout, 1245 T_ASC_PresentationContextID *presID, 1246 DcmOutputStream *filestream, 1247 DIMSE_ProgressCallback callback, void *callbackData); 1248 1249 /** receive and discard one data set (of instance data) via network from another DICOM application. 1250 * @param assoc The association (network connection to another DICOM application). 1251 * @param blocking The blocking mode for receiving data (either DIMSE_BLOCKING or DIMSE_NONBLOCKING) 1252 * @param timeout Timeout interval for receiving data (if the blocking mode is DIMSE_NONBLOCKING). 1253 * @param bytesRead [out] number of bytes read 1254 * @param pdvCount [out] number of PDVs read 1255 * @return EC_Normal if successful, an error code otherwise. 1256 */ 1257 DCMTK_DCMNET_EXPORT OFCondition 1258 DIMSE_ignoreDataSet( T_ASC_Association * assoc, 1259 T_DIMSE_BlockingMode blocking, 1260 int timeout, 1261 DIC_UL * bytesRead, 1262 DIC_UL * pdvCount); 1263 1264 /* 1265 * Misc functions 1266 */ 1267 1268 DCMTK_DCMNET_EXPORT OFString DIMSE_warn_str(T_ASC_Association *assoc); 1269 1270 enum DIMSE_direction { 1271 DIMSE_INCOMING, 1272 DIMSE_OUTGOING 1273 }; 1274 1275 /* Debugging functions for printing contents of a command structure */ 1276 DCMTK_DCMNET_EXPORT OFString& DIMSE_dumpMessage(OFString &str, T_DIMSE_Message &msg, 1277 enum DIMSE_direction dir, DcmItem *dataset = NULL, T_ASC_PresentationContextID presID = 0); 1278 DCMTK_DCMNET_EXPORT OFString& DIMSE_dumpMessage(OFString &str, T_DIMSE_C_EchoRQ &msg, 1279 enum DIMSE_direction dir, DcmItem *dataset = NULL, T_ASC_PresentationContextID presID = 0); 1280 DCMTK_DCMNET_EXPORT OFString& DIMSE_dumpMessage(OFString &str, T_DIMSE_C_EchoRSP &msg, 1281 enum DIMSE_direction dir, DcmItem *dataset = NULL, T_ASC_PresentationContextID presID = 0); 1282 DCMTK_DCMNET_EXPORT OFString& DIMSE_dumpMessage(OFString &str, T_DIMSE_C_GetRQ &msg, 1283 enum DIMSE_direction dir, DcmItem *dataset = NULL, T_ASC_PresentationContextID presID = 0); 1284 DCMTK_DCMNET_EXPORT OFString& DIMSE_dumpMessage(OFString &str, T_DIMSE_C_GetRSP &msg, 1285 enum DIMSE_direction dir, DcmItem *dataset = NULL, T_ASC_PresentationContextID presID = 0); 1286 DCMTK_DCMNET_EXPORT OFString& DIMSE_dumpMessage(OFString &str, T_DIMSE_C_MoveRQ &msg, 1287 enum DIMSE_direction dir, DcmItem *dataset = NULL, T_ASC_PresentationContextID presID = 0); 1288 DCMTK_DCMNET_EXPORT OFString& DIMSE_dumpMessage(OFString &str, T_DIMSE_C_MoveRSP &msg, 1289 enum DIMSE_direction dir, DcmItem *dataset = NULL, T_ASC_PresentationContextID presID = 0); 1290 DCMTK_DCMNET_EXPORT OFString& DIMSE_dumpMessage(OFString &str, T_DIMSE_C_FindRQ &msg, 1291 enum DIMSE_direction dir, DcmItem *dataset = NULL, T_ASC_PresentationContextID presID = 0); 1292 DCMTK_DCMNET_EXPORT OFString& DIMSE_dumpMessage(OFString &str, T_DIMSE_C_FindRSP &msg, 1293 enum DIMSE_direction dir, DcmItem *dataset = NULL, T_ASC_PresentationContextID presID = 0); 1294 DCMTK_DCMNET_EXPORT OFString& DIMSE_dumpMessage(OFString &str, T_DIMSE_C_StoreRQ &msg, 1295 enum DIMSE_direction dir, DcmItem *dataset = NULL, T_ASC_PresentationContextID presID = 0); 1296 DCMTK_DCMNET_EXPORT OFString& DIMSE_dumpMessage(OFString &str, T_DIMSE_C_StoreRSP &msg, 1297 enum DIMSE_direction dir, DcmItem *dataset = NULL, T_ASC_PresentationContextID presID = 0); 1298 DCMTK_DCMNET_EXPORT OFString& DIMSE_dumpMessage(OFString &str, T_DIMSE_C_CancelRQ &msg, 1299 enum DIMSE_direction dir, DcmItem *dataset = NULL, T_ASC_PresentationContextID presID = 0); 1300 DCMTK_DCMNET_EXPORT OFString& DIMSE_dumpMessage(OFString &str, T_DIMSE_N_EventReportRQ &msg, 1301 enum DIMSE_direction dir, DcmItem *dataset = NULL, T_ASC_PresentationContextID presID = 0); 1302 DCMTK_DCMNET_EXPORT OFString& DIMSE_dumpMessage(OFString &str, T_DIMSE_N_EventReportRSP &msg, 1303 enum DIMSE_direction dir, DcmItem *dataset = NULL, T_ASC_PresentationContextID presID = 0); 1304 DCMTK_DCMNET_EXPORT OFString& DIMSE_dumpMessage(OFString &str, T_DIMSE_N_GetRQ &msg, 1305 enum DIMSE_direction dir, DcmItem *dataset = NULL, T_ASC_PresentationContextID presID = 0); 1306 DCMTK_DCMNET_EXPORT OFString& DIMSE_dumpMessage(OFString &str, T_DIMSE_N_GetRSP &msg, 1307 enum DIMSE_direction dir, DcmItem *dataset = NULL, T_ASC_PresentationContextID presID = 0); 1308 DCMTK_DCMNET_EXPORT OFString& DIMSE_dumpMessage(OFString &str, T_DIMSE_N_SetRQ &msg, 1309 enum DIMSE_direction dir, DcmItem *dataset = NULL, T_ASC_PresentationContextID presID = 0); 1310 DCMTK_DCMNET_EXPORT OFString& DIMSE_dumpMessage(OFString &str, T_DIMSE_N_SetRSP &msg, 1311 enum DIMSE_direction dir, DcmItem *dataset = NULL, T_ASC_PresentationContextID presID = 0); 1312 DCMTK_DCMNET_EXPORT OFString& DIMSE_dumpMessage(OFString &str, T_DIMSE_N_ActionRQ &msg, 1313 enum DIMSE_direction dir, DcmItem *dataset = NULL, T_ASC_PresentationContextID presID = 0); 1314 DCMTK_DCMNET_EXPORT OFString& DIMSE_dumpMessage(OFString &str, T_DIMSE_N_ActionRSP &msg, 1315 enum DIMSE_direction dir, DcmItem *dataset = NULL, T_ASC_PresentationContextID presID = 0); 1316 DCMTK_DCMNET_EXPORT OFString& DIMSE_dumpMessage(OFString &str, T_DIMSE_N_CreateRQ &msg, 1317 enum DIMSE_direction dir, DcmItem *dataset = NULL, T_ASC_PresentationContextID presID = 0); 1318 DCMTK_DCMNET_EXPORT OFString& DIMSE_dumpMessage(OFString &str, T_DIMSE_N_CreateRSP &msg, 1319 enum DIMSE_direction dir, DcmItem *dataset = NULL, T_ASC_PresentationContextID presID = 0); 1320 DCMTK_DCMNET_EXPORT OFString& DIMSE_dumpMessage(OFString &str, T_DIMSE_N_DeleteRQ &msg, 1321 enum DIMSE_direction dir, DcmItem *dataset = NULL, T_ASC_PresentationContextID presID = 0); 1322 DCMTK_DCMNET_EXPORT OFString& DIMSE_dumpMessage(OFString &str, T_DIMSE_N_DeleteRSP &msg, 1323 enum DIMSE_direction dir, DcmItem *dataset = NULL, T_ASC_PresentationContextID presID = 0); 1324 1325 1326 // Compatibility wrapper 1327 #define DIMSE_COMPAT_WRAP(func, type) \ 1328 static inline void func (FILE * f, type * msg) \ 1329 { \ 1330 OFString str; \ 1331 DIMSE_dumpMessage(str, *msg, DIMSE_INCOMING); \ 1332 fprintf(f, "%s\n", str.c_str()); \ 1333 } 1334 #define DIMSE_COMPAT_WRAP_R(func, type) \ 1335 DIMSE_COMPAT_WRAP(func ## RQ, type ## RQ) \ 1336 DIMSE_COMPAT_WRAP(func ## RSP, type ## RSP) 1337 1338 static inline void DIMSE_printMessage(STD_NAMESPACE ostream& ostream, T_DIMSE_Message &msg, DcmItem *dataset = NULL) 1339 { 1340 OFString str; 1341 ostream << DIMSE_dumpMessage(str, msg, DIMSE_INCOMING, dataset) << OFendl; 1342 } 1343 1344 DIMSE_COMPAT_WRAP(DIMSE_printCommand, T_DIMSE_Message) 1345 DIMSE_COMPAT_WRAP_R(DIMSE_printCEcho, T_DIMSE_C_Echo) 1346 DIMSE_COMPAT_WRAP_R(DIMSE_printCStore, T_DIMSE_C_Store) 1347 DIMSE_COMPAT_WRAP_R(DIMSE_printCGet, T_DIMSE_C_Get) 1348 DIMSE_COMPAT_WRAP_R(DIMSE_printCMove, T_DIMSE_C_Move) 1349 DIMSE_COMPAT_WRAP_R(DIMSE_printCFind, T_DIMSE_C_Find) 1350 DIMSE_COMPAT_WRAP(DIMSE_printCCancelRQ, T_DIMSE_C_EchoRQ) 1351 DIMSE_COMPAT_WRAP_R(DIMSE_printNEventReport, T_DIMSE_N_EventReport) 1352 DIMSE_COMPAT_WRAP_R(DIMSE_printNGet, T_DIMSE_N_Get) 1353 DIMSE_COMPAT_WRAP_R(DIMSE_printNSet, T_DIMSE_N_Set) 1354 DIMSE_COMPAT_WRAP_R(DIMSE_printNAction, T_DIMSE_N_Action) 1355 DIMSE_COMPAT_WRAP_R(DIMSE_printNCreate, T_DIMSE_N_Create) 1356 DIMSE_COMPAT_WRAP_R(DIMSE_printNDelete, T_DIMSE_N_Delete) 1357 1358 #undef DIMSE_COMPAT_WRAP 1359 #undef DIMSE_COMPAT_WRAP_R 1360 1361 #endif 1362