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/vxlan_tunnel.hpp"
18 DEFINE_VAPI_MSG_IDS_VXLAN_API_JSON;
21 vxlan_tunnel::create_cmd::create_cmd(HW::item<handle_t>& item,
22 const std::string& name,
24 : interface::create_cmd<vapi::Vxlan_add_del_tunnel>(item, name)
30 vxlan_tunnel::create_cmd::operator==(const create_cmd& other) const
32 return (m_ep == other.m_ep);
36 vxlan_tunnel::create_cmd::issue(connection& con)
38 msg_t req(con.ctx(), std::ref(*this));
40 auto& payload = req.get_request().get_payload();
43 to_bytes(m_ep.src, &payload.is_ipv6, payload.src_address);
44 to_bytes(m_ep.dst, &payload.is_ipv6, payload.dst_address);
45 payload.mcast_sw_if_index = ~0;
46 payload.encap_vrf_id = 0;
47 payload.decap_next_index = ~0;
48 payload.vni = m_ep.vni;
50 VAPI_CALL(req.execute());
55 interface::add(m_name, m_hw_item);
62 vxlan_tunnel::create_cmd::to_string() const
65 s << "vxlan-tunnel-create: " << m_hw_item.to_string() << m_ep.to_string();
70 vxlan_tunnel::delete_cmd::delete_cmd(HW::item<handle_t>& item,
72 : interface::delete_cmd<vapi::Vxlan_add_del_tunnel>(item)
78 vxlan_tunnel::delete_cmd::operator==(const delete_cmd& other) const
80 return (m_ep == other.m_ep);
84 vxlan_tunnel::delete_cmd::issue(connection& con)
86 msg_t req(con.ctx(), std::ref(*this));
88 auto payload = req.get_request().get_payload();
91 to_bytes(m_ep.src, &payload.is_ipv6, payload.src_address);
92 to_bytes(m_ep.dst, &payload.is_ipv6, payload.dst_address);
93 payload.mcast_sw_if_index = ~0;
94 payload.encap_vrf_id = 0;
95 payload.decap_next_index = ~0;
96 payload.vni = m_ep.vni;
98 VAPI_CALL(req.execute());
101 m_hw_item.set(rc_t::NOOP);
103 interface::remove(m_hw_item);
108 vxlan_tunnel::delete_cmd::to_string() const
110 std::ostringstream s;
111 s << "vxlan-tunnel-delete: " << m_hw_item.to_string() << m_ep.to_string();
116 vxlan_tunnel::dump_cmd::dump_cmd()
121 vxlan_tunnel::dump_cmd::operator==(const dump_cmd& other) const
127 vxlan_tunnel::dump_cmd::issue(connection& con)
129 m_dump.reset(new msg_t(con.ctx(), std::ref(*this)));
131 auto& payload = m_dump->get_request().get_payload();
132 payload.sw_if_index = ~0;
134 VAPI_CALL(m_dump->execute());
142 vxlan_tunnel::dump_cmd::to_string() const
144 return ("Vpp-vxlan_tunnels-Dump");
149 * fd.io coding-style-patch-verification: ON
152 * eval: (c-set-style "mozilla")