FD.io VPP  v21.10.1-2-g0a485f517
Vector Packet Processing
interface_span_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_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  */
32  : public rpc_cmd<HW::item<bool>, vapi::Sw_interface_span_enable_disable>
33 {
34 public:
35  /**
36  * Constructor
37  */
39  const handle_t& itf_from,
40  const handle_t& itf_to,
42 
43  /**
44  * Issue the command to VPP/HW
45  */
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  */
76  : public rpc_cmd<HW::item<bool>, vapi::Sw_interface_span_enable_disable>
77 {
78 public:
79  /**
80  * Constructor
81  */
83  const handle_t& itf_from,
84  const handle_t& itf_to);
85 
86  /**
87  * Issue the command to VPP/HW
88  */
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  */
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: OFF
148  *
149  * Local Variables:
150  * eval: (c-set-style "mozilla")
151  * End:
152  */
153 
154 #endif
VOM::interface_span_cmds::unconfig_cmd::unconfig_cmd
unconfig_cmd(HW::item< bool > &item, const handle_t &itf_from, const handle_t &itf_to)
Constructor.
Definition: interface_span_cmds.cpp:67
VOM::HW::item< bool >
VOM::interface_span_cmds::config_cmd
A command class that configures the interface span.
Definition: interface_span_cmds.hpp:31
VOM::interface_span_cmds::dump_cmd::issue
rc_t issue(connection &con)
Issue the command to VPP/HW.
Definition: interface_span_cmds.cpp:120
VOM
The VPP Object Model (VOM) library.
Definition: acl_binding.cpp:19
VOM::rpc_cmd
A base class for all RPC commands to VPP.
Definition: rpc_cmd.hpp:40
state
vl_api_dhcp_client_state_t state
Definition: dhcp.api:201
con
Connection con
Definition: vapi_cpp_test.cpp:56
VOM::interface_span_cmds::config_cmd::config_cmd
config_cmd(HW::item< bool > &item, const handle_t &itf_from, const handle_t &itf_to, const interface_span::state_t &state)
Constructor.
Definition: interface_span_cmds.cpp:23
VOM::interface_span_cmds::unconfig_cmd
A cmd class that Unconfigs interface span.
Definition: interface_span_cmds.hpp:75
VOM::interface_span::state_t
The state of the interface - rx/tx or both to be mirrored.
Definition: interface_span.hpp:36
VOM::interface_span_cmds::dump_cmd
A cmd class that Dumps all the interface spans.
Definition: interface_span_cmds.hpp:114
interface_span.hpp
VOM::interface_span_cmds::config_cmd::operator==
bool operator==(const config_cmd &i) const
Comparison operator - only used for UT.
Definition: interface_span_cmds.cpp:34
VOM::connection
A representation of the connection to VPP.
Definition: connection.hpp:33
VOM::interface_span_cmds::unconfig_cmd::to_string
std::string to_string() const
convert to string format for debug purposes
Definition: interface_span_cmds.cpp:101
VOM::handle_t
A type declaration of an interface handle in VPP.
Definition: types.hpp:233
VOM::interface_span_cmds::config_cmd::issue
rc_t issue(connection &con)
Issue the command to VPP/HW.
Definition: interface_span_cmds.cpp:41
dump_cmd.hpp
VOM::rpc_cmd< HW::item< bool >, vapi::Sw_interface_span_enable_disable >::item
HW::item< bool > & item()
return the HW item the command updates
Definition: rpc_cmd.hpp:66
VOM::interface_span_cmds::dump_cmd::to_string
std::string to_string() const
convert to string format for debug purposes
Definition: interface_span_cmds.cpp:135
VOM::interface_span_cmds::dump_cmd::dump_cmd
dump_cmd()
Constructor.
Definition: interface_span_cmds.cpp:111
i
int i
Definition: flowhash_template.h:376
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
VOM::interface_span_cmds::dump_cmd::operator==
bool operator==(const dump_cmd &i) const
Comparison operator - only used for UT.
Definition: interface_span_cmds.cpp:114
VOM::interface_span_cmds::unconfig_cmd::operator==
bool operator==(const unconfig_cmd &i) const
Comparison operator - only used for UT.
Definition: interface_span_cmds.cpp:76
VOM::interface_span_cmds::config_cmd::to_string
std::string to_string() const
convert to string format for debug purposes
Definition: interface_span_cmds.cpp:57
rpc_cmd.hpp
VOM::interface_span_cmds::unconfig_cmd::issue
rc_t issue(connection &con)
Issue the command to VPP/HW.
Definition: interface_span_cmds.cpp:82
string
const char *const string
Definition: cJSON.h:172