diff options
-rw-r--r-- | apps/CMakeLists.txt | 1 | ||||
-rw-r--r-- | cmake/Modules/License.txt | 12 | ||||
-rw-r--r-- | cmake/Modules/Packager.cmake | 108 | ||||
-rw-r--r-- | cmake/Modules/PostInstall.cmake | 83 | ||||
-rw-r--r-- | ctrl/facemgr/CMakeLists.txt | 14 | ||||
-rw-r--r-- | ctrl/facemgr/cmake/Modules/Packaging.cmake | 15 | ||||
-rw-r--r-- | ctrl/facemgr/config/facemgr.conf | 194 | ||||
-rw-r--r-- | ctrl/facemgr/config/facemgr.service | 24 | ||||
-rwxr-xr-x | ctrl/facemgr/config/post | 5 | ||||
-rwxr-xr-x | ctrl/facemgr/config/postinst | 3 | ||||
-rwxr-xr-x | ctrl/facemgr/config/prerm | 3 | ||||
-rwxr-xr-x | ctrl/facemgr/config/preun | 3 | ||||
-rw-r--r-- | ctrl/facemgr/examples/mobility/Makefile | 23 | ||||
-rw-r--r-- | ctrl/facemgr/examples/mobility/mobility.c | 88 | ||||
-rw-r--r-- | ctrl/facemgr/src/CMakeLists.txt | 2 | ||||
-rw-r--r-- | hicn-light/CMakeLists.txt | 2 | ||||
-rw-r--r-- | lib/includes/CMakeLists.txt | 2 | ||||
-rw-r--r-- | libtransport/CMakeLists.txt | 1 |
18 files changed, 581 insertions, 2 deletions
diff --git a/apps/CMakeLists.txt b/apps/CMakeLists.txt index 9b9011800..37e44f9e7 100644 --- a/apps/CMakeLists.txt +++ b/apps/CMakeLists.txt @@ -61,6 +61,7 @@ list(APPEND LIBRARIES ${CMAKE_THREAD_LIBS_INIT} ) +set(APPS_LIBRARY_LIST "${OPENSSL_LIBRARIES};${CMAKE_THREAD_LIBS_INIT}" CACHE INTERNAL "APPS_LIBRARY_LIST") if (WIN32) set(CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS} /wd4200 /wd4996") endif () diff --git a/cmake/Modules/License.txt b/cmake/Modules/License.txt new file mode 100644 index 000000000..4d84c0dc7 --- /dev/null +++ b/cmake/Modules/License.txt @@ -0,0 +1,12 @@ +Copyright (c) 2017-2021 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.
\ No newline at end of file diff --git a/cmake/Modules/Packager.cmake b/cmake/Modules/Packager.cmake index 7aad1d7b0..b414f7169 100644 --- a/cmake/Modules/Packager.cmake +++ b/cmake/Modules/Packager.cmake @@ -52,7 +52,6 @@ macro(extract_version) if (NOT VER) set(VER "v1.2-0-gcafe") endif() - message(STATUS "Git describe output: ${VER}") string(REGEX REPLACE "v([0-9]+).([0-9]+)-?(.*)?-([0-9]+)-(g[0-9a-f]+)" "\\1;\\2;\\3;\\4;\\5;" VER ${VER}) @@ -93,7 +92,6 @@ function(make_packages) else() set(bld "b$ENV{BUILD_NUMBER}") endif() - message(STATUS "Build number is: ${bld}") #define DEB and RPM version numbers @@ -225,5 +223,111 @@ function(make_packages) set(CPACK_PACKAGE_CONTACT ${CONTACT}) include(CPack) endif() + elseif(${CMAKE_SYSTEM_NAME} MATCHES "Darwin" OR ${CMAKE_SYSTEM_NAME} MATCHES "Windows") + set(CMAKE_SKIP_BUILD_RPATH FALSE) + set(CMAKE_BUILD_WITH_INSTALL_RPATH TRUE) + set(CMAKE_INSTALL_RPATH /opt/hicn) + + set(CMAKE_INSTALL_RPATH_USE_LINK_PATH TRUE) + + set(CPACK_SET_DESTDIR true) + + set(CMAKE_INSTALL_RPATH "\${CPACK_INSTALL_PREFIX}") + set(CMAKE_SKIP_INSTALL_RPATH FALSE) + set(HICN_DEPENDECIES_INSTALLER "${LIBTRANSPORT_LIBRARIES_LIST};${FACEMGR_LIBRARY_LIST};${APPS_LIBRARY_LIST}") + separate_arguments(HICN_DEPENDECIES_INSTALLER) + foreach (HICN_DEPENDECY ${HICN_DEPENDECIES_INSTALLER}) + get_filename_component(DEPENDENCY_NAME "${HICN_DEPENDECY}" NAME) + get_filename_component(DEPENDENCY "${HICN_DEPENDECY}" REALPATH) + get_filename_component(DEPENDENCY_PATH "${DEPENDENCY}" DIRECTORY) + install(FILES ${DEPENDENCY} DESTINATION lib COMPONENT dependencies) + endforeach() + set(CPACK_PACKAGE_NAME "hicn") + extract_version() + set(CPACK_PACKAGE_VENDOR "${PACKAGE_VENDOR}") + set(CPACK_PACKAGE_DESCRIPTION_SUMMARY "hICN") + set(CPACK_PACKAGE_VERSION "${VERSION_MAJOR}.${VERSION_MINOR}.${VERSION_REVISION}") + set(CPACK_PACKAGE_VERSION_MAJOR "${VERSION_MAJOR}") + set(CPACK_PACKAGE_VERSION_MINOR "${VERSION_MINOR}") + set(CPACK_PACKAGE_VERSION_PATCH "${VERSION_REVISION}") + set(CPACK_PACKAGE_INSTALL_DIRECTORY "hICN Components") + + set(CPACK_COMPONENTS_ALL dependencies ${HICN_UTILS} ${HICN_LIGHT} ${HICN_APPS} ${FACEMGR} lib${LIBTRANSPORT} ${LIBTRANSPORT}-dev lib${LIBHICN} ${LIBHICN}-dev ${HICN_UTILS}-dev ${HICN_LIGHT}-dev ${HICN_APPS}-dev ${FACEMGR}-dev) + set(CPACK_COMPONENT_DEPENDENCIES_DISPLAY_NAME "Dependencies") + string(TOUPPER ${HICN_UTILS} HICN_UTILS_UPPERCASE) + string(TOUPPER ${HICN_LIGHT} HICN_LIGHT_UPPERCASE) + string(TOUPPER ${HICN_APPS} HICN_APPS_UPPERCASE) + string(TOUPPER ${FACEMGR} FACEMGR_UPPERCASE) + + string(TOUPPER lib${LIBTRANSPORT} LIBTRANSPORT_UPPERCASE) + string(TOUPPER ${LIBTRANSPORT}-dev LIBTRANSPORT_DEV_UPPERCASE) + string(TOUPPER lib${LIBHICN} LIBHICN_UPPERCASE) + string(TOUPPER ${LIBHICN}-dev LIBHICN_DEV_UPPERCASE) + string(TOUPPER ${HICN_UTILS}-dev HICN_UTILS_DEV_UPPERCASE) + string(TOUPPER ${HICN_LIGHT}-dev HICN_LIGHT_DEV_UPPERCASE) + string(TOUPPER ${HICN_APPS}-dev HICN_APPS_DEV_UPPERCASE) + string(TOUPPER ${FACEMGR}-dev FACEMGR_DEV_UPPERCASE) + + set(CPACK_COMPONENT_${HICN_UTILS_UPPERCASE}_DISPLAY_NAME "hICN utils") + set(CPACK_COMPONENT_${HICN_LIGHT_UPPERCASE}_DISPLAY_NAME "hICN light apps") + set(CPACK_COMPONENT_${HICN_APPS_UPPERCASE}_DISPLAY_NAME "hICN apps") + set(CPACK_COMPONENT_${FACEMGR_UPPERCASE}_DISPLAY_NAME "facemgr") + set(CPACK_COMPONENT_${LIBTRANSPORT_UPPERCASE}_DISPLAY_NAME "libtransport libs") + set(CPACK_COMPONENT_${LIBHICN_UPPERCASE}_DISPLAY_NAME "hicn libs") + set(CPACK_COMPONENT_${LIBTRANSPORT_DEV_UPPERCASE}_DISPLAY_NAME "libtransport headers") + set(CPACK_COMPONENT_${LIBHICN_DEV_UPPERCASE}_DISPLAY_NAME "hicn headers") + set(CPACK_COMPONENT_${HICN_UTILS_DEV_UPPERCASE}_DISPLAY_NAME "hicn utils headers") + set(CPACK_COMPONENT_${HICN_LIGHT_DEV_UPPERCASE}_DISPLAY_NAME "hicn-light headers") + set(CPACK_COMPONENT_${HICN_APPS_DEV_UPPERCASE}_DISPLAY_NAME "hicn-apps headers") + set(CPACK_COMPONENT_${FACEMGR_DEV_UPPERCASE}_DISPLAY_NAME "facemgr headers") + set (CPACK_RESOURCE_FILE_LICENSE + "${PROJECT_SOURCE_DIR}/cmake/Modules/License.txt") + set(CPACK_COMPONENT_DEPENDENCIES_DESCRIPTION + "All dependency libreries") + + set(CPACK_COMPONENT_${HICN_UTILS_UPPERCASE}_GROUP "Executables") + set(CPACK_COMPONENT_${HICN_LIGHT_UPPERCASE}_GROUP "Executables") + set(CPACK_COMPONENT_${HICN_APPS_UPPERCASE}_GROUP "Executables") + set(CPACK_COMPONENT_${FACEMGR_UPPERCASE}_GROUP "Executables") + + set(CPACK_COMPONENT_${LIBTRANSPORT_UPPERCASE}_GROUP "Libraries") + set(CPACK_COMPONENT_${LIBHICN_UPPERCASE}_GROUP "Libraries") + set(CPACK_COMPONENT_${LIBTRANSPORT_DEV_UPPERCASE}_GROUP "Headers") + set(CPACK_COMPONENT_${LIBHICN_DEV_UPPERCASE}_GROUP "Headers") + set(CPACK_COMPONENT_${HICN_UTILS_DEV_UPPERCASE}_GROUP "Headers") + set(CPACK_COMPONENT_${HICN_LIGHT_DEV_UPPERCASE}_GROUP "Headers") + set(CPACK_COMPONENT_${HICN_APPS_DEV_UPPERCASE}_GROUP "Headers") + set(CPACK_COMPONENT_${FACEMGR_DEV_UPPERCASE}_GROUP "Headers") + set(CPACK_COMPONENT_DEPENDENCIES_GROUP "Dependencies") + + + set(CPACK_COMPONENT_GROUP_DEVELOPMENT_EXPANDED ON) + set(CPACK_COMPONENT_GROUP_DEPENDENCIES_DESCRIPTION + "All dependency libreries") + set(CPACK_ALL_INSTALL_TYPES Full Developer) + set(CPACK_INSTALL_TYPE_FULL_DISPLAY_NAME "Everything") + set(CPACK_COMPONENT_${HICN_UTILS_UPPERCASE}_INSTALL_TYPES Full) + set(CPACK_COMPONENT_${HICN_LIGHT_UPPERCASE}_INSTALL_TYPES Full) + set(CPACK_COMPONENT_${HICN_APPS_UPPERCASE}_INSTALL_TYPES Full) + set(CPACK_COMPONENT_${FACEMGR_UPPERCASE}_INSTALL_TYPES Full) + set(CPACK_COMPONENT_${LIBTRANSPORT_UPPERCASE}_INSTALL_TYPES Full) + set(CPACK_COMPONENT_${LIBHICN_UPPERCASE}_INSTALL_TYPES Full) + set(CPACK_COMPONENT_${LIBTRANSPORT_DEV_UPPERCASE}_INSTALL_TYPES Full) + set(CPACK_COMPONENT_${LIBHICN_DEV_UPPERCASE}_INSTALL_TYPES Full) + set(CPACK_COMPONENT_${HICN_UTILS_DEV_UPPERCASE}_INSTALL_TYPES Full) + set(CPACK_COMPONENT_${HICN_LIGHT_DEV_UPPERCASE}_INSTALL_TYPES Full) + set(CPACK_COMPONENT_${HICN_APPS_DEV_UPPERCASE}_INSTALL_TYPES Full) + set(CPACK_COMPONENT_${FACEMGR_DEV_UPPERCASE}_INSTALL_TYPES Full) + + if (${CMAKE_SYSTEM_NAME} MATCHES "Darwin") + set(CMAKE_INSTALL_RPATH /opt/hicn) + + set(CPACK_INSTALL_PREFIX "/opt/hicn") + set(CPACK_GENERATOR productbuild) + set( CPACK_PRE_BUILD_SCRIPTS "${PROJECT_SOURCE_DIR}/cmake/Modules/PostInstall.cmake") + else() + set(CPACK_INSTALL_PREFIX "c:/Program Files/hicn") + endif() + include(CPack) endif() endfunction() diff --git a/cmake/Modules/PostInstall.cmake b/cmake/Modules/PostInstall.cmake new file mode 100644 index 000000000..89c7b9f68 --- /dev/null +++ b/cmake/Modules/PostInstall.cmake @@ -0,0 +1,83 @@ +function(change_rpath LIB_PATH TYPE) + execute_process ( + COMMAND bash -c "ls ${LIB_PATH}" + OUTPUT_VARIABLE ITEMS + ) + string(REPLACE "\n" ";" ITEMS ${ITEMS}) + + separate_arguments(ITEMS) + foreach (ITEM ${ITEMS}) + if (NOT ITEM MATCHES ".a$") + if (TYPE STREQUAL "LIB") + execute_process ( + COMMAND bash -c "otool -L ${LIB_PATH}/${ITEM} | head -2 | tail -1| sed -e 's/^[[:space:]]*//'|awk '{print $1;}'" + OUTPUT_VARIABLE OTOOL_OUTPUT + ) + string(REPLACE "\n" "" OTOOL_OUTPUT ${OTOOL_OUTPUT}) + + execute_process ( + COMMAND bash -c "basename ${OTOOL_OUTPUT}| sed -e 's/^[[:space:]]*//'" + OUTPUT_VARIABLE BASENAME + ) + string(REPLACE "\n" "" BASENAME ${BASENAME}) + execute_process ( + COMMAND bash -c "install_name_tool -id ${CPACK_INSTALL_PREFIX}/${BASENAME} ${LIB_PATH}/${ITEM}" + OUTPUT_VARIABLE OUTPUT_INSTALL_NAME_TOOL + ) + #change rpath + execute_process ( + COMMAND bash -c "otool -L ${LIB_PATH}/${ITEM} | tail -n +3| sed -e 's/^[[:space:]]*//'|awk '{print $1;}'" + OUTPUT_VARIABLE OTOOL_OUTPUTS + ) + else () + #change rpath + execute_process ( + COMMAND bash -c "otool -L ${LIB_PATH}/${ITEM} | tail -n +2| sed -e 's/^[[:space:]]*//'|awk '{print $1;}'" + OUTPUT_VARIABLE OTOOL_OUTPUTS + ) + endif () + string(REPLACE "\n" ";" OTOOL_OUTPUTS ${OTOOL_OUTPUTS}) + separate_arguments(OTOOL_OUTPUTS) + foreach (OTOOL_OUTPUT ${OTOOL_OUTPUTS}) + execute_process ( + COMMAND bash -c "basename ${OTOOL_OUTPUT}| sed -e 's/^[[:space:]]*//'" + OUTPUT_VARIABLE BASENAME + ) + string(REPLACE "\n" "" BASENAME ${BASENAME}) + execute_process ( + COMMAND bash -c "dirname ${OTOOL_OUTPUT}| sed -e 's/^[[:space:]]*//'" + OUTPUT_VARIABLE DIRNAME + ) + string(REPLACE "\n" "" DIRNAME ${DIRNAME}) + if(NOT DIRNAME MATCHES "/usr/lib") + execute_process ( + COMMAND bash -c "install_name_tool -change ${OTOOL_OUTPUT} ${CPACK_INSTALL_PREFIX}/${BASENAME} ${LIB_PATH}/${ITEM}" + OUTPUT_VARIABLE OUTPUT_INSTALL_NAME_TOOL + ) + endif() + + endforeach() + endif() + endforeach() +endfunction() +string(TOLOWER ${CPACK_COMPONENT_DEPENDENCIES_GROUP} CPACK_COMPONENT_DEPENDENCIES_GROUP ) +set(LIB_PATH "${CPACK_TEMPORARY_DIRECTORY}/${CPACK_COMPONENT_DEPENDENCIES_GROUP}${CPACK_INSTALL_PREFIX}/lib") +change_rpath(${LIB_PATH} LIB) + +set(LIB_PATH "${CPACK_TEMPORARY_DIRECTORY}/facemgr${CPACK_INSTALL_PREFIX}/lib") +change_rpath(${LIB_PATH} LIB) +set(LIB_PATH "${CPACK_TEMPORARY_DIRECTORY}/libhicntransport${CPACK_INSTALL_PREFIX}/lib") +change_rpath(${LIB_PATH} LIB) +set(LIB_PATH "${CPACK_TEMPORARY_DIRECTORY}/libhicn${CPACK_INSTALL_PREFIX}/lib") +change_rpath(${LIB_PATH} LIB) + +set(EXE_PATH "${CPACK_TEMPORARY_DIRECTORY}/hicn-utils${CPACK_INSTALL_PREFIX}/bin") +change_rpath(${EXE_PATH} EXE) +set(EXE_PATH "${CPACK_TEMPORARY_DIRECTORY}/hicn-light${CPACK_INSTALL_PREFIX}/bin") +change_rpath(${EXE_PATH} EXE) +set(EXE_PATH "${CPACK_TEMPORARY_DIRECTORY}/hicn-apps${CPACK_INSTALL_PREFIX}/bin") +change_rpath(${EXE_PATH} EXE) +set(EXE_PATH "${CPACK_TEMPORARY_DIRECTORY}/facemgr${CPACK_INSTALL_PREFIX}/bin") +change_rpath(${EXE_PATH} EXE) +#set(EXE_PATH "${CPACK_TEMPORARY_DIRECTORY}/hicnctrl${CPACK_INSTALL_PREFIX}/bin") +#change_rpath(${EXE_PATH} EXE) diff --git a/ctrl/facemgr/CMakeLists.txt b/ctrl/facemgr/CMakeLists.txt index 290f96fa0..ba9de9464 100644 --- a/ctrl/facemgr/CMakeLists.txt +++ b/ctrl/facemgr/CMakeLists.txt @@ -94,6 +94,20 @@ add_subdirectory(src) include(Packaging) +# Install service file in linux systems +include(ServiceScript) +install_service_script( + ${CMAKE_CURRENT_SOURCE_DIR}/config/facemgr.service + COMPONENT ${FACEMGR} +) + +# Configuration file +set(FACEMGR_CONF_FILE ${CMAKE_CURRENT_SOURCE_DIR}/config/facemgr.conf) +set(FACEMGR_CONF_FOLDER "/etc/facemgr") +if (${CMAKE_SYSTEM_NAME} STREQUAL "Linux") + install (FILES ${FACEMGR_CONF_FILE} DESTINATION ${FACEMGR_CONF_FOLDER} COMPONENT ${FACEMGR}) +endif() + if(CMAKE_SOURCE_DIR STREQUAL PROJECT_SOURCE_DIR) include(Packager) make_packages() diff --git a/ctrl/facemgr/cmake/Modules/Packaging.cmake b/ctrl/facemgr/cmake/Modules/Packaging.cmake index 3a7e5a85c..bb4fa42fa 100644 --- a/ctrl/facemgr/cmake/Modules/Packaging.cmake +++ b/ctrl/facemgr/cmake/Modules/Packaging.cmake @@ -25,7 +25,22 @@ set(${FACEMGR}_DEB_DEPENDENCIES CACHE STRING "Dependencies for deb/rpm package." ) +set(${HICN_LIGHT}_DEB_PACKAGE_CONTROL_EXTRA + "${CMAKE_CURRENT_SOURCE_DIR}/config/postinst;${CMAKE_CURRENT_SOURCE_DIR}/config/prerm" + CACHE STRING "Control scripts conffiles, postinst, postrm, prerm." +) + set(${FACEMGR}_RPM_DEPENDENCIES "libconfig, libevent-devel, lib${LIBHICNCTRL} >= stable_version" CACHE STRING "Dependencies for deb/rpm package." ) + +set(${HICN_LIGHT}_RPM_POST_INSTALL_SCRIPT_FILE + "${CMAKE_CURRENT_SOURCE_DIR}/config/post" + CACHE STRING "Install script that will be copied in the %post section" +) + +set(${HICN_LIGHT}_RPM_PRE_UNINSTALL_SCRIPT_FILE + "${CMAKE_CURRENT_SOURCE_DIR}/config/preun" + CACHE STRING "Install script that will be copied in the %post section" +) diff --git a/ctrl/facemgr/config/facemgr.conf b/ctrl/facemgr/config/facemgr.conf new file mode 100644 index 000000000..d9c6f5fa9 --- /dev/null +++ b/ctrl/facemgr/config/facemgr.conf @@ -0,0 +1,194 @@ +# +# hICN facemgr configuration file +# + +################################################################################ +# Global settings +################################################################################ + +global = { + +# Default type for face creation +# +# Values: "auto" | "native-udp" | "native-tcp" | "overlay-udp" | "overlay-tcp" +# Default "auto" +# +#face_type = "auto"; +face_type = "overlay-udp" + +# Disable service discovery for overlay creation +# +# This is only meaningful for overlay_* face types. If service discovery is +# disabled, only manually entered overlay information will be used, if any. +# Otherwise, no face will be created. +# +# Values : true | false +# Default: false +# +#disable_discovery = true; + +# Disable IPv4 face creation +# +# Values : true | false +# Default: false +# +#disable_ipv4 = true; + +# Disable IPv6 face creation +# +# Values : true | false +# Default: false +# +#disable_ipv6 = true; + +# overlay +# +# By default, no address is specified, and local and remote ports are set to +# the standard value for hICN (9695). +# + +}; + +################################################################################ +# Per-interface rules +################################################################################ +# +# Rules allow to override the default behaviour of the face manager. +# +# The list of rules must be specified as follows (note that the last one has no +# coma at the end) : +# +# rules = ( +# { ... }, +# { ... }, +# { ... } +# ); +# +# A rule is composed of match and override attributes, and has the following +# syntax: +# +# { +# match = { +# interface_name = STRING; +# interface_type = STRING; +# }; +# override = { +# face_type = STRING; +# disable_discovery = BOOL; +# ignore = BOOL; +# tags = (STRING, STRING, STRING); +# overlay = { +# ipv4 = { +# local_port = PORT; +# remote_addr = IP_ADDRESS; +# remote_port = PORT; +# }; +# ipv6 = { +# local_port = PORT; +# remote_addr = IP_ADDRESS; +# remote_port = PORT; +# }; +# }; +# }; +# } +# +# Match attributes: +# +# Match attributes serve to identify rules and as such defining two rules with +# similar matches is not allowed. However, overlapping match definitions are +# possible, in which case only the first matching rule is considered. +# +# A match is composed of the name of an interface and/or its type (either +# attribute is optional but at least one has to be specified). +# +# * interface_name - a string representing an interface name +# +# * interface_type - the type of interface to match +# +# Values: "wired" | "wifi" | "cellular" +# +# Override attributes: +# +# Those attributes are applied when all specified match attributes correspond, +# and override general settings or default values. +# +# * face_type - type used for face creation +# +# Values: "auto" | "native_udp" | "native_tcp" | "overlay_udp" | "overlay_tcp" +# +# * disable_discovery - disable service discovery for overlay creation +# +# Values : true | false +# +# * ignore - a boolean indicating whether that interface should be ignored +# +# * TODO tags - a (possibly empty) list of tags to be associated to the created face. +# +# Values: "wired" | "wifi" | "cellular" | "trusted" +# +# * overlay +# +# An overlay specification is used to complement any information retrieved +# through service discovery (or replace it if service discovery is +# disabled). +# +# It is possible to specify values for IPv4, IPv6 or both. +# +# Note that it is not currently possible to set different settings for IPv4 and +# IPv6 but overlay specifications. +# +# +# Here are a few example of rule definitions: +# +# rules = ( +# # Ignore localhost interface +# { +# match = { +# interface_name = "lo"; +# }; +# override = { +# ignore = true; +# }; +# }, +# # Set tags for unknown tunnnel interface +# { +# match = { +# interface_name = "utun1"; +# }; +# override = { +# tags = ("WIRED", "TRUSTED"); +# }; +# }, +# # Force cellular connections to use manually specified overlay faces +# { +# match = { +# interface_type = "cellular", +# }; +# override = { +# overlay = { +# ipv4 = { +# local_port = 9695; +# remote_addr = "10.60.16.14"; +# remote_port = 9695; +# }; +# ipv6 = { +# local_port = 9695; +# remote_addr = "2001:420:44f1:10:20c:29ff:fef3:8f8f"; +# remote_port = 9695; +# }; +# }; +# }; +# } +# ); +# +#rules = ( +#); + +################################################################################ +# Logging +################################################################################ + +log: +{ + log_level = "DEBUG"; +} diff --git a/ctrl/facemgr/config/facemgr.service b/ctrl/facemgr/config/facemgr.service new file mode 100644 index 000000000..0f9e818ea --- /dev/null +++ b/ctrl/facemgr/config/facemgr.service @@ -0,0 +1,24 @@ +# 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. + +[Unit] +Description=hICN face manager + +[Service] +Environment=CONFIG=/etc/facemgr/facemgr.conf +Environment=LOGFILE=/var/log/facemgr.log +ExecStart=/usr/bin/facemgr -c ${CONFIG} 1>${LOGFILE} 2>&1 +Restart=on-failure + +[Install] +WantedBy=multi-user.target diff --git a/ctrl/facemgr/config/post b/ctrl/facemgr/config/post new file mode 100755 index 000000000..7b2fd57fe --- /dev/null +++ b/ctrl/facemgr/config/post @@ -0,0 +1,5 @@ +#!/bin/bash + +if pidof systemd; then + systemctl enable facemgr +fi diff --git a/ctrl/facemgr/config/postinst b/ctrl/facemgr/config/postinst new file mode 100755 index 000000000..4113b0eca --- /dev/null +++ b/ctrl/facemgr/config/postinst @@ -0,0 +1,3 @@ +#!/bin/bash + +systemctl enable facemgr diff --git a/ctrl/facemgr/config/prerm b/ctrl/facemgr/config/prerm new file mode 100755 index 000000000..b5c486ea5 --- /dev/null +++ b/ctrl/facemgr/config/prerm @@ -0,0 +1,3 @@ +#!/bin/bash + +systemctl disable facemgr diff --git a/ctrl/facemgr/config/preun b/ctrl/facemgr/config/preun new file mode 100755 index 000000000..b5c486ea5 --- /dev/null +++ b/ctrl/facemgr/config/preun @@ -0,0 +1,3 @@ +#!/bin/bash + +systemctl disable facemgr diff --git a/ctrl/facemgr/examples/mobility/Makefile b/ctrl/facemgr/examples/mobility/Makefile new file mode 100644 index 000000000..3b92d9d5f --- /dev/null +++ b/ctrl/facemgr/examples/mobility/Makefile @@ -0,0 +1,23 @@ +EXEC = $(shell basename $$(pwd)) +CC = gcc + +CFLAGS = -std=gnu11 -O3 -Wall -Wextra -Wpedantic -Wstrict-aliasing + +SRC = $(wildcard *.c) +OBJ = $(SRC:.c=.o) + +all: $(EXEC) + +${EXEC}: $(OBJ) + $(CC) -o $@ $^ $(LDFLAGS) + +%.o: %.c + $(CC) -o $@ -c $< $(CFLAGS) + +.PHONY: clean mrproper + +clean: + @rm -rf *.o + +mrproper: clean + @rm -rf $(EXEC) diff --git a/ctrl/facemgr/examples/mobility/mobility.c b/ctrl/facemgr/examples/mobility/mobility.c new file mode 100644 index 000000000..528951446 --- /dev/null +++ b/ctrl/facemgr/examples/mobility/mobility.c @@ -0,0 +1,88 @@ +/* + * Dummy server sending alternating bytes to all clients. + * + * This program can be used to trigger mobility events in the hICN forwarder, to + * switch from WiFi to LTE and back, at regular intervals. + * + * Test server using nc: nc -4kvul localhost 9533 + */ + +#include <arpa/inet.h> // inet_ntop +#include <errno.h> // EINTR,. .. +#include <netinet/in.h> // INET_ADDRSTRLEN, INET6_ADDRSTRLEN +#include <stdio.h> +#include <inttypes.h> + +#include <stdlib.h> +#include <sys/socket.h> +#include <sys/timerfd.h> +#include <sys/un.h> // sockaddr_un +#include <unistd.h> // fcntl +#include <fcntl.h> // fcntl + +#define MS2US(x) (x * 1000) + +/** + * \brief Main function + */ +int main(int argc, char **argv) +{ + int rc; + + if (argc != 4) { + fprintf(stderr, "Usage: %s IP PORT INTERVAL\n", argv[0]); + fprintf(stderr, "\n"); + fprintf(stderr, " IP Target hostname\n"); + fprintf(stderr, " PORT Target port\n"); + fprintf(stderr, " INTERVAL Interval between mobility events (in ms)\n"); + fprintf(stderr, "\n"); + exit(EXIT_FAILURE); + } + + int interval = atoi(argv[3]); + + int fd = socket(AF_INET, SOCK_DGRAM, IPPROTO_UDP); + if (fd < 0) { + perror("socket"); + goto ERR_SOCKET; + } + + struct sockaddr_in addr; + memset(&addr, 0, sizeof(addr)); + addr.sin_family = AF_INET; + addr.sin_addr.s_addr = inet_addr(argv[1]); + addr.sin_port = htons(atoi(argv[2])); + + if (connect(fd, (struct sockaddr*)&addr, sizeof(addr)) < 0) { + perror("connect"); + goto ERR_CONNECT; + } + + unsigned state = 0; + char buf[1]; + for(;;) { + usleep(MS2US(interval)); + + buf[0] = state; + rc = send(fd, buf, 1, 0); + if (rc < 0) { + if (errno == ECONNREFUSED) { + continue; + } + perror("send"); + goto ERR_SEND; + } + + state = 1 - state; + } + + close(fd); + + exit(EXIT_SUCCESS); + +ERR_SEND: +ERR_CONNECT: + close(fd); +ERR_SOCKET: + exit(EXIT_FAILURE); +} diff --git a/ctrl/facemgr/src/CMakeLists.txt b/ctrl/facemgr/src/CMakeLists.txt index 3650ef4f5..cf5606e04 100644 --- a/ctrl/facemgr/src/CMakeLists.txt +++ b/ctrl/facemgr/src/CMakeLists.txt @@ -68,6 +68,8 @@ set(LIBRARIES ${LIBEVENT_LIBRARY} ) +set(FACEMGR_LIBRARY_LIST "${LIBCONFIG_LIBRARIES};${LIBEVENT_LIBRARY}" CACHE INTERNAL "FACEMGR_LIBRARY_LIST") + add_subdirectory(interfaces) diff --git a/hicn-light/CMakeLists.txt b/hicn-light/CMakeLists.txt index db56feff7..c9a536dd6 100644 --- a/hicn-light/CMakeLists.txt +++ b/hicn-light/CMakeLists.txt @@ -91,6 +91,8 @@ set(HICN_LIGHT_LINK_LIBRARIES ${WINDOWS_LIBRARIES} ) +set(HICN_LIGHT_LIBRARIES_LIST "${LIBPARC_LIBRARIES};${CMAKE_THREAD_LIBS_INIT};${WINDOWS_LIBRARIES}" CACHE INTERNAL "HICN_LIGHT_LIBRARIES_LIST") + # Include dirs -- Order does matter! list(APPEND HICN_LIGHT_INCLUDE_DIRS diff --git a/lib/includes/CMakeLists.txt b/lib/includes/CMakeLists.txt index 12529bd57..6c2c34b86 100644 --- a/lib/includes/CMakeLists.txt +++ b/lib/includes/CMakeLists.txt @@ -54,3 +54,5 @@ set(LIBHICN_HEADER_FILES_UTIL PARENT_SCOPE ) +set_property(GLOBAL PROPERTY LIBHICN_HEADER_FILES_UTIL_PROPERTY "${LIBHICN_HEADER_FILES_UTIL}") + diff --git a/libtransport/CMakeLists.txt b/libtransport/CMakeLists.txt index 9d2b9069f..d94f2859b 100644 --- a/libtransport/CMakeLists.txt +++ b/libtransport/CMakeLists.txt @@ -105,6 +105,7 @@ list(APPEND LIBRARIES ${LIBCONFIG_CPP_LIBRARIES} ) +set(LIBTRANSPORT_LIBRARIES_LIST "${LIBPARC_LIBRARIES};${CMAKE_THREAD_LIBS_INIT};${VPP_LIBRARIES};${ANDROID_LIBRARIES};${OPENSSL_LIBRARIES};${WINDOWS_LIBRARIES};${LIBCONFIG_CPP_LIBRARIES}" CACHE INTERNAL "LIBTRANSPORT_LIBRARIES_LIST") # Include dirs -- Order does matter! list(APPEND LIBTRANSPORT_INTERNAL_INCLUDE_DIRS |