/
ovsdb_client.cc
75 lines (63 loc) · 2.31 KB
/
ovsdb_client.cc
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
/*
* Copyright (c) 2014 Juniper Networks, Inc. All rights reserved.
*/
#include <ovsdb_object.h>
#include <oper/agent_sandesh.h>
#include <ovsdb_types.h>
#include <ovsdb_client.h>
#include <ovsdb_client_ssl.h>
#include <ovsdb_client_tcp.h>
#include <ovsdb_client_connection_state.h>
#include <ovs_tor_agent/tor_agent_init.h>
#include <ovs_tor_agent/tor_agent_param.h>
using OVSDB::OvsdbClient;
using OVSDB::ConnectionStateTable;
OvsdbClient::OvsdbClient(OvsPeerManager *manager, int keepalive_interval) :
peer_manager_(manager), ksync_obj_manager_(KSyncObjectManager::Init()),
keepalive_interval_(keepalive_interval) {
}
OvsdbClient::~OvsdbClient() {
}
void OvsdbClient::RegisterConnectionTable(Agent *agent) {
connection_table_.reset(new ConnectionStateTable(agent));
}
ConnectionStateTable *OvsdbClient::connection_table() {
return connection_table_.get();
}
KSyncObjectManager *OvsdbClient::ksync_obj_manager() {
return ksync_obj_manager_;
}
int OvsdbClient::keepalive_interval() const {
return keepalive_interval_;
}
void OvsdbClient::Init() {
}
OvsdbClient *OvsdbClient::Allocate(Agent *agent, TorAgentParam *params,
OvsPeerManager *manager) {
KSyncObjectManager::Init();
if (params->tor_protocol() == "tcp") {
return (new OvsdbClientTcp(agent, IpAddress(params->tor_ip()),
params->tor_port(), params->tsn_ip(),
params->keepalive_interval(), manager));
} else if (params->tor_protocol() == "pssl") {
return (new OvsdbClientSsl(agent, params, manager));
}
return NULL;
}
/////////////////////////////////////////////////////////////////////////////
// Sandesh routines
/////////////////////////////////////////////////////////////////////////////
void OvsdbClientReq::HandleRequest() const {
OvsdbClientResp *resp = new OvsdbClientResp();
SandeshOvsdbClient client_data;
OvsdbClient *client = Agent::GetInstance()->ovsdb_client();
client_data.set_protocol(client->protocol());
client_data.set_server(client->server());
client_data.set_port(client->port());
client_data.set_tor_service_node(client->tsn_ip().to_string());
client->AddSessionInfo(client_data);
resp->set_client(client_data);
resp->set_context(context());
resp->set_more(false);
resp->Response();
}