This file is indexed.

/usr/include/dcmtk/dcmnet/dcmtrans.h is in libdcmtk2-dev 3.6.0-15.

This file is owned by root:root, with mode 0o644.

The actual contents of the file can be viewed below.

  1
  2
  3
  4
  5
  6
  7
  8
  9
 10
 11
 12
 13
 14
 15
 16
 17
 18
 19
 20
 21
 22
 23
 24
 25
 26
 27
 28
 29
 30
 31
 32
 33
 34
 35
 36
 37
 38
 39
 40
 41
 42
 43
 44
 45
 46
 47
 48
 49
 50
 51
 52
 53
 54
 55
 56
 57
 58
 59
 60
 61
 62
 63
 64
 65
 66
 67
 68
 69
 70
 71
 72
 73
 74
 75
 76
 77
 78
 79
 80
 81
 82
 83
 84
 85
 86
 87
 88
 89
 90
 91
 92
 93
 94
 95
 96
 97
 98
 99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
255
256
257
258
259
260
261
262
263
264
265
266
267
268
269
270
271
272
273
274
275
276
277
278
279
280
281
282
283
284
285
286
287
288
289
290
291
292
293
294
295
296
297
298
299
300
301
302
303
304
305
306
307
308
309
310
311
312
313
314
315
316
317
318
319
320
321
322
323
324
325
326
327
328
329
330
331
332
333
334
335
336
337
338
339
340
341
342
343
344
345
346
347
348
349
350
351
352
353
354
355
356
357
358
359
360
361
362
363
364
365
366
367
368
369
370
371
372
373
374
375
376
377
378
379
380
381
/*
 *
 *  Copyright (C) 1998-2010, OFFIS e.V.
 *  All rights reserved.  See COPYRIGHT file for details.
 *
 *  This software and supporting documentation were developed by
 *
 *    OFFIS e.V.
 *    R&D Division Health
 *    Escherweg 2
 *    D-26121 Oldenburg, Germany
 *
 *
 *  Module: dcmnet
 *
 *  Author: Marco Eichelberg
 *
 *  Purpose:
 *    classes: DcmTransportConnection, DcmTCPConnection
 *
 *  Last Update:      $Author: joergr $
 *  Update Date:      $Date: 2010-10-14 13:17:22 $
 *  CVS/RCS Revision: $Revision: 1.11 $
 *  Status:           $State: Exp $
 *
 *  CVS/RCS Log at end of file
 *
 */

#ifndef DCMTRANS_H
#define DCMTRANS_H

#include "dcmtk/config/osconfig.h"    /* make sure OS specific configuration is included first */
#include "dcmtk/ofstd/oftypes.h"     /* for OFBool */
#include "dcmtk/dcmnet/dcmlayer.h"    /* for DcmTransportLayerStatus */
#include "dcmtk/ofstd/ofstream.h"    /* for ostream */

#define INCLUDE_UNISTD
#include "dcmtk/ofstd/ofstdinc.h"

/** this class represents a TCP/IP based transport connection
 *  which can be a transparent TCP/IP socket communication or a
 *  secure transport protocol such as TLS.
 */
class DcmTransportConnection
{
public:

  /** constructor.
   *  @param openSocket TCP/IP socket to be used for the transport connection.
   *    the connection must already be establised on socket level. This object
   *    takes over control of the socket.
   */
  DcmTransportConnection(int openSocket);

  /** destructor
   */
  virtual ~DcmTransportConnection();

  /** performs server side handshake on established socket.
   *  This function is used to establish a secure transport connection
   *  over the established TCP connection. Abstract method.
   *  @return TCS_ok if successful, an error code otherwise.
   */
  virtual DcmTransportLayerStatus serverSideHandshake() = 0;

  /** performs client side handshake on established socket.
   *  This function is used to establish a secure transport connection
   *  over the established TCP connection. Abstract method.
   *  @return TCS_ok if successful, an error code otherwise.
   */
  virtual DcmTransportLayerStatus clientSideHandshake() = 0;

  /** performs a re-negotiation of the connection with different
   *  connection parameters. Used to change the parameters of the
   *  secure transport connection. Abstract method.
   *  @param newSuite string identifying the ciphersuite to be negotiated.
   *  @return TCS_ok if successful, an error code otherwise.
   */
  virtual DcmTransportLayerStatus renegotiate(const char *newSuite) = 0;

  /** attempts to read nbyte bytes from the transport connection and
   *  writes them into the given buffer. Abstract method.
   *  @param buf buffer
   *  @param nbyte number of bytes to read
   *  @return number of bytes read, negative number if unsuccessful.
   */
  virtual ssize_t read(void *buf, size_t nbyte) = 0;

  /** attempts to write nbyte bytes from the given buffer
   *  to the transport connection. Abstract method.
   *  @param buf buffer
   *  @param nbyte number of bytes to write
   *  @return number of bytes written, negative number if unsuccessful.
   */
  virtual ssize_t write(void *buf, size_t nbyte) = 0;

  /** Closes the transport connection. If a secure connection
   *  is used, a closure alert is sent before the connection
   *  is closed. Abstract method.
   */
  virtual void close() = 0;

  /** returns the size in bytes of the peer certificate of a secure connection.
   *  May return 0 if connection is transparent TCP/IP.
   *  @return peer certificate length in bytes
   */
  virtual unsigned long getPeerCertificateLength() = 0;

  /* copies the peer certificate of a secure connection into a buffer
   * specified by the caller. If the buffer is too small to hold the
   * certificate, nothing is copied and zero is returned.
   * @param buf buffer into which the certificate is written
   * @param bufLen size of the buffer in bytes
   * @return number of bytes written, always less or equal bufLen.
   */
  virtual unsigned long getPeerCertificate(void *buf, unsigned long bufLen) = 0;

  /** checks if data is available to be read on the transport connection.
   *  Abstract method.
   *  @param timeout maximum number of seconds to wait if no data is available.
   *     If this parameter is 0, the function does not block.
   *  @returns OFTrue if data is available, OFFalse otherwise.
   */
  virtual OFBool networkDataAvailable(int timeout) = 0;

  /** returns OFTrue if this connection is a transparent TCP connection,
   *  OFFalse if the connection is a secure connection.
   */
  virtual OFBool isTransparentConnection() = 0;

  /** dump the characteristics of the current connection
   *  @param str the string to dump into
   *  @return reference to string
   */
  virtual OFString& dumpConnectionParameters(OFString& str) = 0;

  /** prints the characteristics of the current connection
   *  on the given output stream.
   *  @param out output stream
   *  @deprecated Please use the other dumpConnectionParameters() function instead!
   */
  void dumpConnectionParameters(STD_NAMESPACE ostream& out);

  /** returns an error string for a given error code.
   *  @param code error code
   *  @return description for error code
   */
  virtual const char *errorString(DcmTransportLayerStatus code) = 0;

  /** indicates which of the specified transport connections is ready for
   *  reading. If none of the specified transport connections is ready
   *  for reading, this method blocks up to the specified timeout interval
   *  or until one of the connections becomes readable, whatever occurs
   *  first.
   *  @param connections list of transport connections. May contain NULL entries.
   *    Upon successful return of this method, all transport connections which are
   *    not ready for reading are set to NULL in this array.
   *  @param connCount number of entries in connections array.
   *  @param timeout number of seconds for timeout. If timeout is 0, this method
   *    does not block.
   *  @return OFTrue if one or more connections are readable upon return from
   *    this method, OFFalse if no connection is ready for reading.
   */
  static OFBool selectReadableAssociation(DcmTransportConnection *connections[], int connCount, int timeout);

protected:

  /** returns the socket file descriptor managed by this object.
   *  @return socket file descriptor
   */
  int getSocket() { return theSocket; }

  /** set the socket file descriptor managed by this object.
   *  @param socket file descriptor
   */
  void setSocket(int socket) { theSocket = socket; }

private:

  /// private undefined copy constructor
  DcmTransportConnection(const DcmTransportConnection&);

  /// private undefined assignment operator
  DcmTransportConnection& operator=(const DcmTransportConnection&);

  /** indicates which of the specified transport connections is ready for
   *  reading. If none of the specified transport connections is ready
   *  for reading, this method blocks up to the specified timeout interval
   *  or until one of the connections becomes readable, whatever occurs
   *  first. This method uses a safe approach that also works with secure
   *  transport connections, but which may be slower than a select() system
   *  call and consumes slightly more computation time.
   *  @param connections list of transport connections. May contain NULL entries.
   *    Upon successful return of this method, all transport connections which are
   *    not ready for reading are set to NULL in this array.
   *  @param connCount number of entries in connections array.
   *  @param timeout number of seconds for timeout. If timeout is 0, this method
   *    does not block.
   *  @return OFTrue if one or more connections are readable upon return from
   *    this method, OFFalse if no connection is ready for reading.
   */
  static OFBool safeSelectReadableAssociation(DcmTransportConnection *connections[], int connCount, int timeout);

  /** indicates which of the specified transport connections is ready for
   *  reading. If none of the specified transport connections is ready
   *  for reading, this method blocks up to the specified timeout interval
   *  or until one of the connections becomes readable, whatever occurs
   *  first. This method uses the select() system call. It may only be used
   *  with an array of transparent TCP transport connections. This precondition
   *  must be assured by the caller.
   *  @param connections list of transport connections. May contain NULL entries.
   *    Upon successful return of this method, all transport connections which are
   *    not ready for reading are set to NULL in this array.
   *  @param connCount number of entries in connections array.
   *  @param timeout number of seconds for timeout. If timeout is 0, this method
   *    does not block.
   *  @return OFTrue if one or more connections are readable upon return from
   *    this method, OFFalse if no connection is ready for reading.
   */
  static OFBool fastSelectReadableAssociation(DcmTransportConnection *connections[], int connCount, int timeout);

  /// the socket file descriptor used by the transport connection.
  int theSocket;
};


/** this class represents a TCP/IP based transport connection.
 */
class DcmTCPConnection: public DcmTransportConnection
{
public:

  /** constructor.
   *  @param openSocket TCP/IP socket to be used for the transport connection.
   *    the connection must already be establised on socket level. This object
   *    takes over control of the socket.
   */
  DcmTCPConnection(int openSocket);

  /** destructor
   */
  virtual ~DcmTCPConnection();

  /** performs server side handshake on established socket.
   *  This function is used to establish a secure transport connection
   *  over the established TCP connection.
   *  @return TCS_ok if successful, an error code otherwise.
   */
  virtual DcmTransportLayerStatus serverSideHandshake();

  /** performs client side handshake on established socket.
   *  This function is used to establish a secure transport connection
   *  over the established TCP connection.
   *  @return TCS_ok if successful, an error code otherwise.
   */
  virtual DcmTransportLayerStatus clientSideHandshake();

  /** performs a re-negotiation of the connection with different
   *  connection parameters. Used to change the parameters of the
   *  secure transport connection.
   *  @param newSuite string identifying the ciphersuite to be negotiated.
   *  @return TCS_ok if successful, an error code otherwise.
   */
  virtual DcmTransportLayerStatus renegotiate(const char *newSuite);

  /** attempts to read nbyte bytes from the transport connection and
   *  writes them into the given buffer.
   *  @param buf buffer
   *  @param nbyte number of bytes to read
   *  @return number of bytes read, negative number if unsuccessful.
   */
  virtual ssize_t read(void *buf, size_t nbyte);

  /** attempts to write nbyte bytes from the given buffer
   *  to the transport connection.
   *  @param buf buffer
   *  @param nbyte number of bytes to write
   *  @return number of bytes written, negative number if unsuccessful.
   */
  virtual ssize_t write(void *buf, size_t nbyte);

  /** Closes the transport connection. If a secure connection
   *  is used, a closure alert is sent before the connection
   *  is closed.
   */
  virtual void close();

  /** returns the size in bytes of the peer certificate of a secure connection.
   *  May return 0 if connection is transparent TCP/IP.
   *  @return peer certificate length in bytes
   */
  virtual unsigned long getPeerCertificateLength();

  /* copies the peer certificate of a secure connection into a buffer
   * specified by the caller. If the buffer is too small to hold the
   * certificate, nothing is copied and zero is returned.
   * @param buf buffer into which the certificate is written
   * @param bufLen size of the buffer in bytes
   * @return number of bytes written, always less or equal bufLen.
   */
  virtual unsigned long getPeerCertificate(void *buf, unsigned long bufLen);

  /** checks if data is available to be read on the transport connection.
   *  @param timeout maximum number of seconds to wait if no data is available.
   *     If this parameter is 0, the function does not block.
   *  @returns OFTrue if data is available, OFFalse otherwise.
   */
  virtual OFBool networkDataAvailable(int timeout);

  /** returns OFTrue if this connection is a transparent TCP connection,
   *  OFFalse if the connection is a secure connection.
   */
  virtual OFBool isTransparentConnection();

  /** dump the characteristics of the current connection
   *  @param str the string to dump into
   *  @return reference to string
   */
  virtual OFString& dumpConnectionParameters(OFString& str);

  /** returns an error string for a given error code.
   *  @param code error code
   *  @return description for error code
   */
  virtual const char *errorString(DcmTransportLayerStatus code);

private:

  /// private undefined copy constructor
  DcmTCPConnection(const DcmTCPConnection&);

  /// private undefined assignment operator
  DcmTCPConnection& operator=(const DcmTCPConnection&);

};

#endif

/*
 *  $Log: dcmtrans.h,v $
 *  Revision 1.11  2010-10-14 13:17:22  joergr
 *  Updated copyright header. Added reference to COPYRIGHT file.
 *
 *  Revision 1.10  2009-11-18 11:53:58  uli
 *  Switched to logging mechanism provided by the "new" oflog module.
 *
 *  Revision 1.9  2009-01-29 11:39:44  joergr
 *  Fixed issue with missing invalidation of socket variable during close method.
 *  Please note that this is only required if the connection objects exists after
 *  the TCP/IP connection has been closed (which is currently not the case).
 *
 *  Revision 1.8  2006/08/15 16:04:29  meichel
 *  Updated the code in module dcmnet to correctly compile when
 *    all standard C++ classes remain in namespace std.
 *
 *  Revision 1.7  2005/12/08 16:02:18  meichel
 *  Changed include path schema for all DCMTK header files
 *
 *  Revision 1.6  2004/08/03 11:42:43  meichel
 *  Headers libc.h and unistd.h are now included via ofstdinc.h
 *
 *  Revision 1.5  2003/12/05 10:39:45  joergr
 *  Removed leading underscore characters from preprocessor symbols (reserved
 *  symbols).
 *
 *  Revision 1.4  2003/07/04 13:27:15  meichel
 *  Added include for ofstream.h, to make sure ofstream is correctly defined
 *
 *  Revision 1.3  2001/06/01 15:50:04  meichel
 *  Updated copyright header
 *
 *  Revision 1.2  2000/10/10 12:06:53  meichel
 *  Updated transport layer error codes and routines for printing
 *    connection parameters.
 *
 *  Revision 1.1  2000/08/10 14:50:53  meichel
 *  Added initial OpenSSL support.
 *
 *
 */