summaryrefslogtreecommitdiffstats
path: root/libtransport/src
diff options
context:
space:
mode:
authorMauro Sardara <msardara@cisco.com>2019-01-19 01:29:33 +0100
committerMauro Sardara <msardara@cisco.com>2019-01-21 12:03:48 +0100
commit9e5f41ed6ebe64a789916794626485460078c420 (patch)
treed2ac3090026ec8929558e88eca533f8787a6ff0b /libtransport/src
parentd13d37534d9449dd54277af664310d5f957dc44a (diff)
- Code style fix
- 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>
Diffstat (limited to 'libtransport/src')
-rwxr-xr-xlibtransport/src/hicn/transport/core/CMakeLists.txt3
-rw-r--r--[-rwxr-xr-x]libtransport/src/hicn/transport/core/connector.cc0
-rw-r--r--[-rwxr-xr-x]libtransport/src/hicn/transport/core/connector.h6
-rw-r--r--[-rwxr-xr-x]libtransport/src/hicn/transport/core/content_object.cc0
-rw-r--r--[-rwxr-xr-x]libtransport/src/hicn/transport/core/content_object.h0
-rw-r--r--[-rwxr-xr-x]libtransport/src/hicn/transport/core/facade.h0
-rw-r--r--[-rwxr-xr-x]libtransport/src/hicn/transport/core/forwarder_interface.h0
-rw-r--r--[-rwxr-xr-x]libtransport/src/hicn/transport/core/hicn_binary_api.c85
-rw-r--r--[-rwxr-xr-x]libtransport/src/hicn/transport/core/hicn_binary_api.h37
-rw-r--r--[-rwxr-xr-x]libtransport/src/hicn/transport/core/hicn_forwarder_interface.cc2
-rw-r--r--[-rwxr-xr-x]libtransport/src/hicn/transport/core/hicn_forwarder_interface.h0
-rwxr-xr-xlibtransport/src/hicn/transport/core/hicn_memif_api.c0
-rw-r--r--[-rwxr-xr-x]libtransport/src/hicn/transport/core/interest.cc0
-rw-r--r--[-rwxr-xr-x]libtransport/src/hicn/transport/core/interest.h0
-rwxr-xr-xlibtransport/src/hicn/transport/core/key_locator.cc42
-rwxr-xr-xlibtransport/src/hicn/transport/core/key_locator.h48
-rwxr-xr-xlibtransport/src/hicn/transport/core/key_locator_type.h28
-rw-r--r--[-rwxr-xr-x]libtransport/src/hicn/transport/core/manifest.cc0
-rw-r--r--[-rwxr-xr-x]libtransport/src/hicn/transport/core/manifest.h32
-rw-r--r--[-rwxr-xr-x]libtransport/src/hicn/transport/core/manifest_format.h76
-rw-r--r--[-rwxr-xr-x]libtransport/src/hicn/transport/core/manifest_format_fixed.cc64
-rw-r--r--[-rwxr-xr-x]libtransport/src/hicn/transport/core/manifest_format_fixed.h46
-rw-r--r--[-rwxr-xr-x]libtransport/src/hicn/transport/core/manifest_format_json_jsoncpp.cc52
-rw-r--r--[-rwxr-xr-x]libtransport/src/hicn/transport/core/manifest_format_json_jsoncpp.h54
-rw-r--r--[-rwxr-xr-x]libtransport/src/hicn/transport/core/manifest_format_json_libparc_deprecated.cc56
-rw-r--r--[-rwxr-xr-x]libtransport/src/hicn/transport/core/manifest_format_json_libparc_deprecated.h42
-rw-r--r--[-rwxr-xr-x]libtransport/src/hicn/transport/core/manifest_inline.h24
-rw-r--r--[-rwxr-xr-x]libtransport/src/hicn/transport/core/memif_binary_api.c62
-rw-r--r--[-rwxr-xr-x]libtransport/src/hicn/transport/core/memif_binary_api.h13
-rw-r--r--[-rwxr-xr-x]libtransport/src/hicn/transport/core/memif_connector.cc31
-rw-r--r--[-rwxr-xr-x]libtransport/src/hicn/transport/core/memif_connector.h1
-rw-r--r--[-rwxr-xr-x]libtransport/src/hicn/transport/core/name.cc0
-rw-r--r--[-rwxr-xr-x]libtransport/src/hicn/transport/core/name.h0
-rw-r--r--[-rwxr-xr-x]libtransport/src/hicn/transport/core/packet.cc28
-rw-r--r--[-rwxr-xr-x]libtransport/src/hicn/transport/core/packet.h4
-rw-r--r--[-rwxr-xr-x]libtransport/src/hicn/transport/core/payload_type.h0
-rw-r--r--[-rwxr-xr-x]libtransport/src/hicn/transport/core/pending_interest.cc0
-rw-r--r--[-rwxr-xr-x]libtransport/src/hicn/transport/core/pending_interest.h0
-rw-r--r--[-rwxr-xr-x]libtransport/src/hicn/transport/core/portal.h2
-rw-r--r--[-rwxr-xr-x]libtransport/src/hicn/transport/core/prefix.cc0
-rw-r--r--[-rwxr-xr-x]libtransport/src/hicn/transport/core/prefix.h0
-rw-r--r--[-rwxr-xr-x]libtransport/src/hicn/transport/core/raw_socket_connector.cc0
-rw-r--r--[-rwxr-xr-x]libtransport/src/hicn/transport/core/raw_socket_connector.h0
-rw-r--r--[-rwxr-xr-x]libtransport/src/hicn/transport/core/raw_socket_interface.cc0
-rw-r--r--[-rwxr-xr-x]libtransport/src/hicn/transport/core/raw_socket_interface.h0
-rw-r--r--[-rwxr-xr-x]libtransport/src/hicn/transport/core/socket_connector.cc0
-rw-r--r--[-rwxr-xr-x]libtransport/src/hicn/transport/core/socket_connector.h0
-rw-r--r--[-rwxr-xr-x]libtransport/src/hicn/transport/core/test/test_core_manifest.cc0
-rw-r--r--[-rwxr-xr-x]libtransport/src/hicn/transport/core/vpp_binary_api.c60
-rw-r--r--[-rwxr-xr-x]libtransport/src/hicn/transport/core/vpp_binary_api.h29
-rw-r--r--[-rwxr-xr-x]libtransport/src/hicn/transport/core/vpp_binary_api_internal.h33
-rw-r--r--[-rwxr-xr-x]libtransport/src/hicn/transport/core/vpp_forwarder_interface.cc96
-rw-r--r--[-rwxr-xr-x]libtransport/src/hicn/transport/core/vpp_forwarder_interface.h0
-rw-r--r--[-rwxr-xr-x]libtransport/src/hicn/transport/interfaces/full_duplex_socket.cc7
-rw-r--r--[-rwxr-xr-x]libtransport/src/hicn/transport/interfaces/rtc_socket_producer.cc2
-rw-r--r--[-rwxr-xr-x]libtransport/src/hicn/transport/interfaces/socket_consumer.cc6
-rw-r--r--[-rwxr-xr-x]libtransport/src/hicn/transport/protocols/rtc.cc40
-rw-r--r--[-rwxr-xr-x]libtransport/src/hicn/transport/protocols/rtc_data_path.h2
-rw-r--r--[-rwxr-xr-x]libtransport/src/hicn/transport/protocols/vegas.cc16
-rw-r--r--[-rwxr-xr-x]libtransport/src/hicn/transport/utils/identity.cc9
-rw-r--r--[-rwxr-xr-x]libtransport/src/hicn/transport/utils/log.cc8
-rw-r--r--[-rwxr-xr-x]libtransport/src/hicn/transport/utils/log.h4
-rwxr-xr-xlibtransport/src/hicn/transport/utils/object_pool.h11
-rw-r--r--[-rwxr-xr-x]libtransport/src/hicn/transport/utils/signer.cc45
-rw-r--r--[-rwxr-xr-x]libtransport/src/hicn/transport/utils/verifier.cc6
65 files changed, 578 insertions, 634 deletions
diff --git a/libtransport/src/hicn/transport/core/CMakeLists.txt b/libtransport/src/hicn/transport/core/CMakeLists.txt
index c8dea8328..a97e74b2a 100755
--- a/libtransport/src/hicn/transport/core/CMakeLists.txt
+++ b/libtransport/src/hicn/transport/core/CMakeLists.txt
@@ -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
diff --git a/libtransport/src/hicn/transport/core/connector.cc b/libtransport/src/hicn/transport/core/connector.cc
index ff567d78a..ff567d78a 100755..100644
--- a/libtransport/src/hicn/transport/core/connector.cc
+++ b/libtransport/src/hicn/transport/core/connector.cc
diff --git a/libtransport/src/hicn/transport/core/connector.h b/libtransport/src/hicn/transport/core/connector.h
index 14201879c..c5250486c 100755..100644
--- a/libtransport/src/hicn/transport/core/connector.h
+++ b/libtransport/src/hicn/transport/core/connector.h
@@ -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);
}
diff --git a/libtransport/src/hicn/transport/core/content_object.cc b/libtransport/src/hicn/transport/core/content_object.cc
index dc2056582..dc2056582 100755..100644
--- a/libtransport/src/hicn/transport/core/content_object.cc
+++ b/libtransport/src/hicn/transport/core/content_object.cc
diff --git a/libtransport/src/hicn/transport/core/content_object.h b/libtransport/src/hicn/transport/core/content_object.h
index c85259f20..c85259f20 100755..100644
--- a/libtransport/src/hicn/transport/core/content_object.h
+++ b/libtransport/src/hicn/transport/core/content_object.h
diff --git a/libtransport/src/hicn/transport/core/facade.h b/libtransport/src/hicn/transport/core/facade.h
index c28c84671..c28c84671 100755..100644
--- a/libtransport/src/hicn/transport/core/facade.h
+++ b/libtransport/src/hicn/transport/core/facade.h
diff --git a/libtransport/src/hicn/transport/core/forwarder_interface.h b/libtransport/src/hicn/transport/core/forwarder_interface.h
index e7b6fb1a6..e7b6fb1a6 100755..100644
--- a/libtransport/src/hicn/transport/core/forwarder_interface.h
+++ b/libtransport/src/hicn/transport/core/forwarder_interface.h
diff --git a/libtransport/src/hicn/transport/core/hicn_binary_api.c b/libtransport/src/hicn/transport/core/hicn_binary_api.c
index c49cb5c88..d909578a2 100755..100644
--- a/libtransport/src/hicn/transport/core/hicn_binary_api.c
+++ b/libtransport/src/hicn/transport/core/hicn_binary_api.c
@@ -19,11 +19,12 @@
#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;
}
diff --git a/libtransport/src/hicn/transport/core/hicn_binary_api.h b/libtransport/src/hicn/transport/core/hicn_binary_api.h
index 752844153..410ffb96c 100755..100644
--- a/libtransport/src/hicn/transport/core/hicn_binary_api.h
+++ b/libtransport/src/hicn/transport/core/hicn_binary_api.h
@@ -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;
diff --git a/libtransport/src/hicn/transport/core/hicn_forwarder_interface.cc b/libtransport/src/hicn/transport/core/hicn_forwarder_interface.cc
index 03a294957..1d82ff0b0 100755..100644
--- a/libtransport/src/hicn/transport/core/hicn_forwarder_interface.cc
+++ b/libtransport/src/hicn/transport/core/hicn_forwarder_interface.cc
@@ -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_forwarder_interface.h b/libtransport/src/hicn/transport/core/hicn_forwarder_interface.h
index e57fae105..e57fae105 100755..100644
--- a/libtransport/src/hicn/transport/core/hicn_forwarder_interface.h
+++ b/libtransport/src/hicn/transport/core/hicn_forwarder_interface.h
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
index e69de29bb..000000000
--- a/libtransport/src/hicn/transport/core/hicn_memif_api.c
+++ /dev/null
diff --git a/libtransport/src/hicn/transport/core/interest.cc b/libtransport/src/hicn/transport/core/interest.cc
index ff4a5bb34..ff4a5bb34 100755..100644
--- a/libtransport/src/hicn/transport/core/interest.cc
+++ b/libtransport/src/hicn/transport/core/interest.cc
diff --git a/libtransport/src/hicn/transport/core/interest.h b/libtransport/src/hicn/transport/core/interest.h
index 75fcba8eb..75fcba8eb 100755..100644
--- a/libtransport/src/hicn/transport/core/interest.h
+++ b/libtransport/src/hicn/transport/core/interest.h
diff --git a/libtransport/src/hicn/transport/core/key_locator.cc b/libtransport/src/hicn/transport/core/key_locator.cc
deleted file mode 100755
index 509fc35ff..000000000
--- a/libtransport/src/hicn/transport/core/key_locator.cc
+++ /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
index ae3a4ab08..000000000
--- a/libtransport/src/hicn/transport/core/key_locator.h
+++ /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
index 0c84a43ca..000000000
--- a/libtransport/src/hicn/transport/core/key_locator_type.h
+++ /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
diff --git a/libtransport/src/hicn/transport/core/manifest.cc b/libtransport/src/hicn/transport/core/manifest.cc
index 3f890f3d0..3f890f3d0 100755..100644
--- a/libtransport/src/hicn/transport/core/manifest.cc
+++ b/libtransport/src/hicn/transport/core/manifest.cc
diff --git a/libtransport/src/hicn/transport/core/manifest.h b/libtransport/src/hicn/transport/core/manifest.h
index 767addb2e..558a96804 100755..100644
--- a/libtransport/src/hicn/transport/core/manifest.h
+++ b/libtransport/src/hicn/transport/core/manifest.h
@@ -45,21 +45,21 @@ class Manifest : public Base {
Base::setPayloadType(PayloadType::MANIFEST);
}
- Manifest(const core::Name& name)
+ 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 Manifest& other) {
+ 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(); }
- Manifest& decode() {
+ 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();
}
- Manifest& setManifestType(ManifestType type) {
+ Manifest &setManifestType(ManifestType type) {
manifest_type_ = type;
encoder_.setManifestType(manifest_type_);
return *this;
}
- Manifest& setHashAlgorithm(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_; }
- Manifest& setVersion(ManifestVersion version) {
+ Manifest &setVersion(ManifestVersion version) {
encoder_.setVersion(version);
return *this;
}
- Manifest& setFinalBlockNumber(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(); }
- Manifest& setFinalManifest(bool is_final_manifest) {
+ Manifest &setFinalManifest(bool is_final_manifest) {
encoder_.setIsFinalManifest(is_final_manifest);
is_last_ = is_final_manifest;
return *this;
}
- Manifest& clear() {
+ 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_;
diff --git a/libtransport/src/hicn/transport/core/manifest_format.h b/libtransport/src/hicn/transport/core/manifest_format.h
index 1dcf013dc..00782f14d 100755..100644
--- a/libtransport/src/hicn/transport/core/manifest_format.h
+++ b/libtransport/src/hicn/transport/core/manifest_format.h
@@ -71,28 +71,28 @@ class ManifestEncoder {
virtual ~ManifestEncoder() = default;
ManifestEncoder encode() {
- return static_cast<Implementation&>(*this).encodeImpl();
+ return static_cast<Implementation &>(*this).encodeImpl();
}
- ManifestEncoder& clear() {
- return static_cast<Implementation&>(*this).clearImpl();
+ ManifestEncoder &clear() {
+ return static_cast<Implementation &>(*this).clearImpl();
}
- ManifestEncoder& setManifestType(ManifestType type) {
- return static_cast<Implementation&>(*this).setManifestTypeImpl(type);
+ ManifestEncoder &setManifestType(ManifestType type) {
+ return static_cast<Implementation &>(*this).setManifestTypeImpl(type);
}
- ManifestEncoder& setHashAlgorithm(HashAlgorithm hash) {
- return static_cast<Implementation&>(*this).setHashAlgorithmImpl(hash);
+ ManifestEncoder &setHashAlgorithm(HashAlgorithm hash) {
+ return static_cast<Implementation &>(*this).setHashAlgorithmImpl(hash);
}
- ManifestEncoder& setFinalChunkNumber(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);
}
- ManifestEncoder& setNextSegmentCalculationStrategy(
+ 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));
}
- ManifestEncoder& setIsFinalManifest(bool is_last) {
- return static_cast<Implementation&>(*this).setIsFinalManifestImpl(is_last);
+ ManifestEncoder &setIsFinalManifest(bool is_last) {
+ return static_cast<Implementation &>(*this).setIsFinalManifestImpl(is_last);
}
- ManifestEncoder& setVersion(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);
}
- ManifestEncoder& update() {
- return static_cast<Implementation&>(*this).updateImpl();
+ ManifestEncoder &update() {
+ return static_cast<Implementation &>(*this).updateImpl();
}
- ManifestEncoder& setFinalBlockNumber(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;
- ManifestDecoder& clear() {
- 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();
}
};
diff --git a/libtransport/src/hicn/transport/core/manifest_format_fixed.cc b/libtransport/src/hicn/transport/core/manifest_format_fixed.cc
index f26f20adb..6141ae311 100755..100644
--- a/libtransport/src/hicn/transport/core/manifest_format_fixed.cc
+++ b/libtransport/src/hicn/transport/core/manifest_format_fixed.cc
@@ -23,72 +23,72 @@ namespace transport {
namespace core {
// TODO use preallocated pool of membufs
-FixedManifestEncoder::FixedManifestEncoder(Packet& packet)
+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() {}
-FixedManifestEncoder& FixedManifestEncoder::encodeImpl() {
+FixedManifestEncoder &FixedManifestEncoder::encodeImpl() {
packet_.appendPayload(std::move(manifest_));
return *this;
}
-FixedManifestEncoder& FixedManifestEncoder::clearImpl() {
+FixedManifestEncoder &FixedManifestEncoder::clearImpl() {
manifest_ = utils::MemBuf::create(Packet::default_mtu - packet_.headerSize());
return *this;
}
-FixedManifestEncoder& FixedManifestEncoder::setHashAlgorithmImpl(
+FixedManifestEncoder &FixedManifestEncoder::setHashAlgorithmImpl(
HashAlgorithm algorithm) {
manifest_header_->hash_algorithm = static_cast<uint8_t>(algorithm);
return *this;
}
-FixedManifestEncoder& FixedManifestEncoder::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;
}
-FixedManifestEncoder& FixedManifestEncoder::setBaseNameImpl(
- const core::Name& base_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;
}
-FixedManifestEncoder& FixedManifestEncoder::addSuffixAndHashImpl(
- uint32_t suffix, const utils::CryptoHash& hash) {
+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_t* hash,
+ 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,
}
}
-FixedManifestEncoder& FixedManifestEncoder::setIsFinalManifestImpl(
+FixedManifestEncoder &FixedManifestEncoder::setIsFinalManifestImpl(
bool is_last) {
manifest_header_->flags.is_last = static_cast<uint8_t>(is_last);
return *this;
}
-FixedManifestEncoder& FixedManifestEncoder::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);
}
-FixedManifestEncoder& FixedManifestEncoder::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;
}
-FixedManifestEncoder& FixedManifestEncoder::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(Packet& packet)
+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() {
}
}
-FixedManifestDecoder& FixedManifestDecoder::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));
}
}
diff --git a/libtransport/src/hicn/transport/core/manifest_format_fixed.h b/libtransport/src/hicn/transport/core/manifest_format_fixed.h
index 66825e2f4..82817ddfb 100755..100644
--- a/libtransport/src/hicn/transport/core/manifest_format_fixed.h
+++ b/libtransport/src/hicn/transport/core/manifest_format_fixed.h
@@ -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(Packet& packet);
+ FixedManifestEncoder(Packet &packet);
~FixedManifestEncoder();
- FixedManifestEncoder& encodeImpl();
+ FixedManifestEncoder &encodeImpl();
- FixedManifestEncoder& clearImpl();
+ FixedManifestEncoder &clearImpl();
- FixedManifestEncoder& setManifestTypeImpl(ManifestType manifest_type);
+ FixedManifestEncoder &setManifestTypeImpl(ManifestType manifest_type);
- FixedManifestEncoder& setHashAlgorithmImpl(HashAlgorithm algorithm);
+ FixedManifestEncoder &setHashAlgorithmImpl(HashAlgorithm algorithm);
- FixedManifestEncoder& setNextSegmentCalculationStrategyImpl(
+ FixedManifestEncoder &setNextSegmentCalculationStrategyImpl(
NextSegmentCalculationStrategy strategy);
- FixedManifestEncoder& setBaseNameImpl(const core::Name& base_name);
+ FixedManifestEncoder &setBaseNameImpl(const core::Name &base_name);
- FixedManifestEncoder& addSuffixAndHashImpl(uint32_t suffix,
- const utils::CryptoHash& hash);
+ FixedManifestEncoder &addSuffixAndHashImpl(uint32_t suffix,
+ const utils::CryptoHash &hash);
- FixedManifestEncoder& setIsFinalManifestImpl(bool is_last);
+ FixedManifestEncoder &setIsFinalManifestImpl(bool is_last);
- FixedManifestEncoder& setVersionImpl(ManifestVersion version);
+ FixedManifestEncoder &setVersionImpl(ManifestVersion version);
std::size_t estimateSerializedLengthImpl(std::size_t additional_entries = 0);
- FixedManifestEncoder& updateImpl();
+ FixedManifestEncoder &updateImpl();
- FixedManifestEncoder& setFinalBlockNumberImpl(
+ FixedManifestEncoder &setFinalBlockNumberImpl(
std::uint32_t final_block_number);
static std::size_t getManifestHeaderSizeImpl();
private:
- void addSuffixHashBytes(uint32_t suffix, const uint8_t* hash,
+ void addSuffixHashBytes(uint32_t suffix, const uint8_t *hash,
std::size_t length);
- Packet& packet_;
+ Packet &packet_;
std::size_t max_size_;
std::unique_ptr<utils::MemBuf> manifest_;
- ManifestHeader* manifest_header_;
- ManifestEntry* manifest_entries_;
+ ManifestHeader *manifest_header_;
+ ManifestEntry *manifest_entries_;
std::size_t current_entry_;
};
class FixedManifestDecoder : public ManifestDecoder<FixedManifestDecoder> {
public:
- FixedManifestDecoder(Packet& packet);
+ FixedManifestDecoder(Packet &packet);
~FixedManifestDecoder();
void decodeImpl();
- FixedManifestDecoder& clearImpl();
+ FixedManifestDecoder &clearImpl();
ManifestType getManifestTypeImpl() const;
@@ -158,9 +158,9 @@ class FixedManifestDecoder : public ManifestDecoder<FixedManifestDecoder> {
uint32_t getFinalBlockNumberImpl() const;
private:
- Packet& packet_;
- ManifestHeader* manifest_header_;
- ManifestEntry* manifest_entries_;
+ Packet &packet_;
+ ManifestHeader *manifest_header_;
+ ManifestEntry *manifest_entries_;
};
} // namespace core
diff --git a/libtransport/src/hicn/transport/core/manifest_format_json_jsoncpp.cc b/libtransport/src/hicn/transport/core/manifest_format_json_jsoncpp.cc
index 512cdba5b..0ffca39f6 100755..100644
--- a/libtransport/src/hicn/transport/core/manifest_format_json_jsoncpp.cc
+++ b/libtransport/src/hicn/transport/core/manifest_format_json_jsoncpp.cc
@@ -25,38 +25,38 @@ namespace core {
namespace {
template <typename T>
-TRANSPORT_ALWAYS_INLINE void checkPointer(T* pointer) {
+TRANSPORT_ALWAYS_INLINE void checkPointer(T *pointer) {
if (pointer == nullptr) {
throw errors::NullPointerException();
}
}
template <typename EnumType>
-TRANSPORT_ALWAYS_INLINE void setValueToJson(Json::Value& root, 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::Value& root) {
+TRANSPORT_ALWAYS_INLINE EnumType getValueFromJson(const Json::Value &root) {
return static_cast<EnumType>(root[JSONKey<EnumType>::key].asUInt());
};
} // namespace
-JSONManifestEncoder::JSONManifestEncoder(Packet& packet) : packet_(packet) {}
+JSONManifestEncoder::JSONManifestEncoder(Packet &packet) : packet_(packet) {}
JSONManifestEncoder::~JSONManifestEncoder() {}
-TRANSPORT_ALWAYS_INLINE JSONManifestEncoder& JSONManifestEncoder::encodeImpl() {
+TRANSPORT_ALWAYS_INLINE JSONManifestEncoder &JSONManifestEncoder::encodeImpl() {
Json::StreamWriterBuilder writer_builder;
- Json::StreamWriter* fast_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 JSONManifestEncoder& JSONManifestEncoder::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;
}
-JSONManifestEncoder& JSONManifestEncoder::setManifestTypeImpl(
+JSONManifestEncoder &JSONManifestEncoder::setManifestTypeImpl(
ManifestType manifest_type) {
setValueToJson(root_, manifest_type);
return *this;
}
-JSONManifestEncoder& JSONManifestEncoder::setNextSegmentCalculationStrategyImpl(
+JSONManifestEncoder &JSONManifestEncoder::setNextSegmentCalculationStrategyImpl(
NextSegmentCalculationStrategy strategy) {
setValueToJson(root_, strategy);
return *this;
}
-TRANSPORT_ALWAYS_INLINE JSONManifestEncoder&
-JSONManifestEncoder::setBaseNameImpl(const core::Name& base_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::CryptoHash& hash) {
+ 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::SuffixList& name_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::StreamWriter* fast_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 JSONManifestEncoder& JSONManifestEncoder::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(Packet& packet) : 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::CharReader* reader = 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 JSONManifestDecoder& JSONManifestDecoder::clearImpl() {
+TRANSPORT_ALWAYS_INLINE JSONManifestDecoder &JSONManifestDecoder::clearImpl() {
root_.clear();
return *this;
}
diff --git a/libtransport/src/hicn/transport/core/manifest_format_json_jsoncpp.h b/libtransport/src/hicn/transport/core/manifest_format_json_jsoncpp.h
index 39f0cf351..84d2ba29a 100755..100644
--- a/libtransport/src/hicn/transport/core/manifest_format_json_jsoncpp.h
+++ b/libtransport/src/hicn/transport/core/manifest_format_json_jsoncpp.h
@@ -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 char* key = "manifest_version";
+ static const constexpr char *key = "manifest_version";
};
template <>
struct JSONKey<HashAlgorithm> {
- static const constexpr char* key = "hash_algorithm";
+ static const constexpr char *key = "hash_algorithm";
};
template <>
struct JSONKey<ManifestType> {
- static const constexpr char* key = "manifest_type";
+ static const constexpr char *key = "manifest_type";
};
template <>
struct JSONKey<NextSegmentCalculationStrategy> {
- static const constexpr char* key = "next_segment_strategy";
+ static const constexpr char *key = "next_segment_strategy";
};
template <>
struct JSONKey<typename JSON::SuffixList> {
- static const constexpr char* key = "suffix_hash_list";
+ static const constexpr char *key = "suffix_hash_list";
};
template <>
struct JSONKey<core::Name> {
- static const constexpr char* key = "base_name";
+ static const constexpr char *key = "base_name";
};
template <>
struct JSONKey<bool> {
- static const constexpr char* final_manifest = "final_manifest";
+ static const constexpr char *final_manifest = "final_manifest";
};
class JSONManifestEncoder : public ManifestEncoder<JSONManifestEncoder> {
public:
- JSONManifestEncoder(Packet& packet);
+ JSONManifestEncoder(Packet &packet);
~JSONManifestEncoder() override;
- JSONManifestEncoder& encodeImpl();
+ JSONManifestEncoder &encodeImpl();
- JSONManifestEncoder& clearImpl();
+ JSONManifestEncoder &clearImpl();
- JSONManifestEncoder& setManifestTypeImpl(ManifestType manifest_type);
+ JSONManifestEncoder &setManifestTypeImpl(ManifestType manifest_type);
- JSONManifestEncoder& setHashAlgorithmImpl(HashAlgorithm algorithm);
+ JSONManifestEncoder &setHashAlgorithmImpl(HashAlgorithm algorithm);
- JSONManifestEncoder& setNextSegmentCalculationStrategyImpl(
+ JSONManifestEncoder &setNextSegmentCalculationStrategyImpl(
NextSegmentCalculationStrategy strategy);
- JSONManifestEncoder& setSuffixHashListImpl(
- const typename JSON::SuffixList& name_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);
- JSONManifestEncoder& addSuffixAndHashImpl(uint32_t suffix,
- const utils::CryptoHash& hash);
+ JSONManifestEncoder &addSuffixAndHashImpl(uint32_t suffix,
+ const utils::CryptoHash &hash);
- JSONManifestEncoder& setIsFinalManifestImpl(bool is_last);
+ JSONManifestEncoder &setIsFinalManifestImpl(bool is_last);
- JSONManifestEncoder& setVersionImpl(ManifestVersion version);
+ JSONManifestEncoder &setVersionImpl(ManifestVersion version);
std::size_t estimateSerializedLengthImpl(std::size_t number_of_entries);
- JSONManifestEncoder& updateImpl();
+ JSONManifestEncoder &updateImpl();
- JSONManifestEncoder& setFinalBlockNumberImpl(
+ JSONManifestEncoder &setFinalBlockNumberImpl(
std::uint32_t final_block_number);
static std::size_t getManifestHeaderSizeImpl();
private:
- Packet& packet_;
+ Packet &packet_;
Json::Value root_;
};
class JSONManifestDecoder : public ManifestDecoder<JSONManifestDecoder> {
public:
- JSONManifestDecoder(Packet& packet);
+ JSONManifestDecoder(Packet &packet);
~JSONManifestDecoder() override;
void decodeImpl();
- JSONManifestDecoder& clearImpl();
+ JSONManifestDecoder &clearImpl();
ManifestType getManifestTypeImpl() const;
@@ -153,7 +153,7 @@ class JSONManifestDecoder : public ManifestDecoder<JSONManifestDecoder> {
uint32_t getFinalBlockNumberImpl() const;
private:
- Packet& packet_;
+ Packet &packet_;
Json::Value root_;
};
diff --git a/libtransport/src/hicn/transport/core/manifest_format_json_libparc_deprecated.cc b/libtransport/src/hicn/transport/core/manifest_format_json_libparc_deprecated.cc
index d0365d2fe..a3a47e62b 100755..100644
--- a/libtransport/src/hicn/transport/core/manifest_format_json_libparc_deprecated.cc
+++ b/libtransport/src/hicn/transport/core/manifest_format_json_libparc_deprecated.cc
@@ -29,23 +29,23 @@ namespace core {
namespace {
template <typename T>
-TRANSPORT_ALWAYS_INLINE void checkPointer(T* pointer) {
+TRANSPORT_ALWAYS_INLINE void checkPointer(T *pointer) {
if (pointer == nullptr) {
throw errors::NullPointerException();
}
}
template <typename EnumType>
-TRANSPORT_ALWAYS_INLINE void setValueToJson(PARCJSON* root, 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(PARCJSON* root) {
+TRANSPORT_ALWAYS_INLINE EnumType getValueFromJson(PARCJSON *root) {
checkPointer(root);
- PARCJSONValue* value = 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 SONManifestEncoder& JSONManifestEncoder::encodeImpl(
- Packet& packet) {
- char* json_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 JSONManifestEncoder& JSONManifestEncoder::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::Name& base_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::CryptoHash& hash) {
+ 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 SuffixHashList& name_hash_list) {
- for (auto& suffix : 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_t* payload, 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);
- char* str = parcJSON_ToString(root_);
+ char *str = parcJSON_ToString(root_);
}
-TRANSPORT_ALWAYS_INLINE JSONManifestDecoder& JSONManifestDecoder::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_);
- PARCJSONValue* value =
+ PARCJSONValue *value =
parcJSON_GetValueByName(root_, JSONKey<core::Name>::key);
- PARCBuffer* b = parcJSONValue_GetString(value);
- char* string = 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_);
- PARCJSONValue* value =
+ PARCJSONValue *value =
parcJSON_GetValueByName(root_, JSONKey<bool>::final_manifest);
bool ret = parcJSONValue_GetBoolean(value);
diff --git a/libtransport/src/hicn/transport/core/manifest_format_json_libparc_deprecated.h b/libtransport/src/hicn/transport/core/manifest_format_json_libparc_deprecated.h
index 28c6c1b40..c89f4af7b 100755..100644
--- a/libtransport/src/hicn/transport/core/manifest_format_json_libparc_deprecated.h
+++ b/libtransport/src/hicn/transport/core/manifest_format_json_libparc_deprecated.h
@@ -42,37 +42,37 @@ struct JSONKey;
template <>
struct JSONKey<HashAlgorithm> {
- static const constexpr char* key = "hash_algorithm";
+ static const constexpr char *key = "hash_algorithm";
};
template <>
struct JSONKey<ManifestType> {
- static const constexpr char* key = "manifest_type";
+ static const constexpr char *key = "manifest_type";
};
template <>
struct JSONKey<NextSegmentCalculationStrategy> {
- static const constexpr char* key = "next_segment_strategy";
+ static const constexpr char *key = "next_segment_strategy";
};
template <>
struct JSONKey<NameHashList> {
- static const constexpr char* key = "name_hash_list";
+ static const constexpr char *key = "name_hash_list";
};
template <>
struct JSONKey<SuffixHashList> {
- static const constexpr char* key = "suffix_hash_list";
+ static const constexpr char *key = "suffix_hash_list";
};
template <>
struct JSONKey<core::Name> {
- static const constexpr char* key = "base_name";
+ static const constexpr char *key = "base_name";
};
template <>
struct JSONKey<bool> {
- static const constexpr char* final_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);
- JSONManifestEncoder& clearImpl();
+ JSONManifestEncoder &clearImpl();
- JSONManifestEncoder& setManifestTypeImpl(ManifestType manifest_type);
+ JSONManifestEncoder &setManifestTypeImpl(ManifestType manifest_type);
- JSONManifestEncoder& setHashAlgorithmImpl(HashAlgorithm algorithm);
+ JSONManifestEncoder &setHashAlgorithmImpl(HashAlgorithm algorithm);
- JSONManifestEncoder& setNextSegmentCalculationStrategyImpl(
+ JSONManifestEncoder &setNextSegmentCalculationStrategyImpl(
NextSegmentCalculationStrategy strategy);
- JSONManifestEncoder& setSuffixHashListImpl(
- const SuffixHashList& name_hash_list);
+ JSONManifestEncoder &setSuffixHashListImpl(
+ const SuffixHashList &name_hash_list);
- JSONManifestEncoder& setBaseNameImpl(const core::Name& base_name);
+ JSONManifestEncoder &setBaseNameImpl(const core::Name &base_name);
- JSONManifestEncoder& addSuffixAndHashImpl(uint32_t suffix, uint64_t hash);
+ JSONManifestEncoder &addSuffixAndHashImpl(uint32_t suffix, uint64_t hash);
- JSONManifestEncoder& setIsFinalManifestImpl(bool is_last);
+ JSONManifestEncoder &setIsFinalManifestImpl(bool is_last);
private:
- PARCJSON* root_;
+ PARCJSON *root_;
};
class JSONManifestDecoder : public ManifestDecoder<JSONManifestDecoder> {
@@ -125,9 +125,9 @@ class JSONManifestDecoder : public ManifestDecoder<JSONManifestDecoder> {
~JSONManifestDecoder();
- void decodeImpl(const uint8_t* payload, std::size_t payload_size);
+ void decodeImpl(const uint8_t *payload, std::size_t payload_size);
- JSONManifestDecoder& clearImpl();
+ JSONManifestDecoder &clearImpl();
ManifestType getManifestTypeImpl() const;
@@ -144,7 +144,7 @@ class JSONManifestDecoder : public ManifestDecoder<JSONManifestDecoder> {
bool getIsFinalManifestImpl();
private:
- PARCJSON* root_;
+ PARCJSON *root_;
};
} // namespace core
diff --git a/libtransport/src/hicn/transport/core/manifest_inline.h b/libtransport/src/hicn/transport/core/manifest_inline.h
index fd1a9abd3..1f2c4edb4 100755..100644
--- a/libtransport/src/hicn/transport/core/manifest_inline.h
+++ b/libtransport/src/hicn/transport/core/manifest_inline.h
@@ -37,15 +37,15 @@ class ManifestInline
public:
ManifestInline() : ManifestBase() {}
- ManifestInline(const core::Name& name) : 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 ManifestInline* createManifest(
- const core::Name& manifest_name, ManifestVersion version,
+ static TRANSPORT_ALWAYS_INLINE ManifestInline *createManifest(
+ const core::Name &manifest_name, ManifestVersion version,
ManifestType type, HashAlgorithm algorithm, bool is_last,
- const Name& base_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;
}
- ManifestInline& encodeImpl() {
+ ManifestInline &encodeImpl() {
ManifestBase::encoder_.encode();
return *this;
}
- ManifestInline& decodeImpl() {
+ 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 Name& getBaseName() { 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 SuffixList& getSuffixList() { return suffix_hash_map_; }
+ const SuffixList &getSuffixList() { return suffix_hash_map_; }
- ManifestInline& setNextSegmentCalculationStrategy(
+ ManifestInline &setNextSegmentCalculationStrategy(
NextSegmentCalculationStrategy strategy) {
next_segment_strategy_ = strategy;
ManifestBase::encoder_.setNextSegmentCalculationStrategy(
diff --git a/libtransport/src/hicn/transport/core/memif_binary_api.c b/libtransport/src/hicn/transport/core/memif_binary_api.c
index b443b51ce..834c8db13 100755..100644
--- a/libtransport/src/hicn/transport/core/memif_binary_api.c
+++ b/libtransport/src/hicn/transport/core/memif_binary_api.c
@@ -57,6 +57,10 @@
#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
@@ -66,35 +70,34 @@
_(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;
}
diff --git a/libtransport/src/hicn/transport/core/memif_binary_api.h b/libtransport/src/hicn/transport/core/memif_binary_api.h
index 582aeb1a0..b950292b9 100755..100644
--- a/libtransport/src/hicn/transport/core/memif_binary_api.h
+++ b/libtransport/src/hicn/transport/core/memif_binary_api.h
@@ -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_t* api,
- memif_create_params_t* input_params,
- memif_output_params_t* output_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_t* api,
+int memif_binary_api_delete_memif(vpp_plugin_binary_api_t *api,
uint32_t sw_if_index);
#ifdef __cplusplus
diff --git a/libtransport/src/hicn/transport/core/memif_connector.cc b/libtransport/src/hicn/transport/core/memif_connector.cc
index 7a672314e..b3785e5c3 100755..100644
--- a/libtransport/src/hicn/transport/core/memif_connector.cc
+++ b/libtransport/src/hicn/transport/core/memif_connector.cc
@@ -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");
+ }
}
}
diff --git a/libtransport/src/hicn/transport/core/memif_connector.h b/libtransport/src/hicn/transport/core/memif_connector.h
index 24c8ac16c..4667ec0b2 100755..100644
--- a/libtransport/src/hicn/transport/core/memif_connector.h
+++ b/libtransport/src/hicn/transport/core/memif_connector.h
@@ -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_;
diff --git a/libtransport/src/hicn/transport/core/name.cc b/libtransport/src/hicn/transport/core/name.cc
index 10c45eb08..10c45eb08 100755..100644
--- a/libtransport/src/hicn/transport/core/name.cc
+++ b/libtransport/src/hicn/transport/core/name.cc
diff --git a/libtransport/src/hicn/transport/core/name.h b/libtransport/src/hicn/transport/core/name.h
index b0da15026..b0da15026 100755..100644
--- a/libtransport/src/hicn/transport/core/name.h
+++ b/libtransport/src/hicn/transport/core/name.h
diff --git a/libtransport/src/hicn/transport/core/packet.cc b/libtransport/src/hicn/transport/core/packet.cc
index 74f407ff7..69cbb3cb3 100755..100644
--- a/libtransport/src/hicn/transport/core/packet.cc
+++ b/libtransport/src/hicn/transport/core/packet.cc
@@ -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.");
diff --git a/libtransport/src/hicn/transport/core/packet.h b/libtransport/src/hicn/transport/core/packet.h
index 0a5673401..bc23588dc 100755..100644
--- a/libtransport/src/hicn/transport/core/packet.h
+++ b/libtransport/src/hicn/transport/core/packet.h
@@ -20,10 +20,10 @@
#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;
diff --git a/libtransport/src/hicn/transport/core/payload_type.h b/libtransport/src/hicn/transport/core/payload_type.h
index fa79db35a..fa79db35a 100755..100644
--- a/libtransport/src/hicn/transport/core/payload_type.h
+++ b/libtransport/src/hicn/transport/core/payload_type.h
diff --git a/libtransport/src/hicn/transport/core/pending_interest.cc b/libtransport/src/hicn/transport/core/pending_interest.cc
index 8f6de1839..8f6de1839 100755..100644
--- a/libtransport/src/hicn/transport/core/pending_interest.cc
+++ b/libtransport/src/hicn/transport/core/pending_interest.cc
diff --git a/libtransport/src/hicn/transport/core/pending_interest.h b/libtransport/src/hicn/transport/core/pending_interest.h
index cbcafb5d9..cbcafb5d9 100755..100644
--- a/libtransport/src/hicn/transport/core/pending_interest.h
+++ b/libtransport/src/hicn/transport/core/pending_interest.h
diff --git a/libtransport/src/hicn/transport/core/portal.h b/libtransport/src/hicn/transport/core/portal.h
index 88020447f..a79717037 100755..100644
--- a/libtransport/src/hicn/transport/core/portal.h
+++ b/libtransport/src/hicn/transport/core/portal.h
@@ -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_;
diff --git a/libtransport/src/hicn/transport/core/prefix.cc b/libtransport/src/hicn/transport/core/prefix.cc
index 69c2b845a..69c2b845a 100755..100644
--- a/libtransport/src/hicn/transport/core/prefix.cc
+++ b/libtransport/src/hicn/transport/core/prefix.cc
diff --git a/libtransport/src/hicn/transport/core/prefix.h b/libtransport/src/hicn/transport/core/prefix.h
index b68c6bdf6..b68c6bdf6 100755..100644
--- a/libtransport/src/hicn/transport/core/prefix.h
+++ b/libtransport/src/hicn/transport/core/prefix.h
diff --git a/libtransport/src/hicn/transport/core/raw_socket_connector.cc b/libtransport/src/hicn/transport/core/raw_socket_connector.cc
index 5cfff39fb..5cfff39fb 100755..100644
--- a/libtransport/src/hicn/transport/core/raw_socket_connector.cc
+++ b/libtransport/src/hicn/transport/core/raw_socket_connector.cc
diff --git a/libtransport/src/hicn/transport/core/raw_socket_connector.h b/libtransport/src/hicn/transport/core/raw_socket_connector.h
index 5e39efa0e..5e39efa0e 100755..100644
--- a/libtransport/src/hicn/transport/core/raw_socket_connector.h
+++ b/libtransport/src/hicn/transport/core/raw_socket_connector.h
diff --git a/libtransport/src/hicn/transport/core/raw_socket_interface.cc b/libtransport/src/hicn/transport/core/raw_socket_interface.cc
index 37aaff7e0..37aaff7e0 100755..100644
--- a/libtransport/src/hicn/transport/core/raw_socket_interface.cc
+++ b/libtransport/src/hicn/transport/core/raw_socket_interface.cc
diff --git a/libtransport/src/hicn/transport/core/raw_socket_interface.h b/libtransport/src/hicn/transport/core/raw_socket_interface.h
index c030af662..c030af662 100755..100644
--- a/libtransport/src/hicn/transport/core/raw_socket_interface.h
+++ b/libtransport/src/hicn/transport/core/raw_socket_interface.h
diff --git a/libtransport/src/hicn/transport/core/socket_connector.cc b/libtransport/src/hicn/transport/core/socket_connector.cc
index 332b87ec7..332b87ec7 100755..100644
--- a/libtransport/src/hicn/transport/core/socket_connector.cc
+++ b/libtransport/src/hicn/transport/core/socket_connector.cc
diff --git a/libtransport/src/hicn/transport/core/socket_connector.h b/libtransport/src/hicn/transport/core/socket_connector.h
index d7a05aab4..d7a05aab4 100755..100644
--- a/libtransport/src/hicn/transport/core/socket_connector.h
+++ b/libtransport/src/hicn/transport/core/socket_connector.h
diff --git a/libtransport/src/hicn/transport/core/test/test_core_manifest.cc b/libtransport/src/hicn/transport/core/test/test_core_manifest.cc
index 58563d8f9..58563d8f9 100755..100644
--- a/libtransport/src/hicn/transport/core/test/test_core_manifest.cc
+++ b/libtransport/src/hicn/transport/core/test/test_core_manifest.cc
diff --git a/libtransport/src/hicn/transport/core/vpp_binary_api.c b/libtransport/src/hicn/transport/core/vpp_binary_api.c
index ab23d3cf5..09ffb2ec6 100755..100644
--- a/libtransport/src/hicn/transport/core/vpp_binary_api.c
+++ b/libtransport/src/hicn/transport/core/vpp_binary_api.c
@@ -53,13 +53,22 @@
#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);
diff --git a/libtransport/src/hicn/transport/core/vpp_binary_api.h b/libtransport/src/hicn/transport/core/vpp_binary_api.h
index 1eb10e766..932a59ec2 100755..100644
--- a/libtransport/src/hicn/transport/core/vpp_binary_api.h
+++ b/libtransport/src/hicn/transport/core/vpp_binary_api.h
@@ -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_t* api);
+void vpp_binary_api_destroy(vpp_binary_api_t *api);
-void vpp_binary_api_send_receive_ping(vpp_binary_api_t* api);
+void vpp_binary_api_send_receive_ping(vpp_binary_api_t *api);
-int vpp_binary_api_set_int_state(vpp_binary_api_t* api, 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_t* api,
- void* request);
+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_t* api);
+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
}
diff --git a/libtransport/src/hicn/transport/core/vpp_binary_api_internal.h b/libtransport/src/hicn/transport/core/vpp_binary_api_internal.h
index 22b665e96..a6e2c01a3 100755..100644
--- a/libtransport/src/hicn/transport/core/vpp_binary_api_internal.h
+++ b/libtransport/src/hicn/transport/core/vpp_binary_api_internal.h
@@ -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)); \
diff --git a/libtransport/src/hicn/transport/core/vpp_forwarder_interface.cc b/libtransport/src/hicn/transport/core/vpp_forwarder_interface.cc
index 3a748c821..0335c3829 100755..100644
--- a/libtransport/src/hicn/transport/core/vpp_forwarder_interface.cc
+++ b/libtransport/src/hicn/transport/core/vpp_forwarder_interface.cc
@@ -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));
}
}
diff --git a/libtransport/src/hicn/transport/core/vpp_forwarder_interface.h b/libtransport/src/hicn/transport/core/vpp_forwarder_interface.h
index 322cd1f8b..322cd1f8b 100755..100644
--- a/libtransport/src/hicn/transport/core/vpp_forwarder_interface.h
+++ b/libtransport/src/hicn/transport/core/vpp_forwarder_interface.h
diff --git a/libtransport/src/hicn/transport/interfaces/full_duplex_socket.cc b/libtransport/src/hicn/transport/interfaces/full_duplex_socket.cc
index 7b6342262..37e1d7b3e 100755..100644
--- a/libtransport/src/hicn/transport/interfaces/full_duplex_socket.cc
+++ b/libtransport/src/hicn/transport/interfaces/full_duplex_socket.cc
@@ -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});
diff --git a/libtransport/src/hicn/transport/interfaces/rtc_socket_producer.cc b/libtransport/src/hicn/transport/interfaces/rtc_socket_producer.cc
index d8a9d53b9..ec8c4c69e 100755..100644
--- a/libtransport/src/hicn/transport/interfaces/rtc_socket_producer.cc
+++ b/libtransport/src/hicn/transport/interfaces/rtc_socket_producer.cc
@@ -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
diff --git a/libtransport/src/hicn/transport/interfaces/socket_consumer.cc b/libtransport/src/hicn/transport/interfaces/socket_consumer.cc
index 8109d0e99..27ed4e65f 100755..100644
--- a/libtransport/src/hicn/transport/interfaces/socket_consumer.cc
+++ b/libtransport/src/hicn/transport/interfaces/socket_consumer.cc
@@ -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_;
diff --git a/libtransport/src/hicn/transport/protocols/rtc.cc b/libtransport/src/hicn/transport/protocols/rtc.cc
index 1f42cf230..ee90e5d9e 100755..100644
--- a/libtransport/src/hicn/transport/protocols/rtc.cc
+++ b/libtransport/src/hicn/transport/protocols/rtc.cc
@@ -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;
//}
diff --git a/libtransport/src/hicn/transport/protocols/rtc_data_path.h b/libtransport/src/hicn/transport/protocols/rtc_data_path.h
index ace16ff12..b55139d52 100755..100644
--- a/libtransport/src/hicn/transport/protocols/rtc_data_path.h
+++ b/libtransport/src/hicn/transport/protocols/rtc_data_path.h
@@ -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
diff --git a/libtransport/src/hicn/transport/protocols/vegas.cc b/libtransport/src/hicn/transport/protocols/vegas.cc
index b6d79bfcc..1431020a6 100755..100644
--- a/libtransport/src/hicn/transport/protocols/vegas.cc
+++ b/libtransport/src/hicn/transport/protocols/vegas.cc
@@ -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() {
diff --git a/libtransport/src/hicn/transport/utils/identity.cc b/libtransport/src/hicn/transport/utils/identity.cc
index bdf7f29f9..1b2fd4828 100755..100644
--- a/libtransport/src/hicn/transport/utils/identity.cc
+++ b/libtransport/src/hicn/transport/utils/identity.cc
@@ -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());
diff --git a/libtransport/src/hicn/transport/utils/log.cc b/libtransport/src/hicn/transport/utils/log.cc
index 064625ec0..00bd7d54f 100755..100644
--- a/libtransport/src/hicn/transport/utils/log.cc
+++ b/libtransport/src/hicn/transport/utils/log.cc
@@ -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,
@@ -321,19 +321,19 @@
#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
diff --git a/libtransport/src/hicn/transport/utils/log.h b/libtransport/src/hicn/transport/utils/log.h
index 17e47e7df..3c4f1277a 100755..100644
--- a/libtransport/src/hicn/transport/utils/log.h
+++ b/libtransport/src/hicn/transport/utils/log.h
@@ -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,
diff --git a/libtransport/src/hicn/transport/utils/object_pool.h b/libtransport/src/hicn/transport/utils/object_pool.h
index d4d8e18d6..c369f7e12 100755
--- a/libtransport/src/hicn/transport/utils/object_pool.h
+++ b/libtransport/src/hicn/transport/utils/object_pool.h
@@ -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
diff --git a/libtransport/src/hicn/transport/utils/signer.cc b/libtransport/src/hicn/transport/utils/signer.cc
index c11d5e183..579b08aff 100755..100644
--- a/libtransport/src/hicn/transport/utils/signer.cc
+++ b/libtransport/src/hicn/transport/utils/signer.cc
@@ -17,10 +17,9 @@
#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);
diff --git a/libtransport/src/hicn/transport/utils/verifier.cc b/libtransport/src/hicn/transport/utils/verifier.cc
index 9a3de43c1..93efe063a 100755..100644
--- a/libtransport/src/hicn/transport/utils/verifier.cc
+++ b/libtransport/src/hicn/transport/utils/verifier.cc
@@ -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)) {