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/gbp_vxlan_cmds.hpp"
17 #include "vom/api_types.hpp"
20 namespace gbp_vxlan_cmds {
21 create_cmd::create_cmd(HW::item<handle_t>& item,
22 const std::string& name,
23 const boost::asio::ip::address_v4& src,
27 : interface::create_cmd<vapi::Gbp_vxlan_tunnel_add>(item, name)
36 create_cmd::issue(connection& con)
38 msg_t req(con.ctx(), std::ref(*this));
40 auto& payload = req.get_request().get_payload();
42 payload.tunnel.vni = m_vni;
43 payload.tunnel.bd_rd_id = m_bd_rd;
45 payload.tunnel.mode = GBP_VXLAN_TUNNEL_MODE_L2;
47 payload.tunnel.mode = GBP_VXLAN_TUNNEL_MODE_L3;
48 to_api(m_src, payload.tunnel.src);
50 VAPI_CALL(req.execute());
53 if (m_hw_item.rc() == rc_t::OK) {
57 return (m_hw_item.rc());
61 create_cmd::to_string() const
64 s << "gbp-vxlan-create: " << m_hw_item.to_string() << " vni:" << m_vni
65 << " bd/rd:" << m_bd_rd;
70 delete_cmd::delete_cmd(HW::item<handle_t>& item, uint32_t vni)
71 : interface::delete_cmd<vapi::Gbp_vxlan_tunnel_del>(item)
77 delete_cmd::issue(connection& con)
79 msg_t req(con.ctx(), std::ref(*this));
81 auto& payload = req.get_request().get_payload();
84 VAPI_CALL(req.execute());
87 m_hw_item.set(rc_t::NOOP);
94 delete_cmd::to_string() const
97 s << "gbp-vxlan-delete: " << m_hw_item.to_string() << " vni:" << m_vni;
107 dump_cmd::operator==(const dump_cmd& other) const
113 dump_cmd::issue(connection& con)
115 m_dump.reset(new msg_t(con.ctx(), std::ref(*this)));
117 VAPI_CALL(m_dump->execute());
125 dump_cmd::to_string() const
127 return ("gbp-vxlan-dump");
130 } // namespace gbp_vxlan_cmds
134 * fd.io coding-style-patch-verification: ON
137 * eval: (c-set-style "mozilla")