5 #include <boost/bind/bind.hpp>
9 #include <ovsdb_types.h>
15 using namespace boost::placeholders;
25 int ha_stale_route_interval,
26 const std::string &ssl_cert,
27 const std::string &ssl_privkey,
28 const std::string &ssl_cacert,
30 SslServer(agent->event_manager(),
boost::asio::ssl::context::tlsv1_server),
31 OvsdbClient(manager, keepalive_interval, ha_stale_route_interval),
32 agent_(agent), ssl_server_port_(tor_port), tsn_ip_(tsn_ip.to_v4()),
35 boost::asio::ssl::context *ctx =
context();
36 boost::system::error_code ec;
39 ctx->set_verify_mode((boost::asio::ssl::verify_peer |
40 boost::asio::ssl::verify_fail_if_no_peer_cert), ec);
41 assert(ec.value() == 0);
43 ctx->use_certificate_chain_file(ssl_cert, ec);
44 if (ec.value() != 0) {
45 LOG(ERROR,
"Error : " << ec.message() <<
", while using cert file : "
50 ctx->use_private_key_file(ssl_privkey, boost::asio::ssl::context::pem, ec);
51 if (ec.value() != 0) {
52 LOG(ERROR,
"Error : " << ec.message() <<
", while using privkey file : "
57 ctx->load_verify_file(ssl_cacert, ec);
58 if (ec.value() != 0) {
59 LOG(ERROR,
"Error : " << ec.message() <<
", while using cacert file : "
109 while (ssl != NULL) {
119 SessionMap::iterator it;
125 if (it !=
session_map_.end() && it->first.first == ip) {
132 SessionMap::iterator it;
133 if (session == NULL) {
149 SandeshOvsdbClientSession session;
150 std::vector<SandeshOvsdbClientSession> session_list;
152 while (ssl != NULL) {
154 session_list.push_back(session);
157 client.set_sessions(session_list);
172 SslSession(server, sock, async_ready), status_(
"Init") {
196 Send(buf, len, NULL);
210 const boost::system::error_code &
227 return ovs_server->
tsn_ip();
253 boost::system::error_code ec;
254 switch (ovs_event.
event) {
272 std::pair<OvsdbClientSsl::SessionMap::iterator, bool> ret =
277 assert(ret.second ==
true);
291 ovs_event.
event = event;
boost::asio::ip::address IpAddress
boost::asio::ip::address_v4 Ip4Address
TaskScheduler * task_scheduler() const
void AddSessionInfo(SandeshOvsdbClientSession &session)
void MessageProcess(const u_int8_t *buf, std::size_t len)
WorkQueue< OvsdbSessionEvent > * session_event_queue_
void EnqueueEvent(TcpSession::Event event)
OvsdbClientSslSession(Agent *agent, OvsPeerManager *manager, OvsdbClientSsl *server, SslSocket *sock, bool async_ready=true)
void SendMsg(u_int8_t *buf, std::size_t len)
KSyncObjectManager * ksync_obj_manager()
bool RecvMsg(const u_int8_t *buf, std::size_t len)
ConnectionStateTable * connection_table()
virtual void OnRead(Buffer buffer)
const boost::system::error_code & ovsdb_close_reason() const
virtual Ip4Address remote_ip() const
virtual uint16_t remote_port() const
bool ProcessSessionEvent(OvsdbSessionEvent event)
OvsdbClientTcpSessionReader * reader_
void set_status(std::string status)
void OnSessionEvent(TcpSession *session, TcpSession::Event event)
bool AcceptSession(TcpSession *session)
virtual ~OvsdbClientSsl()
void AddSessionInfo(SandeshOvsdbClient &client)
uint32_t ssl_server_port_
const std::string protocol()
std::pair< Ip4Address, uint16_t > SessionKey
OvsdbClientSession * NextSession(OvsdbClientSession *session)
virtual SslSession * AllocSession(SslSocket *socket)
const std::string server()
OvsdbClientSession * FindSession(Ip4Address ip, uint16_t port)
friend class OvsdbClientSslSession
OvsPeerManager * peer_manager_
ConnectionStateTable * connection_table()
void RegisterConnectionTable(Agent *agent)
int keepalive_interval() const
KSyncObjectManager * ksync_obj_manager()
boost::asio::ssl::stream< boost::asio::ip::tcp::socket > SslSocket
boost::asio::ssl::context * context()
boost::asio::ssl::stream< boost::asio::ip::tcp::socket > SslSocket
int GetTaskId(const std::string &name)
virtual void OnRead(Buffer buffer)
Endpoint LocalEndpoint() const
virtual bool Initialize(unsigned short port)
virtual void DeleteSession(TcpSession *session)
const boost::system::error_code & close_reason() const
void set_observer(EventObserver observer)
Endpoint remote_endpoint() const
boost::asio::const_buffer Buffer
virtual bool Send(const uint8_t *data, size_t size, size_t *sent)
bool Enqueue(QueueEntryT entry)
void Shutdown(bool delete_entries=true)
void set_name(const std::string &name)
#define LOG(_Level, _Msg)
#define OVSDB_PKT_TRACE(obj,...)