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:
7 * http://www.apache.org/licenses/LICENSE-2.0
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.
16 #include "vom/neighbour_cmds.hpp"
17 #include "vom/api_types.hpp"
19 DEFINE_VAPI_MSG_IDS_IP_NEIGHBOR_API_JSON;
22 namespace neighbour_cmds {
23 create_cmd::create_cmd(HW::item<handle_t>& item,
25 const mac_address_t& mac,
26 const boost::asio::ip::address& ip_addr,
27 const neighbour::flags_t& flags)
36 create_cmd::operator==(const create_cmd& other) const
38 return ((m_mac == other.m_mac) && (m_ip_addr == other.m_ip_addr) &&
39 (m_itf == other.m_itf) && (m_flags == other.m_flags));
43 create_cmd::issue(connection& con)
45 msg_t req(con.ctx(), std::ref(*this));
47 auto& payload = req.get_request().get_payload();
49 payload.neighbor.sw_if_index = m_itf.value();
51 to_api(m_mac, payload.neighbor.mac_address);
52 to_api(m_ip_addr, payload.neighbor.ip_address);
53 payload.neighbor.flags = to_api(m_flags);
55 VAPI_CALL(req.execute());
61 create_cmd::to_string() const
64 s << "nieghbour-create: " << m_hw_item.to_string()
65 << " itf:" << m_itf.to_string() << " mac:" << m_mac.to_string()
66 << " ip:" << m_ip_addr.to_string();
71 delete_cmd::delete_cmd(HW::item<handle_t>& item,
73 const mac_address_t& mac,
74 const boost::asio::ip::address& ip_addr,
75 const neighbour::flags_t& flags)
84 delete_cmd::operator==(const delete_cmd& other) const
86 return ((m_mac == other.m_mac) && (m_ip_addr == other.m_ip_addr) &&
87 (m_itf == other.m_itf));
91 delete_cmd::issue(connection& con)
93 msg_t req(con.ctx(), std::ref(*this));
95 auto& payload = req.get_request().get_payload();
97 payload.neighbor.sw_if_index = m_itf.value();
99 to_api(m_mac, payload.neighbor.mac_address);
100 to_api(m_ip_addr, payload.neighbor.ip_address);
101 payload.neighbor.flags = to_api(m_flags);
103 VAPI_CALL(req.execute());
106 m_hw_item.set(rc_t::NOOP);
112 delete_cmd::to_string() const
114 std::ostringstream s;
115 s << "neighbour-delete: " << m_hw_item.to_string()
116 << " itf:" << m_itf.to_string() << " mac:" << m_mac.to_string()
117 << " ip:" << m_ip_addr.to_string();
122 dump_cmd::dump_cmd(const handle_t& hdl, const l3_proto_t& proto)
127 dump_cmd::dump_cmd(const dump_cmd& d)
133 dump_cmd::operator==(const dump_cmd& other) const
139 dump_cmd::issue(connection& con)
141 m_dump.reset(new msg_t(con.ctx(), std::ref(*this)));
143 auto& payload = m_dump->get_request().get_payload();
144 payload.sw_if_index = m_itf.value();
145 payload.af = to_api(m_proto);
147 VAPI_CALL(m_dump->execute());
155 dump_cmd::to_string() const
157 std::ostringstream s;
159 s << "neighbour-dump: " << m_itf.to_string() << " " << m_proto.to_string();
163 } // namespace neighbour_cmds
167 * fd.io coding-style-patch-verification: ON
170 * eval: (c-set-style "mozilla")