dcmtrans.h

00001 /*
00002  *
00003  *  Copyright (C) 1998-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:
00023  *    classes: DcmTransportConnection, DcmTCPConnection
00024  *
00025  *  Last Update:      $Author: meichel $
00026  *  Update Date:      $Date: 2005/12/08 16:02:18 $
00027  *  CVS/RCS Revision: $Revision: 1.7 $
00028  *  Status:           $State: Exp $
00029  *
00030  *  CVS/RCS Log at end of file
00031  *
00032  */
00033 
00034 #ifndef DCMTRANS_H
00035 #define DCMTRANS_H
00036 
00037 #include "dcmtk/config/osconfig.h"    /* make sure OS specific configuration is included first */
00038 #include "dcmtk/ofstd/oftypes.h"     /* for OFBool */
00039 #include "dcmtk/dcmnet/dcmlayer.h"    /* for DcmTransportLayerStatus */
00040 #include "dcmtk/ofstd/ofstream.h"    /* for ostream */
00041 
00042 #define INCLUDE_UNISTD
00043 #include "dcmtk/ofstd/ofstdinc.h"
00044 
00049 class DcmTransportConnection
00050 {
00051 public:
00052 
00058   DcmTransportConnection(int openSocket);
00059 
00062   virtual ~DcmTransportConnection();
00063 
00069   virtual DcmTransportLayerStatus serverSideHandshake() = 0;
00070 
00076   virtual DcmTransportLayerStatus clientSideHandshake() = 0;
00077 
00084   virtual DcmTransportLayerStatus renegotiate(const char *newSuite) = 0;
00085 
00092   virtual ssize_t read(void *buf, size_t nbyte) = 0;
00093 
00100   virtual ssize_t write(void *buf, size_t nbyte) = 0;
00101 
00106   virtual void close() = 0;
00107 
00112   virtual unsigned long getPeerCertificateLength() = 0;
00113 
00114   /* copies the peer certificate of a secure connection into a buffer
00115    * specified by the caller. If the buffer is too small to hold the
00116    * certificate, nothing is copied and zero is returned.
00117    * @param buf buffer into which the certificate is written
00118    * @param bufLen size of the buffer in bytes
00119    * @return number of bytes written, always less or equal bufLen.
00120    */
00121   virtual unsigned long getPeerCertificate(void *buf, unsigned long bufLen) = 0;
00122 
00129   virtual OFBool networkDataAvailable(int timeout) = 0;
00130 
00134   virtual OFBool isTransparentConnection() = 0;
00135 
00140   virtual void dumpConnectionParameters(ostream &out) = 0;
00141 
00146   virtual const char *errorString(DcmTransportLayerStatus code) = 0;
00147 
00162   static OFBool selectReadableAssociation(DcmTransportConnection *connections[], int connCount, int timeout);
00163 
00164 protected:
00165 
00169   int getSocket() { return theSocket; }
00170 
00171 private:
00172 
00174   DcmTransportConnection(const DcmTransportConnection&);
00175 
00177   DcmTransportConnection& operator=(const DcmTransportConnection&);
00178 
00195   static OFBool safeSelectReadableAssociation(DcmTransportConnection *connections[], int connCount, int timeout);
00196 
00213   static OFBool fastSelectReadableAssociation(DcmTransportConnection *connections[], int connCount, int timeout);
00214 
00216   int theSocket;
00217 };
00218 
00219 
00222 class DcmTCPConnection: public DcmTransportConnection
00223 {
00224 public:
00225 
00231   DcmTCPConnection(int openSocket);
00232 
00235   virtual ~DcmTCPConnection();
00236 
00242   virtual DcmTransportLayerStatus serverSideHandshake();
00243 
00249   virtual DcmTransportLayerStatus clientSideHandshake();
00250 
00257   virtual DcmTransportLayerStatus renegotiate(const char *newSuite);
00258 
00265   virtual ssize_t read(void *buf, size_t nbyte);
00266 
00273   virtual ssize_t write(void *buf, size_t nbyte);
00274 
00279   virtual void close();
00280 
00285   virtual unsigned long getPeerCertificateLength();
00286 
00287   /* copies the peer certificate of a secure connection into a buffer
00288    * specified by the caller. If the buffer is too small to hold the
00289    * certificate, nothing is copied and zero is returned.
00290    * @param buf buffer into which the certificate is written
00291    * @param bufLen size of the buffer in bytes
00292    * @return number of bytes written, always less or equal bufLen.
00293    */
00294   virtual unsigned long getPeerCertificate(void *buf, unsigned long bufLen);
00295 
00301   virtual OFBool networkDataAvailable(int timeout);
00302 
00306   virtual OFBool isTransparentConnection();
00307 
00312   virtual void dumpConnectionParameters(ostream &out);
00313 
00318   virtual const char *errorString(DcmTransportLayerStatus code);
00319 
00320 private:
00321 
00323   DcmTCPConnection(const DcmTCPConnection&);
00324 
00326   DcmTCPConnection& operator=(const DcmTCPConnection&);
00327 
00328 };
00329 
00330 #endif
00331 
00332 /*
00333  *  $Log: dcmtrans.h,v $
00334  *  Revision 1.7  2005/12/08 16:02:18  meichel
00335  *  Changed include path schema for all DCMTK header files
00336  *
00337  *  Revision 1.6  2004/08/03 11:42:43  meichel
00338  *  Headers libc.h and unistd.h are now included via ofstdinc.h
00339  *
00340  *  Revision 1.5  2003/12/05 10:39:45  joergr
00341  *  Removed leading underscore characters from preprocessor symbols (reserved
00342  *  symbols).
00343  *
00344  *  Revision 1.4  2003/07/04 13:27:15  meichel
00345  *  Added include for ofstream.h, to make sure ofstream is correctly defined
00346  *
00347  *  Revision 1.3  2001/06/01 15:50:04  meichel
00348  *  Updated copyright header
00349  *
00350  *  Revision 1.2  2000/10/10 12:06:53  meichel
00351  *  Updated transport layer error codes and routines for printing
00352  *    connection parameters.
00353  *
00354  *  Revision 1.1  2000/08/10 14:50:53  meichel
00355  *  Added initial OpenSSL support.
00356  *
00357  *
00358  */
00359 


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