93 #include "dcmtk/config/osconfig.h"
95 #include "dcmtk/dcmnet/dicom.h"
96 #include "dcmtk/dcmnet/lst.h"
97 #include "dcmtk/dcmnet/cond.h"
98 #include "dcmtk/dcmnet/dul.h"
99 #include "dcmtk/dcmnet/assoc.h"
100 #include "dcmtk/dcmdata/dcdatset.h"
101 #include "dcmtk/ofstd/ofglobal.h"
127 #define STATUS_Success 0x0000
128 #define STATUS_Pending 0xff00
130 #define DICOM_PENDING_STATUS(status) (((status)&0xff00) == 0xff00)
131 #define DICOM_WARNING_STATUS(status) (((status)&0xf000) == 0xb000)
139 #define STATUS_STORE_Refused_OutOfResources 0xa700
140 #define STATUS_STORE_Refused_SOPClassNotSupported 0xa800
141 #define STATUS_STORE_Error_DataSetDoesNotMatchSOPClass 0xa900
142 #define STATUS_STORE_Error_CannotUnderstand 0xc000
143 #define STATUS_STORE_Warning_CoersionOfDataElements 0xb000
144 #define STATUS_STORE_Warning_DataSetDoesNotMatchSOPClass 0xb007
145 #define STATUS_STORE_Warning_ElementsDiscarded 0xb006
148 #define STATUS_FIND_Refused_OutOfResources 0xa700
149 #define STATUS_FIND_Refused_SOPClassNotSupported 0xa800
150 #define STATUS_FIND_Failed_IdentifierDoesNotMatchSOPClass 0xa900
151 #define STATUS_FIND_Failed_UnableToProcess 0xc000
152 #define STATUS_FIND_Cancel_MatchingTerminatedDueToCancelRequest 0xfe00
153 #define STATUS_FIND_Pending_WarningUnsupportedOptionalKeys 0xff01
156 #define STATUS_MOVE_Refused_OutOfResourcesNumberOfMatches 0xa701
157 #define STATUS_MOVE_Refused_OutOfResourcesSubOperations 0xa702
158 #define STATUS_MOVE_Failed_SOPClassNotSupported 0xa800
159 #define STATUS_MOVE_Failed_MoveDestinationUnknown 0xa801
160 #define STATUS_MOVE_Failed_IdentifierDoesNotMatchSOPClass 0xa900
161 #define STATUS_MOVE_Failed_UnableToProcess 0xc000
162 #define STATUS_MOVE_Cancel_SubOperationsTerminatedDueToCancelIndication 0xfe00
163 #define STATUS_MOVE_Warning_SubOperationsCompleteOneOrMoreFailures 0xb000
166 #define STATUS_GET_Refused_OutOfResourcesNumberOfMatches 0xa701
167 #define STATUS_GET_Refused_OutOfResourcesSubOperations 0xa702
168 #define STATUS_GET_Failed_SOPClassNotSupported 0xa800
169 #define STATUS_GET_Failed_IdentifierDoesNotMatchSOPClass 0xa900
170 #define STATUS_GET_Failed_UnableToProcess 0xc000
171 #define STATUS_GET_Cancel_SubOperationsTerminatedDueToCancelIndication 0xfe00
172 #define STATUS_GET_Warning_SubOperationsCompleteOneOrMoreFailures 0xb000
175 #define STATUS_N_Cancel 0xFE00
176 #define STATUS_N_AttributeListError 0x0107
177 #define STATUS_N_SOPClassNotSupported 0x0122
178 #define STATUS_N_ClassInstanceConflict 0x0119
179 #define STATUS_N_DuplicateSOPInstance 0x0111
180 #define STATUS_N_DuplicateInvocation 0x0210
181 #define STATUS_N_InvalidArgumentValue 0x0115
182 #define STATUS_N_InvalidAttributeValue 0x0106
183 #define STATUS_N_InvalidObjectInstance 0x0117
184 #define STATUS_N_MissingAttribute 0x0120
185 #define STATUS_N_MissingAttributeValue 0x0121
186 #define STATUS_N_MistypedArgument 0x0212
187 #define STATUS_N_NoSuchArgument 0x0114
188 #define STATUS_N_NoSuchAttribute 0x0105
189 #define STATUS_N_NoSuchEventType 0x0113
190 #define STATUS_N_NoSuchObjectInstance 0x0112
191 #define STATUS_N_NoSuchSOPClass 0x0118
192 #define STATUS_N_ProcessingFailure 0x0110
193 #define STATUS_N_ResourceLimitation 0x0213
194 #define STATUS_N_UnrecognizedOperation 0x0211
195 #define STATUS_N_NoSuchAction 0x0123
198 #define STATUS_N_PRINT_BFS_Warn_MemoryAllocation 0xB600
199 #define STATUS_N_PRINT_BFS_Warn_NoSessionPrinting 0xB601
200 #define STATUS_N_PRINT_BFS_Warn_EmptyPage 0xB602
201 #define STATUS_N_PRINT_BFB_Warn_EmptyPage 0xB603
202 #define STATUS_N_PRINT_BFS_Fail_NoFilmBox 0xC600
203 #define STATUS_N_PRINT_BFS_Fail_PrintQueueFull 0xC601
204 #define STATUS_N_PRINT_BSB_Fail_PrintQueueFull 0xC602
205 #define STATUS_N_PRINT_BFS_BFB_Fail_ImageSize 0xC603
206 #define STATUS_N_PRINT_BFS_BFB_Fail_PositionCollision 0xC604
207 #define STATUS_N_PRINT_IB_Fail_InsufficientMemory 0xC605
208 #define STATUS_N_PRINT_IB_Fail_MoreThanOneVOILUT 0xC606
220 DIMSE_NOTHING = 0x0000,
221 DIMSE_C_STORE_RQ = 0x0001,
222 DIMSE_C_STORE_RSP = 0x8001,
223 DIMSE_C_GET_RQ = 0x0010,
224 DIMSE_C_GET_RSP = 0x8010,
225 DIMSE_C_FIND_RQ = 0x0020,
226 DIMSE_C_FIND_RSP = 0x8020,
227 DIMSE_C_MOVE_RQ = 0x0021,
228 DIMSE_C_MOVE_RSP = 0x8021,
229 DIMSE_C_ECHO_RQ = 0x0030,
230 DIMSE_C_ECHO_RSP = 0x8030,
231 DIMSE_C_CANCEL_RQ = 0x0fff,
234 DIMSE_N_EVENT_REPORT_RQ = 0x0100,
235 DIMSE_N_EVENT_REPORT_RSP = 0x8100,
236 DIMSE_N_GET_RQ = 0x0110,
237 DIMSE_N_GET_RSP = 0x8110,
238 DIMSE_N_SET_RQ = 0x0120,
239 DIMSE_N_SET_RSP = 0x8120,
240 DIMSE_N_ACTION_RQ = 0x0130,
241 DIMSE_N_ACTION_RSP = 0x8130,
242 DIMSE_N_CREATE_RQ = 0x0140,
243 DIMSE_N_CREATE_RSP = 0x8140,
244 DIMSE_N_DELETE_RQ = 0x0150,
245 DIMSE_N_DELETE_RSP = 0x8150
253 DIMSE_DATASET_PRESENT = 0x0001,
254 DIMSE_DATASET_NULL = 0x0101
255 } T_DIMSE_DataSetType;
262 DIMSE_PRIORITY_LOW = 0x0002,
263 DIMSE_PRIORITY_MEDIUM = 0x0000,
264 DIMSE_PRIORITY_HIGH = 0x0001
274 } T_DIMSE_BlockingMode;
286 DIC_UI AffectedSOPClassUID;
287 T_DIMSE_Priority Priority;
288 T_DIMSE_DataSetType DataSetType;
289 DIC_UI AffectedSOPInstanceUID;
290 DIC_AE MoveOriginatorApplicationEntityTitle;
291 DIC_US MoveOriginatorID;
294 #define O_STORE_MOVEORIGINATORAETITLE 0x0001
295 #define O_STORE_MOVEORIGINATORID 0x0002
301 #define O_STORE_RQ_BLANK_PADDING 0x0008
305 DIC_US MessageIDBeingRespondedTo;
306 DIC_UI AffectedSOPClassUID;
307 T_DIMSE_DataSetType DataSetType;
309 DIC_UI AffectedSOPInstanceUID;
311 #define O_STORE_AFFECTEDSOPCLASSUID 0x0001
312 #define O_STORE_AFFECTEDSOPINSTANCEUID 0x0002
317 #define O_STORE_PEER_REQUIRES_EXACT_UID_COPY 0x0004
319 #define O_STORE_RSP_BLANK_PADDING 0x0008
326 DIC_UI AffectedSOPClassUID;
327 T_DIMSE_DataSetType DataSetType;
331 DIC_US MessageIDBeingRespondedTo;
332 DIC_UI AffectedSOPClassUID;
333 T_DIMSE_DataSetType DataSetType;
336 #define O_ECHO_AFFECTEDSOPCLASSUID 0x0001
343 DIC_UI AffectedSOPClassUID;
344 T_DIMSE_Priority Priority;
345 T_DIMSE_DataSetType DataSetType;
350 DIC_US MessageIDBeingRespondedTo;
351 DIC_UI AffectedSOPClassUID;
352 T_DIMSE_DataSetType DataSetType;
356 #define O_FIND_AFFECTEDSOPCLASSUID 0x0001
363 DIC_UI AffectedSOPClassUID;
364 T_DIMSE_Priority Priority;
365 T_DIMSE_DataSetType DataSetType;
370 DIC_US MessageIDBeingRespondedTo;
371 DIC_UI AffectedSOPClassUID;
372 T_DIMSE_DataSetType DataSetType;
374 DIC_US NumberOfRemainingSubOperations;
375 DIC_US NumberOfCompletedSubOperations;
376 DIC_US NumberOfFailedSubOperations;
377 DIC_US NumberOfWarningSubOperations;
379 #define O_GET_AFFECTEDSOPCLASSUID 0x0001
380 #define O_GET_NUMBEROFREMAININGSUBOPERATIONS 0x0002
381 #define O_GET_NUMBEROFCOMPLETEDSUBOPERATIONS 0x0004
382 #define O_GET_NUMBEROFFAILEDSUBOPERATIONS 0x0008
383 #define O_GET_NUMBEROFWARNINGSUBOPERATIONS 0x0010
390 DIC_UI AffectedSOPClassUID;
391 T_DIMSE_Priority Priority;
392 T_DIMSE_DataSetType DataSetType;
393 DIC_AE MoveDestination;
398 DIC_US MessageIDBeingRespondedTo;
399 DIC_UI AffectedSOPClassUID;
400 T_DIMSE_DataSetType DataSetType;
402 DIC_US NumberOfRemainingSubOperations;
403 DIC_US NumberOfCompletedSubOperations;
404 DIC_US NumberOfFailedSubOperations;
405 DIC_US NumberOfWarningSubOperations;
407 #define O_MOVE_AFFECTEDSOPCLASSUID 0x0001
408 #define O_MOVE_NUMBEROFREMAININGSUBOPERATIONS 0x0002
409 #define O_MOVE_NUMBEROFCOMPLETEDSUBOPERATIONS 0x0004
410 #define O_MOVE_NUMBEROFFAILEDSUBOPERATIONS 0x0008
411 #define O_MOVE_NUMBEROFWARNINGSUBOPERATIONS 0x0010
418 DIC_US MessageIDBeingRespondedTo;
419 T_DIMSE_DataSetType DataSetType;
427 DIC_UI AffectedSOPClassUID;
428 DIC_UI AffectedSOPInstanceUID;
429 T_DIMSE_DataSetType DataSetType;
435 DIC_US MessageIDBeingRespondedTo;
436 DIC_UI AffectedSOPClassUID;
438 DIC_UI AffectedSOPInstanceUID;
439 T_DIMSE_DataSetType DataSetType;
443 #define O_NEVENTREPORT_AFFECTEDSOPCLASSUID 0x0001
444 #define O_NEVENTREPORT_AFFECTEDSOPINSTANCEUID 0x0002
445 #define O_NEVENTREPORT_EVENTTYPEID 0x0004
452 DIC_UI RequestedSOPClassUID;
453 DIC_UI RequestedSOPInstanceUID;
454 T_DIMSE_DataSetType DataSetType;
462 DIC_US *AttributeIdentifierList;
466 DIC_US MessageIDBeingRespondedTo;
467 DIC_UI AffectedSOPClassUID;
469 DIC_UI AffectedSOPInstanceUID;
470 T_DIMSE_DataSetType DataSetType;
473 #define O_NGET_AFFECTEDSOPCLASSUID 0x0001
474 #define O_NGET_AFFECTEDSOPINSTANCEUID 0x0002
481 DIC_UI RequestedSOPClassUID;
482 DIC_UI RequestedSOPInstanceUID;
483 T_DIMSE_DataSetType DataSetType;
488 DIC_US MessageIDBeingRespondedTo;
489 DIC_UI AffectedSOPClassUID;
491 DIC_UI AffectedSOPInstanceUID;
492 T_DIMSE_DataSetType DataSetType;
495 #define O_NSET_AFFECTEDSOPCLASSUID 0x0001
496 #define O_NSET_AFFECTEDSOPINSTANCEUID 0x0002
503 DIC_UI RequestedSOPClassUID;
504 DIC_UI RequestedSOPInstanceUID;
506 T_DIMSE_DataSetType DataSetType;
511 DIC_US MessageIDBeingRespondedTo;
512 DIC_UI AffectedSOPClassUID;
514 DIC_UI AffectedSOPInstanceUID;
516 T_DIMSE_DataSetType DataSetType;
519 #define O_NACTION_AFFECTEDSOPCLASSUID 0x0001
520 #define O_NACTION_AFFECTEDSOPINSTANCEUID 0x0002
521 #define O_NACTION_ACTIONTYPEID 0x0004
528 DIC_UI AffectedSOPClassUID;
529 DIC_UI AffectedSOPInstanceUID;
530 T_DIMSE_DataSetType DataSetType;
533 #define O_NCREATE_AFFECTEDSOPINSTANCEUID 0x0002
537 DIC_US MessageIDBeingRespondedTo;
538 DIC_UI AffectedSOPClassUID;
540 DIC_UI AffectedSOPInstanceUID;
541 T_DIMSE_DataSetType DataSetType;
544 #define O_NCREATE_AFFECTEDSOPCLASSUID 0x0001
545 #define O_NCREATE_AFFECTEDSOPINSTANCEUID 0x0002
552 DIC_UI RequestedSOPClassUID;
553 DIC_UI RequestedSOPInstanceUID;
554 T_DIMSE_DataSetType DataSetType;
558 DIC_US MessageIDBeingRespondedTo;
559 DIC_UI AffectedSOPClassUID;
561 DIC_UI AffectedSOPInstanceUID;
562 T_DIMSE_DataSetType DataSetType;
564 #define O_NDELETE_AFFECTEDSOPCLASSUID 0x0001
565 #define O_NDELETE_AFFECTEDSOPINSTANCEUID 0x0002
575 T_DIMSE_Command CommandField;
618 extern E_GrpLenEncoding g_dimse_send_groupLength_encoding;
619 extern E_EncodingType g_dimse_send_sequenceType_encoding;
632 extern OFBool g_dimse_save_dimse_data;
670 T_DIMSE_BlockingMode blockMode,
int timeout,
676 T_ASC_PresentationContextID presID,
686 DIMSE_StoreProgressing,
688 } T_DIMSE_StoreProgressState;
691 T_DIMSE_StoreProgressState state;
698 typedef void (*DIMSE_StoreUserCallback)(
705 OFBool cancelEncountered;
706 T_ASC_PresentationContextID presId;
715 const char *imageFileName,
DcmDataset *imageDataSet,
716 DIMSE_StoreUserCallback callback,
void *callbackData,
718 T_DIMSE_BlockingMode blockMode,
int timeout,
724 long imageFileTotalBytes=0);
726 typedef void (*DIMSE_StoreProviderCallback)(
731 char *imageFileName,
DcmDataset **imageDataSet,
740 T_ASC_PresentationContextID presIdCmd,
742 const char* imageFileName,
int writeMetaheader,
744 DIMSE_StoreProviderCallback callback,
void *callbackData,
746 T_DIMSE_BlockingMode blockMode,
int timeout);
750 T_ASC_PresentationContextID presID,
760 typedef void (*DIMSE_FindUserCallback)(
773 T_ASC_PresentationContextID presID,
775 DIMSE_FindUserCallback callback,
void *callbackData,
777 T_DIMSE_BlockingMode blockMode,
int timeout,
781 typedef void (*DIMSE_FindProviderCallback)(
785 DcmDataset *requestIdentifiers,
int responseCount,
795 T_ASC_PresentationContextID presIdCmd,
797 DIMSE_FindProviderCallback callback,
void *callbackData,
799 T_DIMSE_BlockingMode blockMode,
int timeout);
803 T_ASC_PresentationContextID presID,
812 typedef void (*DIMSE_MoveUserCallback)(
818 typedef void (*DIMSE_SubOpProviderCallback)(
void *subOpCallbackData,
825 T_ASC_PresentationContextID presID,
828 DIMSE_MoveUserCallback callback,
void *callbackData,
830 T_DIMSE_BlockingMode blockMode,
int timeout,
833 DIMSE_SubOpProviderCallback subOpCallback,
void *subOpCallbackData,
837 OFBool ignorePendingDatasets = OFFalse);
839 typedef void (*DIMSE_MoveProviderCallback)(
843 DcmDataset *requestIdentifiers,
int responseCount,
852 T_ASC_PresentationContextID presIdCmd,
854 DIMSE_MoveProviderCallback callback,
void *callbackData,
856 T_DIMSE_BlockingMode blockMode,
int timeout);
868 typedef void (*DIMSE_GetUserCallback)(
874 typedef void (*DIMSE_SubOpProviderCallback)(
void *subOpCallbackData,
881 T_ASC_PresentationContextID presID,
884 DIMSE_GetUserCallback callback,
void *callbackData,
886 T_DIMSE_BlockingMode blockMode,
int timeout,
889 DIMSE_SubOpProviderCallback subOpCallback,
void *subOpCallbackData,
894 typedef void (*DIMSE_GetProviderCallback)(
898 DcmDataset *requestIdentifiers,
int responseCount,
907 T_ASC_PresentationContextID presIdCmd,
909 DIMSE_GetProviderCallback callback,
void *callbackData,
911 T_DIMSE_BlockingMode blockMode,
int timeout);
925 T_ASC_PresentationContextID presId, DIC_US msgId);
929 T_ASC_PresentationContextID presId, DIC_US msgId);
945 typedef void (*DIMSE_ProgressCallback)(
void *callbackContext,
946 unsigned long byteCount);
951 T_ASC_PresentationContextID presID,
953 const char* dataFileName,
954 DIMSE_ProgressCallback callback,
955 void *callbackContext,
960 T_ASC_PresentationContextID presID,
963 DIMSE_ProgressCallback callback,
964 void *callbackContext,
969 T_DIMSE_BlockingMode blocking,
971 T_ASC_PresentationContextID *presID,
978 T_DIMSE_BlockingMode blocking,
980 T_ASC_PresentationContextID *presID,
982 DIMSE_ProgressCallback callback,
983 void *callbackContext);
986 DIMSE_createFilestream(
988 const char *filename,
991 T_ASC_PresentationContextID presIdCmd,
998 T_DIMSE_BlockingMode blocking,
int timeout,
999 T_ASC_PresentationContextID *presID,
1001 DIMSE_ProgressCallback callback,
void *callbackData);
1005 T_DIMSE_BlockingMode blocking,
1016 enum DIMSE_direction {
1023 enum DIMSE_direction dir,
DcmItem *dataset = NULL, T_ASC_PresentationContextID presID = 0);
1025 enum DIMSE_direction dir,
DcmItem *dataset = NULL, T_ASC_PresentationContextID presID = 0);
1027 enum DIMSE_direction dir,
DcmItem *dataset = NULL, T_ASC_PresentationContextID presID = 0);
1029 enum DIMSE_direction dir,
DcmItem *dataset = NULL, T_ASC_PresentationContextID presID = 0);
1031 enum DIMSE_direction dir,
DcmItem *dataset = NULL, T_ASC_PresentationContextID presID = 0);
1033 enum DIMSE_direction dir,
DcmItem *dataset = NULL, T_ASC_PresentationContextID presID = 0);
1035 enum DIMSE_direction dir,
DcmItem *dataset = NULL, T_ASC_PresentationContextID presID = 0);
1037 enum DIMSE_direction dir,
DcmItem *dataset = NULL, T_ASC_PresentationContextID presID = 0);
1039 enum DIMSE_direction dir,
DcmItem *dataset = NULL, T_ASC_PresentationContextID presID = 0);
1041 enum DIMSE_direction dir,
DcmItem *dataset = NULL, T_ASC_PresentationContextID presID = 0);
1043 enum DIMSE_direction dir,
DcmItem *dataset = NULL, T_ASC_PresentationContextID presID = 0);
1045 enum DIMSE_direction dir,
DcmItem *dataset = NULL, T_ASC_PresentationContextID presID = 0);
1047 enum DIMSE_direction dir,
DcmItem *dataset = NULL, T_ASC_PresentationContextID presID = 0);
1049 enum DIMSE_direction dir,
DcmItem *dataset = NULL, T_ASC_PresentationContextID presID = 0);
1051 enum DIMSE_direction dir,
DcmItem *dataset = NULL, T_ASC_PresentationContextID presID = 0);
1053 enum DIMSE_direction dir,
DcmItem *dataset = NULL, T_ASC_PresentationContextID presID = 0);
1055 enum DIMSE_direction dir,
DcmItem *dataset = NULL, T_ASC_PresentationContextID presID = 0);
1057 enum DIMSE_direction dir,
DcmItem *dataset = NULL, T_ASC_PresentationContextID presID = 0);
1059 enum DIMSE_direction dir,
DcmItem *dataset = NULL, T_ASC_PresentationContextID presID = 0);
1061 enum DIMSE_direction dir,
DcmItem *dataset = NULL, T_ASC_PresentationContextID presID = 0);
1063 enum DIMSE_direction dir,
DcmItem *dataset = NULL, T_ASC_PresentationContextID presID = 0);
1065 enum DIMSE_direction dir,
DcmItem *dataset = NULL, T_ASC_PresentationContextID presID = 0);
1067 enum DIMSE_direction dir,
DcmItem *dataset = NULL, T_ASC_PresentationContextID presID = 0);
1069 enum DIMSE_direction dir,
DcmItem *dataset = NULL, T_ASC_PresentationContextID presID = 0);
1073 #define DIMSE_COMPAT_WRAP(func, type) \
1074 static inline void func (FILE * f, type * msg) \
1077 DIMSE_dumpMessage(str, *msg, DIMSE_INCOMING); \
1078 fprintf(f, "%s\n", str.c_str()); \
1080 #define DIMSE_COMPAT_WRAP_R(func, type) \
1081 DIMSE_COMPAT_WRAP(func ## RQ, type ## RQ) \
1082 DIMSE_COMPAT_WRAP(func ## RSP, type ## RSP)
1084 static inline void DIMSE_printMessage(STD_NAMESPACE ostream& ostream,
T_DIMSE_Message &msg,
DcmItem *dataset = NULL)
1087 ostream << DIMSE_dumpMessage(str, msg, DIMSE_INCOMING, dataset) << OFendl;
1091 DIMSE_COMPAT_WRAP_R(DIMSE_printCEcho, T_DIMSE_C_Echo)
1092 DIMSE_COMPAT_WRAP_R(DIMSE_printCStore, T_DIMSE_C_Store)
1093 DIMSE_COMPAT_WRAP_R(DIMSE_printCGet, T_DIMSE_C_Get)
1094 DIMSE_COMPAT_WRAP_R(DIMSE_printCMove, T_DIMSE_C_Move)
1095 DIMSE_COMPAT_WRAP_R(DIMSE_printCFind, T_DIMSE_C_Find)
1097 DIMSE_COMPAT_WRAP_R(DIMSE_printNEventReport, T_DIMSE_N_EventReport)
1098 DIMSE_COMPAT_WRAP_R(DIMSE_printNGet, T_DIMSE_N_Get)
1099 DIMSE_COMPAT_WRAP_R(DIMSE_printNSet, T_DIMSE_N_Set)
1100 DIMSE_COMPAT_WRAP_R(DIMSE_printNAction, T_DIMSE_N_Action)
1101 DIMSE_COMPAT_WRAP_R(DIMSE_printNCreate, T_DIMSE_N_Create)
1102 DIMSE_COMPAT_WRAP_R(DIMSE_printNDelete, T_DIMSE_N_Delete)
1104 #undef DIMSE_COMPAT_WRAP
1105 #undef DIMSE_COMPAT_WRAP_R