FD.io VPP  v18.04-17-g3a0d853
Vector Packet Processing
bridge_domain_arp_entry_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 
18 namespace VOM {
19 namespace bridge_domain_arp_entry_cmds {
20 
22  uint32_t bd,
23  const mac_address_t& mac,
24  const boost::asio::ip::address& ip_addr)
25  : rpc_cmd(item)
26  , m_bd(bd)
27  , m_mac(mac)
28  , m_ip_addr(ip_addr)
29 {
30 }
31 
32 bool
34 {
35  return ((m_mac == other.m_mac) && (m_ip_addr == other.m_ip_addr) &&
36  (m_bd == other.m_bd));
37 }
38 
39 rc_t
41 {
42  msg_t req(con.ctx(), std::ref(*this));
43 
44  auto& payload = req.get_request().get_payload();
45  payload.bd_id = m_bd;
46  payload.is_add = 1;
47  m_mac.to_bytes(payload.mac_address, 6);
48  to_bytes(m_ip_addr, &payload.is_ipv6, payload.ip_address);
49 
50  VAPI_CALL(req.execute());
51 
52  m_hw_item.set(wait());
53 
54  return rc_t::OK;
55 }
56 
57 std::string
59 {
60  std::ostringstream s;
61  s << "bridge-domain-arp-entry-create: " << m_hw_item.to_string()
62  << " bd:" << m_bd << " mac:" << m_mac.to_string()
63  << " ip:" << m_ip_addr.to_string();
64 
65  return (s.str());
66 }
67 
69  uint32_t bd,
70  const mac_address_t& mac,
71  const boost::asio::ip::address& ip_addr)
72  : rpc_cmd(item)
73  , m_bd(bd)
74  , m_mac(mac)
75  , m_ip_addr(ip_addr)
76 {
77 }
78 
79 bool
81 {
82  return ((m_mac == other.m_mac) && (m_ip_addr == other.m_ip_addr) &&
83  (m_bd == other.m_bd));
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_bd;
93  payload.is_add = 0;
94  m_mac.to_bytes(payload.mac_address, 6);
95  to_bytes(m_ip_addr, &payload.is_ipv6, payload.ip_address);
96 
97  VAPI_CALL(req.execute());
98 
99  wait();
101 
102  return rc_t::OK;
103 }
104 
105 std::string
107 {
108  std::ostringstream s;
109  s << "bridge-domain-arp-entry-delete: " << m_hw_item.to_string()
110  << " bd:" << m_bd << " mac:" << m_mac.to_string()
111  << " ip:" << m_ip_addr.to_string();
112 
113  return (s.str());
114 }
115 
116 }; // namespace bridge_domain_arp_entry
117 }; // namespace VOM
118 
119 /*
120  * fd.io coding-style-patch-verification: ON
121  *
122  * Local Variables:
123  * eval: (c-set-style "mozilla")
124  * End:
125  */
static const rc_t NOOP
The HW write/update action was/has not been attempted.
Definition: types.hpp:107
HW::item< bool > & m_hw_item
A reference to an object&#39;s HW::item that the command will update.
Definition: rpc_cmd.hpp:135
bool operator==(const create_cmd &i) const
Comparison operator - only used for UT.
std::string to_string() const
convert to string format for debug purposes
std::string to_string() const
String conversion.
Definition: types.cpp:151
Error codes that VPP will return during a HW write.
Definition: types.hpp:90
std::string to_string() const
convert to string format for debug purposes
Definition: hw.hpp:160
void to_bytes(const boost::asio::ip::address_v6 &addr, uint8_t *array)
Definition: prefix.cpp:218
A representation of the connection to VPP.
Definition: connection.hpp:33
HW::item< bool > & item()
return the HW item the command updates
Definition: rpc_cmd.hpp:64
A base class for all RPC commands to VPP.
Definition: rpc_cmd.hpp:38
#define VAPI_CALL(_stmt)
Convenince wrapper macro for error handling in VAPI sends.
Definition: types.hpp:29
delete_cmd(HW::item< bool > &item, uint32_t id, const mac_address_t &mac, const boost::asio::ip::address &ip_addr)
Constructor.
A cmd class that deletes a bridge domain ARP entry.
static const rc_t OK
The HW write was successfull.
Definition: types.hpp:112
vapi::Connection & ctx()
Retrun the VAPI context the commands will use.
Definition: connection.cpp:49
void to_bytes(uint8_t *array, uint8_t len) const
Convert to byte array.
Definition: types.cpp:143
The VPP Object Model (VOM) library.
Definition: acl_binding.cpp:19
rc_t issue(connection &con)
Issue the command to VPP/HW.
create_cmd(HW::item< bool > &item, uint32_t id, const mac_address_t &mac, const boost::asio::ip::address &ip_addr)
Constructor.
void set(const rc_t &rc)
Set the HW return code - should only be called from the family of Command objects.
Definition: hw.hpp:124
vapi::Bd_ip_mac_add_del msg_t
convenient typedef
Definition: rpc_cmd.hpp:44
rc_t issue(connection &con)
Issue the command to VPP/HW.
Type def of a Ethernet address.
Definition: types.hpp:298
A command class that creates or updates the bridge domain ARP Entry.
bool operator==(const delete_cmd &i) const
Comparison operator - only used for UT.
std::string to_string() const
convert to string format for debug purposes