Line data Source code
1 : /*
2 : * Copyright (c) 2013 Juniper Networks, Inc. All rights reserved.
3 : * Copyright Contributors to the OpenSDN project
4 : */
5 :
6 : #ifndef vnsw_inet4_multicast_route_hpp
7 : #define vnsw_inet4_multicast_route_hpp
8 :
9 : //////////////////////////////////////////////////////////////////
10 : // MULTICAST INET4
11 : /////////////////////////////////////////////////////////////////
12 : class Inet4MulticastAgentRouteTable : public AgentRouteTable {
13 : public:
14 74 : Inet4MulticastAgentRouteTable(DB *db, const std::string &name) :
15 : AgentRouteTable(db, name),
16 74 : walkid_(DBTableWalker::kInvalidWalkerId) { };
17 148 : virtual ~Inet4MulticastAgentRouteTable() { };
18 : virtual AgentSandeshPtr GetAgentSandesh(const AgentSandeshArguments *args,
19 : const std::string &context);
20 : // Nexthop will be stored in path as localvmpeer so that it falls in line
21 : // Override virtual routines for no action w.r.t. multicast
22 0 : virtual string GetTableName() const {
23 0 : return "Inet4MulticastAgentRouteTable";
24 : }
25 348 : virtual Agent::RouteTableType GetTableType() const {
26 348 : return Agent::INET4_MULTICAST;
27 : }
28 :
29 : void McRtRouteNotifyDone(DBTableBase *base, DBState *);
30 : void AddVHostRecvRoute(const string &vm_vrf,
31 : const string &interface_name,
32 : const Ip4Address &addr,
33 : bool policy);
34 : Inet4MulticastRouteEntry *FindRoute(const Ip4Address &grp_addr,
35 : const Ip4Address &src_addr);
36 : static DBTableBase *CreateTable(DB *db, const std::string &name);
37 : static void AddMulticastRoute(const string &vn_name, const string &vrf_name,
38 : const Ip4Address &src_addr,
39 : const Ip4Address &grp_addr,
40 : ComponentNHKeyList &component_nh_key_list);
41 : static void AddMulticastRoute(const Peer *peer,
42 : const string &vrf_name,
43 : const Ip4Address &src_addr,
44 : const Ip4Address &grp_addr,
45 : uint32_t ethernet_tag,
46 : AgentRouteData *data);
47 : static void DeleteMulticastRoute(const string &vrf_name,
48 : const Ip4Address &src_addr,
49 : const Ip4Address &grp_addr);
50 : static void DeleteMulticastRoute(const Peer *peer,
51 : const string &vrf_name,
52 : const Ip4Address &src_addr,
53 : const Ip4Address &grp_addr,
54 : uint32_t ethernet_tag,
55 : COMPOSITETYPE type);
56 : static void Delete(const string &vrf_name, const Ip4Address &src_addr,
57 : const Ip4Address &grp_addr);
58 : private:
59 : DBTableWalker::WalkId walkid_;
60 : DISALLOW_COPY_AND_ASSIGN(Inet4MulticastAgentRouteTable);
61 : };
62 :
63 : class Inet4MulticastRouteEntry : public AgentRoute {
64 : public:
65 0 : Inet4MulticastRouteEntry(VrfEntry *vrf, const Ip4Address &dst,
66 0 : const Ip4Address &src) :
67 0 : AgentRoute(vrf, true), dst_addr_(dst), src_addr_(src) {
68 0 : }
69 0 : virtual ~Inet4MulticastRouteEntry() { }
70 :
71 : virtual int CompareTo(const Route &rhs) const;
72 : virtual string ToString() const;
73 : virtual KeyPtr GetDBRequestKey() const;
74 : virtual void SetKey(const DBRequestKey *key);
75 : virtual bool ReComputePathAdd(AgentPath *path);
76 : virtual bool ReComputePathDeletion(AgentPath *path);
77 0 : virtual const string GetAddressString() const {
78 0 : return dst_addr_.to_string();
79 : }
80 0 : virtual const string GetSourceAddressString() const {
81 0 : return src_addr_.to_string();
82 : }
83 : virtual bool DBEntrySandesh(Sandesh *sresp, bool stale) const;
84 0 : virtual Agent::RouteTableType GetTableType() const {
85 0 : return Agent::INET4_MULTICAST;
86 : }
87 : bool DBEntrySandesh(Sandesh *sresp, const Ip4Address &src_addr,
88 : const Ip4Address &dst_addr, bool stale) const;
89 :
90 0 : void set_dest_ip_addr(const Ip4Address &dst) {dst_addr_ = dst;}
91 0 : void set_src_ip_addr(const Ip4Address &src) {src_addr_ = src;}
92 0 : const Ip4Address &src_ip_addr() const {return src_addr_;}
93 0 : const Ip4Address &dest_ip_addr() const {return dst_addr_;}
94 0 : virtual Composite::Type GetMulticastCompType() { return Composite::L3COMP; }
95 :
96 : private:
97 : Ip4Address dst_addr_;
98 : Ip4Address src_addr_;
99 : DISALLOW_COPY_AND_ASSIGN(Inet4MulticastRouteEntry);
100 : };
101 :
102 : class Inet4MulticastRouteKey : public AgentRouteKey {
103 : public:
104 0 : Inet4MulticastRouteKey(const Peer *peer, const string &vrf_name,
105 : const Ip4Address &dip,
106 : const Ip4Address &sip,
107 0 : uint32_t ethernet_tag) :
108 : AgentRouteKey(peer, vrf_name),
109 0 : dip_(dip), sip_(sip), ethernet_tag_(ethernet_tag) {
110 0 : }
111 0 : Inet4MulticastRouteKey(const string &vrf_name,const Ip4Address &dip,
112 0 : const Ip4Address &sip) :
113 : AgentRouteKey(Agent::GetInstance()->multicast_peer(), vrf_name),
114 0 : dip_(dip), sip_(sip) {
115 0 : ethernet_tag_ = 0;
116 0 : }
117 0 : Inet4MulticastRouteKey(const string &vrf_name, const Ip4Address &dip) :
118 : AgentRouteKey(Agent::GetInstance()->multicast_peer(), vrf_name),
119 0 : dip_(dip) {
120 0 : boost::system::error_code ec;
121 0 : sip_ = IpAddress::from_string("0.0.0.0", ec).to_v4();
122 0 : ethernet_tag_ = 0;
123 0 : }
124 : Inet4MulticastRouteKey(const string &vrf_name) :
125 : AgentRouteKey(Agent::GetInstance()->multicast_peer(), vrf_name) {
126 : boost::system::error_code ec;
127 : dip_ = IpAddress::from_string("255.255.255.255", ec).to_v4();
128 : sip_ = IpAddress::from_string("0.0.0.0", ec).to_v4();
129 : ethernet_tag_ = 0;
130 : }
131 0 : virtual ~Inet4MulticastRouteKey() { }
132 : virtual AgentRoute *AllocRouteEntry(VrfEntry *vrf, bool is_multicast) const;
133 0 : virtual Agent::RouteTableType GetRouteTableType() {
134 0 : return Agent::INET4_MULTICAST;
135 : }
136 : virtual AgentRouteKey *Clone() const;
137 : virtual string ToString() const;
138 :
139 0 : const Ip4Address &dest_ip_addr() const {return dip_;}
140 0 : const Ip4Address &src_ip_addr() const {return sip_;}
141 :
142 : private:
143 : Ip4Address dip_;
144 : Ip4Address sip_;
145 : uint32_t ethernet_tag_;
146 : DISALLOW_COPY_AND_ASSIGN(Inet4MulticastRouteKey);
147 : };
148 :
149 : #endif // vnsw_inet4_multicast_route_hpp
|