FD.io VPP  v21.10.1-2-g0a485f517
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 
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 
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 
139 {
140  return ("bridge-domain-dump");
141 }
142 }
143 }
144 
145 /*
146  * fd.io coding-style-patch-verification: OFF
147  *
148  * Local Variables:
149  * eval: (c-set-style "mozilla")
150  * End:
151  */
VOM::HW::item< uint32_t >
VOM::bridge_domain::arp_term_mode_t
Bridge Domain ARP termination mode.
Definition: bridge_domain.hpp:57
VOM::dump_cmd< vapi::Bridge_domain_dump >::msg_t
vapi::Bridge_domain_dump msg_t
Definition: dump_cmd.hpp:46
VOM::bridge_domain_cmds::dump_cmd
A cmd class that Dumps all the bridge domains.
Definition: bridge_domain_cmds.hpp:116
VOM::rpc_cmd< HW::item< uint32_t >, vapi::Bridge_domain_add_del >::wait
rc_t wait()
Wait on the commands promise.
Definition: rpc_cmd.hpp:82
VOM::HW::item::set
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
VOM::bridge_domain::arp_ufwd_mode_t
Bridge Domain ARP Unicast Forward mode.
Definition: bridge_domain.hpp:72
VOM
The VPP Object Model (VOM) library.
Definition: acl_binding.cpp:19
VOM::rc_t::OK
const static rc_t OK
The HW write was successfull.
Definition: types.hpp:109
VOM::bridge_domain::flood_mode_t
Bridge Domain flood mode.
Definition: bridge_domain.hpp:102
VOM::bridge_domain_cmds::delete_cmd
A cmd class that Delete an Bridge-Domain.
Definition: bridge_domain_cmds.hpp:89
DEFINE_VAPI_MSG_IDS_L2_API_JSON
DEFINE_VAPI_MSG_IDS_L2_API_JSON
Definition: bridge_domain_cmds.cpp:18
VOM::bridge_domain_cmds::delete_cmd::delete_cmd
delete_cmd(HW::item< uint32_t > &item)
Constructor.
Definition: bridge_domain_cmds.cpp:75
VOM::rpc_cmd
A base class for all RPC commands to VPP.
Definition: rpc_cmd.hpp:40
bridge_domain_cmds.hpp
con
Connection con
Definition: vapi_cpp_test.cpp:56
VOM::rpc_cmd< HW::item< uint32_t >, vapi::Bridge_domain_add_del >::m_hw_item
HW::item< uint32_t > & m_hw_item
A reference to an object's HW::item that the command will update.
Definition: rpc_cmd.hpp:134
VOM::dump_cmd< vapi::Bridge_domain_dump >::m_dump
std::unique_ptr< vapi::Bridge_domain_dump > m_dump
The VAPI event registration.
Definition: dump_cmd.hpp:143
VOM::bridge_domain_cmds::dump_cmd::dump_cmd
dump_cmd()
Constructor.
Definition: bridge_domain_cmds.cpp:112
VOM::enum_base::value
int value() const
Return the value of the enum - same as integer conversion.
Definition: enum_base.hpp:88
VAPI_CALL
#define VAPI_CALL(_stmt)
Convenince wrapper macro for error handling in VAPI sends.
Definition: types.hpp:29
VOM::bridge_domain_cmds::delete_cmd::operator==
bool operator==(const delete_cmd &i) const
Comparison operator - only used for UT.
Definition: bridge_domain_cmds.cpp:81
VOM::connection
A representation of the connection to VPP.
Definition: connection.hpp:33
VOM::bridge_domain_cmds::delete_cmd::to_string
std::string to_string() const
convert to string format for debug purposes
Definition: bridge_domain_cmds.cpp:104
VOM::dump_cmd< vapi::Bridge_domain_dump >::wait
rc_t wait()
Wait for the issue of the command to complete.
Definition: dump_cmd.hpp:93
VOM::bridge_domain_cmds::create_cmd::operator==
bool operator==(const create_cmd &i) const
Comparison operator - only used for UT.
Definition: bridge_domain_cmds.cpp:40
VOM::rc_t::NOOP
const static rc_t NOOP
The HW write/update action was/has not been attempted.
Definition: types.hpp:104
VOM::bridge_domain_cmds::delete_cmd::issue
rc_t issue(connection &con)
Issue the command to VPP/HW.
Definition: bridge_domain_cmds.cpp:87
VOM::HW::item::to_string
std::string to_string() const
convert to string format for debug purposes
Definition: hw.hpp:161
VOM::rpc_cmd< HW::item< uint32_t >, vapi::Bridge_domain_add_del >::msg_t
vapi::Bridge_domain_add_del msg_t
convenient typedef
Definition: rpc_cmd.hpp:46
VOM::HW::item::data
T & data()
Return the data read/written.
Definition: hw.hpp:109
VOM::bridge_domain_cmds::create_cmd::to_string
std::string to_string() const
convert to string format for debug purposes
Definition: bridge_domain_cmds.cpp:67
VOM::bridge_domain_cmds::dump_cmd::issue
rc_t issue(connection &con)
Issue the command to VPP/HW.
Definition: bridge_domain_cmds.cpp:123
VOM::bridge_domain_cmds::create_cmd::issue
rc_t issue(connection &con)
Issue the command to VPP/HW.
Definition: bridge_domain_cmds.cpp:46
VOM::bridge_domain_cmds::dump_cmd::to_string
std::string to_string() const
convert to string format for debug purposes
Definition: bridge_domain_cmds.cpp:138
item
cJSON * item
Definition: cJSON.h:222
VOM::bridge_domain_cmds::create_cmd::create_cmd
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.
Definition: bridge_domain_cmds.cpp:22
VOM::bridge_domain::learning_mode_t
Bridge Domain Learning mode.
Definition: bridge_domain.hpp:42
VOM::rc_t
Error codes that VPP will return during a HW write.
Definition: types.hpp:89
VOM::bridge_domain::uu_flood_mode_t
Bridge Domain Unknown Unicast Flood mode.
Definition: bridge_domain.hpp:117
VOM::bridge_domain_cmds::create_cmd
A command class that creates an Bridge-Domain.
Definition: bridge_domain_cmds.hpp:30
VOM::bridge_domain_cmds::dump_cmd::operator==
bool operator==(const dump_cmd &i) const
Comparison operator - only used for UT.
Definition: bridge_domain_cmds.cpp:117
VOM::bridge_domain::mac_age_mode_t
Bridge Domain MAC aging mode.
Definition: bridge_domain.hpp:87
string
const char *const string
Definition: cJSON.h:172