2 * Copyright (c) 2017 Cisco and/or its affiliates.
3 * Licensed under the Apache License, Version 2.0 (the "License");
4 * you may not use this file except in compliance with the License.
5 * You may obtain a copy of the License at:
7 * http://www.apache.org/licenses/LICENSE-2.0
9 * Unless required by applicable law or agreed to in writing, software
10 * distributed under the License is distributed on an "AS IS" BASIS,
11 * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
12 * See the License for the specific language governing permissions and
13 * limitations under the License.
16 #ifndef __VOM_ROUTE_DOMAIN_H__
17 #define __VOM_ROUTE_DOMAIN_H__
19 #include "vom/object_base.hpp"
21 #include "vom/prefix.hpp"
22 #include "vom/singular_db.hpp"
24 #include <vapi/ip.api.vapi.hpp>
28 * A route-domain is a VRF.
29 * creating a route-domain object will construct both an IPv4
32 class route_domain : public object_base
36 * The Key for a route-domain
38 typedef route::table_id_t key_t;
41 * Construct a new object matching the desried state
43 route_domain(route::table_id_t id);
48 route_domain(const route_domain& o);
56 * Return the matching 'singular instance'
58 std::shared_ptr<route_domain> singular() const;
61 * Debug print function
63 std::string to_string() const;
68 route::table_id_t table_id() const;
71 * Get the route-domain's key
76 * Find the instnace of the route domain in the OM
78 static std::shared_ptr<route_domain> find(const route_domain& temp);
81 * Dump all route-doamin into the stream provided
83 static void dump(std::ostream& os);
86 * Return the sigular instance for the default table
88 static std::shared_ptr<route_domain> get_default();
91 * replay the object to create it in hardware
96 * A command class that creates the IP table
99 : public rpc_cmd<HW::item<bool>, rc_t, vapi::Ip_table_add_del>
105 create_cmd(HW::item<bool>& item, l3_proto_t proto, route::table_id_t id);
108 * Issue the command to VPP/HW
110 rc_t issue(connection& con);
113 * convert to string format for debug purposes
115 std::string to_string() const;
118 * Comparison operator - only used for UT
120 bool operator==(const create_cmd& i) const;
126 route::table_id_t m_id;
129 * L3 protocol of the table
135 * A cmd class that Deletes the IP Table
138 : public rpc_cmd<HW::item<bool>, rc_t, vapi::Ip_table_add_del>
144 delete_cmd(HW::item<bool>& item, l3_proto_t proto, route::table_id_t id);
147 * Issue the command to VPP/HW
149 rc_t issue(connection& con);
152 * convert to string format for debug purposes
154 std::string to_string() const;
157 * Comparison operator - only used for UT
159 bool operator==(const delete_cmd& i) const;
165 route::table_id_t m_id;
168 * L3 protocol of the table
175 * Commit the acculmulated changes into VPP. i.e. to a 'HW" write.
177 void update(const route_domain& obj);
180 * Find or add the instnace of the route domain in the OM
182 static std::shared_ptr<route_domain> find_or_add(const route_domain& temp);
185 * It's the OM class that updates the objects in HW
190 * It's the singular_db class that calls replay()
192 friend class singular_db<route::table_id_t, route_domain>;
195 * Sweep/reap the object if still stale
200 * HW configuration for the result of creating the v4 table
202 HW::item<bool> m_hw_v4;
205 * HW configuration for the result of creating the v6 table
207 HW::item<bool> m_hw_v6;
210 * VPP understands Table-IDs not table names.
211 * The table IDs for V4 and V6 are the same.
213 route::table_id_t m_table_id;
216 * A map of all interfaces key against the interface's name
218 static singular_db<route::table_id_t, route_domain> m_db;
223 * fd.io coding-style-patch-verification: ON
226 * eval: (c-set-style "mozilla")