FD.io VPP  v21.10.1-2-g0a485f517
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 #include "vom/api_types.hpp"
18 
20 
21 namespace VOM {
22 namespace arp_proxy_config_cmds {
23 
25  const boost::asio::ip::address_v4& low,
26  const boost::asio::ip::address_v4& high)
27  : rpc_cmd(item)
28  , m_low(low)
29  , m_high(high)
30 {}
31 
32 bool
34 {
35  return ((m_low == o.m_low) && (m_high == o.m_high));
36 }
37 
38 rc_t
40 {
41  msg_t req(con.ctx(), std::ref(*this));
42 
43  auto& payload = req.get_request().get_payload();
44  payload.is_add = 1;
45 
46  to_api(m_low, payload.proxy.low);
47  to_api(m_high, payload.proxy.hi);
48 
49  VAPI_CALL(req.execute());
50 
51  wait();
52 
53  return (rc_t::OK);
54 }
55 
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 bool
76 {
77  return ((m_low == o.m_low) && (m_high == o.m_high));
78 }
79 
80 rc_t
82 {
83  msg_t req(con.ctx(), std::ref(*this));
84 
85  auto& payload = req.get_request().get_payload();
86  payload.is_add = 0;
87 
88  to_api(m_low, payload.proxy.low);
89  to_api(m_high, payload.proxy.hi);
90 
91  VAPI_CALL(req.execute());
92 
93  wait();
95 
96  return (rc_t::OK);
97 }
98 
101 {
102  std::ostringstream s;
103  s << "ARP-proxy-unconfig: " << m_hw_item.to_string()
104  << " low:" << m_low.to_string() << " high:" << m_high.to_string();
105 
106  return (s.str());
107 }
108 
109 bool
110 dump_cmd::operator==(const dump_cmd& other) const
111 {
112  return (true);
113 }
114 
115 rc_t
117 {
118  m_dump.reset(new msg_t(con.ctx(), std::ref(*this)));
119 
120  VAPI_CALL(m_dump->execute());
121 
122  wait();
123 
124  return rc_t::OK;
125 }
126 
129 {
130  return ("ARP-proxy-dump");
131 }
132 
133 }; // namesapce cmds
134 }; // namespace VOM
135 
136 /*
137  * fd.io coding-style-patch-verification: OFF
138  *
139  * Local Variables:
140  * eval: (c-set-style "mozilla")
141  * End:
142  */
VOM::HW::item< bool >
DEFINE_VAPI_MSG_IDS_ARP_API_JSON
DEFINE_VAPI_MSG_IDS_ARP_API_JSON
Definition: arp_proxy_config_cmds.cpp:19
VOM::dump_cmd< vapi::Proxy_arp_dump >::msg_t
vapi::Proxy_arp_dump msg_t
Definition: dump_cmd.hpp:46
VOM::rpc_cmd< HW::item< bool >, vapi::Proxy_arp_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
The VPP Object Model (VOM) library.
Definition: acl_binding.cpp:19
VOM::arp_proxy_config_cmds::config_cmd::config_cmd
config_cmd(HW::item< bool > &item, const boost::asio::ip::address_v4 &lo, const boost::asio::ip::address_v4 &high)
Constructor.
Definition: arp_proxy_config_cmds.cpp:24
VOM::rc_t::OK
const static rc_t OK
The HW write was successfull.
Definition: types.hpp:109
VOM::arp_proxy_config_cmds::config_cmd::issue
rc_t issue(connection &con)
Issue the command to VPP/HW.
Definition: arp_proxy_config_cmds.cpp:39
VOM::rpc_cmd
A base class for all RPC commands to VPP.
Definition: rpc_cmd.hpp:40
VOM::arp_proxy_config_cmds::config_cmd::to_string
std::string to_string() const
convert to string format for debug purposes
Definition: arp_proxy_config_cmds.cpp:57
con
Connection con
Definition: vapi_cpp_test.cpp:56
VOM::arp_proxy_config_cmds::dump_cmd::issue
rc_t issue(connection &con)
Issue the command to VPP/HW.
Definition: arp_proxy_config_cmds.cpp:116
VOM::arp_proxy_config_cmds::unconfig_cmd::issue
rc_t issue(connection &con)
Issue the command to VPP/HW.
Definition: arp_proxy_config_cmds.cpp:81
VOM::arp_proxy_config_cmds::dump_cmd
A cmd class that Dumps all the Proxy ARP configs.
Definition: arp_proxy_config_cmds.hpp:100
VOM::rpc_cmd< HW::item< bool >, vapi::Proxy_arp_add_del >::m_hw_item
HW::item< bool > & 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::Proxy_arp_dump >::m_dump
std::unique_ptr< vapi::Proxy_arp_dump > m_dump
The VAPI event registration.
Definition: dump_cmd.hpp:143
VAPI_CALL
#define VAPI_CALL(_stmt)
Convenince wrapper macro for error handling in VAPI sends.
Definition: types.hpp:29
VOM::arp_proxy_config_cmds::unconfig_cmd::operator==
bool operator==(const unconfig_cmd &i) const
Comparison operator - only used for UT.
Definition: arp_proxy_config_cmds.cpp:75
VOM::arp_proxy_config_cmds::unconfig_cmd::unconfig_cmd
unconfig_cmd(HW::item< bool > &item, const boost::asio::ip::address_v4 &lo, const boost::asio::ip::address_v4 &hig)
Constructor.
Definition: arp_proxy_config_cmds.cpp:66
VOM::connection
A representation of the connection to VPP.
Definition: connection.hpp:33
VOM::dump_cmd< vapi::Proxy_arp_dump >::wait
rc_t wait()
Wait for the issue of the command to complete.
Definition: dump_cmd.hpp:93
VOM::arp_proxy_config_cmds::dump_cmd::operator==
bool operator==(const dump_cmd &i) const
Comparison operator - only used for UT.
Definition: arp_proxy_config_cmds.cpp:110
VOM::rc_t::NOOP
const static rc_t NOOP
The HW write/update action was/has not been attempted.
Definition: types.hpp:104
low
vl_api_ip4_address_t low
Definition: arp.api:36
VOM::arp_proxy_config_cmds::dump_cmd::to_string
std::string to_string() const
convert to string format for debug purposes
Definition: arp_proxy_config_cmds.cpp:128
VOM::HW::item::to_string
std::string to_string() const
convert to string format for debug purposes
Definition: hw.hpp:161
VOM::arp_proxy_config_cmds::config_cmd
A command class that adds the ARP Proxy config.
Definition: arp_proxy_config_cmds.hpp:30
VOM::arp_proxy_config_cmds::unconfig_cmd::to_string
std::string to_string() const
convert to string format for debug purposes
Definition: arp_proxy_config_cmds.cpp:100
VOM::to_api
vapi_enum_ip_neighbor_flags to_api(const neighbour::flags_t &f)
Definition: api_types.cpp:21
VOM::rpc_cmd< HW::item< bool >, vapi::Proxy_arp_add_del >::msg_t
vapi::Proxy_arp_add_del msg_t
convenient typedef
Definition: rpc_cmd.hpp:46
item
cJSON * item
Definition: cJSON.h:222
VOM::arp_proxy_config_cmds::unconfig_cmd
A cmd class that Unconfigs ArpProxy Config from an interface.
Definition: arp_proxy_config_cmds.hpp:65
VOM::arp_proxy_config_cmds::config_cmd::operator==
bool operator==(const config_cmd &i) const
Comparison operator - only used for UT.
Definition: arp_proxy_config_cmds.cpp:33
VOM::rc_t
Error codes that VPP will return during a HW write.
Definition: types.hpp:89
arp_proxy_config_cmds.hpp
api_types.hpp
string
const char *const string
Definition: cJSON.h:172