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,
27 : interface::create_cmd<vapi::Vxlan_add_del_tunnel>(item, name)
29 , m_mcast_itf(mcast_itf)
33 create_cmd::operator==(const create_cmd& other) const
35 return (m_ep == other.m_ep);
39 create_cmd::issue(connection& con)
41 msg_t req(con.ctx(), std::ref(*this));
43 auto& payload = req.get_request().get_payload();
46 (uint8_t*)&payload.src_address.af,
47 (uint8_t*)&payload.src_address.un);
49 (uint8_t*)&payload.dst_address.af,
50 (uint8_t*)&payload.dst_address.un);
51 payload.mcast_sw_if_index = m_mcast_itf.value();
52 payload.encap_vrf_id = 0;
53 payload.decap_next_index = ~0;
54 payload.vni = m_ep.vni;
56 VAPI_CALL(req.execute());
60 if (rc_t::OK == m_hw_item.rc()) {
68 create_cmd::to_string() const
71 s << "vxlan-tunnel-create: " << m_hw_item.to_string() << " "
77 delete_cmd::delete_cmd(HW::item<handle_t>& item,
78 const vxlan_tunnel::endpoint_t& ep)
79 : interface::delete_cmd<vapi::Vxlan_add_del_tunnel>(item)
84 delete_cmd::operator==(const delete_cmd& other) const
86 return (m_ep == other.m_ep);
90 delete_cmd::issue(connection& con)
92 msg_t req(con.ctx(), std::ref(*this));
94 auto payload = req.get_request().get_payload();
97 (uint8_t*)&payload.src_address.af,
98 (uint8_t*)&payload.src_address.un);
100 (uint8_t*)&payload.dst_address.af,
101 (uint8_t*)&payload.dst_address.un);
102 payload.mcast_sw_if_index = ~0;
103 payload.encap_vrf_id = 0;
104 payload.decap_next_index = ~0;
105 payload.vni = m_ep.vni;
107 VAPI_CALL(req.execute());
110 m_hw_item.set(rc_t::NOOP);
117 delete_cmd::to_string() const
119 std::ostringstream s;
120 s << "vxlan-tunnel-delete: " << m_hw_item.to_string() << m_ep.to_string();
125 dump_cmd::dump_cmd() {}
128 dump_cmd::operator==(const dump_cmd& other) const
134 dump_cmd::issue(connection& con)
136 m_dump.reset(new msg_t(con.ctx(), std::ref(*this)));
138 auto& payload = m_dump->get_request().get_payload();
139 payload.sw_if_index = ~0;
141 VAPI_CALL(m_dump->execute());
149 dump_cmd::to_string() const
151 return ("Vpp-vxlan_tunnels-Dump");
153 } // namespace vxlan_tunnel_cmds
157 * fd.io coding-style-patch-verification: OFF
160 * eval: (c-set-style "mozilla")