aboutsummaryrefslogtreecommitdiffstats
path: root/libtransport
diff options
context:
space:
mode:
authorJordan Augé <jordan.auge+fdio@cisco.com>2019-11-07 16:42:01 +0100
committerJordan Augé <jordan.auge+fdio@cisco.com>2019-11-08 01:36:45 +0100
commit1bf749aa3e4b0ccc40057b2587af5211926a1431 (patch)
tree1e59105d64e7dc13f4f1cd4ae8437bb8bb932292 /libtransport
parenta30d495f6e91f3bed0420bf76c19315fe0de8801 (diff)
[HICN-385] fix route removal in hicnctrl, code uniformization in hicn-light control api
Change-Id: Id097368dcde993775f206623195cc5aa57b4fe12 Signed-off-by: Jordan Augé <jordan.auge+fdio@cisco.com>
Diffstat (limited to 'libtransport')
-rw-r--r--libtransport/src/hicn/transport/core/hicn_binary_api.c4
-rw-r--r--libtransport/src/hicn/transport/core/prefix.cc18
-rw-r--r--libtransport/src/hicn/transport/core/vpp_forwarder_interface.cc23
3 files changed, 23 insertions, 22 deletions
diff --git a/libtransport/src/hicn/transport/core/hicn_binary_api.c b/libtransport/src/hicn/transport/core/hicn_binary_api.c
index 9f93953ab..aea2f09f7 100644
--- a/libtransport/src/hicn/transport/core/hicn_binary_api.c
+++ b/libtransport/src/hicn/transport/core/hicn_binary_api.c
@@ -112,7 +112,7 @@ int hicn_binary_api_register_prod_app(
CONTEXT_SAVE(context_store, api, mp)
fib_prefix_t prefix;
- memcpy(&prefix.fp_addr.as_u64, &input_params->prefix->address.as_u64, sizeof(ip46_address_t));
+ memcpy(&prefix.fp_addr, &input_params->prefix->address, sizeof(ip46_address_t));
prefix.fp_len = input_params->prefix->len;
prefix.fp_proto = ip46_address_is_ip4(&prefix.fp_addr) ? FIB_PROTOCOL_IP4 : FIB_PROTOCOL_IP6;
ip_prefix_encode(&prefix, &mp->prefix);
@@ -185,7 +185,7 @@ int hicn_binary_api_register_route(
CONTEXT_SAVE(context_store, api, mp)
fib_prefix_t prefix;
- memcpy(&prefix.fp_addr.as_u64, &input_params->prefix->address.as_u64, sizeof(ip46_address_t));
+ memcpy(&prefix.fp_addr, &input_params->prefix->address, sizeof(ip46_address_t));
prefix.fp_len = input_params->prefix->len;
mp->face_ids[0] = clib_host_to_net_u32(input_params->face_id);
mp->n_faces = 1;
diff --git a/libtransport/src/hicn/transport/core/prefix.cc b/libtransport/src/hicn/transport/core/prefix.cc
index b7ddce73a..648c0a67b 100644
--- a/libtransport/src/hicn/transport/core/prefix.cc
+++ b/libtransport/src/hicn/transport/core/prefix.cc
@@ -77,7 +77,17 @@ void Prefix::buildPrefix(std::string &prefix, uint16_t prefix_length,
throw errors::InvalidIpAddressException();
}
- int ret = inet_pton(family, prefix.c_str(), ip_prefix_.address.buffer);
+ int ret;
+ switch (family) {
+ case AF_INET:
+ ret = inet_pton(AF_INET, prefix.c_str(), ip_prefix_.address.v4.buffer);
+ break;
+ case AF_INET6:
+ ret = inet_pton(AF_INET6, prefix.c_str(), ip_prefix_.address.v6.buffer);
+ break;
+ default:
+ throw errors::InvalidIpAddressException();
+ }
if (ret != 1) {
throw errors::InvalidIpAddressException();
@@ -147,7 +157,7 @@ Name Prefix::getName() const {
}
Prefix &Prefix::setNetwork(std::string &network) {
- if (!inet_pton(AF_INET6, network.c_str(), ip_prefix_.address.buffer)) {
+ if (!inet_pton(AF_INET6, network.c_str(), ip_prefix_.address.v6.buffer)) {
throw errors::RuntimeException("The network name is not valid.");
}
@@ -165,8 +175,8 @@ Name Prefix::makeRandomName() const {
uint32_t hash_size_bits = IPV6_ADDR_LEN_BITS - ip_prefix_.len;
uint64_t ip_address[2];
- memcpy(ip_address, ip_prefix_.address.buffer, sizeof(uint64_t));
- memcpy(ip_address + 1, ip_prefix_.address.buffer + 8, sizeof(uint64_t));
+ memcpy(ip_address, ip_prefix_.address.v6.buffer, sizeof(uint64_t));
+ memcpy(ip_address + 1, ip_prefix_.address.v6.buffer + 8, sizeof(uint64_t));
std::string network(IPV6_ADDR_LEN * 3, 0);
// Let's do the magic ;)
diff --git a/libtransport/src/hicn/transport/core/vpp_forwarder_interface.cc b/libtransport/src/hicn/transport/core/vpp_forwarder_interface.cc
index 598b692c9..17239b8fb 100644
--- a/libtransport/src/hicn/transport/core/vpp_forwarder_interface.cc
+++ b/libtransport/src/hicn/transport/core/vpp_forwarder_interface.cc
@@ -102,9 +102,9 @@ void VPPForwarderInterface::consumerConnection() {
throw errors::RuntimeException(hicn_binary_api_get_error_string(ret));
}
- std::memcpy(inet_address_.v4.as_u8, output.src4->as_u8, IPV4_ADDR_LEN);
+ std::memcpy(inet_address_.v4.as_u8, output.src4->v4.as_u8, IPV4_ADDR_LEN);
- std::memcpy(inet6_address_.v6.as_u8, output.src6->as_u8, IPV6_ADDR_LEN);
+ std::memcpy(inet6_address_.v6.as_u8, output.src6->v6.as_u8, IPV6_ADDR_LEN);
}
void VPPForwarderInterface::producerConnection() {
@@ -156,9 +156,8 @@ void VPPForwarderInterface::registerRoute(Prefix &prefix) {
// memif_id, since this function should be called after the
// memif creation.
input.swif = sw_if_index_;
- input.prefix->address.as_u64[0] = addr.address.as_u64[0];
- input.prefix->address.as_u64[1] = addr.address.as_u64[1];
- input.prefix->family = addr.family == AF_INET6 ? AF_INET6 : AF_INET;
+ input.prefix->address = addr.address;
+ input.prefix->family = addr.family;
input.prefix->len = addr.len;
input.cs_reserved = content_store_reserved_;
@@ -169,22 +168,14 @@ void VPPForwarderInterface::registerRoute(Prefix &prefix) {
throw errors::RuntimeException(hicn_binary_api_get_error_string(ret));
}
- if (addr.family == AF_INET6) {
- inet6_address_.v6.as_u64[0] = output.prod_addr->v6.as_u64[0];
- inet6_address_.v6.as_u64[1] = output.prod_addr->v6.as_u64[1];
- } else {
- // The ipv4 is written in the last 4 bytes of the ipv6 address, so we need
- // to copy from the byte 12
- inet_address_.v4.as_u32 = output.prod_addr->v4.as_u32;
- }
+ inet6_address_ = *output.prod_addr;
face_id_ = output.face_id;
} else {
hicn_producer_set_route_params params;
params.prefix = &producer_prefix;
- params.prefix->address.as_u64[0] = addr.address.as_u64[0];
- params.prefix->address.as_u64[1] = addr.address.as_u64[1];
- params.prefix->family = addr.family == AF_INET6 ? AF_INET6 : AF_INET;
+ params.prefix->address = addr.address;
+ params.prefix->family = addr.family;
params.prefix->len = addr.len;
params.face_id = face_id_;