1 /*
2  *
3  *  Copyright (C) 1994-2019, 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, RSNA and Washington University
19 
20           The software and supporting documentation for the Radiological
21           Society of North America (RSNA) 1993, 1994 Digital Imaging and
22           Communications in Medicine (DICOM) Demonstration were developed
23           at the
24                   Electronic Radiology Laboratory
25                   Mallinckrodt Institute of Radiology
26                   Washington University School of Medicine
27                   510 S. Kingshighway Blvd.
28                   St. Louis, MO 63110
29           as part of the 1993, 1994 DICOM Central Test Node project for, and
30           under contract with, the Radiological Society of North America.
31 
32           THIS SOFTWARE IS MADE AVAILABLE, AS IS, AND NEITHER RSNA NOR
33           WASHINGTON UNIVERSITY MAKE ANY WARRANTY ABOUT THE SOFTWARE, ITS
34           PERFORMANCE, ITS MERCHANTABILITY OR FITNESS FOR ANY PARTICULAR
35           USE, FREEDOM FROM ANY COMPUTER DISEASES OR ITS CONFORMITY TO ANY
36           SPECIFICATION. THE ENTIRE RISK AS TO QUALITY AND PERFORMANCE OF
37           THE SOFTWARE IS WITH THE USER.
38 
39           Copyright of the software and supporting documentation is
40           jointly owned by RSNA and Washington University, and free access
41           is hereby granted as a license to use this software, copy this
42           software and prepare derivative works based upon this software.
43           However, any distribution of this software source code or
44           supporting documentation or derivative works (source code and
45           supporting documentation) must include the three paragraphs of
46           the copyright notice.
47 */
48 
49 /*
50 **        DICOM 93
51 **        Electronic Radiology Laboratory
52 **      Mallinckrodt Institute of Radiology
53 **    Washington University School of Medicine
54 **
55 ** Module Name(s):
56 ** Author, Date:  Stephen M. Moore, 14-Apr-1993
57 ** Intent:        This file defines the public structures and constants
58 **                and the function prototypes for the DUL (DICOM Upper
59 **                Layer) facility.
60 */
61 
62 
63 #ifndef DUL_IS_IN
64 #define DUL_IS_IN 1
65 
66 #include "dcmtk/config/osconfig.h"    /* make sure OS specific configuration is included first */
67 
68 #include "dcmtk/ofstd/ofglobal.h"
69 #include "dcmtk/ofstd/oftypes.h"
70 #include "dcmtk/ofstd/ofcast.h"
71 #include "dcmtk/dcmnet/extneg.h"
72 #include "dcmtk/dcmnet/dicom.h"
73 #include "dcmtk/dcmnet/dcuserid.h"
74 #include "dcmtk/dcmnet/dntypes.h"
75 
76 class DcmTransportConnection;
77 class DcmTransportLayer;
78 class LST_HEAD;
79 
80 // include this file in doxygen documentation
81 
82 /** @file dul.h
83  *  @brief type definitions, constants, global variables and functions for the dcmnet/dul module
84  */
85 
86 /** Global flag to enable/disable reverse DNS lookup when accepting associations.
87  *  If disabled, the numerical IP address instead of the symbolic hostname is
88  *  stored in the callingPresentationAddress field of the association parameters
89  *  structure.  Most DICOM applications (except imagectn) don't need the symbolic
90  *  hostname anyway, and the reverse DNS lookup can cause a long timeout.
91  */
92 extern DCMTK_DCMNET_EXPORT OFGlobal<OFBool> dcmDisableGethostbyaddr;   /* default: OFFalse */
93 
94 /** Global timeout in seconds for connecting to remote hosts.
95  *  Default value is -1, which selects infinite timeout, i.e. blocking connect().
96  */
97 extern DCMTK_DCMNET_EXPORT OFGlobal<Sint32> dcmConnectionTimeout;   /* default: -1 */
98 
99 /** This global flag allows to set an already opened socket file descriptor which
100  *  will be used by dcmnet the next time receiveTransportConnectionTCP() is called.
101  *  Useful for use with proxy applications, but inherently thread unsafe!
102  */
103 extern DCMTK_DCMNET_EXPORT OFGlobal<DcmNativeSocketType> dcmExternalSocketHandle;   /* default: platform specific value that denotes <i>invalid</i> */
104 
105 /** When compiled with WITH_TCPWRAPPER, DCMTK server processes may use the TCP
106  *  wrapper library to enforce access control - see hosts_access(5).  If this
107  *  global flag is non-NULL, the TCP wrapper is enabled and the string pointed
108  *  to is used as the daemon name.  If the flag is NULL, no access control is
109  *  performed.
110  */
111 extern DCMTK_DCMNET_EXPORT OFGlobal<const char *> dcmTCPWrapperDaemonName;   /* default: NULL */
112 
113 /* Global option flag for compatibility with DCMTK releases prior to version 3.0.
114  * Default (0) is automatic handling, which should work in most cases.
115  */
116 extern DCMTK_DCMNET_EXPORT OFGlobal<unsigned long> dcmEnableBackwardCompatibility;
117 
118 /** Maximum size (in bytes) of incoming A-ASSOCIATE-RQ or A-ASSOCIATE-AC PDUs
119  *  that we are willing to accept. Under normal conditions, valid A-ASSOCIATE PDUs
120  *  will never be larger than 64 kBytes, so the default of 1 MByte should be safe.
121  *  We should limit the maximum accepted PDU size to avoid denial of service
122  *  attacks through faulty PDUs that cause the network layer to allocate up
123  *  to 4 GByte of memory for one PDU.
124  *
125  *  Note: This limit can be disabled by setting a value of zero, which
126  *  causes the behaviour to revert to that of DCMTK releases up to 3.6.3.
127  */
128 extern DCMTK_DCMNET_EXPORT OFGlobal<size_t> dcmAssociatePDUSizeLimit;   /* default: 1 MB */
129 
130 typedef void DUL_NETWORKKEY;
131 typedef void DUL_ASSOCIATIONKEY;
132 typedef unsigned char DUL_PRESENTATIONCONTEXTID;
133 
134 /** pure virtual base class for DUL mode callbacks
135  */
136 
137 /*  Define a structure containing fixed length fields that can
138  *  be used for requesting or accepting an association.  The
139  *  lengths of "titles" and "names" are specified by the DICOM
140  *  protocol document.  The fields in the structure are made
141  *  longer to allow for zero-terminators.  DICOM doesn't know
142  *  about node names, but the DUL_ package needs them.
143  */
144 
145 #define DUL_LEN_TITLE  OFstatic_cast(size_t, 16)  /* required by DICOM protocol */
146 #define DUL_LEN_NAME   OFstatic_cast(size_t, 64)  /* required by DICOM protocol */
147 #define DUL_LEN_UID    OFstatic_cast(size_t, 64)  /* required by DICOM protocol */
148 #define DUL_LEN_NODE   OFstatic_cast(size_t, 127) /* should be "big enough" */
149 
150 
151 /* DICOM PDU Types */
152 
153 #define DUL_TYPEASSOCIATERQ  OFstatic_cast(unsigned char, 0x01)
154 #define DUL_TYPEASSOCIATEAC  OFstatic_cast(unsigned char, 0x02)
155 #define DUL_TYPEASSOCIATERJ  OFstatic_cast(unsigned char, 0x03)
156 #define DUL_TYPEDATA         OFstatic_cast(unsigned char, 0x04)
157 #define DUL_TYPERELEASERQ    OFstatic_cast(unsigned char, 0x05)
158 #define DUL_TYPERELEASERP    OFstatic_cast(unsigned char, 0x06)
159 #define DUL_TYPEABORT        OFstatic_cast(unsigned char, 0x07)
160 
161 #define DUL_MAXTYPE          OFstatic_cast(unsigned char, 0x07)
162 
163 class DCMTK_DCMNET_EXPORT DUL_ModeCallback
164 {
165 public:
166 
167   /// destructor
~DUL_ModeCallback()168   virtual ~DUL_ModeCallback() {}
169 
170   /** callback method
171    *  @param mode DUL compatibility mode passed in callback
172    */
173   virtual void callback(unsigned long mode) = 0;
174 };
175 
176 typedef struct {
177     char applicationContextName[DUL_LEN_NAME + 1];
178     char callingAPTitle[DUL_LEN_TITLE + 1];
179     char calledAPTitle[DUL_LEN_TITLE + 1];
180     char respondingAPTitle[DUL_LEN_TITLE + 1];
181     unsigned long maxPDU;
182     unsigned short result;
183     unsigned short resultSource;
184     unsigned short diagnostic;
185     char callingPresentationAddress[64];
186     char calledPresentationAddress[64];
187     LST_HEAD *requestedPresentationContext;
188     LST_HEAD *acceptedPresentationContext;
189     unsigned short maximumOperationsInvoked;
190     unsigned short maximumOperationsPerformed;
191     char callingImplementationClassUID[DICOM_UI_LENGTH + 1];
192     char callingImplementationVersionName[16 + 1];
193     char calledImplementationClassUID[DICOM_UI_LENGTH + 1];
194     char calledImplementationVersionName[16 + 1];
195     unsigned long peerMaxPDU;
196     SOPClassExtendedNegotiationSubItemList *requestedExtNegList;
197     SOPClassExtendedNegotiationSubItemList *acceptedExtNegList;
198     UserIdentityNegotiationSubItemRQ *reqUserIdentNeg;
199     UserIdentityNegotiationSubItemAC *ackUserIdentNeg;
200 
201     OFBool useSecureLayer;
202 }   DUL_ASSOCIATESERVICEPARAMETERS;
203 
204 /** Enum describing the possible role settings for role negotiation sub items.
205  *  DCMTK implements the following role negotiation behaviour for association
206  *  acceptors:
207  *  @verbatim
208  *  +--------------------+------------------+---------+
209  *  | Requestor Proposal | Acceptor Setting | Result  |
210  *  +--------------------+------------------+---------+
211  *  | SCU                | SCP              | NONE    |
212  *  | SCU                | SCU              | SCU     |
213  *  | SCU                | SCU/SCP          | SCU     |
214  *  | SCU                | DEFAULT          | DEFAULT |
215  *  | SCP                | SCP              | SCP     |
216  *  | SCP                | SCU              | NONE    |
217  *  | SCP                | SCU/SCP          | SCP     |
218  *  | SCP                | DEFAULT          | DEFAULT |
219  *  | SCU/SCP            | SCP              | SCP     |
220  *  | SCU/SCP            | SCU              | SCU     |
221  *  | SCU/SCP            | SCU/SCP          | SCU/SCP |
222  *  | SCU/SCP            | DEFAULT          | DEFAULT |
223  *  | DEFAULT            | SCP              | Reject  |
224  *  | DEFAULT            | SCU              | DEFAULT |
225  *  | DEFAULT            | SCU/SCP          | DEFAULT |
226  *  | DEFAULT            | DEFAULT          | DEFAULT |
227  *  +--------------------+------------------+---------+
228  *  @endverbatim
229  *  NONE, SCU, SCP as well as SCU/SCP denote the related flags in the
230  *  association role selection user items. The "Reject" case denotes that
231  *  such a presentation context will be rejected by the association acceptor:
232  *  If the requestor connects with default role but the acceptor explicitly
233  *  requires the SCP role (only) then the presentation context
234  *  will be rejected. All other cases do not lead to rejection but to actual
235  *  "negotiation".
236  *
237  *  The Reject case can be avoided by setting a related option available in
238  *  association acceptance code like ASC_acceptPresentationContext() or DcmSCP.
239  *  to OFTrue (reading something like "alwaysAcceptDefaultRole" since when enabled,
240  *  with the Reject being disabled all Default role proposals will be accepted).
241  *  This can make sense for faulty Requestors, e.g. faulty Storage Commitment Servers
242  *  connecting on a second connection for delivering an N-EVENT-REPORT, or broken
243  *  Retrieve requestors proposing GET-based SOP Classes for retrieval using the Default
244  *  role instead of the required SCP role.
245  */
246 typedef enum {
247     DUL_SC_ROLE_NONE,
248     DUL_SC_ROLE_DEFAULT,
249     DUL_SC_ROLE_SCU,
250     DUL_SC_ROLE_SCP,
251     DUL_SC_ROLE_SCUSCP
252 }   DUL_SC_ROLE;
253 
254 #define DUL_PRESENTATION_ACCEPT                 0
255 #define DUL_PRESENTATION_REJECT_USER            1
256 #define DUL_PRESENTATION_REJECT_NOREASON        2
257 #define DUL_PRESENTATION_REJECT_ABSTRACT_SYNTAX 3
258 #define DUL_PRESENTATION_REJECT_TRANSFER_SYNTAX 4
259 
260 typedef OFList<char *> DUL_TRANSFERSYNTAXLIST;
261 
262 typedef struct {
263     void *reserved[2];
264     DUL_PRESENTATIONCONTEXTID presentationContextID;
265     char abstractSyntax[DUL_LEN_UID + 1];
266     LST_HEAD *proposedTransferSyntax;
267     char acceptedTransferSyntax[DUL_LEN_UID + 1];
268     unsigned char result;
269     DUL_SC_ROLE proposedSCRole;
270     DUL_SC_ROLE acceptedSCRole;
271 }   DUL_PRESENTATIONCONTEXT;
272 
273 typedef struct {
274     void *reserved[2];
275     char transferSyntax[DUL_LEN_UID + 1];
276 }   DUL_TRANSFERSYNTAX;
277 
278 typedef struct dul_abortitems {
279     unsigned char result;
280     unsigned char source;
281     unsigned char reason;
282 }   DUL_ABORTITEMS;
283 
284 typedef enum {
285     DUL_COMMANDPDV,   /* A command PDV inside a data PDU */
286     DUL_DATASETPDV
287 }   /* A data set PDV inside a data PDU */
288     DUL_DATAPDV;
289 
290 typedef enum {
291     DUL_BLOCK,      /* Block on an operation (read, request) */
292     DUL_NOBLOCK
293 }   /* Or return immediately if nothing avail */
294     DUL_BLOCKOPTIONS;
295 
296 typedef struct {
297     unsigned long fragmentLength;
298     unsigned char presentationContextID;
299     DUL_DATAPDV pdvType;
300     OFBool lastPDV;
301     void *data;
302 }   DUL_PDV;
303 
304 typedef struct {
305     unsigned long count;
306     void *scratch;
307     unsigned long scratchLength;
308     DUL_ABORTITEMS abort;
309     DUL_PDV *pdv;
310 }   DUL_PDVLIST;
311 
312 /*  Define the bits that go in the options field for InitializeNetwork
313 **
314 **  The low two bits define the byte order of messages at the DICOM
315 **  level.  This does not define the order of user data inside of a
316 **  DICOM PDU.
317 */
318 
319 #define DUL_ORDERMASK          0x03  /* The bottom two bits */
320 #define DUL_ORDERLITTLEENDIAN  0x01
321 #define DUL_ORDERBIGENDIAN     0x02
322 
323 #define DUL_DOMAINMASK         0x04
324 #define DUL_FULLDOMAINNAME     0x04
325 
326 #define DUL_AEREQUESTOR        "AE REQUESTOR"
327 #define DUL_AEACCEPTOR         "AE ACCEPTOR"
328 #define DUL_AEBOTH             "AE BOTH"
329 
330 /*  These macros define results and reasons for rejecting an association
331 **  request.  Result is permanent or transient.  There are a number of
332 **  different reasons for rejecting requests that occur at different layers
333  */
334 #define DUL_REJ_RSLTPERMANENT  0x01
335 #define DUL_REJ_RSLTTRANSIENT  0x02
336 
337 /*  These macros define parameters used to construct an ABORT PDU.
338 **  These include the source of the abort (SCU or SCP) and the
339 **  reason for the abort.
340 */
341 
342 #define DUL_SCU_INITIATED_ABORT           0x00
343 #define DUL_SCP_INITIATED_ABORT           0x02
344 
345 #define DUL_ABORTSERVICEUSER              0x00
346 #define DUL_ABORTSERVICEPROVIDER          0x02
347 
348 #define DUL_ABORTNOREASON                 0x00
349 #define DUL_ABORTUNRECOGNIZEDPDU          0x01
350 #define DUL_ABORTUNEXPECTEDPDU            0x02
351 #define DUL_ABORTUNRECOGNIZEDPDUPARAM     0x04
352 #define DUL_ABORTUNEXPECTEDPDUPARAM       0x05
353 #define DUL_ABORTINVALIDPDUPARAM          0x06
354 
355 /*  These macros define parameters used to construct a REJECT PDU.
356 **  These include the source of the reject (DICOM UL service-user,
357 **  (DICOM UL service-provider) and the reason for the reject.
358 */
359 #define DUL_REJECT_PERMANENT              0x01
360 #define DUL_REJECT_TRANSIENT              0x02
361 
362 #define DUL_ULSU_REJECT                   0x01
363 #define DUL_ULSP_ACSE_REJECT              0x02
364 #define DUL_ULSP_PRESENTATION_REJECT      0x03
365 
366 #define DUL_ULSU_REJ_NOREASON             0x01
367 #define DUL_ULSU_REJ_UNSUP_APP_CTX_NAME   0x02
368 #define DUL_ULSU_REJ_UNREC_CALLING_TITLE  0x03
369 #define DUL_ULSU_REJ_UNREC_CALLED_TITLE   0x07
370 
371 #define DUL_ULSP_ACSE_REJ_NOREASON        0x01
372 #define DUL_ULSP_ACSE_UNSUP_PROTOCOL      0x02
373 
374 #define DUL_ULSP_PRES_REJ_TEMP_CONGEST    0x01
375 #define DUL_ULSP_PRES_REJ_LIMIT           0x02
376 
377 #define DUL_ABORTNOREASON                 0x00
378 #define DUL_ABORTUNRECOGNIZEDPDU          0x01
379 #define DUL_ABORTUNEXPECTEDPDU            0x02
380 #define DUL_ABORTUNRECOGNIZEDPDUPARAM     0x04
381 #define DUL_ABORTUNEXPECTEDPDUPARAM       0x05
382 #define DUL_ABORTINVALIDPDUPARAM          0x06
383 
384 /* Define a set of constants and types that let the user get information
385 ** about the Association
386 */
387 
388 typedef enum {
389     DUL_K_INTEGER,    /* An integer type */
390     DUL_K_STRING      /* A string type */
391 }   DUL_DATA_TYPE;
392 
393 typedef enum {
394     DUL_K_MAX_PDV_XMIT
395 }   DUL_ASSOCIATION_PARAMETER;
396 
397 #define DUL_TIMEOUT 180
398 
399 /* Operating mode flags as defined in the 1993 toolkit specification.
400 ** Needed for backward compatibility with DCMTK releases prior to 3.0
401 ** (and possibly older CTN releases).
402 */
403 
404 #define DUL_DULCOMPAT     2768240730UL
405 #define DUL_DIMSECOMPAT   1048576UL
406 #define DUL_MAXPDUCOMPAT  4278190335UL
407 
408 /* Define the function prototypes for this facility.
409 **
410 ** First set of functions are for establishing the network and associations.
411 */
412 
413 DCMTK_DCMNET_EXPORT OFCondition
414 DUL_AcknowledgeAssociationRQ(
415   DUL_ASSOCIATIONKEY ** association,
416   DUL_ASSOCIATESERVICEPARAMETERS * params,
417   int activatePDUStorage);
418 
419 DCMTK_DCMNET_EXPORT OFCondition
420 DUL_InitializeNetwork(
421   const char *mode,
422   void *param,
423   int timeout,
424   unsigned long
425   options,
426   DUL_NETWORKKEY ** network);
427 
428 DCMTK_DCMNET_EXPORT OFCondition
429 DUL_ReceiveAssociationRQ(
430   DUL_NETWORKKEY ** network,
431   DUL_BLOCKOPTIONS block,
432   int timeout,
433   DUL_ASSOCIATESERVICEPARAMETERS * parameters,
434   DUL_ASSOCIATIONKEY ** association,
435   int activatePDUStorage);
436 
437 DCMTK_DCMNET_EXPORT OFCondition
438 DUL_RejectAssociationRQ(
439   DUL_ASSOCIATIONKEY ** association,
440   DUL_ABORTITEMS * params,
441   int activatePDUStorage);
442 
443 DCMTK_DCMNET_EXPORT OFCondition
444 DUL_RequestAssociation(
445   DUL_NETWORKKEY ** network,
446   DUL_BLOCKOPTIONS block,
447   int timeout,
448   DUL_ASSOCIATESERVICEPARAMETERS * params,
449   DUL_ASSOCIATIONKEY ** association,
450   int activatePDUStorage);
451 
452 /* Define functions for releasing/aborting Associations.
453 */
454 DCMTK_DCMNET_EXPORT OFCondition DUL_AbortAssociation(DUL_ASSOCIATIONKEY ** association);
455 DCMTK_DCMNET_EXPORT OFCondition DUL_DropAssociation(DUL_ASSOCIATIONKEY ** association);
456 DCMTK_DCMNET_EXPORT OFCondition DUL_DropNetwork(DUL_NETWORKKEY ** network);
457 DCMTK_DCMNET_EXPORT OFCondition DUL_ReleaseAssociation(DUL_ASSOCIATIONKEY ** association);
458 DCMTK_DCMNET_EXPORT OFCondition DUL_AcknowledgeRelease(DUL_ASSOCIATIONKEY ** association);
459 
460 /* Functions for reading/write PDVs inside P DATA PDUs.
461 */
462 DCMTK_DCMNET_EXPORT OFCondition
463 DUL_ReadPDVs(DUL_ASSOCIATIONKEY ** association,
464        DUL_PDVLIST * pdvList, DUL_BLOCKOPTIONS block, int timeout);
465 DCMTK_DCMNET_EXPORT OFCondition
466 DUL_WritePDVs(DUL_ASSOCIATIONKEY ** association,
467         DUL_PDVLIST * pdvList);
468 DCMTK_DCMNET_EXPORT OFCondition DUL_NextPDV(DUL_ASSOCIATIONKEY ** association, DUL_PDV * pdv);
469 
470 
471 /* Miscellaneous functions.
472 */
473 DCMTK_DCMNET_EXPORT OFCondition
474 DUL_AssociationParameter(DUL_ASSOCIATIONKEY ** association,
475        DUL_ASSOCIATION_PARAMETER param, DUL_DATA_TYPE type,
476        void *address, size_t length);
477 DCMTK_DCMNET_EXPORT OFCondition
478 DUL_MakePresentationCtx(DUL_PRESENTATIONCONTEXT ** ctx,
479          DUL_SC_ROLE proposedSCRole, DUL_SC_ROLE acceptedSCRole,
480 DUL_PRESENTATIONCONTEXTID ctxID, unsigned char reason, const char *abstractSyntax,
481       const char *transferSyntax, ...);
482 DCMTK_DCMNET_EXPORT OFString& DUL_DumpParams(OFString& str, DUL_ASSOCIATESERVICEPARAMETERS * params);
483 DCMTK_DCMNET_EXPORT OFString& DUL_DumpConnectionParameters(OFString& str, DUL_ASSOCIATIONKEY *association);
484 
485 DCMTK_DCMNET_EXPORT OFCondition DUL_ClearServiceParameters(DUL_ASSOCIATESERVICEPARAMETERS * params);
486 DCMTK_DCMNET_EXPORT OFString& dumpExtNegList(OFString& str, SOPClassExtendedNegotiationSubItemList& lst);
487 
488 /*
489 ** Additional functions (from dulextra.cc) needed to support
490 ** selecting amongst several concurrent associations.
491 ** Andrew Hewett, Institute OFFIS, Oldenburg, Germany.
492 */
493 
494 DCMTK_DCMNET_EXPORT OFBool
495 DUL_dataWaiting(DUL_ASSOCIATIONKEY * callerAssociation, int timeout);
496 
497 DCMTK_DCMNET_EXPORT DcmNativeSocketType DUL_networkSocket(DUL_NETWORKKEY * callerNet);
498 
499 DCMTK_DCMNET_EXPORT OFBool
500 DUL_associationWaiting(DUL_NETWORKKEY * callerNet, int timeout);
501 
502 /*
503  * functions allowing to retrieve raw A-ASSOCIATE PDUs from the DUL layer
504  */
505 DCMTK_DCMNET_EXPORT void DUL_activateAssociatePDUStorage(DUL_ASSOCIATIONKEY *dulassoc);
506 DCMTK_DCMNET_EXPORT void DUL_returnAssociatePDUStorage(DUL_ASSOCIATIONKEY *dulassoc, void *& pdu, unsigned long& pdusize);
507 
508 /* get pointer to transport connection from opaque association pointer */
509 DCMTK_DCMNET_EXPORT DcmTransportConnection *DUL_getTransportConnection(DUL_ASSOCIATIONKEY * callerAssociation);
510 
511 /* change transport layer */
512 DCMTK_DCMNET_EXPORT OFCondition DUL_setTransportLayer(DUL_NETWORKKEY *callerNetworkKey, DcmTransportLayer *newLayer, int takeoverOwnership);
513 
514 /* activate compatibility mode and callback */
515 DCMTK_DCMNET_EXPORT void DUL_activateCompatibilityMode(DUL_ASSOCIATIONKEY *dulassoc, unsigned long mode);
516 DCMTK_DCMNET_EXPORT void DUL_activateCallback(DUL_ASSOCIATIONKEY *dulassoc, DUL_ModeCallback *cb);
517 
518 /*
519  * function allowing to retrieve the peer certificate from the DUL layer
520  */
521 DCMTK_DCMNET_EXPORT unsigned long DUL_getPeerCertificateLength(DUL_ASSOCIATIONKEY *dulassoc);
522 DCMTK_DCMNET_EXPORT unsigned long DUL_getPeerCertificate(DUL_ASSOCIATIONKEY *dulassoc, void *buf, unsigned long bufLen);
523 
524 /*
525  * functions for multi-process servers
526  */
527 
528 /** this function returns true if the current process was created by the
529  *  DICOM network layer during receipt of a TCP transport connection, i.e.
530  *  in receiveTransportConnectionTCP().
531  *  @return true if current process is a forked child of a multi-process server
532  */
533 DCMTK_DCMNET_EXPORT OFBool DUL_processIsForkedChild();
534 
535 /** this function marks the current process as a child created by the
536  *  DICOM network layer during receipt of a TCP transport connection, i.e.
537  *  in receiveTransportConnectionTCP(). The call is not reversible - use with care.
538  */
539 DCMTK_DCMNET_EXPORT void DUL_markProcessAsForkedChild();
540 
541 /** this helper function calls DUL_markProcessAsForkedChild(), then reads
542  *  the socket handle from the pipe opened by the parent process and
543  *  stores it in the global variable dcmExternalSocketHandle. This is
544  *  in most cases everything needed to prepare the network layer to act
545  *  as a forked child on Win32. On other operating system, the function does nothing.
546  * @return EC_Normal if successful, an error code otherwise.
547  */
548 DCMTK_DCMNET_EXPORT OFCondition DUL_readSocketHandleAsForkedChild();
549 
550 /** this function marks the current process as a multi-process server and enables
551  *  the creation of child processes for each incoming TCP transport connection
552  *  in receiveTransportConnectionTCP().
553  *  @param argc argc command line argument counter variable passed to main().
554  *     The content of this parameter is ignored on Posix platforms but required
555  *     on Win32, where the child process is created with CreateProcess and the
556  *     command line parameters have to be passed from parent to child.
557  *  @param argv argv command line argument value array passed to main().
558  *     The content of this parameter is ignored on Posix platforms but required
559  *     on Win32, where the child process is created with CreateProcess and the
560  *     command line parameters have to be passed from parent to child.
561  */
562 DCMTK_DCMNET_EXPORT void DUL_requestForkOnTransportConnectionReceipt(int argc, char *argv[]);
563 
564 
565 /// @deprecated Use OFString& DUL_DumpParams(OFString&, DUL_ASSOCIATESERVICEPARAMETERS) instead.
566 DCMTK_DCMNET_EXPORT void DUL_DumpParams(DUL_ASSOCIATESERVICEPARAMETERS * params);
567 /// @deprecated Use OFString& DUL_DumpConnectionParameters(OFString&, DUL_ASSOCIATIONKEY*) instead.
568 DCMTK_DCMNET_EXPORT void DUL_DumpConnectionParameters(DUL_ASSOCIATIONKEY *association, STD_NAMESPACE ostream& outstream);
569 /// @deprecated Use OFString& dumpExtNegList(OFString&, SOPClassExtendedNegotiationSubItemList&) instead.
570 DCMTK_DCMNET_EXPORT void dumpExtNegList(SOPClassExtendedNegotiationSubItemList& lst);
571 
572 #endif
573