aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
-rw-r--r--apps/http-proxy/CMakeLists.txt12
-rw-r--r--cmake/Modules/FindCollectd.cmake10
-rw-r--r--ctrl/facemgr/src/api.c81
-rw-r--r--ctrl/facemgr/src/facelet.c6
-rw-r--r--ctrl/facemgr/src/interfaces/android_utility/android_utility.c4
-rw-r--r--ctrl/facemgr/src/interfaces/hicn_light/hicn_light.c5
-rw-r--r--ctrl/facemgr/src/interfaces/priority_controller/priority_controller.c146
-rw-r--r--ctrl/facemgr/src/interfaces/priority_controller/priority_controller.h45
-rw-r--r--ctrl/libhicnctrl/cmake/Modules/Packaging.cmake4
-rw-r--r--ctrl/libhicnctrl/includes/hicn/ctrl/api.h2
-rw-r--r--ctrl/libhicnctrl/includes/hicn/ctrl/commands.h4
-rw-r--r--hicn-light/src/hicn/config/configurationListeners.c4
-rw-r--r--hicn-light/src/hicn/config/controlAddPolicy.c2
-rw-r--r--hicn-light/src/hicn/core/mapme.c61
-rw-r--r--hicn-light/src/hicn/core/name.c5
-rw-r--r--hicn-light/src/hicn/core/nameBitvector.c4
-rw-r--r--hicn-light/src/hicn/io/hicnListener.c6
-rw-r--r--hicn-light/src/hicn/io/udpListener.c1
-rw-r--r--hicn-light/src/hicn/processor/fib.c5
-rw-r--r--hicn-light/src/hicn/processor/fibEntry.c10
-rw-r--r--hicn-light/src/hicn/processor/fibEntry.h11
-rw-r--r--hicn-light/src/hicn/processor/messageProcessor.c1
-rw-r--r--hicn-light/src/hicn/strategies/loadBalancer.c12
-rw-r--r--hicn-light/src/hicn/utils/commands.h4
-rw-r--r--hicn-plugin/src/route.c49
-rw-r--r--hicn-plugin/vapi/vapi_safe.c6
-rw-r--r--lib/includes/hicn/policy.h6
-rw-r--r--libtransport/CMakeLists.txt1
-rw-r--r--libtransport/cmake/Modules/Packaging.cmake8
-rw-r--r--libtransport/src/core/forwarder_interface.h5
-rw-r--r--libtransport/src/core/memif_connector.cc7
-rw-r--r--libtransport/src/core/memif_connector.h5
-rw-r--r--libtransport/src/core/vpp_forwarder_interface.cc21
-rw-r--r--libtransport/src/core/vpp_forwarder_interface.h1
-rw-r--r--libtransport/src/http/response.cc5
-rw-r--r--libtransport/src/utils/epoll_event_reactor.cc7
-rw-r--r--telemetry/vpp-collectd/CMakeLists.txt2
-rw-r--r--telemetry/vpp-collectd/vpp-hicn/CMakeLists.txt9
-rw-r--r--telemetry/vpp-collectd/vpp-hicn/vpp_hicn.c30
-rw-r--r--telemetry/vpp-collectd/vpp/CMakeLists.txt22
-rw-r--r--telemetry/vpp-collectd/vpp/vpp.c33
-rw-r--r--utils/src/hiperf.cc6
42 files changed, 465 insertions, 203 deletions
diff --git a/apps/http-proxy/CMakeLists.txt b/apps/http-proxy/CMakeLists.txt
index d2d02d0dc..8c2043c30 100644
--- a/apps/http-proxy/CMakeLists.txt
+++ b/apps/http-proxy/CMakeLists.txt
@@ -14,6 +14,18 @@
cmake_minimum_required(VERSION 3.5 FATAL_ERROR)
set(CMAKE_CXX_STANDARD 14)
+# -Wno-c99-designator issue
+#
+# Unsure about version for which this was introduced
+# clang version 9.0.8 (no flag), 11.0.5 (ndk22, flag)
+if (CMAKE_CXX_COMPILER_ID STREQUAL "Clang")
+ EXECUTE_PROCESS( COMMAND ${CMAKE_CXX_COMPILER} --version OUTPUT_VARIABLE clang_full_version_string )
+ string (REGEX REPLACE ".*clang version ([0-9]+\\.[0-9]+).*" "\\1" CLANG_VERSION_STRING ${clang_full_version_string})
+ if (CLANG_VERSION_STRING VERSION_GREATER_EQUAL 11)
+ set(CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS} -Wno-c99-designator")
+ endif()
+endif()
+
set(CMAKE_MODULE_PATH
${CMAKE_MODULE_PATH}
"${CMAKE_SOURCE_DIR}/cmake/Modules/"
diff --git a/cmake/Modules/FindCollectd.cmake b/cmake/Modules/FindCollectd.cmake
index 76d2df43f..244fd14e5 100644
--- a/cmake/Modules/FindCollectd.cmake
+++ b/cmake/Modules/FindCollectd.cmake
@@ -25,21 +25,15 @@ find_path(COLLECTD_INCLUDE_DIR collectd.h
DOC "Find the collectd includes"
)
-find_path(COLLECTD_COMMON_INCLUDE_DIR common.h
- HINTS ${COLLECTD_SEARCH_PATH_LIST}
- PATH_SUFFIXES include/collectd/core/daemon/ utils/common/
- DOC "Find the collectd includes"
-)
-
find_path(COLLECTD_CONFIG_INCLUDE_DIR config.h
HINTS ${COLLECTD_SEARCH_PATH_LIST}
PATH_SUFFIXES include/collectd/core/
DOC "Find the collectd includes"
)
-message(STATUS ${COLLECTD_INCLUDE_DIR} ${COLLECTD_COMMON_INCLUDE_DIR} ${COLLECTD_CONFIG_INCLUDE_DIR})
+message(STATUS ${COLLECTD_INCLUDE_DIR} ${COLLECTD_CONFIG_INCLUDE_DIR})
-set(COLLECTD_INCLUDE_DIRS ${COLLECTD_INCLUDE_DIR} ${COLLECTD_COMMON_INCLUDE_DIR} ${COLLECTD_CONFIG_INCLUDE_DIR})
+set(COLLECTD_INCLUDE_DIRS ${COLLECTD_INCLUDE_DIR} ${COLLECTD_CONFIG_INCLUDE_DIR})
include(FindPackageHandleStandardArgs)
find_package_handle_standard_args(Collectd DEFAULT_MSG COLLECTD_INCLUDE_DIRS)
diff --git a/ctrl/facemgr/src/api.c b/ctrl/facemgr/src/api.c
index f934883de..9e029c5b7 100644
--- a/ctrl/facemgr/src/api.c
+++ b/ctrl/facemgr/src/api.c
@@ -21,12 +21,12 @@
#ifdef __ANDROID__
/*
- * Use AndroidUtility to determine interface types
+ * Use FacemgrUtility to determine interface types
*
* NOTE: this is currently disabled as SDK APIs do not allow to determine the
* type of interfaces that are DOWN
*/
-//#define WITH_ANDROID_UTILITY
+//#define WITH_FACEMGR_UTILITY
/*
* Use priority controller interface
@@ -59,9 +59,11 @@
#include "interfaces/bonjour/bonjour.h"
#endif /* __linux__ */
-#ifdef WITH_ANDROID_UTILITY
+#ifdef WITH_FACEMGR_UTILITY
#include "interfaces/android_utility/android_utility.h"
-#endif /* WITH_ANDROID_UTILITY */
+#endif /* WITH_FACEMGR_UTILITY */
+
+#include "interfaces/priority_controller/priority_controller.h"
#include <hicn/ctrl/face.h>
#include <hicn/facemgr/facelet.h>
@@ -100,9 +102,9 @@ extern interface_ops_t network_framework_ops;
extern interface_ops_t netlink_ops;
extern interface_ops_t bonjour_ops;
#endif
-#ifdef WITH_ANDROID_UTILITY
+#ifdef WITH_FACEMGR_UTILITY
extern interface_ops_t android_utility_ops;
-#endif /* WITH_ANDROID_UTILITY */
+#endif /* WITH_FACEMGR_UTILITY */
#ifdef WITH_PRIORITY_CONTROLLER
extern interface_ops_t priority_controller_ops;
#endif
@@ -162,9 +164,9 @@ struct facemgr_s {
interface_t * hl;
-#ifdef WITH_ANDROID_UTILITY
+#ifdef WITH_FACEMGR_UTILITY
interface_t * au; /* android_utility */
-#endif /* WITH_ANDROID_UTILITY */
+#endif /* WITH_FACEMGR_UTILITY */
#ifdef WITH_PRIORITY_CONTROLLER
interface_t * pc;
@@ -538,7 +540,7 @@ int facemgr_query_bonjour(facemgr_t * facemgr, netdevice_t * netdevice)
}
#endif /* __linux__ */
-#ifdef WITH_ANDROID_UTILITY
+#ifdef WITH_FACEMGR_UTILITY
int facemgr_query_android_utility(facemgr_t * facemgr, netdevice_t netdevice)
{
/* Send an event to the interface */
@@ -564,7 +566,7 @@ ERR_ND:
ERR_MALLOC:
return -1;
}
-#endif /* WITH_ANDROID_UTILITY */
+#endif /* WITH_FACEMGR_UTILITY */
/**
@@ -640,7 +642,7 @@ facemgr_facelet_satisfy_rules(facemgr_t * facemgr, facelet_t * facelet)
}
netdevice_type_t netdevice_type = NETDEVICE_TYPE_UNDEFINED;
-#ifndef WITH_ANDROID_UTILITY
+#ifndef WITH_FACEMGR_UTILITY
/*
* In addition to netdevice, netdevice_type should be present to correctly
* apply rules
@@ -650,7 +652,7 @@ facemgr_facelet_satisfy_rules(facemgr_t * facemgr, facelet_t * facelet)
ERROR("[facemgr_facelet_satisfy_rules] Error retrieving netdevice_type from facelet");
return -2;
}
-#endif /* WITH_ANDROID_UTILITY */
+#endif /* WITH_FACEMGR_UTILITY */
/* Default ignore list */
if ((netdevice_type == NETDEVICE_TYPE_LOOPBACK) || (netdevice_type == NETDEVICE_TYPE_UNDEFINED)) {
@@ -705,7 +707,7 @@ facemgr_facelet_satisfy_rules(facemgr_t * facemgr, facelet_t * facelet)
return 0;
}
-#ifdef WITH_ANDROID_UTILITY
+#ifdef WITH_FACEMGR_UTILITY
/**
* \brief Complements facelet information through Android Utility interface
* \return 0 if request was successful, -1 in case of error, and -2 if the
@@ -741,7 +743,7 @@ facemgr_complement_facelet_au(facemgr_t * facemgr, facelet_t * facelet)
facelet_set_au_done(facelet);
return 0;
}
-#endif /* WITH_ANDROID_UTILITY */
+#endif /* WITH_FACEMGR_UTILITY */
#ifdef __linux__
/**
@@ -763,7 +765,7 @@ facemgr_complement_facelet_bj(facemgr_t * facemgr, facelet_t * facelet)
}
netdevice_type_t netdevice_type = NETDEVICE_TYPE_UNDEFINED;
-#ifndef WITH_ANDROID_UTILITY
+#ifndef WITH_FACEMGR_UTILITY
/*
* In addition to netdevice, netdevice_type should be present to correctly
* apply rules
@@ -773,7 +775,7 @@ facemgr_complement_facelet_bj(facemgr_t * facemgr, facelet_t * facelet)
ERROR("[facemgr_complement_facelet_bj] Error retrieving netdevice_type from facelet");
return -2;
}
-#endif /* WITH_ANDROID_UTILITY */
+#endif /* WITH_FACEMGR_UTILITY */
bool discovery;
if (facemgr_cfg_get_discovery(facemgr->cfg, &netdevice, netdevice_type,
@@ -835,7 +837,7 @@ facemgr_complement_facelet_manual(facemgr_t * facemgr, facelet_t * facelet)
}
netdevice_type_t netdevice_type = NETDEVICE_TYPE_UNDEFINED;
-#ifndef WITH_ANDROID_UTILITY
+#ifndef WITH_FACEMGR_UTILITY
/*
* In addition to netdevice, netdevice_type should be present to correctly
* apply rules
@@ -845,7 +847,7 @@ facemgr_complement_facelet_manual(facemgr_t * facemgr, facelet_t * facelet)
ERROR("[facemgr_complement_facelet_manual] Error retrieving netdevice_type from facelet");
return -2;
}
-#endif /* WITH_ANDROID_UTILITY */
+#endif /* WITH_FACEMGR_UTILITY */
int family = AF_UNSPEC;
if (facelet_has_family(facelet)) {
@@ -957,11 +959,11 @@ facemgr_complement_facelet(facemgr_t * facemgr, facelet_t * facelet)
if (!facelet_has_key(facelet))
return -2;
-#ifdef WITH_ANDROID_UTILITY
+#ifdef WITH_FACEMGR_UTILITY
rc = facemgr_complement_facelet_au(facemgr, facelet);
if (rc != -2)
return rc;
-#endif /* WITH_ANDROID_UTILITY */
+#endif /* WITH_FACEMGR_UTILITY */
#if 0
if (!facelet_has_netdevice_type(facelet)) {
@@ -1008,7 +1010,7 @@ int facemgr_assign_face_type(facemgr_t * facemgr, facelet_t * facelet)
}
netdevice_type_t netdevice_type = NETDEVICE_TYPE_UNDEFINED;
-#ifndef WITH_ANDROID_UTILITY
+#ifndef WITH_FACEMGR_UTILITY
/*
* In addition to netdevice, netdevice_type should be present to correctly
* apply rules
@@ -1018,7 +1020,7 @@ int facemgr_assign_face_type(facemgr_t * facemgr, facelet_t * facelet)
ERROR("[facemgr_assign_face_type] Error retrieving netdevice_type from facelet");
return -2;
}
-#endif /* WITH_ANDROID_UTILITY */
+#endif /* WITH_FACEMGR_UTILITY */
facemgr_face_type_t face_type = FACEMGR_FACE_TYPE_UNDEFINED;
if (facemgr_cfg_get_face_type(facemgr->cfg, &netdevice, netdevice_type, &face_type) < 0)
@@ -1153,9 +1155,9 @@ facemgr_process_facelet(facemgr_t * facemgr, facelet_t * facelet)
facelet_unset_admin_state(facelet);
facelet_unset_state(facelet);
facelet_unset_bj_done(facelet);
-#ifdef WITH_ANDROID_UTILITY
+#ifdef WITH_FACEMGR_UTILITY
facelet_unset_au_done(facelet);
-#endif /* WITH_ANDROID_UTILITY */
+#endif /* WITH_FACEMGR_UTILITY */
facelet_set_status(facelet, FACELET_STATUS_DELETED);
#if 0
@@ -1416,9 +1418,9 @@ facemgr_consider_static_facelet(facemgr_t * facemgr, facelet_t * facelet)
facelet_unset_state(new_facelet);
facelet_unset_bj_done(new_facelet);
facelet_clear_routes(new_facelet);
-#ifdef WITH_ANDROID_UTILITY
+#ifdef WITH_FACEMGR_UTILITY
facelet_unset_au_done(new_facelet);
-#endif /* WITH_ANDROID_UTILITY */
+#endif /* WITH_FACEMGR_UTILITY */
/* We try to apply static_facelet over facelet */
if (!facelet_match(new_facelet, static_facelet)) {
@@ -1650,9 +1652,9 @@ facemgr_process_facelet_delete(facemgr_t * facemgr, facelet_t * facelet)
facelet_unset_admin_state(facelet);
facelet_unset_state(facelet);
facelet_unset_bj_done(facelet);
-#ifdef WITH_ANDROID_UTILITY
+#ifdef WITH_FACEMGR_UTILITY
facelet_unset_au_done(facelet);
-#endif /* WITH_ANDROID_UTILITY */
+#endif /* WITH_FACEMGR_UTILITY */
facelet_unset_error(facelet);
facelet_set_status(facelet, FACELET_STATUS_DELETED);
#if 0
@@ -2188,13 +2190,13 @@ facemgr_bootstrap(facemgr_t * facemgr)
}
#endif /* __linux__ */
-#ifdef WITH_ANDROID_UTILITY
+#ifdef WITH_FACEMGR_UTILITY
rc = interface_register(&android_utility_ops);
if (rc < 0) {
ERROR("[facemgr_bootstrap] Error registering android_utility interface");
goto ERR_REGISTER;
}
-#endif /* WITH_ANDROID_UTILITY */
+#endif /* WITH_FACEMGR_UTILITY */
#ifdef WITH_PRIORITY_CONTROLLER
INFO("[facemgr_bootstrap] registering priority_controller interface");
@@ -2245,7 +2247,7 @@ facemgr_bootstrap(facemgr_t * facemgr)
}
#endif /* __linux__ */
-#ifdef WITH_ANDROID_UTILITY
+#ifdef WITH_FACEMGR_UTILITY
android_utility_cfg_t au_cfg = {
.jvm = facemgr->jvm,
};
@@ -2254,11 +2256,16 @@ facemgr_bootstrap(facemgr_t * facemgr)
ERROR("Error creating 'Android Utility' interface\n");
goto ERR_AU_CREATE;
}
-#endif /* WITH_ANDROID_UTILITY */
+#endif /* WITH_FACEMGR_UTILITY */
#ifdef WITH_PRIORITY_CONTROLLER
INFO("[facemgr_bootstrap] creating priority_controller interface");
- rc = facemgr_create_interface(facemgr, "pc", "priority_controller", NULL, &facemgr->pc);
+ priority_controller_cfg_t pc_cfg = {
+#ifdef PRIORITY_CONTROLLER_INTERNAL
+ .jvm = facemgr->jvm,
+#endif /* PRIORITY_CONTROLLER_INTERNAL */
+ };
+ rc = facemgr_create_interface(facemgr, "pc", "priority_controller", &pc_cfg, &facemgr->pc);
if (rc < 0) {
ERROR("Error creating 'Priority Controller' interface\n");
goto ERR_PC_CREATE;
@@ -2293,10 +2300,10 @@ ERR_UPDOWN_CREATE:
facemgr_delete_interface(facemgr, facemgr->dummy);
ERR_DUMMY_CREATE:
#endif
-#ifdef WITH_ANDROID_UTILITY
+#ifdef WITH_FACEMGR_UTILITY
facemgr_delete_interface(facemgr, facemgr->au);
ERR_AU_CREATE:
-#endif /* WITH_ANDROID_UTILITY */
+#endif /* WITH_FACEMGR_UTILITY */
#ifdef WITH_PRIORITY_CONTROLLER
facemgr_delete_interface(facemgr, facemgr->pc);
ERR_PC_CREATE:
@@ -2346,9 +2353,9 @@ void facemgr_stop(facemgr_t * facemgr)
}
#endif /* __linux__ */
-#ifdef WITH_ANDROID_UTILITY
+#ifdef WITH_FACEMGR_UTILITY
facemgr_delete_interface(facemgr, facemgr->au);
-#endif /* WITH_ANDROID_UTILITY */
+#endif /* WITH_FACEMGR_UTILITY */
#ifdef WITH_PRIORITY_CONTROLLER
facemgr_delete_interface(facemgr, facemgr->pc);
diff --git a/ctrl/facemgr/src/facelet.c b/ctrl/facemgr/src/facelet.c
index 0cf44d4dc..9e9f3f67f 100644
--- a/ctrl/facemgr/src/facelet.c
+++ b/ctrl/facemgr/src/facelet.c
@@ -356,8 +356,10 @@ facelet_create_from_face(face_t * face)
facelet->error = 0;
/* TODO Consistency check between face type and found attributes */
- if (facelet_validate_face(facelet) < 0)
+ if (facelet_validate_face(facelet) < 0) {
+ ERROR("[facelet_create_from_face] Cannot validate face");
goto ERR_FACE;
+ }
facelet->bj_done = false;
facelet->au_done = false;
@@ -367,7 +369,7 @@ facelet_create_from_face(face_t * face)
/* We need to get route set */
facelet->routes = route_set_create();
if (!facelet->routes) {
- ERROR("[facelet_create] Cannot create route set");
+ ERROR("[facelet_create_from_face] Cannot create route set");
goto ERR_ROUTE_SET;
}
facelet->routes_done = false;
diff --git a/ctrl/facemgr/src/interfaces/android_utility/android_utility.c b/ctrl/facemgr/src/interfaces/android_utility/android_utility.c
index d1fe324fb..d8e20659a 100644
--- a/ctrl/facemgr/src/interfaces/android_utility/android_utility.c
+++ b/ctrl/facemgr/src/interfaces/android_utility/android_utility.c
@@ -28,7 +28,7 @@
#include "android_utility.h"
-#define FACEMGR_ANDROID_UTILITY_CLASS "com/cisco/hicn/forwarder/supportlibrary/AndroidUtility"
+#define FACEMGR_UTILITY_CLASS "com/cisco/hicn/facemgrlibrary/supportlibrary/FacemgrUtility"
#define AU_INTERFACE_TYPE_UNDEFINED 0
@@ -89,7 +89,7 @@ int au_on_event(interface_t * interface, facelet_t * facelet)
JNIEnv *env;
JavaVM *jvm = data->cfg.jvm;
(*jvm)->AttachCurrentThread(jvm, &env, NULL);
- jclass cls = (*env)->FindClass(env, FACEMGR_ANDROID_UTILITY_CLASS);
+ jclass cls = (*env)->FindClass(env, FACEMGR_UTILITY_CLASS);
jmethodID getNetworkType = (*env)->GetStaticMethodID(env, cls,
"getNetworkType", "(Ljava/lang/String;)I");
jint interface_type = (*env)->CallStaticIntMethod(env, cls, getNetworkType,
diff --git a/ctrl/facemgr/src/interfaces/hicn_light/hicn_light.c b/ctrl/facemgr/src/interfaces/hicn_light/hicn_light.c
index 508c0713b..74a0cd62b 100644
--- a/ctrl/facemgr/src/interfaces/hicn_light/hicn_light.c
+++ b/ctrl/facemgr/src/interfaces/hicn_light/hicn_light.c
@@ -642,6 +642,11 @@ int hl_callback(interface_t * interface, int fd, void * unused)
/* We can ignore faces on localhost */
facelet_t * facelet = facelet_create_from_face(&f->face);
+ if (!facelet) {
+ ERROR("[hl_callback] Could not create facelet... skipping");
+ continue;
+ }
+
foreach_route(r, data->polled_routes) {
if (r->face_id != f->id)
continue;
diff --git a/ctrl/facemgr/src/interfaces/priority_controller/priority_controller.c b/ctrl/facemgr/src/interfaces/priority_controller/priority_controller.c
index 76538185f..67edc5e39 100644
--- a/ctrl/facemgr/src/interfaces/priority_controller/priority_controller.c
+++ b/ctrl/facemgr/src/interfaces/priority_controller/priority_controller.c
@@ -1,5 +1,5 @@
/*
- * Copyright (c) 2017-2019 Cisco and/or its affiliates.
+ * Copyright (c) 2017-2020 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:
@@ -27,19 +27,110 @@
#include <hicn/facemgr.h>
+#include "priority_controller.h"
#include "../../common.h"
#include "../../interface.h"
#define PC_DEFAULT_PORT 9533
typedef struct {
+ priority_controller_cfg_t cfg;
int fd;
+#ifdef PRIORITY_CONTROLLER_INTERNAL
+ unsigned state;
+ JNIEnv * env;
+ jclass cls;
+ jmethodID mid;
+#endif /* PRIORITY_CONTROLLER_INTERNAL */
} pc_data_t;
+#ifdef PRIORITY_CONTROLLER_INTERNAL
+#include <jni.h>
+
+#define ERR_STR_JAVA "Java VM parameters are required in the interface configuration."
+
+#define PREFER_CELLULAR 0
+#define PREFER_WIFI 1
+#define PREFER_BOTH 2
+
+#define INTERVAL_MS 500
+
+const char * prefer_str[] = { "Cellular", "WiFi", "both" };
+
+jclass find_class_global(JNIEnv* env, const char *name){
+ jclass c = (*env)->FindClass(env, name);
+ jclass c_global = 0;
+ if (c){
+ c_global = (jclass)(*env)->NewGlobalRef(env, c);
+ (*env)->DeleteLocalRef(env, c);
+ }
+ return c_global;
+}
+
+
+int priority_controller_tick(interface_t * interface, int fd, void * unused)
+{
+ pc_data_t * data = (pc_data_t*)interface->data;
+ unsigned new_state = PREFER_BOTH;
+
+ jint rssi = (*data->env)->CallStaticIntMethod(data->env, data->cls, data->mid);
+ DEBUG("[priority_controller_tick] rssi=%d\n", rssi);
+ if (rssi > -67) {
+ new_state = PREFER_WIFI;
+
+#if 0
+ } else if ((rssi < -67) && (rssi > -70)) {
+ new_state = PREFER_BOTH;
+#endif
+
+ } else { /* rssi < -70 */
+ new_state = PREFER_CELLULAR;
+ }
+
+ if (new_state == data->state)
+ return 0;
+
+ ERROR("[priority_controller_tick] Setting priority to %s", prefer_str[new_state]);
+
+ /* XXX Factor this */
+
+ facelet_t * facelet_w = facelet_create();
+ facelet_t * facelet_c = facelet_create();
+ facelet_set_netdevice_type(facelet_w, NETDEVICE_TYPE_WIFI);
+ facelet_set_netdevice_type(facelet_c, NETDEVICE_TYPE_CELLULAR);
+ facelet_set_attr_clean(facelet_w);
+ facelet_set_attr_clean(facelet_c);
+
+ switch(new_state) {
+ case PREFER_CELLULAR:
+ facelet_set_priority(facelet_w, 0);
+ facelet_set_priority(facelet_c, 10);
+ break;
+ case PREFER_WIFI:
+ facelet_set_priority(facelet_w, 10);
+ facelet_set_priority(facelet_c, 0);
+ break;
+ case PREFER_BOTH:
+ facelet_set_priority(facelet_w, 0);
+ facelet_set_priority(facelet_c, 0);
+ break;
+ }
+
+ facelet_set_event(facelet_w, FACELET_EVENT_UPDATE);
+ facelet_set_event(facelet_c, FACELET_EVENT_UPDATE);
+
+ interface_raise_event(interface, facelet_w);
+ interface_raise_event(interface, facelet_c);
+
+ data->state = new_state;
+
+ return 0;
+}
+#endif /* PRIORITY_CONTROLLER_INTERNAL */
+
int priority_controller_initialize(interface_t * interface, void * cfg)
{
INFO("Initializing priority controller");
- struct sockaddr_in addr;
pc_data_t * data = malloc(sizeof(pc_data_t));
if (!data) {
@@ -49,6 +140,33 @@ int priority_controller_initialize(interface_t * interface, void * cfg)
interface->data = data;
+ data->cfg = * (priority_controller_cfg_t *) cfg;
+
+#ifdef PRIORITY_CONTROLLER_INTERNAL
+
+ if (!cfg) {
+ ERROR(ERR_STR_JAVA);
+ goto ERR_CFG;
+ }
+
+ /* Retrieve RSSI information from SDK through AndroidUtility class */
+ (*data->cfg.jvm)->AttachCurrentThread(data->cfg.jvm, &data->env, NULL);
+ data->cls = find_class_global(data->env, FACEMGR_ANDROID_UTILITY_CLASS);
+ if (data->cls == 0)
+ goto ERR_JAVA;
+ data->mid = (*data->env)->GetStaticMethodID(data->env, data->cls, "getWifiRSSI", "()I");
+
+ data->fd = interface_register_timer(interface, INTERVAL_MS,
+ priority_controller_tick, interface);
+ if (data->fd < 0) {
+ ERROR("[priority_controller_initialize] Could not initialize timer");
+ goto ERR_FD;
+ }
+ data->state = PREFER_BOTH;
+
+#else /* PRIORITY_CONTROLLER_INTERNAL */
+ struct sockaddr_in addr;
+
data->fd = socket(AF_INET, SOCK_DGRAM, 0);
//data->fd = socket(AF_INET, SOCK_STREAM, 0);
if (data->fd < 0) {
@@ -67,18 +185,28 @@ int priority_controller_initialize(interface_t * interface, void * cfg)
perror("bind error");
goto ERR_BIND;
}
+
+ DEBUG("[priority_controller_initialize] register fd");
if (interface_register_fd(interface, data->fd, NULL) < 0) {
ERROR("[priority_controller_initialize] Error registering fd");
goto ERR_FD;
}
+#endif /* PRIORITY_CONTROLLER_INTERNAL */
+
INFO("Priority controller successfully initialized");
return 0;
+#ifdef PRIORITY_CONTROLLER_INTERNAL
+ERR_CFG:
+ERR_JAVA:
+#endif /* PRIORITY_CONTROLLER_INTERNAL */
ERR_FD:
+#ifndef PRIORITY_CONTROLLER_INTERNAL
ERR_BIND:
close(data->fd);
ERR_SOCKET:
+#endif /* ! PRIORITY_CONTROLLER_INTERNAL */
free(data);
ERR_MALLOC:
return -1;
@@ -88,12 +216,21 @@ int priority_controller_finalize(interface_t * interface)
{
pc_data_t * data = (pc_data_t*)interface->data;
- if (data->fd > 0) {close(data->fd);}
+#ifdef PRIORITY_CONTROLLER_INTERNAL
+ DEBUG("[priority_controller_finalize] unregister timer");
+ interface_unregister_timer(interface, data->fd);
+#else
+ if (data->fd > 0) {
+ interface_unregister_fd(interface, data->fd);
+ close(data->fd);
+ }
free(data);
+#endif /* PRIORITY_CONTROLLER_INTERNAL */
return 0;
}
+#ifndef PRIORITY_CONTROLLER_INTERNAL
int priority_controller_callback(interface_t * interface, int fd, void * unused)
{
pc_data_t * data = (pc_data_t*)interface->data;
@@ -148,10 +285,13 @@ int priority_controller_callback(interface_t * interface, int fd, void * unused)
return 0;
}
+#endif /* ! PRIORITY_CONTROLLER_INTERNAL */
interface_ops_t priority_controller_ops = {
.type = "priority_controller",
.initialize = priority_controller_initialize,
.finalize = priority_controller_finalize,
+#ifndef PRIORITY_CONTROLLER_INTERNAL
.callback = priority_controller_callback,
+#endif /* ! PRIORITY_CONTROLLER_INTERNAL */
};
diff --git a/ctrl/facemgr/src/interfaces/priority_controller/priority_controller.h b/ctrl/facemgr/src/interfaces/priority_controller/priority_controller.h
new file mode 100644
index 000000000..247fc3c57
--- /dev/null
+++ b/ctrl/facemgr/src/interfaces/priority_controller/priority_controller.h
@@ -0,0 +1,45 @@
+/*
+ * Copyright (c) 2017-2020 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.
+ */
+
+/**
+ * \file priority_controller.h
+ * \brief Priority Controller interface
+ */
+
+#ifndef FACEMGR_INTERFACE_PRIORITY_CONTROLLER
+#define FACEMGR_INTERFACE_PRIORITY_CONTROLLER
+
+#define FACEMGR_UTILITY_CLASS "com/cisco/hicn/facemgrlibrary/supportlibrary/FacemgrUtility"
+
+/*
+ * Uncomment this line to use a Priority controller interface internal to the
+ * face manager (only available in Android).
+ */
+// #define PRIORITY_CONTROLLER_INTERNAL
+
+#ifdef __ANDROID__
+#include <jni.h>
+#endif /* __ANDROID__ */
+
+typedef struct {
+#ifdef __ANDROID__
+#ifdef PRIORITY_CONTROLLER_INTERNAL
+ JavaVM * jvm;
+#endif /* PRIORITY_CONTROLLER_INTERNAL */
+#endif /* __ANDROID__ */
+} priority_controller_cfg_t;
+
+
+#endif /* FACEMGR_INTERFACE_PRIORITY_CONTROLLER */
diff --git a/ctrl/libhicnctrl/cmake/Modules/Packaging.cmake b/ctrl/libhicnctrl/cmake/Modules/Packaging.cmake
index 92e9d4adb..bf0a4d504 100644
--- a/ctrl/libhicnctrl/cmake/Modules/Packaging.cmake
+++ b/ctrl/libhicnctrl/cmake/Modules/Packaging.cmake
@@ -32,7 +32,7 @@ if (BUILD_HICNPLUGIN AND "${CMAKE_SYSTEM_NAME}" STREQUAL "Linux")
)
set(${LIBHICNCTRL_COMPONENT}-dev_DEB_DEPENDENCIES
- "${LIBHICNCTRL_COMPONENT} (>= stable_version), hicn-plugin-dev (>= stable_version-release), hicn-plugin-dev (<< next_version-release)"
+ "${LIBHICNCTRL_COMPONENT} (>= stable_version), hicn-plugin-dev (>= stable_version)"
CACHE STRING "Dependencies for deb/rpm package."
)
@@ -42,7 +42,7 @@ if (BUILD_HICNPLUGIN AND "${CMAKE_SYSTEM_NAME}" STREQUAL "Linux")
)
set(${LIBHICNCTRL_COMPONENT}-dev_RPM_DEPENDENCIES
- "${LIBHICNCTRL_COMPONENT} >= stable_version, hicn-plugin-dev >= stable_version-release, hicn-plugin-dev < next_version-release"
+ "${LIBHICNCTRL_COMPONENT} >= stable_version, hicn-plugin-dev >= stable_version"
CACHE STRING "Dependencies for deb/rpm package."
)
diff --git a/ctrl/libhicnctrl/includes/hicn/ctrl/api.h b/ctrl/libhicnctrl/includes/hicn/ctrl/api.h
index bdb0c0a5f..f92b39ff3 100644
--- a/ctrl/libhicnctrl/includes/hicn/ctrl/api.h
+++ b/ctrl/libhicnctrl/includes/hicn/ctrl/api.h
@@ -711,7 +711,7 @@ typedef struct {
int family; /* Krw */
ip_address_t remote_addr; /* krw */
u8 len; /* krw */
- policy_t policy; /* .rw */
+ hicn_policy_t policy; /* .rw */
} hc_policy_t;
int hc_policy_parse(void *in, hc_policy_t *policy);
diff --git a/ctrl/libhicnctrl/includes/hicn/ctrl/commands.h b/ctrl/libhicnctrl/includes/hicn/ctrl/commands.h
index d8e5329b3..3758f0f41 100644
--- a/ctrl/libhicnctrl/includes/hicn/ctrl/commands.h
+++ b/ctrl/libhicnctrl/includes/hicn/ctrl/commands.h
@@ -329,14 +329,14 @@ typedef struct {
ip_address_t address;
uint8_t addressType;
uint8_t len;
- policy_t policy;
+ hicn_policy_t policy;
} add_policy_command;
typedef struct {
ip_address_t address;
uint8_t addressType;
uint8_t len;
- policy_t policy;
+ hicn_policy_t policy;
} list_policies_command;
typedef struct {
diff --git a/hicn-light/src/hicn/config/configurationListeners.c b/hicn-light/src/hicn/config/configurationListeners.c
index 21bfe7640..b862b98f4 100644
--- a/hicn-light/src/hicn/config/configurationListeners.c
+++ b/hicn-light/src/hicn/config/configurationListeners.c
@@ -393,10 +393,12 @@ bool _addHicn(Configuration *config, add_listener_command *control,
if (success == true && localAddress != NULL) {
if (logger_IsLoggable(configuration_GetLogger(config),
LoggerFacility_Config, PARCLogLevel_Info)) {
+ char * str = addressToString(localAddress);
logger_Log(configuration_GetLogger(config), LoggerFacility_Config,
PARCLogLevel_Info, __func__,
"Setup hicn listener on address %s",
- addressToString(localAddress));
+ str);
+ parcMemory_Deallocate((void **)&str);
}
}
diff --git a/hicn-light/src/hicn/config/controlAddPolicy.c b/hicn-light/src/hicn/config/controlAddPolicy.c
index 8618c6246..66439d29c 100644
--- a/hicn-light/src/hicn/config/controlAddPolicy.c
+++ b/hicn-light/src/hicn/config/controlAddPolicy.c
@@ -139,7 +139,7 @@ static CommandReturn _controlAddPolicy_Execute(CommandParser *parser,
addPolicyCommand->len = len;
- policy_t policy;
+ hicn_policy_t policy;
snprintf((char*)policy.app_name, APP_NAME_LEN, "%s", (char*)parcList_GetAtIndex(args, 3));
for (int i=4; i < 11; i++) {
const char *tag = parcList_GetAtIndex(args, i);
diff --git a/hicn-light/src/hicn/core/mapme.c b/hicn-light/src/hicn/core/mapme.c
index a22d01ae7..397723a79 100644
--- a/hicn-light/src/hicn/core/mapme.c
+++ b/hicn-light/src/hicn/core/mapme.c
@@ -146,7 +146,7 @@ ERR_MALLOC:
void mapmeTFIB_Release(MapMeTFIB **tfibPtr) {
MapMeTFIB *tfib = *tfibPtr;
- /* TODO; Release all timers */
+ /* TODO; Release all timers: see mapmeTFIB_Remove */
parcHashMap_Release(&tfib->nexthops);
free(tfib);
*tfibPtr = NULL;
@@ -177,9 +177,13 @@ static const PARCEventTimer *mapmeTFIB_Get(const MapMeTFIB *tfib,
const PARCBuffer *buffer;
PARCUnsigned *cid = parcUnsigned_Create(conn_id);
buffer = parcHashMap_Get(tfib->nexthops, cid);
- if (!buffer) return NULL;
+ if (!buffer) {
+ timer = NULL;
+ goto END;
+ }
PARCByteArray *array = parcBuffer_Array(buffer);
timer = *((PARCEventTimer **)parcByteArray_Array(array));
+END:
parcUnsigned_Release(&cid);
return timer;
}
@@ -200,14 +204,37 @@ static void mapmeTFIB_Put(MapMeTFIB *tfib, unsigned conn_id,
parcBuffer_Release(&buffer);
}
-static void mapmeTFIB_Remove(MapMeTFIB *tfib, unsigned conn_id) {
- // Who releases the timer ?
+static void mapmeTFIB_Remove(const MapMe * mapme, MapMeTFIB *tfib, unsigned conn_id) {
PARCUnsigned *cid = parcUnsigned_Create(conn_id);
+
+ /* Release timer */
+ const PARCBuffer *buffer = parcHashMap_Get(tfib->nexthops, cid);
+ if (buffer) {
+ PARCByteArray *array = parcBuffer_Array(buffer);
+ PARCEventTimer * timer = *((PARCEventTimer **)parcByteArray_Array(array));
+ if (timer) {
+ Dispatcher *dispatcher = forwarder_GetDispatcher(mapme->forwarder);
+ dispatcher_DestroyTimerEvent(dispatcher, &timer);
+ }
+ }
+
parcHashMap_Remove(tfib->nexthops, cid);
parcUnsigned_Release(&cid);
}
static PARCIterator *mapmeTFIB_CreateKeyIterator(const MapMeTFIB *tfib) {
+ /*
+ * Creating an iterator on an empty HashMap seems to raise an exception
+ * due to :
+ * parcTrapOutOfMemoryIf(state->listIterator == NULL,
+ * "Cannot create parcLinkedList_CreateIterator");
+ * in : _parcHashMap_Init
+ *
+ * All buckets are empty, as they are after creation, and as they should be,
+ * but the error is triggered.
+ */
+ if (parcHashMap_Size(tfib->nexthops) == 0)
+ return NULL;
return parcHashMap_CreateKeyIterator(tfib->nexthops);
}
@@ -368,7 +395,7 @@ static bool mapme_setFacePending(const MapMe *mapme, const Name *name,
PARCEventTimer *oldTimer = (PARCEventTimer *)mapmeTFIB_Get(TFIB(fibEntry), conn_id);
if (oldTimer)
parcEventTimer_Stop(oldTimer);
- mapmeTFIB_Remove(TFIB(fibEntry), conn_id);
+ mapmeTFIB_Remove(mapme, TFIB(fibEntry), conn_id);
}
numberSet_Release(&conns);
@@ -402,6 +429,7 @@ static bool mapme_setFacePending(const MapMe *mapme, const Name *name,
name_str, params.seq, conn_id);
free(name_str);
connection_ReSend(conn, special_interest, NOT_A_NOTIFICATION);
+ parcMemory_Deallocate((void**)&special_interest);
} else {
INFO(mapme, "[MAP-Me] Stopped retransmissions as face went down");
}
@@ -743,15 +771,18 @@ static bool mapme_onSpecialInterest(const MapMe *mapme,
INFO(mapme, "[MAP-Me] - (1/3) processing prev hops");
if (params->type == UPDATE) {
PARCIterator *iterator = mapmeTFIB_CreateKeyIterator(TFIB(fibEntry));
- while (parcIterator_HasNext(iterator)) {
- PARCUnsigned *cid = parcIterator_Next(iterator);
- unsigned conn_id = parcUnsigned_GetUnsigned(cid);
- INFO(mapme, "[MAP-Me] - Re-sending IU to pending connection %d",
- conn_id);
- mapme_setFacePending(mapme, fibEntry_GetPrefix(fibEntry), fibEntry,
- conn_id, false, false, false, 0);
+ if (iterator) {
+ /* No iterator is created if the TFIB is empty */
+ while (parcIterator_HasNext(iterator)) {
+ PARCUnsigned *cid = parcIterator_Next(iterator);
+ unsigned conn_id = parcUnsigned_GetUnsigned(cid);
+ INFO(mapme, "[MAP-Me] - Re-sending IU to pending connection %d",
+ conn_id);
+ mapme_setFacePending(mapme, fibEntry_GetPrefix(fibEntry), fibEntry,
+ conn_id, false, false, false, 0);
+ }
+ parcIterator_Release(&iterator);
}
- parcIterator_Release(&iterator);
}
/* nextHops -> prevHops
@@ -791,7 +822,7 @@ static bool mapme_onSpecialInterest(const MapMe *mapme,
INFO(mapme, "[MAP-Me] - Canceled pending timer");
parcEventTimer_Stop(oldTimer);
}
- mapmeTFIB_Remove(TFIB(fibEntry), conn_in_id);
+ mapmeTFIB_Remove(mapme, TFIB(fibEntry), conn_in_id);
/* Remove all next hops */
for (size_t k = 0; k < numberSet_Length(nexthops); k++) {
@@ -934,7 +965,7 @@ void mapme_onSpecialInterestAck(const MapMe *mapme, const uint8_t *msgBuffer,
/* Stop timer and remove entry from TFIB */
parcEventTimer_Stop(timer);
- mapmeTFIB_Remove(TFIB(fibEntry), conn_in_id);
+ mapmeTFIB_Remove(mapme, TFIB(fibEntry), conn_in_id);
INFO(mapme, "[MAP-Me] - Removing TFIB entry for ack on connection %d",
conn_in_id);
diff --git a/hicn-light/src/hicn/core/name.c b/hicn-light/src/hicn/core/name.c
index 805e7bfae..b4a5e8d1b 100644
--- a/hicn-light/src/hicn/core/name.c
+++ b/hicn-light/src/hicn/core/name.c
@@ -239,8 +239,9 @@ char *name_ToString(const Name *name) {
Address *packetAddr = nameBitvector_ToAddress(name_GetContentName(name));
- sprintf(output, "name: %s seq: %u", addressToString(packetAddr),
- name->segment);
+ char * address_str = addressToString(packetAddr);
+ sprintf(output, "name: %s seq: %u", address_str, name->segment);
+ parcMemory_Deallocate((void **)&address_str);
addressDestroy(&packetAddr);
diff --git a/hicn-light/src/hicn/core/nameBitvector.c b/hicn-light/src/hicn/core/nameBitvector.c
index 6ad623b14..cc13bf610 100644
--- a/hicn-light/src/hicn/core/nameBitvector.c
+++ b/hicn-light/src/hicn/core/nameBitvector.c
@@ -354,7 +354,9 @@ char *nameBitvector_ToString(const NameBitvector *name) {
Address *packetAddr = nameBitvector_ToAddress(name);
- sprintf(output, "prefix: %s len: %u", addressToString(packetAddr), name->len);
+ char * str = addressToString(packetAddr);
+ sprintf(output, "prefix: %s len: %u", str, name->len);
+ parcMemory_Deallocate((void **)&str);
addressDestroy(&packetAddr);
diff --git a/hicn-light/src/hicn/io/hicnListener.c b/hicn-light/src/hicn/io/hicnListener.c
index bc49f4cee..8647a4d54 100644
--- a/hicn-light/src/hicn/io/hicnListener.c
+++ b/hicn-light/src/hicn/io/hicnListener.c
@@ -216,7 +216,10 @@ static void _hicnListener_readcb(int fd, PARCEventType what, void *listener_void
static bool _isEmptyAddressIPv4(Address *address) {
bool res = false;
- if (strcmp("inet4://0.0.0.0:1234", addressToString(address)) == 0) res = true;
+ char * str = addressToString(address);
+ if (strcmp("inet4://0.0.0.0:1234", str) == 0) res = true;
+ parcMemory_Deallocate((void**)&str);
+
return res;
}
@@ -228,6 +231,7 @@ ListenerOps *hicnListener_CreateInet(Forwarder *forwarder, char *symbolic,
hicn->forwarder = forwarder;
hicn->listenerName = parcMemory_StringDuplicate(symbolic, strlen(symbolic));
+ hicn->logger = logger_Acquire(forwarder_GetLogger(forwarder));
hicn->conn_id = forwarder_GetNextConnectionId(forwarder);
hicn->inetFamily = IPv4;
diff --git a/hicn-light/src/hicn/io/udpListener.c b/hicn-light/src/hicn/io/udpListener.c
index 21b4f6190..16e8c8ddf 100644
--- a/hicn-light/src/hicn/io/udpListener.c
+++ b/hicn-light/src/hicn/io/udpListener.c
@@ -633,6 +633,7 @@ static void _readcb(int fd, PARCEventType what, void * listener_void) {
if(readLength < 0) {
printf("unable to read the message\n");
+ parcMemory_Deallocate(packet);
return;
}
diff --git a/hicn-light/src/hicn/processor/fib.c b/hicn-light/src/hicn/processor/fib.c
index 8822134fe..de0d1e2ef 100644
--- a/hicn-light/src/hicn/processor/fib.c
+++ b/hicn-light/src/hicn/processor/fib.c
@@ -236,6 +236,8 @@ void fib_Add(FIB *fib, FibEntry *entry) {
inner_node ->right = curr;
}
fib->size ++;
+
+ name_Release(&inner_prefix);
}
FibEntry *fib_Contains(const FIB *fib, const Name *prefix) {
@@ -431,6 +433,9 @@ void fib_Remove(FIB *fib, const Name *name, unsigned connId) {
_removeNode(fib, name);
#endif /* WITH_MAPME */
+ // XXX We never release the FIB entry here it seems, including the inner
+ // prefix
+
}
void _removeConnectionId(FibNode *n, unsigned connectionId,
diff --git a/hicn-light/src/hicn/processor/fibEntry.c b/hicn-light/src/hicn/processor/fibEntry.c
index 077e33ff3..7412b4ccf 100644
--- a/hicn-light/src/hicn/processor/fibEntry.c
+++ b/hicn-light/src/hicn/processor/fibEntry.c
@@ -55,7 +55,7 @@ struct fib_entry {
#ifdef WITH_POLICY
NumberSet *nexthops;
const Forwarder * forwarder;
- policy_t policy;
+ hicn_policy_t policy;
policy_counters_t policy_counters;
// NumberSet *available_nexthops;
#ifdef WITH_MAPME
@@ -198,7 +198,7 @@ fibEntry_GetAvailableNextHops(const FibEntry *fibEntry, unsigned in_connection)
ConnectionTable * table = forwarder_GetConnectionTable(fibEntry->forwarder);
NumberSet * nexthops;
bool dealloc_nexthops = false;
- policy_t policy = fibEntry_GetPolicy(fibEntry);
+ hicn_policy_t policy = fibEntry_GetPolicy(fibEntry);
/* Reset available next hops and start filtering */
NumberSet * available_nexthops = numberSet_Create();
@@ -465,11 +465,11 @@ fibEntry_GetAvailableNextHops(const FibEntry *fibEntry, unsigned in_connection)
return priority_nexthops;
}
-policy_t fibEntry_GetPolicy(const FibEntry *fibEntry) {
+hicn_policy_t fibEntry_GetPolicy(const FibEntry *fibEntry) {
return fibEntry->policy;
}
-void fibEntry_SetPolicy(FibEntry *fibEntry, policy_t policy) {
+void fibEntry_SetPolicy(FibEntry *fibEntry, hicn_policy_t policy) {
fibEntry->policy = policy;
mapme_reconsiderFibEntry(forwarder_getMapmeInstance(fibEntry->forwarder), fibEntry);
}
@@ -541,7 +541,7 @@ const NumberSet *fibEntry_GetNexthopsFromForwardingStrategy(
ConnectionTable * table = forwarder_GetConnectionTable(fibEntry->forwarder);
unsigned in_connection = message_GetIngressConnectionId(interestMessage);
- policy_t policy = fibEntry_GetPolicy(fibEntry);
+ hicn_policy_t policy = fibEntry_GetPolicy(fibEntry);
NumberSet * out;
diff --git a/hicn-light/src/hicn/processor/fibEntry.h b/hicn-light/src/hicn/processor/fibEntry.h
index 9e438b0e6..3f78f47dd 100644
--- a/hicn-light/src/hicn/processor/fibEntry.h
+++ b/hicn-light/src/hicn/processor/fibEntry.h
@@ -99,13 +99,6 @@ size_t fibEntry_NexthopCount(const FibEntry *fibEntry);
*/
const NumberSet *fibEntry_GetNexthops(const FibEntry *fibEntry);
-const NumberSet *fibEntry_GetNexthopsFromForwardingStrategy(
-#ifdef WITH_POLICY
- FibEntry *fibEntry, const Message *interestMessage, bool is_retransmission);
-#else
- const FibEntry *fibEntry, const Message *interestMessage);
-#endif /* WITH_POLICY */
-
#ifdef WITH_POLICY
void fibEntry_ReceiveObjectMessage(FibEntry *fibEntry,
#else
@@ -117,9 +110,9 @@ void fibEntry_ReceiveObjectMessage(const FibEntry *fibEntry,
Ticks objReception);
#ifdef WITH_POLICY
-policy_t fibEntry_GetPolicy(const FibEntry *fibEntry);
+hicn_policy_t fibEntry_GetPolicy(const FibEntry *fibEntry);
void fibEntry_ReconsiderPolicy(FibEntry *fibEntry);
-void fibEntry_SetPolicy(FibEntry *fibEntry, policy_t policy);
+void fibEntry_SetPolicy(FibEntry *fibEntry, hicn_policy_t policy);
void fibEntry_UpdateStats(FibEntry *fibEntry, uint64_t now);
NumberSet * fibEntry_GetAvailableNextHops(const FibEntry *fibEntry, unsigned in_connection);
NumberSet * fibEntry_GetPreviousNextHops(const FibEntry *fibEntry);
diff --git a/hicn-light/src/hicn/processor/messageProcessor.c b/hicn-light/src/hicn/processor/messageProcessor.c
index bdd9c23e8..d3f07cbda 100644
--- a/hicn-light/src/hicn/processor/messageProcessor.c
+++ b/hicn-light/src/hicn/processor/messageProcessor.c
@@ -619,6 +619,7 @@ static bool messageProcessor_ForwardViaFib(MessageProcessor *processor,
}
}
+ numberSet_Release(&nexthops);
return false;
}
diff --git a/hicn-light/src/hicn/strategies/loadBalancer.c b/hicn-light/src/hicn/strategies/loadBalancer.c
index 878a58515..bba398b02 100644
--- a/hicn-light/src/hicn/strategies/loadBalancer.c
+++ b/hicn-light/src/hicn/strategies/loadBalancer.c
@@ -355,14 +355,14 @@ static void _strategyLoadBalancer_ImplDestroy(StrategyImpl **strategyPtr) {
parcObject_Release((void **) &state);
}
parcIterator_Release(&it);
+ }
- parcHashMap_Release(&(strategy->strategy_state));
+ parcHashMap_Release(&(strategy->strategy_state));
#ifndef WITH_POLICY
- numberSet_Release(&(strategy->nexthops));
+ numberSet_Release(&(strategy->nexthops));
#endif /* ! WITH_POLICY */
- parcMemory_Deallocate((void **) &strategy);
- parcMemory_Deallocate((void **) &impl);
- *strategyPtr = NULL;
- }
+ parcMemory_Deallocate((void **) &strategy);
+ parcMemory_Deallocate((void **) &impl);
+ *strategyPtr = NULL;
}
diff --git a/hicn-light/src/hicn/utils/commands.h b/hicn-light/src/hicn/utils/commands.h
index d8e5329b3..3758f0f41 100644
--- a/hicn-light/src/hicn/utils/commands.h
+++ b/hicn-light/src/hicn/utils/commands.h
@@ -329,14 +329,14 @@ typedef struct {
ip_address_t address;
uint8_t addressType;
uint8_t len;
- policy_t policy;
+ hicn_policy_t policy;
} add_policy_command;
typedef struct {
ip_address_t address;
uint8_t addressType;
uint8_t len;
- policy_t policy;
+ hicn_policy_t policy;
} list_policies_command;
typedef struct {
diff --git a/hicn-plugin/src/route.c b/hicn-plugin/src/route.c
index b569d431e..6db52f2fd 100644
--- a/hicn-plugin/src/route.c
+++ b/hicn-plugin/src/route.c
@@ -261,6 +261,20 @@ sync_hicn_fib_entry(hicn_dpo_ctx_t *fib_entry)
dpo_id_t temp = DPO_INVALID;
const dpo_id_t *former_dpo = &temp;
int index = 0;
+
+#define ADD_FACE(nh) \
+ do { \
+ /* Careful, this adds a lock on the face if it exists */ \
+ hicn_face_add(dpo, nh, sw_if, &face_id, 0); \
+ vec_validate(vec_faces, index); \
+ vec_faces[index] = face_id; \
+ (index)++; \
+ \
+ /* Face creation can realloc load_balance_t? Seem the fib_tracking does so. */ \
+ dpo_loadbalance = fib_entry_contribute_ip_forwarding (fib_entry->fib_entry_index); \
+ lb0 = load_balance_get(dpo_loadbalance->dpoi_index); \
+ } while (0) \
+
for (int j = 0; j < lb0->lb_n_buckets; j++) {
const dpo_id_t * dpo = load_balance_get_bucket_i(lb0,j);
@@ -282,42 +296,33 @@ sync_hicn_fib_entry(hicn_dpo_ctx_t *fib_entry)
ip_adjacency_t * adj = adj_get (dpo->dpoi_index);
sw_if = adj->rewrite_header.sw_if_index;
nh = get_address (&(adj->sub_type.nbr.next_hop), sw_if, fib_entry->proto);
+ ADD_FACE(nh);
}
else if (dpo->dpoi_type == dpo_type_udp_ip4 || dpo->dpoi_type == dpo_type_udp_ip6)
{
u8 proto = dpo->dpoi_type == dpo_type_udp_ip4 ? FIB_PROTOCOL_IP4 : FIB_PROTOCOL_IP6;
- nh = calloc (1, sizeof(ip46_address_t));
+ ip46_address_t _nh = {0};
+ nh = &_nh;
switch (dpo->dpoi_proto)
{
case FIB_PROTOCOL_IP6:
- nh = calloc (1, sizeof(ip46_address_t));
- ip46_address_set_ip6(nh, &localhost6);
- break;
case FIB_PROTOCOL_IP4:
- nh = calloc (1, sizeof(ip46_address_t));
+ /**
+ * Independently of the type of tunnel, encapsulated packet
+ * can be either v6 or v4, so we need to create 2 faces for each
+ * version. Tunneled hicn packet MUST have locator set to the loopback
+ * address, so ::1 for IPv6 and 127.0.0.1 for IPv4.
+ */
+ ip46_address_set_ip6(nh, &localhost6);
+ ADD_FACE(nh);
ip46_address_set_ip4(nh, &localhost4);
+ ADD_FACE(nh);
break;
default:
- nh = calloc (1, sizeof(ip46_address_t));
+ continue;
}
udp_tunnel_add_existing (dpo->dpoi_index, proto);
}
- else //if (dpo_is_drop(dpo))
- {
- sw_if = dpo_get_urpf(dpo);
- nh = calloc (1, sizeof(ip46_address_t));
- }
-
- /* Careful, this adds a lock on the face if it exists */
- hicn_face_add(dpo, nh, sw_if, &face_id, 0);
-
- vec_validate(vec_faces, index);
- vec_faces[index] = face_id;
- index++;
-
- /* Face creation can realloc load_balance_t? Seem the fib_tracking does so. */
- dpo_loadbalance = fib_entry_contribute_ip_forwarding (fib_entry->fib_entry_index);
- lb0 = load_balance_get(dpo_loadbalance->dpoi_index);
}
const hicn_dpo_vft_t * strategy_vft = hicn_dpo_get_vft(fib_entry->dpo_type);
diff --git a/hicn-plugin/vapi/vapi_safe.c b/hicn-plugin/vapi/vapi_safe.c
index c1d66c0ac..e9353497f 100644
--- a/hicn-plugin/vapi/vapi_safe.c
+++ b/hicn-plugin/vapi/vapi_safe.c
@@ -12,7 +12,7 @@ u32 count = 0;
int lock = 0;
vapi_error_e vapi_connect_safe(vapi_ctx_t *vapi_ctx_ret, int async) {
- vapi_error_e rv = VAPI_OK;
+ vapi_error_e rv = VAPI_OK;
while (!__sync_bool_compare_and_swap(&lock, 0, 1));
@@ -39,7 +39,7 @@ vapi_error_e vapi_connect_safe(vapi_ctx_t *vapi_ctx_ret, int async) {
async ? VAPI_MODE_NONBLOCKING : VAPI_MODE_BLOCKING, true);
if (rv != VAPI_OK)
- goto err_vapi;
+ goto err;
count++;
}
@@ -49,8 +49,6 @@ vapi_error_e vapi_connect_safe(vapi_ctx_t *vapi_ctx_ret, int async) {
while (!__sync_bool_compare_and_swap(&lock, 1, 0));
return rv;
- err_vapi:
- vapi_ctx_free(g_vapi_ctx_instance);
err_mutex_init:
free(mutex);
err_mutex_alloc:
diff --git a/lib/includes/hicn/policy.h b/lib/includes/hicn/policy.h
index 51bab4241..3de34ee68 100644
--- a/lib/includes/hicn/policy.h
+++ b/lib/includes/hicn/policy.h
@@ -217,9 +217,9 @@ typedef struct {
char app_name[APP_NAME_LEN];
policy_tag_state_t tags[POLICY_TAG_N];
policy_stats_t stats;
-} policy_t;
+} hicn_policy_t;
-static const policy_t POLICY_NONE = {
+static const hicn_policy_t POLICY_NONE = {
.app_name = { 0 },
.tags = {
#define _(x, y) [POLICY_TAG_ ## x] = { POLICY_STATE_NEUTRAL, 0 },
@@ -240,7 +240,7 @@ typedef struct {
char ipv4_prefix[INET_ADDRSTRLEN + PFX_STRLEN];
char ipv6_prefix[INET6_ADDRSTRLEN + PFX_STRLEN];
};
- policy_t policy;
+ hicn_policy_t policy;
} policy_description_t;
#endif /* HICN_POLICY_H */
diff --git a/libtransport/CMakeLists.txt b/libtransport/CMakeLists.txt
index 28124b26e..b07c8cccb 100644
--- a/libtransport/CMakeLists.txt
+++ b/libtransport/CMakeLists.txt
@@ -152,7 +152,6 @@ list(APPEND LIBRARIES
${ANDROID_LIBRARIES}
${OPENSSL_LIBRARIES}
${WINDOWS_LIBRARIES}
- ${LIBHICNCTRL_LIBRARIES}
)
# Include dirs -- Order does matter!
diff --git a/libtransport/cmake/Modules/Packaging.cmake b/libtransport/cmake/Modules/Packaging.cmake
index 274eb4c59..e24172661 100644
--- a/libtransport/cmake/Modules/Packaging.cmake
+++ b/libtransport/cmake/Modules/Packaging.cmake
@@ -32,22 +32,22 @@ set(lib${LIBTRANSPORT}-devel_DESCRIPTION ${lib${LIBTRANSPORT}_DESCRIPTION}
if ((BUILD_MEMIF_CONNECTOR OR BUILD_HICNPLUGIN) AND "${CMAKE_SYSTEM_NAME}" STREQUAL "Linux")
set(lib${LIBTRANSPORT}_DEB_DEPENDENCIES
- "lib${LIBHICN} (>= stable_version), libparc (>= 1.0), libmemif (>= stable_version), vpp (>= stable_version-release), vpp (<< next_version-release), libhicnctrl-memif (>= stable_version-release), libhicnctrl-memif (<< next_version-release)"
+ "lib${LIBHICN} (>= stable_version), libparc (>= 1.0), libmemif (>= stable_version), vpp (>= stable_version-release), vpp (<< next_version-release), hicn-plugin (>= stable_version)"
CACHE STRING "Dependencies for deb/rpm package."
)
set(lib${LIBTRANSPORT}_RPM_DEPENDENCIES
- "lib${LIBHICN} >= stable_version, libparc >= 1.0, libmemif >= stable_version, vpp >= stable_version-release, vpp < next_version-release, libhicnctrl-memif >= stable_version-release, libhicnctrl-memif < stable_version-release"
+ "lib${LIBHICN} >= stable_version, libparc >= 1.0, libmemif >= stable_version, vpp >= stable_version-release, vpp < next_version-release, hicn-plugin >= stable_version"
CACHE STRING "Dependencies for deb/rpm package."
)
set(lib${LIBTRANSPORT}-dev_DEB_DEPENDENCIES
- "lib${LIBTRANSPORT} (>= stable_version), libasio-dev (>= 1.10), libhicn-dev (>= stable_version), libmemif-dev (>= stable_version), libparc-dev (>= 1.0), vpp-dev (>= stable_version-release), vpp-dev (<< next_version-release), hicn-plugin-dev (>= stable_version-release), hicn-plugin-dev (<< next_version-release)"
+ "lib${LIBTRANSPORT} (>= stable_version), libasio-dev (>= 1.10), libhicn-dev (>= stable_version), libmemif-dev (>= stable_version), libparc-dev (>= 1.0), vpp-dev (>= stable_version-release), vpp-dev (<< next_version-release), hicn-plugin-dev (>= stable_version)"
CACHE STRING "Dependencies for deb/rpm package."
)
set(lib${LIBTRANSPORT}-dev_RPM_DEPENDENCIES
- "lib${LIBTRANSPORT} >= stable_version, asio-devel >= 1.10, lib${LIBHICN}-devel >= stable_version, libmemif-devel >= stable_version, libparc-devel >= 1.0, vpp-devel >= stable_version-release, vpp-devel < next_version-release, hicn-plugin-dev >= stable_version-release, hicn-plugin-dev < next_version-release"
+ "lib${LIBTRANSPORT} >= stable_version, asio-devel >= 1.10, lib${LIBHICN}-devel >= stable_version, libmemif-devel >= stable_version, libparc-devel >= 1.0, vpp-devel >= stable_version-release, vpp-devel < next_version-release, hicn-plugin-dev >= stable_version"
CACHE STRING "Dependencies for deb/rpm package."
)
diff --git a/libtransport/src/core/forwarder_interface.h b/libtransport/src/core/forwarder_interface.h
index 772cfbb52..a94414d38 100644
--- a/libtransport/src/core/forwarder_interface.h
+++ b/libtransport/src/core/forwarder_interface.h
@@ -49,7 +49,10 @@ class ForwarderInterface {
inet6_address_({}),
mtu_(1500),
output_interface_(""),
- content_store_reserved_(standard_cs_reserved) {}
+ content_store_reserved_(standard_cs_reserved) {
+ inet_address_.v4.as_u32 = htonl(0x7f00001);
+ inet6_address_.v6.as_u8[15] = 0x01;
+ }
public:
virtual ~ForwarderInterface() {}
diff --git a/libtransport/src/core/memif_connector.cc b/libtransport/src/core/memif_connector.cc
index 553aab42a..087e8cba8 100644
--- a/libtransport/src/core/memif_connector.cc
+++ b/libtransport/src/core/memif_connector.cc
@@ -267,6 +267,7 @@ int MemifConnector::bufferAlloc(long n, uint16_t qid) {
if (TRANSPORT_EXPECT_FALSE(err != MEMIF_ERR_SUCCESS)) {
TRANSPORT_LOGE("memif_buffer_alloc: %s", memif_strerror(err));
+ return -1;
}
c->tx_buf_num += r;
@@ -441,7 +442,7 @@ void MemifConnector::send(const Packet::MemBufPtr &packet) {
int MemifConnector::doSend() {
std::size_t max = 0;
- uint16_t n = 0;
+ int32_t n = 0;
std::size_t size = 0;
{
@@ -451,9 +452,9 @@ int MemifConnector::doSend() {
do {
max = size < MAX_MEMIF_BUFS ? size : MAX_MEMIF_BUFS;
+ n = bufferAlloc(max, memif_connection_->tx_qid);
- if (TRANSPORT_EXPECT_FALSE(
- (n = bufferAlloc(max, memif_connection_->tx_qid)) < 0)) {
+ if (TRANSPORT_EXPECT_FALSE(n < 0)) {
TRANSPORT_LOGE("Error allocating buffers.");
return -1;
}
diff --git a/libtransport/src/core/memif_connector.h b/libtransport/src/core/memif_connector.h
index 693efd14c..8a0e9efad 100644
--- a/libtransport/src/core/memif_connector.h
+++ b/libtransport/src/core/memif_connector.h
@@ -15,11 +15,10 @@
#pragma once
+#include <core/connector.h>
#include <hicn/transport/config.h>
#include <hicn/transport/portability/portability.h>
#include <hicn/transport/utils/ring_buffer.h>
-
-#include <core/connector.h>
//#include <hicn/transport/core/hicn_vapi.h>
#include <utils/epoll_event_reactor.h>
#include <utils/fd_deadline_timer.h>
@@ -43,7 +42,7 @@ typedef struct memif_connection memif_connection_t;
#define IF_NAME "vpp_connection"
#define MEMIF_BUF_SIZE 2048
-#define MEMIF_LOG2_RING_SIZE 11
+#define MEMIF_LOG2_RING_SIZE 13
#define MAX_MEMIF_BUFS (1 << MEMIF_LOG2_RING_SIZE)
class MemifConnector : public Connector {
diff --git a/libtransport/src/core/vpp_forwarder_interface.cc b/libtransport/src/core/vpp_forwarder_interface.cc
index 28a2560b3..9f7beeb37 100644
--- a/libtransport/src/core/vpp_forwarder_interface.cc
+++ b/libtransport/src/core/vpp_forwarder_interface.cc
@@ -36,8 +36,6 @@ namespace transport {
namespace core {
-std::mutex VPPForwarderInterface::global_lock_;
-
VPPForwarderInterface::VPPForwarderInterface(MemifConnector &connector)
: ForwarderInterface<VPPForwarderInterface, MemifConnector>(connector),
sw_if_index_(~0),
@@ -112,9 +110,24 @@ void VPPForwarderInterface::producerConnection() {
}
void VPPForwarderInterface::connect(bool is_consumer) {
- std::lock_guard<std::mutex> connection_lock(global_lock_);
+ int retry = 20;
+
+ TRANSPORT_LOGI("Connecting to VPP through vapi.");
+ vapi_error_e ret = vapi_connect_safe(&sock_, 0);
+
+ while (ret != VAPI_OK && retry > 0) {
+ TRANSPORT_LOGE("Error connecting to VPP through vapi. Retrying..");
+ --retry;
+ ret = vapi_connect_safe(&sock_, 0);
+ }
+
+ if (ret != VAPI_OK) {
+ throw std::runtime_error(
+ "Impossible to connect to forwarder. Is VPP running?");
+ }
+
- vapi_connect_safe(&sock_, 0);
+ TRANSPORT_LOGI("Connected to VPP through vapi.");
sw_if_index_ = getMemifConfiguration();
diff --git a/libtransport/src/core/vpp_forwarder_interface.h b/libtransport/src/core/vpp_forwarder_interface.h
index bc83f476e..31d23b40d 100644
--- a/libtransport/src/core/vpp_forwarder_interface.h
+++ b/libtransport/src/core/vpp_forwarder_interface.h
@@ -79,7 +79,6 @@ class VPPForwarderInterface
uint32_t face_id2_;
bool is_consumer_;
vapi_ctx_t sock_;
- static std::mutex global_lock_;
};
} // namespace core
diff --git a/libtransport/src/http/response.cc b/libtransport/src/http/response.cc
index 79550898b..c665fbc5f 100644
--- a/libtransport/src/http/response.cc
+++ b/libtransport/src/http/response.cc
@@ -98,7 +98,10 @@ std::size_t HTTPResponse::parseHeaders(const uint8_t *buffer, std::size_t size,
value_start++;
}
if (value_start < line.size()) {
- headers[line.substr(0, param_end)] =
+ auto header = line.substr(0, param_end);
+ std::transform(header.begin(), header.end(), header.begin(),
+ [](unsigned char c) { return std::tolower(c); });
+ headers[header] =
line.substr(value_start, line.size() - value_start - 1);
}
}
diff --git a/libtransport/src/utils/epoll_event_reactor.cc b/libtransport/src/utils/epoll_event_reactor.cc
index 0e6590d0e..63c08df95 100644
--- a/libtransport/src/utils/epoll_event_reactor.cc
+++ b/libtransport/src/utils/epoll_event_reactor.cc
@@ -104,12 +104,15 @@ void EpollEventReactor::runEventLoop(int timeout) {
while (run_event_loop_) {
memset(&evt, 0, sizeof(evt));
-
en = epoll_pwait(epoll_fd_, evt, 128, timeout, &sigset);
if (TRANSPORT_EXPECT_FALSE(en < 0)) {
TRANSPORT_LOGE("epoll_pwait: %s", strerror(errno));
- return;
+ if (errno == EINTR) {
+ continue;
+ } else {
+ return;
+ }
}
for (int i = 0; i < en; i++) {
diff --git a/telemetry/vpp-collectd/CMakeLists.txt b/telemetry/vpp-collectd/CMakeLists.txt
index ef09fb980..8f82745f2 100644
--- a/telemetry/vpp-collectd/CMakeLists.txt
+++ b/telemetry/vpp-collectd/CMakeLists.txt
@@ -13,7 +13,7 @@
cmake_minimum_required(VERSION 3.5 FATAL_ERROR)
-set (COLLECTD_PLUGINS hicn-collectd-plugins)
+set(COLLECTD_PLUGINS hicn-collectd-plugins)
project(hicn-collectd-plugins)
set(CMAKE_MODULE_PATH ${CMAKE_MODULE_PATH} "${CMAKE_CURRENT_SOURCE_DIR}/cmake/Modules/" "${CMAKE_CURRENT_SOURCE_DIR}/../../cmake/Modules/")
diff --git a/telemetry/vpp-collectd/vpp-hicn/CMakeLists.txt b/telemetry/vpp-collectd/vpp-hicn/CMakeLists.txt
index fc39b9385..3703515dc 100644
--- a/telemetry/vpp-collectd/vpp-hicn/CMakeLists.txt
+++ b/telemetry/vpp-collectd/vpp-hicn/CMakeLists.txt
@@ -18,7 +18,7 @@ find_package(Collectd REQUIRED)
find_package(Vpp REQUIRED)
if(${CMAKE_SOURCE_DIR}/vpp-collectd STREQUAL ${PROJECT_SOURCE_DIR})
- message (STATUS "not compiling in the same folder")
+ message (STATUS "not compiling in the same folder")
find_package(HicnPlugin REQUIRED)
find_package(VapiSafe REQUIRED)
else()
@@ -29,17 +29,16 @@ else()
endif()
list(APPEND SOURCE_FILES
- ${CMAKE_CURRENT_SOURCE_DIR}/vpp_hicn.c
-)
+ ${CMAKE_CURRENT_SOURCE_DIR}/vpp_hicn.c)
-list (APPEND INCLUDE_DIRS
+list(APPEND INCLUDE_DIRS
${COLLECTD_INCLUDE_DIRS}
${HICNPLUGIN_INCLUDE_DIRS}
${SAFE_VAPI_INCLUDE_DIRS}
${VPP_INCLUDE_DIRS}
${CMAKE_CURRENT_SOURCE_DIR})
-list (APPEND LIBRARIES
+list(APPEND LIBRARIES
${VPP_LIBRARY_VAPICLIENT}
${SAFE_VAPI_LIBRARIES})
diff --git a/telemetry/vpp-collectd/vpp-hicn/vpp_hicn.c b/telemetry/vpp-collectd/vpp-hicn/vpp_hicn.c
index 591b8f584..4228ac6e6 100644
--- a/telemetry/vpp-collectd/vpp-hicn/vpp_hicn.c
+++ b/telemetry/vpp-collectd/vpp-hicn/vpp_hicn.c
@@ -13,25 +13,9 @@
* limitations under the License.
*/
-#if !HAVE_CONFIG_H
-#include <stdlib.h>
-#include <string.h>
-
-#ifndef __USE_ISOC99 /* required for NAN */
-#define DISABLE_ISOC99 1
-#define __USE_ISOC99 1
-#endif /* !defined(__USE_ISOC99) */
-
-#if DISABLE_ISOC99
-#undef DISABLE_ISOC99
-#undef __USE_ISOC99
-#endif /* DISABLE_ISOC99 */
-#endif /* ! HAVE_CONFIG */
-
/* Keep order as it is */
#include <config.h>
#include <collectd.h>
-#include <common.h>
#include <plugin.h>
#define counter_t vpp_counter_t
@@ -42,6 +26,15 @@
DEFINE_VAPI_MSG_IDS_HICN_API_JSON
vapi_ctx_t vapi_ctx;
+#define STATIC_ARRAY_SIZE(a) (sizeof(a) / sizeof(*(a)))
+
+#define IS_TRUE(s) \
+ ((strcasecmp("true", (s)) == 0) || (strcasecmp("yes", (s)) == 0) || \
+ (strcasecmp("on", (s)) == 0))
+#define IS_FALSE(s) \
+ ((strcasecmp("false", (s)) == 0) || (strcasecmp("no", (s)) == 0) || \
+ (strcasecmp("off", (s)) == 0))
+
/************** OPTIONS ***********************************/
static const char *config_keys[2] = {
"Verbose",
@@ -188,6 +181,11 @@ static data_set_t dtx_ds = {
/**********************************************************/
/********** UTILITY FUNCTIONS *****************************/
/**********************************************************/
+char *sstrncpy(char *dest, const char *src, size_t n) {
+ strncpy(dest, src, n);
+ dest[n - 1] = '\0';
+ return dest;
+}
/*
* Utility function used by the read callback to populate a
diff --git a/telemetry/vpp-collectd/vpp/CMakeLists.txt b/telemetry/vpp-collectd/vpp/CMakeLists.txt
index 36248b17a..464ab42d8 100644
--- a/telemetry/vpp-collectd/vpp/CMakeLists.txt
+++ b/telemetry/vpp-collectd/vpp/CMakeLists.txt
@@ -14,22 +14,20 @@
cmake_minimum_required(VERSION 3.5 FATAL_ERROR)
# Dependencies
-
-list(APPEND SOURCE_FILES
- ${CMAKE_CURRENT_SOURCE_DIR}/vpp.c
-)
-
find_package(Vpp REQUIRED)
find_package(Collectd REQUIRED)
-list (APPEND INCLUDE_DIRS
- ${COLLECTD_INCLUDE_DIRS}
- ${VPP_INCLUDE_DIRS}
- ${CMAKE_CURRENT_SOURCE_DIR})
+list(APPEND SOURCE_FILES
+ ${CMAKE_CURRENT_SOURCE_DIR}/vpp.c)
+
+list(APPEND INCLUDE_DIRS
+ ${COLLECTD_INCLUDE_DIRS}
+ ${VPP_INCLUDE_DIRS}
+ ${CMAKE_CURRENT_SOURCE_DIR})
-list (APPEND LIBRARIES
- ${VPP_LIBRARY_VPPAPICLIENT}
- ${VPP_LIBRARY_INFRA})
+list(APPEND LIBRARIES
+ ${VPP_LIBRARY_VPPAPICLIENT}
+ ${VPP_LIBRARY_INFRA})
build_library(vpp
SHARED
diff --git a/telemetry/vpp-collectd/vpp/vpp.c b/telemetry/vpp-collectd/vpp/vpp.c
index ba838a050..8bf5182a8 100644
--- a/telemetry/vpp-collectd/vpp/vpp.c
+++ b/telemetry/vpp-collectd/vpp/vpp.c
@@ -13,25 +13,9 @@
* limitations under the License.
*/
-#if !HAVE_CONFIG_H
-#include <stdlib.h>
-#include <string.h>
-
-#ifndef __USE_ISOC99 /* required for NAN */
-#define DISABLE_ISOC99 1
-#define __USE_ISOC99 1
-#endif /* !defined(__USE_ISOC99) */
-
-#if DISABLE_ISOC99
-#undef DISABLE_ISOC99
-#undef __USE_ISOC99
-#endif /* DISABLE_ISOC99 */
-#endif /* ! HAVE_CONFIG */
-
/* Keep order as it is */
#include <config.h>
#include <collectd.h>
-#include <common.h>
#include <plugin.h>
#define counter_t vpp_counter_t
@@ -39,6 +23,15 @@
#include <vppinfra/vec.h>
#undef counter_t
+#define STATIC_ARRAY_SIZE(a) (sizeof(a) / sizeof(*(a)))
+
+#define IS_TRUE(s) \
+ ((strcasecmp("true", (s)) == 0) || (strcasecmp("yes", (s)) == 0) || \
+ (strcasecmp("on", (s)) == 0))
+#define IS_FALSE(s) \
+ ((strcasecmp("false", (s)) == 0) || (strcasecmp("no", (s)) == 0) || \
+ (strcasecmp("off", (s)) == 0))
+
/************** OPTIONS ***********************************/
static const char *config_keys[2] = {
"Verbose",
@@ -164,6 +157,11 @@ static data_set_t if_tx_broadcast_ds = {
/**********************************************************/
/********** UTILITY FUNCTIONS *****************************/
/**********************************************************/
+char *sstrncpy(char *dest, const char *src, size_t n) {
+ strncpy(dest, src, n);
+ dest[n - 1] = '\0';
+ return dest;
+}
/*
* Utility function used by the read callback to populate a
@@ -327,8 +325,7 @@ static int vpp_read(void) {
}
value_t values[1] = {
- (value_t){.derive = res[i].simple_counter_vec[k][j]}
- };
+ (value_t){.derive = res[i].simple_counter_vec[k][j]}};
err = submit(interfaces[j], data_set.type, values, 1, &timestamp);
diff --git a/utils/src/hiperf.cc b/utils/src/hiperf.cc
index 967241250..f4764e096 100644
--- a/utils/src/hiperf.cc
+++ b/utils/src/hiperf.cc
@@ -217,7 +217,7 @@ class HIperfClient {
: configuration_(conf),
total_duration_milliseconds_(0),
old_bytes_value_(0),
- signals_(io_service_, SIGINT),
+ signals_(io_service_),
expected_seg_(0),
lost_packets_(std::unordered_set<uint32_t>()),
rtc_callback_(configuration_.rtc_ ? new RTCCallback(*this) : nullptr),
@@ -514,6 +514,7 @@ class HIperfClient {
int run() {
std::cout << "Starting download of " << configuration_.name << std::endl;
+ signals_.add(SIGINT);
signals_.async_wait([this](const std::error_code &, const int &) {
consumer_socket_->stop();
io_service_.stop();
@@ -712,7 +713,7 @@ class HIperfServer {
public:
HIperfServer(ServerConfiguration &conf)
: configuration_(conf),
- signals_(io_service_, SIGINT),
+ signals_(io_service_),
rtc_timer_(io_service_),
unsatisfied_interests_(),
content_objects_((std::uint16_t)(1 << log2_content_object_buffer_size)),
@@ -1023,6 +1024,7 @@ class HIperfServer {
int run() {
std::cerr << "Starting to serve consumers" << std::endl;
+ signals_.add(SIGINT);
signals_.async_wait([this](const std::error_code &, const int &) {
std::cout << "STOPPING!!" << std::endl;
producer_socket_->stop();