diff options
-rw-r--r-- | hicn-light/CMakeLists.txt | 5 | ||||
-rw-r--r-- | hicn-light/src/CMakeLists.txt | 36 | ||||
-rw-r--r-- | hicn-light/src/command_line/daemon/hicnLightDaemon_main.c | 7 | ||||
-rw-r--r-- | hicn-light/src/config/configuration.c | 6 | ||||
-rw-r--r-- | hicn-light/src/config/configurationListeners.c | 13 | ||||
-rw-r--r-- | hicn-light/src/core/forwarder.c | 5 |
6 files changed, 45 insertions, 27 deletions
diff --git a/hicn-light/CMakeLists.txt b/hicn-light/CMakeLists.txt index 7df740b4c..0d9e4d261 100644 --- a/hicn-light/CMakeLists.txt +++ b/hicn-light/CMakeLists.txt @@ -16,6 +16,8 @@ set(CMAKE_MODULE_PATH set(CMAKE_C_STANDARD 11) set(CMAKE_C_STANDARD_REQUIRED ON) +option(ENABLE_PUNTING "Enable punting on linux systems" ON) + include( CTest ) include( detectCacheSize ) @@ -24,10 +26,11 @@ if(NOT WIN32) else () set(CMAKE_C_FLAGS "${CMAKE_C_FLAGS} /wd4996") endif () + if(ANDROID_API) message("############ Detected cross compile for $ENV{CMAKE_SYSTEM_NAME}") set(CMAKE_C_FLAGS "${CMAKE_C_FLAGS} ${ANDROID_C_FLAGS}") - endif() +endif() set(CMAKE_C_FLAGS_RELEASE "${CMAKE_C_FLAGS_RELEASE} -DLIBRTA_DISABLE_VALIDATION -DPARCLibrary_DISABLE_VALIDATION") diff --git a/hicn-light/src/CMakeLists.txt b/hicn-light/src/CMakeLists.txt index 1951d00f7..851b961c7 100644 --- a/hicn-light/src/CMakeLists.txt +++ b/hicn-light/src/CMakeLists.txt @@ -4,7 +4,7 @@ include(BuildMacros) configure_file(config.h.in config.h @ONLY) if(NOT ANDROID_API AND NOT COMPILE_FOR_IOS) - add_subdirectory(command_line) + add_subdirectory(command_line) endif () add_subdirectory(config) @@ -19,27 +19,35 @@ add_subdirectory(strategies) add_subdirectory(utils) list(APPEND HEADER_FILES - ${CMAKE_CURRENT_BINARY_DIR}/config.h + ${CMAKE_CURRENT_BINARY_DIR}/config.h ) -set(COMPILER_DEFINITIONS "-DWITH_MAPME -DWITH_MAPME_FIXES") +if("${CMAKE_SYSTEM_NAME}" STREQUAL "Linux" AND ENABLE_PUNTING) + list(APPEND COMPILER_DEFINITIONS + "-DPUNTING" + ) +endif() + +list(APPEND COMPILER_DEFINITIONS + "-DWITH_MAPME -DWITH_MAPME_FIXES" +) list(APPEND HICN_LIGHT_INCLUDE_DIRS - ${CMAKE_CURRENT_SOURCE_DIR}/.. + ${CMAKE_CURRENT_SOURCE_DIR}/.. ) if (INSTALL_HEADER) - set(TO_INSTALL_HEADERS ${HEADER_FILES}) + set(TO_INSTALL_HEADERS ${HEADER_FILES}) endif() build_library(${LIBHICN_LIGHT} - STATIC - SOURCES ${SOURCE_FILES} - INSTALL_HEADERS ${TO_INSTALL_HEADERS} - LINK_LIBRARIES ${LIBRARIES} - DEPENDS ${DEPENDENCIES} - COMPONENT ${LIBHICN_LIGHT} - INCLUDE_DIRS ${HICN_LIGHT_INCLUDE_DIRS} - INSTALL_ROOT_DIR hicn/hicn-light - DEFINITIONS ${COMPILER_DEFINITIONS} + STATIC + SOURCES ${SOURCE_FILES} + INSTALL_HEADERS ${TO_INSTALL_HEADERS} + LINK_LIBRARIES ${LIBRARIES} + DEPENDS ${DEPENDENCIES} + COMPONENT ${LIBHICN_LIGHT} + INCLUDE_DIRS ${HICN_LIGHT_INCLUDE_DIRS} + INSTALL_ROOT_DIR hicn/hicn-light + DEFINITIONS ${COMPILER_DEFINITIONS} ) diff --git a/hicn-light/src/command_line/daemon/hicnLightDaemon_main.c b/hicn-light/src/command_line/daemon/hicnLightDaemon_main.c index ce8c373ca..9a6c352fb 100644 --- a/hicn-light/src/command_line/daemon/hicnLightDaemon_main.c +++ b/hicn-light/src/command_line/daemon/hicnLightDaemon_main.c @@ -365,6 +365,13 @@ int main(int argc, const char *argv[]) { // this will update the clock to the tick clock Forwarder *forwarder = forwarder_Create(logger); + if (forwarder == NULL) { + logger_Log(logger, LoggerFacility_Core, PARCLogLevel_Error, "daemon", + "Forwarder initialization failed. Are you running it with sudo " + "privileges?"); + return -1; + } + Configuration *configuration = forwarder_GetConfiguration(forwarder); if (capacity > -1) { diff --git a/hicn-light/src/config/configuration.c b/hicn-light/src/config/configuration.c index 865dbca4d..48c26b4a2 100644 --- a/hicn-light/src/config/configuration.c +++ b/hicn-light/src/config/configuration.c @@ -310,8 +310,8 @@ static void configuration_SendResponse(Configuration *config, struct iovec *msg, } connection_SendCommandResponse(conn, msg); - //IoOperations *ops = connection_GetIoOperations(conn); - //streamState_SendCommandResponse(ops, msg); + // IoOperations *ops = connection_GetIoOperations(conn); + // streamState_SendCommandResponse(ops, msg); } struct iovec *configuration_ProcessCreateTunnel(Configuration *config, @@ -370,7 +370,7 @@ struct iovec *configuration_ProcessCreateTunnel(Configuration *config, logger_Log(config->logger, LoggerFacility_Config, PARCLogLevel_Error, __func__, "Unsupported tunnel protocol: GRE"); break; -#if !defined(__APPLE__) && !defined(_WIN32) +#if !defined(__APPLE__) && !defined(_WIN32) && defined(PUNTING) case HICN_CONN: ops = hicnTunnel_Create(config->forwarder, source, destination); break; diff --git a/hicn-light/src/config/configurationListeners.c b/hicn-light/src/config/configurationListeners.c index 6539e8c9f..3024d7bba 100644 --- a/hicn-light/src/config/configurationListeners.c +++ b/hicn-light/src/config/configurationListeners.c @@ -42,7 +42,7 @@ static bool _setupHicnListenerOnInet4(Forwarder *forwarder, const char *symbolic, Address *address) { bool success = false; -#if !defined(__APPLE__) && !defined(_WIN32) +#if !defined(__APPLE__) && !defined(_WIN32) && defined(PUNTING) ListenerOps *ops = hicnListener_CreateInet(forwarder, (char *)symbolic, address); if (ops != NULL) { @@ -57,7 +57,7 @@ static bool _setupHicnListenerOnInet4(Forwarder *forwarder, static bool _setupHicnListenerOnInet6(Forwarder *forwarder, const char *symbolic, Address *address) { bool success = false; -#if !defined(__APPLE__) && !defined(_WIN32) +#if !defined(__APPLE__) && !defined(_WIN32) && defined(PUNTING) ListenerOps *ops = hicnListener_CreateInet6(forwarder, (char *)symbolic, address); if (ops != NULL) { @@ -81,7 +81,7 @@ bool configurationListeners_Remove(const Configuration *config) { bool _AddPuntingInet(const Configuration *config, Punting *punting, unsigned ingressId) { -#if !defined(__APPLE__) && !defined(_WIN32) +#if !defined(__APPLE__) && !defined(_WIN32) && defined(PUNTING) struct sockaddr *addr = parcNetwork_SockAddress("0.0.0.0", 1234); if (addr == NULL) { printf("Error creating address\n"); @@ -141,7 +141,7 @@ bool _AddPuntingInet(const Configuration *config, Punting *punting, bool _AddPuntingInet6(const Configuration *config, Punting *punting, unsigned ingressId) { -#if !defined(__APPLE__) && !defined(_WIN32) +#if !defined(__APPLE__) && !defined(_WIN32) && defined(PUNTING) struct sockaddr *addr = parcNetwork_SockAddress("0::0", 1234); if (addr == NULL) { printf("Error creating address\n"); @@ -231,7 +231,6 @@ static bool _setupTcpListenerOnInet(Forwarder *forwarder, ipv4_addr_t *addr4, static bool _setupUdpListenerOnInet(Forwarder *forwarder, ipv4_addr_t *addr4, uint16_t *port) { - bool success = false; struct sockaddr_in addr; @@ -537,6 +536,6 @@ void configurationListeners_SetutpLocalIPv4(const Configuration *config, uint16_t port) { Forwarder *forwarder = configuration_GetForwarder(config); in_addr_t addr = inet_addr("127.0.0.1"); - _setupUdpListenerOnInet(forwarder, (ipv4_addr_t *) &(addr), &port); - _setupTcpListenerOnInet(forwarder, (ipv4_addr_t *) &(addr), &port); + _setupUdpListenerOnInet(forwarder, (ipv4_addr_t *)&(addr), &port); + _setupTcpListenerOnInet(forwarder, (ipv4_addr_t *)&(addr), &port); } diff --git a/hicn-light/src/core/forwarder.c b/hicn-light/src/core/forwarder.c index 2b00a35e5..a7d151314 100644 --- a/hicn-light/src/core/forwarder.c +++ b/hicn-light/src/core/forwarder.c @@ -197,7 +197,7 @@ Forwarder *forwarder_Create(Logger *logger) { dispatcher_StartSignalEvent(forwarder->dispatcher, forwarder->signal_usr1); #endif -#if !defined(__APPLE__) && !defined(_WIN32) +#if !defined(__APPLE__) && !defined(_WIN32) && defined(PUNTING) forwarder->hicnSocketHelper = hicn_create(); if (forwarder->hicnSocketHelper == NULL) return NULL; #endif /* __APPLE__ */ @@ -237,7 +237,8 @@ void forwarder_Destroy(Forwarder **ptr) { parcAssertNotNull(ptr, "Parameter must be non-null double pointer"); parcAssertNotNull(*ptr, "Parameter must dereference to non-null pointer"); Forwarder *forwarder = *ptr; -#if !defined(__APPLE__) && !defined(__ANDROID__) && !defined(_WIN32) +#if !defined(__APPLE__) && !defined(__ANDROID__) && !defined(_WIN32) && \ + defined(PUNTING) hicn_destroy(); #endif parcEventTimer_Destroy(&(forwarder->keepalive_event)); |