VOM: support for pipes
[vpp.git] / extras / vom / vom / interface_span_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_INTERFACE_SPAN_CMDS_H__
17 #define __VOM_INTERFACE_SPAN_CMDS_H__
18
19 #include "vom/dump_cmd.hpp"
20 #include "vom/interface_span.hpp"
21 #include "vom/rpc_cmd.hpp"
22
23 #include <vapi/span.api.vapi.hpp>
24
25 namespace VOM {
26 namespace interface_span_cmds {
27
28 /**
29  * A command class that configures the interface span
30  */
31 class config_cmd
32   : public rpc_cmd<HW::item<bool>, vapi::Sw_interface_span_enable_disable>
33 {
34 public:
35   /**
36    * Constructor
37    */
38   config_cmd(HW::item<bool>& item,
39              const handle_t& itf_from,
40              const handle_t& itf_to,
41              const interface_span::state_t& state);
42
43   /**
44    * Issue the command to VPP/HW
45    */
46   rc_t issue(connection& con);
47   /**
48    * convert to string format for debug purposes
49    */
50   std::string to_string() const;
51
52   /**
53    * Comparison operator - only used for UT
54    */
55   bool operator==(const config_cmd& i) const;
56
57 private:
58   /**
59    * Reference to the interface to be mirrored
60    */
61   const handle_t& m_itf_from;
62   /**
63    * Reference to the interface where the traffic is mirrored
64    */
65   const handle_t& m_itf_to;
66   /**
67    * the state (rx, tx or both) of the interface to be mirrored
68    */
69   const interface_span::state_t& m_state;
70 };
71
72 /**
73  * A cmd class that Unconfigs interface span
74  */
75 class unconfig_cmd
76   : public rpc_cmd<HW::item<bool>, vapi::Sw_interface_span_enable_disable>
77 {
78 public:
79   /**
80    * Constructor
81    */
82   unconfig_cmd(HW::item<bool>& item,
83                const handle_t& itf_from,
84                const handle_t& itf_to);
85
86   /**
87    * Issue the command to VPP/HW
88    */
89   rc_t issue(connection& con);
90   /**
91    * convert to string format for debug purposes
92    */
93   std::string to_string() const;
94
95   /**
96    * Comparison operator - only used for UT
97    */
98   bool operator==(const unconfig_cmd& i) const;
99
100 private:
101   /**
102    * Reference to the interface to be mirrored
103    */
104   const handle_t& m_itf_from;
105   /**
106    * Reference to the interface where the traffic is mirrored
107    */
108   const handle_t& m_itf_to;
109 };
110
111 /**
112  * A cmd class that Dumps all the interface spans
113  */
114 class dump_cmd : public VOM::dump_cmd<vapi::Sw_interface_span_dump>
115 {
116 public:
117   /**
118    * Constructor
119    */
120   dump_cmd();
121   dump_cmd(const dump_cmd& d);
122
123   /**
124    * Issue the command to VPP/HW
125    */
126   rc_t issue(connection& con);
127   /**
128    * convert to string format for debug purposes
129    */
130   std::string to_string() const;
131
132   /**
133    * Comparison operator - only used for UT
134    */
135   bool operator==(const dump_cmd& i) const;
136
137 private:
138   /**
139    * HW reutrn code
140    */
141   HW::item<bool> item;
142 };
143 };
144 };
145
146 /*
147  * fd.io coding-style-patch-verification: ON
148  *
149  * Local Variables:
150  * eval: (c-set-style "mozilla")
151  * End:
152  */
153
154 #endif