summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorLutz Bichler <Lutz.Bichler@bmw.de>2020-06-29 15:14:50 +0200
committerLutz Bichler <Lutz.Bichler@bmw.de>2020-06-29 15:14:50 +0200
commit3ccf1c682d31e453d356e4b902d8aebce3f376a1 (patch)
tree728e38e268a23f6157753a1a004bf7f66bec081f
parentc78c92307c4908ed286042def6fdae86f9a04b70 (diff)
downloadvSomeIP-3ccf1c682d31e453d356e4b902d8aebce3f376a1.tar.gz
vsomeip 3.1.15.13.1.15.1
-rw-r--r--CHANGES21
-rw-r--r--CMakeLists.txt70
-rw-r--r--README.md8
-rw-r--r--examples/hello_world/CMakeLists.txt42
-rw-r--r--examples/hello_world/hello_world_client.hpp (renamed from examples/hello_world/hello_world_client.cpp)49
-rw-r--r--examples/hello_world/hello_world_client_main.cpp37
-rw-r--r--examples/hello_world/hello_world_service.hpp (renamed from examples/hello_world/hello_world_service.cpp)45
-rw-r--r--examples/hello_world/hello_world_service_main.cpp37
-rw-r--r--examples/hello_world/readme_android15
-rw-r--r--implementation/configuration/include/configuration.hpp15
-rw-r--r--implementation/configuration/include/configuration_impl.hpp11
-rw-r--r--implementation/configuration/include/internal_android.hpp7
-rw-r--r--implementation/configuration/src/configuration_impl.cpp80
-rw-r--r--implementation/endpoints/include/tp.hpp2
-rw-r--r--implementation/endpoints/src/tp.cpp2
-rw-r--r--implementation/logger/src/message.cpp20
-rw-r--r--implementation/routing/src/routing_manager_impl.cpp2
-rw-r--r--implementation/service_discovery/src/service_discovery_impl.cpp21
-rw-r--r--interface/vsomeip/primitive_types.hpp1
19 files changed, 341 insertions, 144 deletions
diff --git a/CHANGES b/CHANGES
index eae9b13..436544f 100644
--- a/CHANGES
+++ b/CHANGES
@@ -1,22 +1,11 @@
Changes
=======
-v3.1.14.1
-- Merged extended support for static routing (versioning)
- (by Jean-Patrice Laude <jean-patrice.laude@renault.com>)
-- Merged simplification of build process for hello_world example
- (by Nikolay Khilyuk <nkh@ua.fm>)
-- Updated Android.bp to use boost 1.70.0 or higher
-- Merged Android support for hello_world example
- (by Nikolay Khilyuk <nkh@ua.fm>)
-- Align response sample to documentation (do not specify application name)
- (by JayHou <houjie@lixiang.com>)
-- Call dlerror before calling dlsym to clear previous error.
- (by Oleg Kharitonov <Oleg.Kharitonov@elektrobit.com>)
-- Get base path from environment variable for Android NDK.
- (by Nikolay Khilyuk <nkh@ua.fm>)
-- Fixed wrong library naming
- (by Nikolay Khilyuk <nkh@ua.fm>)
+v3.1.15
+- Ensure to remove the correct subscription object on unsubscribe
+- Implemented support to define "secure services"
+- Speedup security policy handling
+- Enable building with boost v1.73.0
v3.1.14
- Fixed race conditions (application registration, subscription)
diff --git a/CMakeLists.txt b/CMakeLists.txt
index 7b5eabf..c36f1f6 100644
--- a/CMakeLists.txt
+++ b/CMakeLists.txt
@@ -11,9 +11,10 @@ set (VSOMEIP_COMPAT_NAME vsomeip)
set (VSOMEIP_MAJOR_VERSION 3)
set (VSOMEIP_MINOR_VERSION 1)
-set (VSOMEIP_PATCH_VERSION 14)
+set (VSOMEIP_PATCH_VERSION 15)
set (VSOMEIP_HOTFIX_VERSION 1)
+
set (VSOMEIP_VERSION ${VSOMEIP_MAJOR_VERSION}.${VSOMEIP_MINOR_VERSION}.${VSOMEIP_PATCH_VERSION})
set (PACKAGE_VERSION ${VSOMEIP_VERSION}) # Used in documentation/doxygen.in
set (CMAKE_VERBOSE_MAKEFILE off)
@@ -71,6 +72,17 @@ if (${CMAKE_SYSTEM_NAME} MATCHES "Linux")
set(OS_CXX_FLAGS "-D_GLIBCXX_USE_NANOSLEEP -pthread -O -Wall -Wextra -Wformat -Wformat-security -Wconversion -fexceptions -fstrict-aliasing -fstack-protector-strong -fasynchronous-unwind-tables -fno-omit-frame-pointer -D_FORTIFY_SOURCE=2 -Wformat -Wformat-security -Werror=format-security -fPIE -pie -Wl,-z,relro,-z,now")
endif (${CMAKE_SYSTEM_NAME} MATCHES "Linux")
+if (${CMAKE_SYSTEM_NAME} MATCHES "Android")
+ set(OS "ANDROID")
+ set(DL_LIBRARY "")
+ set(EXPORTSYMBOLS "")
+ set(NO_DEPRECATED "")
+ set(OPTIMIZE "")
+
+ find_library(ANDROID_LOG_LIB log)
+ set(OS_LIBS ${ANDROID_LOG_LIB})
+endif(${CMAKE_SYSTEM_NAME} MATCHES "Android")
+
if (${CMAKE_SYSTEM_NAME} MATCHES "FreeBSD")
set(OS "FREEBSD")
set(DL_LIBRARY "")
@@ -132,7 +144,13 @@ endif ()
find_package(Threads REQUIRED)
# Boost
-find_package( Boost 1.55 COMPONENTS system thread filesystem REQUIRED )
+if (${CMAKE_SYSTEM_NAME} MATCHES "Android")
+ # Please implement your macro workaround to set Boost_ variables, because NDK does not have Boost libs package
+ # Example of macro implementation you can find in test project that mentioned in examples/hello_world/readme_android
+ ndk_find_package_boost(system thread filesystem)
+else()
+ find_package( Boost 1.55 COMPONENTS system thread filesystem REQUIRED )
+endif()
include_directories( ${Boost_INCLUDE_DIR} )
if(Boost_FOUND)
@@ -179,10 +197,12 @@ endif()
# SystemD
pkg_check_modules(SystemD "libsystemd")
-if(NOT SystemD_FOUND)
+if(NOT SystemD_FOUND OR ${CMAKE_SYSTEM_NAME} MATCHES "Android")
MESSAGE( STATUS "Systemd was not found, watchdog disabled!")
set(CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS} -DWITHOUT_SYSTEMD")
-endif(NOT SystemD_FOUND)
+else()
+list(APPEND OS_LIBS ${SystemD_LIBRARIES})
+endif(NOT SystemD_FOUND OR ${CMAKE_SYSTEM_NAME} MATCHES "Android")
# Multiple routing managers
if (VSOMEIP_ENABLE_MULTIPLE_ROUTING_MANAGERS EQUAL 1)
@@ -221,7 +241,9 @@ if (MSVC)
ADD_DEFINITIONS( -DBOOST_ALL_DYN_LINK )
else()
set (CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS} -D${OS} ${OS_CXX_FLAGS} -g ${OPTIMIZE} -std=c++11 ${NO_DEPRECATED} ${EXPORTSYMBOLS}")
- set(USE_RT "rt")
+ if (NOT ${CMAKE_SYSTEM_NAME} MATCHES "Android")
+ set(USE_RT "rt")
+ endif()
endif()
################################################################################
@@ -238,7 +260,7 @@ if (VSOMEIP_ENABLE_MULTIPLE_ROUTING_MANAGERS EQUAL 0)
set_target_properties(${VSOMEIP_NAME}-cfg PROPERTIES COMPILE_DEFINITIONS "VSOMEIP_DLL_COMPILATION_PLUGIN")
endif()
- target_link_libraries(${VSOMEIP_NAME}-cfg ${VSOMEIP_NAME} ${Boost_LIBRARIES} ${USE_RT} ${DL_LIBRARY} ${SystemD_LIBRARIES})
+ target_link_libraries(${VSOMEIP_NAME}-cfg ${VSOMEIP_NAME} ${Boost_LIBRARIES} ${USE_RT} ${DL_LIBRARY} ${OS_LIBS})
endif ()
################################################################################
@@ -274,7 +296,7 @@ target_include_directories(${VSOMEIP_NAME} INTERFACE
# them (which shouldn't be required). ${Boost_LIBRARIES} includes absolute
# build host paths as of writing, which also makes this important as it breaks
# the build.
-target_link_libraries(${VSOMEIP_NAME} PRIVATE ${Boost_LIBRARIES} ${USE_RT} ${DL_LIBRARY} ${DLT_LIBRARIES} ${SystemD_LIBRARIES} ${CMAKE_THREAD_LIBS_INIT})
+target_link_libraries(${VSOMEIP_NAME} PRIVATE ${Boost_LIBRARIES} ${USE_RT} ${DL_LIBRARY} ${DLT_LIBRARIES} ${CMAKE_THREAD_LIBS_INIT} ${OS_LIBS})
################################################################################
# Service Discovery library
@@ -290,7 +312,7 @@ if (MSVC)
set_target_properties(${VSOMEIP_NAME}-sd PROPERTIES COMPILE_DEFINITIONS "VSOMEIP_DLL_COMPILATION_PLUGIN")
endif ()
-target_link_libraries(${VSOMEIP_NAME}-sd ${VSOMEIP_NAME} ${Boost_LIBRARIES} ${USE_RT} ${DL_LIBRARY} ${SystemD_LIBRARIES} ${CMAKE_THREAD_LIBS_INIT})
+target_link_libraries(${VSOMEIP_NAME}-sd ${VSOMEIP_NAME} ${Boost_LIBRARIES} ${USE_RT} ${DL_LIBRARY} ${CMAKE_THREAD_LIBS_INIT} ${OS_LIBS})
################################################################################
@@ -307,7 +329,7 @@ if (MSVC)
set_target_properties(${VSOMEIP_NAME}-e2e PROPERTIES COMPILE_DEFINITIONS "VSOMEIP_DLL_COMPILATION_PLUGIN")
endif ()
-target_link_libraries(${VSOMEIP_NAME}-e2e ${VSOMEIP_NAME} ${Boost_LIBRARIES} ${USE_RT} ${DL_LIBRARY} ${SystemD_LIBRARIES})
+target_link_libraries(${VSOMEIP_NAME}-e2e ${VSOMEIP_NAME} ${Boost_LIBRARIES} ${USE_RT} ${DL_LIBRARY} ${OS_LIBS})
################################################################################
# Compatibility library
@@ -338,7 +360,7 @@ target_include_directories(
$<BUILD_INTERFACE:${CMAKE_CURRENT_BINARY_DIR}> # for generated files in build mode
$<INSTALL_INTERFACE:include/compat> # for clients in install mode
)
-target_link_libraries(${VSOMEIP_COMPAT_NAME} PRIVATE ${VSOMEIP_NAME} ${Boost_LIBRARIES} ${USE_RT} ${DL_LIBRARY} ${SystemD_LIBRARIES})
+target_link_libraries(${VSOMEIP_COMPAT_NAME} PRIVATE ${VSOMEIP_NAME} ${Boost_LIBRARIES} ${USE_RT} ${DL_LIBRARY} ${OS_LIBS})
endif ()
@@ -568,21 +590,23 @@ if(NOT WIN32)
endif()
##############################################################################
-# build routing manager daemon (Non-Windows only)
-if (NOT MSVC)
-add_subdirectory( examples/routingmanagerd )
-endif()
+if (NOT ${CMAKE_SYSTEM_NAME} MATCHES "Android")
+ # build routing manager daemon (Non-Windows only)
+ if (NOT MSVC)
+ add_subdirectory( examples/routingmanagerd )
+ endif()
+
+ # build tools
+ add_custom_target( tools )
+ add_subdirectory( tools )
-# build tools
-add_custom_target( tools )
-add_subdirectory( tools )
+ # build examples
+ add_custom_target( examples )
+ add_subdirectory( examples EXCLUDE_FROM_ALL )
+ add_custom_target( hello_world )
+ add_subdirectory( examples/hello_world EXCLUDE_FROM_ALL )
+endif()
-# build examples
-add_custom_target( examples )
-add_subdirectory( examples EXCLUDE_FROM_ALL )
-add_custom_target( hello_world )
-add_subdirectory( examples/hello_world EXCLUDE_FROM_ALL )
-
##############################################################################
# Test section
##############################################################################
diff --git a/README.md b/README.md
index 6dab129..8036a11 100644
--- a/README.md
+++ b/README.md
@@ -1,7 +1,7 @@
### vsomeip
##### Copyright
-Copyright (C) 2015-2020, Bayerische Motoren Werke Aktiengesellschaft (BMW AG)
+Copyright (C) 2015-2017, Bayerische Motoren Werke Aktiengesellschaft (BMW AG)
##### License
@@ -22,9 +22,9 @@ MiddlewarE over IP (SOME/IP)) protocol. The stack consists out of:
###### Dependencies
-- A C++11 enabled compiler like gcc >= 5.4 is needed.
+- A C++11 enabled compiler like gcc >= 4.8 is needed.
- vsomeip uses CMake as buildsystem.
-- vsomeip uses Boost v1.55.0 - v1.73.0
+- vsomeip uses Boost >= 1.55:
Ubuntu 14.04:
@@ -115,4 +115,4 @@ PRODUCT_PACKAGES += \
libvsomeip \
libvsomeip_cfg \
libvsomeip_sd
-```
+``` \ No newline at end of file
diff --git a/examples/hello_world/CMakeLists.txt b/examples/hello_world/CMakeLists.txt
index 2aabd02..3990ab6 100644
--- a/examples/hello_world/CMakeLists.txt
+++ b/examples/hello_world/CMakeLists.txt
@@ -6,22 +6,40 @@
cmake_minimum_required (VERSION 2.8.7)
project (vSomeIPHelloWorld)
-# This will get us acces to
-# VSOMEIP_INCLUDE_DIRS - include directories for vSomeIP
-# VSOMEIP_LIBRARIES - libraries to link against
-find_package(${VSOMEIP_NAME})
-if (NOT ${VSOMEIP_NAME}_FOUND)
- message("${VSOMEIP_NAME} was not found. Please specify vsomeip_DIR")
-endif()
-
find_package(Threads REQUIRED)
set(CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS} -std=c++11")
include_directories(${VSOMEIP_INCLUDE_DIRS})
-add_executable (hello_world_service hello_world_service.cpp)
-target_link_libraries(hello_world_service ${VSOMEIP_LIBRARIES} ${CMAKE_THREAD_LIBS_INIT})
+add_library(vsomeip_hello_world_service INTERFACE)
+target_sources(vsomeip_hello_world_service INTERFACE
+ "${CMAKE_CURRENT_SOURCE_DIR}/hello_world_service.hpp"
+)
+target_include_directories(vsomeip_hello_world_service INTERFACE
+ "${CMAKE_CURRENT_SOURCE_DIR}"
+)
+
+add_library(vsomeip_hello_world_client INTERFACE)
+target_sources(vsomeip_hello_world_client INTERFACE
+ "${CMAKE_CURRENT_SOURCE_DIR}/hello_world_client.hpp"
+)
+target_include_directories(vsomeip_hello_world_client INTERFACE
+ "${CMAKE_CURRENT_SOURCE_DIR}"
+ )
-add_executable (hello_world_client hello_world_client.cpp)
-target_link_libraries(hello_world_client ${VSOMEIP_LIBRARIES} ${CMAKE_THREAD_LIBS_INIT})
+if (NOT ${CMAKE_SYSTEM_NAME} MATCHES "Android")
+ # This will get us acces to
+ # VSOMEIP_INCLUDE_DIRS - include directories for vSomeIP
+ # VSOMEIP_LIBRARIES - libraries to link against
+ find_package(${VSOMEIP_NAME})
+ if (NOT ${VSOMEIP_NAME}_FOUND)
+ message("${VSOMEIP_NAME} was not found. Please specify vsomeip_DIR")
+ endif()
+
+ add_executable (hello_world_service hello_world_service_main.cpp)
+ target_link_libraries(hello_world_service vsomeip_hello_world_service ${VSOMEIP_LIBRARIES} ${CMAKE_THREAD_LIBS_INIT})
+
+ add_executable (hello_world_client hello_world_client_main.cpp)
+ target_link_libraries(hello_world_client vsomeip_hello_world_client ${VSOMEIP_LIBRARIES} ${CMAKE_THREAD_LIBS_INIT})
+endif()
diff --git a/examples/hello_world/hello_world_client.cpp b/examples/hello_world/hello_world_client.hpp
index 03de7d5..06bea36 100644
--- a/examples/hello_world/hello_world_client.cpp
+++ b/examples/hello_world/hello_world_client.hpp
@@ -2,11 +2,18 @@
// This Source Code Form is subject to the terms of the Mozilla Public
// License, v. 2.0. If a copy of the MPL was not distributed with this
// file, You can obtain one at http://mozilla.org/MPL/2.0/.
-#ifndef VSOMEIP_ENABLE_SIGNAL_HANDLING
-#include <csignal>
-#endif
#include <vsomeip/vsomeip.hpp>
-#include <iostream>
+
+#ifdef __ANDROID__ // NDK
+#include "android/log.h"
+#define LOG_TAG "hello_world_client"
+#define LOG_INF(...) (void)__android_log_print(ANDROID_LOG_INFO, LOG_TAG, ##__VA_ARGS__)
+#define LOG_ERR(...) (void)__android_log_print(ANDROID_LOG_ERROR, LOG_TAG, ##__VA_ARGS__)
+#else
+#include <cstdio>
+#define LOG_INF(...) fprintf(stdout, __VA_ARGS__)
+#define LOG_ERR(...) fprintf(stderr, __VA_ARGS__)
+#endif
static vsomeip::service_t service_id = 0x1111;
static vsomeip::instance_t service_instance_id = 0x2222;
@@ -27,7 +34,7 @@ public:
bool init(){
// init the application
if (!app_->init()) {
- std::cerr << "Couldn't initialize application" << std::endl;
+ LOG_ERR ("Couldn't initialize application");
return false;
}
@@ -92,7 +99,7 @@ public:
rq->set_payload(pl);
// Send the request to the service. Response will be delivered to the
// registered message handler
- std::cout << "Sending: " << str << std::endl;
+ LOG_INF("Sending: %s", str.c_str());
app_->send(rq);
}
}
@@ -110,7 +117,7 @@ public:
std::string resp = std::string(
reinterpret_cast<const char*>(pl->get_data()), 0,
pl->get_length());
- std::cout << "Received: " << resp << std::endl;
+ LOG_INF("Received: %s", resp.c_str());
stop();
}
}
@@ -134,31 +141,3 @@ private:
std::shared_ptr<vsomeip::runtime> rtm_;
std::shared_ptr<vsomeip::application> app_;
};
-
-#ifndef VSOMEIP_ENABLE_SIGNAL_HANDLING
-hello_world_client *hw_cl_ptr(nullptr);
- void handle_signal(int _signal) {
- if (hw_cl_ptr != nullptr &&
- (_signal == SIGINT || _signal == SIGTERM))
- hw_cl_ptr->stop();
- }
-#endif
-
-int main(int argc, char **argv)
-{
- (void)argc;
- (void)argv;
-
- hello_world_client hw_cl;
-#ifndef VSOMEIP_ENABLE_SIGNAL_HANDLING
- hw_cl_ptr = &hw_cl;
- signal(SIGINT, handle_signal);
- signal(SIGTERM, handle_signal);
-#endif
- if (hw_cl.init()) {
- hw_cl.start();
- return 0;
- } else {
- return 1;
- }
-}
diff --git a/examples/hello_world/hello_world_client_main.cpp b/examples/hello_world/hello_world_client_main.cpp
new file mode 100644
index 0000000..d8cd07d
--- /dev/null
+++ b/examples/hello_world/hello_world_client_main.cpp
@@ -0,0 +1,37 @@
+// Copyright (C) 2015-2017 Bayerische Motoren Werke Aktiengesellschaft (BMW AG)
+// This Source Code Form is subject to the terms of the Mozilla Public
+// License, v. 2.0. If a copy of the MPL was not distributed with this
+// file, You can obtain one at http://mozilla.org/MPL/2.0/.
+#ifndef VSOMEIP_ENABLE_SIGNAL_HANDLING
+#include <csignal>
+#endif
+#include <vsomeip/vsomeip.hpp>
+#include "hello_world_client.hpp"
+
+#ifndef VSOMEIP_ENABLE_SIGNAL_HANDLING
+hello_world_client *hw_cl_ptr(nullptr);
+ void handle_signal(int _signal) {
+ if (hw_cl_ptr != nullptr &&
+ (_signal == SIGINT || _signal == SIGTERM))
+ hw_cl_ptr->stop();
+ }
+#endif
+
+int main(int argc, char **argv)
+{
+ (void)argc;
+ (void)argv;
+
+ hello_world_client hw_cl;
+#ifndef VSOMEIP_ENABLE_SIGNAL_HANDLING
+ hw_cl_ptr = &hw_cl;
+ signal(SIGINT, handle_signal);
+ signal(SIGTERM, handle_signal);
+#endif
+ if (hw_cl.init()) {
+ hw_cl.start();
+ return 0;
+ } else {
+ return 1;
+ }
+}
diff --git a/examples/hello_world/hello_world_service.cpp b/examples/hello_world/hello_world_service.hpp
index 3968581..489d8fe 100644
--- a/examples/hello_world/hello_world_service.cpp
+++ b/examples/hello_world/hello_world_service.hpp
@@ -2,15 +2,22 @@
// This Source Code Form is subject to the terms of the Mozilla Public
// License, v. 2.0. If a copy of the MPL was not distributed with this
// file, You can obtain one at http://mozilla.org/MPL/2.0/.
-#ifndef VSOMEIP_ENABLE_SIGNAL_HANDLING
-#include <csignal>
-#endif
#include <vsomeip/vsomeip.hpp>
#include <chrono>
#include <thread>
#include <condition_variable>
#include <mutex>
-#include <iostream>
+
+#ifdef __ANDROID__ // NDK
+#include "android/log.h"
+#define LOG_TAG "hello_world_service"
+#define LOG_INF(...) (void)__android_log_print(ANDROID_LOG_INFO, LOG_TAG, ##__VA_ARGS__)
+#define LOG_ERR(...) (void)__android_log_print(ANDROID_LOG_ERROR, LOG_TAG, ##__VA_ARGS__)
+#else
+#include <cstdio>
+#define LOG_INF(...) fprintf(stdout, __VA_ARGS__)
+#define LOG_ERR(...) fprintf(stderr, __VA_ARGS__)
+#endif
static vsomeip::service_t service_id = 0x1111;
static vsomeip::instance_t service_instance_id = 0x2222;
@@ -39,7 +46,7 @@ public:
{
// init the application
if (!app_->init()) {
- std::cerr << "Couldn't initialize application" << std::endl;
+ LOG_ERR("Couldn't initialize application");
return false;
}
@@ -128,31 +135,3 @@ private:
std::condition_variable condition_;
std::thread stop_thread_;
};
-
-#ifndef VSOMEIP_ENABLE_SIGNAL_HANDLING
-hello_world_service *hw_srv_ptr(nullptr);
- void handle_signal(int _signal) {
- if (hw_srv_ptr != nullptr &&
- (_signal == SIGINT || _signal == SIGTERM))
- hw_srv_ptr->terminate();
- }
-#endif
-
-int main(int argc, char **argv)
-{
- (void)argc;
- (void)argv;
-
- hello_world_service hw_srv;
-#ifndef VSOMEIP_ENABLE_SIGNAL_HANDLING
- hw_srv_ptr = &hw_srv;
- signal(SIGINT, handle_signal);
- signal(SIGTERM, handle_signal);
-#endif
- if (hw_srv.init()) {
- hw_srv.start();
- return 0;
- } else {
- return 1;
- }
-}
diff --git a/examples/hello_world/hello_world_service_main.cpp b/examples/hello_world/hello_world_service_main.cpp
new file mode 100644
index 0000000..ca3e8cb
--- /dev/null
+++ b/examples/hello_world/hello_world_service_main.cpp
@@ -0,0 +1,37 @@
+// Copyright (C) 2015-2017 Bayerische Motoren Werke Aktiengesellschaft (BMW AG)
+// This Source Code Form is subject to the terms of the Mozilla Public
+// License, v. 2.0. If a copy of the MPL was not distributed with this
+// file, You can obtain one at http://mozilla.org/MPL/2.0/.
+#ifndef VSOMEIP_ENABLE_SIGNAL_HANDLING
+#include <csignal>
+#endif
+#include <vsomeip/vsomeip.hpp>
+#include "hello_world_service.hpp"
+
+#ifndef VSOMEIP_ENABLE_SIGNAL_HANDLING
+hello_world_service *hw_srv_ptr(nullptr);
+ void handle_signal(int _signal) {
+ if (hw_srv_ptr != nullptr &&
+ (_signal == SIGINT || _signal == SIGTERM))
+ hw_srv_ptr->terminate();
+ }
+#endif
+
+int main(int argc, char **argv)
+{
+ (void)argc;
+ (void)argv;
+
+ hello_world_service hw_srv;
+#ifndef VSOMEIP_ENABLE_SIGNAL_HANDLING
+ hw_srv_ptr = &hw_srv;
+ signal(SIGINT, handle_signal);
+ signal(SIGTERM, handle_signal);
+#endif
+ if (hw_srv.init()) {
+ hw_srv.start();
+ return 0;
+ } else {
+ return 1;
+ }
+}
diff --git a/examples/hello_world/readme_android b/examples/hello_world/readme_android
index 2eced5b..3d56fdd 100644
--- a/examples/hello_world/readme_android
+++ b/examples/hello_world/readme_android
@@ -1,4 +1,7 @@
-To start service and client:
+AOSP:
+1. Apply vsomeip project to AOSP tree and build hello_world example (e.g. via mma build command)
+2. Push changes to target
+3. Start service and client via different adb shell sessions:
Shell1:
VSOMEIP_CONFIGURATION=/etc/vsomeip/helloworld-local.json \
@@ -8,4 +11,12 @@ vsomeip_hello_world_service
Shell2:
VSOMEIP_CONFIGURATION=/etc/vsomeip/helloworld-local.json \
VSOMEIP_APPLICATION_NAME=hello_world_client \
-vsomeip_hello_world_client \ No newline at end of file
+vsomeip_hello_world_client
+
+NDK:
+AndroidStudio example how to use vsomeip like communication mechanism between two Android services:
+https://github.com/nkh-lab/ndk-vsomeip-hello-world
+
+Expected Android app Logcat output:
+2020-06-05 11:13:06.407 31221-31266/com.example.vsomeiphelloworld I/hello_world_client: Sending: World
+2020-06-05 11:13:06.437 31221-31266/com.example.vsomeiphelloworld I/hello_world_client: Received: Hello World
diff --git a/implementation/configuration/include/configuration.hpp b/implementation/configuration/include/configuration.hpp
index b1dcf5b..f20d040 100644
--- a/implementation/configuration/include/configuration.hpp
+++ b/implementation/configuration/include/configuration.hpp
@@ -220,6 +220,9 @@ public:
virtual bool is_protected_port(
const boost::asio::ip::address& _address, std::uint16_t _port,
bool _reliable) const = 0;
+ virtual bool is_secure_port(
+ const boost::asio::ip::address& _address, std::uint16_t _port,
+ bool _reliable) const = 0;
typedef std::pair<std::uint16_t, std::uint16_t> port_range_t;
virtual void set_sd_acceptance_rule(
@@ -228,14 +231,14 @@ public:
const std::string &_path, bool _reliable, bool _enable, bool _default) = 0;
typedef std::map<
- boost::asio::ip::address,
+ boost::asio::ip::address, // other device
std::pair<
- std::string,
+ std::string, // path to file that determines whether or not IPsec is active
std::map<
- bool,
+ bool, // false = unreliable (aka UDP), true = reliable (aka TCP)
std::pair<
- boost::icl::interval_set<std::uint16_t>,
- boost::icl::interval_set<std::uint16_t>
+ boost::icl::interval_set<std::uint16_t>, // optional (aka semi-secure) port range
+ boost::icl::interval_set<std::uint16_t> // secure port range
>
>
>
@@ -246,6 +249,8 @@ public:
virtual void set_sd_acceptance_rules_active(
const boost::asio::ip::address& _address, bool _enable) = 0;
+ virtual bool is_secure_service(service_t _service, instance_t _instance) const = 0;
+
virtual std::uint32_t get_udp_receive_buffer_size() const = 0;
virtual bool check_routing_credentials(client_t _client, uint32_t _uid, uint32_t _gid) const = 0;
diff --git a/implementation/configuration/include/configuration_impl.hpp b/implementation/configuration/include/configuration_impl.hpp
index e3dc94b..5b77c18 100644
--- a/implementation/configuration/include/configuration_impl.hpp
+++ b/implementation/configuration/include/configuration_impl.hpp
@@ -203,6 +203,9 @@ public:
VSOMEIP_EXPORT bool is_protected_port(
const boost::asio::ip::address& _address,
std::uint16_t _port, bool _reliable) const;
+ VSOMEIP_EXPORT bool is_secure_port(
+ const boost::asio::ip::address& _address,
+ std::uint16_t _port, bool _reliable) const;
VSOMEIP_EXPORT void set_sd_acceptance_rule(
const boost::asio::ip::address& _address,
@@ -214,6 +217,8 @@ public:
VSOMEIP_EXPORT void set_sd_acceptance_rules_active(
const boost::asio::ip::address& _address, bool _enable);
+ VSOMEIP_EXPORT bool is_secure_service(service_t _service, instance_t _instance) const;
+
VSOMEIP_EXPORT std::uint32_t get_udp_receive_buffer_size() const;
VSOMEIP_EXPORT bool has_overlay(const std::string &_name) const;
@@ -364,6 +369,9 @@ private:
void load_tcp_restart_settings(const configuration_element &_element);
+ void load_secure_services(const configuration_element &_element);
+ void load_secure_service(const boost::property_tree::ptree &_tree);
+
private:
std::mutex mutex_;
@@ -542,6 +550,9 @@ protected:
std::chrono::nanoseconds npdu_default_max_retention_resp_;
std::uint32_t shutdown_timeout_;
+
+ mutable std::mutex secure_services_mutex_;
+ std::map<service_t, std::set<instance_t> > secure_services_;
};
} // namespace cfg
diff --git a/implementation/configuration/include/internal_android.hpp b/implementation/configuration/include/internal_android.hpp
index ddb4631..1c2c505 100644
--- a/implementation/configuration/include/internal_android.hpp
+++ b/implementation/configuration/include/internal_android.hpp
@@ -205,6 +205,13 @@ const std::uint32_t ANY_GID = 0xFFFFFFFF;
typedef std::pair<std::uint32_t, std::uint32_t> credentials_t;
+enum class port_type_e {
+ PT_OPTIONAL,
+ PT_SECURE,
+ PT_UNSECURE,
+ PT_UNKNOWN
+};
+
} // namespace vsomeip_v3
#endif // VSOMEIP_V3_INTERNAL_HPP_
diff --git a/implementation/configuration/src/configuration_impl.cpp b/implementation/configuration/src/configuration_impl.cpp
index eb7b1ea..9f7aeab 100644
--- a/implementation/configuration/src/configuration_impl.cpp
+++ b/implementation/configuration/src/configuration_impl.cpp
@@ -500,6 +500,7 @@ bool configuration_impl::load_data(const std::vector<configuration_element> &_el
load_e2e(e);
load_debounce(e);
load_acceptances(e);
+ load_secure_services(e);
}
}
@@ -3532,6 +3533,55 @@ configuration_impl::load_udp_receive_buffer_size(const configuration_element &_e
}
}
+void configuration_impl::load_secure_services(const configuration_element &_element) {
+ std::lock_guard<std::mutex> its_lock(secure_services_mutex_);
+ try {
+ auto its_services = _element.tree_.get_child("secure-services");
+ for (auto i = its_services.begin(); i != its_services.end(); ++i)
+ load_secure_service(i->second);
+ } catch (...) {
+ // intentionally left empty
+ }
+}
+
+void configuration_impl::load_secure_service(const boost::property_tree::ptree &_tree) {
+ try {
+ service_t its_service(0);
+ instance_t its_instance(0);
+
+ for (auto i = _tree.begin(); i != _tree.end(); ++i) {
+ std::string its_key(i->first);
+ std::string its_value(i->second.data());
+ std::stringstream its_converter;
+
+ // Trim "its_value"
+ if (its_value.size() > 1 && its_value[0] == '0' && its_value[1] == 'x') {
+ its_converter << std::hex << its_value;
+ } else {
+ its_converter << std::dec << its_value;
+ }
+
+ if (its_key == "service") {
+ its_converter >> its_service;
+ } else if (its_key == "instance") {
+ its_converter >> its_instance;
+ }
+ }
+
+ if (its_service != 0 && its_instance != 0) {
+ auto find_service = secure_services_.find(its_service);
+ if (find_service != secure_services_.end()) {
+ find_service->second.insert(its_instance);
+ } else {
+ secure_services_[its_service].insert(its_instance);
+ }
+ }
+
+ } catch (...) {
+ // Intentionally left empty
+ }
+}
+
std::shared_ptr<debounce> configuration_impl::get_debounce(
service_t _service, instance_t _instance, event_t _event) const {
auto found_service = debounces_.find(_service);
@@ -3639,6 +3689,28 @@ bool configuration_impl::is_protected_port(
return (is_required);
}
+bool configuration_impl::is_secure_port(
+ const boost::asio::ip::address& _address, std::uint16_t _port,
+ bool _reliable) const {
+
+ bool is_secure(false);
+
+ std::lock_guard<std::mutex> its_lock(sd_acceptance_required_ips_mutex_);
+ const auto found_address = sd_acceptance_rules_.find(_address);
+ if (found_address != sd_acceptance_rules_.end()) {
+ const auto found_reliability
+ = found_address->second.second.find(_reliable);
+ if (found_reliability != found_address->second.second.end()) {
+ const auto its_range
+ = boost::icl::interval<std::uint16_t>::closed(_port, _port);
+ return (found_reliability->second.second.find(its_range)
+ != found_reliability->second.second.end());
+ }
+ }
+
+ return (is_secure);
+}
+
void configuration_impl::set_sd_acceptance_rule(
const boost::asio::ip::address &_address,
port_range_t _port_range, port_type_e _type,
@@ -3789,6 +3861,14 @@ void configuration_impl::set_sd_acceptance_rules_active(
}
}
+bool configuration_impl::is_secure_service(service_t _service, instance_t _instance) const {
+ std::lock_guard<std::mutex> its_lock(secure_services_mutex_);
+ const auto its_service = secure_services_.find(_service);
+ if (its_service != secure_services_.end())
+ return (its_service->second.find(_instance) != its_service->second.end());
+ return (false);
+}
+
std::uint32_t configuration_impl::get_udp_receive_buffer_size() const {
return udp_receive_buffer_size_;
}
diff --git a/implementation/endpoints/include/tp.hpp b/implementation/endpoints/include/tp.hpp
index f11718d..0e3a9d0 100644
--- a/implementation/endpoints/include/tp.hpp
+++ b/implementation/endpoints/include/tp.hpp
@@ -51,7 +51,7 @@ public:
static tp_split_messages_t tp_split_message(
const std::uint8_t * const _data, std::uint32_t _size);
- static const std::uint16_t tp_max_segment_length_ = 1392;
+ static const std::uint16_t tp_max_segment_length_;
};
} // namespace tp
diff --git a/implementation/endpoints/src/tp.cpp b/implementation/endpoints/src/tp.cpp
index 6d532f6..0a2578d 100644
--- a/implementation/endpoints/src/tp.cpp
+++ b/implementation/endpoints/src/tp.cpp
@@ -26,6 +26,8 @@
namespace vsomeip_v3 {
namespace tp {
+const std::uint16_t tp::tp_max_segment_length_ = 1392;
+
tp_split_messages_t tp::tp_split_message(const std::uint8_t * const _data,
std::uint32_t _size) {
tp_split_messages_t split_messages;
diff --git a/implementation/logger/src/message.cpp b/implementation/logger/src/message.cpp
index 363db37..e4a902f 100644
--- a/implementation/logger/src/message.cpp
+++ b/implementation/logger/src/message.cpp
@@ -10,7 +10,11 @@
#include <iostream>
#ifdef ANDROID
-#include <utils/Log.h>
+#include <android/log.h>
+
+#ifndef LOG_TAG
+#define LOG_TAG NULL
+#endif
#endif
#include <vsomeip/internal/logger.hpp>
@@ -90,25 +94,25 @@ message::~message() {
#else
switch (level_) {
case level_e::LL_FATAL:
- ALOGE(buffer_.data_.str());
+ (void)__android_log_print(ANDROID_LOG_ERROR, LOG_TAG, "%s", buffer_.data_.str().c_str());
break;
case level_e::LL_ERROR:
- ALOGE(buffer_.data_.str());
+ (void)__android_log_print(ANDROID_LOG_ERROR, LOG_TAG, "%s", buffer_.data_.str().c_str());
break;
case level_e::LL_WARNING:
- ALOGW(buffer_.data_.str());
+ (void)__android_log_print(ANDROID_LOG_WARN, LOG_TAG, "%s", buffer_.data_.str().c_str());
break;
case level_e::LL_INFO:
- ALOGI(buffer_.data_.str());
+ (void)__android_log_print(ANDROID_LOG_INFO, LOG_TAG, "%s", buffer_.data_.str().c_str());
break;
case level_e::LL_DEBUG:
- ALOGD(buffer_.data_.str());
+ (void)__android_log_print(ANDROID_LOG_DEBUG, LOG_TAG, "%s", buffer_.data_.str().c_str());
break;
case level_e::LL_VERBOSE:
- ALOGV(buffer_.data_.str());
+ (void)__android_log_print(ANDROID_LOG_VERBOSE, LOG_TAG, "%s", buffer_.data_.str().c_str());
break;
default:
- ALOGI(buffer_.data_.str());
+ (void)__android_log_print(ANDROID_LOG_INFO, LOG_TAG, "%s", buffer_.data_.str().c_str());
};
#endif // !ANDROID
}
diff --git a/implementation/routing/src/routing_manager_impl.cpp b/implementation/routing/src/routing_manager_impl.cpp
index c132569..f141c57 100644
--- a/implementation/routing/src/routing_manager_impl.cpp
+++ b/implementation/routing/src/routing_manager_impl.cpp
@@ -2757,8 +2757,6 @@ void routing_manager_impl::on_remote_unsubscribe(
const auto its_eventgroup = its_info->get_eventgroup();
const auto its_major = its_info->get_major();
- auto its_subscriber = _subscription->get_subscriber();
-
// Get remote port(s)
auto its_reliable = _subscription->get_reliable();
if (its_reliable) {
diff --git a/implementation/service_discovery/src/service_discovery_impl.cpp b/implementation/service_discovery/src/service_discovery_impl.cpp
index 7ae5395..fba2227 100644
--- a/implementation/service_discovery/src/service_discovery_impl.cpp
+++ b/implementation/service_discovery/src/service_discovery_impl.cpp
@@ -1272,6 +1272,21 @@ service_discovery_impl::process_offerservice_serviceentry(
if (!its_runtime)
return;
+ bool is_secure = configuration_->is_secure_service(_service, _instance);
+ if (is_secure &&
+ ((_reliable_port != ILLEGAL_PORT &&
+ !configuration_->is_secure_port(_reliable_address, _reliable_port, true))
+ || (_unreliable_port != ILLEGAL_PORT
+ && !configuration_->is_secure_port(_unreliable_address, _unreliable_port, false)))) {
+
+ VSOMEIP_WARNING << __func__ << ": Ignoring offer of ["
+ << std::hex << std::setw(4) << std::setfill('0') << _service
+ << "."
+ << std::hex << std::setw(4) << std::setfill('0') << _instance
+ << "]";
+ return;
+ }
+
std::shared_ptr<request> its_request = find_request(_service, _instance);
if (its_request) {
std::lock_guard<std::mutex> its_lock(requested_mutex_);
@@ -2297,6 +2312,9 @@ service_discovery_impl::handle_eventgroup_subscription(
// Create subscription object
auto its_subscription = std::make_shared<remote_subscription>();
its_subscription->set_eventgroupinfo(_info);
+ its_subscription->set_subscriber(its_subscriber);
+ its_subscription->set_reliable(its_reliable);
+ its_subscription->set_unreliable(its_unreliable);
its_subscription->reset(_clients);
if (_ttl == 0) { // --> unsubscribe
@@ -2315,9 +2333,6 @@ service_discovery_impl::handle_eventgroup_subscription(
if (_force_initial_events) {
its_subscription->set_force_initial_events(true);
}
- its_subscription->set_subscriber(its_subscriber);
- its_subscription->set_reliable(its_reliable);
- its_subscription->set_unreliable(its_unreliable);
its_subscription->set_ttl(_ttl
* get_ttl_factor(_service, _instance, ttl_factor_subscriptions_));
diff --git a/interface/vsomeip/primitive_types.hpp b/interface/vsomeip/primitive_types.hpp
index f0dd136..26a9fd7 100644
--- a/interface/vsomeip/primitive_types.hpp
+++ b/interface/vsomeip/primitive_types.hpp
@@ -8,6 +8,7 @@
#include <array>
#include <cstdint>
+#include <string>
#ifndef _WIN32
#include <sys/types.h>