27 singular_db<ip_route::key_t, ip_route> ip_route::m_db;
28 singular_db<ip_mroute::key_t, ip_mroute> ip_mroute::m_db;
36 path::special_t::special_t(
int v,
const std::string& s)
37 : enum_base<path::special_t>(v, s)
41 const path::flags_t path::flags_t::NONE(0,
"none");
42 const path::flags_t path::flags_t::DVR((1 << 0),
"dvr");
44 path::flags_t::flags_t(
int v,
const std::string& s)
45 : enum_base<path::flags_t>(v, s)
49 const itf_flags_t itf_flags_t::NONE(0,
"none");
50 const itf_flags_t itf_flags_t::ACCEPT((1 << 1),
"accept");
51 const itf_flags_t itf_flags_t::FORWARD((1 << 2),
"forward");
53 itf_flags_t::itf_flags_t(
int v,
const std::string& s)
54 : enum_base<itf_flags_t>(v, s)
64 , m_interface(nullptr)
79 , m_interface(interface.singular())
81 , m_preference(preference)
94 , m_interface(nullptr)
96 , m_preference(preference)
110 , m_interface(interface.singular())
112 , m_preference(preference)
118 , m_nh_proto(p.m_nh_proto)
122 , m_interface(p.m_interface)
123 , m_weight(p.m_weight)
124 , m_preference(p.m_preference)
131 if (m_nh_proto < p.m_nh_proto)
133 if (m_flags < p.m_flags)
135 if (m_type < p.m_type)
141 if (m_rd && p.m_rd) {
142 if (m_rd->table_id() < p.m_rd->table_id())
144 else if (m_rd->table_id() > p.m_rd->table_id())
149 if (m_interface && !p.m_interface)
151 if (!m_interface && p.m_interface)
153 if (m_interface && p.m_interface) {
154 if (m_interface->handle() < p.m_interface->handle())
156 if (p.m_interface->handle() < m_interface->handle())
176 result &= (*m_rd == *p.m_rd);
177 if (m_interface && !p.m_interface)
179 if (!m_interface && p.m_interface)
181 if (m_interface && p.m_interface)
182 result &= (*m_interface == *p.m_interface);
183 return (result && (m_type == p.m_type) && (m_nh == p.m_nh) &&
184 (m_nh_proto == p.m_nh_proto) && (m_flags == p.m_flags));
190 std::ostringstream s;
194 <<
" flags:" << m_flags.
to_string() <<
" neighbour:" << m_nh.to_string();
196 s <<
" " << m_rd->to_string();
199 s <<
" " << m_interface->to_string();
201 s <<
" weight:" <<
static_cast<int>(m_weight)
202 <<
" preference:" << static_cast<int>(m_preference) <<
"]";
231 std::shared_ptr<route_domain>
237 std::shared_ptr<interface>
274 , m_prefix(r.m_prefix)
302 m_db.release(
key(),
this);
309 return (std::make_pair(m_rd->table_id(), m_prefix));
315 return ((
key() == i.
key()) && (m_paths == i.m_paths));
321 m_paths.insert(path);
351 std::ostringstream s;
352 s <<
"route:[" << m_rd->to_string() <<
", " << m_prefix.
to_string() <<
" [" 367 std::shared_ptr<ip_route>
368 ip_route::find_or_add(
const ip_route& temp)
370 return (m_db.find_or_add(temp.
key(), temp));
373 std::shared_ptr<ip_route>
376 return (m_db.find(k));
379 std::shared_ptr<ip_route>
382 return find_or_add(*
this);
398 ip_route::event_handler::handle_replay()
413 for (
auto l3 : l3s) {
414 std::shared_ptr<ip_route_cmds::dump_cmd>
cmd =
415 std::make_shared<ip_route_cmds::dump_cmd>(it->second.lock()->table_id(),
421 for (
auto& record : *cmd) {
422 auto& payload = record.get_payload();
424 std::shared_ptr<route_domain> rd =
434 for (
unsigned int i = 0;
i < payload.route.n_paths;
i++) {
453 ip_route::event_handler::order()
const 475 , m_mprefix(r.m_mprefix)
491 m_paths.insert(std::make_pair(path, flag));
497 m_db.release(
key(),
this);
503 return (std::make_pair(m_rd->table_id(), m_mprefix));
509 return ((
key() == i.
key()) && (m_paths == i.m_paths));
516 for (
auto& p : m_paths)
518 m_mprefix, p.first, p.second));
527 for (
auto& p : m_paths)
529 m_mprefix, p.first, p.second));
535 std::ostringstream s;
536 s <<
"route:[" << m_rd->to_string() <<
", " << m_mprefix.
to_string() <<
" [" 547 for (
auto& p : m_paths)
549 m_mprefix, p.first, p.second));
553 std::shared_ptr<ip_mroute>
554 ip_mroute::find_or_add(
const ip_mroute& temp)
556 return (m_db.find_or_add(temp.
key(), temp));
559 std::shared_ptr<ip_mroute>
562 return (m_db.find(k));
565 std::shared_ptr<ip_mroute>
568 return find_or_add(*
this);
581 "ip multicast route configurations",
this);
585 ip_mroute::event_handler::handle_replay()
600 for (
auto l3 : l3s) {
601 std::shared_ptr<ip_mroute_cmds::dump_cmd>
cmd =
602 std::make_shared<ip_mroute_cmds::dump_cmd>(
603 it->second.lock()->table_id(), l3);
610 for (
auto& record : *cmd) {
611 auto& payload = record.get_payload();
613 std::shared_ptr<route_domain> rd =
623 for (
unsigned int i = 0;
i < payload.route.n_paths;
i++) {
625 from_api(payload.route.paths[
i].itf_flags));
643 ip_mroute::event_handler::order()
const 657 os <<
"[" << key.first <<
", " << key.second.to_string() <<
"]";
665 os <<
"[" << key.first <<
", " << key.second.to_string() <<
"]";
675 os << k.to_string() <<
" ";
687 os <<
"[" << k.first.to_string() <<
", " << k.second.to_string() <<
"]";
void remove(const path &path)
remove a path.
std::pair< route::table_id_t, mprefix_t > key_t
The key for a route.
static std::shared_ptr< route_domain > find(const key_t &temp)
Find the instnace of the route domain in the OM.
std::shared_ptr< ip_mroute > singular() const
Return the matching 'singular instance'.
A cmd class that deletes a route.
static const special_t STANDARD
A standard path type.
A command class that creates or updates the route.
void db_dump(const DB &db, std::ostream &os)
Print each of the objects in the DB into the stream provided.
std::string to_string() const
convert to string format for debug purposes
const std::string key_t
In the opflex world each entity is known by a URI which can be converted into a string.
std::shared_ptr< route_domain > rd() const
A path for IP or MPLS routes.
static void register_handler(const std::vector< std::string > &cmds, const std::string &help, command_handler *ch)
Register a command handler for inspection.
ip_route(const prefix_t &prefix)
Construct a route in the default table.
static rc_t write()
Write/Execute all commands hitherto enqueued.
rc_t rc() const
Get the HW return code.
static const log_level_t DEBUG
std::string to_string() const
convert to string format for debug purposes
std::string to_string() const
Convert to string for debugging.
const boost::asio::ip::address & nh() const
void add(const path &path)
Add a path.
static const special_t LOCAL
A local/for-us/recieve.
static const special_t DROP
drop path
bool operator==(const path &p) const
comparison operator
bool operator==(const ip_mroute &i) const
Comparison operator.
std::ostream & operator<<(std::ostream &os, const ip_route::key_t &key)
Types belonging to Routing.
void add(const path &path, const itf_flags_t &flag)
static const l3_proto_t IPV4
static const special_t UNREACH
a path will return ICMP unreachables
special_t type() const
Getters.
const key_t key() const
Get the route's key.
uint8_t preference() const
A command class that creates or updates the route.
static const special_t PROHIBIT
a path will return ICMP prohibit
bool operator<(const path &p) const
Less than operator for set insertion.
std::set< path > path_list_t
A path-list is a set of paths.
A representation of an interface in VPP.
std::set< std::pair< path, itf_flags_t > > mpath_list_t
A mpath-list is a set of paths and interface flags.
const std::string & to_string() const
convert to string format for debug purposes
Tables in which entries are added, e.g bridge/route-domains.
static rc_t commit(const client_db::key_t &key, const OBJ &obj)
Make the State in VPP reflect the expressed desired state.
void event_handler(void *tls_async)
static std::shared_ptr< ip_mroute > find(const ip_mroute &temp)
Find the instnace of the route domain in the OM.
dependency_t
There needs to be a strict order in which object types are read from VPP (at boot time) and replayed ...
ip_mroute(const mprefix_t &mprefix)
Construct a route in the default table.
static const rc_t OK
The HW write was successfull.
static void enqueue(cmd *f)
Enqueue A command for execution.
std::string to_string() const
Convert to string for debugging.
A cmd class that deletes a route.
nh_proto_t nh_proto() const
bool operator==(const ip_route &i) const
Comparison operator.
path(special_t special, const nh_proto_t &proto=nh_proto_t::IPV4)
constructor for special paths
static std::shared_ptr< ip_route > find(const ip_route &temp)
Find the instnace of the route domain in the OM.
The VPP Object Model (VOM) library.
void replay(void)
replay the object to create it in hardware
const neighbour::flags_t from_api(vapi_enum_ip_neighbor_flags f)
A representation of a method call to VPP.
static const_iterator_t cbegin()
std::shared_ptr< ip_route > singular() const
Return the matching 'singular instance'.
static void dump(std::ostream &os)
Dump all route-doamin into the stream provided.
void replay(void)
replay the object to create it in hardware
static const_iterator_t cend()
std::shared_ptr< interface > itf() const
std::string to_string() const
convert to string format for debug purposes
static void dump(std::ostream &os)
Dump all route-doamin into the stream provided.
static bool register_listener(listener *listener)
Register a listener of events.
const key_t key() const
Get the route's key.
vl_api_fib_path_nh_proto_t proto
std::pair< route::table_id_t, prefix_t > key_t
The key for a route.