Kinetic C/C++ Client
 All Classes Functions Variables Pages
copying_ssl_stream.h
1 /*
2  * kinetic-cpp-client
3  * Copyright (C) 2014 Seagate Technology.
4  *
5  * This program is free software; you can redistribute it and/or
6  * modify it under the terms of the GNU General Public License
7  * as published by the Free Software Foundation; either version 2
8  * of the License, or (at your option) any later version.
9  *
10  * This program is distributed in the hope that it will be useful,
11  * but WITHOUT ANY WARRANTY; without even the implied warranty of
12  * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
13  * GNU General Public License for more details.
14  *
15  * You should have received a copy of the GNU General Public License
16  * along with this program; if not, write to the Free Software
17  * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA.
18  *
19  */
20 
21 #ifndef KINETIC_CPP_CLIENT_COPYING_SSL_STREAM_H_
22 #define KINETIC_CPP_CLIENT_COPYING_SSL_STREAM_H_
23 
24 #include "google/protobuf/io/zero_copy_stream_impl_lite.h"
25 #include "openssl/ssl.h"
26 #include "kinetic/common.h"
27 
28 namespace kinetic {
29 
30 using google::protobuf::io::CopyingInputStream;
31 using google::protobuf::io::CopyingOutputStream;
32 
33 /* These classes represent SSL input and output streams. Note that they assume
34  * an SSL connection has already been established via SSL_accept or
35  * SSL_connect. */
36 
37 class CopyingSslInputStream : public CopyingInputStream {
38  public:
39  explicit CopyingSslInputStream(SSL *ssl);
40  virtual int Read(void *buffer, int size);
41 
42  private:
43  SSL *ssl_;
44  DISALLOW_COPY_AND_ASSIGN(CopyingSslInputStream);
45 };
46 
47 class CopyingSslOutputStream : public CopyingOutputStream {
48  public:
49  explicit CopyingSslOutputStream(SSL *ssl);
50  virtual bool Write(const void *buffer, int size);
51 
52  private:
53  SSL *ssl_;
54  DISALLOW_COPY_AND_ASSIGN(CopyingSslOutputStream);
55 };
56 
57 } // namespace kinetic
58 
59 #endif // KINETIC_CPP_CLIENT_COPYING_SSL_STREAM_H_