create_cmd::create_cmd(HW::item<handle_t>& item,
const std::string& name,
- const vxlan_tunnel::endpoint_t& ep)
+ const vxlan_tunnel::endpoint_t& ep,
+ handle_t mcast_itf)
: interface::create_cmd<vapi::Vxlan_gbp_tunnel_add_del>(item, name)
, m_ep(ep)
+ , m_mcast_itf(mcast_itf)
{
}
to_api(m_ep.src, payload.tunnel.src);
to_api(m_ep.src, payload.tunnel.dst);
- payload.tunnel.mcast_sw_if_index = ~0;
+ payload.tunnel.mcast_sw_if_index = m_mcast_itf.value();
payload.tunnel.encap_table_id = 0;
payload.tunnel.vni = m_ep.vni;
*/
create_cmd(HW::item<handle_t>& item,
const std::string& name,
- const vxlan_tunnel::endpoint_t& ep);
+ const vxlan_tunnel::endpoint_t& ep,
+ handle_t mcast_itf);
/**
* Issue the command to VPP/HW
* Enpoint values of the tunnel to be created
*/
const vxlan_tunnel::endpoint_t m_ep;
+ handle_t m_mcast_itf;
};
/**
interface::admin_state_t::UP)
, m_tep(src, dst, vni)
, m_mode(mode)
+ , m_mcast_itf()
+{
+}
+
+vxlan_tunnel::vxlan_tunnel(const boost::asio::ip::address& src,
+ const boost::asio::ip::address& dst,
+ uint32_t vni,
+ const interface& mcast_itf,
+ const mode_t& mode)
+ : interface(mk_name(src, dst, mode, vni),
+ interface::type_t::VXLAN,
+ interface::admin_state_t::UP)
+ , m_tep(src, dst, vni)
+ , m_mode(mode)
+ , m_mcast_itf(mcast_itf.singular())
{
}
{
if (m_hdl) {
if (mode_t::STANDARD == m_mode)
- HW::enqueue(new vxlan_tunnel_cmds::create_cmd(m_hdl, name(), m_tep));
+ HW::enqueue(new vxlan_tunnel_cmds::create_cmd(
+ m_hdl, name(), m_tep,
+ (m_mcast_itf ? m_mcast_itf->handle() : handle_t::INVALID)));
else if (mode_t::GBP == m_mode)
- HW::enqueue(new vxlan_gbp_tunnel_cmds::create_cmd(m_hdl, name(), m_tep));
+ HW::enqueue(new vxlan_gbp_tunnel_cmds::create_cmd(
+ m_hdl, name(), m_tep,
+ (m_mcast_itf ? m_mcast_itf->handle() : handle_t::INVALID)));
}
}
*/
if (!m_hdl) {
if (mode_t::STANDARD == m_mode)
- HW::enqueue(new vxlan_tunnel_cmds::create_cmd(m_hdl, name(), m_tep));
+ HW::enqueue(new vxlan_tunnel_cmds::create_cmd(
+ m_hdl, name(), m_tep,
+ (m_mcast_itf ? m_mcast_itf->handle() : handle_t::INVALID)));
else if (mode_t::GBP == m_mode)
- HW::enqueue(new vxlan_gbp_tunnel_cmds::create_cmd(m_hdl, name(), m_tep));
+ HW::enqueue(new vxlan_gbp_tunnel_cmds::create_cmd(
+ m_hdl, name(), m_tep,
+ (m_mcast_itf ? m_mcast_itf->handle() : handle_t::INVALID)));
}
}
const boost::asio::ip::address& dst,
uint32_t vni,
const mode_t& mode = mode_t::STANDARD);
-
- /**
- * Construct a new object matching the desried state with a handle
- * read from VPP
- */
- vxlan_tunnel(const handle_t& hdl,
- const boost::asio::ip::address& src,
+ vxlan_tunnel(const boost::asio::ip::address& src,
const boost::asio::ip::address& dst,
uint32_t vni,
+ const interface& mcast_itf,
const mode_t& mode = mode_t::STANDARD);
/*
*/
mode_t m_mode;
+ /**
+ * The interface on which to send the packets if the destination
+ * is multicast
+ */
+ std::shared_ptr<interface> m_mcast_itf;
+
/**
* Construct a unique name for the tunnel
*/
create_cmd::create_cmd(HW::item<handle_t>& item,
const std::string& name,
- const vxlan_tunnel::endpoint_t& ep)
+ const vxlan_tunnel::endpoint_t& ep,
+ handle_t mcast_itf)
: interface::create_cmd<vapi::Vxlan_add_del_tunnel>(item, name)
, m_ep(ep)
+ , m_mcast_itf(mcast_itf)
{
}
payload.is_ipv6 = 0;
to_bytes(m_ep.src, &payload.is_ipv6, payload.src_address);
to_bytes(m_ep.dst, &payload.is_ipv6, payload.dst_address);
- payload.mcast_sw_if_index = ~0;
+ payload.mcast_sw_if_index = m_mcast_itf.value();
payload.encap_vrf_id = 0;
payload.decap_next_index = ~0;
payload.vni = m_ep.vni;
*/
create_cmd(HW::item<handle_t>& item,
const std::string& name,
- const vxlan_tunnel::endpoint_t& ep);
+ const vxlan_tunnel::endpoint_t& ep,
+ handle_t mcast_itf);
/**
* Issue the command to VPP/HW
* Enpoint values of the tunnel to be created
*/
const vxlan_tunnel::endpoint_t m_ep;
+ handle_t m_mcast_itf;
};
/**
vxlan_tunnel vxt(ep.src, ep.dst, ep.vni);
HW::item<handle_t> hw_vxt(3, rc_t::OK);
- ADD_EXPECT(vxlan_tunnel_cmds::create_cmd(hw_vxt, "don't-care", ep));
+ ADD_EXPECT(vxlan_tunnel_cmds::create_cmd(hw_vxt, "don't-care", ep,
+ handle_t::INVALID));
TRY_CHECK_RC(OM::write(franz, vxt));