Main Page | Class Hierarchy | Alphabetical List | Class List | File List | Class Members | Related Pages

dcmtrans.h

00001 /*
00002  *
00003  *  Copyright (C) 1998-2003, 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: joergr $
00026  *  Update Date:      $Date: 2003/12/05 10:39:45 $
00027  *  CVS/RCS Revision: $Revision: 1.5 $
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 "osconfig.h"    /* make sure OS specific configuration is included first */
00038 #include "oftypes.h"     /* for OFBool */
00039 #include "dcmlayer.h"    /* for DcmTransportLayerStatus */
00040 #include "ofstream.h"    /* for ostream */
00041 
00042 BEGIN_EXTERN_C
00043 #ifdef HAVE_UNISTD_H
00044 #include <unistd.h>
00045 #endif
00046 END_EXTERN_C
00047 
00052 class DcmTransportConnection
00053 {
00054 public:
00055 
00061   DcmTransportConnection(int openSocket);
00062 
00065   virtual ~DcmTransportConnection();
00066 
00072   virtual DcmTransportLayerStatus serverSideHandshake() = 0;
00073 
00079   virtual DcmTransportLayerStatus clientSideHandshake() = 0;
00080 
00087   virtual DcmTransportLayerStatus renegotiate(const char *newSuite) = 0;
00088 
00095   virtual ssize_t read(void *buf, size_t nbyte) = 0;
00096 
00103   virtual ssize_t write(void *buf, size_t nbyte) = 0;
00104 
00109   virtual void close() = 0;
00110 
00115   virtual unsigned long getPeerCertificateLength() = 0;
00116 
00117   /* copies the peer certificate of a secure connection into a buffer
00118    * specified by the caller. If the buffer is too small to hold the
00119    * certificate, nothing is copied and zero is returned.
00120    * @param buf buffer into which the certificate is written
00121    * @param bufLen size of the buffer in bytes
00122    * @return number of bytes written, always less or equal bufLen.
00123    */
00124   virtual unsigned long getPeerCertificate(void *buf, unsigned long bufLen) = 0;
00125 
00132   virtual OFBool networkDataAvailable(int timeout) = 0;
00133 
00137   virtual OFBool isTransparentConnection() = 0;
00138 
00143   virtual void dumpConnectionParameters(ostream &out) = 0;
00144 
00149   virtual const char *errorString(DcmTransportLayerStatus code) = 0;
00150 
00165   static OFBool selectReadableAssociation(DcmTransportConnection *connections[], int connCount, int timeout);
00166 
00167 protected:
00168 
00172   int getSocket() { return theSocket; }
00173 
00174 private:
00175 
00177   DcmTransportConnection(const DcmTransportConnection&);
00178 
00180   DcmTransportConnection& operator=(const DcmTransportConnection&);
00181 
00198   static OFBool safeSelectReadableAssociation(DcmTransportConnection *connections[], int connCount, int timeout);
00199 
00216   static OFBool fastSelectReadableAssociation(DcmTransportConnection *connections[], int connCount, int timeout);
00217 
00219   int theSocket;
00220 };
00221 
00222 
00225 class DcmTCPConnection: public DcmTransportConnection
00226 {
00227 public:
00228 
00234   DcmTCPConnection(int openSocket);
00235 
00238   virtual ~DcmTCPConnection();
00239 
00245   virtual DcmTransportLayerStatus serverSideHandshake();
00246 
00252   virtual DcmTransportLayerStatus clientSideHandshake();
00253 
00260   virtual DcmTransportLayerStatus renegotiate(const char *newSuite);
00261 
00268   virtual ssize_t read(void *buf, size_t nbyte);
00269 
00276   virtual ssize_t write(void *buf, size_t nbyte);
00277 
00282   virtual void close();
00283 
00288   virtual unsigned long getPeerCertificateLength();
00289 
00290   /* copies the peer certificate of a secure connection into a buffer
00291    * specified by the caller. If the buffer is too small to hold the
00292    * certificate, nothing is copied and zero is returned.
00293    * @param buf buffer into which the certificate is written
00294    * @param bufLen size of the buffer in bytes
00295    * @return number of bytes written, always less or equal bufLen.
00296    */
00297   virtual unsigned long getPeerCertificate(void *buf, unsigned long bufLen);
00298 
00304   virtual OFBool networkDataAvailable(int timeout);
00305 
00309   virtual OFBool isTransparentConnection();
00310 
00315   virtual void dumpConnectionParameters(ostream &out);
00316 
00321   virtual const char *errorString(DcmTransportLayerStatus code);
00322 
00323 private:
00324 
00326   DcmTCPConnection(const DcmTCPConnection&);
00327 
00329   DcmTCPConnection& operator=(const DcmTCPConnection&);
00330 
00331 };
00332 
00333 #endif
00334 
00335 /*
00336  *  $Log: dcmtrans.h,v $
00337  *  Revision 1.5  2003/12/05 10:39:45  joergr
00338  *  Removed leading underscore characters from preprocessor symbols (reserved
00339  *  symbols).
00340  *
00341  *  Revision 1.4  2003/07/04 13:27:15  meichel
00342  *  Added include for ofstream.h, to make sure ofstream is correctly defined
00343  *
00344  *  Revision 1.3  2001/06/01 15:50:04  meichel
00345  *  Updated copyright header
00346  *
00347  *  Revision 1.2  2000/10/10 12:06:53  meichel
00348  *  Updated transport layer error codes and routines for printing
00349  *    connection parameters.
00350  *
00351  *  Revision 1.1  2000/08/10 14:50:53  meichel
00352  *  Added initial OpenSSL support.
00353  *
00354  *
00355  */
00356 


Generated on 8 Dec 2004 for OFFIS DCMTK Version 3.5.3 by Doxygen 1.3.9.1