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/inspect.hpp"
20 #include "vom/object_base.hpp"
22 #include "vom/prefix.hpp"
23 #include "vom/singular_db.hpp"
27 * A route-domain is a VRF.
28 * creating a route-domain object will construct both an IPv4
31 class route_domain : public object_base
35 * The Key for a route-domain
37 typedef route::table_id_t key_t;
40 * Construct a new object matching the desried state
42 route_domain(route::table_id_t id);
47 route_domain(const route_domain& o);
55 * comparison operator - for UT
57 bool operator==(const route_domain& r) const;
60 * Return the matching 'singular instance'
62 std::shared_ptr<route_domain> singular() const;
65 * Debug print function
67 std::string to_string() const;
72 route::table_id_t table_id() const;
75 * Get the route-domain's key
80 * Find the instnace of the route domain in the OM
82 static std::shared_ptr<route_domain> find(const key_t& temp);
85 * Dump all route-doamin into the stream provided
87 static void dump(std::ostream& os);
90 * Return the sigular instance for the default table
92 static std::shared_ptr<route_domain> get_default();
95 * replay the object to create it in hardware
101 * Class definition for listeners to OM events
103 class event_handler : public OM::listener, public inspect::command_handler
107 virtual ~event_handler() = default;
110 * Handle a populate event
112 void handle_populate(const client_db::key_t& key);
115 * Handle a replay event
117 void handle_replay();
120 * Show the object in the Singular DB
122 void show(std::ostream& os);
125 * Get the sortable Id of the listener
127 dependency_t order() const;
131 * Instance of the event handler to register with OM
133 static event_handler m_evh;
136 * Commit the acculmulated changes into VPP. i.e. to a 'HW" write.
138 void update(const route_domain& obj);
141 * Find or add the instnace of the route domain in the OM
143 static std::shared_ptr<route_domain> find_or_add(const route_domain& temp);
146 * It's the OM class that updates the objects in HW
151 * It's the singular_db class that calls replay()
153 friend class singular_db<route::table_id_t, route_domain>;
156 * Sweep/reap the object if still stale
161 * HW configuration for the result of creating the v4 table
163 HW::item<bool> m_hw_v4;
166 * HW configuration for the result of creating the v6 table
168 HW::item<bool> m_hw_v6;
171 * VPP understands Table-IDs not table names.
172 * The table IDs for V4 and V6 are the same.
174 route::table_id_t m_table_id;
177 * A map of all interfaces key against the interface's name
179 static singular_db<route::table_id_t, route_domain> m_db;
184 * fd.io coding-style-patch-verification: ON
187 * eval: (c-set-style "mozilla")