/
ovsdb_route_peer.h
63 lines (53 loc) · 1.95 KB
/
ovsdb_route_peer.h
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
/*
* Copyright (c) 2014 Juniper Networks, Inc. All rights reserved.
*/
#ifndef SRC_VNSW_AGENT_OVS_TOR_AGENT_OVSDB_CLIENT_OVS_PEER_H_
#define SRC_VNSW_AGENT_OVS_TOR_AGENT_OVSDB_CLIENT_OVS_PEER_H_
#include <cmn/agent_cmn.h>
#include <oper/peer.h>
class OvsPeerManager;
// Peer for routes added by OVS
class OvsPeer : public Peer {
public:
OvsPeer(const IpAddress &peer_ip, uint64_t gen_id, OvsPeerManager *manager);
virtual ~OvsPeer();
bool Compare(const Peer *rhs) const;
const Ip4Address *NexthopIp(Agent *agent, const AgentPath *path) const;
bool AddOvsRoute(const VrfEntry *vrf, uint32_t vxlan_id,
const std::string &dest_vn, const MacAddress &mac,
Ip4Address &tor_ip);
void DeleteOvsRoute(VrfEntry *vrf, uint32_t vxlan, const MacAddress &mac);
void AddOvsPeerMulticastRoute(const VrfEntry *vrf,
uint32_t vxlan_id,
const std::string &vn_name_,
const Ip4Address &tsn_ip,
const Ip4Address &tor_ip);
void DeleteOvsPeerMulticastRoute(const VrfEntry *vrf, uint32_t vxlan_id);
const IpAddress &peer_ip() const {return peer_ip_;}
private:
IpAddress peer_ip_;
uint64_t gen_id_;
OvsPeerManager *peer_manager_;
DISALLOW_COPY_AND_ASSIGN(OvsPeer);
};
class OvsPeerManager {
public:
struct cmp {
bool operator()(const OvsPeer *lhs, const OvsPeer *rhs) {
return lhs->Compare(rhs);
}
};
typedef std::set<OvsPeer *, cmp> OvsPeerTable;
OvsPeerManager(Agent *agent);
virtual ~OvsPeerManager();
OvsPeer *Allocate(const IpAddress &peer_ip);
void Free(OvsPeer *peer);
uint32_t Size() const;
Agent *agent() const;
private:
uint64_t gen_id_;
Agent *agent_;
OvsPeerTable table_;
DISALLOW_COPY_AND_ASSIGN(OvsPeerManager);
};
#endif // SRC_VNSW_AGENT_OVS_TOR_AGENT_OVSDB_CLIENT_OVS_PEER_H_