aboutsummaryrefslogtreecommitdiffstats
path: root/extras/vom
diff options
context:
space:
mode:
Diffstat (limited to 'extras/vom')
-rw-r--r--extras/vom/vom/api_types.cpp31
-rw-r--r--extras/vom/vom/api_types.hpp6
-rw-r--r--extras/vom/vom/arp_proxy_config.cpp5
-rw-r--r--extras/vom/vom/arp_proxy_config_cmds.cpp13
-rw-r--r--extras/vom/vom/neighbour.cpp6
-rw-r--r--extras/vom/vom/neighbour_cmds.cpp19
-rw-r--r--extras/vom/vom/ra_prefix.cpp5
7 files changed, 56 insertions, 29 deletions
diff --git a/extras/vom/vom/api_types.cpp b/extras/vom/vom/api_types.cpp
index 4a81a41daa9..486ebdacb6d 100644
--- a/extras/vom/vom/api_types.cpp
+++ b/extras/vom/vom/api_types.cpp
@@ -18,6 +18,17 @@
namespace VOM {
void
+to_api(const boost::asio::ip::address_v4& a, vapi_type_ip4_address& v)
+{
+ std::copy_n(std::begin(a.to_bytes()), a.to_bytes().size(), v);
+}
+void
+to_api(const boost::asio::ip::address_v6& a, vapi_type_ip6_address& v)
+{
+ std::copy_n(std::begin(a.to_bytes()), a.to_bytes().size(), v);
+}
+
+void
to_api(const ip_address_t& a, vapi_type_address& v)
{
if (a.is_v4()) {
@@ -43,10 +54,24 @@ to_api(const ip_address_t& a,
}
}
-void
-to_api(const boost::asio::ip::address& a, vapi_type_ip4_address& v)
+boost::asio::ip::address_v6
+from_api(const vapi_type_ip6_address& v)
+{
+ std::array<uint8_t, 16> a;
+ std::copy(v, v + 16, std::begin(a));
+ boost::asio::ip::address_v6 v6(a);
+
+ return v6;
+}
+
+boost::asio::ip::address_v4
+from_api(const vapi_type_ip4_address& v)
{
- memcpy(v, a.to_v4().to_bytes().data(), 4);
+ std::array<uint8_t, 4> a;
+ std::copy(v, v + 4, std::begin(a));
+ boost::asio::ip::address_v4 v4(a);
+
+ return v4;
}
ip_address_t
diff --git a/extras/vom/vom/api_types.hpp b/extras/vom/vom/api_types.hpp
index 5856c22d339..ac9a65e84af 100644
--- a/extras/vom/vom/api_types.hpp
+++ b/extras/vom/vom/api_types.hpp
@@ -24,13 +24,15 @@ namespace VOM {
typedef boost::asio::ip::address ip_address_t;
void to_api(const ip_address_t& a, vapi_type_address& v);
-void to_api(const boost::asio::ip::address& a, vapi_type_ip4_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);
void to_api(const boost::asio::ip::address& a,
vapi_union_address_union& u,
vapi_enum_address_family& af);
+boost::asio::ip::address_v4 from_api(const vapi_type_ip4_address& v);
+boost::asio::ip::address_v6 from_api(const vapi_type_ip6_address& v);
ip_address_t from_api(const vapi_type_address& v);
-ip_address_t from_api(const vapi_type_ip4_address& v);
ip_address_t from_api(const vapi_union_address_union& u,
vapi_enum_address_family af);
diff --git a/extras/vom/vom/arp_proxy_config.cpp b/extras/vom/vom/arp_proxy_config.cpp
index 275d9f9bf74..e21fd4a97b2 100644
--- a/extras/vom/vom/arp_proxy_config.cpp
+++ b/extras/vom/vom/arp_proxy_config.cpp
@@ -14,6 +14,7 @@
*/
#include "vom/arp_proxy_config.hpp"
+#include "vom/api_types.hpp"
#include "vom/arp_proxy_config_cmds.hpp"
#include "vom/prefix.hpp"
#include "vom/singular_db_funcs.hpp"
@@ -125,8 +126,8 @@ arp_proxy_config::event_handler::handle_populate(const client_db::key_t& key)
for (auto& record : *cmd) {
auto& payload = record.get_payload();
- boost::asio::ip::address lo = from_bytes(0, payload.proxy.low_address);
- boost::asio::ip::address hi = from_bytes(0, payload.proxy.hi_address);
+ boost::asio::ip::address lo = from_api(payload.proxy.low);
+ boost::asio::ip::address hi = from_api(payload.proxy.hi);
arp_proxy_config ap(lo.to_v4(), hi.to_v4());
OM::commit(key, ap);
diff --git a/extras/vom/vom/arp_proxy_config_cmds.cpp b/extras/vom/vom/arp_proxy_config_cmds.cpp
index deb52c459b7..8185c0910d2 100644
--- a/extras/vom/vom/arp_proxy_config_cmds.cpp
+++ b/extras/vom/vom/arp_proxy_config_cmds.cpp
@@ -14,6 +14,7 @@
*/
#include "vom/arp_proxy_config_cmds.hpp"
+#include "vom/api_types.hpp"
namespace VOM {
namespace arp_proxy_config_cmds {
@@ -41,10 +42,8 @@ config_cmd::issue(connection& con)
auto& payload = req.get_request().get_payload();
payload.is_add = 1;
- std::copy_n(std::begin(m_low.to_bytes()), m_low.to_bytes().size(),
- payload.proxy.low_address);
- std::copy_n(std::begin(m_high.to_bytes()), m_high.to_bytes().size(),
- payload.proxy.hi_address);
+ to_api(m_low, payload.proxy.low);
+ to_api(m_high, payload.proxy.hi);
VAPI_CALL(req.execute());
@@ -86,10 +85,8 @@ unconfig_cmd::issue(connection& con)
auto& payload = req.get_request().get_payload();
payload.is_add = 0;
- std::copy_n(std::begin(m_low.to_bytes()), m_low.to_bytes().size(),
- payload.proxy.low_address);
- std::copy_n(std::begin(m_high.to_bytes()), m_high.to_bytes().size(),
- payload.proxy.hi_address);
+ to_api(m_low, payload.proxy.low);
+ to_api(m_high, payload.proxy.hi);
VAPI_CALL(req.execute());
diff --git a/extras/vom/vom/neighbour.cpp b/extras/vom/vom/neighbour.cpp
index 44e2760a1ec..cbcebd69f7d 100644
--- a/extras/vom/vom/neighbour.cpp
+++ b/extras/vom/vom/neighbour.cpp
@@ -14,6 +14,7 @@
*/
#include "vom/neighbour.hpp"
+#include "vom/api_types.hpp"
#include "vom/neighbour_cmds.hpp"
#include "vom/singular_db_funcs.hpp"
@@ -165,9 +166,8 @@ neighbour::populate_i(const client_db::key_t& key,
*/
auto& payload = record.get_payload();
- mac_address_t mac(payload.mac_address);
- boost::asio::ip::address ip_addr =
- from_bytes(payload.is_ipv6, payload.ip_address);
+ 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);
VOM_LOG(log_level_t::DEBUG) << "neighbour-dump: " << itf->to_string()
diff --git a/extras/vom/vom/neighbour_cmds.cpp b/extras/vom/vom/neighbour_cmds.cpp
index 9bd32923379..d43e508e1f5 100644
--- a/extras/vom/vom/neighbour_cmds.cpp
+++ b/extras/vom/vom/neighbour_cmds.cpp
@@ -14,6 +14,7 @@
*/
#include "vom/neighbour_cmds.hpp"
+#include "vom/api_types.hpp"
namespace VOM {
namespace neighbour_cmds {
@@ -41,11 +42,12 @@ create_cmd::issue(connection& con)
msg_t req(con.ctx(), std::ref(*this));
auto& payload = req.get_request().get_payload();
- payload.sw_if_index = m_itf.value();
payload.is_add = 1;
- payload.is_static = 1;
- m_mac.to_bytes(payload.mac_address, 6);
- to_bytes(m_ip_addr, &payload.is_ipv6, payload.dst_address);
+ 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);
VAPI_CALL(req.execute());
@@ -87,11 +89,12 @@ delete_cmd::issue(connection& con)
msg_t req(con.ctx(), std::ref(*this));
auto& payload = req.get_request().get_payload();
- payload.sw_if_index = m_itf.value();
payload.is_add = 0;
- payload.is_static = 1;
- m_mac.to_bytes(payload.mac_address, 6);
- to_bytes(m_ip_addr, &payload.is_ipv6, payload.dst_address);
+ 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);
VAPI_CALL(req.execute());
diff --git a/extras/vom/vom/ra_prefix.cpp b/extras/vom/vom/ra_prefix.cpp
index 1cf09637082..fe3ad327f6d 100644
--- a/extras/vom/vom/ra_prefix.cpp
+++ b/extras/vom/vom/ra_prefix.cpp
@@ -15,6 +15,7 @@
#include <sstream>
+#include "vom/api_types.hpp"
#include "vom/ra_prefix.hpp"
namespace VOM {
@@ -37,9 +38,7 @@ ra_prefix::ra_prefix(const route::prefix_t& pfx,
void
ra_prefix::to_vpp(vapi_payload_sw_interface_ip6nd_ra_prefix& ra_prefix) const
{
- uint8_t is_ipv6 = 0;
-
- m_pfx.to_vpp(&is_ipv6, ra_prefix.address, &ra_prefix.address_length);
+ ra_prefix.prefix = to_api(m_pfx);
ra_prefix.use_default = m_use_default;
ra_prefix.no_advertise = m_no_advertise;