diff options
author | 2018-08-10 05:30:06 -0700 | |
---|---|---|
committer | 2019-01-30 19:47:53 +0000 | |
commit | 37029305c671f4e2d091d6f6c22142634e409043 (patch) | |
tree | f47257c77b860213fcd1901686874dee43ad1f73 /extras/vom/vom/api_types.cpp | |
parent | 13b2ba2ad5527c8185dce368993a3877e7daf7a2 (diff) |
Use IP and MAC API types for neighbors
use address_t and mac_address_t for IPv6 and ARP entries
and all other API calls in ip.api aprat from the route ones,
that will follow in a separate commit
Change-Id: I67161737c2184d3f8fc1e79ebd2b55121c5b0191
Signed-off-by: Neale Ranns <nranns@cisco.com>
Diffstat (limited to 'extras/vom/vom/api_types.cpp')
-rw-r--r-- | extras/vom/vom/api_types.cpp | 31 |
1 files changed, 28 insertions, 3 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 |