summaryrefslogtreecommitdiffstats
path: root/extras
diff options
context:
space:
mode:
Diffstat (limited to 'extras')
-rw-r--r--extras/vom/vom/api_types.cpp59
-rw-r--r--extras/vom/vom/api_types.hpp2
-rw-r--r--extras/vom/vom/bridge_domain_arp_entry_cmds.cpp4
-rw-r--r--extras/vom/vom/gbp_contract_cmds.cpp2
-rw-r--r--extras/vom/vom/gbp_endpoint_cmds.cpp2
-rw-r--r--extras/vom/vom/ip_punt_redirect_cmds.cpp4
6 files changed, 19 insertions, 54 deletions
diff --git a/extras/vom/vom/api_types.cpp b/extras/vom/vom/api_types.cpp
index 1b9ff2913a1..1bde8be9dcc 100644
--- a/extras/vom/vom/api_types.cpp
+++ b/extras/vom/vom/api_types.cpp
@@ -17,47 +17,15 @@
namespace VOM {
-static vapi_type_ip4_address
-to_api(const boost::asio::ip::address_v4& a)
-{
- vapi_type_ip4_address v;
-
- std::copy_n(a.to_bytes().data(), 4, v.address);
-
- return v;
-}
-
-static vapi_type_ip6_address
-to_api(const boost::asio::ip::address_v6& a)
-{
- vapi_type_ip6_address v;
-
- std::copy_n(a.to_bytes().data(), 16, v.address);
-
- return v;
-}
-
-vapi_type_address
-to_api(const ip_address_t& a)
+void
+to_api(const ip_address_t& a, vapi_type_address& v)
{
if (a.is_v4()) {
- vapi_type_address v = {
- .af = ADDRESS_IP4,
- .un =
- {
- .ip4 = to_api(a.to_v4()),
- },
- };
- return (v);
+ v.af = ADDRESS_IP4;
+ memcpy(v.un.ip4, a.to_v4().to_bytes().data(), 4);
} else {
- vapi_type_address v = {
- .af = ADDRESS_IP6,
- .un =
- {
- .ip6 = to_api(a.to_v6()),
- },
- };
- return (v);
+ v.af = ADDRESS_IP6;
+ memcpy(v.un.ip6, a.to_v6().to_bytes().data(), 16);
}
}
@@ -68,12 +36,12 @@ from_api(const vapi_type_address& v)
if (ADDRESS_IP6 == v.af) {
std::array<uint8_t, 16> a;
- std::copy(v.un.ip6.address, v.un.ip6.address + 16, std::begin(a));
+ std::copy(v.un.ip6, v.un.ip6 + 16, std::begin(a));
boost::asio::ip::address_v6 v6(a);
addr = v6;
} else {
std::array<uint8_t, 4> a;
- std::copy(v.un.ip6.address, v.un.ip6.address + 4, std::begin(a));
+ std::copy(v.un.ip6, v.un.ip6 + 4, std::begin(a));
boost::asio::ip::address_v4 v4(a);
addr = v4;
}
@@ -103,14 +71,11 @@ from_api(const vapi_type_prefix& v)
return route::prefix_t(from_api(v.address), v.address_length);
}
-vapi_type_prefix
-to_api(const route::prefix_t& p)
+void
+to_api(const route::prefix_t& p, vapi_type_prefix& v)
{
- vapi_type_prefix v = {
- .address = to_api(p.address()), .address_length = p.mask_width(),
- };
-
- return v;
+ to_api(p.address(), v.address);
+ v.address_length = p.mask_width();
}
};
diff --git a/extras/vom/vom/api_types.hpp b/extras/vom/vom/api_types.hpp
index b555fc3c752..96e2c47f558 100644
--- a/extras/vom/vom/api_types.hpp
+++ b/extras/vom/vom/api_types.hpp
@@ -23,7 +23,7 @@ namespace VOM {
typedef boost::asio::ip::address ip_address_t;
-vapi_type_address to_api(const ip_address_t& a);
+void to_api(const ip_address_t& a, vapi_type_address& v);
ip_address_t from_api(const vapi_type_address& v);
diff --git a/extras/vom/vom/bridge_domain_arp_entry_cmds.cpp b/extras/vom/vom/bridge_domain_arp_entry_cmds.cpp
index 4e5dfb0f2f4..da5c547bb3b 100644
--- a/extras/vom/vom/bridge_domain_arp_entry_cmds.cpp
+++ b/extras/vom/vom/bridge_domain_arp_entry_cmds.cpp
@@ -46,7 +46,7 @@ create_cmd::issue(connection& con)
payload.bd_id = m_bd;
payload.is_add = 1;
payload.mac = to_api(m_mac);
- payload.ip = to_api(m_ip_addr);
+ to_api(m_ip_addr, payload.ip);
VAPI_CALL(req.execute());
@@ -91,7 +91,7 @@ delete_cmd::issue(connection& con)
payload.bd_id = m_bd;
payload.is_add = 0;
payload.mac = to_api(m_mac);
- payload.ip = to_api(m_ip_addr);
+ to_api(m_ip_addr, payload.ip);
VAPI_CALL(req.execute());
diff --git a/extras/vom/vom/gbp_contract_cmds.cpp b/extras/vom/vom/gbp_contract_cmds.cpp
index db49f9751f1..1a3975b832a 100644
--- a/extras/vom/vom/gbp_contract_cmds.cpp
+++ b/extras/vom/vom/gbp_contract_cmds.cpp
@@ -77,7 +77,7 @@ create_cmd::issue(connection& con)
payload.contract.rules[ii].nh_set.n_nhs = nh_size;
while (jj < nh_size) {
- payload.contract.rules[ii].nh_set.nhs[jj].ip = to_api(nh_it->getIp());
+ to_api(nh_it->getIp(), payload.contract.rules[ii].nh_set.nhs[jj].ip);
payload.contract.rules[ii].nh_set.nhs[jj].mac = to_api(nh_it->getMac());
payload.contract.rules[ii].nh_set.nhs[jj].bd_id = nh_it->getBdId();
payload.contract.rules[ii].nh_set.nhs[jj].rd_id = nh_it->getRdId();
diff --git a/extras/vom/vom/gbp_endpoint_cmds.cpp b/extras/vom/vom/gbp_endpoint_cmds.cpp
index 8d44c91ec61..b15b941b125 100644
--- a/extras/vom/vom/gbp_endpoint_cmds.cpp
+++ b/extras/vom/vom/gbp_endpoint_cmds.cpp
@@ -54,7 +54,7 @@ create_cmd::issue(connection& con)
payload.endpoint.n_ips = m_ip_addrs.size();
for (n = 0; n < payload.endpoint.n_ips; n++) {
- payload.endpoint.ips[n] = to_api(m_ip_addrs[n]);
+ to_api(m_ip_addrs[n], payload.endpoint.ips[n]);
}
payload.endpoint.mac = to_api(m_mac);
diff --git a/extras/vom/vom/ip_punt_redirect_cmds.cpp b/extras/vom/vom/ip_punt_redirect_cmds.cpp
index 135ef6a4e64..419e3f17fba 100644
--- a/extras/vom/vom/ip_punt_redirect_cmds.cpp
+++ b/extras/vom/vom/ip_punt_redirect_cmds.cpp
@@ -47,7 +47,7 @@ config_cmd::issue(connection& con)
payload.is_add = 1;
payload.punt.rx_sw_if_index = m_rx_itf.value();
payload.punt.tx_sw_if_index = m_tx_itf.value();
- payload.punt.nh = to_api(m_addr);
+ to_api(m_addr, payload.punt.nh);
VAPI_CALL(req.execute());
@@ -93,7 +93,7 @@ unconfig_cmd::issue(connection& con)
payload.is_add = 0;
payload.punt.rx_sw_if_index = m_rx_itf.value();
payload.punt.tx_sw_if_index = m_tx_itf.value();
- payload.punt.nh = to_api(m_addr);
+ to_api(m_addr, payload.punt.nh);
VAPI_CALL(req.execute());