2014-11-19 00:25:21 +08:00
|
|
|
|
#pragma once
|
|
|
|
|
|
|
|
|
|
#include "acl_cpp/acl_cpp_define.hpp"
|
|
|
|
|
#include "acl_cpp/stream/stream.hpp"
|
|
|
|
|
|
|
|
|
|
namespace acl {
|
|
|
|
|
|
|
|
|
|
class stream;
|
|
|
|
|
class polarssl_conf;
|
|
|
|
|
|
|
|
|
|
/**
|
|
|
|
|
* stream <EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD>ײ<EFBFBD> IO <EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD>̵Ĵ<EFBFBD><EFBFBD><EFBFBD><EFBFBD>࣬<EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD>еĶ<EFBFBD>д<EFBFBD>Ĺ<EFBFBD><EFBFBD>̽<EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD>
|
|
|
|
|
* stream <EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD> Ĭ<EFBFBD>ϵĵײ<EFBFBD> IO <EFBFBD><EFBFBD><EFBFBD>̣<EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD>Ƕ<EFBFBD>̬<EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD>(<EFBFBD><EFBFBD>Ϊ<EFBFBD>Ѷ<EFBFBD><EFBFBD><EFBFBD>)<EFBFBD><EFBFBD>
|
|
|
|
|
* stream <EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD>ͨ<EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD>ñ<EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD> destroy()<EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD>ͷű<EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD>
|
|
|
|
|
*/
|
|
|
|
|
class ACL_CPP_API polarssl_io : public stream_hook
|
|
|
|
|
{
|
|
|
|
|
public:
|
|
|
|
|
/**
|
|
|
|
|
* <EFBFBD><EFBFBD><EFBFBD>캯<EFBFBD><EFBFBD>
|
|
|
|
|
* @param conf {polarssl_conf&} <EFBFBD><EFBFBD>ÿһ<EFBFBD><EFBFBD> SSL <EFBFBD><EFBFBD><EFBFBD>ӽ<EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD>õ<EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD>
|
|
|
|
|
* @param server_side {bool} <EFBFBD>Ƿ<EFBFBD>Ϊ<EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD>ģʽ<EFBFBD><EFBFBD><EFBFBD><EFBFBD>Ϊ<EFBFBD>ͻ<EFBFBD><EFBFBD><EFBFBD>ģʽ<EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD>
|
|
|
|
|
* ģʽ<EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD>ַ<EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD>ͬ<EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD>ͨ<EFBFBD><EFBFBD><EFBFBD>˲<EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD>
|
|
|
|
|
*/
|
|
|
|
|
polarssl_io(polarssl_conf& conf, bool server_side);
|
|
|
|
|
|
|
|
|
|
virtual void destroy();
|
|
|
|
|
|
|
|
|
|
private:
|
|
|
|
|
~polarssl_io();
|
|
|
|
|
|
|
|
|
|
virtual bool open(stream* s);
|
|
|
|
|
virtual bool on_close(bool alive);
|
|
|
|
|
virtual int read(void* buf, size_t len);
|
|
|
|
|
virtual int send(const void* buf, size_t len);
|
|
|
|
|
|
|
|
|
|
private:
|
|
|
|
|
polarssl_conf& conf_;
|
|
|
|
|
bool server_side_;
|
|
|
|
|
void* ssl_;
|
|
|
|
|
void* ssn_;
|
|
|
|
|
void* rnd_;
|
|
|
|
|
const stream* stream_;
|
|
|
|
|
|
|
|
|
|
static int sock_read(void *ctx, unsigned char *buf, size_t len);
|
|
|
|
|
static int sock_send(void *ctx, const unsigned char *buf, size_t len);
|
|
|
|
|
};
|
|
|
|
|
|
|
|
|
|
} // namespace acl
|