00001 /* 00002 Copyright (C) 1993, 1994, RSNA and Washington University 00003 00004 The software and supporting documentation for the Radiological 00005 Society of North America (RSNA) 1993, 1994 Digital Imaging and 00006 Communications in Medicine (DICOM) Demonstration were developed 00007 at the 00008 Electronic Radiology Laboratory 00009 Mallinckrodt Institute of Radiology 00010 Washington University School of Medicine 00011 510 S. Kingshighway Blvd. 00012 St. Louis, MO 63110 00013 as part of the 1993, 1994 DICOM Central Test Node project for, and 00014 under contract with, the Radiological Society of North America. 00015 00016 THIS SOFTWARE IS MADE AVAILABLE, AS IS, AND NEITHER RSNA NOR 00017 WASHINGTON UNIVERSITY MAKE ANY WARRANTY ABOUT THE SOFTWARE, ITS 00018 PERFORMANCE, ITS MERCHANTABILITY OR FITNESS FOR ANY PARTICULAR 00019 USE, FREEDOM FROM ANY COMPUTER DISEASES OR ITS CONFORMITY TO ANY 00020 SPECIFICATION. THE ENTIRE RISK AS TO QUALITY AND PERFORMANCE OF 00021 THE SOFTWARE IS WITH THE USER. 00022 00023 Copyright of the software and supporting documentation is 00024 jointly owned by RSNA and Washington University, and free access 00025 is hereby granted as a license to use this software, copy this 00026 software and prepare derivative works based upon this software. 00027 However, any distribution of this software source code or 00028 supporting documentation or derivative works (source code and 00029 supporting documentation) must include the three paragraphs of 00030 the copyright notice. 00031 */ 00032 /* Copyright marker. Copyright will be inserted above. Do not remove */ 00033 /* 00034 ** @$=@$=@$= 00035 */ 00036 /* 00037 ** DICOM 93 00038 ** Electronic Radiology Laboratory 00039 ** Mallinckrodt Institute of Radiology 00040 ** Washington University School of Medicine 00041 ** 00042 ** Module Name(s): 00043 ** Author, Date: Stephen M. Moore, 19-May-93 00044 ** Intent: 00045 ** This header contains private typedefs for the DICOM Upper Layer 00046 ** (DUL) protocol package. This is to be used to compile the DUL 00047 ** package and is not intended to be seen by the applications programmer. 00048 ** Files at the package level should include this file to get the 00049 ** proper typedefs and include the public file "dulprotocol.h" to 00050 ** get the public definitions and function prototypes. I have omitted 00051 ** the public definitions and prototypes on purpose so that they 00052 ** exist in only one location. 00053 ** Last Update: $Author: meichel $, $Date: 2005/12/08 15:48:09 $ 00054 ** Source File: $RCSfile: dulstruc.h,v $ 00055 ** Revision: $Revision: 1.9 $ 00056 ** Status: $State: Exp $ 00057 */ 00058 00059 #include "dcmtk/config/osconfig.h" /* make sure OS specific configuration is included first */ 00060 #include "dcmtk/dcmnet/extneg.h" 00061 00062 class DcmTransportConnection; 00063 class DcmTransportLayer; 00064 00065 #define NETWORK_DISCONNECTED 2 00066 #define NETWORK_CONNECTED 3 00067 00068 typedef enum { 00069 DUL_ASSOC_WAITINGFORACK, 00070 DUL_ASSOC_ESTABLISHED, 00071 DUL_ASSOC_RELEASED, 00072 DUL_ASSOC_ABORTED, 00073 DUL_ASSOC_DROPPED 00074 } DUL_ASSOC_STATE; 00075 00076 #define ASSOCIATION_DISCONNECTED 2 00077 #define ASSOCIATION_ABORTED 4 00078 #define ASSOCIATION_RELEASED 5 00079 00080 typedef struct { 00081 char keyType[40]; 00082 int applicationFunction; 00083 int networkState; 00084 int protocolState; 00085 int timeout; 00086 unsigned long options; 00087 union { 00088 struct { 00089 int port; 00090 int listenSocket; 00091 DcmTransportLayer *tLayer; 00092 int tLayerOwned; 00093 } TCP; 00094 } networkSpecific; 00095 } PRIVATE_NETWORKKEY; 00096 00097 typedef struct { 00098 char keyType[40]; 00099 int applicationFunction; 00100 char remoteNode[64]; 00101 DUL_ASSOC_STATE associationState; 00102 int protocolState; 00103 int networkState; 00104 int timeout; 00105 time_t timerStart; 00106 unsigned long maxPDVRequestor; 00107 unsigned long maxPDVAcceptor; 00108 unsigned long maxPDV; 00109 unsigned long maxPDVInput; 00110 unsigned long receiveQp1; 00111 unsigned long receiveQp2; 00112 char calledAPTitle[20]; 00113 char callingAPTitle[20]; 00114 char applicationContextName[68]; 00115 char abstractSyntaxName[68]; 00116 void *receivePDUQueue; 00117 DUL_PRESENTATIONCONTEXTID presentationContextID; 00118 DcmTransportConnection *connection; 00119 DUL_PDVLIST pdvList; 00120 int inputPDU; 00121 unsigned char pduHead[6]; 00122 unsigned char nextPDUType; 00123 unsigned char nextPDUReserved; 00124 unsigned long nextPDULength; 00125 unsigned long compatibilityMode; 00126 int pdvCount; 00127 int pdvIndex; 00128 void *logHandle; 00129 int associatePDUFlag; 00130 void *associatePDU; 00131 unsigned long associatePDULength; 00132 DUL_PDV currentPDV; 00133 unsigned char *pdvPointer; 00134 unsigned long fragmentBufferLength; 00135 unsigned char *fragmentBuffer; 00136 DUL_ModeCallback *modeCallback; 00137 } PRIVATE_ASSOCIATIONKEY; 00138 00139 #define KEY_NETWORK "KEY NETWORK" 00140 #define KEY_ASSOCIATION "KEY ASSOCIATION" 00141 00142 #define AE_REQUESTOR "AE REQUESTOR" 00143 #define AE_ACCEPTOR "AE ACCEPTOR" 00144 #define AE_BOTH "AE BOTH" 00145 00146 #define NO_PDU 1 00147 #define PDU_HEAD 2 00148 #define PDU_DATA 2 00149 00150 /* Default timeout for waiting for PDUs. 100 seconds is high, 00151 ** but used for development so we have time to do things with the 00152 ** debugger. A lower value would be used in a production system. 00153 */ 00154 00155 #define DEFAULT_TIMEOUT 100 00156 00157 /* Private definitions */ 00158 00159 typedef struct dul_subitem { 00160 void *reserved[2]; 00161 unsigned char type; 00162 unsigned char rsv1; 00163 unsigned short length; 00164 char data[DICOM_UI_LENGTH + 1]; 00165 } DUL_SUBITEM; 00166 00167 typedef struct dul_maxlength { 00168 void *reserved[2]; 00169 unsigned char type; 00170 unsigned char rsv1; 00171 unsigned short length; 00172 unsigned long maxLength; 00173 } DUL_MAXLENGTH; 00174 00175 typedef struct { 00176 unsigned char type; 00177 unsigned char rsv1; 00178 unsigned short length; 00179 unsigned short maximumOperationsInvoked; 00180 unsigned short maximumOperationsProvided; 00181 } PRV_ASYNCOPERATIONS; 00182 00183 typedef struct { 00184 unsigned char type; 00185 unsigned char rsv1; 00186 unsigned short length; 00187 char implementationClassUID[DICOM_UI_LENGTH + 1]; 00188 } PRV_IMPLEMENTATIONCLASSUID; 00189 00190 typedef struct { 00191 unsigned char type; 00192 unsigned char rsv1; 00193 unsigned short length; 00194 char implementationVersionName[16 + 1]; 00195 } PRV_IMPLEMENTATIONVERSIONNAME; 00196 00197 typedef struct { 00198 void *reserved[2]; 00199 unsigned char type; 00200 unsigned char rsv1; 00201 unsigned short length; 00202 unsigned short UIDLength; 00203 char SOPClassUID[DICOM_UI_LENGTH + 1]; 00204 unsigned char SCURole; 00205 unsigned char SCPRole; 00206 } PRV_SCUSCPROLE; 00207 00208 typedef struct dul_presentationcontext { 00209 void *reserved[2]; 00210 unsigned char type; 00211 unsigned char rsv1; 00212 unsigned short length; 00213 unsigned char contextID; 00214 unsigned char rsv2; 00215 unsigned char result; 00216 unsigned char rsv3; 00217 00218 DUL_SUBITEM abstractSyntax; 00219 LST_HEAD *transferSyntaxList; 00220 } PRV_PRESENTATIONCONTEXTITEM; 00221 00222 typedef struct user_info { 00223 void *reserved[2]; 00224 unsigned char type; 00225 unsigned char rsv1; 00226 unsigned short length; 00227 DUL_MAXLENGTH maxLength; // 51H: maximum length 00228 PRV_ASYNCOPERATIONS asyncOperations; // 53H: async operations (not yet implemented!) 00229 DUL_SUBITEM implementationClassUID; // 52H: implementation class UID 00230 DUL_SUBITEM implementationVersionName; // 55H: implementation version name 00231 LST_HEAD *SCUSCPRoleList; // 54H: SCP/SCU role selection 00232 SOPClassExtendedNegotiationSubItemList *extNegList; // 56H: extended negotiation 00233 } DUL_USERINFO; 00234 00235 typedef struct dul_associatepdu { 00236 void *reserved[2]; 00237 unsigned char type; 00238 unsigned char rsv1; 00239 unsigned long length; 00240 unsigned short protocol; 00241 unsigned char rsv2[2]; 00242 char calledAPTitle[18]; 00243 char callingAPTitle[18]; 00244 unsigned char rsv3[32]; 00245 00246 DUL_SUBITEM applicationContext; 00247 LST_HEAD *presentationContextList; 00248 DUL_USERINFO userInfo; 00249 } PRV_ASSOCIATEPDU; 00250 00251 typedef struct dul_rejectreleaseabortpdu { 00252 void *reserved[2]; 00253 unsigned char type; 00254 unsigned char rsv1; 00255 unsigned long length; 00256 unsigned char rsv2; 00257 unsigned char result; 00258 unsigned char source; 00259 unsigned char reason; 00260 } DUL_REJECTRELEASEABORTPDU; 00261 00262 typedef struct dul_presentationdatavalue { 00263 void *reserved[2]; 00264 unsigned long length; 00265 unsigned char presentationContextID; 00266 unsigned char messageControlHeader; 00267 void *data; 00268 } DUL_PRESENTATIONDATAVALUE; 00269 00270 typedef struct dul_datapdu { 00271 void *reserved[2]; 00272 unsigned char type; 00273 unsigned char rsv1; 00274 unsigned long length; 00275 DUL_PRESENTATIONDATAVALUE presentationDataValue; 00276 } DUL_DATAPDU; 00277 00278 #define DUL_PROTOCOL (unsigned short) 0x01 00279 00280 #define DUL_TYPEAPPLICATIONCONTEXT (unsigned char)0x10 00281 #define DUL_TYPEPRESENTATIONCONTEXTRQ (unsigned char)0x20 00282 #define DUL_TYPEPRESENTATIONCONTEXTAC (unsigned char)0x21 00283 #define DUL_TYPEABSTRACTSYNTAX (unsigned char)0x30 00284 #define DUL_TYPETRANSFERSYNTAX (unsigned char)0x40 00285 #define DUL_TYPEUSERINFO (unsigned char)0x50 00286 #define DUL_TYPEMAXLENGTH (unsigned char)0x51 00287 #define DUL_TYPEIMPLEMENTATIONCLASSUID (unsigned char)0x52 00288 #define DUL_TYPEASYNCOPERATIONS (unsigned char)0x53 00289 #define DUL_TYPESCUSCPROLE (unsigned char)0x54 00290 #define DUL_TYPEIMPLEMENTATIONVERSIONNAME (unsigned char)0x55 00291 00292 #define COPY_LONG_BIG(A,B) { \ 00293 (B)[0] = (unsigned char)((A)>>24); \ 00294 (B)[1] = (unsigned char)((A)>>16) ; \ 00295 (B)[2] = (unsigned char)((A)>>8) ; \ 00296 (B)[3] = (unsigned char)(A) ; } 00297 #define COPY_SHORT_BIG(A,B) { \ 00298 (B)[0] = (unsigned char)((A)>>8); \ 00299 (B)[1] = (unsigned char)(A) ; } 00300 00301 #define EXTRACT_LONG_BIG(A,B) { \ 00302 (B) = (unsigned long)(A)[3] \ 00303 | (((unsigned long)(A)[2]) << 8) \ 00304 | (((unsigned long)(A)[1]) << 16) \ 00305 | (((unsigned long)(A)[0]) << 24); \ 00306 } 00307 00308 #define EXTRACT_SHORT_BIG(A,B) { (B) = (unsigned short)(A)[1] | (((unsigned short)(A)[0]) << 8); } 00309 00310 /* 00311 ** CVS Log 00312 ** $Log: dulstruc.h,v $ 00313 ** Revision 1.9 2005/12/08 15:48:09 meichel 00314 ** Updated Makefiles to correctly install header files 00315 ** 00316 ** Revision 1.8 2004/02/25 12:31:17 meichel 00317 ** Added global option flag for compatibility with very old DCMTK releases in the 00318 ** DICOM upper layer and ACSE code. Default is automatic handling, which should 00319 ** work in most cases. 00320 ** 00321 ** Revision 1.7 2002/11/26 15:37:03 meichel 00322 ** Changed DUL code to always send A-ASSOCIATE user information sub-items 00323 ** in ascending order. 00324 ** 00325 ** Revision 1.6 2001/10/12 10:18:41 meichel 00326 ** Replaced the CONDITION types, constants and functions in the dcmnet module 00327 ** by an OFCondition based implementation which eliminates the global condition 00328 ** stack. This is a major change, caveat emptor! 00329 ** 00330 ** Revision 1.5 2000/08/10 14:50:59 meichel 00331 ** Added initial OpenSSL support. 00332 ** 00333 ** Revision 1.4 2000/06/07 08:57:27 meichel 00334 ** dcmnet ACSE routines now allow to retrieve a binary copy of the A-ASSOCIATE 00335 ** RQ/AC/RJ PDUs, e.g. for logging purposes. 00336 ** 00337 ** Revision 1.3 1999/04/19 08:39:01 meichel 00338 ** Added experimental support for extended SOP class negotiation. 00339 ** 00340 ** Revision 1.2 1997/07/07 08:11:37 andreas 00341 ** - Changed macros EXTRACT_LONG_BIG and EXTRACT_SHORT_BIG to avoid 00342 ** compiler warnings on SUN-CC and Windows NT/95 00343 ** 00344 ** Revision 1.1.1.1 1996/03/26 18:38:46 hewett 00345 ** Initial Release. 00346 ** 00347 ** 00348 */