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_bridge_domain_cmds.hpp"
19 namespace gbp_bridge_domain_cmds {
21 create_cmd::create_cmd(HW::item<uint32_t>& item,
24 const handle_t uu_fwd,
25 const handle_t bm_flood,
26 const gbp_bridge_domain::flags_t& flags)
31 , m_bm_flood(bm_flood)
37 create_cmd::operator==(const create_cmd& other) const
39 return ((m_hw_item.data() == other.m_hw_item.data()) &&
40 (m_rd_id == other.m_rd_id) && (m_bvi == other.m_bvi) &&
41 (m_uu_fwd == other.m_uu_fwd) && (m_bm_flood == other.m_bm_flood) &&
42 (m_flags == other.m_flags));
46 create_cmd::issue(connection& con)
48 msg_t req(con.ctx(), std::ref(*this));
50 auto& payload = req.get_request().get_payload();
52 payload.bd.bd_id = m_hw_item.data();
53 payload.bd.rd_id = m_rd_id;
54 payload.bd.bvi_sw_if_index = m_bvi.value();
55 payload.bd.uu_fwd_sw_if_index = m_uu_fwd.value();
56 payload.bd.bm_flood_sw_if_index = m_bm_flood.value();
58 vapi_enum_gbp_bridge_domain_flags flags = GBP_BD_API_FLAG_NONE;
59 if (gbp_bridge_domain::flags_t::DO_NOT_LEARN & m_flags)
60 flags = static_cast<vapi_enum_gbp_bridge_domain_flags>(
61 flags | GBP_BD_API_FLAG_DO_NOT_LEARN);
62 if (gbp_bridge_domain::flags_t::UU_FWD_DROP & m_flags)
63 flags = static_cast<vapi_enum_gbp_bridge_domain_flags>(
64 flags | GBP_BD_API_FLAG_UU_FWD_DROP);
65 if (gbp_bridge_domain::flags_t::MCAST_DROP & m_flags)
66 flags = static_cast<vapi_enum_gbp_bridge_domain_flags>(
67 flags | GBP_BD_API_FLAG_MCAST_DROP);
68 if (gbp_bridge_domain::flags_t::UCAST_ARP & m_flags)
69 flags = static_cast<vapi_enum_gbp_bridge_domain_flags>(
70 flags | GBP_BD_API_FLAG_UCAST_ARP);
72 payload.bd.flags = flags;
73 VAPI_CALL(req.execute());
79 create_cmd::to_string() const
82 s << "gbp-bridge-domain: " << m_hw_item.to_string()
83 << " flags:" << m_flags.to_string() << " bvi:" << m_bvi.to_string()
84 << " uu-fwd:" << m_uu_fwd.to_string();
89 delete_cmd::delete_cmd(HW::item<uint32_t>& item)
95 delete_cmd::operator==(const delete_cmd& other) const
97 return (m_hw_item.data() == other.m_hw_item.data());
101 delete_cmd::issue(connection& con)
103 msg_t req(con.ctx(), std::ref(*this));
105 auto& payload = req.get_request().get_payload();
107 payload.bd_id = m_hw_item.data();
109 VAPI_CALL(req.execute());
112 m_hw_item.set(rc_t::NOOP);
118 delete_cmd::to_string() const
120 std::ostringstream s;
121 s << "gbp-bridge-domain: " << m_hw_item.to_string();
127 dump_cmd::operator==(const dump_cmd& other) const
133 dump_cmd::issue(connection& con)
135 m_dump.reset(new msg_t(con.ctx(), std::ref(*this)));
137 VAPI_CALL(m_dump->execute());
145 dump_cmd::to_string() const
147 return ("gbp-bridge-domain-dump");
150 }; // namespace gbp_bridge_domain_cmds
154 * fd.io coding-style-patch-verification: ON
157 * eval: (c-set-style "mozilla")