OFFIS DCMTK  Version 3.6.0
cond.h
1 /*
2  *
3  * Copyright (C) 1994-2010, OFFIS e.V.
4  * All rights reserved. See COPYRIGHT file for details.
5  *
6  * This software and supporting documentation were developed by
7  *
8  * OFFIS e.V.
9  * R&D Division Health
10  * Escherweg 2
11  * D-26121 Oldenburg, Germany
12  *
13  *
14  * Module: dcmnet
15  *
16  * Author: Marco Eichelberg
17  *
18  * Purpose: network conditions and helper class
19  *
20  * Last Update: $Author: joergr $
21  * Update Date: $Date: 2010-10-14 13:17:21 $
22  * CVS/RCS Revision: $Revision: 1.16 $
23  * Status: $State: Exp $
24  *
25  * CVS/RCS Log at end of file
26  *
27  */
28 
29 #ifndef COND_H
30 #define COND_H
31 
32 #include "dcmtk/config/osconfig.h"
33 #include "dcmtk/ofstd/ofconsol.h"
34 #include "dcmtk/dcmdata/dcerror.h"
35 
36 /* NOTES ON THE CONVERSION OF THE DCMNET MODULE FROM CONDITION TO OFCONDITION
37  *
38  * All functions in this module have been adapted to the new OFCondition
39  * class which - unlike the CONDITION functions - does not create problems
40  * in multi-threaded code. The following notes explain the major differences
41  * and modifications needed in client code.
42  *
43  * - OFCondition is a class (CONDITION was just a typedef for long). This
44  * means that switch statements on conditions are not possible anymore.
45  * Use if/else if/else constructs instead.
46  *
47  * - The condition ASC_RELEASECONFIRMED has been removed.
48  * ASC_releaseAssociation() now returns EC_Normal upon successful completion.
49  *
50  * - No translation of error codes that are passed from the DUL module to the
51  * ASC or DIMSE module is performed anymore. That means that error codes
52  * such as DUL_PEERABORTEDASSOCIATION or DUL_PEERREQUESTEDRELEASE are now
53  * passed back to client code instead of their "aliases" with ASC_ or
54  * DIMSE_ prefix. Macros have been defined to catch most of these cases.
55  *
56  * - All normal status codes (DUL_NORMAL, DIMSE_NORMAL, ASC_NORMAL) have been
57  * mapped to EC_Normal. Macros have also been defined for these identifiers.
58  *
59  * - DUL_PEERREQUESTEDRELEASE is now an error code, i.e. unlike prior releases
60  * SUCCESS(DUL_PEERREQUESTEDRELEASE) is false.
61  *
62  * - In strict mode (compiled with OFCONDITION_STRICT_MODE), additional
63  * restrictions apply. OFCondition requires explicit copy construction
64  * (not default constructor), and all compatibility aliases/typedefs
65  * are disabled. SUCCESS(cond) is undefined, use cond.good() instead.
66  *
67  */
68 
69 // condition code constants used in the association module
70 const unsigned short ASCC_BADPRESENTATIONCONTEXTID = 0x101;
71 const unsigned short ASCC_BADPRESENTATIONCONTEXTPOSITION = 0x102;
72 const unsigned short ASCC_CODINGERROR = 0x103;
73 const unsigned short ASCC_DUPLICATEPRESENTATIONCONTEXTID = 0x104;
74 const unsigned short ASCC_MISSINGTRANSFERSYNTAX = 0x105;
75 const unsigned short ASCC_NULLKEY = 0x106;
76 const unsigned short ASCC_SHUTDOWNAPPLICATION = 0x107;
77 const unsigned short ASCC_USERIDENTIFICATIONFAILED = 0x108;
78 const unsigned short ASCC_SCPSCUROLESELECTIONFAILED = 0x109;
79 
80 // condition constants used in the association module
81 extern const OFCondition ASC_BADPRESENTATIONCONTEXTID; /* Bad presentation context ID */
82 extern const OFCondition ASC_MISSINGTRANSFERSYNTAX; /* Missing transfer syntax */
83 extern const OFCondition ASC_NULLKEY; /* Caller passed in a NULL key */
84 extern const OFCondition ASC_SHUTDOWNAPPLICATION; /* Peer requested application shutdown */
85 extern const OFCondition ASC_USERIDENTIFICATIONFAILED; /* User Identity Negotiation failed */
86 extern const OFCondition ASC_SCPSCUROLESELECTIONFAILED; /* SCP/SCU role selection failed */
87 
88 // condition code constants used in the DIMSE module
89 const unsigned short DIMSEC_BADCOMMANDTYPE = 0x201;
90 const unsigned short DIMSEC_BADDATA = 0x202;
91 const unsigned short DIMSEC_BADMESSAGE = 0x203;
92 const unsigned short DIMSEC_BUILDFAILED = 0x204;
93 const unsigned short DIMSEC_ILLEGALASSOCIATION = 0x205;
94 const unsigned short DIMSEC_INVALIDPRESENTATIONCONTEXTID = 0x206;
95 const unsigned short DIMSEC_NODATAAVAILABLE = 0x207;
96 const unsigned short DIMSEC_NOVALIDPRESENTATIONCONTEXTID = 0x208;
97 const unsigned short DIMSEC_NULLKEY = 0x209;
98 const unsigned short DIMSEC_OUTOFRESOURCES = 0x20a;
99 const unsigned short DIMSEC_PARSEFAILED = 0x20b;
100 const unsigned short DIMSEC_READPDVFAILED = 0x20c;
101 const unsigned short DIMSEC_RECEIVEFAILED = 0x20d;
102 const unsigned short DIMSEC_SENDFAILED = 0x20e;
103 const unsigned short DIMSEC_UNEXPECTEDPDVTYPE = 0x20f;
104 const unsigned short DIMSEC_UNEXPECTEDREQUEST = 0x210;
105 const unsigned short DIMSEC_UNEXPECTEDRESPONSE = 0x211;
106 const unsigned short DIMSEC_UNSUPPORTEDTRANSFERSYNTAX = 0x212;
107 const unsigned short DIMSEC_NODATADICT = 0x213;
108 
109 // condition constants used in the DIMSE module
110 extern const OFCondition DIMSE_BADCOMMANDTYPE; /* Bad command type */
111 extern const OFCondition DIMSE_BADDATA; /* Inappropriate data for message (send) */
112 extern const OFCondition DIMSE_BADMESSAGE; /* Badly formed message (send) */
113 extern const OFCondition DIMSE_ILLEGALASSOCIATION; /* Caller passed in an illegal association */
114 extern const OFCondition DIMSE_NODATAAVAILABLE; /* no data (timeout in non-blocking mode) */
115 extern const OFCondition DIMSE_NOVALIDPRESENTATIONCONTEXTID; /* no valid presentation context ID */
116 extern const OFCondition DIMSE_NULLKEY; /* Caller passed in a NULL key */
117 extern const OFCondition DIMSE_OUTOFRESOURCES; /* out of resources */
118 extern const OFCondition DIMSE_PARSEFAILED; /* Failed to parse received message*/
119 extern const OFCondition DIMSE_READPDVFAILED; /* Read PDV failed */
120 extern const OFCondition DIMSE_RECEIVEFAILED; /* Failed to receive message */
121 extern const OFCondition DIMSE_SENDFAILED; /* Failed to send message */
122 extern const OFCondition DIMSE_UNEXPECTEDPDVTYPE; /* Unexpected PDV type */
123 extern const OFCondition DIMSE_NODATADICT; /* Data dictionary missing */
124 
125 // condition code constants used in the DUL module
126 const unsigned short DULC_ASSOCIATIONREJECTED = 0x301;
127 const unsigned short DULC_CODINGERROR = 0x302;
128 const unsigned short DULC_FSMERROR = 0x303;
129 const unsigned short DULC_ILLEGALACCEPT = 0x304;
130 const unsigned short DULC_ILLEGALKEY = 0x305;
131 const unsigned short DULC_ILLEGALPARAMETER = 0x306;
132 const unsigned short DULC_ILLEGALPDU = 0x307;
133 const unsigned short DULC_ILLEGALPDULENGTH = 0x308;
134 const unsigned short DULC_ILLEGALREJECTREASON = 0x309;
135 const unsigned short DULC_ILLEGALREJECTRESULT = 0x30a;
136 const unsigned short DULC_ILLEGALREQUEST = 0x30b;
137 const unsigned short DULC_ILLEGALSERVICEPARAMETER = 0x30c;
138 const unsigned short DULC_INCORRECTBUFFERLENGTH = 0x30d;
139 const unsigned short DULC_INSUFFICIENTBUFFERLENGTH = 0x30e;
140 const unsigned short DULC_LISTERROR = 0x30f;
141 const unsigned short DULC_NETWORKCLOSED = 0x310;
142 // 0x311 was NETWORKINITIALIZED (Network already initialized) in previous releases
143 const unsigned short DULC_NOASSOCIATIONREQUEST = 0x312;
144 const unsigned short DULC_NOPDVS = 0x313;
145 const unsigned short DULC_NULLKEY = 0x314;
146 const unsigned short DULC_PCTRANSLATIONFAILURE = 0x315;
147 const unsigned short DULC_PDATAPDUARRIVED = 0x316;
148 const unsigned short DULC_PEERABORTEDASSOCIATION = 0x317;
149 const unsigned short DULC_PEERILLEGALXFERSYNTAXCOUNT = 0x318;
150 const unsigned short DULC_PEERREQUESTEDRELEASE = 0x319;
151 const unsigned short DULC_READTIMEOUT = 0x31a;
152 const unsigned short DULC_REQUESTASSOCIATIONFAILED = 0x31b;
153 const unsigned short DULC_TCPINITERROR = 0x31c;
154 const unsigned short DULC_TCPIOERROR = 0x31d;
155 const unsigned short DULC_TLSERROR = 0x31e;
156 const unsigned short DULC_UNEXPECTEDPDU = 0x31f;
157 const unsigned short DULC_UNKNOWNHOST = 0x320;
158 const unsigned short DULC_UNRECOGNIZEDPDUTYPE = 0x321;
159 const unsigned short DULC_UNSUPPORTEDPEERPROTOCOL = 0x322;
160 const unsigned short DULC_WRONGDATATYPE = 0x323;
161 const unsigned short DULC_TCPWRAPPER = 0x324;
162 const unsigned short DULC_FORKEDCHILD = 0x325;
163 const unsigned short DULC_CANNOTFORK = 0x326;
164 
165 // condition constants used in the DUL module
166 extern const OFCondition DUL_ASSOCIATIONREJECTED; /* DUL Association Rejected */
167 extern const OFCondition DUL_ILLEGALACCEPT; /* Attempt to accept by requestor */
168 extern const OFCondition DUL_ILLEGALKEY; /* Illegal key */
169 extern const OFCondition DUL_ILLEGALPDU; /* DUL Illegal or ill-formed PDU */
170 extern const OFCondition DUL_ILLEGALPDULENGTH; /* DUL Illegal PDU Length */
171 extern const OFCondition DUL_ILLEGALREQUEST; /* Attempt to request by acceptor */
172 extern const OFCondition DUL_INCORRECTBUFFERLENGTH; /* DUL Incorrect buffer space allocated for data */
173 extern const OFCondition DUL_INSUFFICIENTBUFFERLENGTH; /* DUL Insufficient buffer space allocated for data */
174 extern const OFCondition DUL_LISTERROR; /* DUL List error */
175 extern const OFCondition DUL_NETWORKCLOSED; /* DUL network closed */
176 extern const OFCondition DUL_NOASSOCIATIONREQUEST; /* No requests for associations for this server */
177 extern const OFCondition DUL_NOPDVS; /* DUL No PDVs available in current buffer */
178 extern const OFCondition DUL_NULLKEY; /* NULL key passed to routine */
179 extern const OFCondition DUL_PCTRANSLATIONFAILURE; /* DUL Presentation Context translation failure */
180 extern const OFCondition DUL_PDATAPDUARRIVED; /* DUL P-Data PDU arrived */
181 extern const OFCondition DUL_PEERABORTEDASSOCIATION; /* Peer aborted Association (or never connected) */
182 extern const OFCondition DUL_PEERREQUESTEDRELEASE; /* DUL Peer Requested Release */
183 extern const OFCondition DUL_READTIMEOUT; /* DUL network read timeout */
184 extern const OFCondition DUL_REQUESTASSOCIATIONFAILED; /* Failed to establish association */
185 extern const OFCondition DUL_UNEXPECTEDPDU; /* Received unexpected PDU */
186 extern const OFCondition DUL_UNSUPPORTEDPEERPROTOCOL; /* DUL Unsupported peer protocol */
187 extern const OFCondition DUL_WRONGDATATYPE; /* DUL Wrong Data Type Specified for Request */
188 
189 
190 // This macro creates a condition with given code, severity and text.
191 // Making this a macro instead of a function saves the creation of a temporary.
192 #define makeDcmnetCondition(A, B, C) makeOFCondition(OFM_dcmnet, (A), (B), (C))
193 
194 // This macro creates a condition with given code, severity, text, and subcondition.
195 // This method is intended as a replacement for COND_PushCondition().
196 // Instead of maintaining a global condition stack (which is difficult
197 // in multi-threaded applications), the error text of the sub-condition
198 // is appended to the newly created condition.
199 // Making this a macro instead of a function saves the creation of a temporary.
200 #define makeDcmnetSubCondition(A, B, C, D) DimseCondition::push(OFM_dcmnet, (A), (B), (C), (D))
201 
202 
208 {
209 public:
210 
219  static OFString& dump(OFString& str, OFCondition cond);
220 
229  static void dump(OFCondition cond, OFConsole& console = ofConsole);
230 
237  static OFCondition push(
238  unsigned short aModule,
239  unsigned short aCode,
240  OFStatus aStatus,
241  const char *aText,
242  OFCondition subCondition);
243 
250  static OFCondition push(
251  OFCondition newCondition,
252  OFCondition subCondition);
253 
254 };
255 
256 
257 // if not in strict mode, we define a couple of things
258 // to improve compatibility with existing code.
259 #ifndef OFCONDITION_STRICT_MODE
260 
261 // CONDITION is now identical to OFCondition
262 typedef OFCondition CONDITION;
263 
264 // the success macro was defined in dicom.h in earlier releases
265 #define SUCCESS(cond) ((cond).good())
266 
267 // aliases for condition codes
268 #define ASC_ASSOCIATIONREJECTED DUL_ASSOCIATIONREJECTED
269 #define ASC_NORMAL EC_Normal
270 #define ASC_PEERABORTEDASSOCIATION DUL_PEERABORTEDASSOCIATION
271 #define ASC_PEERREQUESTEDRELEASE DUL_PEERREQUESTEDRELEASE
272 #define ASC_READTIMEOUT DUL_READTIMEOUT
273 #define DIMSE_NORMAL EC_Normal
274 #define DIMSE_PEERABORTEDASSOCIATION DUL_PEERABORTEDASSOCIATION
275 #define DIMSE_PEERREQUESTEDRELEASE DUL_PEERREQUESTEDRELEASE
276 
277 #endif /* !OFCONDITION_STRICT_MODE */
278 
279 #endif
280 
281 /*
282  * CVS Log
283  * $Log: cond.h,v $
284  * Revision 1.16 2010-10-14 13:17:21 joergr
285  * Updated copyright header. Added reference to COPYRIGHT file.
286  *
287  * Revision 1.15 2010-09-09 08:32:13 joergr
288  * Fixed typo in OFCondition constants for SCP/SCU role selection failures.
289  *
290  * Revision 1.14 2010-08-26 09:27:21 joergr
291  * Fixed incorrect behavior of association acceptors during SCP/SCU role
292  * selection negotiation.
293  *
294  * Revision 1.13 2009-11-18 11:53:58 uli
295  * Switched to logging mechanism provided by the "new" oflog module.
296  *
297  * Revision 1.12 2008-09-08 13:16:11 joergr
298  * Fixed typo in OFCondition text string.
299  *
300  * Revision 1.11 2008-04-17 15:28:33 onken
301  * Reworked and extended User Identity Negotiation code.
302  *
303  * Revision 1.10 2005-12-08 16:02:07 meichel
304  * Changed include path schema for all DCMTK header files
305  *
306  * Revision 1.9 2005/11/25 11:31:11 meichel
307  * StoreSCP now supports multi-process mode both on Posix and Win32 platforms
308  * where a separate client process is forked for each incoming association.
309  *
310  * Revision 1.8 2003/06/10 13:37:36 meichel
311  * Added support for TCP wrappers in DICOM network layer
312  *
313  * Revision 1.7 2002/12/10 11:00:57 meichel
314  * Removed error code DUL_NETWORKINITIALIZED which is not used anymore
315  *
316  * Revision 1.6 2001/10/12 10:18:25 meichel
317  * Replaced the CONDITION types, constants and functions in the dcmnet module
318  * by an OFCondition based implementation which eliminates the global condition
319  * stack. This is a major change, caveat emptor!
320  *
321  *
322  */


Generated on Thu Dec 20 2012 for OFFIS DCMTK Version 3.6.0 by Doxygen 1.8.2