• Main Page
  • Related Pages
  • Namespaces
  • Data Structures
  • Files
  • File List
  • Globals

P_SSLNetVConnection.h

Go to the documentation of this file.
00001 /** @file
00002 
00003   A brief file description
00004 
00005   @section license License
00006 
00007   Licensed to the Apache Software Foundation (ASF) under one
00008   or more contributor license agreements.  See the NOTICE file
00009   distributed with this work for additional information
00010   regarding copyright ownership.  The ASF licenses this file
00011   to you under the Apache License, Version 2.0 (the
00012   "License"); you may not use this file except in compliance
00013   with the License.  You may obtain a copy of the License at
00014 
00015       http://www.apache.org/licenses/LICENSE-2.0
00016 
00017   Unless required by applicable law or agreed to in writing, software
00018   distributed under the License is distributed on an "AS IS" BASIS,
00019   WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
00020   See the License for the specific language governing permissions and
00021   limitations under the License.
00022  */
00023 
00024 /****************************************************************************
00025 
00026   SSLNetVConnection.h
00027 
00028   This file implements an I/O Processor for network I/O.
00029 
00030 
00031  ****************************************************************************/
00032 #if !defined (_SSLNetVConnection_h_)
00033 #define _SSLNetVConnection_h_
00034 
00035 #include "libts.h"
00036 #include "P_EventSystem.h"
00037 #include "P_UnixNetVConnection.h"
00038 #include "P_UnixNet.h"
00039 
00040 #include <openssl/ssl.h>
00041 #include <openssl/err.h>
00042 
00043 // These are included here beacuse older OpenSSL libraries don't have them.
00044 // Don't copy these defines, or use their values directly, they are merely
00045 // here to avoid compiler errors.
00046 #ifndef SSL_TLSEXT_ERR_OK
00047 #define SSL_TLSEXT_ERR_OK 0
00048 #endif
00049 
00050 #ifndef SSL_TLSEXT_ERR_NOACK
00051 #define SSL_TLSEXT_ERR_NOACK 3
00052 #endif
00053 
00054 class SSLNextProtocolSet;
00055 
00056 //////////////////////////////////////////////////////////////////
00057 //
00058 //  class NetVConnection
00059 //
00060 //  A VConnection for a network socket.
00061 //
00062 //////////////////////////////////////////////////////////////////
00063 class SSLNetVConnection:public UnixNetVConnection
00064 {
00065 public:
00066   virtual int sslStartHandShake(int event, int &err);
00067   virtual void free(EThread * t);
00068   virtual void enableRead()
00069   {
00070     read.enabled = 1;
00071     write.enabled = 1;
00072   };
00073   virtual bool getSSLHandShakeComplete()
00074   {
00075     return sslHandShakeComplete;
00076   };
00077   void setSSLHandShakeComplete(bool state)
00078   {
00079     sslHandShakeComplete = state;
00080   };
00081   virtual bool getSSLClientConnection()
00082   {
00083     return sslClientConnection;
00084   };
00085   virtual void setSSLClientConnection(bool state)
00086   {
00087     sslClientConnection = state;
00088   };
00089   int sslServerHandShakeEvent(int &err);
00090   int sslClientHandShakeEvent(int &err);
00091   virtual void net_read_io(NetHandler * nh, EThread * lthread);
00092   virtual int64_t load_buffer_and_write(int64_t towrite, int64_t &wattempted, int64_t &total_wrote, MIOBufferAccessor & buf, int &needs);
00093   void registerNextProtocolSet(const SSLNextProtocolSet *);
00094 
00095   ////////////////////////////////////////////////////////////
00096   // Instances of NetVConnection should be allocated        //
00097   // only from the free list using NetVConnection::alloc(). //
00098   // The constructor is public just to avoid compile errors.//
00099   ////////////////////////////////////////////////////////////
00100   SSLNetVConnection();
00101   virtual ~SSLNetVConnection() { }
00102 
00103   SSL *ssl;
00104   ink_hrtime sslHandshakeBeginTime;
00105 
00106   static int advertise_next_protocol(SSL * ssl, const unsigned char ** out, unsigned * outlen, void *);
00107   static int select_next_protocol(SSL * ssl, const unsigned char ** out, unsigned char * outlen, const unsigned char * in, unsigned inlen, void *);
00108 
00109   Continuation * endpoint() const {
00110     return npnEndpoint;
00111   }
00112 
00113   bool getSSLClientRenegotiationAbort() const
00114   {
00115     return sslClientRenegotiationAbort;
00116   };
00117 
00118   void setSSLClientRenegotiationAbort(bool state)
00119   {
00120     sslClientRenegotiationAbort = state;
00121   };
00122 
00123 private:
00124   SSLNetVConnection(const SSLNetVConnection &);
00125   SSLNetVConnection & operator =(const SSLNetVConnection &);
00126 
00127   bool sslHandShakeComplete;
00128   bool sslClientConnection;
00129   bool sslClientRenegotiationAbort;
00130   const SSLNextProtocolSet * npnSet;
00131   Continuation * npnEndpoint;
00132 };
00133 
00134 typedef int (SSLNetVConnection::*SSLNetVConnHandler) (int, void *);
00135 
00136 extern ClassAllocator<SSLNetVConnection> sslNetVCAllocator;
00137 
00138 #endif /* _SSLNetVConnection_h_ */

Generated by  doxygen 1.7.1