00001
00002
00003
00004
00005
00006
00007 #ifndef __WVSSLSTREAM_H
00008 #define __WVSSLSTREAM_H
00009
00010 #include "wvstreamclone.h"
00011 #include "wvfdstream.h"
00012 #include "wvlog.h"
00013 #include "wvcallback.h"
00014
00015 struct ssl_st;
00016 struct ssl_ctx_st;
00017 struct ssl_method_st;
00018
00019 typedef struct ssl_ctx_st SSL_CTX;
00020 typedef struct ssl_st SSL;
00021 typedef struct ssl_method_st SSL_METHOD;
00022
00023 class WvX509Mgr;
00024
00025 typedef WvCallback<bool, WvX509Mgr*> WvSSLValidateCallback;
00026
00032 class WvSSLStream : public WvStreamClone
00033 {
00034 public:
00040 WvSSLStream(IWvStream *_slave, WvX509Mgr *_x509 = NULL,
00041 WvSSLValidateCallback _vcb = 0, bool _is_server = false);
00042
00044 virtual ~WvSSLStream();
00045
00046 virtual bool pre_select(SelectInfo &si);
00047 virtual bool post_select(SelectInfo &si);
00048
00049 virtual void close();
00050 virtual bool isok() const;
00051 virtual void noread();
00052 virtual void nowrite();
00053
00054 protected:
00055 WvX509Mgr *x509;
00056
00058 SSL_CTX *ctx;
00059
00064 SSL *ssl;
00065
00070 SSL_METHOD *meth;
00071
00072 virtual size_t uwrite(const void *buf, size_t len);
00073 virtual size_t uread(void *buf, size_t len);
00074
00075 private:
00080 volatile bool sslconnected;
00081
00083 void setconnected(bool conn);
00084
00086 bool is_server;
00087
00089 bool ssl_stop_read, ssl_stop_write;
00090
00092 WvSSLValidateCallback vcb;
00093
00095 WvLog debug;
00096
00105 WvInPlaceBuf write_bouncebuf;
00106 size_t write_eat;
00107
00109 WvInPlaceBuf read_bouncebuf;
00110 bool read_pending;
00111
00113 WvDynBuf unconnected_buf;
00114
00116 void printerr(WvStringParm func);
00117
00118 };
00119
00120 #endif // __WVSSLSTREAM_H
00121