Go to the documentation of this file.00001 
00002 
00003 
00004 
00005 
00006 
00007 
00008 
00009 
00010 
00011 
00012 
00013 
00014 
00015 
00016 
00017 
00018 
00019 
00020 
00021 
00022 
00023 
00024 
00025 
00026 
00027 
00028 
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 
00044 
00045 
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 
00059 
00060 
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   
00097   
00098   
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