|
reSIProcate/stack
9694
|
00001 #if !defined(TlsConnection_hxx) 00002 #define TlsConnection_hxx 00003 00004 #if defined(HAVE_CONFIG_H) 00005 #include "config.h" 00006 #endif 00007 00008 00009 #include "resip/stack/Connection.hxx" 00010 #include "rutil/HeapInstanceCounter.hxx" 00011 #include "resip/stack/SecurityTypes.hxx" 00012 #include "resip/stack/ssl/Security.hxx" 00013 00014 // If USE_SSL is not defined, this will not be built, and this header will 00015 // not be installed. If you are including this file from a source tree, and are 00016 // getting link errors, the source tree was probably built without USE_SSL. 00017 //#ifdef USE_SSL 00018 //#include <openssl/ssl.h> 00019 //#else 00020 //typedef void BIO; 00021 //typedef void SSL; 00022 //#endif 00023 00024 #include <openssl/ssl.h> 00025 00026 namespace resip 00027 { 00028 00029 class Tuple; 00030 class Security; 00031 00032 class TlsConnection : public Connection 00033 { 00034 public: 00035 RESIP_HeapCount(TlsConnection); 00036 00037 TlsConnection( Transport* transport, const Tuple& who, Socket fd, 00038 Security* security, bool server, Data domain, 00039 SecurityTypes::SSLType sslType , 00040 Compression &compression); 00041 00042 virtual ~TlsConnection(); 00043 00044 int read( char* buf, const int count ); 00045 int write( const char* buf, const int count ); 00046 virtual bool hasDataToRead(); // has data that can be read 00047 virtual bool isGood(); // has valid connection 00048 virtual bool isWritable(); 00049 00050 virtual bool transportWrite(); 00051 00052 void getPeerNames(std::list<Data> & peerNames) const; 00053 00054 typedef enum TlsState { Initial, Broken, Handshaking, Up } TlsState; 00055 static const char * fromState(TlsState); 00056 00057 private: 00059 TlsConnection(); 00060 void computePeerName(); 00061 Data getPeerNamesData() const; 00062 TlsState checkState(); 00063 00064 bool mServer; 00065 Security* mSecurity; 00066 SecurityTypes::SSLType mSslType; 00067 Data mDomain; 00068 00069 TlsState mTlsState; 00070 bool mHandShakeWantsRead; 00071 00072 SSL* mSsl; 00073 BIO* mBio; 00074 std::list<BaseSecurity::PeerName> mPeerNames; 00075 }; 00076 00077 } 00078 00079 #endif 00080 00081 /* ==================================================================== 00082 * The Vovida Software License, Version 1.0 00083 * 00084 * Copyright (c) 2000-2005 Vovida Networks, Inc. All rights reserved. 00085 * 00086 * Redistribution and use in source and binary forms, with or without 00087 * modification, are permitted provided that the following conditions 00088 * are met: 00089 * 00090 * 1. Redistributions of source code must retain the above copyright 00091 * notice, this list of conditions and the following disclaimer. 00092 * 00093 * 2. Redistributions in binary form must reproduce the above copyright 00094 * notice, this list of conditions and the following disclaimer in 00095 * the documentation and/or other materials provided with the 00096 * distribution. 00097 * 00098 * 3. The names "VOCAL", "Vovida Open Communication Application Library", 00099 * and "Vovida Open Communication Application Library (VOCAL)" must 00100 * not be used to endorse or promote products derived from this 00101 * software without prior written permission. For written 00102 * permission, please contact vocal@vovida.org. 00103 * 00104 * 4. Products derived from this software may not be called "VOCAL", nor 00105 * may "VOCAL" appear in their name, without prior written 00106 * permission of Vovida Networks, Inc. 00107 * 00108 * THIS SOFTWARE IS PROVIDED "AS IS" AND ANY EXPRESSED OR IMPLIED 00109 * WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES 00110 * OF MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE, TITLE AND 00111 * NON-INFRINGEMENT ARE DISCLAIMED. IN NO EVENT SHALL VOVIDA 00112 * NETWORKS, INC. OR ITS CONTRIBUTORS BE LIABLE FOR ANY DIRECT DAMAGES 00113 * IN EXCESS OF $1,000, NOR FOR ANY INDIRECT, INCIDENTAL, SPECIAL, 00114 * EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, 00115 * PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR 00116 * PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY 00117 * OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT 00118 * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE 00119 * USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH 00120 * DAMAGE. 00121 * 00122 * ==================================================================== 00123 * 00124 * This software consists of voluntary contributions made by Vovida 00125 * Networks, Inc. and many individuals on behalf of Vovida Networks, 00126 * Inc. For more information on Vovida Networks, Inc., please see 00127 * <http://www.vovida.org/>. 00128 * 00129 */
1.7.5.1