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