VOM: mroutes
[vpp.git] / extras / vom / vom / mroute_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_MROUTE_CMDS_H__
17 #define __VOM_MROUTE_CMDS_H__
18
19 #include "vom/dump_cmd.hpp"
20 #include "vom/route.hpp"
21 #include "vom/rpc_cmd.hpp"
22
23 #include <vapi/ip.api.vapi.hpp>
24
25 namespace VOM {
26 namespace route {
27 namespace ip_mroute_cmds {
28
29 /**
30  * A command class that creates or updates the route
31  */
32 class update_cmd : public rpc_cmd<HW::item<bool>, vapi::Ip_mroute_add_del>
33 {
34 public:
35   /**
36    * Constructor
37    */
38   update_cmd(HW::item<bool>& item,
39              table_id_t id,
40              const mprefix_t& mprefix,
41              const path& path,
42              const itf_flags_t& flags);
43
44   /**
45    * Issue the command to VPP/HW
46    */
47   rc_t issue(connection& con);
48
49   /**
50    * convert to string format for debug purposes
51    */
52   std::string to_string() const;
53
54   /**
55    * Comparison operator - only used for UT
56    */
57   bool operator==(const update_cmd& i) const;
58
59 private:
60   route::table_id_t m_id;
61   mprefix_t m_mprefix;
62   const path m_path;
63   const itf_flags_t& m_flags;
64 };
65
66 /**
67  * A cmd class that deletes a route
68  */
69 class delete_cmd : public rpc_cmd<HW::item<bool>, vapi::Ip_mroute_add_del>
70 {
71 public:
72   /**
73    * Constructor
74    */
75   delete_cmd(HW::item<bool>& item,
76              table_id_t id,
77              const mprefix_t& mprefix,
78              const path& path,
79              const itf_flags_t& flags);
80
81   /**
82    * Issue the command to VPP/HW
83    */
84   rc_t issue(connection& con);
85
86   /**
87    * convert to string format for debug purposes
88    */
89   std::string to_string() const;
90
91   /**
92    * Comparison operator - only used for UT
93    */
94   bool operator==(const delete_cmd& i) const;
95
96 private:
97   route::table_id_t m_id;
98   mprefix_t m_mprefix;
99   const path m_path;
100   const itf_flags_t& m_flags;
101 };
102
103 /**
104  * A cmd class that Dumps ipv4 fib
105  */
106 class dump_v4_cmd : public VOM::dump_cmd<vapi::Ip_mfib_dump>
107 {
108 public:
109   /**
110    * Constructor
111    */
112   dump_v4_cmd();
113   dump_v4_cmd(const dump_cmd& d);
114
115   /**
116    * Issue the command to VPP/HW
117    */
118   rc_t issue(connection& con);
119   /**
120    * convert to string format for debug purposes
121    */
122   std::string to_string() const;
123
124   /**
125    * Comparison operator - only used for UT
126    */
127   bool operator==(const dump_v4_cmd& i) const;
128
129 private:
130   /**
131    * HW reutrn code
132    */
133   HW::item<bool> item;
134 };
135
136 /**
137  * A cmd class that Dumps ipv6 fib
138  */
139 class dump_v6_cmd : public VOM::dump_cmd<vapi::Ip6_mfib_dump>
140 {
141 public:
142   /**
143    * Constructor
144    */
145   dump_v6_cmd();
146   dump_v6_cmd(const dump_cmd& d);
147
148   /**
149    * Issue the command to VPP/HW
150    */
151   rc_t issue(connection& con);
152   /**
153    * convert to string format for debug purposes
154    */
155   std::string to_string() const;
156
157   /**
158    * Comparison operator - only used for UT
159    */
160   bool operator==(const dump_v6_cmd& i) const;
161
162 private:
163   /**
164    * HW reutrn code
165    */
166   HW::item<bool> item;
167 };
168
169 }; // namespace ip_mroute_cmds
170 }; // namespace route
171 }; // namespace VOM
172
173 /*
174  * fd.io coding-style-patch-verification: ON
175  *
176  * Local Variables:
177  * eval: (c-set-style "mozilla")
178  * End:
179  */
180
181 #endif