- Code style fix 97/16897/4
authorMauro Sardara <msardara@cisco.com>
Sat, 19 Jan 2019 00:29:33 +0000 (01:29 +0100)
committerMauro Sardara <msardara@cisco.com>
Mon, 21 Jan 2019 11:03:48 +0000 (12:03 +0100)
- Improved vpp binary api interface
- Correction in object pool destructor
- Fix error in Memif Connector

Change-Id: Id1dd9219fc1ac0b3717ae019ebff17373bebc635
Signed-off-by: Mauro Sardara <msardara@cisco.com>
69 files changed:
cmake/Modules/BuildMacros.cmake
lib/src/name.h
libtransport/src/hicn/transport/core/CMakeLists.txt
libtransport/src/hicn/transport/core/connector.cc [changed mode: 0755->0644]
libtransport/src/hicn/transport/core/connector.h [changed mode: 0755->0644]
libtransport/src/hicn/transport/core/content_object.cc [changed mode: 0755->0644]
libtransport/src/hicn/transport/core/content_object.h [changed mode: 0755->0644]
libtransport/src/hicn/transport/core/facade.h [changed mode: 0755->0644]
libtransport/src/hicn/transport/core/forwarder_interface.h [changed mode: 0755->0644]
libtransport/src/hicn/transport/core/hicn_binary_api.c [changed mode: 0755->0644]
libtransport/src/hicn/transport/core/hicn_binary_api.h [changed mode: 0755->0644]
libtransport/src/hicn/transport/core/hicn_forwarder_interface.cc [changed mode: 0755->0644]
libtransport/src/hicn/transport/core/hicn_forwarder_interface.h [changed mode: 0755->0644]
libtransport/src/hicn/transport/core/hicn_memif_api.c [deleted file]
libtransport/src/hicn/transport/core/interest.cc [changed mode: 0755->0644]
libtransport/src/hicn/transport/core/interest.h [changed mode: 0755->0644]
libtransport/src/hicn/transport/core/key_locator.cc [deleted file]
libtransport/src/hicn/transport/core/key_locator.h [deleted file]
libtransport/src/hicn/transport/core/key_locator_type.h [deleted file]
libtransport/src/hicn/transport/core/manifest.cc [changed mode: 0755->0644]
libtransport/src/hicn/transport/core/manifest.h [changed mode: 0755->0644]
libtransport/src/hicn/transport/core/manifest_format.h [changed mode: 0755->0644]
libtransport/src/hicn/transport/core/manifest_format_fixed.cc [changed mode: 0755->0644]
libtransport/src/hicn/transport/core/manifest_format_fixed.h [changed mode: 0755->0644]
libtransport/src/hicn/transport/core/manifest_format_json_jsoncpp.cc [changed mode: 0755->0644]
libtransport/src/hicn/transport/core/manifest_format_json_jsoncpp.h [changed mode: 0755->0644]
libtransport/src/hicn/transport/core/manifest_format_json_libparc_deprecated.cc [changed mode: 0755->0644]
libtransport/src/hicn/transport/core/manifest_format_json_libparc_deprecated.h [changed mode: 0755->0644]
libtransport/src/hicn/transport/core/manifest_inline.h [changed mode: 0755->0644]
libtransport/src/hicn/transport/core/memif_binary_api.c [changed mode: 0755->0644]
libtransport/src/hicn/transport/core/memif_binary_api.h [changed mode: 0755->0644]
libtransport/src/hicn/transport/core/memif_connector.cc [changed mode: 0755->0644]
libtransport/src/hicn/transport/core/memif_connector.h [changed mode: 0755->0644]
libtransport/src/hicn/transport/core/name.cc [changed mode: 0755->0644]
libtransport/src/hicn/transport/core/name.h [changed mode: 0755->0644]
libtransport/src/hicn/transport/core/packet.cc [changed mode: 0755->0644]
libtransport/src/hicn/transport/core/packet.h [changed mode: 0755->0644]
libtransport/src/hicn/transport/core/payload_type.h [changed mode: 0755->0644]
libtransport/src/hicn/transport/core/pending_interest.cc [changed mode: 0755->0644]
libtransport/src/hicn/transport/core/pending_interest.h [changed mode: 0755->0644]
libtransport/src/hicn/transport/core/portal.h [changed mode: 0755->0644]
libtransport/src/hicn/transport/core/prefix.cc [changed mode: 0755->0644]
libtransport/src/hicn/transport/core/prefix.h [changed mode: 0755->0644]
libtransport/src/hicn/transport/core/raw_socket_connector.cc [changed mode: 0755->0644]
libtransport/src/hicn/transport/core/raw_socket_connector.h [changed mode: 0755->0644]
libtransport/src/hicn/transport/core/raw_socket_interface.cc [changed mode: 0755->0644]
libtransport/src/hicn/transport/core/raw_socket_interface.h [changed mode: 0755->0644]
libtransport/src/hicn/transport/core/socket_connector.cc [changed mode: 0755->0644]
libtransport/src/hicn/transport/core/socket_connector.h [changed mode: 0755->0644]
libtransport/src/hicn/transport/core/test/test_core_manifest.cc [changed mode: 0755->0644]
libtransport/src/hicn/transport/core/vpp_binary_api.c [changed mode: 0755->0644]
libtransport/src/hicn/transport/core/vpp_binary_api.h [changed mode: 0755->0644]
libtransport/src/hicn/transport/core/vpp_binary_api_internal.h [changed mode: 0755->0644]
libtransport/src/hicn/transport/core/vpp_forwarder_interface.cc [changed mode: 0755->0644]
libtransport/src/hicn/transport/core/vpp_forwarder_interface.h [changed mode: 0755->0644]
libtransport/src/hicn/transport/interfaces/full_duplex_socket.cc [changed mode: 0755->0644]
libtransport/src/hicn/transport/interfaces/rtc_socket_producer.cc [changed mode: 0755->0644]
libtransport/src/hicn/transport/interfaces/socket_consumer.cc [changed mode: 0755->0644]
libtransport/src/hicn/transport/protocols/rtc.cc [changed mode: 0755->0644]
libtransport/src/hicn/transport/protocols/rtc_data_path.h [changed mode: 0755->0644]
libtransport/src/hicn/transport/protocols/vegas.cc [changed mode: 0755->0644]
libtransport/src/hicn/transport/utils/identity.cc [changed mode: 0755->0644]
libtransport/src/hicn/transport/utils/log.cc [changed mode: 0755->0644]
libtransport/src/hicn/transport/utils/log.h [changed mode: 0755->0644]
libtransport/src/hicn/transport/utils/object_pool.h
libtransport/src/hicn/transport/utils/signer.cc [changed mode: 0755->0644]
libtransport/src/hicn/transport/utils/verifier.cc [changed mode: 0755->0644]
utils/src/hiperf.cc
utils/src/ping_client.cc

index 14a82fa..3630d2e 100755 (executable)
@@ -19,7 +19,7 @@ macro(build_executable exec)
   cmake_parse_arguments(ARG
     "NO_INSTALL"
     "COMPONENT"
-    "SOURCES;LINK_LIBRARIES;DEPENDS;DEFINITIONS"
+    "SOURCES;LINK_LIBRARIES;DEPENDS;INCLUDE_DIRS;DEFINITIONS"
     ${ARGN}
   )
 
@@ -36,6 +36,13 @@ macro(build_executable exec)
     target_compile_definitions(${exec} PRIVATE ${ARG_DEFINITIONS})
   endif()
 
+  if(ARG_INCLUDE_DIRS)
+    target_include_directories(${exec} BEFORE PUBLIC
+      ${ARG_INCLUDE_DIRS}
+      ${PROJECT_BINARY_DIR}
+    )
+  endif()
+
   if(NOT ARG_NO_INSTALL)
     install(TARGETS ${exec} DESTINATION bin COMPONENT ${ARG_COMPONENT})
   endif()
index 0a55fed..ffcb4a4 100755 (executable)
@@ -48,7 +48,7 @@
 #define IP_MAX_ADDR_LEN IPV6_ADDR_LEN
 #define TCP_SEQNO_LEN 4                /* bytes */
 
-typedef struct
+struct ip_address
 {
   union
   {
@@ -57,12 +57,13 @@ typedef struct
     u16 as_u16[IP_MAX_ADDR_LEN >> 1];
     u32 as_u32[IP_MAX_ADDR_LEN >> 2];
     u64 as_u64[IP_MAX_ADDR_LEN >> 3];
-    ip4_address_t as_ip4;
-    ip6_address_t as_ip6;
+    ip46_address_t as_ip46;
   };
   int family;
   unsigned short prefix_len;
-} ip_address_t;
+};
+
+typedef struct ip_address ip_address_t;
 
 int ip_address_len (const ip_address_t * ip_address);
 bool ip_address_empty (const ip_address_t * ip_address);
index c8dea83..a97e74b 100755 (executable)
@@ -17,8 +17,6 @@ list(APPEND HEADER_FILES
   ${CMAKE_CURRENT_SOURCE_DIR}/content_object.h
   ${CMAKE_CURRENT_SOURCE_DIR}/facade.h
   ${CMAKE_CURRENT_SOURCE_DIR}/interest.h
-  ${CMAKE_CURRENT_SOURCE_DIR}/key_locator.h
-  ${CMAKE_CURRENT_SOURCE_DIR}/key_locator_type.h
   ${CMAKE_CURRENT_SOURCE_DIR}/socket_connector.h
   ${CMAKE_CURRENT_SOURCE_DIR}/manifest.h
   ${CMAKE_CURRENT_SOURCE_DIR}/manifest_inline.h
@@ -41,7 +39,6 @@ list(APPEND HEADER_FILES
 list(APPEND SOURCE_FILES
   ${CMAKE_CURRENT_SOURCE_DIR}/content_object.cc
   ${CMAKE_CURRENT_SOURCE_DIR}/interest.cc
-  ${CMAKE_CURRENT_SOURCE_DIR}/key_locator.cc
   ${CMAKE_CURRENT_SOURCE_DIR}/socket_connector.cc
   ${CMAKE_CURRENT_SOURCE_DIR}/pending_interest.cc
   ${CMAKE_CURRENT_SOURCE_DIR}/packet.cc
old mode 100755 (executable)
new mode 100644 (file)
index 1420187..c525048
@@ -33,7 +33,7 @@ enum class ConnectorType : uint8_t {
   VPP_CONNECTOR,
 };
 
-static constexpr std::size_t packet_size = 2000;
+static constexpr std::size_t packet_size = 2048;
 static constexpr std::size_t queue_size = 4096;
 static constexpr std::size_t packet_pool_size = 4096;
 
@@ -72,6 +72,10 @@ class Connector {
       result = packet_pool_.get();
     }
 
+    if (result.second->isChained()) {
+      result.second->separateChain(result.second->next(),
+                                   result.second->prev());
+    }
     result.second->clear();
     return std::move(result.second);
   }
old mode 100755 (executable)
new mode 100644 (file)
old mode 100755 (executable)
new mode 100644 (file)
index c49cb5c..d909578
 
 #ifdef __vpp__
 
-#include <hicn/transport/core/hicn_binary_api.h>
-#include <hicn/transport/core/vpp_binary_api_internal.h>
-
 #include <hicn/transport/core/hicn_binary_api.h>
 #include <hicn/transport/core/vpp_binary_api_internal.h>
 #include <hicn/transport/utils/log.h>
 
+#define HICN_VPP_PLUGIN
+#include <hicn/name.h>
+#undef HICN_VPP_PLUGIN
+
 #include <fcntl.h>
 #include <inttypes.h>
 #include <semaphore.h>
@@ -66,21 +67,9 @@ const char *HICN_ERROR_STRING[] = {
 };
 /////////////////////////////////////////////////////
 
-#define POINTER_MAP_SIZE 32
-static void *global_pointers_map[POINTER_MAP_SIZE];
-static uint8_t global_pointers_map_index = 0;
-
-#define CONTEXT_SAVE(pointer, mp)                             \
-  do {                                                        \
-    global_pointers_map[global_pointers_map_index] = pointer; \
-    mp->context = global_pointers_map_index++;                \
-    global_pointers_map_index %= POINTER_MAP_SIZE;            \
-  } while (0);
-
-#define CONTEXT_GET(mp, pointer)                \
-  do {                                          \
-    pointer = global_pointers_map[mp->context]; \
-  } while (0);
+static context_store_t context_store = {
+    .global_pointers_map_index = 0,
+};
 
 /*
  * Table of message reply handlers, must include boilerplate handlers
@@ -96,22 +85,19 @@ int hicn_binary_api_register_prod_app(
     hicn_producer_output_params *output_params) {
   vl_api_hicn_api_register_prod_app_t *mp;
   vpp_plugin_binary_api_t *hm = api;
-  api->vpp_api->user_param = output_params;
+  vpp_binary_api_set_user_param(api->vpp_api, output_params);
 
   /* Construct the API message */
   M(HICN_API_REGISTER_PROD_APP, mp);
 
-  CONTEXT_SAVE(api, mp)
+  CONTEXT_SAVE(context_store, api, mp)
 
-  mp->len = (u8)input_params->prefix.prefix_length;
+  mp->len = (u8)input_params->prefix->prefix_len;
   mp->swif = clib_host_to_net_u32(input_params->swif);
   mp->cs_reserved = clib_host_to_net_u32(input_params->cs_reserved);
 
-  mp->prefix[0] = clib_host_to_net_u64(input_params->prefix.ip6.as_u64[0]);
-  mp->prefix[1] = clib_host_to_net_u64(input_params->prefix.ip6.as_u64[1]);
-
-  TRANSPORT_LOGI("Prefix length: %u", mp->len);
-  TRANSPORT_LOGI("Memif ID: %u", mp->swif);
+  mp->prefix[0] = clib_host_to_net_u64(input_params->prefix->as_u64[0]);
+  mp->prefix[1] = clib_host_to_net_u64(input_params->prefix->as_u64[1]);
 
   return vpp_binary_api_send_request_wait_reply(api->vpp_api, mp);
 }
@@ -119,17 +105,17 @@ int hicn_binary_api_register_prod_app(
 static void vl_api_hicn_api_register_prod_app_reply_t_handler(
     vl_api_hicn_api_register_prod_app_reply_t *mp) {
   vpp_plugin_binary_api_t *binary_api;
-  CONTEXT_GET(mp, binary_api);
-  hicn_producer_output_params *params = binary_api->vpp_api->user_param;
+  CONTEXT_GET(context_store, mp, binary_api);
+  hicn_producer_output_params *params =
+      vpp_binary_api_get_user_param(binary_api->vpp_api);
 
-  binary_api->vpp_api->ret_val = clib_net_to_host_u32(mp->retval);
+  vpp_binary_api_set_ret_value(binary_api->vpp_api,
+                               clib_net_to_host_u32(mp->retval));
   params->cs_reserved = mp->cs_reserved;
-  params->prod_addr.ip6.as_u64[0] = mp->prod_addr[0];
-  params->prod_addr.ip6.as_u64[1] = mp->prod_addr[1];
+  params->prod_addr->as_u64[0] = mp->prod_addr[0];
+  params->prod_addr->as_u64[1] = mp->prod_addr[1];
   params->face_id = clib_net_to_host_u32(mp->faceid);
 
-  TRANSPORT_LOGI("ret :%s", get_error_string(binary_api->vpp_api->ret_val));
-
   vpp_binary_api_unlock_waiting_thread(binary_api->vpp_api);
 }
 
@@ -139,14 +125,14 @@ int hicn_binary_api_register_cons_app(
   vl_api_hicn_api_register_cons_app_t *mp;
   vpp_plugin_binary_api_t *hm = api;
 
-  hm->vpp_api->user_param = output_params;
+  vpp_binary_api_set_user_param(hm->vpp_api, output_params);
 
   /* Construct the API message */
   M(HICN_API_REGISTER_CONS_APP, mp);
 
   mp->swif = clib_host_to_net_u32(input_params->swif);
 
-  CONTEXT_SAVE(api, mp)
+  CONTEXT_SAVE(context_store, api, mp)
 
   TRANSPORT_LOGI("Message created");
 
@@ -156,14 +142,16 @@ int hicn_binary_api_register_cons_app(
 static void vl_api_hicn_api_register_cons_app_reply_t_handler(
     vl_api_hicn_api_register_cons_app_reply_t *mp) {
   vpp_plugin_binary_api_t *binary_api;
-  CONTEXT_GET(mp, binary_api);
-  hicn_consumer_output_params *params = binary_api->vpp_api->user_param;
+  CONTEXT_GET(context_store, mp, binary_api);
+  hicn_consumer_output_params *params =
+      vpp_binary_api_get_user_param(binary_api->vpp_api);
 
-  binary_api->vpp_api->ret_val = clib_net_to_host_u32(mp->retval);
+  vpp_binary_api_set_ret_value(binary_api->vpp_api,
+                               clib_net_to_host_u32(mp->retval));
 
-  params->src4.ip4.as_u32 = clib_net_to_host_u32(mp->src_addr4);
-  params->src6.ip6.as_u64[0] = clib_net_to_host_u64(mp->src_addr6[0]);
-  params->src6.ip6.as_u64[1] = clib_net_to_host_u64(mp->src_addr6[1]);
+  params->src4->as_ip46.ip4.as_u32 = clib_net_to_host_u32(mp->src_addr4);
+  params->src6->as_u64[0] = clib_net_to_host_u64(mp->src_addr6[0]);
+  params->src6->as_u64[1] = clib_net_to_host_u64(mp->src_addr6[1]);
   params->face_id = clib_host_to_net_u32(mp->faceid);
 
   vpp_binary_api_unlock_waiting_thread(binary_api->vpp_api);
@@ -178,11 +166,11 @@ int hicn_binary_api_register_route(
   /* Construct the API message */
   M(HICN_API_ROUTE_NHOPS_ADD, mp);
 
-  CONTEXT_SAVE(api, mp)
+  CONTEXT_SAVE(context_store, api, mp)
 
-  mp->prefix[0] = input_params->prefix.ip6.as_u64[0];
-  mp->prefix[1] = input_params->prefix.ip6.as_u64[1];
-  mp->len = input_params->prefix.prefix_length;
+  mp->prefix[0] = input_params->prefix->as_u64[0];
+  mp->prefix[1] = input_params->prefix->as_u64[1];
+  mp->len = input_params->prefix->prefix_len;
   mp->face_ids[0] = input_params->face_id;
   mp->n_faces = 1;
 
@@ -192,9 +180,10 @@ int hicn_binary_api_register_route(
 static void vl_api_hicn_api_route_nhops_add_reply_t_handler(
     vl_api_hicn_api_route_nhops_add_reply_t *mp) {
   vpp_plugin_binary_api_t *binary_api;
-  CONTEXT_GET(mp, binary_api);
+  CONTEXT_GET(context_store, mp, binary_api);
 
-  binary_api->vpp_api->ret_val = clib_net_to_host_u32(mp->retval);
+  vpp_binary_api_set_ret_value(binary_api->vpp_api,
+                               clib_net_to_host_u32(mp->retval));
 
   vpp_binary_api_unlock_waiting_thread(binary_api->vpp_api);
 }
@@ -220,7 +209,7 @@ vpp_plugin_binary_api_t *hicn_binary_api_init(vpp_binary_api_t *api) {
   u8 *name = format(0, "hicn_%08x%c", api_version, 0);
   ret->msg_id_base = vl_client_get_first_plugin_msg_id((char *)name);
   ret->vpp_api = api;
-  ret->my_client_index = api->my_client_index;
+  ret->my_client_index = vpp_binary_api_get_client_index(api);
   hicn_binary_api_setup_handlers(ret);
   return ret;
 }
old mode 100755 (executable)
new mode 100644 (file)
index 7528441..410ffb9
@@ -27,35 +27,10 @@ extern "C" {
 
 #include "stdint.h"
 
-typedef union {
-  uint8_t data[4];
-  uint32_t data_u32;
-  /* Aliases. */
-  uint8_t as_u8[4];
-  uint16_t as_u16[2];
-  uint32_t as_u32;
-} ip4_address;
-
-typedef union {
-  uint8_t as_u8[16];
-  uint16_t as_u16[8];
-  uint32_t as_u32[4];
-  uint64_t as_u64[2];
-} ip6_address;
-
-typedef enum { IP_TYPE_ANY, IP_TYPE_IP4, IP_TYPE_IP6 } ip46_type;
+typedef struct ip_address ip_address_t;
 
 typedef struct {
-  ip46_type type;
-  uint8_t prefix_length;
-  union {
-    ip4_address ip4;
-    ip6_address ip6;
-  };
-} ip46_address;
-
-typedef struct {
-  ip46_address prefix;
+  ip_address_t* prefix;
   uint32_t swif;
   uint32_t cs_reserved;
 } hicn_producer_input_params;
@@ -66,18 +41,18 @@ typedef struct {
 
 typedef struct {
   uint32_t cs_reserved;
-  ip46_address prod_addr;
+  ip_address_t* prod_addr;
   uint32_t face_id;
 } hicn_producer_output_params;
 
 typedef struct {
-  ip46_address src4;
-  ip46_address src6;
+  ip_address_t* src4;
+  ip_address_t* src6;
   uint32_t face_id;
 } hicn_consumer_output_params;
 
 typedef struct {
-  ip46_address prefix;
+  ip_address_t* prefix;
   uint32_t face_id;
 } hicn_producer_set_route_params;
 
old mode 100755 (executable)
new mode 100644 (file)
index 03a2949..1d82ff0
@@ -15,6 +15,7 @@
 
 #include <hicn/transport/core/hicn_forwarder_interface.h>
 
+
 #define ADDR_INET 1
 #define ADDR_INET6 2
 #define ADD_ROUTE 3
@@ -73,7 +74,6 @@ void HicnForwarderInterface::registerRoute(Prefix &prefix) {
   route_to_self->command_id = ADD_ROUTE;
   route_to_self->message_type = REQUEST_LIGHT;
   route_to_self->length = 1;
-  // route_to_self->seq_num not needed for now
 
   send((uint8_t *)route_to_self, sizeof(RouteToSelfCommand),
        [route_to_self]() { delete route_to_self; });
diff --git a/libtransport/src/hicn/transport/core/hicn_memif_api.c b/libtransport/src/hicn/transport/core/hicn_memif_api.c
deleted file mode 100755 (executable)
index e69de29..0000000
old mode 100755 (executable)
new mode 100644 (file)
diff --git a/libtransport/src/hicn/transport/core/key_locator.cc b/libtransport/src/hicn/transport/core/key_locator.cc
deleted file mode 100755 (executable)
index 509fc35..0000000
+++ /dev/null
@@ -1,42 +0,0 @@
-/*
- * Copyright (c) 2017-2019 Cisco and/or its affiliates.
- * Licensed under the Apache License, Version 2.0 (the "License");
- * you may not use this file except in compliance with the License.
- * You may obtain a copy of the License at:
- *
- *     http://www.apache.org/licenses/LICENSE-2.0
- *
- * Unless required by applicable law or agreed to in writing, software
- * distributed under the License is distributed on an "AS IS" BASIS,
- * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
- * See the License for the specific language governing permissions and
- * limitations under the License.
- */
-
-#include <hicn/transport/core/key_locator.h>
-
-namespace transport {
-
-namespace core {
-
-KeyLocator::KeyLocator() : type_(KeyLocatorType::UNKNOWN) {}
-
-KeyLocator::KeyLocator(KeyLocatorType type, Name &name)
-    : type_(type), name_(name) {}
-
-Name &KeyLocator::getName() { return name_; }
-
-void KeyLocator::setName(Name &name) { name_ = name; }
-
-void KeyLocator::setType(KeyLocatorType type) { type_ = type; }
-
-KeyLocatorType KeyLocator::getType() { return type_; }
-
-void KeyLocator::clear() {
-  type_ = KeyLocatorType::UNKNOWN;
-  name_.clear();
-}
-
-}  // end namespace core
-
-}  // end namespace transport
\ No newline at end of file
diff --git a/libtransport/src/hicn/transport/core/key_locator.h b/libtransport/src/hicn/transport/core/key_locator.h
deleted file mode 100755 (executable)
index ae3a4ab..0000000
+++ /dev/null
@@ -1,48 +0,0 @@
-/*
- * Copyright (c) 2017-2019 Cisco and/or its affiliates.
- * Licensed under the Apache License, Version 2.0 (the "License");
- * you may not use this file except in compliance with the License.
- * You may obtain a copy of the License at:
- *
- *     http://www.apache.org/licenses/LICENSE-2.0
- *
- * Unless required by applicable law or agreed to in writing, software
- * distributed under the License is distributed on an "AS IS" BASIS,
- * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
- * See the License for the specific language governing permissions and
- * limitations under the License.
- */
-
-#pragma once
-
-#include <hicn/transport/core/key_locator_type.h>
-#include <hicn/transport/core/name.h>
-
-namespace transport {
-
-namespace core {
-
-class KeyLocator : public std::enable_shared_from_this<KeyLocator> {
- public:
-  KeyLocator();
-
-  KeyLocator(KeyLocatorType type, Name &name);
-
-  KeyLocatorType getType();
-
-  void setType(KeyLocatorType type);
-
-  void setName(Name &name);
-
-  Name &getName();
-
-  void clear();
-
- private:
-  KeyLocatorType type_;
-  Name name_;
-};
-
-}  // end namespace core
-
-}  // end namespace transport
diff --git a/libtransport/src/hicn/transport/core/key_locator_type.h b/libtransport/src/hicn/transport/core/key_locator_type.h
deleted file mode 100755 (executable)
index 0c84a43..0000000
+++ /dev/null
@@ -1,28 +0,0 @@
-/*
- * Copyright (c) 2017-2019 Cisco and/or its affiliates.
- * Licensed under the Apache License, Version 2.0 (the "License");
- * you may not use this file except in compliance with the License.
- * You may obtain a copy of the License at:
- *
- *     http://www.apache.org/licenses/LICENSE-2.0
- *
- * Unless required by applicable law or agreed to in writing, software
- * distributed under the License is distributed on an "AS IS" BASIS,
- * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
- * See the License for the specific language governing permissions and
- * limitations under the License.
- */
-
-#pragma once
-
-namespace transport {
-
-namespace core {
-
-enum Type { NAME = 0, KEY_DIGEST = 1, UNKNOWN = 255 };
-
-typedef enum Type KeyLocatorType;
-
-}  // end namespace core
-
-}  // end namespace transport
old mode 100755 (executable)
new mode 100644 (file)
index 767addb..558a968
@@ -45,21 +45,21 @@ class Manifest : public Base {
     Base::setPayloadType(PayloadType::MANIFEST);
   }
 
-  Manifest(const core::Namename)
+  Manifest(const core::Name &name)
       : packet_(new Base(name, HF_INET6_TCP_AH), nullptr),
         encoder_(*packet_),
         decoder_(*packet_) {
     Base::setPayloadType(PayloadType::MANIFEST);
   }
 
-  Manifest(typename Base::Ptr&& base)
+  Manifest(typename Base::Ptr &&base)
       : packet_(std::move(base)), encoder_(*packet_), decoder_(*packet_) {
     Base::setPayloadType(PayloadType::MANIFEST);
   }
 
   template <typename T>
-  Manifest(T&& base)
-      : packet_(new Base(std::move<T&&>(base)), nullptr),
+  Manifest(T &&base)
+      : packet_(new Base(std::move<T &&>(base)), nullptr),
         encoder_(*packet_),
         decoder_(*packet_) {
     Base::setPayloadType(PayloadType::MANIFEST);
@@ -67,12 +67,12 @@ class Manifest : public Base {
 
   virtual ~Manifest() = default;
 
-  bool operator==(const Manifestother) {
+  bool operator==(const Manifest &other) {
     return this->packet_ == other.packet_;
   }
 
   std::size_t estimateManifestSize(std::size_t additional_entries = 0) {
-    return static_cast<ManifestImpl&>(*this).estimateManifestSizeImpl(
+    return static_cast<ManifestImpl &>(*this).estimateManifestSizeImpl(
         additional_entries);
   }
 
@@ -80,29 +80,29 @@ class Manifest : public Base {
    * After the call to encode, users MUST call clear before adding data
    * to the manifest.
    */
-  Manifest& encode() { return static_cast<ManifestImpl&>(*this).encodeImpl(); }
+  Manifest &encode() { return static_cast<ManifestImpl &>(*this).encodeImpl(); }
 
-  Manifestdecode() {
+  Manifest &decode() {
     Manifest::decoder_.decode();
 
     manifest_type_ = decoder_.getManifestType();
     hash_algorithm_ = decoder_.getHashAlgorithm();
     is_last_ = decoder_.getIsFinalManifest();
 
-    return static_cast<ManifestImpl&>(*this).decodeImpl();
+    return static_cast<ManifestImpl &>(*this).decodeImpl();
   }
 
   static std::size_t getManifestHeaderSize() {
     return Encoder::getManifestHeaderSize();
   }
 
-  ManifestsetManifestType(ManifestType type) {
+  Manifest &setManifestType(ManifestType type) {
     manifest_type_ = type;
     encoder_.setManifestType(manifest_type_);
     return *this;
   }
 
-  ManifestsetHashAlgorithm(HashAlgorithm hash_algorithm) {
+  Manifest &setHashAlgorithm(HashAlgorithm hash_algorithm) {
     hash_algorithm_ = hash_algorithm;
     encoder_.setHashAlgorithm(hash_algorithm_);
     return *this;
@@ -114,12 +114,12 @@ class Manifest : public Base {
 
   bool isFinalManifest() const { return is_last_; }
 
-  ManifestsetVersion(ManifestVersion version) {
+  Manifest &setVersion(ManifestVersion version) {
     encoder_.setVersion(version);
     return *this;
   }
 
-  ManifestsetFinalBlockNumber(std::uint32_t final_block_number) {
+  Manifest &setFinalBlockNumber(std::uint32_t final_block_number) {
     encoder_.setFinalBlockNumber(final_block_number);
     return *this;
   }
@@ -130,13 +130,13 @@ class Manifest : public Base {
 
   ManifestVersion getVersion() const { return decoder_.getVersion(); }
 
-  ManifestsetFinalManifest(bool is_final_manifest) {
+  Manifest &setFinalManifest(bool is_final_manifest) {
     encoder_.setIsFinalManifest(is_final_manifest);
     is_last_ = is_final_manifest;
     return *this;
   }
 
-  Manifestclear() {
+  Manifest &clear() {
     encoder_.clear();
     decoder_.clear();
     return *this;
@@ -147,7 +147,7 @@ class Manifest : public Base {
     encoder_.update();
   }
 
-  typename Base::Ptr&& getPacket() { return std::move(packet_); }
+  typename Base::Ptr &&getPacket() { return std::move(packet_); }
 
  protected:
   typename Base::Ptr packet_;
old mode 100755 (executable)
new mode 100644 (file)
index 1dcf013..00782f1
@@ -71,28 +71,28 @@ class ManifestEncoder {
   virtual ~ManifestEncoder() = default;
 
   ManifestEncoder encode() {
-    return static_cast<Implementation&>(*this).encodeImpl();
+    return static_cast<Implementation &>(*this).encodeImpl();
   }
 
-  ManifestEncoderclear() {
-    return static_cast<Implementation&>(*this).clearImpl();
+  ManifestEncoder &clear() {
+    return static_cast<Implementation &>(*this).clearImpl();
   }
 
-  ManifestEncodersetManifestType(ManifestType type) {
-    return static_cast<Implementation&>(*this).setManifestTypeImpl(type);
+  ManifestEncoder &setManifestType(ManifestType type) {
+    return static_cast<Implementation &>(*this).setManifestTypeImpl(type);
   }
 
-  ManifestEncodersetHashAlgorithm(HashAlgorithm hash) {
-    return static_cast<Implementation&>(*this).setHashAlgorithmImpl(hash);
+  ManifestEncoder &setHashAlgorithm(HashAlgorithm hash) {
+    return static_cast<Implementation &>(*this).setHashAlgorithmImpl(hash);
   }
 
-  ManifestEncodersetFinalChunkNumber(uint32_t final_chunk) {
-    return static_cast<Implementation&>(*this).setFinalChunkImpl(final_chunk);
+  ManifestEncoder &setFinalChunkNumber(uint32_t final_chunk) {
+    return static_cast<Implementation &>(*this).setFinalChunkImpl(final_chunk);
   }
 
-  ManifestEncodersetNextSegmentCalculationStrategy(
+  ManifestEncoder &setNextSegmentCalculationStrategy(
       NextSegmentCalculationStrategy strategy) {
-    return static_cast<Implementation&>(*this)
+    return static_cast<Implementation &>(*this)
         .setNextSegmentCalculationStrategyImpl(strategy);
   }
 
@@ -100,35 +100,35 @@ class ManifestEncoder {
       typename T,
       typename = std::enable_if_t<std::is_same<
           std::remove_const_t<std::remove_reference_t<T>>, core::Name>::value>>
-  ManifestEncoder& setBaseName(T&& name) {
-    return static_cast<Implementation&>(*this).setBaseNameImpl(name);
+  ManifestEncoder &setBaseName(T &&name) {
+    return static_cast<Implementation &>(*this).setBaseNameImpl(name);
   }
 
   template <typename Hash>
-  ManifestEncoder& addSuffixAndHash(uint32_t suffix, Hash&& hash) {
-    return static_cast<Implementation&>(*this).addSuffixAndHashImpl(
-        suffix, std::forward<Hash&&>(hash));
+  ManifestEncoder &addSuffixAndHash(uint32_t suffix, Hash &&hash) {
+    return static_cast<Implementation &>(*this).addSuffixAndHashImpl(
+        suffix, std::forward<Hash &&>(hash));
   }
 
-  ManifestEncodersetIsFinalManifest(bool is_last) {
-    return static_cast<Implementation&>(*this).setIsFinalManifestImpl(is_last);
+  ManifestEncoder &setIsFinalManifest(bool is_last) {
+    return static_cast<Implementation &>(*this).setIsFinalManifestImpl(is_last);
   }
 
-  ManifestEncodersetVersion(ManifestVersion version) {
-    return static_cast<Implementation&>(*this).setVersionImpl(version);
+  ManifestEncoder &setVersion(ManifestVersion version) {
+    return static_cast<Implementation &>(*this).setVersionImpl(version);
   }
 
   std::size_t estimateSerializedLength(std::size_t number_of_entries) {
-    return static_cast<Implementation&>(*this).estimateSerializedLengthImpl(
+    return static_cast<Implementation &>(*this).estimateSerializedLengthImpl(
         number_of_entries);
   }
 
-  ManifestEncoderupdate() {
-    return static_cast<Implementation&>(*this).updateImpl();
+  ManifestEncoder &update() {
+    return static_cast<Implementation &>(*this).updateImpl();
   }
 
-  ManifestEncodersetFinalBlockNumber(std::uint32_t final_block_number) {
-    return static_cast<Implementation&>(*this).setFinalBlockNumberImpl(
+  ManifestEncoder &setFinalBlockNumber(std::uint32_t final_block_number) {
+    return static_cast<Implementation &>(*this).setFinalBlockNumberImpl(
         final_block_number);
   }
 
@@ -142,52 +142,52 @@ class ManifestDecoder {
  public:
   virtual ~ManifestDecoder() = default;
 
-  ManifestDecoderclear() {
-    return static_cast<Implementation&>(*this).clearImpl();
+  ManifestDecoder &clear() {
+    return static_cast<Implementation &>(*this).clearImpl();
   }
 
-  void decode() { static_cast<Implementation&>(*this).decodeImpl(); }
+  void decode() { static_cast<Implementation &>(*this).decodeImpl(); }
 
   ManifestType getManifestType() const {
-    return static_cast<const Implementation&>(*this).getManifestTypeImpl();
+    return static_cast<const Implementation &>(*this).getManifestTypeImpl();
   }
 
   HashAlgorithm getHashAlgorithm() const {
-    return static_cast<const Implementation&>(*this).getHashAlgorithmImpl();
+    return static_cast<const Implementation &>(*this).getHashAlgorithmImpl();
   }
 
   uint32_t getFinalChunkNumber() const {
-    return static_cast<const Implementation&>(*this).getFinalChunkImpl();
+    return static_cast<const Implementation &>(*this).getFinalChunkImpl();
   }
 
   NextSegmentCalculationStrategy getNextSegmentCalculationStrategy() const {
-    return static_cast<const Implementation&>(*this)
+    return static_cast<const Implementation &>(*this)
         .getNextSegmentCalculationStrategyImpl();
   }
 
   core::Name getBaseName() const {
-    return static_cast<const Implementation&>(*this).getBaseNameImpl();
+    return static_cast<const Implementation &>(*this).getBaseNameImpl();
   }
 
   auto getSuffixHashList() {
-    return static_cast<Implementation&>(*this).getSuffixHashListImpl();
+    return static_cast<Implementation &>(*this).getSuffixHashListImpl();
   }
 
   bool getIsFinalManifest() const {
-    return static_cast<const Implementation&>(*this).getIsFinalManifestImpl();
+    return static_cast<const Implementation &>(*this).getIsFinalManifestImpl();
   }
 
   ManifestVersion getVersion() const {
-    return static_cast<const Implementation&>(*this).getVersionImpl();
+    return static_cast<const Implementation &>(*this).getVersionImpl();
   }
 
   std::size_t estimateSerializedLength(std::size_t number_of_entries) const {
-    return static_cast<const Implementation&>(*this)
+    return static_cast<const Implementation &>(*this)
         .estimateSerializedLengthImpl(number_of_entries);
   }
 
   uint32_t getFinalBlockNumber() const {
-    return static_cast<const Implementation&>(*this).getFinalBlockNumberImpl();
+    return static_cast<const Implementation &>(*this).getFinalBlockNumberImpl();
   }
 };
 
old mode 100755 (executable)
new mode 100644 (file)
index f26f20a..6141ae3
@@ -23,72 +23,72 @@ namespace transport {
 namespace core {
 
 // TODO use preallocated pool of membufs
-FixedManifestEncoder::FixedManifestEncoder(Packetpacket)
+FixedManifestEncoder::FixedManifestEncoder(Packet &packet)
     : packet_(packet),
       max_size_(Packet::default_mtu - packet_.headerSize()),
       manifest_(
           utils::MemBuf::create(Packet::default_mtu - packet_.headerSize())),
       manifest_header_(
-          reinterpret_cast<ManifestHeader*>(manifest_->writableData())),
-      manifest_entries_(reinterpret_cast<ManifestEntry*>(
+          reinterpret_cast<ManifestHeader *>(manifest_->writableData())),
+      manifest_entries_(reinterpret_cast<ManifestEntry *>(
           manifest_->writableData() + sizeof(ManifestHeader))),
       current_entry_(0) {}
 
 FixedManifestEncoder::~FixedManifestEncoder() {}
 
-FixedManifestEncoderFixedManifestEncoder::encodeImpl() {
+FixedManifestEncoder &FixedManifestEncoder::encodeImpl() {
   packet_.appendPayload(std::move(manifest_));
   return *this;
 }
 
-FixedManifestEncoderFixedManifestEncoder::clearImpl() {
+FixedManifestEncoder &FixedManifestEncoder::clearImpl() {
   manifest_ = utils::MemBuf::create(Packet::default_mtu - packet_.headerSize());
   return *this;
 }
 
-FixedManifestEncoderFixedManifestEncoder::setHashAlgorithmImpl(
+FixedManifestEncoder &FixedManifestEncoder::setHashAlgorithmImpl(
     HashAlgorithm algorithm) {
   manifest_header_->hash_algorithm = static_cast<uint8_t>(algorithm);
   return *this;
 }
 
-FixedManifestEncoderFixedManifestEncoder::setManifestTypeImpl(
+FixedManifestEncoder &FixedManifestEncoder::setManifestTypeImpl(
     ManifestType manifest_type) {
   manifest_header_->manifest_type = static_cast<uint8_t>(manifest_type);
   return *this;
 }
 
-FixedManifestEncoder&
+FixedManifestEncoder &
 FixedManifestEncoder::setNextSegmentCalculationStrategyImpl(
     NextSegmentCalculationStrategy strategy) {
   manifest_header_->next_segment_strategy = static_cast<uint8_t>(strategy);
   return *this;
 }
 
-FixedManifestEncoderFixedManifestEncoder::setBaseNameImpl(
-    const core::Namebase_name) {
+FixedManifestEncoder &FixedManifestEncoder::setBaseNameImpl(
+    const core::Name &base_name) {
   base_name.copyToDestination(
-      reinterpret_cast<uint8_t*>(&manifest_header_->prefix[0]), false);
+      reinterpret_cast<uint8_t *>(&manifest_header_->prefix[0]), false);
   manifest_header_->flags.ipv6 =
       base_name.getAddressFamily() == AF_INET6 ? 1_U8 : 0_U8;
   return *this;
 }
 
-FixedManifestEncoderFixedManifestEncoder::addSuffixAndHashImpl(
-    uint32_t suffix, const utils::CryptoHashhash) {
+FixedManifestEncoder &FixedManifestEncoder::addSuffixAndHashImpl(
+    uint32_t suffix, const utils::CryptoHash &hash) {
   auto _hash = hash.getDigest<std::uint8_t>();
   addSuffixHashBytes(suffix, _hash.data(), _hash.length());
   return *this;
 }
 
 void FixedManifestEncoder::addSuffixHashBytes(uint32_t suffix,
-                                              const uint8_thash,
+                                              const uint8_t *hash,
                                               std::size_t length) {
   manifest_entries_[current_entry_].suffix = utils::hton(suffix);
   //  std::copy(hash, hash + length,
   //            manifest_entries_[current_entry_].hash);
   std::memcpy(
-      reinterpret_cast<uint8_t*>(manifest_entries_[current_entry_].hash), hash,
+      reinterpret_cast<uint8_t *>(manifest_entries_[current_entry_].hash), hash,
       length);
 
   manifest_header_->number_of_entries++;
@@ -99,13 +99,13 @@ void FixedManifestEncoder::addSuffixHashBytes(uint32_t suffix,
   }
 }
 
-FixedManifestEncoderFixedManifestEncoder::setIsFinalManifestImpl(
+FixedManifestEncoder &FixedManifestEncoder::setIsFinalManifestImpl(
     bool is_last) {
   manifest_header_->flags.is_last = static_cast<uint8_t>(is_last);
   return *this;
 }
 
-FixedManifestEncoderFixedManifestEncoder::setVersionImpl(
+FixedManifestEncoder &FixedManifestEncoder::setVersionImpl(
     ManifestVersion version) {
   manifest_header_->version = static_cast<uint8_t>(version);
   return *this;
@@ -118,17 +118,17 @@ std::size_t FixedManifestEncoder::estimateSerializedLengthImpl(
              sizeof(ManifestEntry);
 }
 
-FixedManifestEncoderFixedManifestEncoder::updateImpl() {
+FixedManifestEncoder &FixedManifestEncoder::updateImpl() {
   max_size_ = Packet::default_mtu - packet_.headerSize();
-  manifest_header_ = reinterpret_cast<ManifestHeader*>(
-      const_cast<uint8_t*>(packet_.getPayload().data()));
-  manifest_entries_ = reinterpret_cast<ManifestEntry*>(
-      const_cast<uint8_t*>(packet_.getPayload().data()) +
+  manifest_header_ = reinterpret_cast<ManifestHeader *>(
+      const_cast<uint8_t *>(packet_.getPayload().data()));
+  manifest_entries_ = reinterpret_cast<ManifestEntry *>(
+      const_cast<uint8_t *>(packet_.getPayload().data()) +
       sizeof(ManifestHeader));
   return *this;
 }
 
-FixedManifestEncoderFixedManifestEncoder::setFinalBlockNumberImpl(
+FixedManifestEncoder &FixedManifestEncoder::setFinalBlockNumberImpl(
     std::uint32_t final_block_number) {
   manifest_header_->final_block_number = utils::hton(final_block_number);
   return *this;
@@ -138,12 +138,12 @@ std::size_t FixedManifestEncoder::getManifestHeaderSizeImpl() {
   return sizeof(ManifestHeader);
 }
 
-FixedManifestDecoder::FixedManifestDecoder(Packetpacket)
+FixedManifestDecoder::FixedManifestDecoder(Packet &packet)
     : packet_(packet),
-      manifest_header_(reinterpret_cast<ManifestHeader*>(
-          const_cast<uint8_t*>(packet_.getPayload().data()))),
-      manifest_entries_(reinterpret_cast<ManifestEntry*>(
-          const_cast<uint8_t*>(packet_.getPayload().data()) +
+      manifest_header_(reinterpret_cast<ManifestHeader *>(
+          const_cast<uint8_t *>(packet_.getPayload().data()))),
+      manifest_entries_(reinterpret_cast<ManifestEntry *>(
+          const_cast<uint8_t *>(packet_.getPayload().data()) +
           sizeof(ManifestHeader))) {}
 
 FixedManifestDecoder::~FixedManifestDecoder() {}
@@ -158,7 +158,7 @@ void FixedManifestDecoder::decodeImpl() {
   }
 }
 
-FixedManifestDecoderFixedManifestDecoder::clearImpl() { return *this; }
+FixedManifestDecoder &FixedManifestDecoder::clearImpl() { return *this; }
 
 ManifestType FixedManifestDecoder::getManifestTypeImpl() const {
   return static_cast<ManifestType>(manifest_header_->manifest_type);
@@ -180,7 +180,7 @@ typename Fixed::SuffixList FixedManifestDecoder::getSuffixHashListImpl() {
   for (int i = 0; i < manifest_header_->number_of_entries; i++) {
     hash_list.insert(hash_list.end(),
                      std::make_pair(utils::ntoh(manifest_entries_[i].suffix),
-                                    reinterpret_cast<uint8_t*>(
+                                    reinterpret_cast<uint8_t *>(
                                         &manifest_entries_[i].hash[0])));
   }
 
@@ -190,10 +190,10 @@ typename Fixed::SuffixList FixedManifestDecoder::getSuffixHashListImpl() {
 core::Name FixedManifestDecoder::getBaseNameImpl() const {
   if (static_cast<bool>(manifest_header_->flags.ipv6)) {
     return core::Name(AF_INET6,
-                      reinterpret_cast<uint8_t*>(&manifest_header_->prefix));
+                      reinterpret_cast<uint8_t *>(&manifest_header_->prefix));
   } else {
     return core::Name(AF_INET,
-                      reinterpret_cast<uint8_t*>(&manifest_header_->prefix));
+                      reinterpret_cast<uint8_t *>(&manifest_header_->prefix));
   }
 }
 
old mode 100755 (executable)
new mode 100644 (file)
index 66825e2..82817dd
@@ -53,7 +53,7 @@ struct Fixed {
   using Encoder = FixedManifestEncoder;
   using Decoder = FixedManifestDecoder;
   using HashType = utils::CryptoHash;
-  using SuffixList = std::list<std::pair<std::uint32_t, std::uint8_t*>>;
+  using SuffixList = std::list<std::pair<std::uint32_t, std::uint8_t *>>;
 };
 
 struct Flags {
@@ -83,60 +83,60 @@ static const constexpr std::uint8_t manifest_version = 1;
 
 class FixedManifestEncoder : public ManifestEncoder<FixedManifestEncoder> {
  public:
-  FixedManifestEncoder(Packetpacket);
+  FixedManifestEncoder(Packet &packet);
 
   ~FixedManifestEncoder();
 
-  FixedManifestEncoderencodeImpl();
+  FixedManifestEncoder &encodeImpl();
 
-  FixedManifestEncoderclearImpl();
+  FixedManifestEncoder &clearImpl();
 
-  FixedManifestEncodersetManifestTypeImpl(ManifestType manifest_type);
+  FixedManifestEncoder &setManifestTypeImpl(ManifestType manifest_type);
 
-  FixedManifestEncodersetHashAlgorithmImpl(HashAlgorithm algorithm);
+  FixedManifestEncoder &setHashAlgorithmImpl(HashAlgorithm algorithm);
 
-  FixedManifestEncodersetNextSegmentCalculationStrategyImpl(
+  FixedManifestEncoder &setNextSegmentCalculationStrategyImpl(
       NextSegmentCalculationStrategy strategy);
 
-  FixedManifestEncoder& setBaseNameImpl(const core::Name& base_name);
+  FixedManifestEncoder &setBaseNameImpl(const core::Name &base_name);
 
-  FixedManifestEncoderaddSuffixAndHashImpl(uint32_t suffix,
-                                             const utils::CryptoHashhash);
+  FixedManifestEncoder &addSuffixAndHashImpl(uint32_t suffix,
+                                             const utils::CryptoHash &hash);
 
-  FixedManifestEncodersetIsFinalManifestImpl(bool is_last);
+  FixedManifestEncoder &setIsFinalManifestImpl(bool is_last);
 
-  FixedManifestEncodersetVersionImpl(ManifestVersion version);
+  FixedManifestEncoder &setVersionImpl(ManifestVersion version);
 
   std::size_t estimateSerializedLengthImpl(std::size_t additional_entries = 0);
 
-  FixedManifestEncoderupdateImpl();
+  FixedManifestEncoder &updateImpl();
 
-  FixedManifestEncodersetFinalBlockNumberImpl(
+  FixedManifestEncoder &setFinalBlockNumberImpl(
       std::uint32_t final_block_number);
 
   static std::size_t getManifestHeaderSizeImpl();
 
  private:
-  void addSuffixHashBytes(uint32_t suffix, const uint8_thash,
+  void addSuffixHashBytes(uint32_t suffix, const uint8_t *hash,
                           std::size_t length);
 
-  Packetpacket_;
+  Packet &packet_;
   std::size_t max_size_;
   std::unique_ptr<utils::MemBuf> manifest_;
-  ManifestHeadermanifest_header_;
-  ManifestEntrymanifest_entries_;
+  ManifestHeader *manifest_header_;
+  ManifestEntry *manifest_entries_;
   std::size_t current_entry_;
 };
 
 class FixedManifestDecoder : public ManifestDecoder<FixedManifestDecoder> {
  public:
-  FixedManifestDecoder(Packetpacket);
+  FixedManifestDecoder(Packet &packet);
 
   ~FixedManifestDecoder();
 
   void decodeImpl();
 
-  FixedManifestDecoderclearImpl();
+  FixedManifestDecoder &clearImpl();
 
   ManifestType getManifestTypeImpl() const;
 
@@ -158,9 +158,9 @@ class FixedManifestDecoder : public ManifestDecoder<FixedManifestDecoder> {
   uint32_t getFinalBlockNumberImpl() const;
 
  private:
-  Packetpacket_;
-  ManifestHeadermanifest_header_;
-  ManifestEntrymanifest_entries_;
+  Packet &packet_;
+  ManifestHeader *manifest_header_;
+  ManifestEntry *manifest_entries_;
 };
 
 }  // namespace core
old mode 100755 (executable)
new mode 100644 (file)
index 512cdba..0ffca39
@@ -25,38 +25,38 @@ namespace core {
 namespace {
 
 template <typename T>
-TRANSPORT_ALWAYS_INLINE void checkPointer(Tpointer) {
+TRANSPORT_ALWAYS_INLINE void checkPointer(T *pointer) {
   if (pointer == nullptr) {
     throw errors::NullPointerException();
   }
 }
 
 template <typename EnumType>
-TRANSPORT_ALWAYS_INLINE void setValueToJson(Json::Valueroot, EnumType value) {
+TRANSPORT_ALWAYS_INLINE void setValueToJson(Json::Value &root, EnumType value) {
   root[JSONKey<EnumType>::key] = static_cast<uint8_t>(value);
 }
 
 template <typename EnumType>
-TRANSPORT_ALWAYS_INLINE EnumType getValueFromJson(const Json::Valueroot) {
+TRANSPORT_ALWAYS_INLINE EnumType getValueFromJson(const Json::Value &root) {
   return static_cast<EnumType>(root[JSONKey<EnumType>::key].asUInt());
 };
 
 }  // namespace
 
-JSONManifestEncoder::JSONManifestEncoder(Packetpacket) : packet_(packet) {}
+JSONManifestEncoder::JSONManifestEncoder(Packet &packet) : packet_(packet) {}
 
 JSONManifestEncoder::~JSONManifestEncoder() {}
 
-TRANSPORT_ALWAYS_INLINE JSONManifestEncoderJSONManifestEncoder::encodeImpl() {
+TRANSPORT_ALWAYS_INLINE JSONManifestEncoder &JSONManifestEncoder::encodeImpl() {
   Json::StreamWriterBuilder writer_builder;
-  Json::StreamWriterfast_writer = writer_builder.newStreamWriter();
+  Json::StreamWriter *fast_writer = writer_builder.newStreamWriter();
 
   asio::streambuf strbuf;
   strbuf.prepare(1500);
   std::ostream stream(&strbuf);
   fast_writer->write(root_, &stream);
 
-  const uint8_t* buffer = asio::buffer_cast<const uint8_t*>(strbuf.data());
+  const uint8_t *buffer = asio::buffer_cast<const uint8_t *>(strbuf.data());
 
   packet_.setPayload(buffer, strbuf.size());
 
@@ -65,38 +65,38 @@ TRANSPORT_ALWAYS_INLINE JSONManifestEncoder& JSONManifestEncoder::encodeImpl() {
   return *this;
 }
 
-TRANSPORT_ALWAYS_INLINE JSONManifestEncoderJSONManifestEncoder::clearImpl() {
+TRANSPORT_ALWAYS_INLINE JSONManifestEncoder &JSONManifestEncoder::clearImpl() {
   root_.clear();
   return *this;
 }
 
-TRANSPORT_ALWAYS_INLINE JSONManifestEncoder&
+TRANSPORT_ALWAYS_INLINE JSONManifestEncoder &
 JSONManifestEncoder::setHashAlgorithmImpl(HashAlgorithm algorithm) {
   setValueToJson(root_, algorithm);
   return *this;
 }
 
-JSONManifestEncoderJSONManifestEncoder::setManifestTypeImpl(
+JSONManifestEncoder &JSONManifestEncoder::setManifestTypeImpl(
     ManifestType manifest_type) {
   setValueToJson(root_, manifest_type);
   return *this;
 }
 
-JSONManifestEncoderJSONManifestEncoder::setNextSegmentCalculationStrategyImpl(
+JSONManifestEncoder &JSONManifestEncoder::setNextSegmentCalculationStrategyImpl(
     NextSegmentCalculationStrategy strategy) {
   setValueToJson(root_, strategy);
   return *this;
 }
 
-TRANSPORT_ALWAYS_INLINE JSONManifestEncoder&
-JSONManifestEncoder::setBaseNameImpl(const core::Namebase_name) {
+TRANSPORT_ALWAYS_INLINE JSONManifestEncoder &
+JSONManifestEncoder::setBaseNameImpl(const core::Name &base_name) {
   root_[JSONKey<core::Name>::key] = base_name.toString().c_str();
   return *this;
 }
 
-TRANSPORT_ALWAYS_INLINE JSONManifestEncoder&
+TRANSPORT_ALWAYS_INLINE JSONManifestEncoder &
 JSONManifestEncoder::addSuffixAndHashImpl(uint32_t suffix,
-                                          const utils::CryptoHashhash) {
+                                          const utils::CryptoHash &hash) {
   throw errors::NotImplementedException();
   //  Json::Value value(Json::arrayValue);
   //  value.append(Json::Value(suffix));
@@ -106,21 +106,21 @@ JSONManifestEncoder::addSuffixAndHashImpl(uint32_t suffix,
   return *this;
 }
 
-TRANSPORT_ALWAYS_INLINE JSONManifestEncoder&
+TRANSPORT_ALWAYS_INLINE JSONManifestEncoder &
 JSONManifestEncoder::setIsFinalManifestImpl(bool is_last) {
   root_[JSONKey<bool>::final_manifest] = is_last;
   return *this;
 }
 
-TRANSPORT_ALWAYS_INLINE JSONManifestEncoder&
+TRANSPORT_ALWAYS_INLINE JSONManifestEncoder &
 JSONManifestEncoder::setVersionImpl(ManifestVersion version) {
   setValueToJson(root_, version);
   return *this;
 }
 
-TRANSPORT_ALWAYS_INLINE JSONManifestEncoder&
+TRANSPORT_ALWAYS_INLINE JSONManifestEncoder &
 JSONManifestEncoder::setSuffixHashListImpl(
-    const typename JSON::SuffixListname_hash_list) {
+    const typename JSON::SuffixList &name_hash_list) {
   throw errors::NotImplementedException();
   //  for (auto &suffix : name_hash_list) {
   //    addSuffixAndHashImpl(suffix.first, suffix.second);
@@ -133,7 +133,7 @@ TRANSPORT_ALWAYS_INLINE std::size_t
 JSONManifestEncoder::estimateSerializedLengthImpl(
     std::size_t number_of_entries) {
   Json::StreamWriterBuilder writer_builder;
-  Json::StreamWriterfast_writer = writer_builder.newStreamWriter();
+  Json::StreamWriter *fast_writer = writer_builder.newStreamWriter();
 
   asio::streambuf strbuf;
   strbuf.prepare(1500);
@@ -143,11 +143,11 @@ JSONManifestEncoder::estimateSerializedLengthImpl(
   return strbuf.size();
 }
 
-TRANSPORT_ALWAYS_INLINE JSONManifestEncoderJSONManifestEncoder::updateImpl() {
+TRANSPORT_ALWAYS_INLINE JSONManifestEncoder &JSONManifestEncoder::updateImpl() {
   throw errors::NotImplementedException();
 }
 
-TRANSPORT_ALWAYS_INLINE JSONManifestEncoder&
+TRANSPORT_ALWAYS_INLINE JSONManifestEncoder &
 JSONManifestEncoder::setFinalBlockNumberImpl(std::uint32_t final_block_number) {
   throw errors::NotImplementedException();
 }
@@ -157,7 +157,7 @@ JSONManifestEncoder::getManifestHeaderSizeImpl() {
   return 0;
 }
 
-JSONManifestDecoder::JSONManifestDecoder(Packetpacket) : packet_(packet) {}
+JSONManifestDecoder::JSONManifestDecoder(Packet &packet) : packet_(packet) {}
 
 JSONManifestDecoder::~JSONManifestDecoder() {}
 
@@ -167,10 +167,10 @@ TRANSPORT_ALWAYS_INLINE void JSONManifestDecoder::decodeImpl() {
   auto payload_size = array.length();
 
   Json::CharReaderBuilder reader_builder;
-  Json::CharReaderreader = reader_builder.newCharReader();
+  Json::CharReader *reader = reader_builder.newCharReader();
   std::string errors;
 
-  if (!reader->parse((char*)payload, (char*)payload + payload_size, &root_,
+  if (!reader->parse((char *)payload, (char *)payload + payload_size, &root_,
                      &errors)) {
     TRANSPORT_LOGE("Error parsing manifest!");
     TRANSPORT_LOGE("%s", errors.c_str());
@@ -183,7 +183,7 @@ TRANSPORT_ALWAYS_INLINE void JSONManifestDecoder::decodeImpl() {
   delete reader;
 }
 
-TRANSPORT_ALWAYS_INLINE JSONManifestDecoderJSONManifestDecoder::clearImpl() {
+TRANSPORT_ALWAYS_INLINE JSONManifestDecoder &JSONManifestDecoder::clearImpl() {
   root_.clear();
   return *this;
 }
old mode 100755 (executable)
new mode 100644 (file)
index 39f0cf3..84d2ba2
@@ -38,7 +38,7 @@ struct JSON {
   using Encoder = JSONManifestEncoder;
   using Decoder = JSONManifestDecoder;
   using HashType = utils::CryptoHash;
-  using SuffixList = std::unordered_map<std::uint32_t, std::uint8_t*>;
+  using SuffixList = std::unordered_map<std::uint32_t, std::uint8_t *>;
 };
 
 template <typename T>
@@ -46,91 +46,91 @@ struct JSONKey;
 
 template <>
 struct JSONKey<ManifestVersion> {
-  static const constexpr charkey = "manifest_version";
+  static const constexpr char *key = "manifest_version";
 };
 
 template <>
 struct JSONKey<HashAlgorithm> {
-  static const constexpr charkey = "hash_algorithm";
+  static const constexpr char *key = "hash_algorithm";
 };
 
 template <>
 struct JSONKey<ManifestType> {
-  static const constexpr charkey = "manifest_type";
+  static const constexpr char *key = "manifest_type";
 };
 
 template <>
 struct JSONKey<NextSegmentCalculationStrategy> {
-  static const constexpr charkey = "next_segment_strategy";
+  static const constexpr char *key = "next_segment_strategy";
 };
 
 template <>
 struct JSONKey<typename JSON::SuffixList> {
-  static const constexpr charkey = "suffix_hash_list";
+  static const constexpr char *key = "suffix_hash_list";
 };
 
 template <>
 struct JSONKey<core::Name> {
-  static const constexpr charkey = "base_name";
+  static const constexpr char *key = "base_name";
 };
 
 template <>
 struct JSONKey<bool> {
-  static const constexpr charfinal_manifest = "final_manifest";
+  static const constexpr char *final_manifest = "final_manifest";
 };
 
 class JSONManifestEncoder : public ManifestEncoder<JSONManifestEncoder> {
  public:
-  JSONManifestEncoder(Packetpacket);
+  JSONManifestEncoder(Packet &packet);
 
   ~JSONManifestEncoder() override;
 
-  JSONManifestEncoderencodeImpl();
+  JSONManifestEncoder &encodeImpl();
 
-  JSONManifestEncoderclearImpl();
+  JSONManifestEncoder &clearImpl();
 
-  JSONManifestEncodersetManifestTypeImpl(ManifestType manifest_type);
+  JSONManifestEncoder &setManifestTypeImpl(ManifestType manifest_type);
 
-  JSONManifestEncodersetHashAlgorithmImpl(HashAlgorithm algorithm);
+  JSONManifestEncoder &setHashAlgorithmImpl(HashAlgorithm algorithm);
 
-  JSONManifestEncodersetNextSegmentCalculationStrategyImpl(
+  JSONManifestEncoder &setNextSegmentCalculationStrategyImpl(
       NextSegmentCalculationStrategy strategy);
 
-  JSONManifestEncodersetSuffixHashListImpl(
-      const typename JSON::SuffixListname_hash_list);
+  JSONManifestEncoder &setSuffixHashListImpl(
+      const typename JSON::SuffixList &name_hash_list);
 
-  JSONManifestEncoder& setBaseNameImpl(const core::Name& base_name);
+  JSONManifestEncoder &setBaseNameImpl(const core::Name &base_name);
 
-  JSONManifestEncoderaddSuffixAndHashImpl(uint32_t suffix,
-                                            const utils::CryptoHashhash);
+  JSONManifestEncoder &addSuffixAndHashImpl(uint32_t suffix,
+                                            const utils::CryptoHash &hash);
 
-  JSONManifestEncodersetIsFinalManifestImpl(bool is_last);
+  JSONManifestEncoder &setIsFinalManifestImpl(bool is_last);
 
-  JSONManifestEncodersetVersionImpl(ManifestVersion version);
+  JSONManifestEncoder &setVersionImpl(ManifestVersion version);
 
   std::size_t estimateSerializedLengthImpl(std::size_t number_of_entries);
 
-  JSONManifestEncoderupdateImpl();
+  JSONManifestEncoder &updateImpl();
 
-  JSONManifestEncodersetFinalBlockNumberImpl(
+  JSONManifestEncoder &setFinalBlockNumberImpl(
       std::uint32_t final_block_number);
 
   static std::size_t getManifestHeaderSizeImpl();
 
  private:
-  Packetpacket_;
+  Packet &packet_;
   Json::Value root_;
 };
 
 class JSONManifestDecoder : public ManifestDecoder<JSONManifestDecoder> {
  public:
-  JSONManifestDecoder(Packetpacket);
+  JSONManifestDecoder(Packet &packet);
 
   ~JSONManifestDecoder() override;
 
   void decodeImpl();
 
-  JSONManifestDecoderclearImpl();
+  JSONManifestDecoder &clearImpl();
 
   ManifestType getManifestTypeImpl() const;
 
@@ -153,7 +153,7 @@ class JSONManifestDecoder : public ManifestDecoder<JSONManifestDecoder> {
   uint32_t getFinalBlockNumberImpl() const;
 
  private:
-  Packetpacket_;
+  Packet &packet_;
   Json::Value root_;
 };
 
old mode 100755 (executable)
new mode 100644 (file)
index d0365d2..a3a47e6
@@ -29,23 +29,23 @@ namespace core {
 namespace {
 
 template <typename T>
-TRANSPORT_ALWAYS_INLINE void checkPointer(Tpointer) {
+TRANSPORT_ALWAYS_INLINE void checkPointer(T *pointer) {
   if (pointer == nullptr) {
     throw errors::NullPointerException();
   }
 }
 
 template <typename EnumType>
-TRANSPORT_ALWAYS_INLINE void setValueToJson(PARCJSONroot, EnumType value) {
+TRANSPORT_ALWAYS_INLINE void setValueToJson(PARCJSON *root, EnumType value) {
   parcJSON_AddInteger(root, JSONKey<EnumType>::key,
                       static_cast<int64_t>(value));
 }
 
 template <typename EnumType>
-TRANSPORT_ALWAYS_INLINE EnumType getValueFromJson(PARCJSONroot) {
+TRANSPORT_ALWAYS_INLINE EnumType getValueFromJson(PARCJSON *root) {
   checkPointer(root);
 
-  PARCJSONValuevalue = parcJSON_GetValueByName(root, JSONKey<EnumType>::key);
+  PARCJSONValue *value = parcJSON_GetValueByName(root, JSONKey<EnumType>::key);
 
   EnumType ret = static_cast<EnumType>(parcJSONValue_GetInteger(value));
   // parcJSONValue_Release(&value);
@@ -65,17 +65,17 @@ JSONManifestEncoder::~JSONManifestEncoder() {
   }
 }
 
-TRANSPORT_ALWAYS_INLINE SONManifestEncoderJSONManifestEncoder::encodeImpl(
-    Packetpacket) {
-  charjson_string = parcJSON_ToString(root_);
-  packet.setPayload(reinterpret_cast<uint8_t*>(json_string),
+TRANSPORT_ALWAYS_INLINE SONManifestEncoder &JSONManifestEncoder::encodeImpl(
+    Packet &packet) {
+  char *json_string = parcJSON_ToString(root_);
+  packet.setPayload(reinterpret_cast<uint8_t *>(json_string),
                     std::strlen(json_string));
   parcMemory_Deallocate(&json_string);
 
   return *this;
 }
 
-TRANSPORT_ALWAYS_INLINE JSONManifestEncoderJSONManifestEncoder::clearImpl() {
+TRANSPORT_ALWAYS_INLINE JSONManifestEncoder &JSONManifestEncoder::clearImpl() {
   if (root_) {
     parcJSON_Release(&root_);
   }
@@ -85,35 +85,35 @@ TRANSPORT_ALWAYS_INLINE JSONManifestEncoder& JSONManifestEncoder::clearImpl() {
   return *this;
 }
 
-TRANSPORT_ALWAYS_INLINE JSONManifestEncoder&
+TRANSPORT_ALWAYS_INLINE JSONManifestEncoder &
 JSONManifestEncoder::setHashAlgorithmImpl(HashAlgorithm algorithm) {
   setValueToJson(root_, algorithm);
   return *this;
 }
 
-TRANSPORT_ALWAYS_INLINE JSONManifestEncoder&
+TRANSPORT_ALWAYS_INLINE JSONManifestEncoder &
 JSONManifestEncoder::setManifestTypeImpl(ManifestType manifest_type) {
   setValueToJson(root_, manifest_type);
   return *this;
 }
 
-TRANSPORT_ALWAYS_INLINE JSONManifestEncoder&
+TRANSPORT_ALWAYS_INLINE JSONManifestEncoder &
 JSONManifestEncoder::setNextSegmentCalculationStrategyImpl(
     NextSegmentCalculationStrategy strategy) {
   setValueToJson(root_, strategy);
   return *this;
 }
 
-TRANSPORT_ALWAYS_INLINE JSONManifestEncoder&
-JSONManifestEncoder::setBaseNameImpl(const core::Namebase_name) {
+TRANSPORT_ALWAYS_INLINE JSONManifestEncoder &
+JSONManifestEncoder::setBaseNameImpl(const core::Name &base_name) {
   parcJSON_AddString(root_, JSONKey<core::Name>::key,
                      base_name.toString().c_str());
   return *this;
 }
 
-TRANSPORT_ALWAYS_INLINE JSONManifestEncoder&
+TRANSPORT_ALWAYS_INLINE JSONManifestEncoder &
 JSONManifestEncoder::addSuffixAndHashImpl(uint32_t suffix,
-                                          utils::CryptoHashhash) {
+                                          utils::CryptoHash &hash) {
   throw errors::NotImplementedException();
   //  PARCJSONValue *value = parcJSON_GetValueByName(root_,
   //                                                 JSONKey<SuffixHashList>::key);
@@ -151,17 +151,17 @@ JSONManifestEncoder::addSuffixAndHashImpl(uint32_t suffix,
   return *this;
 }
 
-TRANSPORT_ALWAYS_INLINE JSONManifestEncoder&
+TRANSPORT_ALWAYS_INLINE JSONManifestEncoder &
 JSONManifestEncoder::setIsFinalManifestImpl(bool is_last) {
   parcJSON_AddBoolean(root_, JSONKey<bool>::final_manifest, is_last);
 
   return *this;
 }
 
-TRANSPORT_ALWAYS_INLINE JSONManifestEncoder&
+TRANSPORT_ALWAYS_INLINE JSONManifestEncoder &
 JSONManifestEncoder::setSuffixHashListImpl(
-    const SuffixHashListname_hash_list) {
-  for (autosuffix : name_hash_list) {
+    const SuffixHashList &name_hash_list) {
+  for (auto &suffix : name_hash_list) {
     addSuffixAndHashImpl(suffix.first, suffix.second);
   }
 
@@ -178,18 +178,18 @@ TRANSPORT_ALWAYS_INLINE JSONManifestDecoder::~JSONManifestDecoder() {
 }
 
 TRANSPORT_ALWAYS_INLINE void JSONManifestDecoder::decodeImpl(
-    const uint8_tpayload, std::size_t payload_size) {
-  PARCBuffer* b = parcBuffer_Wrap(const_cast<uint8_t*>(payload), payload_size,
+    const uint8_t *payload, std::size_t payload_size) {
+  PARCBuffer *b = parcBuffer_Wrap(const_cast<uint8_t *>(payload), payload_size,
                                   0, payload_size);
   clearImpl();
 
   root_ = parcJSON_ParseBuffer(b);
   parcBuffer_Release(&b);
 
-  charstr = parcJSON_ToString(root_);
+  char *str = parcJSON_ToString(root_);
 }
 
-TRANSPORT_ALWAYS_INLINE JSONManifestDecoderJSONManifestDecoder::clearImpl() {
+TRANSPORT_ALWAYS_INLINE JSONManifestDecoder &JSONManifestDecoder::clearImpl() {
   if (root_) {
     parcJSON_Release(&root_);
   }
@@ -261,11 +261,11 @@ JSONManifestDecoder::getSuffixHashListImpl() {
 TRANSPORT_ALWAYS_INLINE core::Name JSONManifestDecoder::getBaseNameImpl()
     const {
   checkPointer(root_);
-  PARCJSONValuevalue =
+  PARCJSONValue *value =
       parcJSON_GetValueByName(root_, JSONKey<core::Name>::key);
 
-  PARCBufferb = parcJSONValue_GetString(value);
-  charstring = parcBuffer_ToString(b);
+  PARCBuffer *b = parcJSONValue_GetString(value);
+  char *string = parcBuffer_ToString(b);
 
   core::Name ret(string);
 
@@ -277,7 +277,7 @@ TRANSPORT_ALWAYS_INLINE core::Name JSONManifestDecoder::getBaseNameImpl()
 
 TRANSPORT_ALWAYS_INLINE bool JSONManifestDecoder::getIsFinalManifestImpl() {
   checkPointer(root_);
-  PARCJSONValuevalue =
+  PARCJSONValue *value =
       parcJSON_GetValueByName(root_, JSONKey<bool>::final_manifest);
 
   bool ret = parcJSONValue_GetBoolean(value);
old mode 100755 (executable)
new mode 100644 (file)
index 28c6c1b..c89f4af
@@ -42,37 +42,37 @@ struct JSONKey;
 
 template <>
 struct JSONKey<HashAlgorithm> {
-  static const constexpr charkey = "hash_algorithm";
+  static const constexpr char *key = "hash_algorithm";
 };
 
 template <>
 struct JSONKey<ManifestType> {
-  static const constexpr charkey = "manifest_type";
+  static const constexpr char *key = "manifest_type";
 };
 
 template <>
 struct JSONKey<NextSegmentCalculationStrategy> {
-  static const constexpr charkey = "next_segment_strategy";
+  static const constexpr char *key = "next_segment_strategy";
 };
 
 template <>
 struct JSONKey<NameHashList> {
-  static const constexpr charkey = "name_hash_list";
+  static const constexpr char *key = "name_hash_list";
 };
 
 template <>
 struct JSONKey<SuffixHashList> {
-  static const constexpr charkey = "suffix_hash_list";
+  static const constexpr char *key = "suffix_hash_list";
 };
 
 template <>
 struct JSONKey<core::Name> {
-  static const constexpr charkey = "base_name";
+  static const constexpr char *key = "base_name";
 };
 
 template <>
 struct JSONKey<bool> {
-  static const constexpr charfinal_manifest = "final_manifest";
+  static const constexpr char *final_manifest = "final_manifest";
 };
 
 // template <>
@@ -95,28 +95,28 @@ class JSONManifestEncoder : public ManifestEncoder<JSONManifestEncoder> {
 
   ~JSONManifestEncoder();
 
-  JSONManifestEncoder& encodeImpl(Packet& packet);
+  JSONManifestEncoder &encodeImpl(Packet &packet);
 
-  JSONManifestEncoderclearImpl();
+  JSONManifestEncoder &clearImpl();
 
-  JSONManifestEncodersetManifestTypeImpl(ManifestType manifest_type);
+  JSONManifestEncoder &setManifestTypeImpl(ManifestType manifest_type);
 
-  JSONManifestEncodersetHashAlgorithmImpl(HashAlgorithm algorithm);
+  JSONManifestEncoder &setHashAlgorithmImpl(HashAlgorithm algorithm);
 
-  JSONManifestEncodersetNextSegmentCalculationStrategyImpl(
+  JSONManifestEncoder &setNextSegmentCalculationStrategyImpl(
       NextSegmentCalculationStrategy strategy);
 
-  JSONManifestEncodersetSuffixHashListImpl(
-      const SuffixHashListname_hash_list);
+  JSONManifestEncoder &setSuffixHashListImpl(
+      const SuffixHashList &name_hash_list);
 
-  JSONManifestEncoder& setBaseNameImpl(const core::Name& base_name);
+  JSONManifestEncoder &setBaseNameImpl(const core::Name &base_name);
 
-  JSONManifestEncoderaddSuffixAndHashImpl(uint32_t suffix, uint64_t hash);
+  JSONManifestEncoder &addSuffixAndHashImpl(uint32_t suffix, uint64_t hash);
 
-  JSONManifestEncodersetIsFinalManifestImpl(bool is_last);
+  JSONManifestEncoder &setIsFinalManifestImpl(bool is_last);
 
  private:
-  PARCJSONroot_;
+  PARCJSON *root_;
 };
 
 class JSONManifestDecoder : public ManifestDecoder<JSONManifestDecoder> {
@@ -125,9 +125,9 @@ class JSONManifestDecoder : public ManifestDecoder<JSONManifestDecoder> {
 
   ~JSONManifestDecoder();
 
-  void decodeImpl(const uint8_tpayload, std::size_t payload_size);
+  void decodeImpl(const uint8_t *payload, std::size_t payload_size);
 
-  JSONManifestDecoderclearImpl();
+  JSONManifestDecoder &clearImpl();
 
   ManifestType getManifestTypeImpl() const;
 
@@ -144,7 +144,7 @@ class JSONManifestDecoder : public ManifestDecoder<JSONManifestDecoder> {
   bool getIsFinalManifestImpl();
 
  private:
-  PARCJSONroot_;
+  PARCJSON *root_;
 };
 
 }  // namespace core
old mode 100755 (executable)
new mode 100644 (file)
index fd1a9ab..1f2c4ed
@@ -37,15 +37,15 @@ class ManifestInline
  public:
   ManifestInline() : ManifestBase() {}
 
-  ManifestInline(const core::Namename) : ManifestBase(name) {}
+  ManifestInline(const core::Name &name) : ManifestBase(name) {}
 
   template <typename T>
-  ManifestInline(T&& base) : ManifestBase(std::forward<T&&>(base)) {}
+  ManifestInline(T &&base) : ManifestBase(std::forward<T &&>(base)) {}
 
-  static TRANSPORT_ALWAYS_INLINE ManifestInlinecreateManifest(
-      const core::Namemanifest_name, ManifestVersion version,
+  static TRANSPORT_ALWAYS_INLINE ManifestInline *createManifest(
+      const core::Name &manifest_name, ManifestVersion version,
       ManifestType type, HashAlgorithm algorithm, bool is_last,
-      const Namebase_name, NextSegmentCalculationStrategy strategy,
+      const Name &base_name, NextSegmentCalculationStrategy strategy,
       std::size_t signature_size) {
     auto manifest = new ManifestInline(manifest_name);
     manifest->setSignatureSize(signature_size);
@@ -59,12 +59,12 @@ class ManifestInline
     return manifest;
   }
 
-  ManifestInlineencodeImpl() {
+  ManifestInline &encodeImpl() {
     ManifestBase::encoder_.encode();
     return *this;
   }
 
-  ManifestInlinedecodeImpl() {
+  ManifestInline &decodeImpl() {
     base_name_ = ManifestBase::decoder_.getBaseName();
     next_segment_strategy_ =
         ManifestBase::decoder_.getNextSegmentCalculationStrategy();
@@ -77,23 +77,23 @@ class ManifestInline
     return ManifestBase::encoder_.estimateSerializedLength(additional_entries);
   }
 
-  ManifestInline& setBaseName(const Name& name) {
+  ManifestInline &setBaseName(const Name &name) {
     base_name_ = name;
     ManifestBase::encoder_.setBaseName(base_name_);
     return *this;
   }
 
-  const NamegetBaseName() { return base_name_; }
+  const Name &getBaseName() { return base_name_; }
 
-  ManifestInline& addSuffixHash(uint32_t suffix, const HashType& hash) {
+  ManifestInline &addSuffixHash(uint32_t suffix, const HashType &hash) {
     ManifestBase::encoder_.addSuffixAndHash(suffix, hash);
     return *this;
   }
 
   // Call this function only after the decode function!
-  const SuffixListgetSuffixList() { return suffix_hash_map_; }
+  const SuffixList &getSuffixList() { return suffix_hash_map_; }
 
-  ManifestInlinesetNextSegmentCalculationStrategy(
+  ManifestInline &setNextSegmentCalculationStrategy(
       NextSegmentCalculationStrategy strategy) {
     next_segment_strategy_ = strategy;
     ManifestBase::encoder_.setNextSegmentCalculationStrategy(
old mode 100755 (executable)
new mode 100644 (file)
index b443b51..834c8db
 #include <vpp/api/vpe_all_api_h.h>
 #undef vl_typedefs
 
+static context_store_t context_store = {
+    .global_pointers_map_index = 0,
+};
+
 /*
  * Table of message reply handlers, must include boilerplate handlers
  * we just generated
   _(MEMIF_DELETE_REPLY, memif_delete_reply) \
   _(MEMIF_DETAILS, memif_details)
 
-#define POINTER_MAP_SIZE 32
-static void *global_pointers_map[POINTER_MAP_SIZE];
-static uint8_t global_pointers_map_index = 0;
-
-uint32_t memif_binary_api_get_next_memif_id(vpp_plugin_binary_api_t *api) {
+int memif_binary_api_get_next_memif_id(vpp_plugin_binary_api_t *api,
+                                       uint32_t *memif_id) {
   // Dump all the memif interfaces and return the next to the largest memif id
   vl_api_memif_dump_t *mp;
   vpp_plugin_binary_api_t *hm = api;
 
   M(MEMIF_DUMP, mp);
-  api->vpp_api->user_param = malloc(sizeof(uint32_t));
-  *(uint32_t *)(api->vpp_api->user_param) = 0;
-  global_pointers_map[global_pointers_map_index] = api;
-  mp->context = global_pointers_map_index++;
-  global_pointers_map_index %= POINTER_MAP_SIZE;
+  uint32_t *user_param = malloc(sizeof(uint32_t));
+  *user_param = 0;
+  vpp_binary_api_set_user_param(api->vpp_api, user_param);
+
+  CONTEXT_SAVE(context_store, api, mp);
 
   vpp_binary_api_send_request(api->vpp_api, mp);
 
   vpp_binary_api_send_receive_ping(api->vpp_api);
 
-  uint32_t ret = *(uint32_t *)(api->vpp_api->user_param);
-  free(api->vpp_api->user_param);
+  user_param = vpp_binary_api_get_user_param(api->vpp_api);
+  *memif_id = *(uint32_t *)(user_param);
+  free(user_param);
 
-  return ret;
+  return vpp_binary_api_get_ret_value(api->vpp_api);
 }
 
 static void vl_api_memif_details_t_handler(vl_api_memif_details_t *mp) {
-  vpp_plugin_binary_api_t *binary_api = global_pointers_map[mp->context];
-  uint32_t *last_memif_id = binary_api->vpp_api->user_param;
+  vpp_plugin_binary_api_t *binary_api;
+  CONTEXT_GET(context_store, mp, binary_api);
+  uint32_t *last_memif_id = vpp_binary_api_get_user_param(binary_api->vpp_api);
   uint32_t current_memif_id = clib_net_to_host_u32(mp->id);
   if (current_memif_id >= *last_memif_id) {
     *last_memif_id = current_memif_id + 1;
@@ -127,14 +130,12 @@ int memif_binary_api_create_memif(vpp_plugin_binary_api_t *api,
     return -1;
   }
 
-  api->vpp_api->user_param = output_params;
+  vpp_binary_api_set_user_param(api->vpp_api, output_params);
 
   /* Construct the API message */
   M(MEMIF_CREATE, mp);
 
-  global_pointers_map[global_pointers_map_index] = api;
-  mp->context = global_pointers_map_index++;
-  global_pointers_map_index %= POINTER_MAP_SIZE;
+  CONTEXT_SAVE(context_store, api, mp)
 
   mp->role = input_params->role;
   mp->mode = input_params->mode;
@@ -161,9 +162,7 @@ int memif_binary_api_delete_memif(vpp_plugin_binary_api_t *api,
   /* Construct the API message */
   M(MEMIF_DELETE, mp);
 
-  global_pointers_map[global_pointers_map_index] = api;
-  mp->context = global_pointers_map_index++;
-  global_pointers_map_index %= POINTER_MAP_SIZE;
+  CONTEXT_SAVE(context_store, api, mp)
 
   mp->sw_if_index = htonl(sw_if_index);
 
@@ -172,22 +171,25 @@ int memif_binary_api_delete_memif(vpp_plugin_binary_api_t *api,
 
 static void vl_api_memif_create_reply_t_handler(
     vl_api_memif_create_reply_t *mp) {
-  vpp_plugin_binary_api_t *binary_api = global_pointers_map[mp->context];
-  memif_output_params_t *params = binary_api->vpp_api->user_param;
+  vpp_plugin_binary_api_t *binary_api;
+  CONTEXT_GET(context_store, mp, binary_api);
+  memif_output_params_t *params =
+      vpp_binary_api_get_user_param(binary_api->vpp_api);
 
-  binary_api->vpp_api->ret_val = ntohl(mp->retval);
+  vpp_binary_api_set_ret_value(binary_api->vpp_api,
+                               clib_net_to_host_u32(mp->retval));
   params->sw_if_index = clib_net_to_host_u32(mp->sw_if_index);
 
-  TRANSPORT_LOGI("ret :%d", binary_api->vpp_api->ret_val);
-
   vpp_binary_api_unlock_waiting_thread(binary_api->vpp_api);
 }
 
 static void vl_api_memif_delete_reply_t_handler(
     vl_api_memif_delete_reply_t *mp) {
-  vpp_plugin_binary_api_t *binary_api = global_pointers_map[mp->context];
+  vpp_plugin_binary_api_t *binary_api;
+  CONTEXT_GET(context_store, mp, binary_api);
 
-  binary_api->vpp_api->ret_val = ntohl(mp->retval);
+  vpp_binary_api_set_ret_value(binary_api->vpp_api,
+                               clib_net_to_host_u32(mp->retval));
 
   vpp_binary_api_unlock_waiting_thread(binary_api->vpp_api);
 }
@@ -210,7 +212,7 @@ vpp_plugin_binary_api_t *memif_binary_api_init(vpp_binary_api_t *api) {
   u8 *name = format(0, "memif_%08x%c", api_version, 0);
   ret->msg_id_base = vl_client_get_first_plugin_msg_id((char *)name);
   ret->vpp_api = api;
-  ret->my_client_index = api->my_client_index;
+  ret->my_client_index = vpp_binary_api_get_client_index(api);
   memif_binary_api_setup_handlers(ret);
   return ret;
 }
old mode 100755 (executable)
new mode 100644 (file)
index 582aeb1..b950292
@@ -43,15 +43,16 @@ typedef struct memif_output_params_s {
   uint32_t sw_if_index;
 } memif_output_params_t;
 
-vpp_plugin_binary_api_t* memif_binary_api_init(vpp_binary_api_t* api);
+vpp_plugin_binary_api_t *memif_binary_api_init(vpp_binary_api_t *api);
 
-uint32_t memif_binary_api_get_next_memif_id(vpp_plugin_binary_api_t* api);
+int memif_binary_api_get_next_memif_id(vpp_plugin_binary_api_t *api,
+                                       uint32_t *memif_id);
 
-int memif_binary_api_create_memif(vpp_plugin_binary_api_tapi,
-                                  memif_create_params_tinput_params,
-                                  memif_output_params_toutput_params);
+int memif_binary_api_create_memif(vpp_plugin_binary_api_t *api,
+                                  memif_create_params_t *input_params,
+                                  memif_output_params_t *output_params);
 
-int memif_binary_api_delete_memif(vpp_plugin_binary_api_tapi,
+int memif_binary_api_delete_memif(vpp_plugin_binary_api_t *api,
                                   uint32_t sw_if_index);
 
 #ifdef __cplusplus
old mode 100755 (executable)
new mode 100644 (file)
index 7a67231..b3785e5
@@ -46,6 +46,7 @@ MemifConnector::MemifConnector(PacketReceivedCallback &&receive_callback,
       is_reconnection_(false),
       data_available_(false),
       enable_burst_(false),
+      closed_(false),
       app_name_(app_name),
       receive_callback_(receive_callback),
       on_reconnect_callback_(on_reconnect_callback),
@@ -342,11 +343,14 @@ int MemifConnector::onInterrupt(memif_conn_handle_t conn, void *private_ctx,
       goto error;
     }
 
+    std::size_t packet_length;
     for (int i = 0; i < rx; i++) {
       auto packet = connector->getPacket();
+      packet_length = (c->rx_bufs + i)->len;
       std::memcpy(packet->writableData(),
                   reinterpret_cast<const uint8_t *>((c->rx_bufs + i)->data),
-                  (c->rx_bufs + i)->len);
+                  packet_length);
+      packet->append(packet_length);
 
       if (!connector->input_buffer_.push(std::move(packet))) {
         TRANSPORT_LOGI("Error pushing packet. Ring buffer full.");
@@ -394,20 +398,19 @@ error:
   return 0;
 }
 
-// void MemifConnector::runEventsLoop() {
-//  io_service_.run();
-//}
-
 void MemifConnector::close() {
-  event_reactor_.stop();
-  io_service_.stop();
-
-  if (memif_worker_ && memif_worker_->joinable()) {
-    memif_worker_->join();
-    TRANSPORT_LOGD("Memif worker joined");
-    deleteMemif();
-  } else {
-    TRANSPORT_LOGD("Memif worker not joined");
+  if (!closed_) {
+    closed_ = true;
+    event_reactor_.stop();
+    io_service_.stop();
+
+    if (memif_worker_ && memif_worker_->joinable()) {
+      memif_worker_->join();
+      TRANSPORT_LOGD("Memif worker joined");
+      deleteMemif();
+    } else {
+      TRANSPORT_LOGD("Memif worker not joined");
+    }
   }
 }
 
old mode 100755 (executable)
new mode 100644 (file)
index 24c8ac1..4667ec0
@@ -143,6 +143,7 @@ class MemifConnector : public Connector {
   volatile bool is_reconnection_;
   bool data_available_;
   bool enable_burst_;
+  bool closed_;
   uint32_t memif_id_;
   uint8_t memif_mode_;
   std::string app_name_;
old mode 100755 (executable)
new mode 100644 (file)
old mode 100755 (executable)
new mode 100644 (file)
old mode 100755 (executable)
new mode 100644 (file)
index 74f407f..69cbb3c
@@ -48,7 +48,6 @@ Packet::Packet(MemBufPtr &&buffer)
       header_head_(packet_.get()),
       payload_head_(nullptr),
       format_(getFormatFromBuffer(packet_start_)) {
-
   auto header_size = getHeaderSizeFromFormat(format_);
   int signature_size = 0;
 
@@ -79,8 +78,6 @@ Packet::Packet(MemBufPtr &&buffer)
     packet_->prependChain(std::move(payload));
     packet_->append(header_size);
   }
-
-
 }
 
 Packet::Packet(const uint8_t *buffer, std::size_t size)
@@ -98,11 +95,7 @@ Packet::Packet(Packet &&other)
   other.format_ = HF_UNSPEC;
 }
 
-Packet::~Packet() {
-  if (packet_->isChained()) {
-    packet_->separateChain(packet_->next(), packet_->prev());
-  }
-}
+Packet::~Packet() {}
 
 std::size_t Packet::getHeaderSizeFromFormat(Format format,
                                             size_t signature_size) {
@@ -317,7 +310,7 @@ void Packet::setSignature(std::unique_ptr<utils::MemBuf> &&signature) {
 
 void Packet::setSignatureTimestamp(const uint64_t &timestamp) {
   int ret = hicn_packet_set_signature_timestamp(
-    format_, (hicn_header_t *)packet_start_, timestamp);
+      format_, (hicn_header_t *)packet_start_, timestamp);
 
   if (ret < 0) {
     throw errors::RuntimeException("Error setting the signature timestamp.");
@@ -327,7 +320,7 @@ void Packet::setSignatureTimestamp(const uint64_t &timestamp) {
 uint64_t Packet::getSignatureTimestamp() const {
   uint64_t return_value;
   int ret = hicn_packet_get_signature_timestamp(
-    format_, (hicn_header_t *)packet_start_, &return_value);
+      format_, (hicn_header_t *)packet_start_, &return_value);
 
   if (ret < 0) {
     throw errors::RuntimeException("Error getting the signature timestamp.");
@@ -336,9 +329,10 @@ uint64_t Packet::getSignatureTimestamp() const {
   return return_value;
 }
 
-void Packet::setValidationAlgorithm(const utils::CryptoSuite &validation_algorithm) {
+void Packet::setValidationAlgorithm(
+    const utils::CryptoSuite &validation_algorithm) {
   int ret = hicn_packet_set_validation_algorithm(
-  format_, (hicn_header_t *)packet_start_, uint8_t(validation_algorithm));
+      format_, (hicn_header_t *)packet_start_, uint8_t(validation_algorithm));
 
   if (ret < 0) {
     throw errors::RuntimeException("Error setting the validation algorithm.");
@@ -348,7 +342,7 @@ void Packet::setValidationAlgorithm(const utils::CryptoSuite &validation_algorit
 utils::CryptoSuite Packet::getValidationAlgorithm() const {
   uint8_t return_value;
   int ret = hicn_packet_get_validation_algorithm(
-    format_, (hicn_header_t *)packet_start_, &return_value);
+      format_, (hicn_header_t *)packet_start_, &return_value);
 
   if (ret < 0) {
     throw errors::RuntimeException("Error getting the validation algorithm.");
@@ -358,8 +352,8 @@ utils::CryptoSuite Packet::getValidationAlgorithm() const {
 }
 
 void Packet::setKeyId(const utils::KeyId &key_id) {
-  int ret = hicn_packet_set_key_id(
-    format_, (hicn_header_t *)packet_start_, key_id.first);
+  int ret = hicn_packet_set_key_id(format_, (hicn_header_t *)packet_start_,
+                                   key_id.first);
 
   if (ret < 0) {
     throw errors::RuntimeException("Error setting the key id.");
@@ -368,8 +362,8 @@ void Packet::setKeyId(const utils::KeyId &key_id) {
 
 utils::KeyId Packet::getKeyId() const {
   utils::KeyId return_value;
-  int ret = hicn_packet_get_key_id(
-    format_, (hicn_header_t *)packet_start_, &return_value.first, &return_value.second);
+  int ret = hicn_packet_get_key_id(format_, (hicn_header_t *)packet_start_,
+                                   &return_value.first, &return_value.second);
 
   if (ret < 0) {
     throw errors::RuntimeException("Error getting the validation algorithm.");
old mode 100755 (executable)
new mode 100644 (file)
index 0a56734..bc23588
 #include <hicn/transport/portability/portability.h>
 #include <hicn/transport/utils/branch_prediction.h>
 #include <hicn/transport/utils/crypto_hasher.h>
-#include <hicn/transport/utils/membuf.h>
-#include <hicn/transport/utils/object_pool.h>
 #include <hicn/transport/utils/crypto_suite.h>
 #include <hicn/transport/utils/key_id.h>
+#include <hicn/transport/utils/membuf.h>
+#include <hicn/transport/utils/object_pool.h>
 
 namespace utils {
 class Signer;
old mode 100755 (executable)
new mode 100644 (file)
index 8802044..a797170
@@ -224,7 +224,7 @@ class Portal {
 
   TRANSPORT_ALWAYS_INLINE void killConnection() { connector_.close(); }
 
-  TRANSPORT_ALWAYS_INLINE void clear() { pending_interest_hash_table_.clear();}
+  TRANSPORT_ALWAYS_INLINE void clear() { pending_interest_hash_table_.clear(); }
 
   TRANSPORT_ALWAYS_INLINE asio::io_service &getIoService() {
     return io_service_;
old mode 100755 (executable)
new mode 100644 (file)
old mode 100755 (executable)
new mode 100644 (file)
old mode 100755 (executable)
new mode 100644 (file)
index ab23d3c..09ffb2e
 #include <vpp/api/vpe_all_api_h.h>
 #undef vl_msg_name_crc_list
 
-// #define vl_api_version(n,v) static u32 vpe_api_version = (v);
-// #include <vpp/api/vpe.api.h>
-// #undef vl_api_version
-
-#define POINTER_MAP_SIZE 32
-static void *global_pointers_map[POINTER_MAP_SIZE];
-static uint8_t global_pointers_map_index = 0;
+#include <semaphore.h>
+
+struct vpp_binary_api {
+  api_main_t *api_main;
+  u32 my_client_index;
+  unix_shared_memory_queue_t *vl_input_queue;
+  vlib_main_t *vlib_main;
+  sem_t *semaphore;
+  u32 ping_id;
+  int ret_val;
+  void *user_param;
+};
+
+static context_store_t context_store = {
+    .global_pointers_map_index = 0,
+};
 
 /*
  * Table of message reply handlers, must include boilerplate handlers
@@ -91,7 +100,8 @@ typedef struct __attribute__((packed)) vl_generic_reply_s {
 static void vl_api_control_ping_reply_t_handler(
     vl_api_control_ping_reply_t *mp) {
   // Just unblock main thread
-  vpp_binary_api_t *binary_api = global_pointers_map[mp->context];
+  vpp_binary_api_t *binary_api;
+  CONTEXT_GET(context_store, mp, binary_api);
   binary_api->ret_val = ntohl(mp->retval);
   vpp_binary_api_unlock_waiting_thread(binary_api);
 }
@@ -99,7 +109,8 @@ static void vl_api_control_ping_reply_t_handler(
 static void vl_api_sw_interface_set_flags_reply_t_handler(
     vl_api_control_ping_reply_t *mp) {
   // Unblock main thread setting reply message status code
-  vpp_binary_api_t *binary_api = global_pointers_map[mp->context];
+  vpp_binary_api_t *binary_api;
+  CONTEXT_GET(context_store, mp, binary_api);
   binary_api->ret_val = ntohl(mp->retval);
   vpp_binary_api_unlock_waiting_thread(binary_api);
 }
@@ -160,9 +171,7 @@ void vpp_binary_api_send_receive_ping(vpp_binary_api_t *api) {
       vl_msg_api_get_msg_index((u8 *)(VL_API_CONTROL_PING_CRC)));
   mp_ping->client_index = api->my_client_index;
 
-  global_pointers_map[global_pointers_map_index] = api;
-  mp_ping->context = global_pointers_map_index++;
-  global_pointers_map_index %= POINTER_MAP_SIZE;
+  CONTEXT_SAVE(context_store, api, mp_ping);
 
   TRANSPORT_LOGI("Sending ping id %u", mp_ping->_vl_msg_id);
 
@@ -191,9 +200,7 @@ int vpp_binary_api_set_int_state(vpp_binary_api_t *api, uint32_t sw_index,
   mp->sw_if_index = clib_host_to_net_u32(sw_index);
   mp->admin_up_down = (u8)state;
 
-  global_pointers_map[global_pointers_map_index] = api;
-  mp->context = global_pointers_map_index++;
-  global_pointers_map_index %= POINTER_MAP_SIZE;
+  CONTEXT_SAVE(context_store, api, mp);
 
   TRANSPORT_LOGI("Sending set int flags id %u", mp->_vl_msg_id);
 
@@ -209,6 +216,29 @@ void vpp_binary_api_send_request(vpp_binary_api_t *api, void *request) {
   S(api, req);
 }
 
+int vpp_binary_api_get_ret_value(vpp_binary_api_t *api) { return api->ret_val; }
+
+void vpp_binary_api_set_ret_value(vpp_binary_api_t *api, int ret_val) {
+  api->ret_val = ret_val;
+}
+
+void *vpp_binary_api_get_user_param(vpp_binary_api_t *api) {
+  return api->user_param;
+}
+
+void vpp_binary_api_set_user_param(vpp_binary_api_t *api, void *user_param) {
+  api->user_param = user_param;
+}
+
+uint32_t vpp_binary_api_get_client_index(vpp_binary_api_t *api) {
+  return api->my_client_index;
+}
+
+void vpp_binary_api_set_client_index(vpp_binary_api_t *api,
+                                     uint32_t client_index) {
+  api->my_client_index = client_index;
+}
+
 int vpp_binary_api_send_request_wait_reply(vpp_binary_api_t *api,
                                            void *request) {
   vpp_binary_api_send_request(api, request);
old mode 100755 (executable)
new mode 100644 (file)
index 1eb10e7..932a59e
@@ -35,27 +35,40 @@ typedef enum link_state_s { UP = 1, DOWN = 0 } link_state_t;
  * @brief Instantiate a new vpp_binary_api_t data structure and
  *        connect the application to the local VPP forwarder.
  */
-vpp_binary_api_t* vpp_binary_api_init(const char* app_name);
+vpp_binary_api_t *vpp_binary_api_init(const char *app_name);
 
 /**
  * @brief Destroy the vpp_binary_api_t and disconnect from VPP.
  */
-void vpp_binary_api_destroy(vpp_binary_api_tapi);
+void vpp_binary_api_destroy(vpp_binary_api_t *api);
 
-void vpp_binary_api_send_receive_ping(vpp_binary_api_tapi);
+void vpp_binary_api_send_receive_ping(vpp_binary_api_t *api);
 
-int vpp_binary_api_set_int_state(vpp_binary_api_tapi, uint32_t sw_index,
+int vpp_binary_api_set_int_state(vpp_binary_api_t *api, uint32_t sw_index,
                                  link_state_t state);
 
 /**
  * @brief Send request to VPP and wait for reply.
  */
-int vpp_binary_api_send_request_wait_reply(vpp_binary_api_tapi,
-                                           voidrequest);
+int vpp_binary_api_send_request_wait_reply(vpp_binary_api_t *api,
+                                           void *request);
 
-void vpp_binary_api_unlock_waiting_thread(vpp_binary_api_tapi);
+void vpp_binary_api_unlock_waiting_thread(vpp_binary_api_t *api);
 
-void vpp_binary_api_send_request(vpp_binary_api_t* api, void* request);
+void vpp_binary_api_send_request(vpp_binary_api_t *api, void *request);
+
+int vpp_binary_api_get_ret_value(vpp_binary_api_t *api);
+
+void vpp_binary_api_set_ret_value(vpp_binary_api_t *api, int ret_val);
+
+void *vpp_binary_api_get_user_param(vpp_binary_api_t *api);
+
+void vpp_binary_api_set_user_param(vpp_binary_api_t *api, void *user_param);
+
+uint32_t vpp_binary_api_get_client_index(vpp_binary_api_t *api);
+
+void vpp_binary_api_set_client_index(vpp_binary_api_t *api,
+                                     uint32_t client_index);
 
 #ifdef __cplusplus
 }
old mode 100755 (executable)
new mode 100644 (file)
index 22b665e..a6e2c01
@@ -27,16 +27,9 @@ extern "C" {
 #include <vlibapi/api.h>
 #include <vlibmemory/api.h>
 
-struct vpp_binary_api {
-  api_main_t *api_main;
-  u32 my_client_index;
-  unix_shared_memory_queue_t *vl_input_queue;
-  vlib_main_t *vlib_main;
-  sem_t *semaphore;
-  u32 ping_id;
-  int ret_val;
-  void *user_param;
-};
+#include <stdint.h>
+
+typedef struct vpp_binary_api vpp_binary_api_t;
 
 struct vpp_plugin_binary_api {
   vpp_binary_api_t *vpp_api;
@@ -44,6 +37,26 @@ struct vpp_plugin_binary_api {
   u32 my_client_index;
 };
 
+#define POINTER_MAP_SIZE 32
+typedef struct {
+  void *global_pointers_map[POINTER_MAP_SIZE];
+  uint8_t global_pointers_map_index;
+} context_store_t;
+
+#define CONTEXT_SAVE(context_store, pointer, mp)                        \
+  do {                                                                  \
+    context_store                                                       \
+        .global_pointers_map[context_store.global_pointers_map_index] = \
+        pointer;                                                        \
+    mp->context = context_store.global_pointers_map_index++;            \
+    context_store.global_pointers_map_index %= POINTER_MAP_SIZE;        \
+  } while (0);
+
+#define CONTEXT_GET(context_store, mp, pointer)               \
+  do {                                                        \
+    pointer = context_store.global_pointers_map[mp->context]; \
+  } while (0);
+
 #define M(T, mp)                                          \
   do {                                                    \
     mp = vl_msg_api_alloc_as_if_client(sizeof(*mp));      \
old mode 100755 (executable)
new mode 100644 (file)
index 3a748c8..0335c38
@@ -19,6 +19,7 @@
 
 #include <hicn/transport/core/hicn_binary_api.h>
 #include <hicn/transport/core/memif_binary_api.h>
+#include <hicn/transport/core/prefix.h>
 #include <hicn/transport/core/vpp_forwarder_interface.h>
 
 typedef enum { MASTER = 0, SLAVE = 1 } memif_role_t;
@@ -42,7 +43,19 @@ VPPForwarderInterface::VPPForwarderInterface(MemifConnector &connector)
       sw_if_index_(~0),
       face_id_(~0) {}
 
-VPPForwarderInterface::~VPPForwarderInterface() {}
+VPPForwarderInterface::~VPPForwarderInterface() {
+  if (sw_if_index_ != uint32_t(~0) && VPPForwarderInterface::memif_api_) {
+    int ret = memif_binary_api_delete_memif(VPPForwarderInterface::memif_api_, sw_if_index_);
+
+    if (ret < 0) {
+      TRANSPORT_LOGE("Error deleting memif with sw idx %u.", sw_if_index_);
+    }
+  }
+
+  if (VPPForwarderInterface::api_) {
+    vpp_binary_api_destroy(VPPForwarderInterface::api_);
+  }
+}
 
 /**
  * @brief Create a memif interface in the local VPP forwarder.
@@ -50,8 +63,13 @@ VPPForwarderInterface::~VPPForwarderInterface() {}
 uint32_t VPPForwarderInterface::getMemifConfiguration() {
   memif_create_params_t input_params = {0};
 
-  memif_id_ =
-      memif_binary_api_get_next_memif_id(VPPForwarderInterface::memif_api_);
+  int ret = memif_binary_api_get_next_memif_id(
+      VPPForwarderInterface::memif_api_, &memif_id_);
+
+  if (ret < 0) {
+    throw errors::RuntimeException(
+        "Error getting next memif id. Could not create memif interface.");
+  }
 
   input_params.id = memif_id_;
   input_params.role = memif_role_t::MASTER;
@@ -63,8 +81,10 @@ uint32_t VPPForwarderInterface::getMemifConfiguration() {
 
   memif_output_params_t output_params = {0};
 
-  if (memif_binary_api_create_memif(VPPForwarderInterface::memif_api_,
-                                    &input_params, &output_params) < 0) {
+  ret = memif_binary_api_create_memif(VPPForwarderInterface::memif_api_,
+                                    &input_params, &output_params);
+
+  if (ret < 0) {
     throw errors::RuntimeException(
         "Error creating memif interface in the local VPP forwarder.");
   }
@@ -75,23 +95,30 @@ uint32_t VPPForwarderInterface::getMemifConfiguration() {
 void VPPForwarderInterface::consumerConnection() {
   hicn_consumer_input_params input = {0};
   hicn_consumer_output_params output;
+  ip_address_t ip4_address;
+  ip_address_t ip6_address;
 
   std::memset(&output, 0, sizeof(hicn_consumer_output_params));
 
+  output.src4 = &ip4_address;
+  output.src6 = &ip6_address;
+
   input.swif = sw_if_index_;
 
-  if (int ret = hicn_binary_api_register_cons_app(
-                    VPPForwarderInterface::hicn_api_, &input, &output) < 0) {
+  int ret = hicn_binary_api_register_cons_app(
+                    VPPForwarderInterface::hicn_api_, &input, &output);
+
+  if (ret < 0) {
     throw errors::RuntimeException(hicn_binary_api_get_error_string(ret));
   }
 
   inet_address_.family = AF_INET;
-  inet_address_.prefix_len = output.src4.prefix_length;
-  std::memcpy(inet_address_.buffer, output.src4.ip4.as_u8, IPV4_ADDR_LEN);
+  inet_address_.prefix_len = output.src4->prefix_len;
+  std::memcpy(inet_address_.buffer, output.src4->buffer, IPV6_ADDR_LEN);
 
   inet6_address_.family = AF_INET6;
-  inet6_address_.prefix_len = output.src6.prefix_length;
-  std::memcpy(inet6_address_.buffer, output.src6.ip6.as_u8, IPV6_ADDR_LEN);
+  inet6_address_.prefix_len = output.src6->prefix_len;
+  std::memcpy(inet6_address_.buffer, output.src6->buffer, IPV6_ADDR_LEN);
 }
 
 void VPPForwarderInterface::producerConnection() {
@@ -127,6 +154,9 @@ void VPPForwarderInterface::connect(bool is_consumer) {
 void VPPForwarderInterface::registerRoute(Prefix &prefix) {
   auto &addr = prefix.toIpAddressStruct();
 
+  // Same ip address for input and outurt params
+  ip_address_t ip_address;
+
   if (face_id_ == uint32_t(~0)) {
     hicn_producer_input_params input;
     std::memset(&input, 0, sizeof(input));
@@ -134,44 +164,52 @@ void VPPForwarderInterface::registerRoute(Prefix &prefix) {
     hicn_producer_output_params output;
     std::memset(&output, 0, sizeof(output));
 
+    input.prefix = &ip_address;
+    output.prod_addr = &ip_address;
+
     // Here we have to ask to the actual connector what is the
     // memif_id, since this function should be called after the
     // memif creation.
     input.swif = sw_if_index_;
-    input.prefix.ip6.as_u64[0] = addr.as_u64[0];
-    input.prefix.ip6.as_u64[1] = addr.as_u64[1];
-    input.prefix.type = addr.family == AF_INET6 ? IP_TYPE_IP6 : IP_TYPE_IP4;
-    input.prefix.prefix_length = addr.prefix_len;
+    input.prefix->as_u64[0] = addr.as_u64[0];
+    input.prefix->as_u64[1] = addr.as_u64[1];
+    input.prefix->family = addr.family == AF_INET6 ? AF_INET6 : AF_INET;
+    input.prefix->prefix_len = addr.prefix_len;
     input.cs_reserved = content_store_reserved_;
 
-    if (int ret = hicn_binary_api_register_prod_app(
-                      VPPForwarderInterface::hicn_api_, &input, &output) < 0) {
+    int ret = hicn_binary_api_register_prod_app(
+                      VPPForwarderInterface::hicn_api_, &input, &output);
+
+    if (ret < 0) {
       throw errors::RuntimeException(hicn_binary_api_get_error_string(ret));
     }
 
     if (addr.family == AF_INET6) {
-      inet6_address_.prefix_len = output.prod_addr.prefix_length;
-      std::memcpy(inet6_address_.buffer, output.prod_addr.ip6.as_u8,
-                  IPV6_ADDR_LEN);
+      inet6_address_.prefix_len = output.prod_addr->prefix_len;
+      inet6_address_.as_u64[0] = output.prod_addr->as_u64[0];
+      inet6_address_.as_u64[1] = output.prod_addr->as_u64[1];
     } else {
-      inet_address_.prefix_len = output.prod_addr.prefix_length;
+      inet_address_.prefix_len = output.prod_addr->prefix_len;
       // The ipv4 is written in the last 4 bytes of the ipv6 address, so we need
       // to copy from the byte 12
-      std::memcpy(inet_address_.buffer, output.prod_addr.ip6.as_u8 + 12,
-                  IPV4_ADDR_LEN);
+      inet_address_.as_u64[0] = output.prod_addr->as_u64[0];
+      inet_address_.as_u64[1] = output.prod_addr->as_u64[1];
     }
 
     face_id_ = output.face_id;
   } else {
     hicn_producer_set_route_params params;
-    params.prefix.ip6.as_u64[0] = addr.as_u64[0];
-    params.prefix.ip6.as_u64[1] = addr.as_u64[1];
-    params.prefix.type = addr.family == AF_INET6 ? IP_TYPE_IP6 : IP_TYPE_IP4;
-    params.prefix.prefix_length = addr.prefix_len;
+    params.prefix = &ip_address;
+    params.prefix->as_u64[0] = addr.as_u64[0];
+    params.prefix->as_u64[1] = addr.as_u64[1];
+    params.prefix->family = addr.family == AF_INET6 ? AF_INET6 : AF_INET;
+    params.prefix->prefix_len = addr.prefix_len;
     params.face_id = face_id_;
 
-    if (int ret = hicn_binary_api_register_route(
-                      VPPForwarderInterface::hicn_api_, &params) < 0) {
+    int ret = hicn_binary_api_register_route(
+                      VPPForwarderInterface::hicn_api_, &params);
+
+    if (ret < 0) {
       throw errors::RuntimeException(hicn_binary_api_get_error_string(ret));
     }
   }
old mode 100755 (executable)
new mode 100644 (file)
index 7b63422..37e1d7b
@@ -68,9 +68,10 @@ AsyncFullDuplexSocket::AsyncFullDuplexSocket(const Prefix &locator,
                                  ConsumerSocket & s, const ContentObject &c)
                                  ->bool { return true; });
 
-  consumer_->setSocketOption(
-      ConsumerCallbacksOptions::CONTENT_RETRIEVED,
-      std::bind(&AsyncFullDuplexSocket::onContentRetrieved, this, _1, _2, _3));
+  ConsumerContentCallback callback =
+      std::bind(&AsyncFullDuplexSocket::onContentRetrieved, this, _1, _2, _3);
+  consumer_->setSocketOption(ConsumerCallbacksOptions::CONTENT_RETRIEVED,
+                             callback);
 
   consumer_->setSocketOption(GeneralTransportOptions::MAX_INTEREST_RETX,
                              uint32_t{4});
old mode 100755 (executable)
new mode 100644 (file)
index d8a9d53..ec8c4c6
@@ -13,9 +13,9 @@
  * limitations under the License.
  */
 
+#include <hicn/transport/interfaces/rtc_socket_producer.h>
 #include <stdlib.h>
 #include <time.h>
-#include <hicn/transport/interfaces/rtc_socket_producer.h>
 
 #define NACK_HEADER_SIZE 8  // bytes
 #define TIMESTAMP_LEN 8     // bytes
old mode 100755 (executable)
new mode 100644 (file)
index 8109d0e..27ed4e6
@@ -137,11 +137,11 @@ void ConsumerSocket::stop() {
     transport_protocol_->stop();
   }
 
-  //is_running_ = false;
+  // is_running_ = false;
 }
 
 void ConsumerSocket::resume() {
-  if(!transport_protocol_->isRunning()){
+  if (!transport_protocol_->isRunning()) {
     transport_protocol_->resume();
   }
 }
@@ -548,7 +548,7 @@ int ConsumerSocket::getSocketOption(int socket_option_key,
 
     case GeneralTransportOptions::RUNNING:
       socket_option_value = transport_protocol_->isRunning();
-       return SOCKET_OPTION_GET;
+      return SOCKET_OPTION_GET;
 
     case OtherOptions::VIRTUAL_DOWNLOAD:
       socket_option_value = virtual_download_;
old mode 100755 (executable)
new mode 100644 (file)
index 1f42cf2..ee90e5d
@@ -48,9 +48,7 @@ RTCTransportProtocol::~RTCTransportProtocol() {
 
 void RTCTransportProtocol::start(
     utils::SharableVector<uint8_t> &content_buffer) {
-
-  if(is_running_)
-    return;
+  if (is_running_) return;
 
   is_running_ = true;
   content_buffer_ = content_buffer.shared_from_this();
@@ -63,29 +61,26 @@ void RTCTransportProtocol::start(
 }
 
 void RTCTransportProtocol::stop() {
-  if(!is_running_)
-    return;
+  if (!is_running_) return;
 
   is_running_ = false;
   portal_->stopEventsLoop();
 }
 
-void RTCTransportProtocol::resume(){
-    if(is_running_)
-        return;
-    
-    is_running_ = true;
-    
-    lastRoundBegin_ = std::chrono::steady_clock::now();
-    inflightInterestsCount_ = 0;
-    if(content_buffer_)
-        content_buffer_->clear();
+void RTCTransportProtocol::resume() {
+  if (is_running_) return;
 
-    scheduleNextInterest();
-    
-    portal_->runEventsLoop();
+  is_running_ = true;
 
-    is_running_ = false;
+  lastRoundBegin_ = std::chrono::steady_clock::now();
+  inflightInterestsCount_ = 0;
+  if (content_buffer_) content_buffer_->clear();
+
+  scheduleNextInterest();
+
+  portal_->runEventsLoop();
+
+  is_running_ = false;
 }
 
 void RTCTransportProtocol::onRTCPPacket(uint8_t *packet, size_t len) {
@@ -452,8 +447,7 @@ void RTCTransportProtocol::sendInterest() {
 
 void RTCTransportProtocol::scheduleNextInterest() {
   checkRound();
-  if(!is_running_)
-    return;
+  if (!is_running_) return;
 
   uint32_t MAX_RECOVER =
       40;  // if the packet is more than MAX_RECOVER seq in the past we drop it
@@ -573,8 +567,8 @@ void RTCTransportProtocol::onNack(const ContentObject &content_object) {
   estimatedBw_ = (double)productionRate;
 
   // if(inflightInterests_[segmentNumber %
-  // default_values::default_buffer_size].retransmissions != 0){ ignore nacks for
-  // retransmissions
+  // default_values::default_buffer_size].retransmissions != 0){ ignore nacks
+  // for retransmissions
   //    return;
   //}
 
old mode 100755 (executable)
new mode 100644 (file)
index ace16ff..b55139d
@@ -15,8 +15,8 @@
 
 #pragma once
 
-#include <stdint.h>
 #include <hicn/transport/utils/min_filter.h>
+#include <stdint.h>
 #include <climits>
 
 #define ALPHA_RTC 0.125
old mode 100755 (executable)
new mode 100644 (file)
index b6d79bf..1431020
@@ -95,9 +95,7 @@ void VegasTransportProtocol::reset() {
 
 void VegasTransportProtocol::start(
     utils::SharableVector<uint8_t> &content_buffer) {
-
-  if(is_running_)
-    return;
+  if (is_running_) return;
 
   socket_->t0_ = std::chrono::steady_clock::now();
 
@@ -110,15 +108,13 @@ void VegasTransportProtocol::start(
   portal_->runEventsLoop();
   removeAllPendingInterests();
   is_running_ = false;
-
 }
 
-void VegasTransportProtocol::resume(){
-  if(is_running_)
-    return;
+void VegasTransportProtocol::resume() {
+  if (is_running_) return;
 
   is_running_ = true;
-  sendInterest(next_suffix_++); 
+  sendInterest(next_suffix_++);
   portal_->runEventsLoop();
   removeAllPendingInterests();
   is_running_ = false;
@@ -539,7 +535,7 @@ void VegasTransportProtocol::reassemble() {
   uint64_t index = last_reassembled_segment_;
   auto it = receive_buffer_.find(index);
 
-  do {
+  while (it != receive_buffer_.end()) {
     if (it->second->getPayloadType() == PayloadType::CONTENT_OBJECT) {
       copyContent(*it->second);
       receive_buffer_.erase(it);
@@ -547,7 +543,7 @@ void VegasTransportProtocol::reassemble() {
 
     index = ++last_reassembled_segment_;
     it = receive_buffer_.find(index);
-  } while (it != receive_buffer_.end());
+  }
 }
 
 void VegasTransportProtocol::partialDownload() {
old mode 100755 (executable)
new mode 100644 (file)
index bdf7f29..1b2fd48
@@ -33,10 +33,11 @@ Identity::Identity(const std::string &keystore_name,
       parcCryptoSuite_GetSigningAlgorithm(static_cast<PARCCryptoSuite>(suite)),
       key_length, validity_days);
 
-  parcAssertTrue(success,
-             "parcPkcs12KeyStore_CreateFile('%s', '%s', '%s', %d, %d) failed.",
-             keystore_name.c_str(), keystore_password.c_str(),
-             subject_name.c_str(), static_cast<int>(key_length), validity_days);
+  parcAssertTrue(
+      success,
+      "parcPkcs12KeyStore_CreateFile('%s', '%s', '%s', %d, %d) failed.",
+      keystore_name.c_str(), keystore_password.c_str(), subject_name.c_str(),
+      static_cast<int>(key_length), validity_days);
 
   PARCIdentityFile *identity_file =
       parcIdentityFile_Create(keystore_name.c_str(), keystore_password.c_str());
old mode 100755 (executable)
new mode 100644 (file)
index 064625e..00bd7d5
@@ -25,8 +25,8 @@
  * copies of the Software, and to permit persons to whom the Software is
  * furnished to do so, subject to the following conditions:
  *
- * The above copyright notice and this permission notice shall be included in all
- * copies or substantial portions of the Software.
+ * The above copyright notice and this permission notice shall be included in
+ * all copies or substantial portions of the Software.
  *
  * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
  * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
 
 #include <assert.h>
 #include <ctype.h>
+#include <hicn/transport/utils/log.h>
 #include <stdarg.h>
 #include <stddef.h>
 #include <stdio.h>
 #include <stdlib.h>
 #include <string.h>
 #include <time.h>
-#include <hicn/transport/utils/log.h>
 
 #if defined(_WIN32) || defined(_WIN64)
 #include <windows.h>
 #else
-#include <unistd.h>
 #include <sys/time.h>
+#include <unistd.h>
 #if defined(__linux__)
 #include <linux/limits.h>
 #else
old mode 100755 (executable)
new mode 100644 (file)
index 17e47e7..3c4f127
@@ -25,8 +25,8 @@
  * copies of the Software, and to permit persons to whom the Software is
  * furnished to do so, subject to the following conditions:
  *
- * The above copyright notice and this permission notice shall be included in all
- * copies or substantial portions of the Software.
+ * The above copyright notice and this permission notice shall be included in
+ * all copies or substantial portions of the Software.
  *
  * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
  * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
index d4d8e18..c369f7e 100755 (executable)
@@ -45,7 +45,11 @@ class ObjectPool {
  public:
   using Ptr = std::unique_ptr<T, ObjectDeleter>;
 
-  ObjectPool() {}
+  ObjectPool() : destructor_(false) {}
+
+  ~ObjectPool() {
+    destructor_ = true;
+  }
 
   std::pair<bool, Ptr> get() {
     if (object_pool_.empty()) {
@@ -60,7 +64,9 @@ class ObjectPool {
 
   void add(T *object) {
     utils::SpinLock::Acquire locked(object_pool_lock_);
-    object_pool_.emplace_back(makePtr(object));
+    if (TRANSPORT_EXPECT_TRUE(!destructor_)) {
+      object_pool_.emplace_back(makePtr(object));
+    }
   }
 
   Ptr makePtr(T *object) { return Ptr(object, ObjectDeleter(this)); }
@@ -71,6 +77,7 @@ class ObjectPool {
 
   utils::SpinLock object_pool_lock_;
   std::deque<Ptr> object_pool_;
+  bool destructor_;
 };
 
 }  // namespace utils
\ No newline at end of file
old mode 100755 (executable)
new mode 100644 (file)
index c11d5e1..579b08a
 
 #include <hicn/transport/errors/malformed_ahpacket_exception.h>
 #include <hicn/transport/utils/endianess.h>
+#include <hicn/transport/utils/key_id.h>
 #include <hicn/transport/utils/membuf.h>
 #include <hicn/transport/utils/signer.h>
-#include <hicn/transport/utils/key_id.h>
-
 
 extern "C" {
 TRANSPORT_CLANG_DISABLE_WARNING("-Wextern-c-compat")
@@ -77,7 +76,7 @@ Signer::~Signer() {
 void Signer::sign(Packet &packet) {
   // header chain points to the IP + TCP hicn header
   utils::MemBuf *header_chain = packet.header_head_;
-  utils::MemBuf * payload_chain = packet.payload_head_;
+  utils::MemBuf *payload_chain = packet.payload_head_;
   uint8_t *hicn_packet = header_chain->writableData();
   Packet::Format format = packet.getFormat();
   std::size_t sign_len_bytes = parcSigner_GetSignatureSize(signer_);
@@ -101,46 +100,51 @@ void Signer::sign(Packet &packet) {
 
   /* Fill the hicn_ah header */
   using namespace std::chrono;
-  auto now = duration_cast<milliseconds>(system_clock::now().time_since_epoch()).count();
+  auto now = duration_cast<milliseconds>(system_clock::now().time_since_epoch())
+                 .count();
   packet.setSignatureTimestamp(now);
   // *reinterpret_cast<uint64_t*>(ah->signTime) = utils::hton<uint64_t>(now);
-  // // std::memcpy(&ah->hicn_ah.signTime, &sign_time, sizeof(ah->hicn_ah.signTime));
+  // // std::memcpy(&ah->hicn_ah.signTime, &sign_time,
+  // sizeof(ah->hicn_ah.signTime));
 
-  packet.setValidationAlgorithm(CryptoSuite(parcSigner_GetCryptoSuite(this->signer_)));
+  packet.setValidationAlgorithm(
+      CryptoSuite(parcSigner_GetCryptoSuite(this->signer_)));
   // ah->validationAlgorithm = parcSigner_GetCryptoSuite(this->signer_);
 
   KeyId key_id;
-  key_id.first = (uint8_t *)parcBuffer_Overlay((PARCBuffer *) parcKeyId_GetKeyId(this->key_id_), 0);
+  key_id.first = (uint8_t *)parcBuffer_Overlay(
+      (PARCBuffer *)parcKeyId_GetKeyId(this->key_id_), 0);
   packet.setKeyId(key_id);
 
   // memcpy(ah->keyId,
-  //        parcBuffer_Overlay((PARCBuffer *) parcKeyId_GetKeyId(this->key_id_), 0),
-  //        sizeof(_ah_header_t::keyId));
+  //        parcBuffer_Overlay((PARCBuffer *) parcKeyId_GetKeyId(this->key_id_),
+  //        0), sizeof(_ah_header_t::keyId));
 
   // Calculate hash
   utils::CryptoHasher hasher(parcSigner_GetCryptoHasher(signer_));
   hasher.init();
   hasher.updateBytes(hicn_packet, header_len);
   hasher.updateBytes(zeros, sign_len_bytes);
-  
-  for (utils::MemBuf *current = payload_chain; current != header_chain; current = current->next()) {
+
+  for (utils::MemBuf *current = payload_chain; current != header_chain;
+       current = current->next()) {
     hasher.updateBytes(current->data(), current->length());
   }
 
   utils::CryptoHash hash = hasher.finalize();
-  
+
   PARCSignature *signature = parcSigner_SignDigest(this->signer_, hash.hash_);
   PARCBuffer *buffer = parcSignature_GetSignature(signature);
 
-  PARCByteArray * byte_array = parcBuffer_Array(buffer);
-  uint8_t * bytes = parcByteArray_Array(byte_array);
+  PARCByteArray *byte_array = parcBuffer_Array(buffer);
+  uint8_t *bytes = parcByteArray_Array(byte_array);
   size_t bytes_len = parcBuffer_Remaining(buffer);
 
   if (bytes_len > sign_len_bytes) {
     throw errors::MalformedAHPacketException();
   }
 
-    /* Restore the resetted fields */
+  /* Restore the resetted fields */
   if (format & HFO_INET) {
     memcpy(hicn_packet, &header_copy, sizeof(hicn_v4_hdr_t));
   } else if (format & HFO_INET6) {
@@ -151,12 +155,11 @@ void Signer::sign(Packet &packet) {
 
   std::unique_ptr<utils::MemBuf> signature_buffer;
   std::unique_ptr<utils::MemBuf> tmp_buf = utils::MemBuf::takeOwnership(
-    bytes,
-    bytes_len,
-    bytes_len,
-    [](void* buf, void* userData){ parcSignature_Release((PARCSignature **)&userData); },
-    signature,
-    true);
+      bytes, bytes_len, bytes_len,
+      [](void *buf, void *userData) {
+        parcSignature_Release((PARCSignature **)&userData);
+      },
+      signature, true);
 
   if (offset) {
     signature_buffer = utils::MemBuf::create(offset);
old mode 100755 (executable)
new mode 100644 (file)
index 9a3de43..93efe06
@@ -65,9 +65,9 @@ bool Verifier::addKey(PARCKey *key) {
   return true;
 }
 
-PARCKeyId * Verifier::addKeyFromCertificate(const std::string &file_name) {
-  PARCCertificateFactory *factory = parcCertificateFactory_Create(PARCCertificateType_X509,
-                                                                  PARCContainerEncoding_PEM);
+PARCKeyId *Verifier::addKeyFromCertificate(const std::string &file_name) {
+  PARCCertificateFactory *factory = parcCertificateFactory_Create(
+      PARCCertificateType_X509, PARCContainerEncoding_PEM);
   parcAssertNotNull(factory, "Expected non-NULL factory");
 
   if (!file_exists(file_name)) {
index d8953b3..221a874 100755 (executable)
@@ -229,7 +229,7 @@ class HIperfClient {
     }
 
     if (consumer_socket_->setSocketOption(OtherOptions::VIRTUAL_DOWNLOAD,
-                                          false) == SOCKET_OPTION_NOT_SET) {
+                                          configuration_.virtual_download) == SOCKET_OPTION_NOT_SET) {
       return ERROR_SETUP;
     }
 
@@ -376,7 +376,7 @@ class HIperfServer {
 
     total = producer_socket_->produce(
         name, reinterpret_cast<const uint8_t *>(content.data()), content.size(),
-        !configuration_.multiphase_produce_);
+        !configuration_.multiphase_produce_, suffix);
 
     std::cout << "Written " << total << "pieces of data in output buffer"
               << std::endl;
index 178bd8b..c3bfa40 100755 (executable)
@@ -403,7 +403,7 @@ int main(int argc, char *argv[]) {
     }
   }
 
-  Client *ping = new Client(c);
+  auto ping = std::make_unique<Client>(c);
 
   auto t0 = std::chrono::steady_clock::now();
   ping->ping();