wvsslstream.h

00001 /* -*- Mode: C++ -*-
00002  * Worldvisions Weaver Software:
00003  *   Copyright (C) 1997-2002 Net Integration Technologies, Inc.
00004  *
00005  * SSL (Socket Security Layer) communications via WvStreams.
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     
00066     virtual size_t uwrite(const void *buf, size_t len);
00067     virtual size_t uread(void *buf, size_t len);
00068     
00069 private:
00074     volatile bool sslconnected;
00075 
00077     void setconnected(bool conn);
00078     
00080     bool is_server;
00081     
00083     bool ssl_stop_read, ssl_stop_write;
00084     
00086     WvSSLValidateCallback vcb;
00087     
00089     WvLog debug;
00090 
00099     WvInPlaceBuf write_bouncebuf;
00100     size_t write_eat;
00101 
00103     WvInPlaceBuf read_bouncebuf;
00104     bool read_pending;
00105 
00107     WvDynBuf unconnected_buf;
00108 
00110     void printerr(WvStringParm func);
00111 
00112 public:
00113     const char *wstype() const { return "WvSSLStream"; }
00114 };
00115 
00116 #endif // __WVSSLSTREAM_H
00117 

Generated on Fri Oct 5 18:20:28 2007 for WvStreams by  doxygen 1.5.3