FD.io VPP  v19.01.3-6-g70449b9b9
Vector Packet Processing
arp_proxy_config_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 arp_proxy_config_cmds {
20 
22  const boost::asio::ip::address_v4& low,
23  const boost::asio::ip::address_v4& high)
24  : rpc_cmd(item)
25  , m_low(low)
26  , m_high(high)
27 {
28 }
29 
30 bool
32 {
33  return ((m_low == o.m_low) && (m_high == o.m_high));
34 }
35 
36 rc_t
38 {
39  msg_t req(con.ctx(), std::ref(*this));
40 
41  auto& payload = req.get_request().get_payload();
42  payload.is_add = 1;
43 
44  std::copy_n(std::begin(m_low.to_bytes()), m_low.to_bytes().size(),
45  payload.proxy.low_address);
46  std::copy_n(std::begin(m_high.to_bytes()), m_high.to_bytes().size(),
47  payload.proxy.hi_address);
48 
49  VAPI_CALL(req.execute());
50 
51  wait();
52 
53  return (rc_t::OK);
54 }
55 
56 std::string
58 {
59  std::ostringstream s;
60  s << "ARP-proxy-config: " << m_hw_item.to_string()
61  << " low:" << m_low.to_string() << " high:" << m_high.to_string();
62 
63  return (s.str());
64 }
65 
67  const boost::asio::ip::address_v4& low,
68  const boost::asio::ip::address_v4& high)
69  : rpc_cmd(item)
70  , m_low(low)
71  , m_high(high)
72 {
73 }
74 
75 bool
77 {
78  return ((m_low == o.m_low) && (m_high == o.m_high));
79 }
80 
81 rc_t
83 {
84  msg_t req(con.ctx(), std::ref(*this));
85 
86  auto& payload = req.get_request().get_payload();
87  payload.is_add = 0;
88 
89  std::copy_n(std::begin(m_low.to_bytes()), m_low.to_bytes().size(),
90  payload.proxy.low_address);
91  std::copy_n(std::begin(m_high.to_bytes()), m_high.to_bytes().size(),
92  payload.proxy.hi_address);
93 
94  VAPI_CALL(req.execute());
95 
96  wait();
98 
99  return (rc_t::OK);
100 }
101 
102 std::string
104 {
105  std::ostringstream s;
106  s << "ARP-proxy-unconfig: " << m_hw_item.to_string()
107  << " low:" << m_low.to_string() << " high:" << m_high.to_string();
108 
109  return (s.str());
110 }
111 
112 bool
113 dump_cmd::operator==(const dump_cmd& other) const
114 {
115  return (true);
116 }
117 
118 rc_t
120 {
121  m_dump.reset(new msg_t(con.ctx(), std::ref(*this)));
122 
123  VAPI_CALL(m_dump->execute());
124 
125  wait();
126 
127  return rc_t::OK;
128 }
129 
130 std::string
132 {
133  return ("ARP-proxy-dump");
134 }
135 
136 }; // namesapce cmds
137 }; // namespace VOM
138 
139 /*
140  * fd.io coding-style-patch-verification: ON
141  *
142  * Local Variables:
143  * eval: (c-set-style "mozilla")
144  * End:
145  */
static const rc_t NOOP
The HW write/update action was/has not been attempted.
Definition: types.hpp:104
rc_t issue(connection &con)
Issue the command to VPP/HW.
config_cmd(HW::item< bool > &item, const boost::asio::ip::address_v4 &lo, const boost::asio::ip::address_v4 &high)
Constructor.
Error codes that VPP will return during a HW write.
Definition: types.hpp:89
rc_t issue(connection &con)
Issue the command to VPP/HW.
rc_t wait()
Wait on the commands promise.
Definition: rpc_cmd.hpp:82
std::string to_string() const
convert to string format for debug purposes
Definition: hw.hpp:161
bool operator==(const unconfig_cmd &i) const
Comparison operator - only used for UT.
std::string to_string() const
convert to string format for debug purposes
A representation of the connection to VPP.
Definition: connection.hpp:33
bool operator==(const dump_cmd &i) const
Comparison operator - only used for UT.
A base class for all RPC commands to VPP.
Definition: rpc_cmd.hpp:40
#define VAPI_CALL(_stmt)
Convenince wrapper macro for error handling in VAPI sends.
Definition: types.hpp:29
std::string to_string() const
convert to string format for debug purposes
std::string to_string() const
convert to string format for debug purposes
unconfig_cmd(HW::item< bool > &item, const boost::asio::ip::address_v4 &lo, const boost::asio::ip::address_v4 &hig)
Constructor.
static const rc_t OK
The HW write was successfull.
Definition: types.hpp:109
vapi::Connection & ctx()
Retrun the VAPI context the commands will use.
Definition: connection.cpp:49
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 cmd class that Unconfigs ArpProxy Config from an interface.
A command class that adds the ARP Proxy config.
A cmd class that Dumps all the Proxy ARP configs.
bool operator==(const config_cmd &i) const
Comparison operator - only used for UT.
HW::item< bool > & m_hw_item
A reference to an object&#39;s HW::item that the command will update.
Definition: rpc_cmd.hpp:134
rc_t issue(connection &con)
Issue the command to VPP/HW.
HW::item< bool > & item()
return the HW item the command updates
Definition: rpc_cmd.hpp:66
vapi::Proxy_arp_add_del msg_t
convenient typedef
Definition: rpc_cmd.hpp:46