fib: fib api updates
[vpp.git] / extras / vom / vom / route_cmds.hpp
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    */
38   update_cmd(HW::item<handle_t>& item,
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    */
46   rc_t issue(connection& con);
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    */
73   delete_cmd(HW::item<handle_t>& item, table_id_t id, const prefix_t& prefix);
74
75   /**
76    * Issue the command to VPP/HW
77    */
78   rc_t issue(connection& con);
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    */
104   dump_cmd(route::table_id_t id, const l3_proto_t& proto);
105   dump_cmd(const dump_cmd& d);
106
107   /**
108    * Issue the command to VPP/HW
109    */
110   rc_t issue(connection& con);
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: ON
136  *
137  * Local Variables:
138  * eval: (c-set-style "mozilla")
139  * End:
140  */
141
142 #endif