cond.h

00001 /*
00002  *
00003  *  Copyright (C) 1994-2005, OFFIS
00004  *
00005  *  This software and supporting documentation were developed by
00006  *
00007  *    Kuratorium OFFIS e.V.
00008  *    Healthcare Information and Communication Systems
00009  *    Escherweg 2
00010  *    D-26121 Oldenburg, Germany
00011  *
00012  *  THIS SOFTWARE IS MADE AVAILABLE,  AS IS,  AND OFFIS MAKES NO  WARRANTY
00013  *  REGARDING  THE  SOFTWARE,  ITS  PERFORMANCE,  ITS  MERCHANTABILITY  OR
00014  *  FITNESS FOR ANY PARTICULAR USE, FREEDOM FROM ANY COMPUTER DISEASES  OR
00015  *  ITS CONFORMITY TO ANY SPECIFICATION. THE ENTIRE RISK AS TO QUALITY AND
00016  *  PERFORMANCE OF THE SOFTWARE IS WITH THE USER.
00017  *
00018  *  Module:  dcmnet
00019  *
00020  *  Author:  Marco Eichelberg
00021  *
00022  *  Purpose: network conditions and helper class
00023  *
00024  *  Last Update:      $Author: meichel $
00025  *  Update Date:      $Date: 2005/12/08 16:02:07 $
00026  *  Source File:      $Source: /share/dicom/cvs-depot/dcmtk/dcmnet/include/dcmtk/dcmnet/cond.h,v $
00027  *  CVS/RCS Revision: $Revision: 1.10 $
00028  *  Status:           $State: Exp $
00029  *
00030  *  CVS/RCS Log at end of file
00031  *
00032  */
00033 
00034 #ifndef COND_H
00035 #define COND_H
00036 
00037 #include "dcmtk/config/osconfig.h"
00038 #include "dcmtk/ofstd/ofconsol.h"
00039 #include "dcmtk/dcmdata/dcerror.h"
00040 
00041 /* NOTES ON THE CONVERSION OF THE DCMNET MODULE FROM CONDITION TO OFCONDITION
00042  *
00043  * All functions in this module have been adapted to the new OFCondition
00044  * class which - unlike the CONDITION functions - does not create problems
00045  * in multi-threaded code. The following notes explain the major differences
00046  * and modifications needed in client code.
00047  *
00048  * - OFCondition is a class (CONDITION was just a typedef for long).  This
00049  *   means that switch statements on conditions are not possible anymore.
00050  *   Use if/else if/else constructs instead.
00051  *
00052  * - The condition ASC_RELEASECONFIRMED has been removed. 
00053  *   ASC_releaseAssociation() now returns EC_Normal upon successful completion.
00054  *
00055  * - No translation of error codes that are passed from the DUL module to the
00056  *   ASC or DIMSE module is performed anymore.  That means that error codes
00057  *   such as DUL_PEERABORTEDASSOCIATION or DUL_PEERREQUESTEDRELEASE are now
00058  *   passed back to client code instead of their "aliases" with ASC_ or
00059  *   DIMSE_ prefix.  Macros have been defined to catch most of these cases.
00060  *
00061  * - All normal status codes (DUL_NORMAL, DIMSE_NORMAL, ASC_NORMAL) have been
00062  *   mapped to EC_Normal. Macros have also been defined for these identifiers.
00063  *
00064  * - DUL_PEERREQUESTEDRELEASE is now an error code, i.e. unlike prior releases
00065  *   SUCCESS(DUL_PEERREQUESTEDRELEASE) is false.
00066  *
00067  * - In strict mode (compiled with OFCONDITION_STRICT_MODE), additional 
00068  *   restrictions apply.  OFCondition requires explicit copy construction
00069  *   (not default constructor), and all compatibility aliases/typedefs
00070  *   are disabled. SUCCESS(cond) is undefined, use cond.good() instead.
00071  *             
00072  */
00073 
00074 // condition code constants used in the association module
00075 const unsigned short ASCC_BADPRESENTATIONCONTEXTID       = 0x101;
00076 const unsigned short ASCC_BADPRESENTATIONCONTEXTPOSITION = 0x102;
00077 const unsigned short ASCC_CODINGERROR                    = 0x103;
00078 const unsigned short ASCC_DUPLICATEPRESENTATIONCONTEXTID = 0x104;
00079 const unsigned short ASCC_MISSINGTRANSFERSYNTAX          = 0x105;
00080 const unsigned short ASCC_NULLKEY                        = 0x106;
00081 const unsigned short ASCC_SHUTDOWNAPPLICATION            = 0x107;
00082 
00083 // condition constants used in the association module
00084 extern const OFCondition ASC_BADPRESENTATIONCONTEXTID;   /* Bad presentation context ID */
00085 extern const OFCondition ASC_MISSINGTRANSFERSYNTAX;      /* Missing transfer syntax */
00086 extern const OFCondition ASC_NULLKEY;                    /* Caller passed in a NULL key */
00087 extern const OFCondition ASC_SHUTDOWNAPPLICATION;        /* Peer requested application shutdown */
00088 
00089 // condition code constants used in the DIMSE module
00090 const unsigned short DIMSEC_BADCOMMANDTYPE               = 0x201;
00091 const unsigned short DIMSEC_BADDATA                      = 0x202;
00092 const unsigned short DIMSEC_BADMESSAGE                   = 0x203;
00093 const unsigned short DIMSEC_BUILDFAILED                  = 0x204;
00094 const unsigned short DIMSEC_ILLEGALASSOCIATION           = 0x205;
00095 const unsigned short DIMSEC_INVALIDPRESENTATIONCONTEXTID = 0x206;
00096 const unsigned short DIMSEC_NODATAAVAILABLE              = 0x207;
00097 const unsigned short DIMSEC_NOVALIDPRESENTATIONCONTEXTID = 0x208;
00098 const unsigned short DIMSEC_NULLKEY                      = 0x209;
00099 const unsigned short DIMSEC_OUTOFRESOURCES               = 0x20a;
00100 const unsigned short DIMSEC_PARSEFAILED                  = 0x20b;
00101 const unsigned short DIMSEC_READPDVFAILED                = 0x20c;
00102 const unsigned short DIMSEC_RECEIVEFAILED                = 0x20d;
00103 const unsigned short DIMSEC_SENDFAILED                   = 0x20e;
00104 const unsigned short DIMSEC_UNEXPECTEDPDVTYPE            = 0x20f;
00105 const unsigned short DIMSEC_UNEXPECTEDREQUEST            = 0x210;
00106 const unsigned short DIMSEC_UNEXPECTEDRESPONSE           = 0x211;
00107 const unsigned short DIMSEC_UNSUPPORTEDTRANSFERSYNTAX    = 0x212;
00108 const unsigned short DIMSEC_NODATADICT                   = 0x213;
00109 
00110 // condition constants used in the DIMSE module
00111 extern const OFCondition DIMSE_BADCOMMANDTYPE;           /* Bad command type */
00112 extern const OFCondition DIMSE_BADDATA;                  /* Inappropriate data for message (send) */
00113 extern const OFCondition DIMSE_BADMESSAGE;               /* Badly formed message (send) */
00114 extern const OFCondition DIMSE_ILLEGALASSOCIATION;       /* Caller passed in an illegal association */
00115 extern const OFCondition DIMSE_NODATAAVAILABLE;          /* no data (timout in non-blocking mode) */
00116 extern const OFCondition DIMSE_NOVALIDPRESENTATIONCONTEXTID;  /* no valid presentation context ID */
00117 extern const OFCondition DIMSE_NULLKEY;                  /* Caller passed in a NULL key */
00118 extern const OFCondition DIMSE_OUTOFRESOURCES;           /* out of resources */
00119 extern const OFCondition DIMSE_PARSEFAILED;              /* Failed to parse received message*/
00120 extern const OFCondition DIMSE_READPDVFAILED;            /* Read PDV failed */
00121 extern const OFCondition DIMSE_RECEIVEFAILED;            /* Failed to receive message */
00122 extern const OFCondition DIMSE_SENDFAILED;               /* Failed to send message */
00123 extern const OFCondition DIMSE_UNEXPECTEDPDVTYPE;        /* Unexpected PDV type */
00124 extern const OFCondition DIMSE_NODATADICT;               /* Data dictionary missing */
00125 
00126 // condition code constants used in the DUL module
00127 const unsigned short DULC_ASSOCIATIONREJECTED              = 0x301;
00128 const unsigned short DULC_CODINGERROR                      = 0x302;
00129 const unsigned short DULC_FSMERROR                         = 0x303;
00130 const unsigned short DULC_ILLEGALACCEPT                    = 0x304;
00131 const unsigned short DULC_ILLEGALKEY                       = 0x305;
00132 const unsigned short DULC_ILLEGALPARAMETER                 = 0x306;
00133 const unsigned short DULC_ILLEGALPDU                       = 0x307;
00134 const unsigned short DULC_ILLEGALPDULENGTH                 = 0x308;
00135 const unsigned short DULC_ILLEGALREJECTREASON              = 0x309;
00136 const unsigned short DULC_ILLEGALREJECTRESULT              = 0x30a;
00137 const unsigned short DULC_ILLEGALREQUEST                   = 0x30b;
00138 const unsigned short DULC_ILLEGALSERVICEPARAMETER          = 0x30c;
00139 const unsigned short DULC_INCORRECTBUFFERLENGTH            = 0x30d;
00140 const unsigned short DULC_INSUFFICIENTBUFFERLENGTH         = 0x30e;
00141 const unsigned short DULC_LISTERROR                        = 0x30f;
00142 const unsigned short DULC_NETWORKCLOSED                    = 0x310;
00143 // 0x311 was NETWORKINITIALIZED (Network already initialized) in previous releases
00144 const unsigned short DULC_NOASSOCIATIONREQUEST             = 0x312;
00145 const unsigned short DULC_NOPDVS                           = 0x313;
00146 const unsigned short DULC_NULLKEY                          = 0x314;
00147 const unsigned short DULC_PCTRANSLATIONFAILURE             = 0x315;
00148 const unsigned short DULC_PDATAPDUARRIVED                  = 0x316;
00149 const unsigned short DULC_PEERABORTEDASSOCIATION           = 0x317;
00150 const unsigned short DULC_PEERILLEGALXFERSYNTAXCOUNT       = 0x318;
00151 const unsigned short DULC_PEERREQUESTEDRELEASE             = 0x319;
00152 const unsigned short DULC_READTIMEOUT                      = 0x31a;
00153 const unsigned short DULC_REQUESTASSOCIATIONFAILED         = 0x31b;
00154 const unsigned short DULC_TCPINITERROR                     = 0x31c;
00155 const unsigned short DULC_TCPIOERROR                       = 0x31d;
00156 const unsigned short DULC_TLSERROR                         = 0x31e;
00157 const unsigned short DULC_UNEXPECTEDPDU                    = 0x31f;
00158 const unsigned short DULC_UNKNOWNHOST                      = 0x320;
00159 const unsigned short DULC_UNRECOGNIZEDPDUTYPE              = 0x321;
00160 const unsigned short DULC_UNSUPPORTEDPEERPROTOCOL          = 0x322;
00161 const unsigned short DULC_WRONGDATATYPE                    = 0x323;
00162 const unsigned short DULC_TCPWRAPPER                       = 0x324;
00163 const unsigned short DULC_FORKEDCHILD                      = 0x325;
00164 const unsigned short DULC_CANNOTFORK                       = 0x326;
00165 
00166 // condition constants used in the DUL module
00167 extern const OFCondition DUL_ASSOCIATIONREJECTED;       /* DUL Association Rejected */
00168 extern const OFCondition DUL_ILLEGALACCEPT;             /* Attempt to accept by requestor */
00169 extern const OFCondition DUL_ILLEGALKEY;                /* Illegal key */
00170 extern const OFCondition DUL_ILLEGALPDU;                /* DUL Illegal or ill-formed PDU */
00171 extern const OFCondition DUL_ILLEGALPDULENGTH;          /* DUL Illegal PDU Length */
00172 extern const OFCondition DUL_ILLEGALREQUEST;            /* Attempt to request by acceptor */
00173 extern const OFCondition DUL_INCORRECTBUFFERLENGTH;     /* DUL Incorrect buffer space allocated for data */
00174 extern const OFCondition DUL_INSUFFICIENTBUFFERLENGTH;  /* DUL Insufficient buffer space allocated for data */
00175 extern const OFCondition DUL_LISTERROR;                 /* DUL List error */
00176 extern const OFCondition DUL_NETWORKCLOSED;             /* DUL network closed */
00177 extern const OFCondition DUL_NOASSOCIATIONREQUEST;      /* No requests for associations for this server */
00178 extern const OFCondition DUL_NOPDVS;                    /* DUL No PDVs available in current buffer */
00179 extern const OFCondition DUL_NULLKEY;                   /* NULL key passed to routine */
00180 extern const OFCondition DUL_PCTRANSLATIONFAILURE;      /* DUL Presentation Context translation failure */
00181 extern const OFCondition DUL_PDATAPDUARRIVED;           /* DUL P-Data PDU arrived */
00182 extern const OFCondition DUL_PEERABORTEDASSOCIATION;    /* Peer aborted Association (or never connected) */
00183 extern const OFCondition DUL_PEERREQUESTEDRELEASE;      /* DUL Peer Requested Release */
00184 extern const OFCondition DUL_READTIMEOUT;               /* DUL network read timeout */
00185 extern const OFCondition DUL_REQUESTASSOCIATIONFAILED;  /* Failed to establish association */
00186 extern const OFCondition DUL_UNEXPECTEDPDU;             /* Received unexpected PDU */
00187 extern const OFCondition DUL_UNSUPPORTEDPEERPROTOCOL;   /* DUL Unsupported peer protocol */
00188 extern const OFCondition DUL_WRONGDATATYPE;             /* DUL Wrong Data Type Specified for Request */
00189 
00190 
00191 // This macro creates a condition with given code, severity and text.
00192 // Making this a macro instead of a function saves the creation of a temporary.
00193 #define makeDcmnetCondition(A, B, C) makeOFCondition(OFM_dcmnet, (A), (B), (C))
00194 
00195 // This macro creates a condition with given code, severity, text, and subcondition.
00196 // This method is intended as a replacement for COND_PushCondition().
00197 // Instead of maintaining a global condition stack (which is difficult
00198 // in multi-threaded applications), the error text of the sub-condition
00199 // is appended to the newly created condition.
00200 // Making this a macro instead of a function saves the creation of a temporary.
00201 #define makeDcmnetSubCondition(A, B, C, D) DimseCondition::push(OFM_dcmnet, (A), (B), (C), (D))
00202 
00203 
00208 class DimseCondition
00209 {
00210 public:
00211 
00219   static void dump(OFCondition cond, OFConsole& console = ofConsole);
00220 
00227   static OFCondition push(
00228     unsigned short aModule,
00229     unsigned short aCode,
00230     OFStatus aStatus,
00231     const char *aText,
00232     OFCondition subCondition);
00233 
00240   static OFCondition push(
00241     OFCondition newCondition,
00242     OFCondition subCondition);
00243 
00244 };
00245 
00246 
00247 // if not in strict mode, we define a couple of things
00248 // to improve compatibility with existing code.
00249 #ifndef OFCONDITION_STRICT_MODE
00250 
00251 // CONDITION is now identical to OFCondition
00252 typedef OFCondition CONDITION;
00253 
00254 // the success macro was defined in dicom.h in earlier releases
00255 #define SUCCESS(cond)                 ((cond).good())
00256 
00257 // aliases for condition codes
00258 #define ASC_ASSOCIATIONREJECTED       DUL_ASSOCIATIONREJECTED
00259 #define ASC_NORMAL                    EC_Normal
00260 #define ASC_PEERABORTEDASSOCIATION    DUL_PEERABORTEDASSOCIATION
00261 #define ASC_PEERREQUESTEDRELEASE      DUL_PEERREQUESTEDRELEASE
00262 #define ASC_READTIMEOUT               DUL_READTIMEOUT
00263 #define DIMSE_NORMAL                  EC_Normal
00264 #define DIMSE_PEERABORTEDASSOCIATION  DUL_PEERABORTEDASSOCIATION
00265 #define DIMSE_PEERREQUESTEDRELEASE    DUL_PEERREQUESTEDRELEASE
00266 
00267 #endif /* !OFCONDITION_STRICT_MODE */
00268 
00269 #endif
00270 
00271 /*
00272  * CVS Log
00273  * $Log: cond.h,v $
00274  * Revision 1.10  2005/12/08 16:02:07  meichel
00275  * Changed include path schema for all DCMTK header files
00276  *
00277  * Revision 1.9  2005/11/25 11:31:11  meichel
00278  * StoreSCP now supports multi-process mode both on Posix and Win32 platforms
00279  *   where a separate client process is forked for each incoming association.
00280  *
00281  * Revision 1.8  2003/06/10 13:37:36  meichel
00282  * Added support for TCP wrappers in DICOM network layer
00283  *
00284  * Revision 1.7  2002/12/10 11:00:57  meichel
00285  * Removed error code DUL_NETWORKINITIALIZED which is not used anymore
00286  *
00287  * Revision 1.6  2001/10/12 10:18:25  meichel
00288  * Replaced the CONDITION types, constants and functions in the dcmnet module
00289  *   by an OFCondition based implementation which eliminates the global condition
00290  *   stack.  This is a major change, caveat emptor!
00291  *
00292  *
00293  */


Generated on 20 Dec 2005 for OFFIS DCMTK Version 3.5.4 by Doxygen 1.4.5