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_cmds.hpp"
18 DEFINE_VAPI_MSG_IDS_VXLAN_API_JSON;
21 namespace vxlan_tunnel_cmds {
23 create_cmd::create_cmd(HW::item<handle_t>& item,
24 const std::string& name,
25 const vxlan_tunnel::endpoint_t& ep)
26 : interface::create_cmd<vapi::Vxlan_add_del_tunnel>(item, name)
32 create_cmd::operator==(const create_cmd& other) const
34 return (m_ep == other.m_ep);
38 create_cmd::issue(connection& con)
40 msg_t req(con.ctx(), std::ref(*this));
42 auto& payload = req.get_request().get_payload();
45 to_bytes(m_ep.src, &payload.is_ipv6, payload.src_address);
46 to_bytes(m_ep.dst, &payload.is_ipv6, payload.dst_address);
47 payload.mcast_sw_if_index = ~0;
48 payload.encap_vrf_id = 0;
49 payload.decap_next_index = ~0;
50 payload.vni = m_ep.vni;
52 VAPI_CALL(req.execute());
64 create_cmd::to_string() const
67 s << "vxlan-tunnel-create: " << m_hw_item.to_string() << m_ep.to_string();
72 delete_cmd::delete_cmd(HW::item<handle_t>& item,
73 const vxlan_tunnel::endpoint_t& ep)
74 : interface::delete_cmd<vapi::Vxlan_add_del_tunnel>(item)
80 delete_cmd::operator==(const delete_cmd& other) const
82 return (m_ep == other.m_ep);
86 delete_cmd::issue(connection& con)
88 msg_t req(con.ctx(), std::ref(*this));
90 auto payload = req.get_request().get_payload();
93 to_bytes(m_ep.src, &payload.is_ipv6, payload.src_address);
94 to_bytes(m_ep.dst, &payload.is_ipv6, payload.dst_address);
95 payload.mcast_sw_if_index = ~0;
96 payload.encap_vrf_id = 0;
97 payload.decap_next_index = ~0;
98 payload.vni = m_ep.vni;
100 VAPI_CALL(req.execute());
103 m_hw_item.set(rc_t::NOOP);
110 delete_cmd::to_string() const
112 std::ostringstream s;
113 s << "vxlan-tunnel-delete: " << m_hw_item.to_string() << m_ep.to_string();
123 dump_cmd::operator==(const dump_cmd& other) const
129 dump_cmd::issue(connection& con)
131 m_dump.reset(new msg_t(con.ctx(), std::ref(*this)));
133 auto& payload = m_dump->get_request().get_payload();
134 payload.sw_if_index = ~0;
136 VAPI_CALL(m_dump->execute());
144 dump_cmd::to_string() const
146 return ("Vpp-vxlan_tunnels-Dump");
148 } // namespace vxlan_tunnel_cmds
152 * fd.io coding-style-patch-verification: ON
155 * eval: (c-set-style "mozilla")