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.hpp"
19 neighbour::create_cmd::create_cmd(HW::item<bool>& item,
21 const mac_address_t& mac,
22 const boost::asio::ip::address& ip_addr)
31 neighbour::create_cmd::operator==(const create_cmd& other) const
33 return ((m_mac == other.m_mac) && (m_ip_addr == other.m_ip_addr) &&
34 (m_itf == other.m_itf));
38 neighbour::create_cmd::issue(connection& con)
40 msg_t req(con.ctx(), std::ref(*this));
42 auto& payload = req.get_request().get_payload();
43 payload.sw_if_index = m_itf.value();
45 payload.is_static = 1;
46 m_mac.to_bytes(payload.mac_address, 6);
47 to_bytes(m_ip_addr, &payload.is_ipv6, payload.dst_address);
49 VAPI_CALL(req.execute());
51 m_hw_item.set(wait());
57 neighbour::create_cmd::to_string() const
60 s << "nieghbour-create: " << m_hw_item.to_string()
61 << " itf:" << m_itf.to_string() << " mac:" << m_mac.to_string()
62 << " ip:" << m_ip_addr.to_string();
67 neighbour::delete_cmd::delete_cmd(HW::item<bool>& item,
69 const mac_address_t& mac,
70 const boost::asio::ip::address& ip_addr)
79 neighbour::delete_cmd::operator==(const delete_cmd& other) const
81 return ((m_mac == other.m_mac) && (m_ip_addr == other.m_ip_addr) &&
82 (m_itf == other.m_itf));
86 neighbour::delete_cmd::issue(connection& con)
88 msg_t req(con.ctx(), std::ref(*this));
90 auto& payload = req.get_request().get_payload();
91 payload.sw_if_index = m_itf.value();
93 payload.is_static = 1;
94 m_mac.to_bytes(payload.mac_address, 6);
95 to_bytes(m_ip_addr, &payload.is_ipv6, payload.dst_address);
97 VAPI_CALL(req.execute());
100 m_hw_item.set(rc_t::NOOP);
106 neighbour::delete_cmd::to_string() const
108 std::ostringstream s;
109 s << "neighbour-delete: " << m_hw_item.to_string()
110 << " itf:" << m_itf.to_string() << " mac:" << m_mac.to_string()
111 << " ip:" << m_ip_addr.to_string();
116 neighbour::dump_cmd::dump_cmd(const handle_t& hdl, const l3_proto_t& proto)
122 neighbour::dump_cmd::dump_cmd(const dump_cmd& d)
129 neighbour::dump_cmd::operator==(const dump_cmd& other) const
135 neighbour::dump_cmd::issue(connection& con)
137 m_dump.reset(new msg_t(con.ctx(), std::ref(*this)));
139 auto& payload = m_dump->get_request().get_payload();
140 payload.sw_if_index = m_itf.value();
141 payload.is_ipv6 = m_proto.is_ipv6();
143 VAPI_CALL(m_dump->execute());
151 neighbour::dump_cmd::to_string() const
153 return ("neighbour-dump");
158 * fd.io coding-style-patch-verification: ON
161 * eval: (c-set-style "mozilla")