FD.io VPP  v19.08.1-401-g8e4ed521a
Vector Packet Processing
bridge_domain_cmds.cpp
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 
17 
19 
20 namespace VOM {
21 namespace bridge_domain_cmds {
23  const bridge_domain::learning_mode_t& lmode,
24  const bridge_domain::arp_term_mode_t& amode,
25  const bridge_domain::arp_ufwd_mode_t& aumode,
26  const bridge_domain::flood_mode_t& fmode,
27  const bridge_domain::uu_flood_mode_t& uufmode,
28  const bridge_domain::mac_age_mode_t& mmode)
29  : rpc_cmd(item)
30  , m_learning_mode(lmode)
31  , m_arp_term_mode(amode)
32  , m_arp_ufwd_mode(aumode)
33  , m_flood_mode(fmode)
34  , m_uu_flood_mode(uufmode)
35  , m_mac_age_mode(mmode)
36 {
37 }
38 
39 bool
41 {
42  return (m_hw_item.data() == other.m_hw_item.data());
43 }
44 
45 rc_t
47 {
48  msg_t req(con.ctx(), std::ref(*this));
49 
50  auto& payload = req.get_request().get_payload();
51  payload.bd_id = m_hw_item.data();
52  payload.flood = m_flood_mode.value();
53  payload.uu_flood = m_uu_flood_mode.value();
54  payload.forward = 1;
55  payload.learn = m_learning_mode.value();
56  payload.arp_term = m_arp_term_mode.value();
57  payload.arp_ufwd = m_arp_ufwd_mode.value();
58  payload.mac_age = m_mac_age_mode.value();
59  payload.is_add = 1;
60 
61  VAPI_CALL(req.execute());
62 
63  return (wait());
64 }
65 
66 std::string
68 {
69  std::ostringstream s;
70  s << "bridge-domain-create: " << m_hw_item.to_string();
71 
72  return (s.str());
73 }
74 
76  : rpc_cmd(item)
77 {
78 }
79 
80 bool
82 {
83  return (m_hw_item == other.m_hw_item);
84 }
85 
86 rc_t
88 {
89  msg_t req(con.ctx(), std::ref(*this));
90 
91  auto& payload = req.get_request().get_payload();
92  payload.bd_id = m_hw_item.data();
93  payload.is_add = 0;
94 
95  VAPI_CALL(req.execute());
96 
97  wait();
99 
100  return (rc_t::OK);
101 }
102 
103 std::string
105 {
106  std::ostringstream s;
107  s << "bridge-domain-delete: " << m_hw_item.to_string();
108 
109  return (s.str());
110 }
111 
113 {
114 }
115 
116 bool
117 dump_cmd::operator==(const dump_cmd& other) const
118 {
119  return (true);
120 }
121 
122 rc_t
124 {
125  m_dump.reset(new msg_t(con.ctx(), std::ref(*this)));
126 
127  auto& payload = m_dump->get_request().get_payload();
128  payload.bd_id = ~0;
129 
130  VAPI_CALL(m_dump->execute());
131 
132  wait();
133 
134  return rc_t::OK;
135 }
136 
137 std::string
139 {
140  return ("bridge-domain-dump");
141 }
142 }
143 }
144 
145 /*
146  * fd.io coding-style-patch-verification: ON
147  *
148  * Local Variables:
149  * eval: (c-set-style "mozilla")
150  * End:
151  */
static const rc_t NOOP
The HW write/update action was/has not been attempted.
Definition: types.hpp:104
std::string to_string() const
convert to string format for debug purposes
Bridge Domain MAC aging mode.
rc_t issue(connection &con)
Issue the command to VPP/HW.
rc_t issue(connection &con)
Issue the command to VPP/HW.
Error codes that VPP will return during a HW write.
Definition: types.hpp:89
int value() const
Return the value of the enum - same as integer conversion.
Definition: enum_base.hpp:88
T & data()
Return the data read/written.
Definition: hw.hpp:109
std::string to_string() const
convert to string format for debug purposes
Definition: hw.hpp:161
delete_cmd(HW::item< uint32_t > &item)
Constructor.
rc_t issue(connection &con)
Issue the command to VPP/HW.
std::string to_string() const
convert to string format for debug purposes
A representation of the connection to VPP.
Definition: connection.hpp:33
Bridge Domain Unknown Unicast Flood mode.
bool operator==(const create_cmd &i) const
Comparison operator - only used for UT.
bool operator==(const delete_cmd &i) const
Comparison operator - only used for UT.
A cmd class that Dumps all the bridge domains.
A base class for all RPC commands to VPP.
Definition: rpc_cmd.hpp:40
std::string to_string() const
convert to string format for debug purposes
#define VAPI_CALL(_stmt)
Convenince wrapper macro for error handling in VAPI sends.
Definition: types.hpp:29
Bridge Domain ARP termination mode.
bool operator==(const dump_cmd &i) const
Comparison operator - only used for UT.
Bridge Domain Learning mode.
DEFINE_VAPI_MSG_IDS_L2_API_JSON
static const rc_t OK
The HW write was successfull.
Definition: types.hpp:109
Bridge Domain ARP Unicast Forward mode.
vapi::Connection & ctx()
Retrun the VAPI context the commands will use.
Definition: connection.cpp:49
Bridge Domain flood mode.
The VPP Object Model (VOM) library.
Definition: acl_binding.cpp:19
void set(const rc_t &rc)
Set the HW return code - should only be called from the family of Command objects.
Definition: hw.hpp:125
A command class that creates an Bridge-Domain.
A cmd class that Delete an Bridge-Domain.
HW::item< uint32_t > & m_hw_item
A reference to an object&#39;s HW::item that the command will update.
Definition: rpc_cmd.hpp:134
create_cmd(HW::item< uint32_t > &item, const bridge_domain::learning_mode_t &lmode, const bridge_domain::arp_term_mode_t &amode, const bridge_domain::arp_ufwd_mode_t &aumode, const bridge_domain::flood_mode_t &fmode, const bridge_domain::uu_flood_mode_t &uufmode, const bridge_domain::mac_age_mode_t &mmode)
Constructor.
HW::item< uint32_t > & item()
return the HW item the command updates
Definition: rpc_cmd.hpp:66
vapi::Bridge_domain_add_del msg_t
convenient typedef
Definition: rpc_cmd.hpp:46