FD.io VPP  v21.10.1-2-g0a485f517
Vector Packet Processing
route_cmds.hpp
Go to the documentation of this file.
1 /*
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:
6  *
7  * http://www.apache.org/licenses/LICENSE-2.0
8  *
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.
14  */
15 
16 #ifndef __VOM_ROUTE_CMDS_H__
17 #define __VOM_ROUTE_CMDS_H__
18 
19 #include "vom/dump_cmd.hpp"
20 #include "vom/route.hpp"
21 #include "vom/srpc_cmd.hpp"
22 
23 #include <vapi/ip.api.vapi.hpp>
24 
25 namespace VOM {
26 namespace route {
27 namespace ip_route_cmds {
28 
29 /**
30  * A command class that creates or updates the route
31  */
32 class update_cmd : public srpc_cmd<vapi::Ip_route_add_del>
33 {
34 public:
35  /**
36  * Constructor
37  */
39  table_id_t id,
40  const prefix_t& prefix,
41  const path_list_t& pl);
42 
43  /**
44  * Issue the command to VPP/HW
45  */
47 
48  /**
49  * convert to string format for debug purposes
50  */
51  std::string to_string() const;
52 
53  /**
54  * Comparison operator - only used for UT
55  */
56  bool operator==(const update_cmd& i) const;
57 
58 private:
59  route::table_id_t m_id;
60  prefix_t m_prefix;
61  const path_list_t& m_pl;
62 };
63 
64 /**
65  * A cmd class that deletes a route
66  */
67 class delete_cmd : public rpc_cmd<HW::item<handle_t>, vapi::Ip_route_add_del>
68 {
69 public:
70  /**
71  * Constructor
72  */
74 
75  /**
76  * Issue the command to VPP/HW
77  */
79 
80  /**
81  * convert to string format for debug purposes
82  */
83  std::string to_string() const;
84 
85  /**
86  * Comparison operator - only used for UT
87  */
88  bool operator==(const delete_cmd& i) const;
89 
90 private:
91  route::table_id_t m_id;
92  prefix_t m_prefix;
93 };
94 
95 /**
96  * A cmd class that Dumps ip fib routes
97  */
98 class dump_cmd : public VOM::dump_cmd<vapi::Ip_route_dump>
99 {
100 public:
101  /**
102  * Constructor
103  */
105  dump_cmd(const dump_cmd& d);
106 
107  /**
108  * Issue the command to VPP/HW
109  */
111  /**
112  * convert to string format for debug purposes
113  */
114  std::string to_string() const;
115 
116  /**
117  * Comparison operator - only used for UT
118  */
119  bool operator==(const dump_cmd& i) const;
120 
121 private:
122  /**
123  * HW reutrn code
124  */
125  HW::item<bool> item;
126  route::table_id_t m_id;
127  const l3_proto_t& m_proto;
128 };
129 
130 }; // namespace ip_route_cmds
131 }; // namespace route
132 }; // namespace VOM
133 
134 /*
135  * fd.io coding-style-patch-verification: OFF
136  *
137  * Local Variables:
138  * eval: (c-set-style "mozilla")
139  * End:
140  */
141 
142 #endif
VOM::route::ip_route_cmds::delete_cmd
A cmd class that deletes a route.
Definition: route_cmds.hpp:67
VOM::route::prefix_t
A prefix defintion.
Definition: prefix.hpp:131
VOM::HW::item< handle_t >
VOM::route::ip_route_cmds::delete_cmd::issue
rc_t issue(connection &con)
Issue the command to VPP/HW.
Definition: route_cmds.cpp:95
VOM
The VPP Object Model (VOM) library.
Definition: acl_binding.cpp:19
VOM::route::ip_route_cmds::dump_cmd::to_string
std::string to_string() const
convert to string format for debug purposes
Definition: route_cmds.cpp:156
VOM::route::path_list_t
std::set< path > path_list_t
A path-list is a set of paths.
Definition: route.hpp:231
VOM::rpc_cmd
A base class for all RPC commands to VPP.
Definition: rpc_cmd.hpp:40
con
Connection con
Definition: vapi_cpp_test.cpp:56
VOM::route::ip_route_cmds::dump_cmd::issue
rc_t issue(connection &con)
Issue the command to VPP/HW.
Definition: route_cmds.cpp:139
VOM::route::ip_route_cmds::update_cmd::issue
rc_t issue(connection &con)
Issue the command to VPP/HW.
Definition: route_cmds.cpp:45
VOM::route::ip_route_cmds::dump_cmd::operator==
bool operator==(const dump_cmd &i) const
Comparison operator - only used for UT.
Definition: route_cmds.cpp:133
route.hpp
VOM::route::ip_route_cmds::update_cmd
A command class that creates or updates the route.
Definition: route_cmds.hpp:32
VOM::connection
A representation of the connection to VPP.
Definition: connection.hpp:33
VOM::route::ip_route_cmds::delete_cmd::to_string
std::string to_string() const
convert to string format for debug purposes
Definition: route_cmds.cpp:117
VOM::route::ip_route_cmds::update_cmd::operator==
bool operator==(const update_cmd &i) const
Comparison operator - only used for UT.
Definition: route_cmds.cpp:38
VOM::route::ip_route_cmds::update_cmd::to_string
std::string to_string() const
convert to string format for debug purposes
Definition: route_cmds.cpp:68
dump_cmd.hpp
VOM::rpc_cmd< HW::item< handle_t >, vapi::Ip_route_add_del >::item
HW::item< handle_t > & item()
return the HW item the command updates
Definition: rpc_cmd.hpp:66
VOM::l3_proto_t
An L3 protocol can be used to construct a prefix that is used to match packets are part of a route.
Definition: prefix.hpp:52
VOM::route::ip_route_cmds::dump_cmd
A cmd class that Dumps ip fib routes.
Definition: route_cmds.hpp:98
VOM::srpc_cmd
Definition: srpc_cmd.hpp:24
VOM::route::ip_route_cmds::update_cmd::update_cmd
update_cmd(HW::item< handle_t > &item, table_id_t id, const prefix_t &prefix, const path_list_t &pl)
Constructor.
Definition: route_cmds.cpp:26
VOM::dump_cmd< vapi::Ip_route_dump >::dump_cmd
dump_cmd()
Default Constructor.
Definition: dump_cmd.hpp:55
i
int i
Definition: flowhash_template.h:376
VOM::route::ip_route_cmds::delete_cmd::operator==
bool operator==(const delete_cmd &i) const
Comparison operator - only used for UT.
Definition: route_cmds.cpp:89
VOM::route::table_id_t
uint32_t table_id_t
type def the table-id
Definition: prefix.hpp:121
VOM::rc_t
Error codes that VPP will return during a HW write.
Definition: types.hpp:89
VOM::dump_cmd
A base class for VPP dump commands.
Definition: dump_cmd.hpp:43
proto
vl_api_ip_proto_t proto
Definition: acl_types.api:51
VOM::route::ip_route_cmds::delete_cmd::delete_cmd
delete_cmd(HW::item< handle_t > &item, table_id_t id, const prefix_t &prefix)
Constructor.
Definition: route_cmds.cpp:79
prefix
vl_api_prefix_t prefix
Definition: ip.api:175
string
const char *const string
Definition: cJSON.h:172
srpc_cmd.hpp