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 WvX509;
00024 class WvX509Mgr;
00025 
00026 typedef WvCallback<bool, WvX509*> WvSSLValidateCallback;
00027 
00033 class WvSSLStream : public WvStreamClone
00034 {
00035 public:
00041     WvSSLStream(IWvStream *_slave, WvX509Mgr *_x509 = NULL, 
00042                 WvSSLValidateCallback _vcb = 0, bool _is_server = false);
00043     
00045     virtual ~WvSSLStream();
00046     
00047     virtual void pre_select(SelectInfo &si);
00048     virtual bool post_select(SelectInfo &si);
00049     
00050     virtual void close();
00051     virtual bool isok() const;
00052     virtual void noread();
00053     virtual void nowrite();
00054     
00055 protected:
00056     WvX509Mgr *x509;
00057     
00059     SSL_CTX *ctx;
00060     
00065     SSL *ssl;
00066     
00067     virtual size_t uwrite(const void *buf, size_t len);
00068     virtual size_t uread(void *buf, size_t len);
00069     
00070 private:
00075     bool sslconnected;
00076     SelectRequest connect_wants;
00077 
00079     void setconnected(bool conn);
00080     
00082     bool is_server;
00083     
00085     bool ssl_stop_read, ssl_stop_write;
00086     
00088     WvSSLValidateCallback vcb;
00089     
00091     WvLog debug;
00092 
00101     WvInPlaceBuf write_bouncebuf;
00102     size_t write_eat;
00103 
00105     WvInPlaceBuf read_bouncebuf;
00106     bool read_pending;
00107 
00109     WvDynBuf unconnected_buf;
00110 
00112     void printerr(WvStringParm func);
00113 
00114 public:
00115     const char *wstype() const { return "WvSSLStream"; }
00116 };
00117 
00118 #endif // __WVSSLSTREAM_H
00119 

Generated on Thu Jan 24 16:50:56 2008 for WvStreams by  doxygen 1.5.4