5 #include <boost/bind.hpp>
9 #include <ovsdb_types.h>
23 int ha_stale_route_interval,
24 const std::string &ssl_cert,
25 const std::string &ssl_privkey,
26 const std::string &ssl_cacert,
28 SslServer(agent->event_manager(), boost::asio::ssl::context::tlsv1_server),
29 OvsdbClient(manager, keepalive_interval, ha_stale_route_interval),
30 agent_(agent), ssl_server_port_(tor_port), tsn_ip_(tsn_ip.to_v4()),
33 boost::asio::ssl::context *ctx =
context();
34 boost::system::error_code ec;
37 ctx->set_verify_mode((boost::asio::ssl::verify_peer |
38 boost::asio::ssl::verify_fail_if_no_peer_cert), ec);
39 assert(ec.value() == 0);
41 ctx->use_certificate_chain_file(ssl_cert, ec);
42 if (ec.value() != 0) {
43 LOG(ERROR,
"Error : " << ec.message() <<
", while using cert file : "
48 ctx->use_private_key_file(ssl_privkey, boost::asio::ssl::context::pem, ec);
49 if (ec.value() != 0) {
50 LOG(ERROR,
"Error : " << ec.message() <<
", while using privkey file : "
55 ctx->load_verify_file(ssl_cacert, ec);
56 if (ec.value() != 0) {
57 LOG(ERROR,
"Error : " << ec.message() <<
", while using cacert file : "
107 while (ssl != NULL) {
117 SessionMap::iterator it;
123 if (it !=
session_map_.end() && it->first.first == ip) {
130 SessionMap::iterator it;
131 if (session == NULL) {
147 SandeshOvsdbClientSession session;
148 std::vector<SandeshOvsdbClientSession> session_list;
150 while (ssl != NULL) {
152 session_list.push_back(session);
155 client.set_sessions(session_list);
170 SslSession(server, sock, async_ready), status_(
"Init") {
194 Send(buf, len, NULL);
208 const boost::system::error_code &
225 return ovs_server->
tsn_ip();
251 boost::system::error_code ec;
252 switch (ovs_event.
event) {
270 std::pair<OvsdbClientSsl::SessionMap::iterator, bool> ret =
275 assert(ret.second ==
true);
289 ovs_event.
event = event;
boost::asio::const_buffer Buffer
virtual void DeleteSession(TcpSession *session)
void SendMsg(u_int8_t *buf, std::size_t len)
void Shutdown(bool delete_entries=true)
virtual ~OvsdbClientSsl()
friend class OvsdbClientSslSession
KSyncObjectManager * ksync_obj_manager()
boost::asio::ip::address IpAddress
OvsdbClientSession * FindSession(Ip4Address ip, uint16_t port)
boost::asio::ssl::context * context()
void RegisterConnectionTable(Agent *agent)
const boost::system::error_code & close_reason() const
OvsdbClientSslSession(Agent *agent, OvsPeerManager *manager, OvsdbClientSsl *server, SslSocket *sock, bool async_ready=true)
std::pair< Ip4Address, uint16_t > SessionKey
virtual bool Send(const uint8_t *data, size_t size, size_t *sent)
boost::asio::ssl::stream< boost::asio::ip::tcp::socket > SslSocket
const std::string server()
virtual Ip4Address remote_ip() const
int GetTaskId(const std::string &name)
Endpoint LocalEndpoint() const
OvsdbClientSession * NextSession(OvsdbClientSession *session)
const std::string protocol()
void set_observer(EventObserver observer)
virtual void OnRead(Buffer buffer)
void AddSessionInfo(SandeshOvsdbClient &client)
uint32_t ssl_server_port_
TaskScheduler * task_scheduler() const
#define OVSDB_PKT_TRACE(obj,...)
virtual void OnRead(Buffer buffer)
void set_status(std::string status)
bool AcceptSession(TcpSession *session)
ConnectionStateTable * connection_table()
boost::asio::ssl::stream< boost::asio::ip::tcp::socket > SslSocket
int keepalive_interval() const
void AddSessionInfo(SandeshOvsdbClientSession &session)
const boost::system::error_code & ovsdb_close_reason() const
OvsdbClientTcpSessionReader * reader_
boost::asio::ip::address_v4 Ip4Address
bool ProcessSessionEvent(OvsdbSessionEvent event)
WorkQueue< OvsdbSessionEvent > * session_event_queue_
virtual SslSession * AllocSession(SslSocket *socket)
ConnectionStateTable * connection_table()
Endpoint remote_endpoint() const
void OnSessionEvent(TcpSession *session, TcpSession::Event event)
void MessageProcess(const u_int8_t *buf, std::size_t len)
#define LOG(_Level, _Msg)
virtual bool Initialize(unsigned short port)
virtual uint16_t remote_port() const
OvsPeerManager * peer_manager_
KSyncObjectManager * ksync_obj_manager()
bool Enqueue(QueueEntryT entry)
bool RecvMsg(const u_int8_t *buf, std::size_t len)
void EnqueueEvent(TcpSession::Event event)
void set_name(const std::string &name)