FD.io VPP  v19.01.2-3-gf61a1a8
Vector Packet Processing
l2_binding_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_L2_BINDING_CMDS_H__
17 #define __VOM_L2_BINDING_CMDS_H__
18 
19 #include "vom/l2_binding.hpp"
20 #include "vom/rpc_cmd.hpp"
21 
22 #include <vapi/l2.api.vapi.hpp>
23 #include <vapi/vpe.api.vapi.hpp>
24 
25 namespace VOM {
26 namespace l2_binding_cmds {
27 
28 /**
29  * A functor class that binds L2 configuration to an interface
30  */
31 class bind_cmd
32  : public rpc_cmd<HW::item<bool>, vapi::Sw_interface_set_l2_bridge>
33 {
34 public:
35  /**
36  * Constructor
37  */
39  const handle_t& itf,
40  uint32_t bd,
41  const l2_binding::l2_port_type_t& port_type);
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 bind_cmd& i) const;
56 
57 private:
58  /**
59  * The interface to bind
60  */
61  const handle_t m_itf;
62 
63  /**
64  * The bridge-domain to bind to
65  */
66  uint32_t m_bd;
67 
68  /**
69  * What is the port type i.e. normal, bvi, uu-fwd that is being bound
70  */
71  const l2_binding::l2_port_type_t& m_port_type;
72 };
73 
74 /**
75  * A cmd class that Unbinds L2 configuration from an interface
76  */
78  : public rpc_cmd<HW::item<bool>, vapi::Sw_interface_set_l2_bridge>
79 {
80 public:
81  /**
82  * Constructor
83  */
85  const handle_t& itf,
86  uint32_t bd,
87  const l2_binding::l2_port_type_t& port_type);
88 
89  /**
90  * Issue the command to VPP/HW
91  */
92  rc_t issue(connection& con);
93  /**
94  * convert to string format for debug purposes
95  */
96  std::string to_string() const;
97 
98  /**
99  * Comparison operator - only used for UT
100  */
101  bool operator==(const unbind_cmd& i) const;
102 
103 private:
104  /**
105  * The interface to bind
106  */
107  const handle_t m_itf;
108 
109  /**
110  * The bridge-domain to bind to
111  */
112  uint32_t m_bd;
113 
114  /**
115  * What is the port type i.e. bvi, normal or uu-fwd that is being bound
116  */
117  const l2_binding::l2_port_type_t& m_port_type;
118 };
119 
120 /**
121  * A cmd class sets the VTR operation
122  */
123 class set_vtr_op_cmd : public rpc_cmd<HW::item<l2_binding::l2_vtr_op_t>,
124  vapi::L2_interface_vlan_tag_rewrite>
125 {
126 public:
127  /**
128  * Constructor
129  */
131  const handle_t& itf,
132  uint16_t tag);
133 
134  /**
135  * Issue the command to VPP/HW
136  */
137  rc_t issue(connection& con);
138 
139  /**
140  * convert to string format for debug purposes
141  */
142  std::string to_string() const;
143 
144  /**
145  * Comparison operator - only used for UT
146  */
147  bool operator==(const set_vtr_op_cmd& i) const;
148 
149 private:
150  /**
151  * The interface to bind
152  */
153  const handle_t m_itf;
154 
155  /**
156  * The tag for the operation
157  */
158  uint16_t m_tag;
159 };
160 
161 }; // namespace l2_binding_cmds
162 }; // namespace VOM
163 
164 /*
165  * fd.io coding-style-patch-verification: ON
166  *
167  * Local Variables:
168  * eval: (c-set-style "mozilla")
169  * End:
170  */
171 
172 #endif
std::string to_string() const
convert to string format for debug purposes
int i
Error codes that VPP will return during a HW write.
Definition: types.hpp:89
A functor class that binds L2 configuration to an interface.
A representation of the connection to VPP.
Definition: connection.hpp:33
A base class for all RPC commands to VPP.
Definition: rpc_cmd.hpp:40
A type declaration of an interface handle in VPP.
Definition: types.hpp:233
A cmd class that Unbinds L2 configuration from an interface.
bool operator==(const bind_cmd &i) const
Comparison operator - only used for UT.
bind_cmd(HW::item< bool > &item, const handle_t &itf, uint32_t bd, const l2_binding::l2_port_type_t &port_type)
Constructor.
The VPP Object Model (VOM) library.
Definition: acl_binding.cpp:19
A cmd class sets the VTR operation.
HW::item< bool > & item()
return the HW item the command updates
Definition: rpc_cmd.hpp:66
rc_t issue(connection &con)
Issue the command to VPP/HW.