#include "vom/prefix.hpp"
#include "vom/route.hpp"
#include "vom/route_cmds.hpp"
+#include "vom/mroute_cmds.hpp"
#include "vom/route_domain.hpp"
#include "vom/route_domain_cmds.hpp"
#include "vom/vxlan_tunnel.hpp"
#include "vom/arp_proxy_binding.hpp"
#include "vom/arp_proxy_config_cmds.hpp"
#include "vom/arp_proxy_binding_cmds.hpp"
+#include "vom/igmp_binding.hpp"
+#include "vom/igmp_binding_cmds.hpp"
+#include "vom/igmp_listen.hpp"
+#include "vom/igmp_listen_cmds.hpp"
#include "vom/ip_punt_redirect.hpp"
#include "vom/ip_punt_redirect_cmds.hpp"
#include "vom/ip_unnumbered.hpp"
class MockListener : public interface::event_listener,
public interface::stat_listener
{
- void handle_interface_stat(interface_cmds::stats_enable_cmd *cmd)
+ void handle_interface_stat(const interface& itf)
{
}
- void handle_interface_event(interface_cmds::events_cmd *cmd)
+ void handle_interface_event(std::vector<VOM::interface::event> events)
{
}
};
{
rc = handle_derived<route::ip_route_cmds::delete_cmd>(f_exp, f_act);
}
+ else if (typeid(*f_exp) == typeid(route::ip_mroute_cmds::update_cmd))
+ {
+ rc = handle_derived<route::ip_mroute_cmds::update_cmd>(f_exp, f_act);
+ }
+ else if (typeid(*f_exp) == typeid(route::ip_mroute_cmds::delete_cmd))
+ {
+ rc = handle_derived<route::ip_mroute_cmds::delete_cmd>(f_exp, f_act);
+ }
else if (typeid(*f_exp) == typeid(neighbour_cmds::create_cmd))
{
rc = handle_derived<neighbour_cmds::create_cmd>(f_exp, f_act);
{
rc = handle_derived<arp_proxy_config_cmds::unconfig_cmd>(f_exp, f_act);
}
+ else if (typeid(*f_exp) == typeid(igmp_binding_cmds::bind_cmd))
+ {
+ rc = handle_derived<igmp_binding_cmds::bind_cmd>(f_exp, f_act);
+ }
+ else if (typeid(*f_exp) == typeid(igmp_binding_cmds::unbind_cmd))
+ {
+ rc = handle_derived<igmp_binding_cmds::unbind_cmd>(f_exp, f_act);
+ }
+ else if (typeid(*f_exp) == typeid(igmp_listen_cmds::listen_cmd))
+ {
+ rc = handle_derived<igmp_listen_cmds::listen_cmd>(f_exp, f_act);
+ }
+ else if (typeid(*f_exp) == typeid(igmp_listen_cmds::unlisten_cmd))
+ {
+ rc = handle_derived<igmp_listen_cmds::unlisten_cmd>(f_exp, f_act);
+ }
else if (typeid(*f_exp) == typeid(ip_punt_redirect_cmds::config_cmd))
{
rc = handle_derived<ip_punt_redirect_cmds::config_cmd>(f_exp, f_act);
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));
TRY_CHECK(OM::remove(fyodor));
}
+BOOST_AUTO_TEST_CASE(test_igmp) {
+ VppInit vi;
+ const std::string Isaiah = "IsaiahBerlin";
+ rc_t rc = rc_t::OK;
+
+ boost::asio::ip::address_v4 gaddr = boost::asio::ip::address_v4::from_string("232.0.0.1");
+ boost::asio::ip::address_v4 saddr1 = boost::asio::ip::address_v4::from_string("192.168.0.20");
+ boost::asio::ip::address_v4 saddr2 = boost::asio::ip::address_v4::from_string("192.168.0.30");
+
+ std::string itf3_name = "host3";
+ interface itf3(itf3_name,
+ interface::type_t::AFPACKET,
+ interface::admin_state_t::UP);
+ HW::item<handle_t> hw_ifh(2, rc_t::OK);
+ HW::item<interface::admin_state_t> hw_as_up(interface::admin_state_t::UP, rc_t::OK);
+ ADD_EXPECT(interface_cmds::af_packet_create_cmd(hw_ifh, itf3_name));
+ ADD_EXPECT(interface_cmds::state_change_cmd(hw_as_up, hw_ifh));
+ TRY_CHECK_RC(OM::write(Isaiah, itf3));
+
+ igmp_binding *ib = new igmp_binding(itf3);
+ HW::item<bool> hw_binding(true, rc_t::OK);
+ ADD_EXPECT(igmp_binding_cmds::bind_cmd(hw_binding, hw_ifh.data()));
+ TRY_CHECK_RC(OM::write(Isaiah, *ib));
+
+ igmp_listen::src_addrs_t saddrs = {saddr1, saddr2};
+
+ igmp_listen *il = new igmp_listen(*ib, gaddr, saddrs);
+ HW::item<bool> hw_as_listen(true, rc_t::OK);
+ ADD_EXPECT(igmp_listen_cmds::listen_cmd(hw_as_listen, hw_ifh.data(), gaddr, saddrs));
+ TRY_CHECK_RC(OM::write(Isaiah, *il));
+
+ delete il;
+ delete ib;
+
+ HW::item<interface::admin_state_t> hw_as_down(interface::admin_state_t::DOWN,
+ rc_t::OK);
+ STRICT_ORDER_OFF();
+ ADD_EXPECT(igmp_listen_cmds::unlisten_cmd(hw_as_listen, hw_ifh.data(), gaddr));
+ ADD_EXPECT(igmp_binding_cmds::unbind_cmd(hw_binding, hw_ifh.data()));
+ ADD_EXPECT(interface_cmds::state_change_cmd(hw_as_down, hw_ifh));
+ ADD_EXPECT(interface_cmds::af_packet_delete_cmd(hw_ifh, itf3_name));
+
+ TRY_CHECK(OM::remove(Isaiah));
+}
+
BOOST_AUTO_TEST_CASE(test_arp_proxy) {
VppInit vi;
const std::string kurt = "KurtVonnegut";
ADD_EXPECT(route::ip_route_cmds::update_cmd(hw_route_dvr, 0, pfx_6, {*path_l2}));
TRY_CHECK_RC(OM::write(ian, *route_dvr));
+ /*
+ * a multicast route
+ */
+ route::mprefix_t mpfx_4(boost::asio::ip::address::from_string("232.1.1.1"), 32);
+ route::ip_mroute *mroute_4 = new route::ip_mroute(mpfx_4);
+
+ route::path *mp1 = new route::path(itf1, nh_proto_t::IPV4);
+ route::path *mp2 = new route::path(*itf2, nh_proto_t::IPV4);
+ mroute_4->add(*mp1, route::itf_flags_t::FORWARD);
+ mroute_4->add(*mp1, route::itf_flags_t::ACCEPT);
+ mroute_4->add(*mp2, route::itf_flags_t::FORWARD);
+ HW::item<bool> hw_mroute_4(true, rc_t::OK);
+ ADD_EXPECT(route::ip_mroute_cmds::update_cmd(hw_mroute_4, 0, mpfx_4,
+ *mp1, route::itf_flags_t::FORWARD));
+ ADD_EXPECT(route::ip_mroute_cmds::update_cmd(hw_mroute_4, 0, mpfx_4,
+ *mp2, route::itf_flags_t::FORWARD));
+ ADD_EXPECT(route::ip_mroute_cmds::update_cmd(hw_mroute_4, 0, mpfx_4,
+ *mp1, route::itf_flags_t::ACCEPT));
+ TRY_CHECK_RC(OM::write(ian, *mroute_4));
+
STRICT_ORDER_OFF();
// delete the stack objects that hold references to others
// so the OM::remove is the call that removes the last reference
delete route_dvr;
delete path_l2;
delete ne;
+ delete mroute_4;
+
+ ADD_EXPECT(route::ip_mroute_cmds::delete_cmd(hw_mroute_4, 0, mpfx_4,
+ *mp1, route::itf_flags_t::FORWARD));
+ ADD_EXPECT(route::ip_mroute_cmds::delete_cmd(hw_mroute_4, 0, mpfx_4,
+ *mp2, route::itf_flags_t::FORWARD));
+ ADD_EXPECT(route::ip_mroute_cmds::delete_cmd(hw_mroute_4, 0, mpfx_4,
+ *mp1, route::itf_flags_t::ACCEPT));
+
+ delete mp1;
+ delete mp2;
+
ADD_EXPECT(neighbour_cmds::delete_cmd(hw_neighbour, hw_ifh.data(), mac_n, nh_10));
ADD_EXPECT(route::ip_route_cmds::delete_cmd(hw_route_dvr, 0, pfx_6));
ADD_EXPECT(route::ip_route_cmds::delete_cmd(hw_route_5_2, 1, pfx_5));