namespace VOM {
+vapi_enum_ip_neighbor_flags
+to_api(const neighbour::flags_t& f)
+{
+ vapi_enum_ip_neighbor_flags out = IP_API_NEIGHBOR_FLAG_NONE;
+
+ if (f & neighbour::flags_t::STATIC)
+ out = static_cast<vapi_enum_ip_neighbor_flags>(out |
+ IP_API_NEIGHBOR_FLAG_STATIC);
+ if (f & neighbour::flags_t::NO_FIB_ENTRY)
+ out = static_cast<vapi_enum_ip_neighbor_flags>(
+ out | IP_API_NEIGHBOR_FLAG_NO_FIB_ENTRY);
+
+ return (out);
+}
+
+const neighbour::flags_t
+from_api(vapi_enum_ip_neighbor_flags f)
+{
+ neighbour::flags_t out = neighbour::flags_t::NONE;
+
+ if (f & IP_API_NEIGHBOR_FLAG_STATIC)
+ out |= neighbour::flags_t::STATIC;
+ if (f & IP_API_NEIGHBOR_FLAG_NO_FIB_ENTRY)
+ out |= neighbour::flags_t::NO_FIB_ENTRY;
+
+ return out;
+}
+
void
to_api(const boost::asio::ip::address_v4& a, vapi_type_ip4_address& v)
{
*/
#include <boost/asio/ip/address.hpp>
+#include <vom/neighbour.hpp>
#include <vom/prefix.hpp>
#include <vom/types.hpp>
typedef boost::asio::ip::address ip_address_t;
+vapi_enum_ip_neighbor_flags to_api(const neighbour::flags_t& f);
+const neighbour::flags_t from_api(vapi_enum_ip_neighbor_flags f);
+
void to_api(const ip_address_t& a, vapi_type_address& v);
void to_api(const boost::asio::ip::address_v4& a, vapi_type_ip4_address& v);
void to_api(const boost::asio::ip::address_v6& a, vapi_type_ip6_address& v);
return (*this);
}
+ /**
+ * bitwise or assignemnt
+ */
+ enum_base& operator|=(const enum_base& e)
+ {
+ m_value += e.m_value;
+ m_desc += ":" + e.m_desc;
+
+ return *this;
+ }
+
+ /**
+ * bitwise or
+ */
+ enum_base operator|(const enum_base& e1) const
+ {
+ enum_base e = *this;
+ e |= e1;
+ return e;
+ }
+
/**
* Comparison operator
*/
singular_db<neighbour::key_t, neighbour> neighbour::m_db;
neighbour::event_handler neighbour::m_evh;
+const neighbour::flags_t neighbour::flags_t::NONE(0, "");
+const neighbour::flags_t neighbour::flags_t::STATIC(1, "static");
+const neighbour::flags_t neighbour::flags_t::NO_FIB_ENTRY(2, "no-fib-entry");
+
+neighbour::flags_t::flags_t(int v, const std::string s)
+ : enum_base(v, s)
+{
+}
+
neighbour::neighbour(const interface& itf,
const boost::asio::ip::address& ip_addr,
- const mac_address_t& mac)
+ const mac_address_t& mac,
+ const flags_t flags)
: m_hw(false)
, m_itf(itf.singular())
, m_ip_addr(ip_addr)
, m_mac(mac)
+ , m_flags(flags)
{
}
-neighbour::neighbour(const neighbour& bde)
- : m_hw(bde.m_hw)
- , m_itf(bde.m_itf)
- , m_ip_addr(bde.m_ip_addr)
- , m_mac(bde.m_mac)
+neighbour::neighbour(const neighbour& n)
+ : m_hw(n.m_hw)
+ , m_itf(n.m_itf)
+ , m_ip_addr(n.m_ip_addr)
+ , m_mac(n.m_mac)
+ , m_flags(n.m_flags)
{
}
neighbour::sweep()
{
if (m_hw) {
- HW::enqueue(
- new neighbour_cmds::delete_cmd(m_hw, m_itf->handle(), m_mac, m_ip_addr));
+ HW::enqueue(new neighbour_cmds::delete_cmd(m_hw, m_itf->handle(), m_mac,
+ m_ip_addr, m_flags));
}
HW::write();
}
neighbour::replay()
{
if (m_hw) {
- HW::enqueue(
- new neighbour_cmds::create_cmd(m_hw, m_itf->handle(), m_mac, m_ip_addr));
+ HW::enqueue(new neighbour_cmds::create_cmd(m_hw, m_itf->handle(), m_mac,
+ m_ip_addr, m_flags));
}
}
{
std::ostringstream s;
s << "neighbour:[" << m_itf->to_string() << ", " << m_mac.to_string() << ", "
- << m_ip_addr.to_string() << "]";
+ << m_ip_addr.to_string() << " " << m_flags.to_string() << "]";
return (s.str());
}
* create the table if it is not yet created
*/
if (rc_t::OK != m_hw.rc()) {
- HW::enqueue(
- new neighbour_cmds::create_cmd(m_hw, m_itf->handle(), m_mac, m_ip_addr));
+ HW::enqueue(new neighbour_cmds::create_cmd(m_hw, m_itf->handle(), m_mac,
+ m_ip_addr, m_flags));
}
}
mac_address_t mac = from_api(payload.neighbor.mac_address);
boost::asio::ip::address ip_addr = from_api(payload.neighbor.ip_address);
- neighbour n(*itf, ip_addr, mac);
+ neighbour::flags_t f = from_api(payload.neighbor.flags);
+ neighbour n(*itf, ip_addr, mac, f);
+ ;
- VOM_LOG(log_level_t::DEBUG) << "neighbour-dump: " << itf->to_string()
- << mac.to_string() << ip_addr.to_string();
+ VOM_LOG(log_level_t::DEBUG) << "neighbour-dump: " << itf->to_string() << " "
+ << mac.to_string() << " " << ip_addr.to_string()
+ << " " << f.to_string();
/*
* Write each of the discovered interfaces into the OM,
class neighbour : public object_base
{
public:
+ struct flags_t : public enum_base<flags_t>
+ {
+ /**
+ * Constructor
+ */
+ flags_t(int v, const std::string s);
+
+ /**
+ * Destructor
+ */
+ ~flags_t() = default;
+
+ flags_t operator|(const flags_t& e1) const
+ {
+ flags_t e = *this;
+ e |= e1;
+ return e;
+ }
+
+ const static flags_t NONE;
+ const static flags_t STATIC;
+ const static flags_t NO_FIB_ENTRY;
+ };
+
/**
* The key for a neighbour entry;
* the interface and IP address
*/
neighbour(const interface& itf,
const boost::asio::ip::address& ip_addr,
- const mac_address_t& mac);
+ const mac_address_t& mac,
+ const flags_t flags = flags_t::STATIC);
/**
* Copy Construct
*/
mac_address_t m_mac;
+ /**
+ * flags on the entry
+ */
+ flags_t m_flags;
+
/**
* A map of all bridge_domains
*/
create_cmd::create_cmd(HW::item<bool>& item,
handle_t itf,
const mac_address_t& mac,
- const boost::asio::ip::address& ip_addr)
+ const boost::asio::ip::address& ip_addr,
+ const neighbour::flags_t& flags)
: rpc_cmd(item)
, m_itf(itf)
, m_mac(mac)
, m_ip_addr(ip_addr)
+ , m_flags(flags)
{
}
create_cmd::operator==(const create_cmd& other) const
{
return ((m_mac == other.m_mac) && (m_ip_addr == other.m_ip_addr) &&
- (m_itf == other.m_itf));
+ (m_itf == other.m_itf) && (m_flags == other.m_flags));
}
rc_t
auto& payload = req.get_request().get_payload();
payload.is_add = 1;
payload.neighbor.sw_if_index = m_itf.value();
- payload.neighbor.flags = IP_API_NEIGHBOR_FLAG_STATIC;
to_api(m_mac, payload.neighbor.mac_address);
to_api(m_ip_addr, payload.neighbor.ip_address);
+ payload.neighbor.flags = to_api(m_flags);
VAPI_CALL(req.execute());
delete_cmd::delete_cmd(HW::item<bool>& item,
handle_t itf,
const mac_address_t& mac,
- const boost::asio::ip::address& ip_addr)
+ const boost::asio::ip::address& ip_addr,
+ const neighbour::flags_t& flags)
: rpc_cmd(item)
, m_itf(itf)
, m_mac(mac)
, m_ip_addr(ip_addr)
+ , m_flags(flags)
{
}
auto& payload = req.get_request().get_payload();
payload.is_add = 0;
payload.neighbor.sw_if_index = m_itf.value();
- payload.neighbor.flags = IP_API_NEIGHBOR_FLAG_STATIC;
to_api(m_mac, payload.neighbor.mac_address);
to_api(m_ip_addr, payload.neighbor.ip_address);
+ payload.neighbor.flags = to_api(m_flags);
VAPI_CALL(req.execute());
create_cmd(HW::item<bool>& item,
handle_t itf,
const mac_address_t& mac,
- const boost::asio::ip::address& ip_addr);
+ const boost::asio::ip::address& ip_addr,
+ const neighbour::flags_t &flags);
/**
* Issue the command to VPP/HW
handle_t m_itf;
mac_address_t m_mac;
boost::asio::ip::address m_ip_addr;
+ const neighbour::flags_t &m_flags;
};
/**
delete_cmd(HW::item<bool>& item,
handle_t itf,
const mac_address_t& mac,
- const boost::asio::ip::address& ip_addr);
+ const boost::asio::ip::address& ip_addr,
+ const neighbour::flags_t &flags);
/**
* Issue the command to VPP/HW
handle_t m_itf;
mac_address_t m_mac;
boost::asio::ip::address m_ip_addr;
+ const neighbour::flags_t &m_flags;
};
/**
ip_r.add(from_vpp(p.path, nh_proto_t::IPV4),
itf_flags_t::from_vpp(p.itf_flags));
}
- VOM_LOG(log_level_t::INFO) << "ip-mroute-dump: " << ip_r.to_string();
+ VOM_LOG(log_level_t::DEBUG) << "ip-mroute-dump: " << ip_r.to_string();
/*
* Write each of the discovered interfaces into the OM,
HW::item<bool> hw_neighbour(true, rc_t::OK);
mac_address_t mac_n({0,1,2,4,5,6});
neighbour *ne = new neighbour(itf1, nh_10, mac_n);
- ADD_EXPECT(neighbour_cmds::create_cmd(hw_neighbour, hw_ifh.data(), mac_n, nh_10));
+ ADD_EXPECT(neighbour_cmds::create_cmd(hw_neighbour, hw_ifh.data(),
+ mac_n, nh_10,
+ neighbour::flags_t::STATIC));
TRY_CHECK_RC(OM::write(ian, *ne));
/*
delete mp1;
delete mp2;
- ADD_EXPECT(neighbour_cmds::delete_cmd(hw_neighbour, hw_ifh.data(), mac_n, nh_10));
+ ADD_EXPECT(neighbour_cmds::delete_cmd(hw_neighbour, hw_ifh.data(),
+ mac_n, nh_10,
+ neighbour::flags_t::STATIC));
ADD_EXPECT(route::ip_route_cmds::delete_cmd(hw_route_dvr, 0, pfx_6, *path_l2));
ADD_EXPECT(route::ip_route_cmds::delete_cmd(hw_route_5_2, 1, pfx_5, *path_11));
ADD_EXPECT(route::ip_route_cmds::delete_cmd(hw_route_5_2, 1, pfx_5, *path_12));