5 #include <boost/bind.hpp>
8 #include <ovsdb_types.h>
19 IpAddress tsn_ip,
int keepalive_interval,
int ha_stale_route_interval,
21 OvsdbClient(manager, keepalive_interval, ha_stale_route_interval),
22 agent_(agent), session_(NULL), server_ep_(tor_ip, tor_port),
23 tsn_ip_(tsn_ip.to_v4()), shutdown_(false) {
98 SandeshOvsdbClientSession session;
99 std::vector<SandeshOvsdbClientSession> session_list;
105 session_list.push_back(session);
106 client.set_sessions(session_list);
112 TcpSession(server, sock, async_ready), status_(
"Init"),
114 *(agent->event_manager())->io_service(),
115 "OVSDB Client TCP reconnect Timer",
116 agent->task_scheduler()->GetTaskId(
"Agent::KSync"), 0)) {
141 Send(buf, len, NULL);
155 const boost::system::error_code &
172 return ovs_server->
tsn_ip();
202 boost::system::error_code ec;
203 switch (ovs_event.
event) {
233 assert(ec.value() == 0);
252 ovs_event.
event = event;
272 int remain = size - offset;
boost::asio::ip::tcp::endpoint server_ep_
boost::asio::const_buffer Buffer
virtual void DeleteSession(TcpSession *session)
boost::function< bool(const uint8_t *, size_t)> ReceiveCallback
void Shutdown(bool delete_entries=true)
bool RecvMsg(const u_int8_t *buf, std::size_t len)
OvsdbClientSession * FindSession(Ip4Address ip, uint16_t port)
boost::asio::ip::tcp::socket Socket
virtual void Connect(TcpSession *session, Endpoint remote)
boost::asio::ip::address IpAddress
static size_t BufferSize(const Buffer &buffer)
virtual TcpSession * CreateSession()
void RegisterConnectionTable(Agent *agent)
virtual const int GetHeaderLenSize()
const boost::system::error_code & close_reason() const
virtual uint16_t remote_port() const
virtual bool Send(const uint8_t *data, size_t size, size_t *sent)
OvsdbClientSession * NextSession(OvsdbClientSession *session)
int GetTaskId(const std::string &name)
boost::asio::ip::tcp::socket Socket
void set_observer(EventObserver observer)
const boost::system::error_code & ovsdb_close_reason() const
virtual ~OvsdbClientTcpSessionReader()
void AddSessionInfo(SandeshOvsdbClient &client)
bool ProcessSessionEvent(OvsdbSessionEvent event)
TaskScheduler * task_scheduler() const
#define OVSDB_PKT_TRACE(obj,...)
virtual void OnRead(Buffer buffer)
OvsdbClientTcpSessionReader * reader_
boost::asio::const_buffer Buffer
const std::string server()
int keepalive_interval() const
void AddSessionInfo(SandeshOvsdbClientSession &session)
void set_status(std::string status)
virtual ~OvsdbClientTcpSession()
friend class OvsdbClientTcpSession
virtual TcpSession * AllocSession(Socket *socket)
const std::string protocol()
virtual void OnRead(Buffer buffer)
void OnSessionEvent(TcpSession *session, TcpSession::Event event)
#define OVSDB_SESSION_TRACE(obj, session,...)
virtual int MsgLength(Buffer buffer, int offset)
boost::asio::ip::address_v4 Ip4Address
static const uint32_t TcpReconnectWait
ConnectionStateTable * connection_table()
virtual Ip4Address remote_ip() const
bool Start(int time, Handler handler, ErrorHandler error_handler=NULL)
const boost::asio::ip::tcp::endpoint & server_ep() const
Endpoint remote_endpoint() const
void EnqueueEvent(TcpSession::Event event)
void MessageProcess(const u_int8_t *buf, std::size_t len)
SessionEventCb connect_complete_cb_
WorkQueue< OvsdbSessionEvent > * session_event_queue_
KSyncObjectManager * ksync_obj_manager()
Timer * client_reconnect_timer_
SessionEventCb pre_connect_complete_cb_
virtual ~OvsdbClientTcp()
OvsPeerManager * peer_manager_
OvsdbClientTcpSession(Agent *agent, OvsPeerManager *manager, TcpServer *server, Socket *sock, bool async_ready=true)
KSyncObjectManager * ksync_obj_manager()
void SendMsg(u_int8_t *buf, std::size_t len)
bool Enqueue(QueueEntryT entry)
void set_name(const std::string &name)
ConnectionStateTable * connection_table()
virtual boost::system::error_code SetSocketOptions()
static bool DeleteTimer(Timer *Timer)
OvsdbClientTcpSessionReader(TcpSession *session, ReceiveCallback callback)