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"
19 namespace neighbour_cmds {
20 create_cmd::create_cmd(HW::item<bool>& item,
22 const mac_address_t& mac,
23 const boost::asio::ip::address& ip_addr)
32 create_cmd::operator==(const create_cmd& other) const
34 return ((m_mac == other.m_mac) && (m_ip_addr == other.m_ip_addr) &&
35 (m_itf == other.m_itf));
39 create_cmd::issue(connection& con)
41 msg_t req(con.ctx(), std::ref(*this));
43 auto& payload = req.get_request().get_payload();
44 payload.sw_if_index = m_itf.value();
46 payload.is_static = 1;
47 m_mac.to_bytes(payload.mac_address, 6);
48 to_bytes(m_ip_addr, &payload.is_ipv6, payload.dst_address);
50 VAPI_CALL(req.execute());
52 m_hw_item.set(wait());
58 create_cmd::to_string() const
61 s << "nieghbour-create: " << m_hw_item.to_string()
62 << " itf:" << m_itf.to_string() << " mac:" << m_mac.to_string()
63 << " ip:" << m_ip_addr.to_string();
68 delete_cmd::delete_cmd(HW::item<bool>& item,
70 const mac_address_t& mac,
71 const boost::asio::ip::address& ip_addr)
80 delete_cmd::operator==(const delete_cmd& other) const
82 return ((m_mac == other.m_mac) && (m_ip_addr == other.m_ip_addr) &&
83 (m_itf == other.m_itf));
87 delete_cmd::issue(connection& con)
89 msg_t req(con.ctx(), std::ref(*this));
91 auto& payload = req.get_request().get_payload();
92 payload.sw_if_index = m_itf.value();
94 payload.is_static = 1;
95 m_mac.to_bytes(payload.mac_address, 6);
96 to_bytes(m_ip_addr, &payload.is_ipv6, payload.dst_address);
98 VAPI_CALL(req.execute());
101 m_hw_item.set(rc_t::NOOP);
107 delete_cmd::to_string() const
109 std::ostringstream s;
110 s << "neighbour-delete: " << m_hw_item.to_string()
111 << " itf:" << m_itf.to_string() << " mac:" << m_mac.to_string()
112 << " ip:" << m_ip_addr.to_string();
117 dump_cmd::dump_cmd(const handle_t& hdl, const l3_proto_t& proto)
123 dump_cmd::dump_cmd(const dump_cmd& d)
130 dump_cmd::operator==(const dump_cmd& other) const
136 dump_cmd::issue(connection& con)
138 m_dump.reset(new msg_t(con.ctx(), std::ref(*this)));
140 auto& payload = m_dump->get_request().get_payload();
141 payload.sw_if_index = m_itf.value();
142 payload.is_ipv6 = m_proto.is_ipv6();
144 VAPI_CALL(m_dump->execute());
152 dump_cmd::to_string() const
154 return ("neighbour-dump");
156 } // namespace neighbour_cmds
160 * fd.io coding-style-patch-verification: ON
163 * eval: (c-set-style "mozilla")