diff --git a/.gitignore b/.gitignore index fce128e87..c219dacda 100644 --- a/.gitignore +++ b/.gitignore @@ -1,112 +1,177 @@ /CMakeFiles /build*/* /examples/hello_world/build +/.vscode/ /.settings +/.project +/.cproject /doc /daemon/CMakeFiles /examples/CMakeFiles /implementation/configuration/include/internal.hpp -/test/application_tests/application_test.json -/test/application_tests/application_test_daemon.json -/test/application_tests/application_test_no_dispatch_threads.json -/test/application_tests/application_test_no_dispatch_threads_daemon.json -/test/big_payload_tests/big_payload_test_tcp_client.json -/test/big_payload_tests/big_payload_test_tcp_service.json -/test/big_payload_tests/big_payload_test_tcp_client_random.json -/test/big_payload_tests/big_payload_test_tcp_service_random.json -/test/big_payload_tests/big_payload_test_tcp_client_limited_general.json -/test/big_payload_tests/big_payload_test_tcp_service_limited_general.json -/test/big_payload_tests/big_payload_test_tcp_client_queue_limited_general.json -/test/big_payload_tests/big_payload_test_tcp_client_queue_limited_specific.json -/test/big_payload_tests/big_payload_test_tcp_service_queue_limited_general.json -/test/big_payload_tests/big_payload_test_tcp_service_queue_limited_specific.json -/test/magic_cookies_tests/magic_cookies_test_client.json -/test/magic_cookies_tests/magic_cookies_test_service.json -/test/payload_tests/external_local_payload_test_client_external.json -/test/payload_tests/external_local_payload_test_client_local.json -/test/payload_tests/external_local_payload_test_service.json -/test/routing_tests/external_local_routing_test_client_external.json -/test/routing_tests/external_local_routing_test_service.json -/test/routing_tests/local_routing_test_starter.sh -/test/client_id_tests/client_id_test_diff_client_ids_diff_ports_master.json -/test/client_id_tests/client_id_test_diff_client_ids_diff_ports_slave.json -/test/client_id_tests/client_id_test_diff_client_ids_same_ports_master.json -/test/client_id_tests/client_id_test_diff_client_ids_same_ports_slave.json -/test/client_id_tests/client_id_test_diff_client_ids_partial_same_ports_master.json -/test/client_id_tests/client_id_test_diff_client_ids_partial_same_ports_slave.json -/test/client_id_tests/client_id_test_same_client_ids_diff_ports_master.json -/test/client_id_tests/client_id_test_same_client_ids_diff_ports_slave.json -/test/client_id_tests/client_id_test_same_client_ids_same_ports_master.json -/test/client_id_tests/client_id_test_same_client_ids_same_ports_slave.json -/test/subscribe_notify_tests/subscribe_notify_test_diff_client_ids_diff_ports_master.json -/test/subscribe_notify_tests/subscribe_notify_test_diff_client_ids_diff_ports_slave.json -/test/subscribe_notify_tests/subscribe_notify_test_diff_client_ids_same_ports_master.json -/test/subscribe_notify_tests/subscribe_notify_test_diff_client_ids_same_ports_slave.json -/test/subscribe_notify_tests/subscribe_notify_test_diff_client_ids_partial_same_ports_master.json -/test/subscribe_notify_tests/subscribe_notify_test_diff_client_ids_partial_same_ports_slave.json -/test/subscribe_notify_tests/subscribe_notify_test_same_client_ids_diff_ports_master.json -/test/subscribe_notify_tests/subscribe_notify_test_same_client_ids_diff_ports_slave.json -/test/subscribe_notify_tests/subscribe_notify_test_same_client_ids_same_ports_master.json -/test/subscribe_notify_tests/subscribe_notify_test_same_client_ids_same_ports_slave.json -/test/subscribe_notify_tests/subscribe_notify_test_one_event_two_eventgroups_master.json -/test/subscribe_notify_tests/subscribe_notify_test_one_event_two_eventgroups_udp_slave.json -/test/subscribe_notify_tests/subscribe_notify_test_one_event_two_eventgroups_tcp_slave.json -/test/subscribe_notify_one_tests/subscribe_notify_one_test_diff_client_ids_diff_ports_master.json -/test/subscribe_notify_one_tests/subscribe_notify_one_test_diff_client_ids_diff_ports_slave.json -/test/subscribe_notify_one_tests/subscribe_notify_one_test_diff_client_ids_diff_ports_master_tcp.json -/test/subscribe_notify_one_tests/subscribe_notify_one_test_diff_client_ids_diff_ports_slave_tcp.json -/test/subscribe_notify_one_tests/subscribe_notify_one_test_diff_client_ids_diff_ports_master_udp.json -/test/subscribe_notify_one_tests/subscribe_notify_one_test_diff_client_ids_diff_ports_slave_udp.json -/test/subscribe_notify_tests/subscribe_notify_test_diff_client_ids_diff_ports_same_service_id_master.json -/test/subscribe_notify_tests/subscribe_notify_test_diff_client_ids_diff_ports_same_service_id_slave.json -/test/subscribe_notify_tests/subscribe_notify_test_diff_client_ids_diff_ports_master_tcp.json -/test/subscribe_notify_tests/subscribe_notify_test_diff_client_ids_diff_ports_slave_tcp.json -/test/subscribe_notify_tests/subscribe_notify_test_diff_client_ids_same_ports_master_tcp.json -/test/subscribe_notify_tests/subscribe_notify_test_diff_client_ids_same_ports_slave_tcp.json -/test/cpu_load_tests/cpu_load_test_client_slave.json -/test/cpu_load_tests/cpu_load_test_client_master.json -/test/cpu_load_tests/cpu_load_test_service_slave.json -/test/cpu_load_tests/cpu_load_test_service_master.json +/test/network_tests/application_tests/application_test.json +/test/network_tests/application_tests/application_test_daemon.json +/test/network_tests/application_tests/application_test_no_dispatch_threads.json +/test/network_tests/application_tests/application_test_no_dispatch_threads_daemon.json +/test/network_tests/big_payload_tests/big_payload_test_local_tcp_client.json +/test/network_tests/big_payload_tests/big_payload_test_local_tcp_client_limited.json +/test/network_tests/big_payload_tests/big_payload_test_local_tcp_client_queue_limited.json +/test/network_tests/big_payload_tests/big_payload_test_local_tcp_client_random.json +/test/network_tests/big_payload_tests/big_payload_test_local_tcp_service.json +/test/network_tests/big_payload_tests/big_payload_test_local_tcp_service_limited.json +/test/network_tests/big_payload_tests/big_payload_test_local_tcp_service_queue_limited.json +/test/network_tests/big_payload_tests/big_payload_test_local_tcp_service_random.json +/test/network_tests/big_payload_tests/big_payload_test_tcp_client.json +/test/network_tests/big_payload_tests/big_payload_test_tcp_service.json +/test/network_tests/big_payload_tests/big_payload_test_tcp_client_random.json +/test/network_tests/big_payload_tests/big_payload_test_tcp_service_random.json +/test/network_tests/big_payload_tests/big_payload_test_tcp_client_limited_general.json +/test/network_tests/big_payload_tests/big_payload_test_tcp_service_limited_general.json +/test/network_tests/big_payload_tests/big_payload_test_tcp_client_queue_limited_general.json +/test/network_tests/big_payload_tests/big_payload_test_tcp_client_queue_limited_specific.json +/test/network_tests/big_payload_tests/big_payload_test_tcp_service_queue_limited_general.json +/test/network_tests/big_payload_tests/big_payload_test_tcp_service_queue_limited_specific.json +/test/network_tests/big_payload_tests/big_payload_test_udp_client.json +/test/network_tests/big_payload_tests/big_payload_test_udp_service.json +/test/network_tests/magic_cookies_tests/magic_cookies_test_client.json +/test/network_tests/magic_cookies_tests/magic_cookies_test_service.json +/test/network_tests/debounce_frequency_tests/debounce_frequency_test_client.json +/test/network_tests/debounce_frequency_tests/debounce_frequency_test_service.json +/test/network_tests/payload_tests/external_local_payload_test_client_external.json +/test/network_tests/payload_tests/external_local_payload_test_client_local.json +/test/network_tests/payload_tests/external_local_payload_test_service.json +/test/network_tests/routing_tests/external_local_routing_test_client_external.json +/test/network_tests/routing_tests/external_local_routing_test_service.json +/test/network_tests/routing_tests/local_routing_test_starter.sh +/test/network_tests/client_id_tests/client_id_test_diff_client_ids_diff_ports_master.json +/test/network_tests/client_id_tests/client_id_test_diff_client_ids_diff_ports_slave.json +/test/network_tests/client_id_tests/client_id_test_diff_client_ids_same_ports_master.json +/test/network_tests/client_id_tests/client_id_test_diff_client_ids_same_ports_slave.json +/test/network_tests/client_id_tests/client_id_test_diff_client_ids_partial_same_ports_master.json +/test/network_tests/client_id_tests/client_id_test_diff_client_ids_partial_same_ports_slave.json +/test/network_tests/client_id_tests/client_id_test_same_client_ids_diff_ports_master.json +/test/network_tests/client_id_tests/client_id_test_same_client_ids_diff_ports_slave.json +/test/network_tests/client_id_tests/client_id_test_same_client_ids_same_ports_master.json +/test/network_tests/client_id_tests/client_id_test_same_client_ids_same_ports_slave.json +/test/network_tests/subscribe_notify_tests/subscribe_notify_test_diff_client_ids_diff_ports_master.json +/test/network_tests/subscribe_notify_tests/subscribe_notify_test_diff_client_ids_diff_ports_slave.json +/test/network_tests/subscribe_notify_tests/subscribe_notify_test_diff_client_ids_same_ports_master.json +/test/network_tests/subscribe_notify_tests/subscribe_notify_test_diff_client_ids_same_ports_slave.json +/test/network_tests/subscribe_notify_tests/subscribe_notify_test_diff_client_ids_partial_same_ports_master.json +/test/network_tests/subscribe_notify_tests/subscribe_notify_test_diff_client_ids_partial_same_ports_slave.json +/test/network_tests/subscribe_notify_tests/subscribe_notify_test_same_client_ids_diff_ports_master.json +/test/network_tests/subscribe_notify_tests/subscribe_notify_test_same_client_ids_diff_ports_slave.json +/test/network_tests/subscribe_notify_tests/subscribe_notify_test_same_client_ids_same_ports_master.json +/test/network_tests/subscribe_notify_tests/subscribe_notify_test_same_client_ids_same_ports_slave.json +/test/network_tests/subscribe_notify_tests/subscribe_notify_test_one_event_two_eventgroups_master.json +/test/network_tests/subscribe_notify_tests/subscribe_notify_test_one_event_two_eventgroups_udp_slave.json +/test/network_tests/subscribe_notify_tests/subscribe_notify_test_one_event_two_eventgroups_tcp_slave.json +/test/network_tests/subscribe_notify_tests/subscribe_notify_test_diff_client_ids_diff_ports_master_udp.json +/test/network_tests/subscribe_notify_tests/subscribe_notify_test_diff_client_ids_diff_ports_slave_udp.json +/test/network_tests/subscribe_notify_tests/subscribe_notify_test_diff_client_ids_same_ports_master_udp.json +/test/network_tests/subscribe_notify_tests/subscribe_notify_test_diff_client_ids_same_ports_slave_udp.json +/test/network_tests/subscribe_notify_one_tests/subscribe_notify_one_test_diff_client_ids_diff_ports_master.json +/test/network_tests/subscribe_notify_one_tests/subscribe_notify_one_test_diff_client_ids_diff_ports_slave.json +/test/network_tests/subscribe_notify_one_tests/subscribe_notify_one_test_diff_client_ids_diff_ports_master_tcp.json +/test/network_tests/subscribe_notify_one_tests/subscribe_notify_one_test_diff_client_ids_diff_ports_slave_tcp.json +/test/network_tests/subscribe_notify_one_tests/subscribe_notify_one_test_diff_client_ids_diff_ports_master_udp.json +/test/network_tests/subscribe_notify_one_tests/subscribe_notify_one_test_diff_client_ids_diff_ports_slave_udp.json +/test/network_tests/subscribe_notify_tests/subscribe_notify_test_diff_client_ids_diff_ports_same_service_id_master_udp.json +/test/network_tests/subscribe_notify_tests/subscribe_notify_test_diff_client_ids_diff_ports_same_service_id_slave_udp.json +/test/network_tests/subscribe_notify_tests/subscribe_notify_test_diff_client_ids_diff_ports_master_tcp.json +/test/network_tests/subscribe_notify_tests/subscribe_notify_test_diff_client_ids_diff_ports_slave_tcp.json +/test/network_tests/subscribe_notify_tests/subscribe_notify_test_diff_client_ids_same_ports_master_tcp.json +/test/network_tests/subscribe_notify_tests/subscribe_notify_test_diff_client_ids_same_ports_slave_tcp.json +/test/network_tests/subscribe_notify_tests/subscribe_notify_test_diff_client_ids_diff_ports_autoconfig_master_local_tcp.json +/test/network_tests/subscribe_notify_tests/subscribe_notify_test_diff_client_ids_diff_ports_autoconfig_slave_local_tcp.json +/test/network_tests/subscribe_notify_tests/subscribe_notify_test_diff_client_ids_diff_ports_master_local_tcp.json +/test/network_tests/subscribe_notify_tests/subscribe_notify_test_diff_client_ids_diff_ports_master_tcp_local_tcp.json +/test/network_tests/subscribe_notify_tests/subscribe_notify_test_diff_client_ids_diff_ports_master_udp_local_tcp.json +/test/network_tests/subscribe_notify_tests/subscribe_notify_test_diff_client_ids_diff_ports_same_service_id_master_udp_local_tcp.json +/test/network_tests/subscribe_notify_tests/subscribe_notify_test_diff_client_ids_diff_ports_same_service_id_slave_udp_local_tcp.json +/test/network_tests/subscribe_notify_tests/subscribe_notify_test_diff_client_ids_diff_ports_slave_local_tcp.json +/test/network_tests/subscribe_notify_tests/subscribe_notify_test_diff_client_ids_diff_ports_slave_tcp_local_tcp.json +/test/network_tests/subscribe_notify_tests/subscribe_notify_test_diff_client_ids_diff_ports_slave_udp_local_tcp.json +/test/network_tests/subscribe_notify_tests/subscribe_notify_test_diff_client_ids_partial_same_ports_master_local_tcp.json +/test/network_tests/subscribe_notify_tests/subscribe_notify_test_diff_client_ids_partial_same_ports_slave_local_tcp.json +/test/network_tests/subscribe_notify_tests/subscribe_notify_test_diff_client_ids_same_ports_master_local_tcp.json +/test/network_tests/subscribe_notify_tests/subscribe_notify_test_diff_client_ids_same_ports_master_tcp_local_tcp.json +/test/network_tests/subscribe_notify_tests/subscribe_notify_test_diff_client_ids_same_ports_master_udp_local_tcp.json +/test/network_tests/subscribe_notify_tests/subscribe_notify_test_diff_client_ids_same_ports_slave_local_tcp.json +/test/network_tests/subscribe_notify_tests/subscribe_notify_test_diff_client_ids_same_ports_slave_tcp_local_tcp.json +/test/network_tests/subscribe_notify_tests/subscribe_notify_test_diff_client_ids_same_ports_slave_udp_local_tcp.json +/test/network_tests/subscribe_notify_tests/subscribe_notify_test_one_event_two_eventgroups_master_local_tcp.json +/test/network_tests/subscribe_notify_tests/subscribe_notify_test_one_event_two_eventgroups_tcp_slave_local_tcp.json +/test/network_tests/subscribe_notify_tests/subscribe_notify_test_one_event_two_eventgroups_udp_slave_local_tcp.json +/test/network_tests/subscribe_notify_tests/subscribe_notify_test_same_client_ids_diff_ports_master_local_tcp.json +/test/network_tests/subscribe_notify_tests/subscribe_notify_test_same_client_ids_diff_ports_slave_local_tcp.json +/test/network_tests/subscribe_notify_tests/subscribe_notify_test_same_client_ids_same_ports_master_local_tcp.json +/test/network_tests/subscribe_notify_tests/subscribe_notify_test_same_client_ids_same_ports_slave_local_tcp.json +/test/network_tests/cpu_load_tests/cpu_load_test_client_slave.json +/test/network_tests/cpu_load_tests/cpu_load_test_client_master.json +/test/network_tests/cpu_load_tests/cpu_load_test_service_slave.json +/test/network_tests/cpu_load_tests/cpu_load_test_service_master.json /tools/CMakeFiles -/test/initial_event_tests/initial_event_test_diff_client_ids_diff_ports_master.json -/test/initial_event_tests/initial_event_test_diff_client_ids_diff_ports_same_service_id_master.json -/test/initial_event_tests/initial_event_test_diff_client_ids_diff_ports_same_service_id_slave.json -/test/initial_event_tests/initial_event_test_diff_client_ids_diff_ports_slave.json -/test/initial_event_tests/initial_event_test_diff_client_ids_partial_same_ports_master.json -/test/initial_event_tests/initial_event_test_diff_client_ids_partial_same_ports_slave.json -/test/initial_event_tests/initial_event_test_diff_client_ids_same_ports_master.json -/test/initial_event_tests/initial_event_test_diff_client_ids_same_ports_slave.json -/test/initial_event_tests/initial_event_test_same_client_ids_diff_ports_master.json -/test/initial_event_tests/initial_event_test_same_client_ids_diff_ports_slave.json -/test/initial_event_tests/initial_event_test_same_client_ids_same_ports_master.json -/test/initial_event_tests/initial_event_test_same_client_ids_same_ports_slave.json -/test/initial_event_tests/initial_event_test_diff_client_ids_diff_ports_master_tcp.json -/test/initial_event_tests/initial_event_test_diff_client_ids_diff_ports_slave_tcp.json -/test/initial_event_tests/initial_event_test_diff_client_ids_same_ports_master_tcp.json -/test/initial_event_tests/initial_event_test_diff_client_ids_same_ports_slave_tcp.json -/test/offer_tests/offer_test_external_master.json -/test/offer_tests/offer_test_external_slave.json -/test/offer_tests/offer_test_external_master_starter.sh -/test/offer_tests/offer_test_big_sd_msg_master_starter.sh -/test/offer_tests/offer_test_big_sd_msg_master.json -/test/offer_tests/offer_test_big_sd_msg_slave.json -/test/subscribe_notify_tests/subscribe_notify_test_diff_client_ids_diff_ports_autoconfig_master.json -/test/subscribe_notify_tests/subscribe_notify_test_diff_client_ids_diff_ports_autoconfig_slave.json -test/security_tests/security_test_config_client_external_allow.json -test/security_tests/security_test_config_client_external_deny.json -test/security_tests/security_test_config_service_external_allow.json -test/security_tests/security_test_config_service_external_deny.json -test/security_tests/security_test_local_config.json -/test/pending_subscription_tests/pending_subscription_test_master.json -/test/pending_subscription_tests/pending_subscription_test_master_starter.sh -/test/malicious_data_tests/malicious_data_test_master.json -/test/malicious_data_tests/malicious_data_test_master_starter.sh -/test/debug_diag_job_plugin_tests/debug_diag_job_plugin_test_master.json -/test/debug_diag_job_plugin_tests/debug_diag_job_plugin_test_slave.json -/test/security_config_plugin_tests/security_config_plugin_test_local.json -/test/e2e_tests/e2e_test_client_external.json -/test/e2e_tests/e2e_test_service_external.json -/test/event_tests/event_test_master.json -/test/event_tests/event_test_slave_tcp.json -/test/event_tests/event_test_slave_udp.json +/test/network_tests/initial_event_tests/initial_event_test_diff_client_ids_diff_ports_master.json +/test/network_tests/initial_event_tests/initial_event_test_diff_client_ids_diff_ports_same_service_id_master.json +/test/network_tests/initial_event_tests/initial_event_test_diff_client_ids_diff_ports_same_service_id_slave.json +/test/network_tests/initial_event_tests/initial_event_test_diff_client_ids_diff_ports_slave.json +/test/network_tests/initial_event_tests/initial_event_test_diff_client_ids_partial_same_ports_master.json +/test/network_tests/initial_event_tests/initial_event_test_diff_client_ids_partial_same_ports_slave.json +/test/network_tests/initial_event_tests/initial_event_test_diff_client_ids_same_ports_master.json +/test/network_tests/initial_event_tests/initial_event_test_diff_client_ids_same_ports_slave.json +/test/network_tests/initial_event_tests/initial_event_test_same_client_ids_diff_ports_master.json +/test/network_tests/initial_event_tests/initial_event_test_same_client_ids_diff_ports_slave.json +/test/network_tests/initial_event_tests/initial_event_test_same_client_ids_same_ports_master.json +/test/network_tests/initial_event_tests/initial_event_test_same_client_ids_same_ports_slave.json +/test/network_tests/initial_event_tests/initial_event_test_diff_client_ids_diff_ports_master_tcp.json +/test/network_tests/initial_event_tests/initial_event_test_diff_client_ids_diff_ports_slave_tcp.json +/test/network_tests/initial_event_tests/initial_event_test_diff_client_ids_same_ports_master_tcp.json +/test/network_tests/initial_event_tests/initial_event_test_diff_client_ids_same_ports_slave_tcp.json +/test/network_tests/initial_event_tests/initial_event_test_diff_client_ids_diff_ports_master_udp.json +/test/network_tests/initial_event_tests/initial_event_test_diff_client_ids_diff_ports_slave_udp.json +/test/network_tests/initial_event_tests/initial_event_test_diff_client_ids_same_ports_master_udp.json +/test/network_tests/initial_event_tests/initial_event_test_diff_client_ids_same_ports_slave_udp.json +/test/network_tests/offer_tests/offer_test_external_master.json +/test/network_tests/offer_tests/offer_test_external_slave.json +/test/network_tests/offer_tests/offer_test_external_master_starter.sh +/test/network_tests/offer_tests/offer_test_big_sd_msg_master_starter.sh +/test/network_tests/offer_tests/offer_test_big_sd_msg_master.json +/test/network_tests/offer_tests/offer_test_big_sd_msg_slave.json +/test/network_tests/subscribe_notify_tests/subscribe_notify_test_diff_client_ids_diff_ports_autoconfig_master.json +/test/network_tests/subscribe_notify_tests/subscribe_notify_test_diff_client_ids_diff_ports_autoconfig_slave.json +/test/network_tests/security_tests/security_test_config_client_external_allow.json +/test/network_tests/security_tests/security_test_config_client_external_deny.json +/test/network_tests/security_tests/security_test_config_service_external_allow.json +/test/network_tests/security_tests/security_test_config_service_external_deny.json +/test/network_tests/security_tests/security_test_local_config.json +/test/network_tests/pending_subscription_tests/pending_subscription_test_master.json +/test/network_tests/pending_subscription_tests/pending_subscription_test_master_starter.sh +/test/network_tests/malicious_data_tests/malicious_data_test_master.json +/test/network_tests/malicious_data_tests/malicious_data_test_master_starter.sh +/test/network_tests/e2e_tests/e2e_profile_04_test_client_external.json +/test/network_tests/e2e_tests/e2e_profile_04_test_service_external.json +/test/network_tests/e2e_tests/e2e_test_client_external.json +/test/network_tests/e2e_tests/e2e_test_service_external.json +/test/network_tests/event_tests/event_test_master.json +/test/network_tests/event_tests/event_test_slave_tcp.json +/test/network_tests/event_tests/event_test_slave_udp.json +/test/network_tests/npdu_tests/npdu_test_client_no_npdu.json +/test/network_tests/npdu_tests/npdu_test_client_npdu.json +/test/network_tests/npdu_tests/npdu_test_service_no_npdu.json +/test/network_tests/npdu_tests/npdu_test_service_npdu.json +/test/network_tests/someip_tp_tests/someip_tp_test_master.json +/test/network_tests/someip_tp_tests/someip_tp_test_master_starter.sh +/test/network_tests/second_address_tests/second_address_test_master_service_udp.json +/test/network_tests/second_address_tests/second_address_test_master_client.json +/test/network_tests/second_address_tests/second_address_test_slave_client.json +/test/network_tests/second_address_tests/second_address_test_slave_service_udp.json +/test/network_tests/second_address_tests/second_address_test_slave_starter.sh +/test/network_tests/debounce_tests/debounce_test_client.json +/test/network_tests/debounce_tests/debounce_test_service.json +/test/network_tests/debounce_filter_tests/debounce_filter_test_client.json +/test/network_tests/debounce_filter_tests/debounce_filter_test_service.json +/test/network_tests/suspend_resume_tests/suspend_resume_test_client.json +/test/network_tests/suspend_resume_tests/suspend_resume_test_service.json +/Testing !build_qnx/* diff --git a/Android.bp b/Android.bp index cfde41ef6..b4ece3279 100644 --- a/Android.bp +++ b/Android.bp @@ -80,7 +80,7 @@ cc_library_shared { cflags: [ "-DWITHOUT_SYSTEMD", - "-DVSOMEIP_COMPAT_VERSION=\"3.3.8\"", + "-DVSOMEIP_COMPAT_VERSION=\"3.4.9\"", "-DVSOMEIP_BASE_PATH=\"/vendor/run/someip/\"", "-DUSE_DLT", ], diff --git a/Android.mk b/Android.mk index 55d773b28..57366a36b 100644 --- a/Android.mk +++ b/Android.mk @@ -100,7 +100,7 @@ LOCAL_CFLAGS := \ -frtti \ -fexceptions \ -DWITHOUT_SYSTEMD \ - -DVSOMEIP_VERSION=\"3.3.8\" \ + -DVSOMEIP_VERSION=\"3.4.9\" \ -DVSOMEIP_BASE_PATH=\"/vendor/run/someip/\" \ -Wno-unused-parameter \ -Wno-non-virtual-dtor \ @@ -147,7 +147,7 @@ LOCAL_CFLAGS := \ -frtti \ -fexceptions \ -DWITHOUT_SYSTEMD \ - -DVSOMEIP_VERSION=\"3.3.8\" \ + -DVSOMEIP_VERSION=\"3.4.9\" \ -DVSOMEIP_BASE_PATH=\"/vendor/run/someip/\" \ -Wno-unused-parameter \ -Wno-non-virtual-dtor \ @@ -194,8 +194,8 @@ LOCAL_CFLAGS := \ -frtti \ -fexceptions \ -DWITHOUT_SYSTEMD \ - -DVSOMEIP_VERSION=\"3.3.8\" \ - -DVSOMEIP_COMPAT_VERSION=\"3.3.8\" \ + -DVSOMEIP_VERSION=\"3.4.9\" \ + -DVSOMEIP_COMPAT_VERSION=\"3.4.9\" \ -DVSOMEIP_BASE_PATH=\"/vendor/run/someip/\" \ -Wno-unused-parameter \ -Wno-non-virtual-dtor \ diff --git a/CHANGES b/CHANGES index 791786444..0db219b46 100644 --- a/CHANGES +++ b/CHANGES @@ -1,5 +1,71 @@ Changes ======= + +v3.4.9 +- Merge COVESA PR447 with support for QNX 7.1 +- Merge COVESA PR470 with changes to not instantiate +a non existent type for boost < 1.66.0 +- Merge COVESA PR515 with changes that remove not used lines + +v3.4.8 +- Adds debounce_filter_tests json files to gitignore +- Adds check for null serviceinfo +- Implementation of debounce frequency test +- Accept malformed StopSubscribe/Subscribe messages +- security: Fix security library name +- Also remove service instance from map of pending offers +- enforce lock acquisition order to avoid LOI +- Improved logs + +v3.4.7 +- Do _NOT_ try to serialize empty names +- Avoid crash on access to invalid position from tcp_endpoint buffer +- Fix security library name +- revert std::move usage in train buffer's +- Fix deadlock in mutex_ + +v3.4.6 +- check if a policy exist in the vector of policies +- Crash in process vsomeipd crash id: D8DF38B19EEBC79D +- Enable guest port configuration per uid/gid + +v3.4.5 +- Implementation of new debounce filter test +- test availability when double offering service +- network test fixes +- Try to synchronize subscribe/unsubscribe/resubscribe +- Add vsomeip_portcfg.json to the list of mandatory configuration files +- Check buffer before accessing it +- Rework condition for starting the send operation for client endpoint +- Avoid spamming the log +- Extend security interface to enable syncing security clients +- Revert get_local_port() behaviour + +v3.4.4.1 +- manually reset tables for unavailable services on suspend state + +v3.4.4 +- Fix deadlock if binding of UDP client endpoint fails +- Changed local_tcp_client endpoint connect to async connect. +- Change shutdown sequence +- vSomeIP Security: Update vsomeip_sec + +v3.4.3 +- Fixed race between incoming subscription and StopOffer/Offer + +v3.4.2 +- Removed local_port_ attribute + +v3.4.1 +- Rename the new "register_message_handler" overload function +- Set the Client identifier when sending pong command + +v3.4.0 +- Allow to register multiple message handlers for the same message +- load_security_policy_extensions Unit and Benchmark Tests +- Fix is_local flag for acl acceptance msg +- Fix registration issues regarding connecting timeout + v3.3.8 - Check buffer size when serializing/deserializing event registrations - Remove leftovers from shm usage diff --git a/CMakeLists.txt b/CMakeLists.txt index 363500996..d885ea1a8 100644 --- a/CMakeLists.txt +++ b/CMakeLists.txt @@ -1,4 +1,4 @@ -# Copyright (C) 2015-2017 Bayerische Motoren Werke Aktiengesellschaft (BMW AG) +# Copyright (C) 2015-2023 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/. @@ -10,9 +10,9 @@ set (VSOMEIP_NAME vsomeip3) set (VSOMEIP_COMPAT_NAME vsomeip) set (VSOMEIP_MAJOR_VERSION 3) -set (VSOMEIP_MINOR_VERSION 3) -set (VSOMEIP_PATCH_VERSION 8) -set (VSOMEIP_HOTFIX_VERSION 0) +set (VSOMEIP_MINOR_VERSION 4) +set (VSOMEIP_PATCH_VERSION 9) +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 @@ -68,7 +68,7 @@ if (${CMAKE_SYSTEM_NAME} MATCHES "Linux") if (CMAKE_CXX_COMPILER_ID STREQUAL "GNU") # This is only relevant for GCC and causes warnings on Clang set(EXPORTSYMBOLS "-Wl,-export-dynamic -Wl,--version-script=${CMAKE_CURRENT_SOURCE_DIR}/exportmap.gcc") - set(OS_CXX_FLAGS "${OS_CXX_FLAGS} -pie -Wl,-z,relro,-z,now") + set(OS_CXX_FLAGS "${OS_CXX_FLAGS} -pie -Wno-tsan -Wl,-z,relro,-z,now") endif() set(NO_DEPRECATED "") @@ -412,19 +412,36 @@ endif() if (BASE_PATH) set (VSOMEIP_BASE_PATH ${BASE_PATH}) endif () + set (VSOMEIP_DIAGNOSIS_ADDRESS "0x01") if (DIAGNOSIS_ADDRESS) set (VSOMEIP_DIAGNOSIS_ADDRESS ${DIAGNOSIS_ADDRESS}) endif () + set (VSOMEIP_UNICAST_ADDRESS "127.0.0.1") if (UNICAST_ADDRESS) set (VSOMEIP_UNICAST_ADDRESS ${UNICAST_ADDRESS}) endif () + set (VSOMEIP_ROUTING_READY_MESSAGE "SOME/IP routing ready.") if (ROUTING_READY_MESSAGE) set (VSOMEIP_ROUTING_READY_MESSAGE ${ROUTING_READY_MESSAGE}) endif () +set (VSOMEIP_LOCAL_TCP_PORT_WAIT_TIME 100) +if (LOCAL_TCP_PORT_WAIT_TIME) +set (VSOMEIP_LOCAL_TCP_PORT_WAIT_TIME ${LOCAL_TCP_PORT_WAIT_TIME}) +endif () + +set (VSOMEIP_LOCAL_TCP_PORT_MAX_WAIT_TIME 10000) +if (LOCAL_TCP_PORT_MAX_WAIT_TIME) +if (${LOCAL_TCP_PORT_MAX_WAIT_TIME} GREATER ${LOCAL_TCP_PORT_WAIT_TIME}) +set (VSOMEIP_LOCAL_TCP_PORT_MAX_WAIT_TIME ${LOCAL_TCP_PORT_MAX_WAIT_TIME}) +else () +set (VSOMEIP_LOCAL_TCP_PORT_MAX_WAIT_TIME ${LOCAL_TCP_PORT_WAIT_TIME}) +endif () +endif () + set(DEFAULT_CONFIGURATION_FOLDER "/etc/vsomeip" CACHE PATH "Default configuration folder") message(STATUS "Default configuration folder: ${DEFAULT_CONFIGURATION_FOLDER}") @@ -434,6 +451,9 @@ message(STATUS "Default configuration file: ${DEFAULT_CONFIGURATION_FILE}") message("Predefined base path: ${VSOMEIP_BASE_PATH}") message("Predefined unicast address: ${VSOMEIP_UNICAST_ADDRESS}") message("Predefined diagnosis address: ${VSOMEIP_DIAGNOSIS_ADDRESS}") +message("Predefined wait times for internal communication ports (TCP):\ + ${VSOMEIP_LOCAL_TCP_PORT_WAIT_TIME}\ + (max=${VSOMEIP_LOCAL_TCP_PORT_MAX_WAIT_TIME})") ################################################################################ # Installation @@ -632,126 +652,9 @@ add_subdirectory( tools ) add_custom_target( examples ) add_subdirectory( examples EXCLUDE_FROM_ALL ) -############################################################################## -# Test section -############################################################################## - -############################################################################## -# google benchmark -find_package(benchmark) - -############################################################################## -# google test - -# check for set environment variable -if(${GTEST_ROOT} STREQUAL "n/a") - message(STATUS "GTEST_ROOT is not defined. For building the tests the variable - GTEST_ROOT has to be defined. Tests can not be built.") - # early exit - return() # test can not be build -> make commands build_tests and check are not available -else() - message(STATUS "GTEST_ROOT is set. gtest root path set to ${GTEST_ROOT}") -endif() - -# build google test as static library (always) -> therefore deactivate BUILD_SHARED_LIBS in case it is active -set(BUILD_SHARED_LIBS_AUTOMATIC_OFF 0) -if ("${BUILD_SHARED_LIBS}" STREQUAL "ON") - set(BUILD_SHARED_LIBS OFF) - set(BUILD_SHARED_LIBS_AUTOMATIC_OFF 1) -endif() -add_subdirectory(${GTEST_ROOT} ${CMAKE_CURRENT_BINARY_DIR}/gtest EXCLUDE_FROM_ALL) -if ("${BUILD_SHARED_LIBS_AUTOMATIC_OFF}" STREQUAL "1") - set(BUILD_SHARED_LIBS ON) - set(BUILD_SHARED_LIBS_AUTOMATIC_OFF 0) -endif() - - - -############################################################################## -# build tests - -enable_testing() -SET(TESTS_BAT "OFF" CACHE BOOL - "Controls whether only BAT tests should be build or not") -SET(TEST_SYMLINK_CONFIG_FILES "OFF" CACHE BOOL - "Controls if the json and scripts needed needed to run the tests are copied or symlinked into the build directroy (ignored on Windows)") -SET(TEST_SYMLINK_CONFIG_FILES_RELATIVE "OFF" CACHE BOOL - "Controls if the json and scripts needed needed to run the tests are symlinked relatively into the build directroy (ignored on Windows)") - -SET(TEST_IP_DEFAULT_VALUE "XXX.XXX.XXX.XXX") -SET(TEST_IP_MASTER "${TEST_IP_DEFAULT_VALUE}" CACHE STRING - "The IP address of the interface which will act as test master") -SET(TEST_IP_SLAVE "${TEST_IP_DEFAULT_VALUE}" CACHE STRING - "The IP address of the interface which will act as test slave") - -if((${TEST_IP_MASTER} STREQUAL ${TEST_IP_DEFAULT_VALUE}) OR - (${TEST_IP_SLAVE} STREQUAL ${TEST_IP_DEFAULT_VALUE})) - message(WARNING "TEST_IP_MASTER and/or TEST_IP_SLAVE isn't set. " - "Remote tests cannot be run. " - "To enable, please specify for example " - "-DTEST_IP_MASTER=10.0.3.1 -DTEST_IP_SLAVE=10.0.3.2") -endif() - -SET(TEST_IP_SLAVE_SECOND "${TEST_IP_DEFAULT_VALUE}" CACHE STRING - "The second IP address of the interface which will act as test slave") -set(TEST_SECOND_ADDRESS "OFF" CACHE BOOL - "Controls whether second address tests should run or not") - -if(${TEST_IP_SLAVE_SECOND} STREQUAL ${TEST_IP_DEFAULT_VALUE}) - message(WARNING "TEST_IP_SLAVE_SECOND isn't set. " - "Test with more than one IP address on same interface is not enabled." - "Please specify them via for example " - "-TEST_IP_SLAVE_SECOND=10.0.3.126") -else() - set(TEST_SECOND_ADDRESS "ON") -endif() - -set(TEST_E2E_PROFILE_04 "ON") - -SET(TEST_UID_DEFAULT_VALUE "123456789") -SET(TEST_UID "${TEST_UID_DEFAULT_VALUE}" CACHE STRING - "The User ID of the user running the test: Needed for security") -SET(TEST_GID_DEFAULT_VALUE "123456789") -SET(TEST_GID "${TEST_GID_DEFAULT_VALUE}" CACHE STRING - "The Group ID of the user running the test: Needed for security") - -SET(TEST_SECURITY "ON" CACHE BOOL - "Controls whether security tests should run or not") - -if((${TEST_UID} STREQUAL ${TEST_UID_DEFAULT_VALUE}) OR - (${TEST_GID} STREQUAL ${TEST_GID_DEFAULT_VALUE}) OR - DISABLE_SECURITY) - message(WARNING "TEST_UID and/or TEST_GID isn't set. " - "Security Tests are not runnable " - "Please specify them for example " - "-DTEST_UID=1000 -DTEST_GID=1000") - SET(TEST_SECURITY "OFF") -endif() - -add_custom_target(build_tests) - -set(CMAKE_CTEST_COMMAND ctest -V) -add_custom_target(check COMMAND ${CMAKE_CTEST_COMMAND}) -add_dependencies(check build_tests) - -add_custom_target(build_network_tests) -add_dependencies(build_network_tests ${VSOMEIP_NAME}) -add_dependencies(build_network_tests ${VSOMEIP_NAME}-e2e) -add_dependencies(build_network_tests ${VSOMEIP_NAME}-sd) -add_dependencies(build_tests build_network_tests) - -add_custom_target(build_unit_tests) -add_dependencies(build_unit_tests ${VSOMEIP_NAME}) -add_dependencies(build_unit_tests ${VSOMEIP_NAME}-sd) -add_dependencies(build_tests build_unit_tests) - -add_custom_target(build_benchmark_tests) -add_dependencies(build_benchmark_tests ${VSOMEIP_NAME}) -add_dependencies(build_benchmark_tests ${VSOMEIP_NAME}-sd) -add_dependencies(build_tests build_benchmark_tests) - ############################################################################## # add test directory +enable_testing() add_subdirectory( test EXCLUDE_FROM_ALL ) diff --git a/build_qnx/common.mk b/build_qnx/common.mk index 387937467..12dacf8fc 100644 --- a/build_qnx/common.mk +++ b/build_qnx/common.mk @@ -50,7 +50,8 @@ CMAKE_ARGS = -DCMAKE_TOOLCHAIN_FILE=$(PROJECT_ROOT)/qnx.nto.toolchain.cmake \ -DINSTALL_INCLUDE_DIR=$(VSOMEIP_INSTALL_ROOT)/usr/include \ -DCPUVARDIR=$(CPUVARDIR) \ -DGCC_VER=${GCC_VER} \ - -DVSOMEIP_INSTALL_ROUTINGMANAGERD=ON + -DVSOMEIP_INSTALL_ROUTINGMANAGERD=ON \ + -DDISABLE_DLT=y ifeq ($(GENERATE_TESTS), TRUE) CMAKE_ARGS += -DENABLE_SIGNAL_HANDLING=1 \ diff --git a/config/vsomeip-local-security.json b/config/vsomeip-local-security.json index 0f8096f80..aa3e0912e 100644 --- a/config/vsomeip-local-security.json +++ b/config/vsomeip-local-security.json @@ -1,19 +1,19 @@ { "unicast" : "10.0.3.1", "logging" : - { + { "level" : "info", "console" : "true", "file" : { "enable" : "false", "path" : "/tmp/vsomeip.log" }, "dlt" : "false" }, - "applications" : + "applications" : [ { "name" : "service-sample", "id" : "0x1277" }, - { + { "name" : "client-sample", "id" : "0x1344" } diff --git a/config/vsomeip-local-tcp-client.json b/config/vsomeip-local-tcp-client.json index 863356fbf..28e1a0c45 100644 --- a/config/vsomeip-local-tcp-client.json +++ b/config/vsomeip-local-tcp-client.json @@ -1,7 +1,7 @@ { "unicast" : "192.168.56.101", "netmask" : "255.255.255.0", - "logging" : + "logging" : { "level" : "info", "console" : "true", @@ -27,14 +27,14 @@ "id" : "0x1346" } ], - "services" : + "services" : [ { "service" : "0x1234", "instance" : "0x5678", "unicast" : "192.168.56.102", "reliable" : { "port" : "30509", "magic-cookies" : false }, - "events" : + "events" : [ { "event" : "0x0777", @@ -53,15 +53,15 @@ [ { "eventgroup" : "0x4455", - "events" : [ "0x777", "0x778" ] + "events" : [ "0x777", "0x778" ] }, { "eventgroup" : "0x4465", - "events" : [ "0x778", "0x779" ] + "events" : [ "0x778", "0x779" ] }, { "eventgroup" : "0x4555", - "events" : [ "0x777", "0x779" ] + "events" : [ "0x777", "0x779" ] } ] } diff --git a/config/vsomeip-local-tcp-service.json b/config/vsomeip-local-tcp-service.json index 621d09914..e3f0e81df 100644 --- a/config/vsomeip-local-tcp-service.json +++ b/config/vsomeip-local-tcp-service.json @@ -1,13 +1,13 @@ { "unicast" : "192.168.56.102", "logging" : - { + { "level" : "debug", "console" : "true", "file" : { "enable" : "false", "path" : "/tmp/vsomeip.log" }, "dlt" : "false" }, - "applications" : + "applications" : [ { "name" : "service-sample", @@ -20,7 +20,7 @@ "service" : "0x1234", "instance" : "0x5678", "reliable" : { "port" : "30509", "magic-cookies" : "false" }, - "events" : + "events" : [ { "event" : "0x0777", @@ -52,7 +52,7 @@ }, { "eventgroup" : "0x4555", - "events" : [ "0x777", "0x779" ] + "events" : [ "0x777", "0x779" ] } ] } diff --git a/config/vsomeip-local-tracing.json b/config/vsomeip-local-tracing.json index ba3a6bf98..e8497a6e0 100644 --- a/config/vsomeip-local-tracing.json +++ b/config/vsomeip-local-tracing.json @@ -1,7 +1,7 @@ { "unicast" : "10.0.2.15", "logging" : - { + { "level" : "debug", "console" : "true", "file" : { "enable" : "false", "path" : "/tmp/vsomeip.log" }, @@ -11,13 +11,13 @@ { "enable" : "true" }, - "applications" : + "applications" : [ { "name" : "service-sample", "id" : "0x1277" }, - { + { "name" : "client-sample", "id" : "0x1344" } @@ -28,12 +28,12 @@ "service" : "0x1234", "instance" : "0x5678", "unreliable" : "30509", - "multicast" : - { - "address" : "224.225.226.233", + "multicast" : + { + "address" : "224.225.226.233", "port" : "32344" }, - "events" : + "events" : [ { "event" : "0x0777", @@ -59,11 +59,11 @@ { "eventgroup" : "0x4465", "events" : [ "0x778", "0x779" ], - "is_multicast" : "true" + "is_multicast" : "true" }, { "eventgroup" : "0x4555", - "events" : [ "0x777", "0x779" ] + "events" : [ "0x777", "0x779" ] } ] } diff --git a/config/vsomeip-local.json b/config/vsomeip-local.json index 967a9affa..6edc8c02d 100644 --- a/config/vsomeip-local.json +++ b/config/vsomeip-local.json @@ -1,19 +1,19 @@ { "unicast" : "10.0.2.15", "logging" : - { + { "level" : "debug", "console" : "true", "file" : { "enable" : "false", "path" : "/tmp/vsomeip.log" }, "dlt" : "false" }, - "applications" : + "applications" : [ { "name" : "service-sample", "id" : "0x1277" }, - { + { "name" : "client-sample", "id" : "0x1344" } @@ -24,12 +24,12 @@ "service" : "0x1234", "instance" : "0x5678", "unreliable" : "30509", - "multicast" : - { - "address" : "224.225.226.233", + "multicast" : + { + "address" : "224.225.226.233", "port" : "32344" }, - "events" : + "events" : [ { "event" : "0x0777", @@ -55,11 +55,11 @@ { "eventgroup" : "0x4465", "events" : [ "0x778", "0x779" ], - "is_multicast" : "true" + "is_multicast" : "true" }, { "eventgroup" : "0x4555", - "events" : [ "0x777", "0x779" ] + "events" : [ "0x777", "0x779" ] } ] } diff --git a/config/vsomeip-tcp-client-security.json b/config/vsomeip-tcp-client-security.json index 4a3f65beb..a9701346c 100644 --- a/config/vsomeip-tcp-client-security.json +++ b/config/vsomeip-tcp-client-security.json @@ -1,7 +1,7 @@ { "unicast" : "10.0.3.28", "netmask" : "255.255.255.0", - "logging" : + "logging" : { "level" : "info", "console" : "true", diff --git a/config/vsomeip-tcp-client.json b/config/vsomeip-tcp-client.json index 65b8189b3..0431468af 100644 --- a/config/vsomeip-tcp-client.json +++ b/config/vsomeip-tcp-client.json @@ -1,7 +1,7 @@ { "unicast" : "192.168.56.101", "netmask" : "255.255.255.0", - "logging" : + "logging" : { "level" : "info", "console" : "true", diff --git a/config/vsomeip-tcp-service-security.json b/config/vsomeip-tcp-service-security.json index d1a852126..979bbf04c 100644 --- a/config/vsomeip-tcp-service-security.json +++ b/config/vsomeip-tcp-service-security.json @@ -1,13 +1,13 @@ { "unicast" : "10.0.3.1", "logging" : - { + { "level" : "debug", "console" : "true", "file" : { "enable" : "false", "path" : "/tmp/vsomeip.log" }, "dlt" : "false" }, - "applications" : + "applications" : [ { "name" : "service-sample", @@ -25,9 +25,9 @@ "service" : "0x1235", "instance" : "0x5678", "unreliable" : "30509", - "multicast" : - { - "address" : "224.225.226.234", + "multicast" : + { + "address" : "224.225.226.234", "port" : "32344" } } diff --git a/config/vsomeip-tcp-service.json b/config/vsomeip-tcp-service.json index a2445eef2..f3bf47418 100644 --- a/config/vsomeip-tcp-service.json +++ b/config/vsomeip-tcp-service.json @@ -1,13 +1,13 @@ { "unicast" : "192.168.56.101", "logging" : - { + { "level" : "debug", "console" : "true", "file" : { "enable" : "false", "path" : "/tmp/vsomeip.log" }, "dlt" : "false" }, - "applications" : + "applications" : [ { "name" : "service-sample", @@ -20,7 +20,7 @@ "service" : "0x1234", "instance" : "0x5678", "reliable" : { "port" : "30509", "enable-magic-cookies" : "false" }, - "events" : + "events" : [ { "event" : "0x8777", @@ -52,7 +52,7 @@ }, { "eventgroup" : "0x4555", - "events" : [ "0x8777", "0x8779" ] + "events" : [ "0x8777", "0x8779" ] } ] }, @@ -60,9 +60,9 @@ "service" : "0x1235", "instance" : "0x5678", "unreliable" : "30509", - "multicast" : - { - "address" : "224.225.226.234", + "multicast" : + { + "address" : "224.225.226.234", "port" : "32344" } } diff --git a/config/vsomeip-udp-client-security.json b/config/vsomeip-udp-client-security.json index eec9613da..020c9a0e8 100644 --- a/config/vsomeip-udp-client-security.json +++ b/config/vsomeip-udp-client-security.json @@ -1,7 +1,7 @@ { "unicast" : "10.0.3.28", "netmask" : "255.255.255.0", - "logging" : + "logging" : { "level" : "debug", "console" : "true", diff --git a/config/vsomeip-udp-client.json b/config/vsomeip-udp-client.json index 47ffb2693..0f3bcf0fd 100644 --- a/config/vsomeip-udp-client.json +++ b/config/vsomeip-udp-client.json @@ -1,7 +1,7 @@ { "unicast" : "192.168.56.101", "netmask" : "255.255.255.0", - "logging" : + "logging" : { "level" : "debug", "console" : "true", diff --git a/config/vsomeip-udp-service-security.json b/config/vsomeip-udp-service-security.json index 8dcff8e52..be86b9460 100644 --- a/config/vsomeip-udp-service-security.json +++ b/config/vsomeip-udp-service-security.json @@ -1,13 +1,13 @@ { "unicast" : "10.0.3.1", "logging" : - { + { "level" : "debug", "console" : "true", "file" : { "enable" : "false", "path" : "/tmp/vsomeip.log" }, "dlt" : "false" }, - "applications" : + "applications" : [ { "name" : "service-sample", @@ -25,9 +25,9 @@ "service" : "0x1235", "instance" : "0x5678", "unreliable" : "30509", - "multicast" : - { - "address" : "224.225.226.234", + "multicast" : + { + "address" : "224.225.226.234", "port" : "32344" } } diff --git a/config/vsomeip-udp-service.json b/config/vsomeip-udp-service.json index 6850a7f3d..728dd75d4 100644 --- a/config/vsomeip-udp-service.json +++ b/config/vsomeip-udp-service.json @@ -1,13 +1,13 @@ { "unicast" : "192.168.56.101", "logging" : - { + { "level" : "debug", "console" : "true", "file" : { "enable" : "false", "path" : "/tmp/vsomeip.log" }, "dlt" : "false" }, - "applications" : + "applications" : [ { "name" : "service-sample", @@ -20,7 +20,7 @@ "service" : "0x1234", "instance" : "0x5678", "unreliable" : "30509", - "events" : + "events" : [ { "event" : "0x8777", @@ -47,15 +47,15 @@ { "eventgroup" : "0x4465", "events" : [ "0x8778", "0x8779" ], - "multicast" : - { - "address" : "224.225.226.233", + "multicast" : + { + "address" : "224.225.226.233", "port" : "32344" } }, { "eventgroup" : "0x4555", - "events" : [ "0x8777", "0x8779" ] + "events" : [ "0x8777", "0x8779" ] } ] }, @@ -63,9 +63,9 @@ "service" : "0x1235", "instance" : "0x5678", "unreliable" : "30509", - "multicast" : - { - "address" : "224.225.226.234", + "multicast" : + { + "address" : "224.225.226.234", "port" : "32344" } } diff --git a/config/vsomeip.json b/config/vsomeip.json index b119c07ff..53b977df4 100644 --- a/config/vsomeip.json +++ b/config/vsomeip.json @@ -7,7 +7,7 @@ "file" : { "enable" : "false", "path" : "/var/log/vsomeip.log" }, "dlt" : "false" }, - "applications" : + "applications" : [ { "name" : "client-sample", @@ -20,7 +20,7 @@ { "name" : "service-sample", "id" : "0x1277" - } + } ], "services" : [ diff --git a/documentation/vsomeipUserGuide b/documentation/vsomeipUserGuide index b98183a5c..facc942ac 100644 --- a/documentation/vsomeipUserGuide +++ b/documentation/vsomeipUserGuide @@ -124,6 +124,23 @@ cmake -DDEFAULT_CONFIGURATION_FILE= .. ---- The default configuration file is /etc/vsomeip.json. +Compilation with changed (maximimum) wait times for local TCP ports +^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ +If local communication is done via TCP, we depend on the availability +of the network. Therefore, server port creation and therefore port +assignment might fail. If the failure is causes by the port already +being in use, we use the next available port. For all other failure, +we wait for a wait time until we retry with the same port. If the +overall wait time of all retries exceeds the maximum wait time, +the endpoint creation is aborted. To configure wait time and maximum +wait time, call cmake with: +[source,bash] +----- +cmake -DLOCAL_TCP_PORT_WAIT_TIME=50 -DLOCAL_TCP_PORT_MAX_WAIT_TIME=2000 .. +----- +The default values are a wait time of 100ms and a maximum wait time of 10000ms. +These configurations have no effect if local communication uses UDS (default). + Compilation with signal handling ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ To compile vsomeip with signal handling (SIGINT/SIGTERM) enabled, @@ -1010,10 +1027,34 @@ The unicast address that shall be used by the applications to connect to the rou *** `ports` + -A set of port ranges that shall be used to connect to the routing manager. Each client application requires -two ports, one for receiving messages from other applications and one to send messages to other applications. -Notes: Each configured port range must contain an even number of ports. If an even port number is configured -to be the routing host port, the first port in the range must also be even. If an uneven port number is +A set of port ranges that shall be used to connect to the routing manager per user identifier/group identifier. +Either specify uid, gid and ranges, or only a set of port ranges. If uid and gid are not explicitly specified, +they default to any. Each client application requires two ports, one for receiving messages from other +applications and one to send messages to other applications. ++ +**** `uid` ++ +User identifier + +**** `gid` ++ +Group identifier + +**** `ranges` ++ +Set of port ranges. Each entry consists of a `first`, `last` pair that determines the first and the last port +of a port range. ++ +***** `first` ++ +First port of a port range ++ +***** `last` ++ +Last port of a port range ++ +NOTE: Each configured port range must contain an even number of ports. If an even port number is configured +to be the routing host port, the first port in the range must also be even. If an uneven port number is configured to be the routing host port, the first port in the range must also be uneven. * `routing-credentials` (deprecated) @@ -1146,6 +1187,51 @@ Time which the stack collects new service offers before they enter the repetition phase. This can be used to reduce the number of sent messages during startup. The default setting is _500ms_. + +//Suppress Event Logs ++ +* 'suppress_missing_event_logs' ++ +Used to filter the log message `deliver_notification: Event [1234.5678.80f3] +is not registered. The message is dropped.` that occurs whenever vSomeIP +receives an event without having a corresponding object being registered. + +[source, bash] +---- +... +"suppress_missing_event_logs" : +[ + { + "service" : "0x0023", + "instance" : "0x0001", + "events" : [ "0x8001", "0x8002", + { + "first" : "0x8010", + "last" : "0x801f" + }, + "0x8020" ] + }, + { + "service" : "0x0023", + "instance" : "0x0002", + "events" : [ "0x8005", "0x8006" ] + }, + { + "service" : "0x0023", + "instance" : "0x0002", + "events" : [ "0x8105", "0x8106" ] + }, + { + // no "events" --> ignore all(!) events of these services + "service" : "any", + "instance" : "0x00f2" + }, + { + "service" : "0x0102", + "instance" : "any", + "events" : [ "0x8005", "0x8006" ] + } +] + //Watchdog * anchor:config-watchdog[]`watchdog` (optional) + @@ -1210,7 +1296,11 @@ The available configuration switches for the security feature are: // Security * anchor:config-policy[]`security` (optional) + -If specified the credential passing mechanism is activated. However no credential or security checks are done as long as _check_credentials_ isn't set to _true_, but the routing manager client ID must be configured if security tag is specified and shall not be set to 0x6300. +NOTE: As long as no _security_ node exists, the security implementation is switched off. This also means, +no external security library will be loaded and used. ++ +If specified the credential passing mechanism is activated. However no credential or security checks are done as long as +_check_credentials_ isn't set to _true_, but the routing manager client ID must be configured if security tag is specified. If _check_credentials_ is set to _true_, the routing managers UID and GID needs to be specified using _routing-credentials_ tag. ** `check_credentials` (optional) @@ -1454,7 +1544,8 @@ Specifies the linux hostname. + Specifies a filesystem path (relative to vsomeip_policy_extensions.json or absolute) which contains $UID_$GID subfolders that hold a `vsomeip_security.json` file. -Note: ($UID / $GID is the UID /GID of the vsomeip client application ++ +NOTE: ($UID / $GID is the UID /GID of the vsomeip client application to which a client from hostname defined with `container`connetcs to. diff --git a/examples/routingmanagerd/CMakeLists.txt b/examples/routingmanagerd/CMakeLists.txt index dbdbd4a7a..e8a2397fc 100644 --- a/examples/routingmanagerd/CMakeLists.txt +++ b/examples/routingmanagerd/CMakeLists.txt @@ -1,4 +1,4 @@ -# Copyright (C) 2015-2017 Bayerische Motoren Werke Aktiengesellschaft (BMW AG) +# Copyright (C) 2015-2023 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/. diff --git a/exportmap.gcc b/exportmap.gcc index 8e8b99ba6..5939e6c4c 100644 --- a/exportmap.gcc +++ b/exportmap.gcc @@ -46,6 +46,7 @@ global: *vsomeip_v3::utility; vsomeip_v3::utility::is*; vsomeip_v3::utility::data*; + vsomeip_v3::utility::re*; *vsomeip_v3::plugin_manager; vsomeip_v3::plugin_manager::*; vsomeip_v3::tp::tp_reassembler::*; diff --git a/implementation/configuration/include/configuration.hpp b/implementation/configuration/include/configuration.hpp index b93cb3a2d..8b32a0c99 100644 --- a/implementation/configuration/include/configuration.hpp +++ b/implementation/configuration/include/configuration.hpp @@ -90,7 +90,8 @@ class configuration { virtual port_t get_routing_host_port() const = 0; virtual const boost::asio::ip::address &get_routing_guest_address() const = 0; - virtual std::set > get_routing_guest_ports() const = 0; + virtual std::set > get_routing_guest_ports( + uid_t _uid, gid_t _gid) const = 0; virtual bool is_local_routing() const = 0; @@ -270,6 +271,9 @@ class configuration { virtual bool check_routing_credentials(client_t _client, const vsomeip_sec_client_t *_sec_client) const = 0; + virtual bool check_suppress_events(service_t _service, + instance_t _instance, event_t _event) const = 0; + // SOME/IP-TP virtual bool is_tp_client( service_t _service, const std::string &_address, std::uint16_t _port, @@ -302,6 +306,7 @@ class configuration { // security virtual bool is_security_enabled() const = 0; + virtual bool is_security_external() const = 0; virtual bool is_security_audit() const = 0; virtual bool is_remote_access_allowed() const = 0; }; diff --git a/implementation/configuration/include/configuration_impl.hpp b/implementation/configuration/include/configuration_impl.hpp index 44987fcfb..f30e0ecf5 100644 --- a/implementation/configuration/include/configuration_impl.hpp +++ b/implementation/configuration/include/configuration_impl.hpp @@ -6,6 +6,7 @@ #ifndef VSOMEIP_V3_CFG_CONFIGURATION_IMPL_HPP #define VSOMEIP_V3_CFG_CONFIGURATION_IMPL_HPP +#include #include #include #include @@ -37,6 +38,25 @@ struct event; struct eventgroup; struct watchdog; +struct suppress_t { + service_t service; + instance_t instance; + event_t event; + + inline bool operator<(const suppress_t& entry_) const { + if(service != entry_.service) { + return service < entry_.service; + } + if(instance != entry_.instance) { + return instance < entry_.instance; + } + if(event != entry_.event) { + return event < entry_.event; + } + return false; + } +}; + class configuration_impl: public configuration, public std::enable_shared_from_this { @@ -112,7 +132,8 @@ class configuration_impl: VSOMEIP_EXPORT port_t get_routing_host_port() const; VSOMEIP_EXPORT const boost::asio::ip::address &get_routing_guest_address() const; - VSOMEIP_EXPORT std::set > get_routing_guest_ports() const; + VSOMEIP_EXPORT std::set > get_routing_guest_ports( + uid_t _uid, gid_t _gid) const; VSOMEIP_EXPORT client_t get_id(const std::string &_name) const; VSOMEIP_EXPORT bool is_configured_client_id(client_t _id) const; @@ -186,6 +207,9 @@ class configuration_impl: VSOMEIP_EXPORT bool check_routing_credentials(client_t _client, const vsomeip_sec_client_t *_sec_client) const; + VSOMEIP_EXPORT bool check_suppress_events(service_t _service, + instance_t _instance, event_t _event) const; + VSOMEIP_EXPORT std::map> get_plugins( const std::string &_name) const; // E2E @@ -269,6 +293,7 @@ class configuration_impl: const uint16_t &_unreliable_port) const; VSOMEIP_EXPORT bool is_security_enabled() const; + VSOMEIP_EXPORT bool is_security_external() const; VSOMEIP_EXPORT bool is_security_audit() const; VSOMEIP_EXPORT bool is_remote_access_allowed() const; @@ -311,6 +336,8 @@ class configuration_impl: const std::string &_name); bool load_routing_guests(const boost::property_tree::ptree &_tree); void load_routing_guest_ports(const boost::property_tree::ptree &_tree); + std::set > load_routing_guest_port_range( + const boost::property_tree::ptree &_tree) const; bool load_routing_credentials(const configuration_element &_element); // compatibility void load_routing_client_ports(const configuration_element &_element); // compatibility @@ -328,6 +355,18 @@ class configuration_impl: const boost::property_tree::ptree &_data, std::tuple &_match); + void load_suppress_events(const configuration_element &_element); + void load_suppress_events_data( + const boost::property_tree::ptree &_tree); + std::set load_suppress_multiple_events( + const boost::property_tree::ptree &_tree); + uint16_t load_suppress_data(const std::string &_value) const; + std::set load_range_events(event_t _first_event, + event_t _last_event) const ; + void insert_suppress_events(service_t _service, + instance_t _instance, event_t _event); + void print_suppress_events(void) const; + void load_network(const configuration_element &_element); void load_device(const configuration_element &_element); @@ -453,6 +492,7 @@ class configuration_impl: bool has_file_log_; bool has_dlt_log_; std::string logfile_; + mutable std::mutex mutex_loglevel_; vsomeip_v3::logger::level_e loglevel_; std::map< @@ -471,6 +511,9 @@ class configuration_impl: std::map>>> services_by_ip_port_; + std::set suppress_events_; + bool is_suppress_events_enabled_; + std::list< std::shared_ptr > clients_; routing_t routing_; @@ -628,9 +671,10 @@ class configuration_impl: > > plugins_additional_; - bool is_security_enabled_; - bool is_security_audit_; - bool is_remote_access_allowed_; + std::atomic_bool is_security_enabled_; + std::atomic_bool is_security_external_; + std::atomic_bool is_security_audit_; + std::atomic_bool is_remote_access_allowed_; }; } // namespace cfg diff --git a/implementation/configuration/include/internal.hpp.in b/implementation/configuration/include/internal.hpp.in index 02103bfe9..72c8d503e 100644 --- a/implementation/configuration/include/internal.hpp.in +++ b/implementation/configuration/include/internal.hpp.in @@ -1,4 +1,4 @@ -// Copyright (C) 2014-2021 Bayerische Motoren Werke Aktiengesellschaft (BMW AG) +// Copyright (C) 2014-2023 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/. @@ -23,7 +23,7 @@ #define VSOMEIP_DEFAULT_CONFIGURATION_FILE "@DEFAULT_CONFIGURATION_FILE@" #define VSOMEIP_LOCAL_CONFIGURATION_FILE "./vsomeip.json" -#define VSOMEIP_MANDATORY_CONFIGURATION_FILES "vsomeip_std.json,vsomeip_app.json,vsomeip_events.json,vsomeip_plc.json,vsomeip_log.json,vsomeip_security.json,vsomeip_whitelist.json,vsomeip_policy_extensions.json" +#define VSOMEIP_MANDATORY_CONFIGURATION_FILES "vsomeip_std.json,vsomeip_app.json,vsomeip_events.json,vsomeip_plc.json,vsomeip_log.json,vsomeip_security.json,vsomeip_whitelist.json,vsomeip_policy_extensions.json,vsomeip_portcfg.json" #define VSOMEIP_DEFAULT_CONFIGURATION_FOLDER "@DEFAULT_CONFIGURATION_FOLDER@" #define VSOMEIP_DEBUG_CONFIGURATION_FOLDER "/var/opt/public/sin/vsomeip/" @@ -52,9 +52,9 @@ #endif #ifdef _WIN32 -#define VSOMEIP_SEC_LIBRARY "vsomeip3-sec.dll" +#define VSOMEIP_SEC_LIBRARY "vsomeip_sec.dll" #else -#define VSOMEIP_SEC_LIBRARY "libvsomeip3-sec.so" +#define VSOMEIP_SEC_LIBRARY "libvsomeip-sec.so.1" #endif #define VSOMEIP_ROUTING_CLIENT 0 @@ -112,7 +112,10 @@ #define VSOMEIP_LOCAL_CLIENT_ENDPOINT_RECV_BUFFER_SIZE 19 #define VSOMEIP_MINIMUM_CHECK_TTL_TIMEOUT 100 -#define VSOMEIP_SETSOCKOPT_TIMEOUT_US 500000 // microseconds +#define VSOMEIP_SETSOCKOPT_TIMEOUT_US 500000 // us + +#define LOCAL_TCP_PORT_WAIT_TIME @VSOMEIP_LOCAL_TCP_PORT_WAIT_TIME@ +#define LOCAL_TCP_PORT_MAX_WAIT_TIME @VSOMEIP_LOCAL_TCP_PORT_MAX_WAIT_TIME@ #if defined(__linux__) || defined(ANDROID) || defined(__QNX__) #include diff --git a/implementation/configuration/include/internal_android.hpp b/implementation/configuration/include/internal_android.hpp index a98d42fb0..f5425722b 100644 --- a/implementation/configuration/include/internal_android.hpp +++ b/implementation/configuration/include/internal_android.hpp @@ -23,7 +23,7 @@ #define VSOMEIP_DEFAULT_CONFIGURATION_FILE "/vendor/run/etc/vsomeip.json" #define VSOMEIP_LOCAL_CONFIGURATION_FILE "./vsomeip.json" -#define VSOMEIP_MANDATORY_CONFIGURATION_FILES "vsomeip_std.json,vsomeip_app.json,vsomeip_plc.json,vsomeip_log.json,vsomeip_security.json,vsomeip_whitelist.json,vsomeip_policy_extensions.json" +#define VSOMEIP_MANDATORY_CONFIGURATION_FILES "vsomeip_std.json,vsomeip_app.json,vsomeip_plc.json,vsomeip_log.json,vsomeip_security.json,vsomeip_whitelist.json,vsomeip_policy_extensions.json,vsomeip_portcfg.json" #define VSOMEIP_DEFAULT_CONFIGURATION_FOLDER "/vendor/run/etc/vsomeip" #define VSOMEIP_DEBUG_CONFIGURATION_FOLDER "/var/opt/public/sin/vsomeip/" @@ -40,7 +40,7 @@ #define VSOMEIP_E2E_LIBRARY "libvsomeip_e2e.so" -#define VSOMEIP_SEC_LIBRARY "libvsomeip_sec.so" +#define VSOMEIP_SEC_LIBRARY "libvsomeip-sec.so.1" #define VSOMEIP_ROUTING "vsomeipd" #define VSOMEIP_ROUTING_CLIENT 0 @@ -94,7 +94,10 @@ #define VSOMEIP_LOCAL_CLIENT_ENDPOINT_RECV_BUFFER_SIZE 19 #define VSOMEIP_MINIMUM_CHECK_TTL_TIMEOUT 100 -#define VSOMEIP_SETSOCKOPT_TIMEOUT_US 500000 // microseconds +#define VSOMEIP_SETSOCKOPT_TIMEOUT_US 500000 // us + +#define LOCAL_TCP_PORT_WAIT_TIME 100 +#define LOCAL_TCP_PORT_MAX_WAIT_TIME 10000 #include diff --git a/implementation/configuration/include/routing.hpp b/implementation/configuration/include/routing.hpp index c30b828e2..b29296952 100644 --- a/implementation/configuration/include/routing.hpp +++ b/implementation/configuration/include/routing.hpp @@ -38,7 +38,9 @@ struct routing_host_t { struct routing_guests_t { boost::asio::ip::address unicast_; - std::set > ports_; + std::map, + std::set > + > ports_; routing_guests_t &operator=(const routing_guests_t &_other) { unicast_ = _other.unicast_; @@ -49,7 +51,7 @@ struct routing_guests_t { }; struct routing_t { - bool is_enabled_; + bool is_enabled_; routing_host_t host_; routing_guests_t guests_; @@ -57,7 +59,7 @@ struct routing_t { routing_t() : is_enabled_(true) {} routing_t &operator=(const routing_t &_other) { - is_enabled_ = _other.is_enabled_; + is_enabled_ = _other.is_enabled_; host_ = _other.host_; guests_ = _other.guests_; diff --git a/implementation/configuration/src/configuration_impl.cpp b/implementation/configuration/src/configuration_impl.cpp index bd61d4e3a..748dfd013 100644 --- a/implementation/configuration/src/configuration_impl.cpp +++ b/implementation/configuration/src/configuration_impl.cpp @@ -1,4 +1,4 @@ -// Copyright (C) 2014-2021 Bayerische Motoren Werke Aktiengesellschaft (BMW AG) +// Copyright (C) 2014-2023 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/. @@ -7,6 +7,7 @@ #include #include #include +#include #include #include #include @@ -102,6 +103,7 @@ configuration_impl::configuration_impl(const std::string &_path) max_remote_subscribers_(VSOMEIP_DEFAULT_MAX_REMOTE_SUBSCRIBERS), path_(_path), is_security_enabled_(false), + is_security_external_(false), is_security_audit_(false), is_remote_access_allowed_(true) { @@ -210,9 +212,10 @@ configuration_impl::configuration_impl(const configuration_impl &_other) statistics_max_messages_ = _other.statistics_max_messages_; max_remote_subscribers_ = _other.max_remote_subscribers_; - is_security_enabled_ = _other.is_security_enabled_; - is_security_audit_ = _other.is_security_audit_; - is_remote_access_allowed_ = _other.is_remote_access_allowed_; + is_security_enabled_ = _other.is_security_enabled_.load(); + is_security_external_ = _other.is_security_external_.load(); + is_security_audit_ = _other.is_security_audit_.load(); + is_remote_access_allowed_ = _other.is_remote_access_allowed_.load(); } configuration_impl::~configuration_impl() { @@ -590,6 +593,7 @@ bool configuration_impl::load_data(const std::vector &_el load_secure_services(e); load_partitions(e); load_routing_client_ports(e); + load_suppress_events(e); } } @@ -646,6 +650,7 @@ bool configuration_impl::load_logging( " Ignoring definition from " + _element.name_); } else { std::string its_value(i->second.data()); + std::lock_guard lock(mutex_loglevel_); loglevel_ = (its_value == "trace" ? vsomeip_v3::logger::level_e::LL_VERBOSE : @@ -735,7 +740,7 @@ configuration_impl::load_routing(const configuration_element &_element) { if (routing_.guests_.unicast_.is_unspecified()) routing_.guests_.unicast_ = routing_.host_.unicast_; if (routing_.guests_.ports_.empty()) - routing_.guests_.ports_.insert(std::make_pair(31492, 31999)); + routing_.guests_.ports_[{ ANY_UID, ANY_GID }].emplace(31492, 31999); } // Try to validate the port configuration. Check whether a range @@ -744,34 +749,37 @@ configuration_impl::load_routing(const configuration_element &_element) { // cases by reducing the range, if necessary. std::set > its_invalid_ranges; std::set > its_corrected_ranges; - for (auto &r : routing_.guests_.ports_) { - auto its_pair = std::make_pair(r.first, r.second); - - bool is_even(((r.second - r.first + 1) % 2) == 0); - - // If the routing host port is [un]even, the start number of the - // range shall also be [un]even. - bool is_matching((r.first % 2) == (routing_.host_.port_ % 2)); - if (!is_matching) { - its_pair.first++; - if (is_even) + for (auto &ug : routing_.guests_.ports_) { + for (auto &r : ug.second) { + auto its_pair = std::make_pair(r.first, r.second); + + bool is_even(((r.second - r.first + 1) % 2) == 0); + + // If the routing host port is [un]even, the start number of the + // range shall also be [un]even. + bool is_matching((r.first % 2) == (routing_.host_.port_ % 2)); + if (!is_matching) { + its_pair.first++; + if (is_even) + its_pair.second--; + } else if (!is_even) { its_pair.second--; - } else if (!is_even) { - its_pair.second--; - } + } - if (!is_even || !is_matching) { - its_invalid_ranges.insert(r); - its_corrected_ranges.insert(its_pair); + if (!is_even || !is_matching) { + its_invalid_ranges.insert(r); + its_corrected_ranges.insert(its_pair); + } } - } - - for (const auto &r : its_invalid_ranges) - routing_.guests_.ports_.erase(r); - for (const auto &r : its_corrected_ranges) - routing_.guests_.ports_.insert(r); + for (const auto &r : its_invalid_ranges) + ug.second.erase(r); + its_invalid_ranges.clear(); + for (const auto &r : its_corrected_ranges) + ug.second.insert(r); + its_corrected_ranges.clear(); + } is_configured_[ET_ROUTING] = true; } } catch (...) { @@ -867,23 +875,62 @@ void configuration_impl::load_routing_guest_ports( const boost::property_tree::ptree &_tree) { - try { - for (auto its_range = _tree.begin(); - its_range != _tree.end(); ++its_range) { + std::stringstream its_converter; - port_t its_first_port(0), its_last_port(0); - for (auto its_element = its_range->second.begin(); - its_element != its_range->second.end(); ++its_element) { + for (auto its_range = _tree.begin(); + its_range != _tree.end(); ++its_range) { - std::string its_key(its_element->first); - std::string its_value(its_element->second.data()); + uid_t its_uid { ANY_UID }; + gid_t its_gid { ANY_GID }; + std::set > its_ranges; - std::stringstream its_converter; - if (its_value.find("0x") == 0) { - its_converter << std::hex << its_value; - } else { - its_converter << std::dec << its_value; - } + try { + auto its_uid_value = its_range->second.get_child("uid").data(); + its_converter.str(""); + its_converter.clear(); + its_converter << its_uid_value; + its_converter >> (its_uid_value.find("0x") == 0 ? std::hex : std::dec) >> its_uid; + + auto its_gid_value = its_range->second.get_child("gid").data(); + its_converter.str(""); + its_converter.clear(); + its_converter << its_gid_value; + its_converter >> (its_gid_value.find("0x") == 0 ? std::hex : std::dec) >> its_gid; + + auto its_ranges_value = its_range->second.get_child("ranges"); + its_ranges = load_routing_guest_port_range(its_ranges_value); + } catch (...) { + its_ranges = load_routing_guest_port_range(its_range->second); + } + + if (!its_ranges.empty()) + routing_.guests_.ports_[{ its_uid, its_gid }] = its_ranges; + } +} + +std::set< std::pair > +configuration_impl::load_routing_guest_port_range( + const boost::property_tree::ptree &_tree) const { + + std::stringstream its_converter; + std::set< std::pair > its_ranges; + + for (auto its_range = _tree.begin(); + its_range != _tree.end(); ++its_range) { + + port_t its_first_port { 0 }; + port_t its_last_port { 0 }; + + for (auto its_element = its_range->second.begin(); + its_element != its_range->second.end(); ++its_element) { + + std::string its_key(its_element->first); + std::string its_value(its_element->second.data()); + + if (!its_value.empty()) { + its_converter.str(""); + its_converter.clear(); + its_converter << (its_value.find("0x") == 0 ? std::hex : std::dec) << its_value; if (its_key == "first") { its_converter >> its_first_port; @@ -891,17 +938,15 @@ configuration_impl::load_routing_guest_ports( its_converter >> its_last_port; } } - - if (its_first_port != 0 && its_last_port != 0) { - routing_.guests_.ports_.insert(std::make_pair( - std::min(its_first_port, its_last_port), - std::max(its_first_port, its_last_port))); - } } - } catch (...) { + + if (its_first_port > 0 && its_last_port > 0) + its_ranges.emplace(std::min(its_first_port, its_last_port), + std::max(its_first_port, its_last_port)); } -} + return its_ranges; +} void configuration_impl::load_routing_client_ports(const configuration_element &_element) { @@ -1335,6 +1380,176 @@ void configuration_impl::load_trace_filter_match( } } +void configuration_impl::load_suppress_events(const configuration_element &_element) { + try { + auto its_missing_events = _element.tree_.get_child("suppress_missing_event_logs"); + + if(its_missing_events.size()) { + for (auto i = its_missing_events.begin(); + i != its_missing_events.end(); + ++i) { + load_suppress_events_data(i->second); + } + + if(suppress_events_.size()) + is_suppress_events_enabled_ = true; + } + } catch (...) { + // Intentionally left empty + } +} + +void configuration_impl::load_suppress_events_data( + const boost::property_tree::ptree &_tree) { + + //Default everything to ANY, and change with the provided values + service_t its_service(ANY_SERVICE); + instance_t its_instance(ANY_INSTANCE); + event_t its_event(ANY_EVENT); + std::set events; + + 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; + + if (its_key == "service") { + its_service = load_suppress_data(its_value); + } else if (its_key == "instance") { + its_instance = load_suppress_data(its_value); + } else if (its_key == "events") { + if (i->second.empty()) { //Single Event + its_event = load_suppress_data(its_value); + events.insert(its_event); + } else { //Multiple Events/Range + events = load_suppress_multiple_events(i->second); + } + } + } + + //If no event is present in the configuration, use ANY_EVENT! + if(events.empty()) + events.insert(ANY_EVENT); + + for(const auto& event : events) { + insert_suppress_events(its_service, its_instance, event); + } +} + +std::set configuration_impl::load_suppress_multiple_events( + const boost::property_tree::ptree &_tree) { + + event_t its_first_event(ANY_EVENT); + event_t its_last_event(ANY_EVENT); + event_t its_event(ANY_EVENT); + std::set events; + + try { + for(auto i = _tree.begin(); i != _tree.end(); ++i) { + std::string its_key(i->first); + std::string its_value(i->second.data()); + + //Extract Single Event from multiple entries + if (i->second.size() == 0) { + + if (its_key == "first") { // Range Events + its_first_event = load_suppress_data(its_value); + } else if (its_key == "last") { + its_last_event = load_suppress_data(its_value); + + std::set range_events = load_range_events(its_first_event, its_last_event); + events.insert(range_events.begin(), range_events.end()); + return events; + } else { + //Single Events + its_event = load_suppress_data(its_value); + events.insert(its_event); + } + } else { + //Go down one level in the JSON, recursively + std::set range_events = load_suppress_multiple_events(i->second); + events.insert(range_events.begin(), range_events.end()); + } + } + } catch (...) { + // intentionally left empty + } + return events; +} + +uint16_t configuration_impl::load_suppress_data(const std::string &_value) const { + + std::stringstream its_converter; + uint16_t its_converted = ANY_EVENT; + + if (_value == "any") { + its_converted = ANY_EVENT; //use ANY_x + } else if (_value.find("0x") == 0) { + its_converter << std::hex << _value; + } else { + its_converter << std::dec << _value; + } + its_converter >> its_converted; + + return its_converted; +} + +std::set configuration_impl::load_range_events(event_t _first_event, + event_t _last_event) const { + + std::set range_events; + + if ((_first_event != ANY_EVENT) && (_last_event != ANY_EVENT)) { + for (event_t its_event = _first_event; its_event<=_last_event; its_event++) { + range_events.insert(its_event); + } + } + return range_events; +} + +void configuration_impl::insert_suppress_events(service_t _service, + instance_t _instance, event_t _event) { + + suppress_t new_event = {_service, _instance, _event}; + suppress_events_.insert(new_event); +} + +bool configuration_impl::check_suppress_events(service_t _service, instance_t _instance, + event_t _event) const { + + if (!is_suppress_events_enabled_) + return false; + + std::set event_combinations = { + {_service, _instance, _event}, + {_service, _instance, ANY_EVENT}, + {_service, ANY_INSTANCE, _event}, + {_service, ANY_INSTANCE, ANY_EVENT}, + {ANY_SERVICE, _instance, _event}, + {ANY_SERVICE, _instance, ANY_EVENT}, + {ANY_SERVICE, ANY_INSTANCE, _event} + }; + + for (const auto &its_event: event_combinations) { + if (suppress_events_.find(its_event) != std::end(suppress_events_)) + return true; + } + + return false; +} + +void configuration_impl::print_suppress_events(void) const { + + VSOMEIP_INFO << "Suppress Event logs size: " << suppress_events_.size(); + + for (const auto& its_log : suppress_events_) { + VSOMEIP_INFO << std::hex << std::setfill('0') + << "+[" << std::setw(4) << its_log.service + << "." << std::setw(4) << its_log.instance + << "." << its_log.event << "]"; + } +} + void configuration_impl::load_unicast_address(const configuration_element &_element) { try { std::string its_value = _element.tree_.get("unicast"); @@ -2443,6 +2658,7 @@ void configuration_impl::load_security(const configuration_element &_element) { auto its_security = _element.tree_.get_child_optional("security"); if (its_security) { is_security_enabled_ = true; + is_security_external_ = its_security->empty(); auto its_audit_mode = its_security->get_child_optional("check_credentials"); if (its_audit_mode) { @@ -2473,7 +2689,8 @@ void configuration_impl::load_security(const configuration_element &_element) { } #ifndef VSOMEIP_DISABLE_SECURITY - policy_manager_impl::get()->load(_element); + if (!is_security_external()) + policy_manager_impl::get()->load(_element); #endif // !VSOMEIP_DISABLE_SECURITY } @@ -2671,6 +2888,7 @@ const std::string & configuration_impl::get_logfile() const { } vsomeip_v3::logger::level_e configuration_impl::get_loglevel() const { + std::unique_lock its_lock(mutex_loglevel_); return loglevel_; } @@ -2801,11 +3019,12 @@ bool configuration_impl::get_client_port( } // Configured ports do exist, but they are all in use - VSOMEIP_ERROR << "Cannot find free client port for communication to service: " - << _service << " instance: " - << _instance << " remote_port: " - << _remote_port << " reliable: " - << _reliable; + VSOMEIP_ERROR << "Cannot find free client port for communication to service [" + << std::hex << std::setw(4) << std::setfill('0') << _service << "." + << std::hex << std::setw(4) << std::setfill('0') << _instance << "." + << std::dec << _remote_port << "." + << std::boolalpha <<_reliable << "]"; + return false; } @@ -2851,9 +3070,25 @@ configuration_impl::get_routing_guest_address() const { } std::set > -configuration_impl::get_routing_guest_ports() const { +configuration_impl::get_routing_guest_ports(uid_t _uid, gid_t _gid) const { + + auto found = routing_.guests_.ports_.find({ _uid, _gid }); + if (found != routing_.guests_.ports_.end()) + return found->second; + + found = routing_.guests_.ports_.find({ _uid, ANY_GID }); + if (found != routing_.guests_.ports_.end()) + return found->second; + + found = routing_.guests_.ports_.find({ ANY_UID, _gid }); + if (found != routing_.guests_.ports_.end()) + return found->second; - return routing_.guests_.ports_; + found = routing_.guests_.ports_.find({ ANY_UID, ANY_GID }); + if (found != routing_.guests_.ports_.end()) + return found->second; + + return std::set >(); } bool @@ -4412,6 +4647,10 @@ bool configuration_impl::is_protected_port( bool is_required(is_protected_device(_address)); + if (!is_required) { + return false; + } + std::lock_guard its_lock(sd_acceptance_required_ips_mutex_); const auto found_address = sd_acceptance_rules_.find(_address); if (found_address != sd_acceptance_rules_.end()) { @@ -4427,7 +4666,7 @@ bool configuration_impl::is_protected_port( = (found_reliability->second.second.find(its_range) != found_reliability->second.second.end()); - is_required = ((is_required && is_optional) || is_secure); + is_required = is_optional || is_secure; } } @@ -4621,7 +4860,7 @@ bool configuration_impl::is_secure_service(service_t _service, instance_t _insta int configuration_impl::get_udp_receive_buffer_size() const { - return udp_receive_buffer_size_; + return udp_receive_buffer_size_; } bool configuration_impl::is_tp_client( @@ -4769,6 +5008,12 @@ configuration_impl::is_security_enabled() const { return is_security_enabled_; } +bool +configuration_impl::is_security_external() const { + + return is_security_external_; +} + bool configuration_impl::is_security_audit() const { diff --git a/implementation/endpoints/include/client_endpoint_impl.hpp b/implementation/endpoints/include/client_endpoint_impl.hpp index d832130ab..92c69aa82 100644 --- a/implementation/endpoints/include/client_endpoint_impl.hpp +++ b/implementation/endpoints/include/client_endpoint_impl.hpp @@ -109,8 +109,7 @@ class client_endpoint_impl: public endpoint_impl, public client_endpoi typename endpoint_impl::cms_ret_e check_message_size( const std::uint8_t * const _data, std::uint32_t _size); bool check_queue_limit(const uint8_t *_data, std::uint32_t _size) const; - void queue_train(const std::shared_ptr &_train, - bool _queue_size_zero_on_entry); + void queue_train(const std::shared_ptr &_train); void update_last_departure(); protected: @@ -142,11 +141,11 @@ class client_endpoint_impl: public endpoint_impl, public client_endpoi std::deque > queue_; std::size_t queue_size_; - mutable std::mutex mutex_; + mutable std::recursive_mutex mutex_; std::atomic was_not_connected_; - std::atomic local_port_; + bool is_sending_; boost::asio::io_context::strand strand_; diff --git a/implementation/endpoints/include/local_server_endpoint_impl_receive_op.hpp b/implementation/endpoints/include/local_server_endpoint_impl_receive_op.hpp index fcc339f0c..b729e37f5 100644 --- a/implementation/endpoints/include/local_server_endpoint_impl_receive_op.hpp +++ b/implementation/endpoints/include/local_server_endpoint_impl_receive_op.hpp @@ -1,4 +1,4 @@ -// Copyright (C) 2020-2021 Bayerische Motoren Werke Aktiengesellschaft (BMW AG) +// Copyright (C) 2020-2023 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/. diff --git a/implementation/endpoints/include/local_tcp_server_endpoint_impl.hpp b/implementation/endpoints/include/local_tcp_server_endpoint_impl.hpp index ccaf99a3b..49b6fcb77 100644 --- a/implementation/endpoints/include/local_tcp_server_endpoint_impl.hpp +++ b/implementation/endpoints/include/local_tcp_server_endpoint_impl.hpp @@ -110,6 +110,8 @@ class local_tcp_server_endpoint_impl std::string get_path_local() const; std::string get_path_remote() const; void handle_recv_buffer_exception(const std::exception &_e); + void shutdown_and_close(); + void shutdown_and_close_unlocked(); std::mutex socket_mutex_; local_tcp_server_endpoint_impl::socket_type socket_; @@ -130,6 +132,7 @@ class local_tcp_server_endpoint_impl vsomeip_sec_client_t sec_client_; bool assigned_client_; + std::atomic is_stopped_; }; std::mutex acceptor_mutex_; diff --git a/implementation/endpoints/include/local_uds_server_endpoint_impl.hpp b/implementation/endpoints/include/local_uds_server_endpoint_impl.hpp index 2f87dff08..1e78822d5 100644 --- a/implementation/endpoints/include/local_uds_server_endpoint_impl.hpp +++ b/implementation/endpoints/include/local_uds_server_endpoint_impl.hpp @@ -1,4 +1,4 @@ -// Copyright (C) 2014-2022 Bayerische Motoren Werke Aktiengesellschaft (BMW AG) +// Copyright (C) 2014-2023 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/. @@ -132,6 +132,8 @@ class local_uds_server_endpoint_impl: public local_uds_server_endpoint_base_impl std::string get_path_local() const; std::string get_path_remote() const; void handle_recv_buffer_exception(const std::exception &_e); + void shutdown_and_close(); + void shutdown_and_close_unlocked(); std::mutex socket_mutex_; local_uds_server_endpoint_impl::socket_type socket_; @@ -152,6 +154,7 @@ class local_uds_server_endpoint_impl: public local_uds_server_endpoint_base_impl vsomeip_sec_client_t sec_client_; bool assigned_client_; + std::atomic is_stopped_; }; std::mutex acceptor_mutex_; diff --git a/implementation/endpoints/include/tcp_client_endpoint_impl.hpp b/implementation/endpoints/include/tcp_client_endpoint_impl.hpp index b5f6d99f5..56b54e798 100644 --- a/implementation/endpoints/include/tcp_client_endpoint_impl.hpp +++ b/implementation/endpoints/include/tcp_client_endpoint_impl.hpp @@ -33,6 +33,9 @@ class tcp_client_endpoint_impl: public tcp_client_endpoint_base_impl { void start(); void restart(bool _force); + std::uint16_t get_local_port() const; + void set_local_port(port_t _port); + bool get_remote_address(boost::asio::ip::address &_address) const; std::uint16_t get_remote_port() const; bool is_reliable() const; @@ -99,8 +102,6 @@ class tcp_client_endpoint_impl: public tcp_client_endpoint_base_impl { std::atomic aborted_restart_count_; std::chrono::steady_clock::time_point connect_timepoint_; - std::mutex sent_mutex_; - bool is_sending_; boost::asio::steady_timer sent_timer_; }; diff --git a/implementation/endpoints/include/udp_client_endpoint_impl.hpp b/implementation/endpoints/include/udp_client_endpoint_impl.hpp index 32946c544..4d02ab27a 100644 --- a/implementation/endpoints/include/udp_client_endpoint_impl.hpp +++ b/implementation/endpoints/include/udp_client_endpoint_impl.hpp @@ -41,9 +41,13 @@ class udp_client_endpoint_impl: virtual public udp_client_endpoint_base_impl { void receive_cbk(boost::system::error_code const &_error, std::size_t _bytes, const message_buffer_ptr_t& _recv_buffer); + std::uint16_t get_local_port() const; + void set_local_port(port_t _port); + bool get_remote_address(boost::asio::ip::address &_address) const; std::uint16_t get_remote_port() const; bool is_local() const; + void print_status(); bool is_reliable() const; @@ -70,6 +74,9 @@ class udp_client_endpoint_impl: virtual public udp_client_endpoint_base_impl { const std::uint16_t remote_port_; const int udp_receive_buffer_size_; std::shared_ptr tp_reassembler_; + + std::mutex last_sent_mutex_; + std::chrono::steady_clock::time_point last_sent_; }; } // namespace vsomeip_v3 diff --git a/implementation/endpoints/include/udp_server_endpoint_impl.hpp b/implementation/endpoints/include/udp_server_endpoint_impl.hpp index 1591276c9..b9b68fbc0 100644 --- a/implementation/endpoints/include/udp_server_endpoint_impl.hpp +++ b/implementation/endpoints/include/udp_server_endpoint_impl.hpp @@ -101,6 +101,10 @@ class udp_server_endpoint_impl: public udp_server_endpoint_base_impl { bool is_same_subnet(const boost::asio::ip::address &_address) const; + void shutdown_and_close(); + void unicast_shutdown_and_close_unlocked(); + void multicast_shutdown_and_close_unlocked(); + private: socket_type unicast_socket_; endpoint_type unicast_remote_; @@ -128,6 +132,11 @@ class udp_server_endpoint_impl: public udp_server_endpoint_base_impl { std::shared_ptr tp_reassembler_; boost::asio::steady_timer tp_cleanup_timer_; + + std::mutex last_sent_mutex_; + std::chrono::steady_clock::time_point last_sent_; + + std::atomic is_stopped_; }; } // namespace vsomeip_v3 diff --git a/implementation/endpoints/include/udp_server_endpoint_impl_receive_op.hpp b/implementation/endpoints/include/udp_server_endpoint_impl_receive_op.hpp index c2ca541df..5941bc794 100644 --- a/implementation/endpoints/include/udp_server_endpoint_impl_receive_op.hpp +++ b/implementation/endpoints/include/udp_server_endpoint_impl_receive_op.hpp @@ -1,4 +1,4 @@ -// Copyright (C) 2022 Bayerische Motoren Werke Aktiengesellschaft (BMW AG) +// Copyright (C) 2023 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/. diff --git a/implementation/endpoints/src/client_endpoint_impl.cpp b/implementation/endpoints/src/client_endpoint_impl.cpp index d3b56fa66..58041ecae 100644 --- a/implementation/endpoints/src/client_endpoint_impl.cpp +++ b/implementation/endpoints/src/client_endpoint_impl.cpp @@ -1,4 +1,4 @@ -// Copyright (C) 2014-2021 Bayerische Motoren Werke Aktiengesellschaft (BMW AG) +// Copyright (C) 2014-2023 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/. @@ -47,7 +47,7 @@ client_endpoint_impl::client_endpoint_impl( has_last_departure_(false), queue_size_(0), was_not_connected_(false), - local_port_(0), + is_sending_(false), strand_(_io) { } @@ -118,7 +118,7 @@ void client_endpoint_impl::prepare_stop( template void client_endpoint_impl::stop() { { - std::lock_guard its_lock(mutex_); + std::lock_guard its_lock(mutex_); endpoint_impl::sending_blocked_ = true; // delete unsent messages queue_.clear(); @@ -180,7 +180,7 @@ bool client_endpoint_impl::send_error( template bool client_endpoint_impl::send(const uint8_t *_data, uint32_t _size) { - std::lock_guard its_lock(mutex_); + std::lock_guard its_lock(mutex_); bool must_depart(false); auto its_now(std::chrono::steady_clock::now()); @@ -324,18 +324,18 @@ void client_endpoint_impl::send_segments( train_->departure_ = its_now + its_retention; } - const bool queue_size_still_zero(queue_.empty()); for (const auto& s : _segments) { queue_.emplace_back(std::make_pair(s, _separation_time)); queue_size_ += s->size(); } - if (queue_size_still_zero && !queue_.empty()) { // no writing in progress + if (!is_sending_ && !queue_.empty()) { // no writing in progress // respect minimal debounce time schedule_train(); // ignore retention time and send immediately as the train is full anyway auto its_entry = get_front(); if (its_entry.first) { + is_sending_ = true; strand_.dispatch(std::bind(&client_endpoint_impl::send_queued, this->shared_from_this(), its_entry)); } @@ -369,7 +369,7 @@ bool client_endpoint_impl::flush() { bool has_queued(true); bool is_current_train(true); - std::lock_guard its_lock(mutex_); + std::lock_guard its_lock(mutex_); std::shared_ptr its_train(train_); if (!dispatched_trains_.empty()) { @@ -389,7 +389,7 @@ bool client_endpoint_impl::flush() { if (!its_train->buffer_->empty()) { - queue_train(its_train, !queue_.size()); + queue_train(its_train); // Reset current train if necessary if (is_current_train) { @@ -443,12 +443,12 @@ void client_endpoint_impl::connect_cbk( } connect_timeout_ = VSOMEIP_DEFAULT_CONNECT_TIMEOUT; // TODO: use config variable reconnect_counter_ = 0; - set_local_port(); if (was_not_connected_) { was_not_connected_ = false; - std::lock_guard its_lock(mutex_); + std::lock_guard its_lock(mutex_); auto its_entry = get_front(); if (its_entry.first) { + is_sending_ = true; strand_.dispatch(std::bind(&client_endpoint_impl::send_queued, this->shared_from_this(), its_entry)); VSOMEIP_WARNING << __func__ << ": resume sending to: " @@ -466,13 +466,16 @@ void client_endpoint_impl::connect_cbk( template void client_endpoint_impl::cancel_and_connect_cbk( boost::system::error_code const &_error) { + std::size_t operations_cancelled; { /* Need this for TCP endpoints for now because we have no direct control about the point in time the connect has finished */ std::lock_guard its_lock(connecting_timer_mutex_); - connecting_timer_.cancel(); + operations_cancelled = connecting_timer_.cancel(); + } + if (operations_cancelled != 0) { + connect_cbk(_error); } - connect_cbk(_error); } template @@ -489,6 +492,7 @@ void client_endpoint_impl::wait_connect_cbk( template void client_endpoint_impl::wait_connecting_cbk( boost::system::error_code const &_error) { + if (!_error && !client_endpoint_impl::sending_blocked_) { connect_cbk(boost::asio::error::timed_out); } @@ -502,23 +506,28 @@ void client_endpoint_impl::send_cbk( (void)_bytes; if (!_error) { - std::lock_guard its_lock(mutex_); + std::lock_guard its_lock(mutex_); if (queue_.size() > 0) { queue_size_ -= queue_.front().first->size(); queue_.pop_front(); update_last_departure(); - auto its_entry = get_front(); - if (its_entry.first) { - send_queued(its_entry); + if (queue_.empty()) + is_sending_ = false; + else { + auto its_entry = get_front(); + if (its_entry.first) { + send_queued(its_entry); + } } } + return; } else if (_error == boost::asio::error::broken_pipe) { state_ = cei_state_e::CLOSED; bool stopping(false); { - std::lock_guard its_lock(mutex_); + std::lock_guard its_lock(mutex_); stopping = endpoint_impl::sending_blocked_; if (stopping) { queue_.clear(); @@ -569,7 +578,7 @@ void client_endpoint_impl::send_cbk( VSOMEIP_WARNING << "cei::send_cbk received error: " << _error.message() << " (" << std::dec << _error.value() << ") " << get_remote_information(); - std::lock_guard its_lock(mutex_); + std::lock_guard its_lock(mutex_); queue_.clear(); queue_size_ = 0; } @@ -618,6 +627,9 @@ void client_endpoint_impl::send_cbk( << std::setw(4) << its_session << "]"; print_status(); } + + std::lock_guard its_lock(mutex_); + is_sending_ = false; } template @@ -639,7 +651,6 @@ void client_endpoint_impl::shutdown_and_close_socket(bool _recreate_so template void client_endpoint_impl::shutdown_and_close_socket_unlocked(bool _recreate_socket) { - local_port_ = 0; if (socket_->is_open()) { #if defined(__linux__) || defined(ANDROID) || defined(__QNX__) if (-1 == fcntl(socket_->native_handle(), F_GETFD)) { @@ -674,13 +685,13 @@ std::uint16_t client_endpoint_impl::get_remote_port() const { template std::uint16_t client_endpoint_impl::get_local_port() const { - return local_port_; + return 0; } template -void client_endpoint_impl::set_local_port(uint16_t _port) { +void client_endpoint_impl::set_local_port(port_t _port) { - local_port_ = _port; + (void)_port; // overwritten in IP endpoints } template @@ -784,14 +795,15 @@ bool client_endpoint_impl::check_queue_limit(const uint8_t *_data, std template void client_endpoint_impl::queue_train( - const std::shared_ptr &_train, bool _queue_size_zero_on_entry) { + const std::shared_ptr &_train) { - queue_.push_back(std::make_pair(_train->buffer_, 0)); queue_size_ += _train->buffer_->size(); + queue_.emplace_back(_train->buffer_, 0); - if (_queue_size_zero_on_entry && !queue_.empty()) { // no writing in progress + if (!is_sending_ && !queue_.empty()) { // no writing in progress auto its_entry = get_front(); if (its_entry.first) { + is_sending_ = true; strand_.dispatch(std::bind(&client_endpoint_impl::send_queued, this->shared_from_this(), its_entry)); } @@ -801,7 +813,7 @@ void client_endpoint_impl::queue_train( template size_t client_endpoint_impl::get_queue_size() const { - std::lock_guard its_lock(mutex_); + std::lock_guard its_lock(mutex_); return queue_size_; } diff --git a/implementation/endpoints/src/endpoint_impl.cpp b/implementation/endpoints/src/endpoint_impl.cpp index c966198f0..196a22adc 100644 --- a/implementation/endpoints/src/endpoint_impl.cpp +++ b/implementation/endpoints/src/endpoint_impl.cpp @@ -1,4 +1,4 @@ -// Copyright (C) 2014-2021 Bayerische Motoren Werke Aktiengesellschaft (BMW AG) +// Copyright (C) 2014-2023 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/. @@ -145,15 +145,7 @@ instance_t endpoint_impl::get_instance(service_t _service) { } // Instantiate template -#ifdef __linux__ -#if VSOMEIP_BOOST_VERSION < 106600 -template class endpoint_impl; -#else -template class endpoint_impl; -#endif -#endif - -#ifdef __QNX__ +#if defined(__linux__) || defined(__QNX__) #if VSOMEIP_BOOST_VERSION < 106600 template class endpoint_impl; #endif diff --git a/implementation/endpoints/src/endpoint_manager_base.cpp b/implementation/endpoints/src/endpoint_manager_base.cpp index dde325c2e..540ef3103 100644 --- a/implementation/endpoints/src/endpoint_manager_base.cpp +++ b/implementation/endpoints/src/endpoint_manager_base.cpp @@ -1,4 +1,4 @@ -// Copyright (C) 2014-2021 Bayerische Motoren Werke Aktiengesellschaft (BMW AG) +// Copyright (C) 2014-2023 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/. @@ -122,6 +122,7 @@ std::shared_ptr endpoint_manager_base::create_local_server( port_t its_port; std::set its_used_ports; auto its_address = configuration_->get_routing_guest_address(); + uint32_t its_current_wait_time { 0 }; while (get_local_server_port(its_port, its_used_ports) && !its_server_endpoint) { try { its_server_endpoint = std::make_shared( @@ -140,8 +141,17 @@ std::shared_ptr endpoint_manager_base::create_local_server( VSOMEIP_INFO << __func__ << ": Connecting to other clients from " << its_address.to_string() << ":" << std::dec << local_port_; - } catch (const std::exception&) { - its_used_ports.insert(its_port); + } catch (const boost::system::system_error &e) { + if (e.code() == boost::asio::error::address_in_use) { + its_used_ports.insert(its_port); + } else { + its_current_wait_time += LOCAL_TCP_PORT_WAIT_TIME; + if (its_current_wait_time > LOCAL_TCP_PORT_MAX_WAIT_TIME) + break; + + std::this_thread::sleep_for( + std::chrono::milliseconds(LOCAL_TCP_PORT_WAIT_TIME)); + } } } @@ -253,12 +263,12 @@ endpoint_manager_base::create_local_unlocked(client_t _client) { #if defined(__linux__) || defined(ANDROID) || defined(__QNX__) if (is_local_routing_) { - VSOMEIP_INFO << "Client [" << std::hex << rm_->get_client() << "] is connecting to [" - << std::hex << _client << "] at " << its_path.str(); its_endpoint = std::make_shared( shared_from_this(), rm_->shared_from_this(), boost::asio::local::stream_protocol::endpoint(its_path.str()), io_, configuration_); + VSOMEIP_INFO << "Client [" << std::hex << rm_->get_client() << "] is connecting to [" + << std::hex << _client << "] at " << its_path.str(); } else { #else { @@ -332,7 +342,21 @@ endpoint_manager_base::get_local_server_port(port_t &_port, #define SERVER_PORT_OFFSET 2 - auto its_port_ranges = configuration_->get_routing_guest_ports(); +#ifdef _WIN32 + uid_t its_uid { ANY_UID }; + gid_t its_gid { ANY_GID }; +#else + uid_t its_uid { getuid() }; + gid_t its_gid { getgid() }; +#endif + + auto its_port_ranges = configuration_->get_routing_guest_ports( + its_uid, its_gid); + + if (its_port_ranges.empty()) { + VSOMEIP_WARNING << __func__ << ": No configured port ranges for uid/gid=" + << std::dec << its_uid << '/' << its_gid; + } for (const auto &its_range : its_port_ranges) { for (int r = its_range.first; r < its_range.second; diff --git a/implementation/endpoints/src/endpoint_manager_impl.cpp b/implementation/endpoints/src/endpoint_manager_impl.cpp index 2f3f9ac3f..d423d4590 100644 --- a/implementation/endpoints/src/endpoint_manager_impl.cpp +++ b/implementation/endpoints/src/endpoint_manager_impl.cpp @@ -1,4 +1,4 @@ -// Copyright (C) 2014-2021 Bayerische Motoren Werke Aktiengesellschaft (BMW AG) +// Copyright (C) 2014-2023 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/. @@ -749,10 +749,10 @@ endpoint_manager_impl::create_routing_root( std::chrono::milliseconds(VSOMEIP_ROUTING_ROOT_RECONNECT_INTERVAL)); } } - + if (!create_routing_result) { return false; - } + } _is_socket_activated = false; } diff --git a/implementation/endpoints/src/local_tcp_client_endpoint_impl.cpp b/implementation/endpoints/src/local_tcp_client_endpoint_impl.cpp index 98c441506..6445dab9a 100644 --- a/implementation/endpoints/src/local_tcp_client_endpoint_impl.cpp +++ b/implementation/endpoints/src/local_tcp_client_endpoint_impl.cpp @@ -52,7 +52,7 @@ void local_tcp_client_endpoint_impl::restart(bool _force) { } state_ = cei_state_e::CONNECTING; { - std::lock_guard its_lock(mutex_); + std::lock_guard its_lock(mutex_); sending_blocked_ = false; queue_.clear(); queue_size_ = 0; @@ -69,7 +69,7 @@ void local_tcp_client_endpoint_impl::restart(bool _force) { void local_tcp_client_endpoint_impl::start() { { - std::lock_guard its_lock(mutex_); + std::lock_guard its_lock(mutex_); sending_blocked_ = false; } connect(); @@ -77,7 +77,7 @@ void local_tcp_client_endpoint_impl::start() { void local_tcp_client_endpoint_impl::stop() { { - std::lock_guard its_lock(mutex_); + std::lock_guard its_lock(mutex_); sending_blocked_ = true; } { @@ -112,48 +112,46 @@ void local_tcp_client_endpoint_impl::stop() { } void local_tcp_client_endpoint_impl::connect() { - start_connecting_timer(); boost::system::error_code its_connect_error; - { - std::lock_guard its_lock(socket_mutex_); - boost::system::error_code its_error; - socket_->open(remote_.protocol(), its_error); - - if (!its_error || its_error == boost::asio::error::already_open) { - socket_->set_option(boost::asio::socket_base::reuse_address(true), its_error); - if (its_error) { - VSOMEIP_WARNING << "local_tcp_client_endpoint_impl::" << __func__ - << ": Cannot enable SO_REUSEADDR" - << "(" << its_error.message() << ")"; - } - - socket_->bind(local_, its_error); - if (its_error) { - VSOMEIP_WARNING << "local_tcp_client_endpoint_impl::" << __func__ - << ": Cannot bind to client port " << local_.port() - << "(" << its_error.message() << ")"; - } - - state_ = cei_state_e::CONNECTING; - socket_->connect(remote_, its_connect_error); - } else { - VSOMEIP_WARNING << "local_client_endpoint::connect: Error opening socket: " - << its_error.message() << " (" << std::dec << its_error.value() - << ")"; - its_connect_error = its_error; + std::lock_guard its_lock(socket_mutex_); + boost::system::error_code its_error; + socket_->open(remote_.protocol(), its_error); + if (!its_error || its_error == boost::asio::error::already_open) { + socket_->set_option(boost::asio::socket_base::reuse_address(true), its_error); + if (its_error) { + VSOMEIP_WARNING << "local_tcp_client_endpoint_impl::" << __func__ + << ": Cannot enable SO_REUSEADDR" + << "(" << its_error.message() << ")"; } - } - // call connect_cbk asynchronously - { - std::lock_guard its_lock(connecting_timer_mutex_); - connecting_timer_.cancel(); - } - try { - strand_.post( + socket_->bind(local_, its_error); + if (its_error) { + VSOMEIP_WARNING << "local_tcp_client_endpoint_impl::" << __func__ + << ": Cannot bind to client port " << local_.port() + << "(" << its_error.message() << ")"; + } + state_ = cei_state_e::CONNECTING; + start_connecting_timer(); + socket_->async_connect( + remote_, + strand_.wrap( + std::bind( + &local_tcp_client_endpoint_impl::cancel_and_connect_cbk, + shared_from_this(), + std::placeholders::_1 + ) + ) + ); + } else { + VSOMEIP_WARNING << "local_client_endpoint::connect: Error opening socket: " + << its_error.message() << " (" << std::dec << its_error.value() << ")"; + its_connect_error = its_error; + try { + strand_.post( std::bind(&client_endpoint_impl::connect_cbk, shared_from_this(), its_connect_error)); - } catch (const std::exception &e) { - VSOMEIP_ERROR << "local_client_endpoint_impl::connect: " << e.what(); + } catch (const std::exception &e) { + VSOMEIP_ERROR << "local_client_endpoint_impl::connect: " << e.what(); + } } } @@ -179,9 +177,8 @@ void local_tcp_client_endpoint_impl::receive() { // this overrides client_endpoint_impl::send to disable the pull method // for local communication bool local_tcp_client_endpoint_impl::send(const uint8_t *_data, uint32_t _size) { - std::lock_guard its_lock(mutex_); + std::lock_guard its_lock(mutex_); bool ret(true); - const bool queue_size_zero_on_entry(queue_.empty()); if (endpoint_impl::sending_blocked_ || check_message_size(nullptr, _size) != cms_ret_e::MSG_OK || !check_packetizer_space(_size) || @@ -197,7 +194,7 @@ bool local_tcp_client_endpoint_impl::send(const uint8_t *_data, uint32_t _size) VSOMEIP_INFO << msg.str(); #endif train_->buffer_->insert(train_->buffer_->end(), _data, _data + _size); - queue_train(train_, queue_size_zero_on_entry); + queue_train(train_); train_->buffer_ = std::make_shared(); } return ret; @@ -314,7 +311,7 @@ void local_tcp_client_endpoint_impl::print_status() { std::size_t its_data_size(0); std::size_t its_queue_size(0); { - std::lock_guard its_lock(mutex_); + std::lock_guard its_lock(mutex_); its_queue_size = queue_.size(); its_data_size = queue_size_; } diff --git a/implementation/endpoints/src/local_tcp_server_endpoint_impl.cpp b/implementation/endpoints/src/local_tcp_server_endpoint_impl.cpp index 5bf660d92..219262e9c 100644 --- a/implementation/endpoints/src/local_tcp_server_endpoint_impl.cpp +++ b/implementation/endpoints/src/local_tcp_server_endpoint_impl.cpp @@ -1,4 +1,4 @@ -// Copyright (C) 2014-2021 Bayerische Motoren Werke Aktiengesellschaft (BMW AG) +// Copyright (C) 2014-2023 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/. @@ -20,6 +20,7 @@ #include "../../protocol/include/assign_client_ack_command.hpp" #include "../../routing/include/routing_host.hpp" #include "../../security/include/policy_manager_impl.hpp" +#include "../../security/include/security.hpp" #include "../../utility/include/byteorder.hpp" #include "../../utility/include/utility.hpp" @@ -268,15 +269,15 @@ local_tcp_server_endpoint_impl::connection::connection( buffer_shrink_threshold_(_buffer_shrink_threshold), bound_client_(VSOMEIP_CLIENT_UNSET), bound_client_host_(""), - assigned_client_(false) { + assigned_client_(false), + is_stopped_(true) { if (_server->is_routing_endpoint_ && !_server->configuration_->is_security_enabled()) { assigned_client_ = true; } - sec_client_.client_type = VSOMEIP_CLIENT_TCP; - sec_client_.client.ip_client.ip = 0; - sec_client_.client.ip_client.port = 0; + sec_client_.host = 0; + sec_client_.port = VSOMEIP_SEC_PORT_UNSET; } local_tcp_server_endpoint_impl::connection::ptr @@ -343,6 +344,7 @@ void local_tcp_server_endpoint_impl::connection::start() { return; } + is_stopped_ = false; #if VSOMEIP_BOOST_VERSION < 106600 socket_.async_receive( boost::asio::buffer(&recv_buffer_[recv_buffer_size_], left_buffer_size), @@ -369,6 +371,7 @@ void local_tcp_server_endpoint_impl::connection::start() { void local_tcp_server_endpoint_impl::connection::stop() { std::lock_guard its_lock(socket_mutex_); + is_stopped_ = true; if (socket_.is_open()) { #if defined(__linux__) || defined(ANDROID) || defined(__QNX__) if (-1 == fcntl(socket_.native_handle(), F_GETFD)) { @@ -377,8 +380,7 @@ void local_tcp_server_endpoint_impl::connection::stop() { } #endif boost::system::error_code its_error; - socket_.shutdown(socket_.shutdown_both, its_error); - socket_.close(its_error); + socket_.cancel(its_error); } } @@ -637,21 +639,27 @@ void local_tcp_server_endpoint_impl::connection::receive_cbk( its_server->send_client_identifier(its_client); assigned_client_ = true; } else if (!its_server->is_routing_endpoint_ || assigned_client_) { + boost::system::error_code ec; + auto its_endpoint = socket_.remote_endpoint(ec); + if (!ec) { + auto its_address = its_endpoint.address(); + auto its_port = its_endpoint.port(); + + if (its_address.is_v4()) { + sec_client_.host + = htonl(uint32_t(its_address.to_v4().to_ulong())); + } + sec_client_.port = its_port; + security::sync_client(&sec_client_); - auto its_address = socket_.remote_endpoint().address(); - auto its_port = socket_.remote_endpoint().port(); - - sec_client_.client_type = VSOMEIP_CLIENT_TCP; - if (its_address.is_v4()) { - sec_client_.client.ip_client.ip - = htonl(uint32_t(its_address.to_v4().to_ulong())); + its_host->on_message(&recv_buffer_[its_start], + uint32_t(its_end - its_start), its_server.get(), + false, bound_client_, &sec_client_, + its_address, its_port); + } else { + VSOMEIP_WARNING << std::hex << "Client 0x" << its_host->get_client() + << " endpoint encountered an error[" << ec.value() << "]: " << ec.message(); } - sec_client_.client.ip_client.port = its_port; - - its_host->on_message(&recv_buffer_[its_start], - uint32_t(its_end - its_start), its_server.get(), - false, bound_client_, &sec_client_, - its_address, its_port); } else { VSOMEIP_WARNING << std::hex << "Client 0x" << its_host->get_client() << " didn't receive VSOMEIP_ASSIGN_CLIENT as first message"; @@ -690,10 +698,11 @@ void local_tcp_server_endpoint_impl::connection::receive_cbk( } while (recv_buffer_size_ > 0 && found_message); } - if (_error == boost::asio::error::eof + if (is_stopped_ + || _error == boost::asio::error::eof || _error == boost::asio::error::connection_reset || is_error) { - stop(); + shutdown_and_close(); its_server->remove_connection(bound_client_); policy_manager_impl::get()->remove_client_to_sec_client_mapping(bound_client_); } else if (_error != boost::asio::error::bad_descriptor) { @@ -792,6 +801,19 @@ local_tcp_server_endpoint_impl::connection::get_recv_buffer_capacity() const { return recv_buffer_.capacity(); } +void +local_tcp_server_endpoint_impl::connection::shutdown_and_close() { + std::lock_guard its_lock(socket_mutex_); + shutdown_and_close_unlocked(); +} + +void +local_tcp_server_endpoint_impl::connection::shutdown_and_close_unlocked() { + boost::system::error_code its_error; + socket_.shutdown(socket_.shutdown_both, its_error); + socket_.close(its_error); +} + void local_tcp_server_endpoint_impl::print_status() { std::lock_guard its_lock(mutex_); connections_t its_connections; diff --git a/implementation/endpoints/src/local_uds_client_endpoint_impl.cpp b/implementation/endpoints/src/local_uds_client_endpoint_impl.cpp index 3e8fca0ef..0b7e261c1 100644 --- a/implementation/endpoints/src/local_uds_client_endpoint_impl.cpp +++ b/implementation/endpoints/src/local_uds_client_endpoint_impl.cpp @@ -1,4 +1,4 @@ -// Copyright (C) 2014-2021 Bayerische Motoren Werke Aktiengesellschaft (BMW AG) +// Copyright (C) 2014-2023 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/. @@ -55,7 +55,7 @@ void local_uds_client_endpoint_impl::restart(bool _force) { } state_ = cei_state_e::CONNECTING; { - std::lock_guard its_lock(mutex_); + std::lock_guard its_lock(mutex_); sending_blocked_ = false; queue_.clear(); queue_size_ = 0; @@ -76,7 +76,7 @@ void local_uds_client_endpoint_impl::start() { void local_uds_client_endpoint_impl::stop() { { - std::lock_guard its_lock(mutex_); + std::lock_guard its_lock(mutex_); sending_blocked_ = true; } { @@ -111,6 +111,7 @@ void local_uds_client_endpoint_impl::stop() { } void local_uds_client_endpoint_impl::connect() { + start_connecting_timer(); boost::system::error_code its_connect_error; { std::lock_guard its_lock(socket_mutex_); @@ -127,7 +128,7 @@ void local_uds_client_endpoint_impl::connect() { socket_->connect(remote_, its_connect_error); // Credentials -#ifndef __QNX__ + #ifndef __QNX__ if (!its_connect_error) { auto its_host = endpoint_host_.lock(); if (its_host) { @@ -140,7 +141,7 @@ void local_uds_client_endpoint_impl::connect() { << its_connect_error.message() << " / " << std::dec << its_connect_error.value() << ")"; } -#endif + #endif } else { VSOMEIP_WARNING << "local_client_endpoint::connect: Error opening socket: " << its_error.message() << " (" << std::dec << its_error.value() @@ -148,13 +149,20 @@ void local_uds_client_endpoint_impl::connect() { its_connect_error = its_error; } } - // call connect_cbk asynchronously - try { - strand_.post( - std::bind(&client_endpoint_impl::connect_cbk, shared_from_this(), - its_connect_error)); - } catch (const std::exception &e) { - VSOMEIP_ERROR << "local_client_endpoint_impl::connect: " << e.what(); + std::size_t operations_cancelled; + { + std::lock_guard its_lock(connecting_timer_mutex_); + operations_cancelled = connecting_timer_.cancel(); + } + if (operations_cancelled != 0) { + // call connect_cbk asynchronously + try { + strand_.post( + std::bind(&client_endpoint_impl::connect_cbk, shared_from_this(), + its_connect_error)); + } catch (const std::exception &e) { + VSOMEIP_ERROR << "local_client_endpoint_impl::connect: " << e.what(); + } } } @@ -180,9 +188,8 @@ void local_uds_client_endpoint_impl::receive() { // this overrides client_endpoint_impl::send to disable the pull method // for local communication bool local_uds_client_endpoint_impl::send(const uint8_t *_data, uint32_t _size) { - std::lock_guard its_lock(mutex_); + std::lock_guard its_lock(mutex_); bool ret(true); - const bool queue_size_zero_on_entry(queue_.empty()); if (endpoint_impl::sending_blocked_ || check_message_size(nullptr, _size) != cms_ret_e::MSG_OK || !check_packetizer_space(_size) || @@ -198,7 +205,7 @@ bool local_uds_client_endpoint_impl::send(const uint8_t *_data, uint32_t _size) VSOMEIP_INFO << msg.str(); #endif train_->buffer_->insert(train_->buffer_->end(), _data, _data + _size); - queue_train(train_, queue_size_zero_on_entry); + queue_train(train_); train_->buffer_ = std::make_shared(); } return ret; @@ -320,7 +327,7 @@ void local_uds_client_endpoint_impl::print_status() { std::size_t its_queue_size(0); { - std::lock_guard its_lock(mutex_); + std::lock_guard its_lock(mutex_); its_queue_size = queue_.size(); its_data_size = queue_size_; } diff --git a/implementation/endpoints/src/local_uds_server_endpoint_impl.cpp b/implementation/endpoints/src/local_uds_server_endpoint_impl.cpp index 2875776e0..e23b59864 100644 --- a/implementation/endpoints/src/local_uds_server_endpoint_impl.cpp +++ b/implementation/endpoints/src/local_uds_server_endpoint_impl.cpp @@ -1,4 +1,4 @@ -// Copyright (C) 2014-2021 Bayerische Motoren Werke Aktiengesellschaft (BMW AG) +// Copyright (C) 2014-2023 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/. @@ -64,7 +64,6 @@ local_uds_server_endpoint_impl::local_uds_server_endpoint_impl( if (ec) VSOMEIP_ERROR << __func__ << ": listen failed (" << ec.message() << ")"; - #ifndef __QNX__ if (chmod(_local.path().c_str(), static_cast(_configuration->get_permissions_uds())) == -1) { @@ -286,9 +285,9 @@ void local_uds_server_endpoint_impl::accept_cbk( std::string its_client_host; vsomeip_sec_client_t its_sec_client; - its_sec_client.client_type = VSOMEIP_CLIENT_UDS; - its_sec_client.client.uds_client.user = ANY_UID; - its_sec_client.client.uds_client.group = ANY_GID; + its_sec_client.port = VSOMEIP_SEC_PORT_UNUSED; + its_sec_client.user = ANY_UID; + its_sec_client.group = ANY_GID; socket_type &its_socket = _connection->get_socket(); if (auto creds = credentials::receive_credentials(its_socket.native_handle())) { @@ -296,8 +295,8 @@ void local_uds_server_endpoint_impl::accept_cbk( its_client = std::get<0>(*creds); its_client_host = std::get<3>(*creds); - its_sec_client.client.uds_client.user = std::get<1>(*creds); - its_sec_client.client.uds_client.group = std::get<2>(*creds); + its_sec_client.user = std::get<1>(*creds); + its_sec_client.group = std::get<2>(*creds); } else { VSOMEIP_WARNING << "vSomeIP Security: Client 0x" << std::hex << its_host->get_client() << " is rejecting new connection because client credentials couldn't be received!"; @@ -312,8 +311,8 @@ void local_uds_server_endpoint_impl::accept_cbk( VSOMEIP_WARNING << "vSomeIP Security: Rejecting new connection with routing manager client ID 0x" << std::hex << its_client << " uid/gid= " << std::dec - << its_sec_client.client.uds_client.user << "/" - << its_sec_client.client.uds_client.group + << its_sec_client.user << "/" + << its_sec_client.group << " because passed credentials do not match with routing manager credentials!"; boost::system::error_code er; its_socket.shutdown(its_socket.shutdown_both, er); @@ -334,8 +333,8 @@ void local_uds_server_endpoint_impl::accept_cbk( VSOMEIP_WARNING << "vSomeIP Security: Client 0x" << std::hex << its_host->get_client() << " is rejecting new connection with client ID 0x" << its_client << " uid/gid= " << std::dec - << its_sec_client.client.uds_client.user << "/" - << its_sec_client.client.uds_client.group + << its_sec_client.user << "/" + << its_sec_client.group << " because of already existing connection using same client ID"; boost::system::error_code er; its_socket.shutdown(its_socket.shutdown_both, er); @@ -352,8 +351,8 @@ void local_uds_server_endpoint_impl::accept_cbk( VSOMEIP_WARNING << "vSomeIP Security: Client 0x" << std::hex << its_host->get_client() << " received client credentials from client 0x" << its_client << " which violates the security policy : uid/gid=" - << std::dec << its_sec_client.client.uds_client.user << "/" - << its_sec_client.client.uds_client.group; + << std::dec << its_sec_client.user << "/" + << its_sec_client.group; boost::system::error_code er; its_socket.shutdown(its_socket.shutdown_both, er); its_socket.close(er); @@ -375,7 +374,6 @@ void local_uds_server_endpoint_impl::accept_cbk( } _connection->set_bound_client_host(its_client_host); } - #endif _connection->start(); } @@ -402,15 +400,15 @@ local_uds_server_endpoint_impl::connection::connection( buffer_shrink_threshold_(_buffer_shrink_threshold), bound_client_(VSOMEIP_CLIENT_UNSET), bound_client_host_(""), - assigned_client_(false) { + assigned_client_(false), + is_stopped_(true) { if (_server->is_routing_endpoint_ && !_server->configuration_->is_security_enabled()) { assigned_client_ = true; } - sec_client_.client_type = VSOMEIP_CLIENT_UDS; - sec_client_.client.uds_client.user = ANY_UID; - sec_client_.client.uds_client.group = ANY_GID; + sec_client_.user = ANY_UID; + sec_client_.group = ANY_GID; } local_uds_server_endpoint_impl::connection::ptr @@ -477,6 +475,7 @@ void local_uds_server_endpoint_impl::connection::start() { return; } + is_stopped_ = false; #if VSOMEIP_BOOST_VERSION >= 106600 local_server_endpoint_impl_receive_op its_operation { socket_, @@ -513,14 +512,14 @@ void local_uds_server_endpoint_impl::connection::start() { void local_uds_server_endpoint_impl::connection::stop() { std::lock_guard its_lock(socket_mutex_); + is_stopped_ = true; if (socket_.is_open()) { if (-1 == fcntl(socket_.native_handle(), F_GETFD)) { VSOMEIP_ERROR << "lse: socket/handle closed already '" << std::string(std::strerror(errno)) << "' (" << errno << ") " << get_path_local(); } boost::system::error_code its_error; - socket_.shutdown(socket_.shutdown_both, its_error); - socket_.close(its_error); + socket_.cancel(its_error); } } @@ -782,8 +781,8 @@ void local_uds_server_endpoint_impl::connection::receive_cbk( VSOMEIP_WARNING << std::hex << "Client 0x" << its_host->get_client() << " is rejecting new connection with client ID 0x" << its_client << " uid/gid= " << std::dec - << sec_client_.client.uds_client.user << "/" - << sec_client_.client.uds_client.group + << sec_client_.user << "/" + << sec_client_.group << " because of already existing connection using same client ID"; stop(); return; @@ -792,8 +791,8 @@ void local_uds_server_endpoint_impl::connection::receive_cbk( VSOMEIP_WARNING << std::hex << "Client 0x" << its_host->get_client() << " received client credentials from client 0x" << its_client << " which violates the security policy : uid/gid=" - << std::dec << sec_client_.client.uds_client.user << "/" - << sec_client_.client.uds_client.group; + << std::dec << sec_client_.user << "/" + << sec_client_.group; its_server->remove_connection(its_client); utility::release_client_id(its_config->get_network(), its_client); @@ -812,11 +811,11 @@ void local_uds_server_endpoint_impl::connection::receive_cbk( assigned_client_ = true; } else if (!its_server->is_routing_endpoint_ || assigned_client_) { - vsomeip_sec_client_t its_sec_client; - memset(&its_sec_client, 0, sizeof(its_sec_client)); - its_sec_client.client_type = VSOMEIP_CLIENT_UDS; - its_sec_client.client.uds_client.user = _uid; - its_sec_client.client.uds_client.group = _gid; + vsomeip_sec_client_t its_sec_client{}; + + its_sec_client.port = VSOMEIP_SEC_PORT_UNUSED; + its_sec_client.user = _uid; + its_sec_client.group = _gid; its_host->on_message(&recv_buffer_[its_start], uint32_t(its_end - its_start), its_server.get(), @@ -859,10 +858,11 @@ void local_uds_server_endpoint_impl::connection::receive_cbk( } while (recv_buffer_size_ > 0 && found_message); } - if (_error == boost::asio::error::eof + if (is_stopped_ + || _error == boost::asio::error::eof || _error == boost::asio::error::connection_reset || is_error) { - stop(); + shutdown_and_close(); its_server->remove_connection(bound_client_); policy_manager_impl::get()->remove_client_to_sec_client_mapping(bound_client_); } else if (_error != boost::asio::error::bad_descriptor) { @@ -954,9 +954,7 @@ void local_uds_server_endpoint_impl::connection::handle_recv_buffer_exception( VSOMEIP_ERROR << "lse: socket/handle closed already '" << std::string(std::strerror(errno)) << "' (" << errno << ") " << get_path_local(); } - boost::system::error_code its_error; - socket_.shutdown(socket_.shutdown_both, its_error); - socket_.close(its_error); + } std::shared_ptr its_server = server_.lock(); if (its_server) { @@ -969,6 +967,19 @@ local_uds_server_endpoint_impl::connection::get_recv_buffer_capacity() const { return recv_buffer_.capacity(); } +void +local_uds_server_endpoint_impl::connection::shutdown_and_close() { + std::lock_guard its_lock(socket_mutex_); + shutdown_and_close_unlocked(); +} + +void +local_uds_server_endpoint_impl::connection::shutdown_and_close_unlocked() { + boost::system::error_code its_error; + socket_.shutdown(socket_.shutdown_both, its_error); + socket_.close(its_error); +} + void local_uds_server_endpoint_impl::print_status() { std::lock_guard its_lock(mutex_); connections_t its_connections; @@ -995,6 +1006,7 @@ void local_uds_server_endpoint_impl::print_status() { << " recv_buffer: " << std::dec << its_recv_size; } } + std::string local_uds_server_endpoint_impl::get_remote_information( const target_data_iterator_type _it) const { diff --git a/implementation/endpoints/src/server_endpoint_impl.cpp b/implementation/endpoints/src/server_endpoint_impl.cpp index 1572c83b7..90e4b85c8 100644 --- a/implementation/endpoints/src/server_endpoint_impl.cpp +++ b/implementation/endpoints/src/server_endpoint_impl.cpp @@ -1,4 +1,4 @@ -// Copyright (C) 2014-2021 Bayerische Motoren Werke Aktiengesellschaft (BMW AG) +// Copyright (C) 2014-2023 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/. @@ -540,8 +540,8 @@ bool server_endpoint_impl::queue_train( bool must_erase(false); auto &its_data = _it->second; - its_data.queue_.push_back(std::make_pair(_train->buffer_, 0)); its_data.queue_size_ += _train->buffer_->size(); + its_data.queue_.emplace_back(_train->buffer_, 0); if (!its_data.is_sending_) { // no writing in progress must_erase = send_queued(_it); @@ -705,8 +705,8 @@ void server_endpoint_impl::send_cbk( cancel_dispatch_timer(it); targets_.erase(it); check_if_all_queues_are_empty(); - } - its_data.is_sending_ = false; + } else + its_data.is_sending_ = false; } } else { message_buffer_ptr_t its_buffer; diff --git a/implementation/endpoints/src/tcp_client_endpoint_impl.cpp b/implementation/endpoints/src/tcp_client_endpoint_impl.cpp index 2eb83d82c..f42d93d41 100644 --- a/implementation/endpoints/src/tcp_client_endpoint_impl.cpp +++ b/implementation/endpoints/src/tcp_client_endpoint_impl.cpp @@ -1,4 +1,4 @@ -// Copyright (C) 2014-2021 Bayerische Motoren Werke Aktiengesellschaft (BMW AG) +// Copyright (C) 2014-2023 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/. @@ -50,7 +50,6 @@ tcp_client_endpoint_impl::tcp_client_endpoint_impl( tcp_restart_aborts_max_(configuration_->get_max_tcp_restart_aborts()), tcp_connect_time_max_(configuration_->get_max_tcp_connect_time()), aborted_restart_count_(0), - is_sending_(false), sent_timer_(_io) { is_supporting_magic_cookies_ = true; @@ -101,7 +100,7 @@ void tcp_client_endpoint_impl::restart(bool _force) { self->was_not_connected_ = true; self->reconnect_counter_ = 0; { - std::lock_guard its_lock(self->mutex_); + std::lock_guard its_lock(self->mutex_); for (const auto &q : self->queue_) { const service_t its_service = VSOMEIP_BYTES_TO_WORD( (*q.first)[VSOMEIP_SERVICE_POS_MIN], @@ -206,7 +205,6 @@ void tcp_client_endpoint_impl::connect() { << ":" << std::dec << local_.port() << " remote:" << get_address_port_remote(); } else { - local_.port(local_port_); VSOMEIP_INFO << "tcp_client_endpoint::connect: " "Using new new local port for tce: " << " local: " << local_.address().to_string() @@ -214,19 +212,22 @@ void tcp_client_endpoint_impl::connect() { << " remote:" << get_address_port_remote(); } } + std::size_t operations_cancelled; { std::lock_guard its_lock(connecting_timer_mutex_); - connecting_timer_.cancel(); + operations_cancelled = connecting_timer_.cancel(); } - try { - // don't connect on bind error to avoid using a random port - strand_.post(std::bind(&client_endpoint_impl::connect_cbk, - shared_from_this(), its_bind_error)); - } catch (const std::exception &e) { - VSOMEIP_ERROR << "tcp_client_endpoint_impl::connect: " - << e.what() - << " local: " << get_address_port_local() - << " remote:" << get_address_port_remote(); + if (operations_cancelled != 0) { + try { + // don't connect on bind error to avoid using a random port + strand_.post(std::bind(&client_endpoint_impl::connect_cbk, + shared_from_this(), its_bind_error)); + } catch (const std::exception &e) { + VSOMEIP_ERROR << "tcp_client_endpoint_impl::connect: " + << e.what() + << " local: " << get_address_port_local() + << " remote:" << get_address_port_remote(); + } } return; } @@ -245,14 +246,17 @@ void tcp_client_endpoint_impl::connect() { ) ); } else { - VSOMEIP_WARNING << "tcp_client_endpoint::connect: Error opening socket: " - << its_error.message() << " remote:" << get_address_port_remote(); + std::size_t operations_cancelled; { std::lock_guard its_lock(connecting_timer_mutex_); - connecting_timer_.cancel(); + operations_cancelled = connecting_timer_.cancel(); + } + if (operations_cancelled != 0) { + VSOMEIP_WARNING << "tcp_client_endpoint::connect: Error opening socket: " + << its_error.message() << " remote:" << get_address_port_remote(); + strand_.post(std::bind(&tcp_client_endpoint_base_impl::connect_cbk, + shared_from_this(), its_error)); } - strand_.post(std::bind(&tcp_client_endpoint_base_impl::connect_cbk, - shared_from_this(), its_error)); } } @@ -359,10 +363,6 @@ void tcp_client_endpoint_impl::send_queued(std::pair its_lock(socket_mutex_); if (socket_->is_open()) { - { - std::lock_guard its_sent_lock(sent_mutex_); - is_sending_ = true; - } boost::asio::async_write( *socket_, boost::asio::buffer(*_entry.first), @@ -405,17 +405,53 @@ bool tcp_client_endpoint_impl::get_remote_address( return true; } +uint16_t tcp_client_endpoint_impl::get_local_port() const { + + uint16_t its_port(0); + + // Local port may be zero, if no client ports are configured + std::lock_guard its_lock(socket_mutex_); + if (socket_->is_open()) { + boost::system::error_code its_error; + endpoint_type its_local = socket_->local_endpoint(its_error); + if (!its_error) { + its_port = its_local.port(); + return its_port; + } + } + + return local_.port(); +} + void tcp_client_endpoint_impl::set_local_port() { std::lock_guard its_lock(socket_mutex_); boost::system::error_code its_error; if (socket_->is_open()) { endpoint_type its_endpoint = socket_->local_endpoint(its_error); if (!its_error) { - local_port_ = its_endpoint.port(); + local_.port(its_endpoint.port()); } else { VSOMEIP_WARNING << "tcp_client_endpoint_impl::set_local_port() " - << " couldn't get local_endpoint: " << its_error.message(); + << " couldn't get local_endpoint: " << its_error.message(); } + } else { + VSOMEIP_WARNING << "tcp_client_endpoint_impl::set_local_port() " + << "failed to set port because the socket is not opened"; + } +} + +void tcp_client_endpoint_impl::set_local_port(port_t _port) { + + std::lock_guard its_lock(socket_mutex_); + if (!socket_->is_open()) { + local_.port(_port); + } else { + boost::system::error_code its_error; + endpoint_type its_endpoint = socket_->local_endpoint(its_error); + if (!its_error) + local_.port(its_endpoint.port()); + VSOMEIP_ERROR << "tcp_client_endpoint_impl::set_local_port() " + << "Cannot change port on open socket!"; } } @@ -555,6 +591,7 @@ void tcp_client_endpoint_impl::receive_cbk( } if (needs_forwarding) { if (!has_enabled_magic_cookies_) { + its_lock.unlock(); its_host->on_message(&(*_recv_buffer)[its_iteration_gap], current_message_size, this, false, @@ -562,9 +599,11 @@ void tcp_client_endpoint_impl::receive_cbk( nullptr, remote_address_, remote_port_); + its_lock.lock(); } else { // Only call on_message without a magic cookie in front of the buffer! if (!is_magic_cookie(_recv_buffer, its_iteration_gap)) { + its_lock.unlock(); its_host->on_message(&(*_recv_buffer)[its_iteration_gap], current_message_size, this, false, @@ -572,6 +611,7 @@ void tcp_client_endpoint_impl::receive_cbk( nullptr, remote_address_, remote_port_); + its_lock.lock(); } } } @@ -593,12 +633,20 @@ void tcp_client_endpoint_impl::receive_cbk( } if (!has_full_message) { - if (_recv_buffer_size > VSOMEIP_RETURN_CODE_POS && - ((*recv_buffer_)[its_iteration_gap + VSOMEIP_PROTOCOL_VERSION_POS] != VSOMEIP_PROTOCOL_VERSION || - !utility::is_valid_message_type(static_cast((*recv_buffer_)[its_iteration_gap + VSOMEIP_MESSAGE_TYPE_POS])) || - !utility::is_valid_return_code(static_cast((*recv_buffer_)[its_iteration_gap + VSOMEIP_RETURN_CODE_POS])) - )) { - if ((*recv_buffer_)[its_iteration_gap + VSOMEIP_PROTOCOL_VERSION_POS] != VSOMEIP_PROTOCOL_VERSION) { + if (_recv_buffer_size > VSOMEIP_RETURN_CODE_POS) { + bool invalid_parameter_detected { false }; + if (recv_buffer_->size() <= (its_iteration_gap + VSOMEIP_RETURN_CODE_POS)) { + VSOMEIP_ERROR << "TCP Client receive_cbk is trying to access invalid vector position." + << " Actual: " << recv_buffer_->size() + << " Received: " << _recv_buffer->size() + << " Current: " << current_message_size + << " Indicated: " << _recv_buffer_size + << " Bytes: " << _bytes + << " Iteration_gap: " << its_iteration_gap + << " Is_full_message: " << has_full_message; + return; + } else if ((*recv_buffer_)[its_iteration_gap + VSOMEIP_PROTOCOL_VERSION_POS] != VSOMEIP_PROTOCOL_VERSION) { + invalid_parameter_detected = true; VSOMEIP_ERROR << "tce: Wrong protocol version: 0x" << std::hex << std::setw(2) << std::setfill('0') << std::uint32_t((*recv_buffer_)[its_iteration_gap + VSOMEIP_PROTOCOL_VERSION_POS]) @@ -606,7 +654,6 @@ void tcp_client_endpoint_impl::receive_cbk( << " remote: " << get_address_port_remote(); // ensure to send back a message w/ wrong protocol version its_lock.unlock(); - its_host->on_message(&(*_recv_buffer)[its_iteration_gap], VSOMEIP_SOMEIP_HEADER_SIZE + 8, this, false, @@ -617,6 +664,7 @@ void tcp_client_endpoint_impl::receive_cbk( its_lock.lock(); } else if (!utility::is_valid_message_type(static_cast( (*recv_buffer_)[its_iteration_gap + VSOMEIP_MESSAGE_TYPE_POS]))) { + invalid_parameter_detected = true; VSOMEIP_ERROR << "tce: Invalid message type: 0x" << std::hex << std::setw(2) << std::setfill('0') << std::uint32_t((*recv_buffer_)[its_iteration_gap + VSOMEIP_MESSAGE_TYPE_POS]) @@ -624,21 +672,26 @@ void tcp_client_endpoint_impl::receive_cbk( << " remote: " << get_address_port_remote(); } else if (!utility::is_valid_return_code(static_cast( (*recv_buffer_)[its_iteration_gap + VSOMEIP_RETURN_CODE_POS]))) { + invalid_parameter_detected = true; VSOMEIP_ERROR << "tce: Invalid return code: 0x" << std::hex << std::setw(2) << std::setfill('0') << std::uint32_t((*recv_buffer_)[its_iteration_gap + VSOMEIP_RETURN_CODE_POS]) << " local: " << get_address_port_local() << " remote: " << get_address_port_remote(); } - state_ = cei_state_e::CONNECTING; - shutdown_and_close_socket_unlocked(false); - its_lock.unlock(); - // wait_until_sent interprets "no error" as timeout. - // Therefore call it with an error. - wait_until_sent(boost::asio::error::operation_aborted); - return; - } else if (max_message_size_ != MESSAGE_SIZE_UNLIMITED && + if (invalid_parameter_detected) { + state_ = cei_state_e::CONNECTING; + shutdown_and_close_socket_unlocked(false); + its_lock.unlock(); + + // wait_until_sent interprets "no error" as timeout. + // Therefore call it with an error. + wait_until_sent(boost::asio::error::operation_aborted); + return; + } + } + if (max_message_size_ != MESSAGE_SIZE_UNLIMITED && current_message_size > max_message_size_) { _recv_buffer_size = 0; _recv_buffer->resize(recv_buffer_size_initial_, 0x0); @@ -821,7 +874,7 @@ void tcp_client_endpoint_impl::handle_recv_buffer_exception( VSOMEIP_ERROR << its_message.str(); _recv_buffer->clear(); { - std::lock_guard its_lock(mutex_); + std::lock_guard its_lock(mutex_); sending_blocked_ = true; } { @@ -841,7 +894,7 @@ void tcp_client_endpoint_impl::print_status() { std::size_t its_queue_size(0); std::size_t its_receive_buffer_capacity(0); { - std::lock_guard its_lock(mutex_); + std::lock_guard its_lock(mutex_); its_queue_size = queue_.size(); its_data_size = queue_size_; } @@ -870,82 +923,82 @@ void tcp_client_endpoint_impl::send_cbk(boost::system::error_code const &_error, const message_buffer_ptr_t& _sent_msg) { (void)_bytes; - { - // Signal that the current send operation has finished. - // Note: Waiting is always done after having closed the socket. - // Therefore, no new send operation will be scheduled. - std::lock_guard its_sent_lock(sent_mutex_); - is_sending_ = false; - - boost::system::error_code ec; - sent_timer_.cancel(ec); - } + std::lock_guard its_lock(mutex_); + boost::system::error_code ec; + sent_timer_.cancel(ec); if (!_error) { - std::lock_guard its_lock(mutex_); if (queue_.size() > 0) { queue_size_ -= queue_.front().first->size(); queue_.pop_front(); update_last_departure(); - auto its_entry = get_front(); - if (its_entry.first) { - auto self = std::dynamic_pointer_cast< tcp_client_endpoint_impl >(shared_from_this()); - strand_.dispatch( - [self, &its_entry]() { self->send_queued(its_entry);} - ); + if (queue_.empty()) + is_sending_ = false; + else { + auto its_entry = get_front(); + if (its_entry.first) { + auto self = std::dynamic_pointer_cast< tcp_client_endpoint_impl >(shared_from_this()); + strand_.dispatch( + [self, &its_entry]() { self->send_queued(its_entry);} + ); + } } } - } else if (_error == boost::system::errc::destination_address_required) { - VSOMEIP_WARNING << "tce::send_cbk received error: " << _error.message() - << " (" << std::dec << _error.value() << ") " - << get_remote_information(); - was_not_connected_ = true; - } else if (_error == boost::asio::error::operation_aborted) { - // endpoint was stopped - shutdown_and_close_socket(false); + return; } else { - if (state_ == cei_state_e::CONNECTING) { - VSOMEIP_WARNING << "tce::send_cbk endpoint is already restarting:" - << get_remote_information(); - } else { - state_ = cei_state_e::CONNECTING; + is_sending_ = false; + + if (_error == boost::system::errc::destination_address_required) { + VSOMEIP_WARNING << "tce::send_cbk received error: " << _error.message() + << " (" << std::dec << _error.value() << ") " + << get_remote_information(); + was_not_connected_ = true; + } else if (_error == boost::asio::error::operation_aborted) { + // endpoint was stopped shutdown_and_close_socket(false); - std::shared_ptr its_host = endpoint_host_.lock(); - if (its_host) { - its_host->on_disconnect(shared_from_this()); + } else { + if (state_ == cei_state_e::CONNECTING) { + VSOMEIP_WARNING << "tce::send_cbk endpoint is already restarting:" + << get_remote_information(); + } else { + state_ = cei_state_e::CONNECTING; + shutdown_and_close_socket(false); + std::shared_ptr its_host = endpoint_host_.lock(); + if (its_host) { + its_host->on_disconnect(shared_from_this()); + } + restart(true); } - restart(true); - } - service_t its_service(0); - method_t its_method(0); - client_t its_client(0); - session_t its_session(0); - if (_sent_msg && _sent_msg->size() > VSOMEIP_SESSION_POS_MAX) { - its_service = VSOMEIP_BYTES_TO_WORD( - (*_sent_msg)[VSOMEIP_SERVICE_POS_MIN], - (*_sent_msg)[VSOMEIP_SERVICE_POS_MAX]); - its_method = VSOMEIP_BYTES_TO_WORD( - (*_sent_msg)[VSOMEIP_METHOD_POS_MIN], - (*_sent_msg)[VSOMEIP_METHOD_POS_MAX]); - its_client = VSOMEIP_BYTES_TO_WORD( - (*_sent_msg)[VSOMEIP_CLIENT_POS_MIN], - (*_sent_msg)[VSOMEIP_CLIENT_POS_MAX]); - its_session = VSOMEIP_BYTES_TO_WORD( - (*_sent_msg)[VSOMEIP_SESSION_POS_MIN], - (*_sent_msg)[VSOMEIP_SESSION_POS_MAX]); + service_t its_service(0); + method_t its_method(0); + client_t its_client(0); + session_t its_session(0); + if (_sent_msg && _sent_msg->size() > VSOMEIP_SESSION_POS_MAX) { + its_service = VSOMEIP_BYTES_TO_WORD( + (*_sent_msg)[VSOMEIP_SERVICE_POS_MIN], + (*_sent_msg)[VSOMEIP_SERVICE_POS_MAX]); + its_method = VSOMEIP_BYTES_TO_WORD( + (*_sent_msg)[VSOMEIP_METHOD_POS_MIN], + (*_sent_msg)[VSOMEIP_METHOD_POS_MAX]); + its_client = VSOMEIP_BYTES_TO_WORD( + (*_sent_msg)[VSOMEIP_CLIENT_POS_MIN], + (*_sent_msg)[VSOMEIP_CLIENT_POS_MAX]); + its_session = VSOMEIP_BYTES_TO_WORD( + (*_sent_msg)[VSOMEIP_SESSION_POS_MIN], + (*_sent_msg)[VSOMEIP_SESSION_POS_MAX]); + } + VSOMEIP_WARNING << "tce::send_cbk received error: " + << _error.message() << " (" << std::dec + << _error.value() << ") " << get_remote_information() + << " " << std::dec << queue_.size() + << " " << std::dec << queue_size_ << " (" + << std::hex << std::setw(4) << std::setfill('0') << its_client <<"): [" + << std::hex << std::setw(4) << std::setfill('0') << its_service << "." + << std::hex << std::setw(4) << std::setfill('0') << its_method << "." + << std::hex << std::setw(4) << std::setfill('0') << its_session << "]"; } - VSOMEIP_WARNING << "tce::send_cbk received error: " - << _error.message() << " (" << std::dec - << _error.value() << ") " << get_remote_information() - << " " << std::dec << queue_.size() - << " " << std::dec << queue_size_ << " (" - << std::hex << std::setfill('0') - << std::setw(4) << its_client << "): [" - << std::setw(4) << its_service << "." - << std::setw(4) << its_method << "." - << std::setw(4) << its_session << "]"; } } @@ -966,9 +1019,9 @@ void tcp_client_endpoint_impl::max_allowed_reconnects_reached() { void tcp_client_endpoint_impl::wait_until_sent(const boost::system::error_code &_error) { - std::unique_lock its_sent_lock(sent_mutex_); + std::unique_lock its_lock(mutex_); if (!is_sending_ || !_error) { - its_sent_lock.unlock(); + its_lock.unlock(); if (!_error) VSOMEIP_WARNING << __func__ << ": Maximum wait time for send operation exceeded for tce."; diff --git a/implementation/endpoints/src/tcp_server_endpoint_impl.cpp b/implementation/endpoints/src/tcp_server_endpoint_impl.cpp index e7606c6a3..f83252ae2 100644 --- a/implementation/endpoints/src/tcp_server_endpoint_impl.cpp +++ b/implementation/endpoints/src/tcp_server_endpoint_impl.cpp @@ -1,5 +1,5 @@ -// Copyright (C) 2014-2021 Bayerische Motoren Werke Aktiengesellschaft (BMW AG) +// Copyright (C) 2014-2023 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/. @@ -141,7 +141,7 @@ bool tcp_server_endpoint_impl::send_error( its_data.queue_size_ += _size; if (!its_data.is_sending_) { // no writing in progress - send_queued(its_target_iterator); + (void)send_queued(its_target_iterator); } ret = true; } @@ -157,6 +157,9 @@ bool tcp_server_endpoint_impl::send_queued(const target_data_iterator_type _it) auto connection_iterator = connections_.find(_it->first); if (connection_iterator != connections_.end()) { its_connection = connection_iterator->second; + if (its_connection) { + its_connection->send_queued(_it); + } } else { VSOMEIP_INFO << "Didn't find connection: " << _it->first.address().to_string() << ":" << std::dec @@ -196,12 +199,11 @@ bool tcp_server_endpoint_impl::send_queued(const target_data_iterator_type _it) } } + // Drop outstanding messages. + _it->second.queue_.clear(); must_erase = true; } } - if (its_connection) { - its_connection->send_queued(_it); - } return (must_erase); } diff --git a/implementation/endpoints/src/tp.cpp b/implementation/endpoints/src/tp.cpp index 4b2d2e50a..359995086 100644 --- a/implementation/endpoints/src/tp.cpp +++ b/implementation/endpoints/src/tp.cpp @@ -1,4 +1,4 @@ -// Copyright (C) 2019-2021 Bayerische Motoren Werke Aktiengesellschaft (BMW AG) +// Copyright (C) 2019-2023 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/. diff --git a/implementation/endpoints/src/tp_message.cpp b/implementation/endpoints/src/tp_message.cpp index 0d27a90a4..986976f08 100644 --- a/implementation/endpoints/src/tp_message.cpp +++ b/implementation/endpoints/src/tp_message.cpp @@ -1,4 +1,4 @@ -// Copyright (C) 2019-2021 Bayerische Motoren Werke Aktiengesellschaft (BMW AG) +// Copyright (C) 2019-2023 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/. diff --git a/implementation/endpoints/src/udp_client_endpoint_impl.cpp b/implementation/endpoints/src/udp_client_endpoint_impl.cpp index 992db4e1f..d69522284 100644 --- a/implementation/endpoints/src/udp_client_endpoint_impl.cpp +++ b/implementation/endpoints/src/udp_client_endpoint_impl.cpp @@ -1,4 +1,4 @@ -// Copyright (C) 2014-2021 Bayerische Motoren Werke Aktiengesellschaft (BMW AG) +// Copyright (C) 2014-2023 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/. @@ -53,7 +53,7 @@ bool udp_client_endpoint_impl::is_local() const { } void udp_client_endpoint_impl::connect() { - std::lock_guard its_lock(socket_mutex_); + std::unique_lock its_lock(socket_mutex_); boost::system::error_code its_error; socket_->open(remote_.protocol(), its_error); if (!its_error || its_error == boost::asio::error::already_open) { @@ -135,6 +135,8 @@ void udp_client_endpoint_impl::connect() { << ":" << std::dec << local_.port() << " remote:" << get_address_port_remote(); + its_lock.unlock(); + std::shared_ptr its_host = endpoint_host_.lock(); if (its_host) { // set new client port depending on service / instance / remote port @@ -145,7 +147,6 @@ void udp_client_endpoint_impl::connect() { << ":" << std::dec << local_.port() << " remote:" << get_address_port_remote(); } else { - local_.port(local_port_); VSOMEIP_INFO << "udp_client_endpoint::connect: " "Using new new local port for uce: " << " local: " << local_.address().to_string() @@ -196,7 +197,7 @@ void udp_client_endpoint_impl::restart(bool _force) { } state_ = cei_state_e::CONNECTING; { - std::lock_guard its_lock(mutex_); + std::lock_guard its_lock(mutex_); queue_.clear(); } std::string local; @@ -213,7 +214,7 @@ void udp_client_endpoint_impl::restart(bool _force) { } void udp_client_endpoint_impl::send_queued(std::pair &_entry) { - static std::chrono::steady_clock::time_point its_last_sent; + #if 0 std::stringstream msg; msg << "ucei<" << remote_.address() << ":" @@ -224,23 +225,23 @@ void udp_client_endpoint_impl::send_queued(std::pair its_lock(socket_mutex_); + std::lock_guard its_last_sent_lock(last_sent_mutex_); + std::lock_guard its_socket_lock(socket_mutex_); // Check whether we need to wait (SOME/IP-TP separation time) if (_entry.second > 0) { - if (its_last_sent != std::chrono::steady_clock::time_point()) { + if (last_sent_ != std::chrono::steady_clock::time_point()) { const auto its_elapsed = std::chrono::duration_cast( - std::chrono::steady_clock::now() - its_last_sent).count(); + std::chrono::steady_clock::now() - last_sent_).count(); if (_entry.second > its_elapsed) std::this_thread::sleep_for( std::chrono::microseconds(_entry.second - its_elapsed)); } - its_last_sent = std::chrono::steady_clock::now(); + last_sent_ = std::chrono::steady_clock::now(); } else { - its_last_sent = std::chrono::steady_clock::time_point(); + last_sent_ = std::chrono::steady_clock::time_point(); } - // Send socket_->async_send( boost::asio::buffer(*_entry.first), @@ -296,17 +297,53 @@ bool udp_client_endpoint_impl::get_remote_address( return true; } +std::uint16_t udp_client_endpoint_impl::get_local_port() const { + + uint16_t its_port(0); + + // Local port may be zero, if no client ports are configured + std::lock_guard its_lock(socket_mutex_); + if (socket_->is_open()) { + boost::system::error_code its_error; + endpoint_type its_local = socket_->local_endpoint(its_error); + if (!its_error) { + its_port = its_local.port(); + return its_port; + } + } + + return local_.port(); +} + void udp_client_endpoint_impl::set_local_port() { std::lock_guard its_lock(socket_mutex_); boost::system::error_code its_error; if (socket_->is_open()) { endpoint_type its_endpoint = socket_->local_endpoint(its_error); if (!its_error) { - local_port_ = its_endpoint.port(); + local_.port(its_endpoint.port()); } else { VSOMEIP_WARNING << "udp_client_endpoint_impl::set_local_port() " - << " couldn't get local_endpoint: " << its_error.message(); + << "couldn't get local_endpoint: " << its_error.message(); } + } else { + VSOMEIP_WARNING << "udp_client_endpoint_impl::set_local_port() " + << "failed to set port because the socket is not opened"; + } +} + +void udp_client_endpoint_impl::set_local_port(port_t _port) { + + std::lock_guard its_lock(socket_mutex_); + if (!socket_->is_open()) { + local_.port(_port); + } else { + boost::system::error_code its_error; + endpoint_type its_endpoint = socket_->local_endpoint(its_error); + if (!its_error) + local_.port(its_endpoint.port()); + VSOMEIP_ERROR << "udp_client_endpoint_impl::set_local_port() " + << "Cannot change port on open socket!"; } } @@ -465,7 +502,7 @@ void udp_client_endpoint_impl::print_status() { std::size_t its_data_size(0); std::size_t its_queue_size(0); { - std::lock_guard its_lock(mutex_); + std::lock_guard its_lock(mutex_); its_queue_size = queue_.size(); its_data_size = queue_size_; } @@ -491,23 +528,28 @@ void udp_client_endpoint_impl::send_cbk(boost::system::error_code const &_error, std::size_t _bytes, const message_buffer_ptr_t &_sent_msg) { (void)_bytes; if (!_error) { - std::lock_guard its_lock(mutex_); + std::lock_guard its_lock(mutex_); if (queue_.size() > 0) { queue_size_ -= queue_.front().first->size(); queue_.pop_front(); update_last_departure(); - auto its_entry = get_front(); - if (its_entry.first) { - send_queued(its_entry); + if (queue_.empty()) + is_sending_ = false; + else { + auto its_entry = get_front(); + if (its_entry.first) { + send_queued(its_entry); + } } } + return; } else if (_error == boost::asio::error::broken_pipe) { state_ = cei_state_e::CLOSED; bool stopping(false); { - std::lock_guard its_lock(mutex_); + std::lock_guard its_lock(mutex_); stopping = sending_blocked_; if (stopping) { queue_.clear(); @@ -558,7 +600,7 @@ void udp_client_endpoint_impl::send_cbk(boost::system::error_code const &_error, VSOMEIP_WARNING << "uce::send_cbk received error: " << _error.message() << " (" << std::dec << _error.value() << ") " << get_remote_information(); - std::lock_guard its_lock(mutex_); + std::lock_guard its_lock(mutex_); queue_.clear(); queue_size_ = 0; } @@ -619,6 +661,9 @@ void udp_client_endpoint_impl::send_cbk(boost::system::error_code const &_error, << std::setw(4) << its_session << "]"; print_status(); } + + std::lock_guard its_lock(mutex_); + is_sending_ = false; } bool udp_client_endpoint_impl::tp_segmentation_enabled( diff --git a/implementation/endpoints/src/udp_server_endpoint_impl.cpp b/implementation/endpoints/src/udp_server_endpoint_impl.cpp index f1c5f509e..02e24c8c6 100644 --- a/implementation/endpoints/src/udp_server_endpoint_impl.cpp +++ b/implementation/endpoints/src/udp_server_endpoint_impl.cpp @@ -1,4 +1,4 @@ -// Copyright (C) 2014-2021 Bayerische Motoren Werke Aktiengesellschaft (BMW AG) +// Copyright (C) 2014-2023 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/. @@ -55,7 +55,8 @@ udp_server_endpoint_impl::udp_server_endpoint_impl( prefix_(_configuration->get_prefix()), local_port_(_local.port()), tp_reassembler_(std::make_shared(_configuration->get_max_message_size_unreliable(), _io)), - tp_cleanup_timer_(_io) { + tp_cleanup_timer_(_io), + is_stopped_(true) { is_supporting_someip_tp_ = true; boost::system::error_code ec; @@ -154,18 +155,19 @@ bool udp_server_endpoint_impl::is_local() const { } void udp_server_endpoint_impl::start() { + is_stopped_ = false; receive(); } void udp_server_endpoint_impl::stop() { server_endpoint_impl::stop(); + is_stopped_ = true; { std::lock_guard its_lock(unicast_mutex_); if (unicast_socket_.is_open()) { boost::system::error_code its_error; - unicast_socket_.shutdown(socket_type::shutdown_both, its_error); - unicast_socket_.close(its_error); + unicast_socket_.cancel(its_error); } } @@ -174,14 +176,40 @@ void udp_server_endpoint_impl::stop() { if (multicast_socket_ && multicast_socket_->is_open()) { boost::system::error_code its_error; - multicast_socket_->shutdown(socket_type::shutdown_both, its_error); - multicast_socket_->close(its_error); + multicast_socket_->cancel(its_error); } } tp_reassembler_->stop(); } +void udp_server_endpoint_impl::shutdown_and_close() { + { + std::lock_guard its_lock(unicast_mutex_); + unicast_shutdown_and_close_unlocked(); + } + + { + std::lock_guard its_lock(multicast_mutex_); + multicast_shutdown_and_close_unlocked(); + } +} + +void udp_server_endpoint_impl::unicast_shutdown_and_close_unlocked() { + boost::system::error_code its_error; + unicast_socket_.shutdown(socket_type::shutdown_both, its_error); + unicast_socket_.close(its_error); +} + +void udp_server_endpoint_impl::multicast_shutdown_and_close_unlocked() { + if (!multicast_socket_) { + return; + } + boost::system::error_code its_error; + multicast_socket_->shutdown(socket_type::shutdown_both, its_error); + multicast_socket_->close(its_error); +} + void udp_server_endpoint_impl::receive() { receive_unicast(); } @@ -286,7 +314,9 @@ bool udp_server_endpoint_impl::send_error( bool udp_server_endpoint_impl::send_queued( const target_data_iterator_type _it) { - static std::chrono::steady_clock::time_point its_last_sent; + std::lock_guard its_last_sent_lock(last_sent_mutex_); + std::lock_guard its_unicast_lock(unicast_mutex_); + const auto its_entry = _it->second.queue_.front(); #if 0 std::stringstream msg; @@ -297,21 +327,20 @@ bool udp_server_endpoint_impl::send_queued( << (int)(*its_entry.first)[i] << " "; VSOMEIP_INFO << msg.str(); #endif - std::lock_guard its_lock(unicast_mutex_); // Check whether we need to wait (SOME/IP-TP separation time) if (its_entry.second > 0) { - if (its_last_sent != std::chrono::steady_clock::time_point()) { + if (last_sent_ != std::chrono::steady_clock::time_point()) { const auto its_elapsed = std::chrono::duration_cast( - std::chrono::steady_clock::now() - its_last_sent).count(); + std::chrono::steady_clock::now() - last_sent_).count(); if (its_entry.second > its_elapsed) std::this_thread::sleep_for( std::chrono::microseconds(its_entry.second - its_elapsed)); } - its_last_sent = std::chrono::steady_clock::now(); + last_sent_ = std::chrono::steady_clock::now(); } else { - its_last_sent = std::chrono::steady_clock::time_point(); + last_sent_ = std::chrono::steady_clock::time_point(); } _it->second.is_sending_ = true; @@ -479,7 +508,11 @@ void udp_server_endpoint_impl::on_unicast_received( boost::system::error_code const &_error, std::size_t _bytes) { - if (_error != boost::asio::error::operation_aborted) { + if (is_stopped_ + || _error == boost::asio::error::eof + || _error == boost::asio::error::connection_reset) { + shutdown_and_close(); + } else if (_error != boost::asio::error::operation_aborted) { { // By locking the multicast mutex here it is ensured that unicast // & multicast messages are not processed in parallel. This aligns @@ -499,7 +532,11 @@ void udp_server_endpoint_impl::on_multicast_received( const boost::asio::ip::address &_destination) { std::lock_guard its_lock(multicast_mutex_); - if (_error != boost::asio::error::operation_aborted) { + if (is_stopped_ + || _error == boost::asio::error::eof + || _error == boost::asio::error::connection_reset) { + shutdown_and_close(); + } else if (_error != boost::asio::error::operation_aborted) { // Filter messages sent from the same source address if (multicast_remote_.address() != local_.address() && is_same_subnet(multicast_remote_.address())) { diff --git a/implementation/helper/boost/asio/detail/impl/socket_ops_ext_local.ipp b/implementation/helper/boost/asio/detail/impl/socket_ops_ext_local.ipp index ea2767a9f..03cdb9298 100644 --- a/implementation/helper/boost/asio/detail/impl/socket_ops_ext_local.ipp +++ b/implementation/helper/boost/asio/detail/impl/socket_ops_ext_local.ipp @@ -3,7 +3,7 @@ // ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ // // Copyright (c) 2003-2015 Christopher M. Kohlhoff (chris at kohlhoff dot com) -// Copyright (C) 2016-2019 Bayerische Motoren Werke Aktiengesellschaft (BMW AG) +// Copyright (C) 2016-2023 Bayerische Motoren Werke Aktiengesellschaft (BMW AG) // // Distributed under the Boost Software License, Version 1.0. (See accompanying // file LICENSE_boost or copy at http://www.boost.org/LICENSE_1_0.txt) diff --git a/implementation/logger/include/logger_impl.hpp b/implementation/logger/include/logger_impl.hpp index c827bf4f6..34f006468 100644 --- a/implementation/logger/include/logger_impl.hpp +++ b/implementation/logger/include/logger_impl.hpp @@ -32,6 +32,7 @@ class logger_impl { ~logger_impl(); std::shared_ptr get_configuration() const; + void set_configuration(const std::shared_ptr &_configuration); #ifdef USE_DLT void log(level_e _level, const char *_data); @@ -42,7 +43,9 @@ class logger_impl { private: static std::mutex mutex__; + std::shared_ptr configuration_; + mutable std::mutex configuration_mutex_; #ifdef USE_DLT #ifndef ANDROID diff --git a/implementation/logger/src/logger_impl.cpp b/implementation/logger/src/logger_impl.cpp index 0e2aed7fd..b7cd57e31 100644 --- a/implementation/logger/src/logger_impl.cpp +++ b/implementation/logger/src/logger_impl.cpp @@ -1,4 +1,4 @@ -// Copyright (C) 2020-2021 Bayerische Motoren Werke Aktiengesellschaft (BMW AG) +// Copyright (C) 2020-2023 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/. @@ -19,7 +19,7 @@ void logger_impl::init(const std::shared_ptr &_configuration) { std::lock_guard its_lock(mutex__); auto its_logger = logger_impl::get(); - its_logger->configuration_ = _configuration; + its_logger->set_configuration(_configuration); #ifdef USE_DLT # define VSOMEIP_LOG_DEFAULT_CONTEXT_ID "VSIP" @@ -45,9 +45,19 @@ logger_impl::~logger_impl() { std::shared_ptr logger_impl::get_configuration() const { + + std::lock_guard its_lock(configuration_mutex_); return configuration_; } +void +logger_impl::set_configuration( + const std::shared_ptr &_configuration) { + + std::lock_guard its_lock(configuration_mutex_); + configuration_ = _configuration; +} + #ifdef USE_DLT #ifndef ANDROID void diff --git a/implementation/message/src/message_impl.cpp b/implementation/message/src/message_impl.cpp index 106d17c88..47250c137 100644 --- a/implementation/message/src/message_impl.cpp +++ b/implementation/message/src/message_impl.cpp @@ -19,9 +19,8 @@ namespace vsomeip_v3 { message_impl::message_impl() : payload_(runtime::get()->create_payload()), - check_result_(0) { - - sec_client_.client_type = VSOMEIP_CLIENT_INVALID; + check_result_ {0}, + sec_client_ {ANY_UID, ANY_GID, 0, VSOMEIP_SEC_PORT_UNUSED} { } message_impl::~message_impl() { @@ -69,24 +68,12 @@ bool message_impl::is_valid_crc() const { uid_t message_impl::get_uid() const { - uid_t its_uid(ANY_UID); - - if (sec_client_.client_type == VSOMEIP_CLIENT_UDS) { - its_uid = sec_client_.client.uds_client.user; - } - - return its_uid; + return sec_client_.user; } gid_t message_impl::get_gid() const { - gid_t its_gid(ANY_GID); - - if (sec_client_.client_type == VSOMEIP_CLIENT_UDS) { - its_gid = sec_client_.client.uds_client.group; - } - - return its_gid; + return sec_client_.group; } vsomeip_sec_client_t message_impl::get_sec_client() const { diff --git a/implementation/plugin/src/plugin_manager_impl.cpp b/implementation/plugin/src/plugin_manager_impl.cpp index b8cd3871d..bea96d019 100644 --- a/implementation/plugin/src/plugin_manager_impl.cpp +++ b/implementation/plugin/src/plugin_manager_impl.cpp @@ -1,4 +1,4 @@ -// Copyright (C) 2016-2021 Bayerische Motoren Werke Aktiengesellschaft (BMW AG) +// Copyright (C) 2016-2023 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/. diff --git a/implementation/protocol/src/assign_client_command.cpp b/implementation/protocol/src/assign_client_command.cpp index 72ba0dd49..c5ebdfb59 100644 --- a/implementation/protocol/src/assign_client_command.cpp +++ b/implementation/protocol/src/assign_client_command.cpp @@ -41,7 +41,8 @@ assign_client_command::serialize(std::vector &_buffer, return; // serialize payload - std::memcpy(&_buffer[COMMAND_POSITION_PAYLOAD], name_.data(), name_.length()); + if (!name_.empty()) + std::memcpy(&_buffer[COMMAND_POSITION_PAYLOAD], name_.data(), name_.length()); } void @@ -58,13 +59,10 @@ assign_client_command::deserialize(const std::vector &_buffer, if (_error != error_e::ERROR_OK) return; - // payload? - if (size_ == 0) - return; - - // name - name_.assign(&_buffer[COMMAND_POSITION_PAYLOAD], - &_buffer[_buffer.size()-1]); + // name? + if (size_ > 0) + name_.assign(&_buffer[COMMAND_POSITION_PAYLOAD], + &_buffer[_buffer.size()-1]); } std::string diff --git a/implementation/protocol/src/distribute_security_policies_command.cpp b/implementation/protocol/src/distribute_security_policies_command.cpp index 3575b5190..63f6e70e6 100644 --- a/implementation/protocol/src/distribute_security_policies_command.cpp +++ b/implementation/protocol/src/distribute_security_policies_command.cpp @@ -75,10 +75,27 @@ distribute_security_policies_command::deserialize(const std::vector &_bu for (uint32_t i = 0; i < its_policies_count; i++) { uint32_t its_policy_size; + + // Check that the buffer contains the full policy size + if (its_offset + sizeof(its_policy_size) > _buffer.size()) { + + policies_.clear(); + _error = error_e::ERROR_NOT_ENOUGH_BYTES; + return; + } + std::memcpy(&its_policy_size, &_buffer[its_offset], sizeof(its_policy_size)); its_offset += sizeof(its_policy_size); + // Check that the buffer contains the full policy + if (its_offset + its_policy_size > _buffer.size()) { + + policies_.clear(); + _error = error_e::ERROR_NOT_ENOUGH_BYTES; + return; + } + const byte_t *its_policy_data = &_buffer[its_offset]; // set offset to the next policy diff --git a/implementation/routing/include/routing_manager_client.hpp b/implementation/routing/include/routing_manager_client.hpp index 5a1912124..b923ad961 100644 --- a/implementation/routing/include/routing_manager_client.hpp +++ b/implementation/routing/include/routing_manager_client.hpp @@ -1,4 +1,4 @@ -// Copyright (C) 2014-2021 Bayerische Motoren Werke Aktiengesellschaft (BMW AG) +// Copyright (C) 2014-2023 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/. diff --git a/implementation/routing/include/routing_manager_impl.hpp b/implementation/routing/include/routing_manager_impl.hpp index 07f731f98..987f9d3d2 100644 --- a/implementation/routing/include/routing_manager_impl.hpp +++ b/implementation/routing/include/routing_manager_impl.hpp @@ -144,8 +144,8 @@ class routing_manager_impl: public routing_manager_base, remote_subscription_id_t _id); void on_subscribe_nack(client_t _client, service_t _service, - instance_t _instance, eventgroup_t _eventgroup, event_t _event, - remote_subscription_id_t _id); + instance_t _instance, eventgroup_t _eventgroup, + bool _remove, remote_subscription_id_t _id); // interface to stub @@ -330,6 +330,8 @@ class routing_manager_impl: public routing_manager_base, client_t _bound_client, const vsomeip_sec_client_t *_sec_client, uint8_t _status_check = 0, bool _is_from_remote = false); + bool is_suppress_event(service_t _service, instance_t _instance, + event_t _event) const; void init_service_info(service_t _service, instance_t _instance, bool _is_local_service); diff --git a/implementation/routing/include/routing_manager_stub.hpp b/implementation/routing/include/routing_manager_stub.hpp index c427473f1..d30915af4 100644 --- a/implementation/routing/include/routing_manager_stub.hpp +++ b/implementation/routing/include/routing_manager_stub.hpp @@ -1,4 +1,4 @@ -// Copyright (C) 2014-2021 Bayerische Motoren Werke Aktiengesellschaft (BMW AG) +// Copyright (C) 2014-2023 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/. diff --git a/implementation/routing/include/routing_manager_stub_host.hpp b/implementation/routing/include/routing_manager_stub_host.hpp index 04825c8f0..d9863039d 100644 --- a/implementation/routing/include/routing_manager_stub_host.hpp +++ b/implementation/routing/include/routing_manager_stub_host.hpp @@ -57,14 +57,14 @@ class routing_manager_stub_host { major_version_t _major, event_t _event, const std::shared_ptr &_filter) = 0; - virtual void on_subscribe_nack(client_t _client, service_t _service, - instance_t _instance, eventgroup_t _eventgroup, event_t _event, - remote_subscription_id_t _subscription_id) = 0; - virtual void on_subscribe_ack(client_t _client, service_t _service, instance_t _instance, eventgroup_t _eventgroup, event_t _event, remote_subscription_id_t _subscription_id) = 0; + virtual void on_subscribe_nack(client_t _client, service_t _service, + instance_t _instance, eventgroup_t _eventgroup, + bool _remove, remote_subscription_id_t _subscription_id) = 0; + virtual void unsubscribe(client_t _client, const vsomeip_sec_client_t *_sec_client, service_t _service, instance_t _instance, eventgroup_t _eventgroup, event_t _event) = 0; diff --git a/implementation/routing/include/serviceinfo.hpp b/implementation/routing/include/serviceinfo.hpp index 5ea4c185c..85c2f87a0 100644 --- a/implementation/routing/include/serviceinfo.hpp +++ b/implementation/routing/include/serviceinfo.hpp @@ -6,6 +6,7 @@ #ifndef VSOMEIP_V3_SERVICEINFO_HPP_ #define VSOMEIP_V3_SERVICEINFO_HPP_ +#include #include #include #include @@ -69,8 +70,8 @@ class serviceinfo { std::mutex requesters_mutex_; std::set requesters_; - bool is_local_; - bool is_in_mainphase_; + std::atomic_bool is_local_; + std::atomic_bool is_in_mainphase_; }; } // namespace vsomeip_v3 diff --git a/implementation/routing/src/event.cpp b/implementation/routing/src/event.cpp index 8d0a1cf79..e0af104bd 100644 --- a/implementation/routing/src/event.cpp +++ b/implementation/routing/src/event.cpp @@ -251,7 +251,6 @@ event::set_payload_notify_pending(const std::shared_ptr &_payload) { void event::unset_payload(bool _force) { - std::lock_guard its_lock(mutex_); if (_force) { is_set_ = false; @@ -428,11 +427,12 @@ event::notify_one_unlocked(client_t _client, bool _force) { routing_->send(_client, update_, _force); } else { VSOMEIP_INFO << __func__ - << ": Notifying " + << ": Initial value for [" << std::hex << std::setw(4) << std::setfill('0') << get_service() << "." << get_instance() << "." << get_event() - << " to client " << _client - << " failed. Event payload not set!"; + << "] not yet set by the service/client." + << " Client " << _client + << " will not receive any initial notification!"; } } diff --git a/implementation/routing/src/routing_manager_base.cpp b/implementation/routing/src/routing_manager_base.cpp index b05c8a8eb..bd7b557ab 100644 --- a/implementation/routing/src/routing_manager_base.cpp +++ b/implementation/routing/src/routing_manager_base.cpp @@ -622,7 +622,7 @@ bool routing_manager_base::is_subscribe_to_any_event_allowed( void routing_manager_base::add_known_client(client_t _client, const std::string &_client_host) { #if !defined(VSOMEIP_DISABLE_SECURITY) && (defined(__linux__) || defined(ANDROID)) std::lock_guard lazy_lock(add_known_client_mutex_); - if (configuration_->is_security_enabled()) { + if (configuration_->is_security_enabled() && !configuration_->is_security_external()) { //Ignore if we have already loaded the policy extension policy_manager_impl::policy_loaded_e policy_loaded = policy_manager_impl::get()->is_policy_extension_loaded(_client_host); diff --git a/implementation/routing/src/routing_manager_client.cpp b/implementation/routing/src/routing_manager_client.cpp index 3b26ea3f5..e253288a5 100644 --- a/implementation/routing/src/routing_manager_client.cpp +++ b/implementation/routing/src/routing_manager_client.cpp @@ -1,4 +1,4 @@ -// Copyright (C) 2014-2021 Bayerische Motoren Werke Aktiengesellschaft (BMW AG) +// Copyright (C) 2014-2023 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/. @@ -247,23 +247,31 @@ routing_manager_client::on_net_state_change( if (!receiver_) receiver_ = ep_mgr_->create_local_server(shared_from_this()); - receiver_->start(); - is_started_ = true; - if (!sender_) - sender_ = ep_mgr_->create_local(VSOMEIP_ROUTING_CLIENT); - sender_->start(); + if (receiver_) { + receiver_->start(); + is_started_ = true; + + if (!sender_) + sender_ = ep_mgr_->create_local(VSOMEIP_ROUTING_CLIENT); + + if (sender_) + sender_->start(); + } } } else { if (is_local_link_available_) { is_started_ = false; state_ = inner_state_type_e::ST_DEREGISTERED; - on_disconnect(sender_); - sender_->stop(); + if (sender_) { + on_disconnect(sender_); + sender_->stop(); + } - receiver_->stop(); + if (receiver_) + receiver_->stop(); { std::lock_guard its_lock(local_services_mutex_); @@ -1322,7 +1330,7 @@ void routing_manager_client::on_message( << std::setw(4) << its_event << ":" << std::dec << (uint16_t)its_major << "] " << std::boolalpha << (its_pending_id != PENDING_SUBSCRIPTION_ID) - << " " + << " " << (_subscription_accepted ? std::to_string(its_count) + " accepted." : "not accepted."); @@ -2173,6 +2181,7 @@ void routing_manager_client::deregister_application() { void routing_manager_client::send_pong() const { protocol::pong_command its_command; + its_command.set_client(get_client()); std::vector its_buffer; protocol::error_e its_error; diff --git a/implementation/routing/src/routing_manager_impl.cpp b/implementation/routing/src/routing_manager_impl.cpp index 03302b3f1..46687250b 100644 --- a/implementation/routing/src/routing_manager_impl.cpp +++ b/implementation/routing/src/routing_manager_impl.cpp @@ -1,4 +1,4 @@ -// Copyright (C) 2014-2021 Bayerische Motoren Werke Aktiengesellschaft (BMW AG) +// Copyright (C) 2014-2023 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/. @@ -404,19 +404,18 @@ bool routing_manager_impl::offer_service(client_t _client, major_version_t _major, minor_version_t _minor, bool _must_queue) { - VSOMEIP_INFO << "OFFER(" - << std::hex << std::setfill('0') - << std::setw(4) << _client << "): [" - << std::setw(4) << _service << "." - << std::setw(4) << _instance - << ":" << std::dec << int(_major) << "." << _minor << "]" - << " (" << std::boolalpha << _must_queue << ")"; - // only queue commands if method was NOT called via erase_offer_command() if (_must_queue) { if (!insert_offer_command(_service, _instance, uint8_t(protocol::id_e::OFFER_SERVICE_ID), _client, _major, _minor)) { + VSOMEIP_INFO << __func__ << " (" + << std::hex << std::setw(4) << std::setfill('0') << _client <<"): [" + << std::hex << std::setw(4) << std::setfill('0') << _service << "." + << std::hex << std::setw(4) << std::setfill('0') << _instance + << ":" << std::dec << int(_major) << "." << std::dec << _minor << "]" + << " (" << std::boolalpha << _must_queue << ")" + << " not offering as method was called via erase_offer_command()!"; return false; } } @@ -438,6 +437,13 @@ bool routing_manager_impl::offer_service(client_t _client, if (!handle_local_offer_service(_client, _service, _instance, _major, _minor)) { erase_offer_command(_service, _instance); + VSOMEIP_INFO << __func__ << " (" + << std::hex << std::setw(4) << std::setfill('0') << _client <<"): [" + << std::hex << std::setw(4) << std::setfill('0') << _service << "." + << std::hex << std::setw(4) << std::setfill('0') << _instance + << ":" << std::dec << int(_major) << "." << std::dec << _minor << "]" + << " (" << std::boolalpha << _must_queue << ")" + << " not offering, returned from handle_local_offer_service!"; return false; } @@ -483,6 +489,14 @@ bool routing_manager_impl::offer_service(client_t _client, stub_->on_offer_service(_client, _service, _instance, _major, _minor); on_availability(_service, _instance, availability_state_e::AS_AVAILABLE, _major, _minor); erase_offer_command(_service, _instance); + + VSOMEIP_INFO << "OFFER(" + << std::hex << std::setw(4) << std::setfill('0') << _client <<"): [" + << std::hex << std::setw(4) << std::setfill('0') << _service << "." + << std::hex << std::setw(4) << std::setfill('0') << _instance + << ":" << std::dec << int(_major) << "." << std::dec << _minor << "]" + << " (" << std::boolalpha << _must_queue << ")"; + return true; } @@ -510,6 +524,13 @@ void routing_manager_impl::stop_offer_service(client_t _client, if (!insert_offer_command(_service, _instance, uint8_t(protocol::id_e::STOP_OFFER_SERVICE_ID), _client, _major, _minor)) { + VSOMEIP_INFO << __func__ + << std::hex << std::setw(4) << std::setfill('0') << _client <<"): [" + << std::hex << std::setw(4) << std::setfill('0') << _service << "." + << std::hex << std::setw(4) << std::setfill('0') << _instance + << ":" << std::dec << int(_major) << "." << _minor << "]" + << " (" << std::boolalpha << _must_queue << ")" + << " STOP-OFFER NOT INSERTED!"; return; } } @@ -1284,7 +1305,6 @@ void routing_manager_impl::notify_one(service_t _service, instance_t _instance, void routing_manager_impl::on_availability(service_t _service, instance_t _instance, availability_state_e _state, major_version_t _major, minor_version_t _minor) { - // insert subscriptions of routing manager into service discovery // to send SubscribeEventgroup after StopOffer / Offer was received if (_state == availability_state_e::AS_AVAILABLE) { @@ -1293,8 +1313,8 @@ void routing_manager_impl::on_availability(service_t _service, instance_t _insta // remote service if (VSOMEIP_ROUTING_CLIENT == its_local_client) { static const ttl_t configured_ttl(configuration_->get_sd_ttl()); - - std::lock_guard ist_lock(pending_subscription_mutex_); + std::lock_guard its_subscribed_lock(discovery_->get_subscribed_mutex()); + std::lock_guard its_lock(pending_subscription_mutex_); for (auto &ps : pending_subscriptions_) { if (ps.service_ == _service && ps.instance_ == _instance @@ -2109,17 +2129,24 @@ bool routing_manager_impl::deliver_notification( } } else { - VSOMEIP_WARNING << __func__ << ": Event [" - << std::hex << std::setfill('0') - << std::setw(4) << _service << "." - << std::setw(4) << _instance << "." - << std::setw(4) << its_event_id << "]" - << " is not registered. The message is dropped."; + if (!is_suppress_event(_service, _instance, its_event_id)) { + VSOMEIP_WARNING << __func__ << ": Event [" + << std::hex << std::setw(4) << std::setfill('0') << _service << "." + << std::hex << std::setw(4) << std::setfill('0') << _instance << "." + << std::hex << std::setw(4) << std::setfill('0') << its_event_id << "]" + << " is not registered. The message is dropped."; + } } - return true; } +bool routing_manager_impl::is_suppress_event(service_t _service, + instance_t _instance, event_t _event) const { + bool status = configuration_->check_suppress_events(_service, _instance, _event); + + return status; +} + std::shared_ptr routing_manager_impl::find_eventgroup( service_t _service, instance_t _instance, eventgroup_t _eventgroup) const { @@ -2166,8 +2193,14 @@ services_t routing_manager_impl::get_offered_services() const { services_t its_services; for (const auto& s : get_services()) { for (const auto& i : s.second) { - if (i.second->is_local()) { - its_services[s.first][i.first] = i.second; + if (i.second) { + if (i.second->is_local()) { + its_services[s.first][i.first] = i.second; + } + } else { + VSOMEIP_ERROR << __func__ << "Found instance with NULL ServiceInfo [" + << std::hex << std::setw(4) << std::setfill('0') << s.first + << ":" << i.first <<"]"; } } } @@ -2204,14 +2237,16 @@ bool routing_manager_impl::is_acl_message_allowed(endpoint *_receiver, const boost::asio::ip::address &_remote_address) const { if (message_acceptance_handler_ && _receiver) { // Check the ACL whitelist rules if shall accepts the message + std::shared_ptr its_info(find_service(_service, _instance)); + const bool is_local = its_info && its_info->is_local(); message_acceptance_t message_acceptance { #if VSOMEIP_BOOST_VERSION < 106600 - static_cast(_remote_address.to_v4().to_ulong()), _receiver->get_local_port(), + static_cast(_remote_address.to_v4().to_ulong()), #else - _remote_address.to_v4().to_uint(), _receiver->get_local_port(), + _remote_address.to_v4().to_uint(), #endif - _receiver->is_local(), _service, _instance + _receiver->get_local_port(), is_local, _service, _instance }; if (!message_acceptance_handler_(message_acceptance)) { VSOMEIP_WARNING << "Message from " << _remote_address.to_string() @@ -2219,13 +2254,6 @@ bool routing_manager_impl::is_acl_message_allowed(endpoint *_receiver, << _instance << " was rejected by the ACL check."; return false; } -#if 0 - else { - VSOMEIP_INFO << "Message from " << _remote_address.to_string() - << std::hex << " with service/instance " << _instance << "/" - << _instance << " was accepted by the ACL check."; - } -#endif } return true; } @@ -2845,11 +2873,13 @@ void routing_manager_impl::init_routing_info() { void routing_manager_impl::on_remote_subscribe( std::shared_ptr &_subscription, const remote_subscription_callback_t &_callback) { + auto its_eventgroupinfo = _subscription->get_eventgroupinfo(); if (!its_eventgroupinfo) { VSOMEIP_ERROR << __func__ << " eventgroupinfo is invalid"; return; } + const ttl_t its_ttl = _subscription->get_ttl(); const auto its_service = its_eventgroupinfo->get_service(); @@ -3089,8 +3119,7 @@ std::shared_ptr routing_manager_impl::find_or_create_remote_client( void routing_manager_impl::on_subscribe_nack(client_t _client, service_t _service, instance_t _instance, eventgroup_t _eventgroup, - event_t _event, remote_subscription_id_t _id) { - (void)_event; // TODO: Remove completely? + bool _remove, remote_subscription_id_t _id) { auto its_eventgroup = find_eventgroup(_service, _instance, _eventgroup); if (its_eventgroup) { @@ -3121,6 +3150,8 @@ void routing_manager_impl::on_subscribe_nack(client_t _client, << (its_subscription->get_subscriber()->is_reliable() ? " reliable" : " unreliable") << " was not accepted"; } + if (_remove) + its_eventgroup->remove_remote_subscription(_id); } } } @@ -3531,6 +3562,12 @@ bool routing_manager_impl::handle_local_offer_service(client_t _client, service_ return false; } } else { + VSOMEIP_INFO << __func__ + << std::hex << std::setw(4) << std::setfill('0') << _client <<"): [" + << std::hex << std::setw(4) << std::setfill('0') << _service << "." + << std::hex << std::setw(4) << std::setfill('0') << _instance + << ":" << std::dec << int(_major) << "." << std::dec << _minor << "]" + << " client already pinged!"; return false; } } else { @@ -3725,9 +3762,25 @@ void routing_manager_impl::set_routing_state(routing_state_e _routing_state) { // send StopOffer messages for remotely offered services on this node for (const auto &its_service : get_offered_services()) { for (const auto &its_instance : its_service.second) { - if (its_instance.second->get_endpoint(true) || its_instance.second->get_endpoint(false)) { + bool has_reliable(its_instance.second->get_endpoint(true) != nullptr); + bool has_unreliable(its_instance.second->get_endpoint(false) != nullptr); + if (has_reliable || has_unreliable) { const client_t its_client(find_local_client(its_service.first, its_instance.first)); - VSOMEIP_WARNING << "service " + if (its_client == VSOMEIP_ROUTING_CLIENT) { + // Inconsistency between services_ and local_services_ table detected + // --> cleanup. + VSOMEIP_WARNING << "rmi::set_routing_state (table inconsistency)" << __func__ + << std::hex << std::setw(4) << std::setfill('0') << its_service.first << "." + << std::hex << std::setw(4) << std::setfill('0') << its_instance.first; + + del_routing_info(its_service.first, its_instance.first, has_reliable, has_unreliable); + + std::lock_guard its_lock(pending_offers_mutex_); + auto its_pending_offer = pending_offers_.find(its_service.first); + if (its_pending_offer != pending_offers_.end()) + its_pending_offer->second.erase(its_instance.first); + } + VSOMEIP_WARNING << "Service " << std::hex << std::setfill('0') << std::setw(4) << its_service.first << "." << std::setw(4) << its_instance.first << " still offered by " @@ -3916,7 +3969,7 @@ void routing_manager_impl::on_net_interface_or_route_state_changed( } void routing_manager_impl::start_ip_routing() { -#if defined(_WIN32) || defined(__QNX__) +#if defined(_WIN32) || defined(__QNX__) if_state_running_ = true; #endif @@ -4514,7 +4567,7 @@ void routing_manager_impl::send_subscription( &routing_manager_stub_host::on_subscribe_nack, std::dynamic_pointer_cast(shared_from_this()), its_client, _service, _instance, - _eventgroup, ANY_EVENT, _id); + _eventgroup, false, _id); io_.post(its_callback); } else { const auto its_callback = std::bind( @@ -4538,7 +4591,7 @@ void routing_manager_impl::send_subscription( &routing_manager_stub_host::on_subscribe_nack, std::dynamic_pointer_cast(shared_from_this()), its_client, _service, _instance, _eventgroup, - ANY_EVENT, _id); + true, _id); io_.post(its_callback); } catch (const std::exception &e) { VSOMEIP_ERROR << __func__ << e.what(); diff --git a/implementation/routing/src/routing_manager_stub.cpp b/implementation/routing/src/routing_manager_stub.cpp index 44a7b7119..d0015c3f7 100644 --- a/implementation/routing/src/routing_manager_stub.cpp +++ b/implementation/routing/src/routing_manager_stub.cpp @@ -499,7 +499,7 @@ void routing_manager_stub::on_message(const byte_t *_data, length_t _size, its_subscription_id = its_command.get_pending_id(); host_->on_subscribe_nack(its_subscriber, its_service, - its_instance, its_eventgroup, its_notifier, its_subscription_id); + its_instance, its_eventgroup, false, its_subscription_id); VSOMEIP_INFO << "SUBSCRIBE NACK(" << std::hex << std::setfill('0') @@ -839,9 +839,9 @@ void routing_manager_stub::on_register_application(client_t _client) { bool has_mapping = policy_manager_impl::get() ->get_client_to_sec_client_mapping(_client, its_sec_client); if (has_mapping) { - if (its_sec_client.client_type == VSOMEIP_CLIENT_UDS) { - get_requester_policies(its_sec_client.client.uds_client.user, - its_sec_client.client.uds_client.group, its_policies); + if (its_sec_client.port == VSOMEIP_SEC_PORT_UNUSED) { + get_requester_policies(its_sec_client.user, + its_sec_client.group, its_policies); } if (!its_policies.empty()) @@ -1224,8 +1224,8 @@ void routing_manager_stub::distribute_credentials(client_t _hoster, service_t _s vsomeip_sec_client_t its_sec_client; if (policy_manager_impl::get()->get_client_to_sec_client_mapping(_hoster, its_sec_client)) { std::pair its_uid_gid; - its_uid_gid.first = its_sec_client.client.uds_client.user; - its_uid_gid.second = its_sec_client.client.uds_client.group; + its_uid_gid.first = its_sec_client.user; + its_uid_gid.second = its_sec_client.group; its_credentials.insert(its_uid_gid); for (auto its_requesting_client : its_requesting_clients) { vsomeip_sec_client_t its_requester_sec_client; @@ -1862,11 +1862,11 @@ void routing_manager_stub::handle_credentials(const client_t _client, std::set

get_client_to_sec_client_mapping(its_offering_client, its_sec_client)) { - if (its_sec_client.client_type == VSOMEIP_CLIENT_UDS + if (its_sec_client.port == VSOMEIP_SEC_PORT_UNUSED && !utility::compare(its_sec_client, its_requester_sec_client)) { its_credentials.insert(std::make_pair( - its_sec_client.client.uds_client.user, its_sec_client.client.uds_client.group)); + its_sec_client.user, its_sec_client.group)); } } } diff --git a/implementation/routing/src/serviceinfo.cpp b/implementation/routing/src/serviceinfo.cpp index 942168b3f..fc099678e 100644 --- a/implementation/routing/src/serviceinfo.cpp +++ b/implementation/routing/src/serviceinfo.cpp @@ -33,8 +33,8 @@ serviceinfo::serviceinfo(const serviceinfo& _other) : reliable_(_other.reliable_), unreliable_(_other.unreliable_), requesters_(_other.requesters_), - is_local_(_other.is_local_), - is_in_mainphase_(_other.is_in_mainphase_) + is_local_(_other.is_local_.load()), + is_in_mainphase_(_other.is_in_mainphase_.load()) {} serviceinfo::~serviceinfo() { diff --git a/implementation/runtime/include/application_impl.hpp b/implementation/runtime/include/application_impl.hpp index c1a39867e..ad803abd4 100644 --- a/implementation/runtime/include/application_impl.hpp +++ b/implementation/runtime/include/application_impl.hpp @@ -226,11 +226,22 @@ class application_impl: public application, service_t _service, instance_t _instance, eventgroup_t _eventgroup, async_subscription_handler_sec_t _handler); + VSOMEIP_EXPORT void register_message_handler_ext( + service_t _service, instance_t _instance, method_t _method, + const message_handler_t &_handler, + handler_registration_type_e _type); + private: + using members_methods_t = std::map >; + using members_methods_iterator_t = members_methods_t::const_iterator; + using members_instances_t = std::map; + using members_instances_iterator_t = members_instances_t::const_iterator; + using members_t = std::map; + using members_iterator_t = members_t::const_iterator; + // // Types // - enum class handler_type_e : uint8_t { MESSAGE, AVAILABILITY, @@ -272,17 +283,6 @@ class application_impl: public application, handler_type_e handler_type_; }; - struct message_handler { - message_handler(const message_handler_t &_handler) : - handler_(_handler) {} - - bool operator<(const message_handler& _other) const { - return handler_.target &)>() - < _other.handler_.target &)>(); - } - message_handler_t handler_; - }; - // // Methods // @@ -332,6 +332,13 @@ class application_impl: public application, bool is_local_endpoint(const boost::asio::ip::address &_unicast, port_t _port); + void find_service_handlers(std::deque &, + service_t _service, instance_t _instance, method_t _method) const; + void find_instance_handlers(std::deque &, + const members_iterator_t &_it, instance_t _instance, method_t _method) const; + void find_method_handlers(std::deque &, + const members_instances_iterator_t &_it, method_t _method) const; + // // Attributes // @@ -370,8 +377,7 @@ class application_impl: public application, offered_services_handler_t offered_services_handler_; // Method/Event (=Member) handlers - std::map > > members_; + members_t members_; mutable std::mutex members_mutex_; // Availability handlers diff --git a/implementation/runtime/src/application_impl.cpp b/implementation/runtime/src/application_impl.cpp index a6f4472d1..0c3ef9d27 100644 --- a/implementation/runtime/src/application_impl.cpp +++ b/implementation/runtime/src/application_impl.cpp @@ -1,4 +1,4 @@ -// Copyright (C) 2014-2021 Bayerische Motoren Werke Aktiengesellschaft (BMW AG) +// Copyright (C) 2014-2023 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/. @@ -58,7 +58,7 @@ application_impl::application_impl(const std::string &_name, const std::string & work_(std::make_shared(io_)), routing_(0), state_(state_type_e::ST_DEREGISTERED), - security_mode_(security_mode_e::SM_OFF), + security_mode_(security_mode_e::SM_ON), #ifdef VSOMEIP_ENABLE_SIGNAL_HANDLING signals_(io_, SIGINT, SIGTERM), catched_signal_(false), @@ -112,10 +112,12 @@ application_impl::~application_impl() { } bool application_impl::init() { + std::lock_guard its_initialized_lock(initialize_mutex_); if(is_initialized_) { VSOMEIP_WARNING << "Trying to initialize an already initialized application."; return true; } + // Application name if (name_ == "") { const char *its_name = getenv(VSOMEIP_ENV_APPLICATION_NAME); @@ -160,32 +162,36 @@ bool application_impl::init() { } if (configuration_->is_local_routing()) { - sec_client_.client_type = VSOMEIP_CLIENT_UDS; + sec_client_.port = VSOMEIP_SEC_PORT_UNUSED; #ifdef __unix__ - sec_client_.client.uds_client.user = getuid(); - sec_client_.client.uds_client.group = getgid(); + sec_client_.user = getuid(); + sec_client_.group = getgid(); #else - sec_client_.client.uds_client.user = ANY_UID; - sec_client_.client.uds_client.group = ANY_GID; + sec_client_.user = ANY_UID; + sec_client_.group = ANY_GID; #endif } else { - sec_client_.client_type = VSOMEIP_CLIENT_TCP; + sec_client_.port = VSOMEIP_SEC_PORT_UNSET; } // Set security mode if (configuration_->is_security_enabled()) { - if (configuration_->is_security_audit()) { - security_mode_ = security_mode_e::SM_AUDIT; + if (configuration_->is_security_external()) { + if (security::load()) { + VSOMEIP_INFO << "Using external security implementation!"; + auto its_result = security::initialize(); + if (VSOMEIP_SEC_POLICY_OK != its_result) + VSOMEIP_ERROR << "Intializing external security implementation failed (" + << std::dec << its_result << ')'; + } } else { - security_mode_ = security_mode_e::SM_ON; - } - - if (security::load()) { - VSOMEIP_INFO << "Using external security implementation!"; - security::initialize(); + VSOMEIP_INFO << "Using internal security implementation!"; + if (configuration_->is_security_audit()) + security_mode_ = security_mode_e::SM_AUDIT; } } else { security_mode_ = security_mode_e::SM_OFF; + VSOMEIP_INFO << "Security disabled!"; } const char *client_side_logging = getenv(VSOMEIP_ENV_CLIENTSIDELOGGING); @@ -364,10 +370,13 @@ void application_impl::start() { pthread_setname_np(pthread_self(),s.str().c_str()); } #endif - if (!is_initialized_) { - VSOMEIP_ERROR << "Trying to start an uninitialized application."; - return; - } + { + std::lock_guard its_initialized_lock(initialize_mutex_); + if (!is_initialized_) { + VSOMEIP_ERROR << "Trying to start an unintialized application."; + return; + } + } const size_t io_thread_count = configuration_->get_io_thread_count(name_); const int io_thread_nice_level = configuration_->get_io_thread_nice_level(name_); @@ -438,11 +447,14 @@ void application_impl::start() { VSOMEIP_WARNING << "nice(" << io_thread_nice_level << ") failed " << errno << " for " << std::this_thread::get_id(); } #endif - try { - io_.run(); - } catch (const std::exception &e) { - VSOMEIP_ERROR << "application_impl::start() " - "catched exception: " << e.what(); + while(true) { + try { + io_.run(); + break; + } catch (const std::exception &e) { + VSOMEIP_ERROR << "application_impl::start() " + "caught exception: " << e.what(); + } } }); io_threads_.insert(its_thread); @@ -478,15 +490,16 @@ void application_impl::start() { VSOMEIP_WARNING << "nice(" << io_thread_nice_level << ") failed " << errno << " for " << std::this_thread::get_id(); } #endif - try { - io_.run(); - - if (stop_thread_.joinable()) { - stop_thread_.join(); + while(true) { + try { + io_.run(); + if (stop_thread_.joinable()) { + stop_thread_.join(); + } + break; + } catch (const std::exception &e) { + VSOMEIP_ERROR << "application_impl::start() caught exception: " << e.what(); } - - } catch (const std::exception &e) { - VSOMEIP_ERROR << "application_impl::start() catched exception: " << e.what(); } { @@ -903,11 +916,11 @@ void application_impl::register_availability_handler(service_t _service, instance_t _instance, const availability_handler_t &_handler, major_version_t _major, minor_version_t _minor) { - std::lock_guard availability_lock(availability_mutex_); + std::lock_guard availability_lock(availability_mutex_); auto its_handler_ext = [_handler](service_t _service, instance_t _instance, - availability_state_e _state) { - _handler(_service, _instance, - (_state == availability_state_e::AS_AVAILABLE)); + availability_state_e _state) { + _handler(_service, _instance, + (_state == availability_state_e::AS_AVAILABLE)); }; register_availability_handler_unlocked(_service, _instance, @@ -1043,13 +1056,8 @@ void application_impl::register_subscription_handler(service_t _service, const std::string& _env, bool _is_subscribed ){ - uid_t its_uid{ANY_UID}; - gid_t its_gid{ANY_GID}; - - if (_sec_client && _sec_client->client_type == VSOMEIP_CLIENT_UDS) { - its_uid = _sec_client->client.uds_client.user; - its_gid = _sec_client->client.uds_client.group; - } + uid_t its_uid {_sec_client->user}; + gid_t its_gid {_sec_client->group}; return _handler( _client, @@ -1349,8 +1357,9 @@ void application_impl::unregister_subscription_status_handler(service_t _service void application_impl::register_message_handler(service_t _service, instance_t _instance, method_t _method, const message_handler_t &_handler) { - std::lock_guard its_lock(members_mutex_); - members_[_service][_instance][_method] = _handler; + + register_message_handler_ext(_service, _instance, _method, _handler, + handler_registration_type_e::HRT_REPLACE); } void application_impl::unregister_message_handler(service_t _service, @@ -1518,7 +1527,7 @@ void application_impl::on_state(state_type_e _state) { void application_impl::on_availability(service_t _service, instance_t _instance, availability_state_e _state, major_version_t _major, minor_version_t _minor) { - std::vector its_handlers; + std::vector its_handlers; { std::lock_guard availability_lock(availability_mutex_); if (_state == is_available_unlocked(_service, _instance, _major, _minor)) { @@ -1647,6 +1656,46 @@ void application_impl::on_availability(service_t _service, instance_t _instance, } } +void application_impl::find_service_handlers( + std::deque &_handlers, + service_t _service, instance_t _instance, method_t _method) const { + + auto its_service_it = members_.find(_service); + if (its_service_it != members_.end()) { + find_instance_handlers(_handlers, its_service_it, + _instance, _method); + if (_handlers.empty()) { + find_instance_handlers(_handlers, its_service_it, + ANY_INSTANCE, _method); + } + } +} + +void application_impl::find_instance_handlers( + std::deque &_handlers, + const members_iterator_t &_it, + instance_t _instance, method_t _method) const { + + auto its_instance_it = _it->second.find(_instance); + if (its_instance_it != _it->second.end()) { + find_method_handlers(_handlers, its_instance_it, _method); + if (_handlers.empty()) { + find_method_handlers(_handlers, its_instance_it, ANY_METHOD); + } + } +} + +void application_impl::find_method_handlers( + std::deque &_handlers, + const members_instances_iterator_t &_it, + method_t _method) const { + + auto its_method_it = _it->second.find(_method); + if (its_method_it != _it->second.end()) { + _handlers = its_method_it->second; + } +} + void application_impl::on_message(std::shared_ptr &&_message) { const service_t its_service = _message->get_service(); const instance_t its_instance = _message->get_instance(); @@ -1667,62 +1716,15 @@ void application_impl::on_message(std::shared_ptr &&_message) { { std::lock_guard its_lock(members_mutex_); - std::set its_handlers; - auto found_service = members_.find(its_service); - if (found_service != members_.end()) { - auto found_instance = found_service->second.find(its_instance); - if (found_instance != found_service->second.end()) { - auto found_method = found_instance->second.find(its_method); - if (found_method != found_instance->second.end()) { - its_handlers.insert(found_method->second); - } - auto found_any_method = found_instance->second.find(ANY_METHOD); - if (found_any_method != found_instance->second.end()) { - its_handlers.insert(found_any_method->second); - } - } - auto found_any_instance = found_service->second.find(ANY_INSTANCE); - if (found_any_instance != found_service->second.end()) { - auto found_method = found_any_instance->second.find(its_method); - if (found_method != found_any_instance->second.end()) { - its_handlers.insert(found_method->second); - } - auto found_any_method = found_any_instance->second.find(ANY_METHOD); - if (found_any_method != found_any_instance->second.end()) { - its_handlers.insert(found_any_method->second); - } - } - } - auto found_any_service = members_.find(ANY_SERVICE); - if (found_any_service != members_.end()) { - auto found_instance = found_any_service->second.find(its_instance); - if (found_instance != found_any_service->second.end()) { - auto found_method = found_instance->second.find(its_method); - if (found_method != found_instance->second.end()) { - its_handlers.insert(found_method->second); - } - auto found_any_method = found_instance->second.find(ANY_METHOD); - if (found_any_method != found_instance->second.end()) { - its_handlers.insert(found_any_method->second); - } - } - auto found_any_instance = found_any_service->second.find(ANY_INSTANCE); - if (found_any_instance != found_any_service->second.end()) { - auto found_method = found_any_instance->second.find(its_method); - if (found_method != found_any_instance->second.end()) { - its_handlers.insert(found_method->second); - } - auto found_any_method = found_any_instance->second.find(ANY_METHOD); - if (found_any_method != found_any_instance->second.end()) { - its_handlers.insert(found_any_method->second); - } - } - } + + std::deque its_handlers; + find_service_handlers(its_handlers, its_service, its_instance, its_method); + if (its_handlers.empty()) + find_service_handlers(its_handlers, ANY_SERVICE, its_instance, its_method); if (its_handlers.size()) { std::lock_guard its_lock(handlers_mutex_); - for (const auto &its_handler : its_handlers) { - auto handler = its_handler.handler_; + for (const auto &handler : its_handlers) { std::shared_ptr its_sync_handler = std::make_shared([handler, _message]() { handler(_message); @@ -2606,13 +2608,8 @@ void application_impl::register_async_subscription_handler(service_t _service, bool _is_subscribed, const std::function &_cb ){ - uid_t its_uid{ANY_UID}; - gid_t its_gid{ANY_GID}; - - if (_sec_client && _sec_client->client_type == VSOMEIP_CLIENT_UDS) { - its_uid = _sec_client->client.uds_client.user; - its_gid = _sec_client->client.uds_client.group; - } + uid_t its_uid {_sec_client->user}; + gid_t its_gid {_sec_client->group}; _handler( _client, @@ -2834,11 +2831,11 @@ void application_impl::update_security_policy_configuration(uint32_t _uid, std::shared_ptr _payload, const security_update_handler_t &_handler) { #ifdef VSOMEIP_DISABLE_SECURITY - (void)_uid; - (void)_gid; - (void)_policy; - (void)_payload; - (void)_handler; + (void)_uid; + (void)_gid; + (void)_policy; + (void)_payload; + (void)_handler; #else if (!is_routing()) { VSOMEIP_ERROR << __func__ << " is only intended to be called by " @@ -2858,9 +2855,9 @@ void application_impl::remove_security_policy_configuration(uint32_t _uid, uint32_t _gid, const security_update_handler_t &_handler) { #ifdef VSOMEIP_DISABLE_SECURITY - (void)_uid; - (void)_gid; - (void)_handler; + (void)_uid; + (void)_gid; + (void)_handler; #else if (!is_routing()) { VSOMEIP_ERROR << __func__ << " is only intended to be called by " @@ -2934,4 +2931,25 @@ application_impl::get_additional_data(const std::string &_plugin_name) { return std::map(); } +void application_impl::register_message_handler_ext( + service_t _service, instance_t _instance, method_t _method, + const message_handler_t &_handler, + handler_registration_type_e _type) { + + std::lock_guard its_lock(members_mutex_); + switch (_type) { + case handler_registration_type_e::HRT_REPLACE: + members_[_service][_instance][_method].clear(); + [[gnu::fallthrough]]; + case handler_registration_type_e::HRT_APPEND: + members_[_service][_instance][_method].push_back(_handler); + break; + case handler_registration_type_e::HRT_PREPEND: + members_[_service][_instance][_method].push_front(_handler); + break; + default: + ; + } +} + } // namespace vsomeip_v3 diff --git a/implementation/security/include/policy_manager_impl.hpp b/implementation/security/include/policy_manager_impl.hpp index 4dd3a8654..f8e751360 100644 --- a/implementation/security/include/policy_manager_impl.hpp +++ b/implementation/security/include/policy_manager_impl.hpp @@ -83,6 +83,7 @@ class VSOMEIP_IMPORT_EXPORT policy_manager_impl private: // Configuration + bool exist_in_any_client_policies_unlocked(std::shared_ptr &_policy); void load_policies(const configuration_element &_element); void load_policy(const boost::property_tree::ptree &_tree); void load_policy_body(std::shared_ptr &_policy, @@ -166,20 +167,17 @@ class VSOMEIP_IMPORT_EXPORT policy_manager_impl struct vsomeip_sec_client_comparator_t { bool operator()(const vsomeip_sec_client_t &_lhs, const vsomeip_sec_client_t &_rhs) const { - if (_lhs.client_type < _rhs.client_type) { + if (_lhs.port < _rhs.port) { return true; - } else if (_lhs.client_type == _rhs.client_type) { - switch (_lhs.client_type) { - case VSOMEIP_CLIENT_UDS: - return ((_lhs.client.uds_client.user < _rhs.client.uds_client.user) - || ((_lhs.client.uds_client.user == _rhs.client.uds_client.user) - && (_lhs.client.uds_client.group < _rhs.client.uds_client.group))); - case VSOMEIP_CLIENT_TCP: - return ((_lhs.client.ip_client.ip < _rhs.client.ip_client.ip) - || ((_lhs.client.ip_client.ip == _rhs.client.ip_client.ip) - && (_lhs.client.ip_client.port < _rhs.client.ip_client.port))); - default: - ; + } else if (_lhs.port == _rhs.port) { + if (_lhs.port == VSOMEIP_SEC_PORT_UNUSED) { + return ((_lhs.user < _rhs.user) + || ((_lhs.user == _rhs.user) + && (_lhs.group < _rhs.group))); + } else { + return ((_lhs.host < _rhs.host) + || ((_lhs.host == _rhs.host) + && (_lhs.port < _rhs.port))); } } return false; diff --git a/implementation/security/include/security.hpp b/implementation/security/include/security.hpp index 1affb0c45..0eda37f54 100644 --- a/implementation/security/include/security.hpp +++ b/implementation/security/include/security.hpp @@ -20,6 +20,7 @@ class VSOMEIP_IMPORT_EXPORT security { static decltype(&vsomeip_sec_policy_is_client_allowed_to_offer) is_client_allowed_to_offer; static decltype(&vsomeip_sec_policy_is_client_allowed_to_request) is_client_allowed_to_request; static decltype(&vsomeip_sec_policy_is_client_allowed_to_access_member) is_client_allowed_to_access_member; + static decltype(&vsomeip_sec_sync_client) sync_client; private: static decltype(vsomeip_sec_policy_initialize) default_initialize; @@ -27,6 +28,7 @@ class VSOMEIP_IMPORT_EXPORT security { static decltype(vsomeip_sec_policy_is_client_allowed_to_offer) default_is_client_allowed_to_offer; static decltype(vsomeip_sec_policy_is_client_allowed_to_request) default_is_client_allowed_to_request; static decltype(vsomeip_sec_policy_is_client_allowed_to_access_member) default_is_client_allowed_to_access_member; + static decltype(vsomeip_sec_sync_client) default_sync_client; }; } // namespace vsomeip_v3 diff --git a/implementation/security/src/policy_manager_impl.cpp b/implementation/security/src/policy_manager_impl.cpp index 07802e361..5a3e7bd55 100644 --- a/implementation/security/src/policy_manager_impl.cpp +++ b/implementation/security/src/policy_manager_impl.cpp @@ -1,4 +1,4 @@ -// Copyright (C) 2019-2021 Bayerische Motoren Werke Aktiengesellschaft (BMW AG) +// Copyright (C) 2019-2023 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/. @@ -86,11 +86,11 @@ policy_manager_impl::check_credentials(client_t _client, if (!_sec_client) return true; - if (_sec_client->client_type != VSOMEIP_CLIENT_UDS) + if (_sec_client->port != VSOMEIP_SEC_PORT_UNUSED) return true; - uid_t its_uid(_sec_client->client.uds_client.user); - gid_t its_gid(_sec_client->client.uds_client.group); + uid_t its_uid(_sec_client->user); + gid_t its_gid(_sec_client->group); bool has_id(false); @@ -153,9 +153,9 @@ policy_manager_impl::check_routing_credentials( bool is_known_uid_gid(false); std::lock_guard its_lock(routing_credentials_mutex_); - if (_sec_client && _sec_client->client_type == VSOMEIP_CLIENT_UDS) { - its_uid = _sec_client->client.uds_client.user; - its_gid = _sec_client->client.uds_client.group; + if (_sec_client && _sec_client->port == VSOMEIP_SEC_PORT_UNUSED) { + its_uid = _sec_client->user; + its_gid = _sec_client->group; if (routing_credentials_.first == its_uid && routing_credentials_.second == its_gid) { @@ -219,9 +219,9 @@ policy_manager_impl::is_client_allowed(const vsomeip_sec_client_t *_sec_client, uid_t its_uid(ANY_UID); gid_t its_gid(ANY_GID); if (_sec_client) { - if (_sec_client->client_type == VSOMEIP_CLIENT_UDS) { - its_uid = _sec_client->client.uds_client.user; - its_gid = _sec_client->client.uds_client.group; + if (_sec_client->port == VSOMEIP_SEC_PORT_UNUSED) { + its_uid = _sec_client->user; + its_gid = _sec_client->group; } else { return true; } @@ -335,9 +335,9 @@ policy_manager_impl::is_offer_allowed(const vsomeip_sec_client_t *_sec_client, uint32_t its_uid(ANY_UID), its_gid(ANY_GID); if (_sec_client) { - if (_sec_client->client_type == VSOMEIP_CLIENT_UDS) { - its_uid = _sec_client->client.uds_client.user; - its_gid = _sec_client->client.uds_client.group; + if (_sec_client->port == VSOMEIP_SEC_PORT_UNUSED) { + its_uid = _sec_client->user; + its_gid = _sec_client->group; } else { return true; } @@ -626,6 +626,21 @@ policy_manager_impl::parse_policy(const byte_t* &_buffer, uint32_t &_buffer_size /////////////////////////////////////////////////////////////////////////////// // Configuration /////////////////////////////////////////////////////////////////////////////// +bool +policy_manager_impl::exist_in_any_client_policies_unlocked(std::shared_ptr &_policy) { + for (const auto &p : any_client_policies_) { + std::lock_guard its_policy_lock(p->mutex_); + if (p->credentials_ == _policy->credentials_ && + p->requests_ == _policy->requests_ && + p->offers_ == _policy->offers_ && + p->allow_what_ == _policy->allow_what_ && + p->allow_who_ == _policy->allow_who_) { + return true; + } + } + return false; +} + void policy_manager_impl::load_policies(const configuration_element &_element) { #ifdef _WIN32 @@ -761,7 +776,9 @@ policy_manager_impl::load_policy(const boost::property_tree::ptree &_tree) { } } boost::unique_lock its_lock(any_client_policies_mutex_); - any_client_policies_.push_back(policy); + if (!exist_in_any_client_policies_unlocked(policy)) + any_client_policies_.push_back(policy); + } void @@ -1181,9 +1198,9 @@ policy_manager_impl::get_clients(uid_t _uid, gid_t _gid, std::lock_guard its_lock(ids_mutex_); for (const auto &i : ids_) { - if (i.second.client_type == VSOMEIP_CLIENT_UDS - && i.second.client.uds_client.user == _uid - && i.second.client.uds_client.group == _gid) + if (i.second.port == VSOMEIP_SEC_PORT_UNUSED + && i.second.user == _uid + && i.second.group == _gid) _clients.insert(i.first); } } @@ -1305,16 +1322,16 @@ bool policy_manager_impl::store_client_to_sec_client_mapping( client_t _client, const vsomeip_sec_client_t *_sec_client) { - if (_sec_client != nullptr && _sec_client->client_type == VSOMEIP_CLIENT_UDS) { + if (_sec_client != nullptr && _sec_client->port == VSOMEIP_SEC_PORT_UNUSED) { // store the client -> sec_client mapping std::lock_guard its_lock(ids_mutex_); auto found_client = ids_.find(_client); if (found_client != ids_.end()) { if (!utility::compare(found_client->second, *_sec_client)) { - uid_t its_old_uid = found_client->second.client.uds_client.user; - gid_t its_old_gid = found_client->second.client.uds_client.group; - uid_t its_new_uid = _sec_client->client.uds_client.user; - gid_t its_new_gid = _sec_client->client.uds_client.group; + uid_t its_old_uid = found_client->second.user; + gid_t its_old_gid = found_client->second.group; + uid_t its_new_uid = _sec_client->user; + gid_t its_new_gid = _sec_client->group; VSOMEIP_WARNING << "vSomeIP Security: Client 0x" << std::hex << _client << " with UID/GID=" @@ -1400,7 +1417,7 @@ void policy_manager_impl::store_sec_client_to_client_mapping( const vsomeip_sec_client_t *_sec_client, client_t _client) { - if (_sec_client && _sec_client->client_type == VSOMEIP_CLIENT_UDS) { + if (_sec_client && _sec_client->port == VSOMEIP_SEC_PORT_UNUSED) { // store the uid gid to clients mapping std::lock_guard its_lock(sec_client_to_clients_mutex_); auto found_sec_client = sec_client_to_clients_.find(*_sec_client); @@ -1419,7 +1436,7 @@ policy_manager_impl::get_sec_client_to_clients_mapping( const vsomeip_sec_client_t *_sec_client, std::set &_clients) { - if (_sec_client && _sec_client->client_type == VSOMEIP_CLIENT_UDS) { + if (_sec_client && _sec_client->port == VSOMEIP_SEC_PORT_UNUSED) { // get the clients corresponding to uid, gid std::lock_guard its_lock(sec_client_to_clients_mutex_); auto found_sec_client = sec_client_to_clients_.find(*_sec_client); diff --git a/implementation/security/src/security.cpp b/implementation/security/src/security.cpp index e9a6381c0..a3b6ab3f9 100644 --- a/implementation/security/src/security.cpp +++ b/implementation/security/src/security.cpp @@ -16,20 +16,30 @@ #include #include -#define VSOMEIP_SEC_SYMDEF(sym) symdef_t{\ +#ifndef _WIN32 +#include +#endif + +#define VSOMEIP_SEC_POLICY_SYMDEF(sym) symdef_t{\ "vsomeip_sec_policy_"#sym, nullptr, reinterpret_cast(&sym) \ } +#define VSOMEIP_SEC_SYMDEF(sym) symdef_t{\ + "vsomeip_sec_"#sym, nullptr, reinterpret_cast(&sym) \ +} + namespace vsomeip_v3 { + bool security::load() { using symdef_t = std::tuple; - std::array symbol_table{ - VSOMEIP_SEC_SYMDEF(initialize), - VSOMEIP_SEC_SYMDEF(authenticate_router), - VSOMEIP_SEC_SYMDEF(is_client_allowed_to_offer), - VSOMEIP_SEC_SYMDEF(is_client_allowed_to_request), - VSOMEIP_SEC_SYMDEF(is_client_allowed_to_access_member) + std::array symbol_table{ + VSOMEIP_SEC_POLICY_SYMDEF(initialize), + VSOMEIP_SEC_POLICY_SYMDEF(authenticate_router), + VSOMEIP_SEC_POLICY_SYMDEF(is_client_allowed_to_offer), + VSOMEIP_SEC_POLICY_SYMDEF(is_client_allowed_to_request), + VSOMEIP_SEC_POLICY_SYMDEF(is_client_allowed_to_access_member), + VSOMEIP_SEC_SYMDEF(sync_client) }; if (auto manager = plugin_manager::get()) { @@ -58,6 +68,12 @@ security::load() { // Symbol loading complete, success! return true; + } else { +#ifdef _WIN32 + VSOMEIP_ERROR << "vSomeIP Security: Loading " << VSOMEIP_SEC_LIBRARY << " failed."; +#else + VSOMEIP_ERROR << "vSomeIP Security: " << dlerror(); +#endif } } @@ -79,6 +95,9 @@ security::is_client_allowed_to_request = security::default_is_client_allowed_to_ decltype(security::is_client_allowed_to_access_member) security::is_client_allowed_to_access_member = security::default_is_client_allowed_to_access_member; +decltype(security::sync_client) +security::sync_client = security::default_sync_client; + // // Default interface implementation // @@ -90,7 +109,7 @@ security::default_initialize(void) { vsomeip_sec_acl_result_t security::default_authenticate_router( const vsomeip_sec_client_t *_server) { - if (_server && _server->client_type == VSOMEIP_CLIENT_TCP) + if (_server && _server->port != VSOMEIP_SEC_PORT_UNUSED) return VSOMEIP_SEC_OK; if (policy_manager_impl::get()->check_routing_credentials(_server)) @@ -104,7 +123,7 @@ security::default_is_client_allowed_to_offer( const vsomeip_sec_client_t *_client, vsomeip_sec_service_id_t _service, vsomeip_sec_instance_id_t _instance) { - if (_client && _client->client_type == VSOMEIP_CLIENT_TCP) + if (_client && _client->port != VSOMEIP_SEC_PORT_UNUSED) return VSOMEIP_SEC_OK; if (policy_manager_impl::get()->is_offer_allowed(_client, _service, _instance)) @@ -118,7 +137,7 @@ security::default_is_client_allowed_to_request( const vsomeip_sec_client_t *_client, vsomeip_sec_service_id_t _service, vsomeip_sec_instance_id_t _instance) { - if (_client && _client->client_type == VSOMEIP_CLIENT_TCP) + if (_client && _client->port != VSOMEIP_SEC_PORT_UNUSED) return VSOMEIP_SEC_OK; if (policy_manager_impl::get()->is_client_allowed(_client, _service, _instance, 0x00, true)) @@ -133,7 +152,7 @@ security::default_is_client_allowed_to_access_member( vsomeip_sec_service_id_t _service, vsomeip_sec_instance_id_t _instance, vsomeip_sec_member_id_t _member) { - if (_client && _client->client_type == VSOMEIP_CLIENT_TCP) + if (_client && _client->port != VSOMEIP_SEC_PORT_UNUSED) return VSOMEIP_SEC_OK; if (policy_manager_impl::get()->is_client_allowed(_client, _service, _instance, _member, false)) @@ -142,4 +161,10 @@ security::default_is_client_allowed_to_access_member( return VSOMEIP_SEC_PERM_DENIED; } +void +security::default_sync_client(vsomeip_sec_client_t *_client) { + + (void)_client; +} + } // namespace vsomeip_v3 diff --git a/implementation/service_discovery/include/service_discovery.hpp b/implementation/service_discovery/include/service_discovery.hpp index cab33a8a2..d180960f8 100644 --- a/implementation/service_discovery/include/service_discovery.hpp +++ b/implementation/service_discovery/include/service_discovery.hpp @@ -71,6 +71,7 @@ class service_discovery { const sd_acceptance_handler_t &_handler) = 0; virtual void register_reboot_notification_handler( const reboot_notification_handler_t &_handler) = 0; + virtual std::recursive_mutex& get_subscribed_mutex() = 0; }; } // namespace sd diff --git a/implementation/service_discovery/include/service_discovery_host.hpp b/implementation/service_discovery/include/service_discovery_host.hpp index 09b5301c4..c5d3d2a7c 100644 --- a/implementation/service_discovery/include/service_discovery_host.hpp +++ b/implementation/service_discovery/include/service_discovery_host.hpp @@ -92,7 +92,7 @@ class service_discovery_host { virtual void on_subscribe_nack(client_t _client, service_t _service, instance_t _instance, eventgroup_t _eventgroup, - event_t _event, remote_subscription_id_t _subscription_id) = 0; + bool _remove, remote_subscription_id_t _subscription_id) = 0; virtual std::chrono::steady_clock::time_point expire_subscriptions(bool _force) = 0; diff --git a/implementation/service_discovery/include/service_discovery_impl.hpp b/implementation/service_discovery/include/service_discovery_impl.hpp index 4b3dbcd0f..200627ccf 100644 --- a/implementation/service_discovery/include/service_discovery_impl.hpp +++ b/implementation/service_discovery/include/service_discovery_impl.hpp @@ -64,6 +64,7 @@ class service_discovery_impl: public service_discovery, virtual ~service_discovery_impl(); boost::asio::io_context &get_io(); + std::recursive_mutex& get_subscribed_mutex(); void init(); void start(); @@ -358,7 +359,6 @@ class service_discovery_impl: public service_discovery, reliability_type_e get_eventgroup_reliability( service_t _service, instance_t _instance, eventgroup_t _eventgroup, const std::shared_ptr& _subscription); - private: boost::asio::io_context &io_; service_discovery_host *host_; @@ -381,7 +381,7 @@ class service_discovery_impl: public service_discovery, > > > subscribed_; - std::mutex subscribed_mutex_; + std::recursive_mutex subscribed_mutex_; std::mutex serialize_mutex_; diff --git a/implementation/service_discovery/src/message_impl.cpp b/implementation/service_discovery/src/message_impl.cpp index c897d7a77..cec09a10a 100644 --- a/implementation/service_discovery/src/message_impl.cpp +++ b/implementation/service_discovery/src/message_impl.cpp @@ -429,7 +429,7 @@ gid_t message_impl::get_gid() const { vsomeip_sec_client_t message_impl::get_sec_client() const { static vsomeip_sec_client_t its_dummy_sec_client{ - VSOMEIP_CLIENT_UDS, {vsomeip_sec_uds_client_credentials_t{ANY_UID, ANY_GID}} + ANY_UID, ANY_GID, 0, VSOMEIP_SEC_PORT_UNUSED }; return its_dummy_sec_client; diff --git a/implementation/service_discovery/src/service_discovery_impl.cpp b/implementation/service_discovery/src/service_discovery_impl.cpp index 3eb629da3..f23fa43b1 100644 --- a/implementation/service_discovery/src/service_discovery_impl.cpp +++ b/implementation/service_discovery/src/service_discovery_impl.cpp @@ -228,6 +228,11 @@ service_discovery_impl::update_request(service_t _service, instance_t _instance) } } +std::recursive_mutex& +service_discovery_impl::get_subscribed_mutex() { + return subscribed_mutex_; +} + void service_discovery_impl::subscribe( service_t _service, instance_t _instance, @@ -245,7 +250,7 @@ service_discovery_impl::subscribe( bool is_selective(_info ? _info->is_selective() : false); #endif // VSOMEIP_ENABLE_COMPAT - std::lock_guard its_lock(subscribed_mutex_); + std::lock_guard its_lock(subscribed_mutex_); auto found_service = subscribed_.find(_service); if (found_service != subscribed_.end()) { auto found_instance = found_service->second.find(_instance); @@ -418,7 +423,7 @@ service_discovery_impl::unsubscribe(service_t _service, boost::asio::ip::address its_address; { - std::lock_guard its_lock(subscribed_mutex_); + std::lock_guard its_lock(subscribed_mutex_); auto found_service = subscribed_.find(_service); if (found_service != subscribed_.end()) { auto found_instance = found_service->second.find(_instance); @@ -492,7 +497,7 @@ service_discovery_impl::unsubscribe_all( boost::asio::ip::address its_address; { - std::lock_guard its_lock(subscribed_mutex_); + std::lock_guard its_lock(subscribed_mutex_); auto found_service = subscribed_.find(_service); if (found_service != subscribed_.end()) { auto found_instance = found_service->second.find(_instance); @@ -534,7 +539,7 @@ service_discovery_impl::unsubscribe_all_on_suspend() { std::vector > > its_stopsubscribes; { - std::lock_guard its_lock(subscribed_mutex_); + std::lock_guard its_lock(subscribed_mutex_); for (auto its_service : subscribed_) { for (auto its_instance : its_service.second) { for (auto &its_eventgroup : its_instance.second) { @@ -582,7 +587,7 @@ void service_discovery_impl::remove_subscriptions( service_t _service, instance_t _instance) { - std::lock_guard its_lock(subscribed_mutex_); + std::lock_guard its_lock(subscribed_mutex_); auto found_service = subscribed_.find(_service); if (found_service != subscribed_.end()) { found_service->second.erase(_instance); @@ -1097,6 +1102,7 @@ service_discovery_impl::on_message( #endif std::lock_guard its_lock(check_ttl_mutex_); std::lock_guard its_session_lock(sessions_received_mutex_); + std::lock_guard its_subscribed_lock(subscribed_mutex_); if(is_suspended_) { return; @@ -1527,7 +1533,6 @@ service_discovery_impl::process_offerservice_serviceentry( // No need to resubscribe for unicast offers if (_received_via_mcast) { - std::lock_guard its_lock(subscribed_mutex_); auto found_service = subscribed_.find(_service); if (found_service != subscribed_.end()) { auto found_instance = found_service->second.find(_instance); @@ -1664,7 +1669,7 @@ service_discovery_impl::on_endpoint_connected( get_subscription_address(its_dummy, _endpoint, its_address); { - std::lock_guard its_lock(subscribed_mutex_); + std::lock_guard its_lock(subscribed_mutex_); auto found_service = subscribed_.find(_service); if (found_service != subscribed_.end()) { auto found_instance = found_service->second.find(_instance); @@ -2472,7 +2477,7 @@ service_discovery_impl::handle_eventgroup_subscription_nack( uint8_t _counter, const std::set &_clients) { (void)_counter; - std::lock_guard its_lock(subscribed_mutex_); + std::lock_guard its_lock(subscribed_mutex_); auto found_service = subscribed_.find(_service); if (found_service != subscribed_.end()) { auto found_instance = found_service->second.find(_instance); @@ -2508,7 +2513,7 @@ service_discovery_impl::handle_eventgroup_subscription_ack( (void)_ttl; (void)_counter; - std::lock_guard its_lock(subscribed_mutex_); + std::lock_guard its_lock(subscribed_mutex_); auto found_service = subscribed_.find(_service); if (found_service != subscribed_.end()) { auto found_instance = found_service->second.find(_instance); @@ -3342,16 +3347,10 @@ service_discovery_impl::check_stop_subscribe_subscribe( message_impl::entries_t::const_iterator _iter, message_impl::entries_t::const_iterator _end, const message_impl::options_t& _options) const { - const message_impl::entries_t::const_iterator its_next = std::next(_iter); - if ((*_iter)->get_ttl() > 0 - || (*_iter)->get_type() != entry_type_e::STOP_SUBSCRIBE_EVENTGROUP - || its_next == _end - || (*its_next)->get_type() != entry_type_e::SUBSCRIBE_EVENTGROUP) { - return false; - } - return (*static_cast(_iter->get())).matches( - *(static_cast(its_next->get())), _options); + return (*_iter)->get_ttl() == 0 + && (*_iter)->get_type() == entry_type_e::STOP_SUBSCRIBE_EVENTGROUP + && has_opposite(_iter, _end, _options); } bool diff --git a/implementation/utility/include/utility.hpp b/implementation/utility/include/utility.hpp index 5691588b1..cb567ae0e 100644 --- a/implementation/utility/include/utility.hpp +++ b/implementation/utility/include/utility.hpp @@ -140,21 +140,11 @@ class utility { const vsomeip_sec_client_t &_rhs) { bool is_equal(false); - if (_lhs.client_type == _rhs.client_type) { - switch (_lhs.client_type) { - case VSOMEIP_CLIENT_INVALID: - is_equal = true; - break; - case VSOMEIP_CLIENT_UDS: - is_equal = (_lhs.client.uds_client.user == _rhs.client.uds_client.user - && _lhs.client.uds_client.group == _rhs.client.uds_client.group); - break; - case VSOMEIP_CLIENT_TCP: - is_equal = (_lhs.client.ip_client.ip == _rhs.client.ip_client.ip - && _lhs.client.ip_client.port == _rhs.client.ip_client.port); - break; - default: - break; + if (_lhs.port == _rhs.port) { + if (_lhs.port == VSOMEIP_SEC_PORT_UNUSED) { + is_equal = (_lhs.user == _rhs.user && _lhs.group == _rhs.group); + } else { + is_equal = (_lhs.host == _rhs.host && _lhs.port == _rhs.port); } } return is_equal; diff --git a/implementation/utility/src/wrappers_qnx.cpp b/implementation/utility/src/wrappers_qnx.cpp index 317c55d3d..b9625a6f6 100644 --- a/implementation/utility/src/wrappers_qnx.cpp +++ b/implementation/utility/src/wrappers_qnx.cpp @@ -1,4 +1,4 @@ -// Copyright (C) 2020-2021 Bayerische Motoren Werke Aktiengesellschaft (BMW AG) +// Copyright (C) 2020-2023 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/. diff --git a/interface/compat/vsomeip/primitive_types.hpp b/interface/compat/vsomeip/primitive_types.hpp index cb3d4fd8a..ce1d4bd10 100644 --- a/interface/compat/vsomeip/primitive_types.hpp +++ b/interface/compat/vsomeip/primitive_types.hpp @@ -1,4 +1,4 @@ -// Copyright (C) 2014-2017 Bayerische Motoren Werke Aktiengesellschaft (BMW AG) +// Copyright (C) 2014-2023 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/. diff --git a/interface/vsomeip/application.hpp b/interface/vsomeip/application.hpp index 6d9dd0cc8..4451d4568 100644 --- a/interface/vsomeip/application.hpp +++ b/interface/vsomeip/application.hpp @@ -1,4 +1,4 @@ -// Copyright (C) 2014-2021 Bayerische Motoren Werke Aktiengesellschaft (BMW AG) +// Copyright (C) 2014-2023 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/. @@ -1102,6 +1102,43 @@ class application { virtual void register_async_subscription_handler( service_t _service, instance_t _instance, eventgroup_t _eventgroup, async_subscription_handler_sec_t _handler) = 0; + + /** + * + * \brief Registers a handler for the specified method or event. + * + * A user application must call this method to register callbacks for + * for messages that match the specified service, instance, method/event + * pattern. It is possible to specify wildcard values for all three + * identifiers arguments. + * + * Notes: + * - Only a single handler can be registered per service, instance, + * method/event combination. + * - A subsequent call will overwrite an existing registration. + * - Handler registrations containing wildcards can be active in parallel + * to handler registrations for specific service, instance, method/event + * combinations. + * + * \param _service Service identifier of the service that contains the + * method or event. Can be set to ANY_SERVICE to register a handler for + * a message independent from a specific service. + * \param _instance Instance identifier of the service instance that + * contains the method or event. Can be set to ANY_INSTANCE to register + * a handler for a message independent from a specific service. + * \param _method Method/Event identifier of the method/event that is + * to be handled. Can be set to ANY_METHOD to register a handler for + * all methods and events. + * \param _handler Callback that will be called if a message arrives + * that matches the specified service, instance and method/event + * parameters. + * \param _type Replace, append to or prepend to the current handler (if + * any). + */ + virtual void register_message_handler_ext(service_t _service, + instance_t _instance, method_t _method, + const message_handler_t &_handler, + handler_registration_type_e _type) = 0; }; /** @} */ diff --git a/interface/vsomeip/enumeration_types.hpp b/interface/vsomeip/enumeration_types.hpp index 8229a8952..09734b83b 100644 --- a/interface/vsomeip/enumeration_types.hpp +++ b/interface/vsomeip/enumeration_types.hpp @@ -95,6 +95,13 @@ enum class availability_state_e : uint8_t { AS_UNKNOWN = 0xFF }; +enum class handler_registration_type_e : uint8_t { + HRT_REPLACE = 0x00, + HRT_PREPEND = 0x01, + HRT_APPEND = 0x02, + HRT_UNKNOWN = 0xFF +}; + } // namespace vsomeip_v3 #endif // VSOMEIP_V3_ENUMERATION_TYPES_HPP_ diff --git a/interface/vsomeip/message_base.hpp b/interface/vsomeip/message_base.hpp index 4621fa2a5..624a16027 100644 --- a/interface/vsomeip/message_base.hpp +++ b/interface/vsomeip/message_base.hpp @@ -1,4 +1,4 @@ -// Copyright (C) 2014-2021 Bayerische Motoren Werke Aktiengesellschaft (BMW AG) +// Copyright (C) 2014-2023 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/. diff --git a/interface/vsomeip/primitive_types.hpp b/interface/vsomeip/primitive_types.hpp index 4a1046618..0fbce3c45 100644 --- a/interface/vsomeip/primitive_types.hpp +++ b/interface/vsomeip/primitive_types.hpp @@ -1,4 +1,4 @@ -// Copyright (C) 2014-2021 Bayerische Motoren Werke Aktiengesellschaft (BMW AG) +// Copyright (C) 2014-2023 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/. diff --git a/interface/vsomeip/vsomeip_sec.h b/interface/vsomeip/vsomeip_sec.h index 3b853f630..0d269127e 100644 --- a/interface/vsomeip/vsomeip_sec.h +++ b/interface/vsomeip/vsomeip_sec.h @@ -1,4 +1,4 @@ -// Copyright (C) 2022 Bayerische Motoren Werke Aktiengesellschaft (BMW AG) +// Copyright (C) 2023 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/. @@ -6,6 +6,9 @@ #ifndef VSOMEIP_V3_SECURITY_VSOMEIP_SEC_H_ #define VSOMEIP_V3_SECURITY_VSOMEIP_SEC_H_ +#define VSOMEIP_SEC_PORT_UNUSED 0 +#define VSOMEIP_SEC_PORT_UNSET 0xFFFF + #ifdef __cplusplus extern "C" { #endif @@ -33,25 +36,8 @@ typedef struct { uid_t user; gid_t group; #endif -} vsomeip_sec_uds_client_credentials_t; - -typedef struct { - vsomeip_sec_ip_addr_t ip; - vsomeip_sec_network_port_t port; -} vsomeip_sec_ip_client_credentials_t; - -typedef enum { - VSOMEIP_CLIENT_UDS, - VSOMEIP_CLIENT_TCP, - VSOMEIP_CLIENT_INVALID -} vsomeip_sec_client_type_t; - -typedef struct { - vsomeip_sec_client_type_t client_type; - union { - vsomeip_sec_uds_client_credentials_t uds_client; - vsomeip_sec_ip_client_credentials_t ip_client; - } client; + vsomeip_sec_ip_addr_t host; + vsomeip_sec_network_port_t port; // VSOMEIP_SEC_PORT_UNUSED --> UDS; ]0, VSOMEIP_SEC_PORT_UNSET] --> TCP } vsomeip_sec_client_t; typedef enum { @@ -156,6 +142,14 @@ vsomeip_sec_acl_result_t vsomeip_sec_policy_is_client_allowed_to_access_member( const vsomeip_sec_client_t *client, vsomeip_sec_service_id_t service, vsomeip_sec_instance_id_t instance, vsomeip_sec_member_id_t member); + +/** + * Provides user and group identifiers for a given host address / port combination. + * + * Note: For UDS (aka port=0), calling this function is a no-op. + */ +void vsomeip_sec_sync_client(vsomeip_sec_client_t *client); + #ifdef __cplusplus } // extern "C" #endif diff --git a/libvsomeip.yaml b/libvsomeip.yaml index 2c29c9e13..1dc15dc2b 100644 --- a/libvsomeip.yaml +++ b/libvsomeip.yaml @@ -1,5 +1,5 @@ - name: libvsomeip - version: 3.3.8 + version: 3.4.9 vendor: Lynx Team license: concluded: CLOSED and MPLv2 diff --git a/test/CMakeLists.txt b/test/CMakeLists.txt index 2121715b3..846698d60 100644 --- a/test/CMakeLists.txt +++ b/test/CMakeLists.txt @@ -1,11 +1,131 @@ -# Copyright (C) 2015-2022 Bayerische Motoren Werke Aktiengesellschaft (BMW AG) +# Copyright (C) 2015-2023 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/. +############################################################################## +# Test section +############################################################################## + +############################################################################## +# google benchmark +find_package(benchmark) + +############################################################################## +# google test + +# remove export symbols from the cxx flags +string(REPLACE "${EXPORTSYMBOLS}" "" CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS}") + +# check for set environment variable +if(${GTEST_ROOT} STREQUAL "n/a") + message(STATUS "GTEST_ROOT is not defined. For building the tests the variable + GTEST_ROOT has to be defined. Tests can not be built.") + # early exit + return() # test can not be build -> make commands build_tests and check are not available +else() + message(STATUS "GTEST_ROOT is set. gtest root path set to ${GTEST_ROOT}") +endif() + +# build google test as static library (always) -> therefore deactivate BUILD_SHARED_LIBS in case it is active +set(BUILD_SHARED_LIBS_AUTOMATIC_OFF 0) +if ("${BUILD_SHARED_LIBS}" STREQUAL "ON") + set(BUILD_SHARED_LIBS OFF) + set(BUILD_SHARED_LIBS_AUTOMATIC_OFF 1) +endif() +add_subdirectory(${GTEST_ROOT} ${CMAKE_CURRENT_BINARY_DIR}/gtest EXCLUDE_FROM_ALL) +if ("${BUILD_SHARED_LIBS_AUTOMATIC_OFF}" STREQUAL "1") + set(BUILD_SHARED_LIBS ON) + set(BUILD_SHARED_LIBS_AUTOMATIC_OFF 0) +endif() + +############################################################################## +# build tests + +SET(TESTS_BAT "OFF" CACHE BOOL +"Controls whether only BAT tests should be build or not") +SET(TEST_SYMLINK_CONFIG_FILES "OFF" CACHE BOOL +"Controls if the json and scripts needed needed to run the tests are copied or symlinked into the build directroy (ignored on Windows)") +SET(TEST_SYMLINK_CONFIG_FILES_RELATIVE "OFF" CACHE BOOL + "Controls if the json and scripts needed needed to run the tests are symlinked relatively into the build directroy (ignored on Windows)") + +SET(TEST_IP_DEFAULT_VALUE "XXX.XXX.XXX.XXX") +SET(TEST_IP_MASTER "${TEST_IP_DEFAULT_VALUE}" CACHE STRING + "The IP address of the interface which will act as test master") + SET(TEST_IP_SLAVE "${TEST_IP_DEFAULT_VALUE}" CACHE STRING + "The IP address of the interface which will act as test slave") + +if((${TEST_IP_MASTER} STREQUAL ${TEST_IP_DEFAULT_VALUE}) OR + (${TEST_IP_SLAVE} STREQUAL ${TEST_IP_DEFAULT_VALUE})) + message(WARNING "TEST_IP_MASTER and/or TEST_IP_SLAVE isn't set. " + "Remote tests cannot be run. " + "To enable, please specify for example " + "-DTEST_IP_MASTER=10.0.3.1 -DTEST_IP_SLAVE=10.0.3.2") +endif() + +SET(TEST_IP_SLAVE_SECOND "${TEST_IP_DEFAULT_VALUE}" CACHE STRING +"The second IP address of the interface which will act as test slave") +set(TEST_SECOND_ADDRESS "OFF" CACHE BOOL + "Controls whether second address tests should run or not") + +if(${TEST_IP_SLAVE_SECOND} STREQUAL ${TEST_IP_DEFAULT_VALUE}) + message(WARNING "TEST_IP_SLAVE_SECOND isn't set. " + "Test with more than one IP address on same interface is not enabled." + "Please specify them via for example " + "-TEST_IP_SLAVE_SECOND=10.0.3.126") +else() + set(TEST_SECOND_ADDRESS "ON") +endif() + +set(TEST_E2E_PROFILE_04 "ON") + +SET(TEST_UID_DEFAULT_VALUE "123456789") +SET(TEST_UID "${TEST_UID_DEFAULT_VALUE}" CACHE STRING + "The User ID of the user running the test: Needed for security") +SET(TEST_GID_DEFAULT_VALUE "123456789") +SET(TEST_GID "${TEST_GID_DEFAULT_VALUE}" CACHE STRING +"The Group ID of the user running the test: Needed for security") + +SET(TEST_SECURITY "ON" CACHE BOOL +"Controls whether security tests should run or not") + +if((${TEST_UID} STREQUAL ${TEST_UID_DEFAULT_VALUE}) OR + (${TEST_GID} STREQUAL ${TEST_GID_DEFAULT_VALUE}) OR + DISABLE_SECURITY) + message(WARNING "TEST_UID and/or TEST_GID isn't set. " + "Security Tests are not runnable " + "Please specify them for example " + "-DTEST_UID=1000 -DTEST_GID=1000") + SET(TEST_SECURITY "OFF") +endif() + +add_custom_target(build_tests) + +set(CMAKE_CTEST_COMMAND ctest -V) +add_custom_target(check COMMAND ${CMAKE_CTEST_COMMAND}) +add_dependencies(check build_tests) + +add_custom_target(build_network_tests) +add_dependencies(build_network_tests ${VSOMEIP_NAME}) +add_dependencies(build_network_tests ${VSOMEIP_NAME}-e2e) +add_dependencies(build_network_tests ${VSOMEIP_NAME}-sd) +add_dependencies(build_tests build_network_tests) + +add_custom_target(build_unit_tests) +add_dependencies(build_unit_tests ${VSOMEIP_NAME}) +add_dependencies(build_unit_tests ${VSOMEIP_NAME}-sd) +add_dependencies(build_tests build_unit_tests) + +add_custom_target(build_benchmark_tests) +add_dependencies(build_benchmark_tests ${VSOMEIP_NAME}) +add_dependencies(build_benchmark_tests ${VSOMEIP_NAME}-sd) +add_dependencies(build_tests build_benchmark_tests) + ############################################################################## # add network, unit and benchmark tests directories ############################################################################## + +add_subdirectory(common EXCLUDE_FROM_ALL) add_subdirectory( network_tests EXCLUDE_FROM_ALL ) if (NOT DISABLE_SECURITY) @@ -23,3 +143,5 @@ endif() if(NOT ${TESTS_BAT}) add_subdirectory(internal_routing_disabled_acceptance_test) endif() + +configure_file(tsan-suppressions.txt tsan-suppressions.txt COPYONLY) diff --git a/test/benchmark_tests/CMakeLists.txt b/test/benchmark_tests/CMakeLists.txt index 24905ecdd..ebc51f917 100644 --- a/test/benchmark_tests/CMakeLists.txt +++ b/test/benchmark_tests/CMakeLists.txt @@ -1,11 +1,11 @@ -# Copyright (C) 2015-2022 Bayerische Motoren Werke Aktiengesellschaft (BMW AG) +# Copyright (C) 2015-2023 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/. project ("benchmark_tests_bin" LANGUAGES CXX) -file (GLOB SRCS main.cpp **/*.cpp ../common/utility.cpp) +file (GLOB SRCS main.cpp **/*.cpp) set(THREADS_PREFER_PTHREAD_FLAG ON) @@ -25,6 +25,7 @@ target_link_libraries ( ${DL_LIBRARY} benchmark::benchmark gtest + vsomeip_utilities ) add_dependencies(build_benchmark_tests ${PROJECT_NAME}) diff --git a/test/benchmark_tests/security_tests/bm_check_credentials.cpp b/test/benchmark_tests/security_tests/bm_check_credentials.cpp index 756cd5f44..0c60fb43f 100644 --- a/test/benchmark_tests/security_tests/bm_check_credentials.cpp +++ b/test/benchmark_tests/security_tests/bm_check_credentials.cpp @@ -1,11 +1,11 @@ -// Copyright (C) 2022 Bayerische Motoren Werke Aktiengesellschaft (BMW AG) +// Copyright (C) 2023 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/. #include -#include "../../common/utility.hpp" +#include namespace { vsomeip_v3::client_t client = 1; @@ -13,13 +13,14 @@ namespace { vsomeip_v3::uid_t valid_uid = 4004201; vsomeip_v3::gid_t invalid_gid = 1; vsomeip_v3::gid_t valid_gid = 4004200; + vsomeip_sec_ip_addr_t host_address = 0; } static void BM_check_credentials_policies_not_loaded(benchmark::State& state) { std::unique_ptr its_manager(new vsomeip_v3::policy_manager_impl); // create security clients - vsomeip_sec_client_t its_sec_client_invalid = utility::create_uds_client(invalid_uid, invalid_gid); + vsomeip_sec_client_t its_sec_client_invalid = utility::create_uds_client(invalid_uid, invalid_gid, host_address); for (auto _ : state) its_manager->check_credentials(client, &its_sec_client_invalid); @@ -37,7 +38,7 @@ static void BM_check_credentials_policies_loaded_invalid_values(benchmark::State } // create security clients - vsomeip_sec_client_t its_sec_client_invalid = utility::create_uds_client(invalid_uid, invalid_gid); + vsomeip_sec_client_t its_sec_client_invalid = utility::create_uds_client(invalid_uid, invalid_gid, host_address); for (auto _ : state) its_manager->check_credentials(client, &its_sec_client_invalid); @@ -55,7 +56,7 @@ static void BM_check_credentials_policies_loaded_valid_values(benchmark::State& } // create security clients - vsomeip_sec_client_t its_sec_client_valid = utility::create_uds_client(valid_uid, valid_gid); + vsomeip_sec_client_t its_sec_client_valid = utility::create_uds_client(valid_uid, valid_gid, host_address); for (auto _ : state) its_manager->check_credentials(client, &its_sec_client_valid); @@ -74,7 +75,7 @@ static void BM_check_credentials_policies_loaded_audit_mode_invalid_values(bench } // create security clients - vsomeip_sec_client_t its_sec_client_invalid = utility::create_uds_client(invalid_uid, invalid_gid); + vsomeip_sec_client_t its_sec_client_invalid = utility::create_uds_client(invalid_uid, invalid_gid, host_address); for (auto _ : state) its_manager->check_credentials(client, &its_sec_client_invalid); @@ -93,7 +94,7 @@ static void BM_check_credentials_policies_loaded_audit_mode_valid_values(benchma } // create security clients - vsomeip_sec_client_t its_sec_client_valid = utility::create_uds_client(valid_uid, valid_gid); + vsomeip_sec_client_t its_sec_client_valid = utility::create_uds_client(valid_uid, valid_gid, host_address); for (auto _ : state) its_manager->check_credentials(client, &its_sec_client_valid); @@ -103,4 +104,4 @@ BENCHMARK(BM_check_credentials_policies_not_loaded); BENCHMARK(BM_check_credentials_policies_loaded_invalid_values); BENCHMARK(BM_check_credentials_policies_loaded_valid_values); BENCHMARK(BM_check_credentials_policies_loaded_audit_mode_invalid_values); -BENCHMARK(BM_check_credentials_policies_loaded_audit_mode_valid_values); \ No newline at end of file +BENCHMARK(BM_check_credentials_policies_loaded_audit_mode_valid_values); diff --git a/test/benchmark_tests/security_tests/bm_check_routing_credentials.cpp b/test/benchmark_tests/security_tests/bm_check_routing_credentials.cpp index ed6ed5797..c24ca3e60 100644 --- a/test/benchmark_tests/security_tests/bm_check_routing_credentials.cpp +++ b/test/benchmark_tests/security_tests/bm_check_routing_credentials.cpp @@ -1,23 +1,24 @@ -// Copyright (C) 2022 Bayerische Motoren Werke Aktiengesellschaft (BMW AG) +// Copyright (C) 2023 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/. #include -#include "../../common/utility.hpp" +#include namespace{ vsomeip_v3::uid_t invalid_uid = 1; vsomeip_v3::uid_t valid_uid = 4003017; vsomeip_v3::gid_t invalid_gid = 1; vsomeip_v3::gid_t valid_gid = 5002; +vsomeip_sec_ip_addr_t host_address = 0; } static void BM_check_routing_credentials_policies_not_loaded(benchmark::State& state) { std::unique_ptr security(new vsomeip_v3::policy_manager_impl); - vsomeip_sec_client_t its_sec_client_invalid = utility::create_uds_client(invalid_uid, invalid_gid); + vsomeip_sec_client_t its_sec_client_invalid = utility::create_uds_client(invalid_uid, invalid_gid, host_address); for (auto _ : state) security->check_routing_credentials(&its_sec_client_invalid); @@ -30,7 +31,7 @@ static void BM_check_routing_credentials_policies_loaded_invalid_values(benchmar std::vector policy_elements; std::vector dir_skip; - vsomeip_sec_client_t its_sec_client_invalid = utility::create_uds_client(invalid_uid, invalid_gid); + vsomeip_sec_client_t its_sec_client_invalid = utility::create_uds_client(invalid_uid, invalid_gid, host_address); utility::read_data(utility::get_all_files_in_dir(utility::get_policies_path(), dir_skip), policy_elements, its_failed); for (const auto& e : policy_elements) { @@ -44,7 +45,7 @@ static void BM_check_routing_credentials_policies_loaded_invalid_values(benchmar static void BM_check_routing_credentials_policies_loaded_valid_values(benchmark::State& state) { std::unique_ptr security(new vsomeip_v3::policy_manager_impl); - vsomeip_sec_client_t its_sec_client_valid = utility::create_uds_client(valid_uid, valid_gid); + vsomeip_sec_client_t its_sec_client_valid = utility::create_uds_client(valid_uid, valid_gid, host_address); std::set its_failed; std::vector policy_elements; @@ -61,7 +62,7 @@ static void BM_check_routing_credentials_policies_loaded_valid_values(benchmark: static void BM_check_routing_credentials_policies_loaded_lazy_load_invalid_values(benchmark::State& state) { std::unique_ptr security(new vsomeip_v3::policy_manager_impl); - vsomeip_sec_client_t its_sec_client_invalid = utility::create_uds_client(invalid_uid, invalid_gid); + vsomeip_sec_client_t its_sec_client_invalid = utility::create_uds_client(invalid_uid, invalid_gid, host_address); std::set its_failed; std::vector policy_elements; @@ -78,7 +79,7 @@ static void BM_check_routing_credentials_policies_loaded_lazy_load_invalid_value static void BM_check_routing_credentials_policies_loaded_lazy_load_valid_values(benchmark::State& state) { std::unique_ptr security(new vsomeip_v3::policy_manager_impl); - vsomeip_sec_client_t its_sec_client_valid = utility::create_uds_client(valid_uid, valid_gid); + vsomeip_sec_client_t its_sec_client_valid = utility::create_uds_client(valid_uid, valid_gid, host_address); std::set its_failed; std::vector policy_elements; diff --git a/test/benchmark_tests/security_tests/bm_get_client_to_sec_client_mapping.cpp b/test/benchmark_tests/security_tests/bm_get_client_to_sec_client_mapping.cpp index aa8040686..f77715e96 100644 --- a/test/benchmark_tests/security_tests/bm_get_client_to_sec_client_mapping.cpp +++ b/test/benchmark_tests/security_tests/bm_get_client_to_sec_client_mapping.cpp @@ -1,11 +1,11 @@ -// Copyright (C) 2022 Bayerische Motoren Werke Aktiengesellschaft (BMW AG) +// Copyright (C) 2023 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/. #include -#include "../../common/utility.hpp" +#include namespace{ vsomeip_v3::client_t client = 10; @@ -16,14 +16,15 @@ vsomeip_v3::uid_t uid_2 = 1; vsomeip_v3::gid_t gid_2 = 1; vsomeip_v3::uid_t uid_3 = 2; vsomeip_v3::gid_t gid_3 = 2; +vsomeip_sec_ip_addr_t host_address = 0; } static void BM_get_client_to_sec_client_mapping_valid_values(benchmark::State &state) { std::unique_ptr security(new vsomeip_v3::policy_manager_impl); - vsomeip_sec_client_t its_sec_client_uid_gid_1 = utility::create_uds_client(uid_1, gid_1); - vsomeip_sec_client_t its_sec_client_uid_gid_2 = utility::create_uds_client(uid_2, gid_2); + vsomeip_sec_client_t its_sec_client_uid_gid_1 = utility::create_uds_client(uid_1, gid_1, host_address); + vsomeip_sec_client_t its_sec_client_uid_gid_2 = utility::create_uds_client(uid_2, gid_2, host_address); // add client and security client mappings security->store_client_to_sec_client_mapping(client, &its_sec_client_uid_gid_1); @@ -32,7 +33,7 @@ static void BM_get_client_to_sec_client_mapping_valid_values(benchmark::State &s security->get_client_to_sec_client_mapping(client, its_sec_client_uid_gid_2); } - vsomeip_sec_client_t its_sec_client_uid_gid_3 = utility::create_uds_client(uid_3, gid_3); + vsomeip_sec_client_t its_sec_client_uid_gid_3 = utility::create_uds_client(uid_3, gid_3, host_address); // add alternate client and security client security->store_client_to_sec_client_mapping(alternate_client, &its_sec_client_uid_gid_1); @@ -46,7 +47,7 @@ static void BM_get_client_to_sec_client_mapping_invalid_values(benchmark::State { std::unique_ptr security(new vsomeip_v3::policy_manager_impl); - vsomeip_sec_client_t its_sec_client_uid_gid_1 = utility::create_uds_client(uid_1, gid_1); + vsomeip_sec_client_t its_sec_client_uid_gid_1 = utility::create_uds_client(uid_1, gid_1, host_address); for (auto _ : state) { security->get_client_to_sec_client_mapping(client, its_sec_client_uid_gid_1); diff --git a/test/benchmark_tests/security_tests/bm_get_clients.cpp b/test/benchmark_tests/security_tests/bm_get_clients.cpp index 091c9e1ef..21c07a48a 100644 --- a/test/benchmark_tests/security_tests/bm_get_clients.cpp +++ b/test/benchmark_tests/security_tests/bm_get_clients.cpp @@ -1,11 +1,11 @@ -// Copyright (C) 2022 Bayerische Motoren Werke Aktiengesellschaft (BMW AG) +// Copyright (C) 2023 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/. #include -#include "../../common/utility.hpp" +#include namespace{ std::unordered_set clients; @@ -15,13 +15,14 @@ vsomeip_v3::client_t client_2 = 11; vsomeip_v3::client_t client_3 = 12; vsomeip_v3::uid_t uid = 4003030; vsomeip_v3::gid_t gid = 4003032; +vsomeip_sec_ip_addr_t host_address = 0; } static void BM_get_clients(benchmark::State &state) { std::unique_ptr security(new vsomeip_v3::policy_manager_impl); - vsomeip_sec_client_t its_sec_client_uid_gid = utility::create_uds_client(uid, gid); + vsomeip_sec_client_t its_sec_client_uid_gid = utility::create_uds_client(uid, gid, host_address); // Loop to do the benchmark test the get with an empty clients list. for (auto _ : state) { diff --git a/test/benchmark_tests/security_tests/bm_get_sec_client_to_clients_mapping.cpp b/test/benchmark_tests/security_tests/bm_get_sec_client_to_clients_mapping.cpp index 71a517a15..c8f2c42c4 100644 --- a/test/benchmark_tests/security_tests/bm_get_sec_client_to_clients_mapping.cpp +++ b/test/benchmark_tests/security_tests/bm_get_sec_client_to_clients_mapping.cpp @@ -1,11 +1,11 @@ -// Copyright (C) 2022 Bayerische Motoren Werke Aktiengesellschaft (BMW AG) +// Copyright (C) 2023 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/. #include -#include "../../common/utility.hpp" +#include namespace{ vsomeip_v3::client_t client = 10; @@ -13,14 +13,15 @@ vsomeip_v3::uid_t uid_1 = 4003030; vsomeip_v3::gid_t gid_1 = 4003032; vsomeip_v3::uid_t uid_2 = 1; vsomeip_v3::gid_t gid_2 = 1; +vsomeip_sec_ip_addr_t host_address = 0; } static void BM_get_sec_client_to_clients_mapping_valid_values(benchmark::State &state) { std::unique_ptr security(new vsomeip_v3::policy_manager_impl); - vsomeip_sec_client_t its_sec_client_uid_gid = utility::create_uds_client(uid_1, gid_1); - vsomeip_sec_client_t its_sec_client_uid_gid_alternate = utility::create_uds_client(uid_2, gid_2); + vsomeip_sec_client_t its_sec_client_uid_gid = utility::create_uds_client(uid_1, gid_1, host_address); + vsomeip_sec_client_t its_sec_client_uid_gid_alternate = utility::create_uds_client(uid_2, gid_2, host_address); // Add client and uid_gid mappings. security->store_sec_client_to_client_mapping(&its_sec_client_uid_gid, client); @@ -43,8 +44,8 @@ static void BM_get_sec_client_to_clients_mapping_invalid_values(benchmark::State { std::unique_ptr security(new vsomeip_v3::policy_manager_impl); - vsomeip_sec_client_t its_sec_client_uid_gid = utility::create_uds_client(uid_1, gid_1); - vsomeip_sec_client_t its_sec_client_uid_gid_alternate = utility::create_uds_client(uid_2, gid_2); + vsomeip_sec_client_t its_sec_client_uid_gid = utility::create_uds_client(uid_1, gid_1, host_address); + vsomeip_sec_client_t its_sec_client_uid_gid_alternate = utility::create_uds_client(uid_2, gid_2, host_address); std::set clients; for (auto _ : state) { diff --git a/test/benchmark_tests/security_tests/bm_is_client_allowed.cpp b/test/benchmark_tests/security_tests/bm_is_client_allowed.cpp index fbbbde348..c33c2c28d 100644 --- a/test/benchmark_tests/security_tests/bm_is_client_allowed.cpp +++ b/test/benchmark_tests/security_tests/bm_is_client_allowed.cpp @@ -1,12 +1,18 @@ +// Copyright (C) 2023 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/. + #include -#include "../../common/utility.hpp" +#include namespace { vsomeip_v3::client_t client = 1; vsomeip_v3::uid_t uid_1 = 4003031; vsomeip_v3::gid_t gid_1 = 4003031; + vsomeip_sec_ip_addr_t host_address = 0; vsomeip_v3::service_t service_1 = 0xf913; vsomeip_v3::instance_t instance = 0x03; @@ -23,7 +29,7 @@ namespace { static void BM_is_client_allowed_policies_not_loaded(benchmark::State& state) { std::unique_ptr its_manager(new vsomeip_v3::policy_manager_impl); - vsomeip_sec_client_t its_sec_client_invalid = utility::create_uds_client(invalid_uid, invalid_gid); + vsomeip_sec_client_t its_sec_client_invalid = utility::create_uds_client(invalid_uid, invalid_gid, host_address); for (auto _ : state) { @@ -43,7 +49,7 @@ static void BM_is_client_allowed_policies_loaded_valid_values(benchmark::State& its_manager->load(e, false); } - vsomeip_sec_client_t its_sec_client = utility::create_uds_client(uid_1, gid_1); + vsomeip_sec_client_t its_sec_client = utility::create_uds_client(uid_1, gid_1, host_address); for (auto _ : state) { its_manager->is_client_allowed(&its_sec_client, service_1, instance, method); @@ -61,7 +67,7 @@ static void BM_is_client_allowed_cache_policies_loaded(benchmark::State& state) its_manager->load(e, false); } - vsomeip_sec_client_t its_sec_client = utility::create_uds_client(uid_1, gid_1); + vsomeip_sec_client_t its_sec_client = utility::create_uds_client(uid_1, gid_1, host_address); its_manager->is_client_allowed(&its_sec_client, service_1, instance, method); @@ -81,7 +87,7 @@ static void BM_is_client_allowed_policies_loaded_invalid_values(benchmark::State its_manager->load(e, false); } - vsomeip_sec_client_t its_sec_client_invalid = utility::create_uds_client(invalid_uid, invalid_gid); + vsomeip_sec_client_t its_sec_client_invalid = utility::create_uds_client(invalid_uid, invalid_gid, host_address); for (auto _ : state) { its_manager->is_client_allowed(&its_sec_client_invalid, service_1, instance, method); @@ -99,7 +105,7 @@ static void BM_is_client_allowed_policies_loaded_deny_valid_values(benchmark::St its_manager->load(e, false); } - vsomeip_sec_client_t its_sec_client_deny = utility::create_uds_client(deny_uid, deny_gid); + vsomeip_sec_client_t its_sec_client_deny = utility::create_uds_client(deny_uid, deny_gid, host_address); for (auto _ : state) { its_manager->is_client_allowed(&its_sec_client_deny, deny_service, instance, method); @@ -118,7 +124,7 @@ static void BM_is_client_allowed_policies_loaded_audit_mode_valid_values(benchma its_manager->load(e, false); } - vsomeip_sec_client_t its_sec_client = utility::create_uds_client(uid_1, gid_1); + vsomeip_sec_client_t its_sec_client = utility::create_uds_client(uid_1, gid_1, host_address); for (auto _ : state) { its_manager->is_client_allowed(&its_sec_client, client, service_1, instance, method); @@ -137,7 +143,7 @@ static void BM_is_client_allowed_cache_policies_loaded_audit_mode(benchmark::Sta its_manager->load(e, false); } - vsomeip_sec_client_t its_sec_client = utility::create_uds_client(uid_1, gid_1); + vsomeip_sec_client_t its_sec_client = utility::create_uds_client(uid_1, gid_1, host_address); its_manager->is_client_allowed(&its_sec_client, service_1, instance, method); @@ -158,7 +164,7 @@ static void BM_is_client_allowed_policies_loaded_audit_mode_invalid_values(bench its_manager->load(e, false); } - vsomeip_sec_client_t its_sec_client_invalid = utility::create_uds_client(invalid_uid, invalid_gid); + vsomeip_sec_client_t its_sec_client_invalid = utility::create_uds_client(invalid_uid, invalid_gid, host_address); for (auto _ : state) { its_manager->is_client_allowed(&its_sec_client_invalid, service_1, instance, method); @@ -177,7 +183,7 @@ static void BM_is_client_allowed_policies_loaded_audit_mode_deny_valid_values(be its_manager->load(e, false); } - vsomeip_sec_client_t its_sec_client_deny = utility::create_uds_client(deny_uid, deny_gid); + vsomeip_sec_client_t its_sec_client_deny = utility::create_uds_client(deny_uid, deny_gid, host_address); for (auto _ : state) { its_manager->is_client_allowed(&its_sec_client_deny, deny_service, instance, method); @@ -192,4 +198,4 @@ BENCHMARK(BM_is_client_allowed_policies_loaded_deny_valid_values); BENCHMARK(BM_is_client_allowed_policies_loaded_audit_mode_valid_values); BENCHMARK(BM_is_client_allowed_cache_policies_loaded_audit_mode); BENCHMARK(BM_is_client_allowed_policies_loaded_audit_mode_invalid_values); -BENCHMARK(BM_is_client_allowed_policies_loaded_audit_mode_deny_valid_values); \ No newline at end of file +BENCHMARK(BM_is_client_allowed_policies_loaded_audit_mode_deny_valid_values); diff --git a/test/benchmark_tests/security_tests/bm_is_offer_allowed.cpp b/test/benchmark_tests/security_tests/bm_is_offer_allowed.cpp index 4b8299f60..36718ae67 100644 --- a/test/benchmark_tests/security_tests/bm_is_offer_allowed.cpp +++ b/test/benchmark_tests/security_tests/bm_is_offer_allowed.cpp @@ -1,16 +1,17 @@ -// Copyright (C) 2022 Bayerische Motoren Werke Aktiengesellschaft (BMW AG) +// Copyright (C) 2023 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/. #include -#include "../../common/utility.hpp" +#include namespace { vsomeip_v3::uid_t uid_1 = 4003016; vsomeip_v3::gid_t gid_1 = 4003016; +vsomeip_sec_ip_addr_t host_address = 0; vsomeip_v3::service_t service_1 = 0xf8c2; vsomeip_v3::service_t deny_service = 0x40; @@ -27,7 +28,7 @@ vsomeip_v3::gid_t deny_gid = 9000; static void BM_is_offer_allowed_policies_not_loaded(benchmark::State& state) { std::unique_ptr security(new vsomeip_v3::policy_manager_impl); - vsomeip_sec_client_t its_sec_client_invalid = utility::create_uds_client(invalid_uid, invalid_gid); + vsomeip_sec_client_t its_sec_client_invalid = utility::create_uds_client(invalid_uid, invalid_gid, host_address); for (auto _ : state) { @@ -44,7 +45,7 @@ static void BM_is_offer_allowed_policies_loaded_valid_values(benchmark::State& s std::vector dir_skip; utility::read_data(utility::get_all_files_in_dir(utility::get_policies_path(), dir_skip), policy_elements, its_failed); - vsomeip_sec_client_t its_sec_client_valid = utility::create_uds_client(uid_1, gid_1); + vsomeip_sec_client_t its_sec_client_valid = utility::create_uds_client(uid_1, gid_1, host_address); for (const auto& e : policy_elements) { security->load(e, false); @@ -64,7 +65,7 @@ static void BM_is_offer_allowed_policies_loaded_invalid_values(benchmark::State& std::vector dir_skip; utility::read_data(utility::get_all_files_in_dir(utility::get_policies_path(), dir_skip), policy_elements, its_failed); - vsomeip_sec_client_t its_sec_client_invalid = utility::create_uds_client(invalid_uid, invalid_gid); + vsomeip_sec_client_t its_sec_client_invalid = utility::create_uds_client(invalid_uid, invalid_gid, host_address); for (const auto& e : policy_elements) { security->load(e, false); @@ -84,7 +85,7 @@ static void BM_is_offer_allowed_policies_loaded_deny_valid_values(benchmark::Sta std::vector dir_skip; utility::read_data(utility::get_all_files_in_dir(utility::get_policies_path(), dir_skip), policy_elements, its_failed); - vsomeip_sec_client_t its_sec_client_deny = utility::create_uds_client(deny_uid, deny_gid); + vsomeip_sec_client_t its_sec_client_deny = utility::create_uds_client(deny_uid, deny_gid, host_address); for (const auto& e : policy_elements) { security->load(e, false); @@ -105,7 +106,7 @@ static void BM_is_offer_allowed_policies_loaded_audit_mode_valid_values(benchmar utility::read_data(utility::get_all_files_in_dir(utility::get_policies_path(), dir_skip), policy_elements, its_failed); utility::force_check_credentials(policy_elements, "false"); - vsomeip_sec_client_t its_sec_client_valid = utility::create_uds_client(uid_1, gid_1); + vsomeip_sec_client_t its_sec_client_valid = utility::create_uds_client(uid_1, gid_1, host_address); for (const auto& e : policy_elements) { security->load(e, false); @@ -126,7 +127,7 @@ static void BM_is_offer_allowed_policies_loaded_audit_mode_invalid_values(benchm utility::read_data(utility::get_all_files_in_dir(utility::get_policies_path(), dir_skip), policy_elements, its_failed); utility::force_check_credentials(policy_elements, "false"); - vsomeip_sec_client_t its_sec_client_invalid = utility::create_uds_client(invalid_uid, invalid_gid); + vsomeip_sec_client_t its_sec_client_invalid = utility::create_uds_client(invalid_uid, invalid_gid, host_address); for (const auto& e : policy_elements) { security->load(e, false); @@ -147,7 +148,7 @@ static void BM_is_offer_allowed_policies_loaded_audit_mode_deny_valid_values(ben utility::read_data(utility::get_all_files_in_dir(utility::get_policies_path(), dir_skip), policy_elements, its_failed); utility::force_check_credentials(policy_elements, "false"); - vsomeip_sec_client_t its_sec_client_deny = utility::create_uds_client(deny_uid, deny_gid); + vsomeip_sec_client_t its_sec_client_deny = utility::create_uds_client(deny_uid, deny_gid, host_address); for (const auto& e : policy_elements) { security->load(e, false); diff --git a/test/benchmark_tests/security_tests/bm_is_policy_update_allowed.cpp b/test/benchmark_tests/security_tests/bm_is_policy_update_allowed.cpp index 8e3ab4d3e..c4bc047aa 100644 --- a/test/benchmark_tests/security_tests/bm_is_policy_update_allowed.cpp +++ b/test/benchmark_tests/security_tests/bm_is_policy_update_allowed.cpp @@ -1,11 +1,11 @@ -// Copyright (C) 2022 Bayerische Motoren Werke Aktiengesellschaft (BMW AG) +// Copyright (C) 2023 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/. #include -#include "../../common/utility.hpp" +#include namespace { std::string configuration_file { "/vsomeip/0_0/vsomeip_security.json" }; diff --git a/test/benchmark_tests/security_tests/bm_load.cpp b/test/benchmark_tests/security_tests/bm_load.cpp index 57a871e49..be53d023a 100644 --- a/test/benchmark_tests/security_tests/bm_load.cpp +++ b/test/benchmark_tests/security_tests/bm_load.cpp @@ -1,11 +1,11 @@ -// Copyright (C) 2022 Bayerische Motoren Werke Aktiengesellschaft (BMW AG) +// Copyright (C) 2023 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/. #include -#include "../../common/utility.hpp" +#include namespace { diff --git a/test/benchmark_tests/security_tests/bm_load_policies.cpp b/test/benchmark_tests/security_tests/bm_load_policies.cpp index bfafd7e74..e69863c4d 100644 --- a/test/benchmark_tests/security_tests/bm_load_policies.cpp +++ b/test/benchmark_tests/security_tests/bm_load_policies.cpp @@ -1,10 +1,10 @@ -// Copyright (C) 2022 Bayerische Motoren Werke Aktiengesellschaft (BMW AG) +// Copyright (C) 2023 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/. #include -#include "../../common/utility.hpp" +#include #include namespace { diff --git a/test/benchmark_tests/security_tests/bm_load_security_policy_extensions.cpp b/test/benchmark_tests/security_tests/bm_load_security_policy_extensions.cpp new file mode 100644 index 000000000..38f62caa0 --- /dev/null +++ b/test/benchmark_tests/security_tests/bm_load_security_policy_extensions.cpp @@ -0,0 +1,126 @@ +// Copyright (C) 2023 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/. + +#include + +#include + +// create valid and invalid user credentials +namespace +{ + std::string configuration_file{ + "/vsomeip/vsomeip_policy_extensions.json"}; // set configuration file policy + +} // namespace + +static void BM_configuration_element(benchmark::State &state) +{ + // Test object path + std::unique_ptr security{ + new vsomeip_v3::policy_manager_impl}; + + // set element + std::vector element; + std::vector full_element; + + // After load try again and check size + std::set its_failed; + std::vector dir_skip; + utility::read_data( + utility::get_all_files_in_dir(utility::get_policies_path(), dir_skip), + full_element, its_failed); + + // load each e into policy_elements + for (const auto &e : full_element) + { + security->load(e, false); // for each e in policy_elements vector load e + } + + // force lazy load = false + for (auto _ : state) + { + security->load(full_element.at(0), false); + } +} + +static void BM_is_policy_extension_loaded(benchmark::State &state) +{ + // Test object path. + std::unique_ptr security{ + new vsomeip_v3::policy_manager_impl}; + + // Set element. + std::vector policy_elements; + + // Force Load of policies. + std::set its_failed; + std::set input{utility::get_policies_path() + + configuration_file}; + utility::read_data(input, policy_elements, its_failed); + + // Load policies. + security->load(policy_elements.at(0)); + + // Check JSON container string. + std::string policy_extension_container{"android-rse"}; + + // Set extension as loaded. + bool loaded_extension = true; + + for (auto _ : state) + { + security->set_is_policy_extension_loaded(policy_extension_container, loaded_extension); + } +} + +static void BM_is_policy_extension_not_loaded(benchmark::State &state) +{ + // Test object path. + std::unique_ptr security{ + new vsomeip_v3::policy_manager_impl}; + + // Set element. + std::vector policy_elements; + + // Force Load of policies. + std::set its_failed; + std::set input{utility::get_policies_path() + + configuration_file}; + utility::read_data(input, policy_elements, its_failed); + + // Load policies. + security->load(policy_elements.at(0)); + + // Check JSON container string. + std::string policy_extension_container{"android-rse"}; + + // Set extension NOT loaded. + bool loaded_extension = false; + + for (auto _ : state) + { + security->set_is_policy_extension_loaded(policy_extension_container, loaded_extension); + } +} + +static void BM_is_policy_extension_not_found(benchmark::State &state) +{ + // Test object path + std::unique_ptr security{ + new vsomeip_v3::policy_manager_impl}; + + // set element + std::vector policy_elements; + + for (auto _ : state) + { + security->is_policy_extension_loaded(""); + } +} + +BENCHMARK(BM_configuration_element); +BENCHMARK(BM_is_policy_extension_loaded); +BENCHMARK(BM_is_policy_extension_not_loaded); +BENCHMARK(BM_is_policy_extension_not_found); diff --git a/test/benchmark_tests/security_tests/bm_load_security_update_whitelist.cpp b/test/benchmark_tests/security_tests/bm_load_security_update_whitelist.cpp index 9c9a43d93..2ec4a1e2e 100644 --- a/test/benchmark_tests/security_tests/bm_load_security_update_whitelist.cpp +++ b/test/benchmark_tests/security_tests/bm_load_security_update_whitelist.cpp @@ -1,10 +1,10 @@ -// Copyright (C) 2022 Bayerische Motoren Werke Aktiengesellschaft (BMW AG) +// Copyright (C) 2023 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/. #include -#include "../../common/utility.hpp" +#include namespace { std::string configuration_file { "/vsomeip/0_0/vsomeip_security.json" }; } diff --git a/test/benchmark_tests/security_tests/bm_remove_client_to_sec_client_mapping.cpp b/test/benchmark_tests/security_tests/bm_remove_client_to_sec_client_mapping.cpp index 9a529eb88..7b70095e6 100644 --- a/test/benchmark_tests/security_tests/bm_remove_client_to_sec_client_mapping.cpp +++ b/test/benchmark_tests/security_tests/bm_remove_client_to_sec_client_mapping.cpp @@ -1,16 +1,17 @@ -// Copyright (C) 2022 Bayerische Motoren Werke Aktiengesellschaft (BMW AG) +// Copyright (C) 2023 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/. #include -#include "../../common/utility.hpp" +#include namespace{ vsomeip_v3::client_t client = 10; vsomeip_v3::uid_t uid = 4003030; vsomeip_v3::gid_t gid = 4003032; +vsomeip_sec_ip_addr_t host_address = 0; std::pair client_uid_gid{uid, gid}; } @@ -19,7 +20,7 @@ static void BM_remove_client_to_sec_client_mapping_invalid_values(benchmark::Sta { std::unique_ptr security(new vsomeip_v3::policy_manager_impl); - vsomeip_sec_client_t its_sec_client = utility::create_uds_client(uid, gid); + vsomeip_sec_client_t its_sec_client = utility::create_uds_client(uid, gid, host_address); for (auto _ : state) { security->get_client_to_sec_client_mapping(client, its_sec_client); @@ -34,7 +35,7 @@ static void BM_remove_client_to_sec_client_mapping_valid_values(benchmark::State { std::unique_ptr security(new vsomeip_v3::policy_manager_impl); - vsomeip_sec_client_t its_sec_client = utility::create_uds_client(uid, gid); + vsomeip_sec_client_t its_sec_client = utility::create_uds_client(uid, gid, host_address); security->store_client_to_sec_client_mapping(client, &its_sec_client); security->store_sec_client_to_client_mapping(&its_sec_client, client); diff --git a/test/benchmark_tests/security_tests/bm_remove_security_policy.cpp b/test/benchmark_tests/security_tests/bm_remove_security_policy.cpp index c56cfd676..2fa88bbc7 100644 --- a/test/benchmark_tests/security_tests/bm_remove_security_policy.cpp +++ b/test/benchmark_tests/security_tests/bm_remove_security_policy.cpp @@ -1,11 +1,11 @@ -// Copyright (C) 2022 Bayerische Motoren Werke Aktiengesellschaft (BMW AG) +// Copyright (C) 2023 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/. #include -#include "../../common/utility.hpp" +#include namespace { diff --git a/test/common/CMakeLists.txt b/test/common/CMakeLists.txt new file mode 100644 index 000000000..d4d145347 --- /dev/null +++ b/test/common/CMakeLists.txt @@ -0,0 +1,40 @@ +# Copyright (C) 2023 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/. + +project (vsomeip_utilities) + +# ---------------------------------------------------------------------------- +# Include all source files (cpp/hpp) +# ---------------------------------------------------------------------------- +file (GLOB SRC src/*.cpp) +file (GLOB INC include/common/*.hpp, include/common/vsomeip_app_utilities/*.hpp) + +# ---------------------------------------------------------------------------- +# Declare the library +# ---------------------------------------------------------------------------- +add_library ( + ${PROJECT_NAME} SHARED + ${SRC} + ${INC} +) + +TARGET_LINK_LIBRARIES ( + ${PROJECT_NAME} + PUBLIC + ${VSOMEIP_NAME} + ${Boost_LIBRARIES} + ${DL_LIBRARY} + ${TEST_LINK_LIBRARIES} +) + +# ---------------------------------------------------------------------------- +# Specify here the include directories exported +# by this library +# ---------------------------------------------------------------------------- +target_include_directories ( + ${PROJECT_NAME} + PUBLIC include + PRIVATE src +) diff --git a/test/common/examples_policies/vsomeip/4002200_4002200/vsomeip_security.json b/test/common/examples_policies/vsomeip/4002200_4002200/vsomeip_security.json index 221d0352a..1fb347769 100644 --- a/test/common/examples_policies/vsomeip/4002200_4002200/vsomeip_security.json +++ b/test/common/examples_policies/vsomeip/4002200_4002200/vsomeip_security.json @@ -1553,4 +1553,4 @@ } ] } -} \ No newline at end of file +} diff --git a/test/common/examples_policies/vsomeip/4002201_4002201/vsomeip_security.json b/test/common/examples_policies/vsomeip/4002201_4002201/vsomeip_security.json index e03049d83..7e725bae9 100644 --- a/test/common/examples_policies/vsomeip/4002201_4002201/vsomeip_security.json +++ b/test/common/examples_policies/vsomeip/4002201_4002201/vsomeip_security.json @@ -119,4 +119,4 @@ } ] } -} \ No newline at end of file +} diff --git a/test/common/examples_policies/vsomeip/4002205_4002205/vsomeip_security.json b/test/common/examples_policies/vsomeip/4002205_4002205/vsomeip_security.json index 9512f8d62..0d70132e8 100644 --- a/test/common/examples_policies/vsomeip/4002205_4002205/vsomeip_security.json +++ b/test/common/examples_policies/vsomeip/4002205_4002205/vsomeip_security.json @@ -51,4 +51,4 @@ } ] } -} \ No newline at end of file +} diff --git a/test/common/examples_policies/vsomeip/4003013_4003011/vsomeip_security.json b/test/common/examples_policies/vsomeip/4003013_4003011/vsomeip_security.json index da35eb4fc..1534a93b2 100644 --- a/test/common/examples_policies/vsomeip/4003013_4003011/vsomeip_security.json +++ b/test/common/examples_policies/vsomeip/4003013_4003011/vsomeip_security.json @@ -61,4 +61,4 @@ } ] } -} \ No newline at end of file +} diff --git a/test/common/examples_policies/vsomeip/4003014_4003014/vsomeip_security.json b/test/common/examples_policies/vsomeip/4003014_4003014/vsomeip_security.json index 0de3d03c9..06af6565a 100644 --- a/test/common/examples_policies/vsomeip/4003014_4003014/vsomeip_security.json +++ b/test/common/examples_policies/vsomeip/4003014_4003014/vsomeip_security.json @@ -1303,4 +1303,4 @@ } ] } -} \ No newline at end of file +} diff --git a/test/common/examples_policies/vsomeip/4003015_4003015/vsomeip_security.json b/test/common/examples_policies/vsomeip/4003015_4003015/vsomeip_security.json index 20f0b4761..b92ae37bc 100644 --- a/test/common/examples_policies/vsomeip/4003015_4003015/vsomeip_security.json +++ b/test/common/examples_policies/vsomeip/4003015_4003015/vsomeip_security.json @@ -79,4 +79,4 @@ } ] } -} \ No newline at end of file +} diff --git a/test/common/utility.hpp b/test/common/include/common/utility.hpp similarity index 89% rename from test/common/utility.hpp rename to test/common/include/common/utility.hpp index b4f110068..1fe896fe3 100644 --- a/test/common/utility.hpp +++ b/test/common/include/common/utility.hpp @@ -1,12 +1,12 @@ -// Copyright (C) 2022 Bayerische Motoren Werke Aktiengesellschaft (BMW AG) +// Copyright (C) 2023 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/. #include -#include "../../implementation/security/include/policy_manager_impl.hpp" -#include "../../implementation/configuration/include/configuration_impl.hpp" -#include "../../implementation/utility/include/utility.hpp" +#include "../../../implementation/security/include/policy_manager_impl.hpp" +#include "../../../implementation/configuration/include/configuration_impl.hpp" +#include "../../../implementation/utility/include/utility.hpp" // This is needed to silence internal warnings in boost, when e.g. including #define BOOST_BIND_GLOBAL_PLACEHOLDERS @@ -31,7 +31,7 @@ class utility { static std::string get_policies_path(); - static vsomeip_sec_client_t create_uds_client(uid_t user, gid_t group); + static vsomeip_sec_client_t create_uds_client(uid_t user, gid_t group, vsomeip_sec_ip_addr_t host); static void force_check_credentials(std::vector &_policy_elements, std::string _value); /** diff --git a/test/common/include/common/vsomeip_app_utilities.hpp b/test/common/include/common/vsomeip_app_utilities.hpp new file mode 100644 index 000000000..5ad0be398 --- /dev/null +++ b/test/common/include/common/vsomeip_app_utilities.hpp @@ -0,0 +1,51 @@ +// Copyright (C) 2023 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_BASE_APP +#define VSOMEIP_BASE_APP +#include +#include +#include +#include +#include +#include + +#ifdef USE_DLT +#ifndef ANDROID +#include +#endif +#endif + +namespace vsomeip_utilities { + +std::shared_ptr create_standard_vsip_request( + vsomeip::service_t _service, vsomeip::instance_t _instance, vsomeip_v3::method_t _method, + vsomeip_v3::interface_version_t _interface, vsomeip_v3::message_type_e _message_type); + +class base_logger +{ +public: + const char *_dlt_application_id = nullptr; + const char *_dlt_application_name = nullptr; + + base_logger(const char *dlt_application_id, const char *dlt_application_name); + + ~base_logger(); +}; + +class base_vsip_app: public base_logger +{ +protected: + std::shared_ptr _app; + std::thread _run_thread; + + void run(); + +public: + base_vsip_app(const char *app_name_, const char *app_id_); + ~base_vsip_app(); +}; +} +#endif // VSOMEIP_BASE_APP diff --git a/test/common/utility.cpp b/test/common/src/utility.cpp similarity index 97% rename from test/common/utility.cpp rename to test/common/src/utility.cpp index 478deeb56..cdf6db8a9 100644 --- a/test/common/utility.cpp +++ b/test/common/src/utility.cpp @@ -1,9 +1,9 @@ -// Copyright (C) 2022 Bayerische Motoren Werke Aktiengesellschaft (BMW AG) +// Copyright (C) 2023 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/. -#include "utility.hpp" +#include void utility::load_policy_data(std::string _input, @@ -102,10 +102,8 @@ utility::get_policies_path() { } vsomeip_sec_client_t -utility::create_uds_client(uid_t user, gid_t group) { - vsomeip_sec_client_t result; - result.client_type = VSOMEIP_CLIENT_UDS; - result.client.uds_client = { user, group }; +utility::create_uds_client(uid_t user, gid_t group, vsomeip_sec_ip_addr_t host) { + vsomeip_sec_client_t result{ user, group, host, VSOMEIP_SEC_PORT_UNUSED }; return result; } diff --git a/test/common/src/vsomeip_app_utilities.cpp b/test/common/src/vsomeip_app_utilities.cpp new file mode 100644 index 000000000..f2e00106c --- /dev/null +++ b/test/common/src/vsomeip_app_utilities.cpp @@ -0,0 +1,64 @@ +// Copyright (C) 2023 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/. + +#include + +namespace vsomeip_utilities { + +std::shared_ptr create_standard_vsip_request( + vsomeip::service_t _service, vsomeip::instance_t _instance, vsomeip_v3::method_t _method, + vsomeip_v3::interface_version_t _interface, vsomeip_v3::message_type_e _message_type) +{ + auto its_runtime = vsomeip::runtime::get(); + auto its_payload = its_runtime->create_payload(); + auto its_message = its_runtime->create_request(false); + its_message->set_service(_service); + its_message->set_instance(_instance); + its_message->set_method(_method); + its_message->set_interface_version(_interface); + its_message->set_message_type(_message_type); + its_message->set_payload(its_payload); + + return its_message; +} + +base_logger::base_logger(const char *dlt_application_id, const char *dlt_application_name) + : _dlt_application_id(dlt_application_id), + _dlt_application_name(dlt_application_name) +{ +#ifdef USE_DLT +#ifndef ANDROID + DLT_REGISTER_APP(_dlt_application_id, _dlt_application_name); +#endif +#endif +} + +base_logger::~base_logger() +{ +#ifdef USE_DLT +#ifndef ANDROID + DLT_UNREGISTER_APP(); +#endif +#endif +} + +base_vsip_app::base_vsip_app(const char *app_name_, const char *app_id_) : base_logger( app_name_, app_id_) +{ + _app = vsomeip::runtime::get()->create_application(app_name_); + _app->init(); + _run_thread = std::thread(std::bind(&base_vsip_app::run, this)); +} + +void base_vsip_app::run() +{ + _app->start(); +} + +base_vsip_app::~base_vsip_app() +{ + _app->stop(); + _run_thread.join(); +} +} diff --git a/test/internal_routing_disabled_acceptance_test/applet.cpp b/test/internal_routing_disabled_acceptance_test/applet.cpp index 50bf41c6c..d327fbdd1 100644 --- a/test/internal_routing_disabled_acceptance_test/applet.cpp +++ b/test/internal_routing_disabled_acceptance_test/applet.cpp @@ -6,8 +6,24 @@ #include #include -applet::applet(std::string_view name) : application{vsomeip_v3::runtime::get()->create_application(std::string{name})} +applet::applet(std::string_view name) + : application{vsomeip_v3::runtime::get()->create_application(std::string{name})} { + +} + +applet::~applet() +{ + this->application->clear_all_handler(); + this->application->stop(); + this->async_start.wait(); +} + +void +applet::init() { + + std::weak_ptr its_me = shared_from_this(); + if(!this->application->init()) { using namespace std::string_literals; @@ -21,24 +37,20 @@ applet::applet(std::string_view name) : application{vsomeip_v3::runtime::get()-> ); this->application->register_state_handler( - [this](vsomeip_v3::state_type_e state){ - switch(state) - { - case vsomeip_v3::state_type_e::ST_REGISTERED: - return this->on_state_registered(); - case vsomeip_v3::state_type_e::ST_DEREGISTERED: - return this->on_state_deregistered(); + [its_me](vsomeip_v3::state_type_e state) { + auto me = its_me.lock(); + if (me) { + switch(state) + { + case vsomeip_v3::state_type_e::ST_REGISTERED: + return me->on_state_registered(); + case vsomeip_v3::state_type_e::ST_DEREGISTERED: + return me->on_state_deregistered(); + } } } ); } -applet::~applet() -{ - this->application->clear_all_handler(); - this->application->stop(); - this->async_start.wait(); -} - void applet::on_state_registered() {} void applet::on_state_deregistered() {} diff --git a/test/internal_routing_disabled_acceptance_test/applet.hpp b/test/internal_routing_disabled_acceptance_test/applet.hpp index d536dc0ed..0d2734332 100644 --- a/test/internal_routing_disabled_acceptance_test/applet.hpp +++ b/test/internal_routing_disabled_acceptance_test/applet.hpp @@ -6,7 +6,7 @@ #include -struct applet +struct applet : public std::enable_shared_from_this { protected: std::shared_ptr application; @@ -14,6 +14,8 @@ struct applet applet(std::string_view name); virtual ~applet(); + void init(); + private: std::future async_start; diff --git a/test/internal_routing_disabled_acceptance_test/client.cpp b/test/internal_routing_disabled_acceptance_test/client.cpp index ff7be781c..e0825b379 100644 --- a/test/internal_routing_disabled_acceptance_test/client.cpp +++ b/test/internal_routing_disabled_acceptance_test/client.cpp @@ -15,33 +15,45 @@ client::client() : applet{"client"}, counter_event_received{}, counter_method_request{}, counter_method_response{} { +} + +void +client::init() { + applet::init(); + + std::weak_ptr its_me + = std::dynamic_pointer_cast(shared_from_this()); + this->application->register_message_handler( config::SERVICE_ID, config::INSTANCE_ID, vsomeip_v3::ANY_METHOD, - [this](const std::shared_ptr& message){ - std::shared_ptr runtime = vsomeip_v3::runtime::get(); - std::shared_ptr payload = message->get_payload(); - - switch(message->get_message_type()) - { - case vsomeip_v3::message_type_e::MT_RESPONSE: - std::cout - << "received:\n" - << "\tservice: " << std::hex << message->get_service() << '\n' - << "\tinstance: " << std::hex << message->get_instance() << '\n' - << "\tmethod: " << std::hex << message->get_method() << '\n' - << "\tpayload: " << payload->get_data() << '\n'; - this->counter_method_response++; - break; - - case vsomeip_v3::message_type_e::MT_NOTIFICATION: - std::cout << "GOT NOTIFICATION\n"; - this->counter_event_received++; - [[fallthrough]]; - - default: - std::cout << "unhandled message type: " << unsigned(message->get_message_type()) << '\n'; + [its_me](const std::shared_ptr& message){ + auto me = its_me.lock(); + if (me) { + std::shared_ptr runtime = vsomeip_v3::runtime::get(); + std::shared_ptr payload = message->get_payload(); + + switch(message->get_message_type()) + { + case vsomeip_v3::message_type_e::MT_RESPONSE: + std::cout + << "received:\n" + << "\tservice: " << std::hex << message->get_service() << '\n' + << "\tinstance: " << std::hex << message->get_instance() << '\n' + << "\tmethod: " << std::hex << message->get_method() << '\n' + << "\tpayload: " << payload->get_data() << '\n'; + me->counter_method_response++; + break; + + case vsomeip_v3::message_type_e::MT_NOTIFICATION: + std::cout << "GOT NOTIFICATION\n"; + me->counter_event_received++; + [[fallthrough]]; + + default: + std::cout << "unhandled message type: " << unsigned(message->get_message_type()) << '\n'; + } } } ); @@ -49,40 +61,43 @@ client::client() : applet{"client"}, counter_event_received{}, counter_method_re this->application->register_availability_handler( config::SERVICE_ID, config::INSTANCE_ID, - [this](vsomeip_v3::service_t service, vsomeip_v3::instance_t instance, bool available){ - std::cout - << __func__ << '(' - << std::hex << service << ", " - << std::hex << instance << ", " - << std::boolalpha << available << ")\n"; - - if(service != config::SERVICE_ID) - return; - if(instance != config::INSTANCE_ID) - return; - if(!available) - return; - - std::shared_ptr runtime = vsomeip_v3::runtime::get(); - - std::shared_ptr payload = runtime->create_payload(); - constexpr vsomeip_v3::byte_t str[]{"hello world"}; - payload->set_data(str, sizeof(str)); - - std::shared_ptr request = runtime->create_request(); - request->set_service(config::SERVICE_ID); - request->set_instance(config::INSTANCE_ID); - request->set_method(config::METHOD_ID); - request->set_payload(payload); - - for(int i = 0; i < 10; i++) - { - std::cout << "sending: " << str << '\n'; - this->application->send(request); - this->counter_method_request++; - - using namespace std::chrono_literals; - std::this_thread::sleep_for(1s); + [its_me](vsomeip_v3::service_t service, vsomeip_v3::instance_t instance, bool available){ + auto me = its_me.lock(); + if (me) { + std::cout + << __func__ << '(' + << std::hex << service << ", " + << std::hex << instance << ", " + << std::boolalpha << available << ")\n"; + + if(service != config::SERVICE_ID) + return; + if(instance != config::INSTANCE_ID) + return; + if(!available) + return; + + std::shared_ptr runtime = vsomeip_v3::runtime::get(); + + std::shared_ptr payload = runtime->create_payload(); + constexpr vsomeip_v3::byte_t str[]{"hello world"}; + payload->set_data(str, sizeof(str)); + + std::shared_ptr request = runtime->create_request(); + request->set_service(config::SERVICE_ID); + request->set_instance(config::INSTANCE_ID); + request->set_method(config::METHOD_ID); + request->set_payload(payload); + + for(int i = 0; i < 10; i++) + { + std::cout << "sending: " << str << '\n'; + me->application->send(request); + me->counter_method_request++; + + using namespace std::chrono_literals; + std::this_thread::sleep_for(1s); + } } } ); @@ -121,6 +136,17 @@ client::~client() config::SERVICE_ID, config::INSTANCE_ID ); + + this->application->unregister_availability_handler( + config::SERVICE_ID, + config::INSTANCE_ID + ); + + this->application->unregister_message_handler( + config::SERVICE_ID, + config::INSTANCE_ID, + vsomeip_v3::ANY_METHOD + ); } std::size_t client::get_event_count() noexcept diff --git a/test/internal_routing_disabled_acceptance_test/client.hpp b/test/internal_routing_disabled_acceptance_test/client.hpp index f6eba6508..e1f22dbe7 100644 --- a/test/internal_routing_disabled_acceptance_test/client.hpp +++ b/test/internal_routing_disabled_acceptance_test/client.hpp @@ -2,6 +2,7 @@ #include #include +#include #include "applet.hpp" @@ -10,6 +11,8 @@ struct client final : applet client(); ~client(); + void init(); + std::size_t get_event_count() noexcept; std::size_t get_method_request_count() noexcept; std::size_t get_method_response_count() noexcept; diff --git a/test/internal_routing_disabled_acceptance_test/main.cpp b/test/internal_routing_disabled_acceptance_test/main.cpp index 7a2e7fccf..270132e3c 100644 --- a/test/internal_routing_disabled_acceptance_test/main.cpp +++ b/test/internal_routing_disabled_acceptance_test/main.cpp @@ -4,36 +4,41 @@ #include +#include + #include "client.hpp" #include "server.hpp" TEST(internal_routing_disabled_acceptance_test, check_connectivity) { - server s; - client c; + auto s = std::make_shared(); + s->init(); + + auto c = std::make_shared(); + c->init(); using namespace std::chrono_literals; std::this_thread::sleep_for(15s); - std::cout + VSOMEIP_INFO << "[server]\n" - << "\tevents: " << s.get_event_count() << '\n' - << "\tmethod requests: " << s.get_method_request_count() << '\n' - << "\tmethod responses: " << s.get_method_response_count() << '\n'; + << "\tevents: " << s->get_event_count() << '\n' + << "\tmethod requests: " << s->get_method_request_count() << '\n' + << "\tmethod responses: " << s->get_method_response_count(); - std::cout + VSOMEIP_INFO << "[client]\n" - << "\tevents: " << c.get_event_count() << '\n' - << "\tmethod requests: " << c.get_method_request_count() << '\n' - << "\tmethod responses: " << c.get_method_response_count() << '\n'; + << "\tevents: " << c->get_event_count() << '\n' + << "\tmethod requests: " << c->get_method_request_count() << '\n' + << "\tmethod responses: " << c->get_method_response_count(); - EXPECT_EQ(s.get_event_count(), 10); - EXPECT_EQ(s.get_method_request_count(), 0); - EXPECT_EQ(s.get_method_response_count(), 0); + EXPECT_EQ(s->get_event_count(), 10); + EXPECT_EQ(s->get_method_request_count(), 0); + EXPECT_EQ(s->get_method_response_count(), 0); - EXPECT_EQ(c.get_event_count(), 0); - EXPECT_EQ(c.get_method_request_count(), 0); - EXPECT_EQ(c.get_method_response_count(), 0); + EXPECT_EQ(c->get_event_count(), 0); + EXPECT_EQ(c->get_method_request_count(), 0); + EXPECT_EQ(c->get_method_response_count(), 0); } int main(int count, char** values) diff --git a/test/internal_routing_disabled_acceptance_test/server.cpp b/test/internal_routing_disabled_acceptance_test/server.cpp index 6e00b1e81..5ba7a18b4 100644 --- a/test/internal_routing_disabled_acceptance_test/server.cpp +++ b/test/internal_routing_disabled_acceptance_test/server.cpp @@ -13,39 +13,51 @@ server::server() : applet{"server"}, counter_event_sent{}, counter_method_request{}, counter_method_response{} { +} + +void +server::init() { + applet::init(); + + std::weak_ptr its_me + = std::dynamic_pointer_cast(shared_from_this()); + this->application->register_message_handler( config::SERVICE_ID, config::INSTANCE_ID, config::METHOD_ID, - [this](const std::shared_ptr& message){ - std::shared_ptr runtime = vsomeip_v3::runtime::get(); - std::shared_ptr payload = message->get_payload(); + [its_me](const std::shared_ptr& message){ + auto me = its_me.lock(); + if (me) { + std::shared_ptr runtime = vsomeip_v3::runtime::get(); + std::shared_ptr payload = message->get_payload(); - switch(message->get_message_type()) - { - case vsomeip_v3::message_type_e::MT_REQUEST: - std::cout << "GOT REQUEST\n"; - this->counter_method_request++; + switch(message->get_message_type()) { - std::shared_ptr response = runtime->create_response(message); - response->set_payload(payload); - - this->application->send(response); - this->counter_method_response++; - - this->application->notify( - config::SERVICE_ID, - config::INSTANCE_ID, - config::EVENT_ID, - payload, - true - ); - this->counter_event_sent++; + case vsomeip_v3::message_type_e::MT_REQUEST: + std::cout << "GOT REQUEST\n"; + me->counter_method_request++; + { + std::shared_ptr response = runtime->create_response(message); + response->set_payload(payload); + + me->application->send(response); + me->counter_method_response++; + + me->application->notify( + config::SERVICE_ID, + config::INSTANCE_ID, + config::EVENT_ID, + payload, + true + ); + me->counter_event_sent++; + } + break; + + default: + std::cout << "unhandled message type: " << unsigned(message->get_message_type()) << '\n'; } - break; - - default: - std::cout << "unhandled message type: " << unsigned(message->get_message_type()) << '\n'; } } ); @@ -64,29 +76,31 @@ server::server() : applet{"server"}, counter_event_sent{}, counter_method_reques ); std::thread{ - [this]{ + [its_me]{ using namespace std::chrono_literals; std::this_thread::sleep_for(1s); + auto me = its_me.lock(); std::shared_ptr runtime = vsomeip_v3::runtime::get(); std::shared_ptr payload = runtime->create_payload(); for(int i = 0; i < 10; i++) { int j = i | 0x30; payload->set_data(reinterpret_cast(&j), sizeof(j)); - this->application->notify( + me->application->notify( config::SERVICE_ID, config::INSTANCE_ID, config::EVENT_ID, payload, true ); - this->counter_event_sent++; + me->counter_event_sent++; std::this_thread::sleep_for(1s); } } }.detach(); + } server::~server() diff --git a/test/internal_routing_disabled_acceptance_test/server.hpp b/test/internal_routing_disabled_acceptance_test/server.hpp index 53685f3da..d6da8d7ea 100644 --- a/test/internal_routing_disabled_acceptance_test/server.hpp +++ b/test/internal_routing_disabled_acceptance_test/server.hpp @@ -2,6 +2,7 @@ #include #include +#include #include "applet.hpp" @@ -10,6 +11,8 @@ struct server final : applet server(); ~server(); + void init(); + std::size_t get_event_count() noexcept; std::size_t get_method_request_count() noexcept; std::size_t get_method_response_count() noexcept; diff --git a/test/network_tests/CMakeLists.txt b/test/network_tests/CMakeLists.txt index 42e4389f7..7ddd58923 100644 --- a/test/network_tests/CMakeLists.txt +++ b/test/network_tests/CMakeLists.txt @@ -1,4 +1,4 @@ -# Copyright (C) 2015-2022 Bayerische Motoren Werke Aktiengesellschaft (BMW AG) +# Copyright (C) 2015-2023 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/. @@ -11,8 +11,8 @@ include_directories( ${gtest_SOURCE_DIR}/include ) -set(TEST_LINK_LIBRARIES gtest) +set(TEST_LINK_LIBRARIES gtest) set(NETWORK_TEST_BIN_DIR ${PROJECT_BINARY_DIR}/test/network_tests) set(NETWORK_TEST_SRC_DIR ${PROJECT_SOURCE_DIR}/test/network_tests) @@ -76,7 +76,6 @@ if(NOT ${TESTS_BAT}) add_executable(${TEST_CONFIGURATION} configuration_tests/configuration-test.cpp ${PROJECT_SOURCE_DIR}/implementation/plugin/src/plugin_manager_impl.cpp - ${PROJECT_SOURCE_DIR}/test/common/utility.cpp ) target_link_libraries(${TEST_CONFIGURATION} ${VSOMEIP_NAME} @@ -84,6 +83,8 @@ if(NOT ${TESTS_BAT}) ${Boost_LIBRARIES} ${DL_LIBRARY} ${TEST_LINK_LIBRARIES} + ${DLT_LIBRARIES} + vsomeip_utilities ) # The following will make sure that ${TEST_CONFIGURATION_CONFIG_FILE} is copied @@ -112,6 +113,8 @@ if(NOT ${TESTS_BAT}) ${Boost_LIBRARIES} ${DL_LIBRARY} ${TEST_LINK_LIBRARIES} + ${DLT_LIBRARIES} + vsomeip_utilities ) set(TEST_APPLICATION_SINGLE_PROCESS_NAME ${TEST_APPLICATION}_single_process) @@ -121,6 +124,8 @@ if(NOT ${TESTS_BAT}) ${Boost_LIBRARIES} ${DL_LIBRARY} ${TEST_LINK_LIBRARIES} + ${DLT_LIBRARIES} + vsomeip_utilities ) if(QNX) target_compile_definitions(${TEST_APPLICATION_SINGLE_PROCESS_NAME} PRIVATE _QNX_SOURCE) @@ -133,6 +138,8 @@ if(NOT ${TESTS_BAT}) ${Boost_LIBRARIES} ${DL_LIBRARY} ${TEST_LINK_LIBRARIES} + ${DLT_LIBRARIES} + vsomeip_utilities ) set(TEST_APPLICATION_SINGLE_PROCESS_CONFIGURATION_FILE ${TEST_APPLICATION}_single_process.json) @@ -213,6 +220,8 @@ if(NOT ${TESTS_BAT}) ${DL_LIBRARY} ${CMAKE_THREAD_LIBS_INIT} ${TEST_LINK_LIBRARIES} + ${DLT_LIBRARIES} + vsomeip_utilities ) set(TEST_MAGIC_COOKIES_SERVICE ${TEST_MAGIC_COOKIES_NAME}_service) @@ -221,8 +230,10 @@ if(NOT ${TESTS_BAT}) ${VSOMEIP_NAME} ${Boost_LIBRARIES} ${DL_LIBRARY} + ${DLT_LIBRARIES} ${CMAKE_THREAD_LIBS_INIT} ${TEST_LINK_LIBRARIES} + vsomeip_utilities ) # Copy config file for client into $BUILDDIR/test @@ -283,6 +294,8 @@ if(NOT ${TESTS_BAT}) ${DL_LIBRARY} ${CMAKE_THREAD_LIBS_INIT} ${TEST_LINK_LIBRARIES} + ${DLT_LIBRARIES} + vsomeip_utilities ) ############################################################################## @@ -296,6 +309,8 @@ if(NOT ${TESTS_BAT}) ${DL_LIBRARY} ${CMAKE_THREAD_LIBS_INIT} ${TEST_LINK_LIBRARIES} + ${DLT_LIBRARIES} + vsomeip_utilities ) # Copy config file for client into $BUILDDIR/test @@ -320,6 +335,8 @@ if(NOT ${TESTS_BAT}) ${DL_LIBRARY} ${CMAKE_THREAD_LIBS_INIT} ${TEST_LINK_LIBRARIES} + ${DLT_LIBRARIES} + vsomeip_utilities ) # Copy config file for service into $BUILDDIR/test @@ -357,6 +374,8 @@ if(NOT ${TESTS_BAT}) ${Boost_LIBRARIES} ${DL_LIBRARY} ${TEST_LINK_LIBRARIES} + ${DLT_LIBRARIES} + vsomeip_utilities ) # Copy config file for service into $BUILDDIR/test @@ -380,6 +399,8 @@ if(NOT ${TESTS_BAT}) ${Boost_LIBRARIES} ${DL_LIBRARY} ${TEST_LINK_LIBRARIES} + ${DLT_LIBRARIES} + vsomeip_utilities ) # Copy config file for client into $BUILDDIR/test @@ -420,6 +441,8 @@ if(NOT ${TESTS_BAT}) ${Boost_LIBRARIES} ${DL_LIBRARY} ${TEST_LINK_LIBRARIES} + ${DLT_LIBRARIES} + vsomeip_utilities ) # Copy config file for service into $BUILDDIR/test @@ -478,6 +501,8 @@ else() ${Boost_LIBRARIES} ${DL_LIBRARY} ${TEST_LINK_LIBRARIES} + ${DLT_LIBRARIES} + vsomeip_utilities ) # Copy config file for service into $BUILDDIR/test @@ -501,6 +526,8 @@ else() ${Boost_LIBRARIES} ${DL_LIBRARY} ${TEST_LINK_LIBRARIES} + ${DLT_LIBRARIES} + vsomeip_utilities ) # Copy config file for client into $BUILDDIR/test @@ -542,6 +569,8 @@ if(NOT ${TESTS_BAT}) ${Boost_LIBRARIES} ${DL_LIBRARY} ${TEST_LINK_LIBRARIES} + ${DLT_LIBRARIES} + vsomeip_utilities ) # Copy config file for service into $BUILDDIR/test @@ -569,6 +598,8 @@ if(NOT ${TESTS_BAT}) ${Boost_LIBRARIES} ${DL_LIBRARY} ${TEST_LINK_LIBRARIES} + ${DLT_LIBRARIES} + vsomeip_utilities ) # Copy config file for client into $BUILDDIR/test @@ -619,6 +650,8 @@ if (${TEST_SECURITY}) ${Boost_LIBRARIES} ${DL_LIBRARY} ${TEST_LINK_LIBRARIES} + ${DLT_LIBRARIES} + vsomeip_utilities ) # Copy config file for service into $BUILDDIR/test @@ -713,6 +746,8 @@ if (${TEST_SECURITY}) ${Boost_LIBRARIES} ${DL_LIBRARY} ${TEST_LINK_LIBRARIES} + ${DLT_LIBRARIES} + vsomeip_utilities ) endif() endif() @@ -731,6 +766,8 @@ if(NOT ${TESTS_BAT}) ${Boost_LIBRARIES} ${DL_LIBRARY} ${TEST_LINK_LIBRARIES} + ${DLT_LIBRARIES} + vsomeip_utilities ) # Copy config file for service into $BUILDDIR/test @@ -759,6 +796,8 @@ if(NOT ${TESTS_BAT}) ${Boost_LIBRARIES} ${DL_LIBRARY} ${TEST_LINK_LIBRARIES} + ${DLT_LIBRARIES} + vsomeip_utilities ) # Copy config file for client into $BUILDDIR/test @@ -910,6 +949,8 @@ if(NOT ${TESTS_BAT}) ${Boost_LIBRARIES} ${DL_LIBRARY} ${TEST_LINK_LIBRARIES} + ${DLT_LIBRARIES} + vsomeip_utilities ) set(TEST_BIG_PAYLOAD_CLIENT big_payload_test_client) @@ -919,6 +960,8 @@ if(NOT ${TESTS_BAT}) ${Boost_LIBRARIES} ${DL_LIBRARY} ${TEST_LINK_LIBRARIES} + ${DLT_LIBRARIES} + vsomeip_utilities ) # Copy config file for client and service into $BUILDDIR/test @@ -1268,18 +1311,22 @@ if(NOT ${TESTS_BAT}) ${Boost_LIBRARIES} ${DL_LIBRARY} ${TEST_LINK_LIBRARIES} + ${DLT_LIBRARIES} + vsomeip_utilities ) set(TEST_CLIENT_ID_UTILITY ${TEST_CLIENT_ID_NAME}_utility) add_executable(${TEST_CLIENT_ID_UTILITY} - client_id_tests/${TEST_CLIENT_ID_UTILITY}.cpp - ${PROJECT_SOURCE_DIR}/implementation/utility/src/utility.cpp) + client_id_tests/${TEST_CLIENT_ID_UTILITY}.cpp) + #${PROJECT_SOURCE_DIR}/implementation/utility/src/utility.cpp) target_link_libraries(${TEST_CLIENT_ID_UTILITY} ${VSOMEIP_NAME} ${VSOMEIP_NAME}-cfg ${Boost_LIBRARIES} ${DL_LIBRARY} ${TEST_LINK_LIBRARIES} + ${DLT_LIBRARIES} + vsomeip_utilities ) # Copy config files for test into $BUILDDIR/test @@ -1466,6 +1513,8 @@ if(NOT ${TESTS_BAT}) ${Boost_LIBRARIES} ${DL_LIBRARY} ${TEST_LINK_LIBRARIES} + ${DLT_LIBRARIES} + vsomeip_utilities ) set(TEST_DEBOUNCE_SERVICE ${TEST_DEBOUNCE_NAME}_service) add_executable(${TEST_DEBOUNCE_SERVICE} debounce_tests/${TEST_DEBOUNCE_SERVICE}.cpp) @@ -1474,6 +1523,8 @@ if(NOT ${TESTS_BAT}) ${Boost_LIBRARIES} ${DL_LIBRARY} ${TEST_LINK_LIBRARIES} + ${DLT_LIBRARIES} + vsomeip_utilities ) # copy starter scripts into builddir @@ -1511,6 +1562,122 @@ if(NOT ${TESTS_BAT}) ) endif() +############################################################################## +# debounce filter tests +############################################################################## +if(NOT ${TESTS_BAT}) + set(TEST_DEBOUNCE_FILTER_NAME debounce_filter_test) + set(TEST_DEBOUNCE_FILTER_CLIENT ${TEST_DEBOUNCE_FILTER_NAME}_client) + add_executable(${TEST_DEBOUNCE_FILTER_CLIENT} debounce_filter_tests/${TEST_DEBOUNCE_FILTER_CLIENT}.cpp) + target_link_libraries(${TEST_DEBOUNCE_FILTER_CLIENT} + ${VSOMEIP_NAME} + ${Boost_LIBRARIES} + ${DL_LIBRARY} + ${TEST_LINK_LIBRARIES} + ) + set(TEST_DEBOUNCE_FILTER_SERVICE ${TEST_DEBOUNCE_FILTER_NAME}_service) + add_executable(${TEST_DEBOUNCE_FILTER_SERVICE} debounce_filter_tests/${TEST_DEBOUNCE_FILTER_SERVICE}.cpp) + target_link_libraries(${TEST_DEBOUNCE_FILTER_SERVICE} + ${VSOMEIP_NAME} + ${Boost_LIBRARIES} + ${DL_LIBRARY} + ${TEST_LINK_LIBRARIES} + ) + + # copy starter scripts into builddir + set(TEST_DEBOUNCE_FILTER_MASTER_STARTER ${TEST_DEBOUNCE_FILTER_NAME}_master_starter.sh) + copy_to_builddir(${NETWORK_TEST_SRC_DIR}/debounce_filter_tests/${TEST_DEBOUNCE_FILTER_MASTER_STARTER} + ${NETWORK_TEST_BIN_DIR}/${TEST_DEBOUNCE_FILTER_MASTER_STARTER} + ${TEST_DEBOUNCE_FILTER_SERVICE} + ) + set(TEST_DEBOUNCE_FILTER_SLAVE_STARTER ${TEST_DEBOUNCE_FILTER_NAME}_slave_starter.sh) + copy_to_builddir(${NETWORK_TEST_SRC_DIR}/debounce_filter_tests/${TEST_DEBOUNCE_FILTER_SLAVE_STARTER} + ${NETWORK_TEST_BIN_DIR}/${TEST_DEBOUNCE_FILTER_SLAVE_STARTER} + ${TEST_DEBOUNCE_FILTER_SERVICE} + ) + + # configure configurations and copy them into builddir + set(TEST_DEBOUNCE_FILTER_MASTER_CONFIG_FILE ${TEST_DEBOUNCE_FILTER_SERVICE}.json) + configure_file( + ${NETWORK_TEST_SRC_DIR}/debounce_filter_tests/conf/${TEST_DEBOUNCE_FILTER_MASTER_CONFIG_FILE}.in + ${NETWORK_TEST_SRC_DIR}/debounce_filter_tests/${TEST_DEBOUNCE_FILTER_MASTER_CONFIG_FILE} + @ONLY) + copy_to_builddir( + ${NETWORK_TEST_SRC_DIR}/debounce_filter_tests/${TEST_DEBOUNCE_FILTER_MASTER_CONFIG_FILE} + ${NETWORK_TEST_BIN_DIR}/${TEST_DEBOUNCE_FILTER_MASTER_CONFIG_FILE} + ${TEST_DEBOUNCE_FILTER_SERVICE} + ) + set(TEST_DEBOUNCE_FILTER_SLAVE_CONFIG_FILE ${TEST_DEBOUNCE_FILTER_CLIENT}.json) + configure_file( + ${NETWORK_TEST_SRC_DIR}/debounce_filter_tests/conf/${TEST_DEBOUNCE_FILTER_SLAVE_CONFIG_FILE}.in + ${NETWORK_TEST_SRC_DIR}/debounce_filter_tests/${TEST_DEBOUNCE_FILTER_SLAVE_CONFIG_FILE} + @ONLY) + copy_to_builddir( + ${NETWORK_TEST_SRC_DIR}/debounce_filter_tests/${TEST_DEBOUNCE_FILTER_SLAVE_CONFIG_FILE} + ${NETWORK_TEST_BIN_DIR}/${TEST_DEBOUNCE_FILTER_SLAVE_CONFIG_FILE} + ${TEST_DEBOUNCE_FILTER_SERVICE} + ) +endif() + +############################################################################## +# debounce frequency tests +############################################################################## +if(NOT ${TESTS_BAT}) + set(TEST_DEBOUNCE_FREQUENCY_NAME debounce_frequency_test) + set(TEST_DEBOUNCE_FREQUENCY_CLIENT ${TEST_DEBOUNCE_FREQUENCY_NAME}_client) + add_executable(${TEST_DEBOUNCE_FREQUENCY_CLIENT} debounce_frequency_tests/${TEST_DEBOUNCE_FREQUENCY_CLIENT}.cpp) + target_link_libraries(${TEST_DEBOUNCE_FREQUENCY_CLIENT} + ${VSOMEIP_NAME} + ${Boost_LIBRARIES} + ${DL_LIBRARY} + ${TEST_LINK_LIBRARIES} + vsomeip_utilities + ) + set(TEST_DEBOUNCE_FREQUENCY_SERVICE ${TEST_DEBOUNCE_FREQUENCY_NAME}_service) + add_executable(${TEST_DEBOUNCE_FREQUENCY_SERVICE} debounce_frequency_tests/${TEST_DEBOUNCE_FREQUENCY_SERVICE}.cpp) + target_link_libraries(${TEST_DEBOUNCE_FREQUENCY_SERVICE} + ${VSOMEIP_NAME} + ${Boost_LIBRARIES} + ${DL_LIBRARY} + ${TEST_LINK_LIBRARIES} + vsomeip_utilities + ) + + # copy starter scripts into builddir + set(TEST_DEBOUNCE_FREQUENCY_MASTER_STARTER ${TEST_DEBOUNCE_FREQUENCY_NAME}_master_starter.sh) + copy_to_builddir(${NETWORK_TEST_SRC_DIR}/debounce_frequency_tests/${TEST_DEBOUNCE_FREQUENCY_MASTER_STARTER} + ${NETWORK_TEST_BIN_DIR}/${TEST_DEBOUNCE_FREQUENCY_MASTER_STARTER} + ${TEST_DEBOUNCE_FREQUENCY_CLIENT} + ) + set(TEST_DEBOUNCE_FREQUENCY_SLAVE_STARTER ${TEST_DEBOUNCE_FREQUENCY_NAME}_slave_starter.sh) + copy_to_builddir(${NETWORK_TEST_SRC_DIR}/debounce_frequency_tests/${TEST_DEBOUNCE_FREQUENCY_SLAVE_STARTER} + ${NETWORK_TEST_BIN_DIR}/${TEST_DEBOUNCE_FREQUENCY_SLAVE_STARTER} + ${TEST_DEBOUNCE_FREQUENCY_SERVICE} + ) + + # configure configurations and copy them into builddir + set(TEST_DEBOUNCE_FREQUENCY_MASTER_CONFIG_FILE ${TEST_DEBOUNCE_FREQUENCY_CLIENT}.json) + configure_file( + ${NETWORK_TEST_SRC_DIR}/debounce_frequency_tests/conf/${TEST_DEBOUNCE_FREQUENCY_MASTER_CONFIG_FILE}.in + ${NETWORK_TEST_SRC_DIR}/debounce_frequency_tests/${TEST_DEBOUNCE_FREQUENCY_MASTER_CONFIG_FILE} + @ONLY) + copy_to_builddir( + ${NETWORK_TEST_SRC_DIR}/debounce_frequency_tests/${TEST_DEBOUNCE_FREQUENCY_MASTER_CONFIG_FILE} + ${NETWORK_TEST_BIN_DIR}/${TEST_DEBOUNCE_FREQUENCY_MASTER_CONFIG_FILE} + ${TEST_DEBOUNCE_FREQUENCY_CLIENT} + ) + set(TEST_DEBOUNCE_FREQUENCY_SLAVE_CONFIG_FILE ${TEST_DEBOUNCE_FREQUENCY_SERVICE}.json) + configure_file( + ${NETWORK_TEST_SRC_DIR}/debounce_frequency_tests/conf/${TEST_DEBOUNCE_FREQUENCY_SLAVE_CONFIG_FILE}.in + ${NETWORK_TEST_SRC_DIR}/debounce_frequency_tests/${TEST_DEBOUNCE_FREQUENCY_SLAVE_CONFIG_FILE} + @ONLY) + copy_to_builddir( + ${NETWORK_TEST_SRC_DIR}/debounce_frequency_tests/${TEST_DEBOUNCE_FREQUENCY_SLAVE_CONFIG_FILE} + ${NETWORK_TEST_BIN_DIR}/${TEST_DEBOUNCE_FREQUENCY_SLAVE_CONFIG_FILE} + ${TEST_DEBOUNCE_FREQUENCY_SERVICE} + ) +endif() + ############################################################################## # subscribe notify tests ############################################################################## @@ -1523,6 +1690,8 @@ if(NOT ${TESTS_BAT}) ${Boost_LIBRARIES} ${DL_LIBRARY} ${TEST_LINK_LIBRARIES} + ${DLT_LIBRARIES} + vsomeip_utilities ) # Copy config files for test into $BUILDDIR/test (local communication via UDS) @@ -1818,6 +1987,8 @@ if(NOT ${TESTS_BAT}) ${Boost_LIBRARIES} ${DL_LIBRARY} ${TEST_LINK_LIBRARIES} + ${DLT_LIBRARIES} + vsomeip_utilities ) # client set(TEST_SUBSCRIBE_NOTIFY_ONE_EVENT_TWO_EVENTGROUPS_CLIENT ${TEST_SUBSCRIBE_NOTIFY_ONE_EVENT_TWO_EVENTGROUPS_NAME}_client) @@ -1828,6 +1999,8 @@ if(NOT ${TESTS_BAT}) ${Boost_LIBRARIES} ${DL_LIBRARY} ${TEST_LINK_LIBRARIES} + ${DLT_LIBRARIES} + vsomeip_utilities ) set(TEST_SUBSCRIBE_NOTIFY_ONE_EVENT_TWO_EVENTGROUPS_MASTER_CONFIG_FILE @@ -2217,6 +2390,8 @@ if(NOT ${TESTS_BAT}) ${Boost_LIBRARIES} ${DL_LIBRARY} ${TEST_LINK_LIBRARIES} + ${DLT_LIBRARIES} + vsomeip_utilities ) # Copy config files for test into $BUILDDIR/test @@ -2326,6 +2501,8 @@ if(NOT ${TESTS_BAT}) ${Boost_LIBRARIES} ${DL_LIBRARY} ${TEST_LINK_LIBRARIES} + ${DLT_LIBRARIES} + vsomeip_utilities ) # Copy config files for test into $BUILDDIR/test @@ -2361,6 +2538,8 @@ if(NOT ${TESTS_BAT}) ${Boost_LIBRARIES} ${DL_LIBRARY} ${TEST_LINK_LIBRARIES} + ${DLT_LIBRARIES} + vsomeip_utilities ) set(TEST_CPU_LOAD_CLIENT_MASTER_CONFIG_FILE ${TEST_CPU_LOAD_NAME}_client_master.json) @@ -2410,6 +2589,8 @@ if(NOT ${TESTS_BAT}) ${Boost_LIBRARIES} ${DL_LIBRARY} ${TEST_LINK_LIBRARIES} + ${DLT_LIBRARIES} + vsomeip_utilities ) set(TEST_INITIAL_EVENT_CLIENT ${TEST_INITIAL_EVENT_NAME}_client) @@ -2419,6 +2600,8 @@ if(NOT ${TESTS_BAT}) ${Boost_LIBRARIES} ${DL_LIBRARY} ${TEST_LINK_LIBRARIES} + ${DLT_LIBRARIES} + vsomeip_utilities ) set(TEST_INITIAL_EVENT_AVAILABILITY_CHECKER ${TEST_INITIAL_EVENT_NAME}_availability_checker) @@ -2428,6 +2611,8 @@ if(NOT ${TESTS_BAT}) ${Boost_LIBRARIES} ${DL_LIBRARY} ${TEST_LINK_LIBRARIES} + ${DLT_LIBRARIES} + vsomeip_utilities ) set(TEST_INITIAL_EVENT_STOP_SERVICE ${TEST_INITIAL_EVENT_NAME}_stop_service) @@ -2437,6 +2622,8 @@ if(NOT ${TESTS_BAT}) ${Boost_LIBRARIES} ${DL_LIBRARY} ${TEST_LINK_LIBRARIES} + ${DLT_LIBRARIES} + vsomeip_utilities ) # Copy config files for test into $BUILDDIR/test @@ -2711,6 +2898,33 @@ if(NOT ${TESTS_BAT}) ${Boost_LIBRARIES} ${DL_LIBRARY} ${TEST_LINK_LIBRARIES} + ${DLT_LIBRARIES} + vsomeip_utilities + ) + + set(TEST_OFFER_MULTIPLE_OFFERING offer_test_multiple_offerings) + add_executable(${TEST_OFFER_MULTIPLE_OFFERING} offer_tests/${TEST_OFFER_MULTIPLE_OFFERING}.cpp) + target_link_libraries(${TEST_OFFER_MULTIPLE_OFFERING} + ${VSOMEIP_NAME} + ${Boost_LIBRARIES} + ${DL_LIBRARY} + ${TEST_LINK_LIBRARIES} + ) + + # copy starter scripts into builddir + set(TEST_OFFER_MULTIPLE_OFFERING_STARTER ${TEST_OFFER_MULTIPLE_OFFERING}_starter.sh) + copy_to_builddir( + ${NETWORK_TEST_SRC_DIR}/offer_tests/${TEST_OFFER_MULTIPLE_OFFERING_STARTER} + ${NETWORK_TEST_BIN_DIR}/${TEST_OFFER_MULTIPLE_OFFERING_STARTER} + ${TEST_OFFER_MULTIPLE_OFFERING} + ) + + # Copy config file for local test into $BUILDDIR/test + set(TEST_OFFER_MULTIPLE_OFFERING_CONFIG ${TEST_OFFER_MULTIPLE_OFFERING}.json) + copy_to_builddir( + ${NETWORK_TEST_SRC_DIR}/offer_tests/${TEST_OFFER_MULTIPLE_OFFERING_CONFIG} + ${NETWORK_TEST_BIN_DIR}/${TEST_OFFER_MULTIPLE_OFFERING_CONFIG} + ${TEST_OFFER_MULTIPLE_OFFERING} ) set(TEST_OFFER_CLIENT ${TEST_OFFER_NAME}_client) @@ -2720,6 +2934,8 @@ if(NOT ${TESTS_BAT}) ${Boost_LIBRARIES} ${DL_LIBRARY} ${TEST_LINK_LIBRARIES} + ${DLT_LIBRARIES} + vsomeip_utilities ) set(TEST_OFFER_SERVICE_EXTERNAL ${TEST_OFFER_NAME}_service_external) @@ -2729,6 +2945,8 @@ if(NOT ${TESTS_BAT}) ${Boost_LIBRARIES} ${DL_LIBRARY} ${TEST_LINK_LIBRARIES} + ${DLT_LIBRARIES} + vsomeip_utilities ) set(TEST_OFFER_EXTERNAL_SD_MESSAGE_SENDER ${TEST_OFFER_NAME}_external_sd_msg_sender) @@ -2737,6 +2955,8 @@ if(NOT ${TESTS_BAT}) ${Boost_LIBRARIES} ${DL_LIBRARY} ${TEST_LINK_LIBRARIES} + ${DLT_LIBRARIES} + vsomeip_utilities ) # client and service for offer test big sd msg @@ -2748,15 +2968,19 @@ if(NOT ${TESTS_BAT}) ${Boost_LIBRARIES} ${DL_LIBRARY} ${TEST_LINK_LIBRARIES} + ${DLT_LIBRARIES} + vsomeip_utilities ) set(TEST_OFFER_BIG_CLIENT ${TEST_OFFER_BIG_NAME}_client) add_executable(${TEST_OFFER_BIG_CLIENT} offer_tests/${TEST_OFFER_BIG_NAME}_client.cpp) target_link_libraries(${TEST_OFFER_BIG_CLIENT} + ${DLT_LIBRARIES} ${VSOMEIP_NAME} ${Boost_LIBRARIES} ${DL_LIBRARY} ${TEST_LINK_LIBRARIES} + vsomeip_utilities ) # copy starter scripts into builddir @@ -2874,6 +3098,8 @@ if(NOT ${TESTS_BAT}) ${Boost_LIBRARIES} ${DL_LIBRARY} ${TEST_LINK_LIBRARIES} + ${DLT_LIBRARIES} + vsomeip_utilities ) set(TEST_OFFERED_SERVICES_INFO_CLIENT ${TEST_OFFERED_SERVICES_INFO_NAME}_client) @@ -2883,6 +3109,8 @@ if(NOT ${TESTS_BAT}) ${Boost_LIBRARIES} ${DL_LIBRARY} ${TEST_LINK_LIBRARIES} + ${DLT_LIBRARIES} + vsomeip_utilities ) # copy starter scripts into builddir @@ -2913,6 +3141,8 @@ if(NOT ${TESTS_BAT}) ${Boost_LIBRARIES} ${DL_LIBRARY} ${TEST_LINK_LIBRARIES} + ${DLT_LIBRARIES} + vsomeip_utilities ) file(GLOB sd_sources @@ -2935,6 +3165,8 @@ if(NOT ${TESTS_BAT}) ${TEST_LINK_LIBRARIES} ${VSOMEIP_NAME} ${VSOMEIP_NAME}-sd + ${DLT_LIBRARIES} + vsomeip_utilities ) # copy starter scripts into builddir @@ -2973,6 +3205,8 @@ if(NOT ${TESTS_BAT}) ${Boost_LIBRARIES} ${DL_LIBRARY} ${TEST_LINK_LIBRARIES} + ${DLT_LIBRARIES} + vsomeip_utilities ) file(GLOB sd_sources @@ -2995,6 +3229,8 @@ if(NOT ${TESTS_BAT}) ${TEST_LINK_LIBRARIES} ${VSOMEIP_NAME} ${VSOMEIP_NAME}-sd + ${DLT_LIBRARIES} + vsomeip_utilities ) # copy starter scripts into builddir @@ -3036,6 +3272,8 @@ if(NOT ${TESTS_BAT}) ${Boost_LIBRARIES} ${DL_LIBRARY} ${TEST_LINK_LIBRARIES} + ${DLT_LIBRARIES} + vsomeip_utilities ) add_executable(${TEST_E2E_CLIENT} @@ -3046,6 +3284,8 @@ if(NOT ${TESTS_BAT}) ${Boost_LIBRARIES} ${DL_LIBRARY} ${TEST_LINK_LIBRARIES} + ${DLT_LIBRARIES} + vsomeip_utilities ) # Copy service config file for external allow tests into $BUILDDIR/test @@ -3104,6 +3344,8 @@ if(NOT ${TESTS_BAT} AND ${TEST_E2E_PROFILE_04}) ${Boost_LIBRARIES} ${DL_LIBRARY} ${TEST_LINK_LIBRARIES} + ${DLT_LIBRARIES} + vsomeip_utilities ) add_executable(${TEST_E2E_PROFILE_04_CLIENT} @@ -3114,6 +3356,8 @@ if(NOT ${TESTS_BAT} AND ${TEST_E2E_PROFILE_04}) ${Boost_LIBRARIES} ${DL_LIBRARY} ${TEST_LINK_LIBRARIES} + ${DLT_LIBRARIES} + vsomeip_utilities ) # Copy service config file for external allow tests into $BUILDDIR/test @@ -3172,6 +3416,8 @@ if(NOT ${TESTS_BAT}) ${Boost_LIBRARIES} ${DL_LIBRARY} ${TEST_LINK_LIBRARIES} + ${DLT_LIBRARIES} + vsomeip_utilities ) add_executable(${TEST_EVENT_CLIENT} @@ -3182,6 +3428,8 @@ if(NOT ${TESTS_BAT}) ${Boost_LIBRARIES} ${DL_LIBRARY} ${TEST_LINK_LIBRARIES} + ${DLT_LIBRARIES} + vsomeip_utilities ) # Copy service config file for external allow tests into $BUILDDIR/test set(TEST_EVENT_SLAVE_TCP_CONFIG_FILE ${TEST_EVENT_NAME}_slave_tcp.json) @@ -3250,6 +3498,8 @@ if(NOT ${TESTS_BAT} AND NOT ${CMAKE_SYSTEM_NAME} MATCHES "QNX") ${Boost_LIBRARIES} ${DL_LIBRARY} ${TEST_LINK_LIBRARIES} + ${DLT_LIBRARIES} + vsomeip_utilities ) set(TEST_NPDU_DAEMON_SERVICE ${TEST_NPDU_DAEMON}_service_side) @@ -3260,6 +3510,8 @@ if(NOT ${TESTS_BAT} AND NOT ${CMAKE_SYSTEM_NAME} MATCHES "QNX") ${Boost_LIBRARIES} ${DL_LIBRARY} ${TEST_LINK_LIBRARIES} + ${DLT_LIBRARIES} + vsomeip_utilities ) ############################################################################## @@ -3275,6 +3527,8 @@ if(NOT ${TESTS_BAT} AND NOT ${CMAKE_SYSTEM_NAME} MATCHES "QNX") ${Boost_LIBRARIES} ${DL_LIBRARY} ${TEST_LINK_LIBRARIES} + ${DLT_LIBRARIES} + vsomeip_utilities ) set(TEST_NPDU_SERVICE_TWO npdu_test_service_2) @@ -3286,6 +3540,8 @@ if(NOT ${TESTS_BAT} AND NOT ${CMAKE_SYSTEM_NAME} MATCHES "QNX") ${Boost_LIBRARIES} ${DL_LIBRARY} ${TEST_LINK_LIBRARIES} + ${DLT_LIBRARIES} + vsomeip_utilities ) set(TEST_NPDU_SERVICE_THREE npdu_test_service_3) @@ -3297,6 +3553,8 @@ if(NOT ${TESTS_BAT} AND NOT ${CMAKE_SYSTEM_NAME} MATCHES "QNX") ${Boost_LIBRARIES} ${DL_LIBRARY} ${TEST_LINK_LIBRARIES} + ${DLT_LIBRARIES} + vsomeip_utilities ) set(TEST_NPDU_SERVICE_FOUR npdu_test_service_4) @@ -3308,6 +3566,8 @@ if(NOT ${TESTS_BAT} AND NOT ${CMAKE_SYSTEM_NAME} MATCHES "QNX") ${Boost_LIBRARIES} ${DL_LIBRARY} ${TEST_LINK_LIBRARIES} + ${DLT_LIBRARIES} + vsomeip_utilities ) # Copy config file for service w/o npdu into $BUILDDIR/test @@ -3360,6 +3620,8 @@ if(NOT ${TESTS_BAT} AND NOT ${CMAKE_SYSTEM_NAME} MATCHES "QNX") ${Boost_LIBRARIES} ${DL_LIBRARY} ${TEST_LINK_LIBRARIES} + ${DLT_LIBRARIES} + vsomeip_utilities ) set(TEST_NPDU_CLIENT_TWO npdu_test_client_2) @@ -3370,6 +3632,8 @@ if(NOT ${TESTS_BAT} AND NOT ${CMAKE_SYSTEM_NAME} MATCHES "QNX") ${Boost_LIBRARIES} ${DL_LIBRARY} ${TEST_LINK_LIBRARIES} + ${DLT_LIBRARIES} + vsomeip_utilities ) set(TEST_NPDU_CLIENT_THREE npdu_test_client_3) @@ -3380,6 +3644,8 @@ if(NOT ${TESTS_BAT} AND NOT ${CMAKE_SYSTEM_NAME} MATCHES "QNX") ${Boost_LIBRARIES} ${DL_LIBRARY} ${TEST_LINK_LIBRARIES} + ${DLT_LIBRARIES} + vsomeip_utilities ) set(TEST_NPDU_CLIENT_FOUR npdu_test_client_4) @@ -3390,6 +3656,8 @@ if(NOT ${TESTS_BAT} AND NOT ${CMAKE_SYSTEM_NAME} MATCHES "QNX") ${Boost_LIBRARIES} ${DL_LIBRARY} ${TEST_LINK_LIBRARIES} + ${DLT_LIBRARIES} + vsomeip_utilities ) # Copy config files for client w/o npdu into $BUILDDIR/test @@ -3453,6 +3721,8 @@ if(NOT ${TESTS_BAT}) ${Boost_LIBRARIES} ${DL_LIBRARY} ${TEST_LINK_LIBRARIES} + ${DLT_LIBRARIES} + vsomeip_utilities ) file(GLOB sd_sources @@ -3476,8 +3746,10 @@ if(NOT ${TESTS_BAT}) ${Boost_LIBRARIES} ${DL_LIBRARY} ${TEST_LINK_LIBRARIES} + ${DLT_LIBRARIES} ${VSOMEIP_NAME} ${VSOMEIP_NAME}-sd + vsomeip_utilities ) # Copy service config file for external allow tests into $BUILDDIR/test @@ -3522,6 +3794,8 @@ if(NOT ${TESTS_BAT} AND ${TEST_SECOND_ADDRESS}) ${Boost_LIBRARIES} ${DL_LIBRARY} ${TEST_LINK_LIBRARIES} + ${DLT_LIBRARIES} + vsomeip_utilities ) add_executable(${TEST_SECOND_ADDRESS_CLIENT} @@ -3532,6 +3806,8 @@ if(NOT ${TESTS_BAT} AND ${TEST_SECOND_ADDRESS}) ${Boost_LIBRARIES} ${DL_LIBRARY} ${TEST_LINK_LIBRARIES} + ${DLT_LIBRARIES} + vsomeip_utilities ) set(TEST_SECOND_ADDRESS_MASTER_SERVICE_UDP_CONFIG_FILE ${TEST_SECOND_ADDRESS_NAME}_master_service_udp.json) @@ -3614,6 +3890,8 @@ if(NOT ${TESTS_BAT}) ${Boost_LIBRARIES} ${DL_LIBRARY} ${TEST_LINK_LIBRARIES} + ${DLT_LIBRARIES} + vsomeip_utilities ) add_executable(${TEST_SUSPEND_RESUME_CLIENT} @@ -3624,6 +3902,8 @@ if(NOT ${TESTS_BAT}) ${Boost_LIBRARIES} ${DL_LIBRARY} ${TEST_LINK_LIBRARIES} + ${DLT_LIBRARIES} + vsomeip_utilities ) set(TEST_SUSPEND_RESUME_SERVICE_CONFIG_FILE ${TEST_SUSPEND_RESUME_SERVICE}.json) @@ -3689,6 +3969,10 @@ if(NOT ${TESTS_BAT}) add_dependencies(${TEST_CLIENT_ID_UTILITY} gtest) add_dependencies(${TEST_DEBOUNCE_CLIENT} gtest) add_dependencies(${TEST_DEBOUNCE_SERVICE} gtest) + add_dependencies(${TEST_DEBOUNCE_FILTER_CLIENT} gtest) + add_dependencies(${TEST_DEBOUNCE_FILTER_SERVICE} gtest) + add_dependencies(${TEST_DEBOUNCE_FREQUENCY_CLIENT} gtest) + add_dependencies(${TEST_DEBOUNCE_FREQUENCY_SERVICE} gtest) add_dependencies(${TEST_SUBSCRIBE_NOTIFY_SERVICE} gtest) add_dependencies(${TEST_SUBSCRIBE_NOTIFY_ONE_EVENT_TWO_EVENTGROUPS_SERVICE} gtest) add_dependencies(${TEST_SUBSCRIBE_NOTIFY_ONE_EVENT_TWO_EVENTGROUPS_CLIENT} gtest) @@ -3771,6 +4055,10 @@ if(NOT ${TESTS_BAT}) add_dependencies(build_network_tests ${TEST_CLIENT_ID_UTILITY}) add_dependencies(build_network_tests ${TEST_DEBOUNCE_CLIENT}) add_dependencies(build_network_tests ${TEST_DEBOUNCE_SERVICE}) + add_dependencies(build_network_tests ${TEST_DEBOUNCE_FILTER_CLIENT}) + add_dependencies(build_network_tests ${TEST_DEBOUNCE_FILTER_SERVICE}) + add_dependencies(build_network_tests ${TEST_DEBOUNCE_FREQUENCY_CLIENT}) + add_dependencies(build_network_tests ${TEST_DEBOUNCE_FREQUENCY_SERVICE}) add_dependencies(build_network_tests ${TEST_SUBSCRIBE_NOTIFY_SERVICE}) add_dependencies(build_network_tests ${TEST_SUBSCRIBE_NOTIFY_ONE_EVENT_TWO_EVENTGROUPS_SERVICE}) add_dependencies(build_network_tests ${TEST_SUBSCRIBE_NOTIFY_ONE_EVENT_TWO_EVENTGROUPS_CLIENT}) @@ -3787,6 +4075,7 @@ if(NOT ${TESTS_BAT}) add_dependencies(build_network_tests ${TEST_OFFER_EXTERNAL_SD_MESSAGE_SENDER}) add_dependencies(build_network_tests ${TEST_OFFER_BIG_SERVICE}) add_dependencies(build_network_tests ${TEST_OFFER_BIG_CLIENT}) + add_dependencies(build_network_tests ${TEST_OFFER_MULTIPLE_OFFERING}) add_dependencies(build_network_tests ${TEST_RESTART_ROUTING_SERVICE}) add_dependencies(build_network_tests ${TEST_RESTART_ROUTING_CLIENT}) if (${TEST_SECURITY}) @@ -3888,7 +4177,7 @@ if(NOT ${TESTS_BAT}) add_test(NAME ${TEST_LOCAL_PAYLOAD_HUGE_NAME} COMMAND ${NETWORK_TEST_BIN_DIR}/${TEST_LOCAL_PAYLOAD_HUGE_STARTER} ) - set_tests_properties(${TEST_LOCAL_PAYLOAD_HUGE_NAME} PROPERTIES TIMEOUT 960) + set_tests_properties(${TEST_LOCAL_PAYLOAD_HUGE_NAME} PROPERTIES TIMEOUT 1800) add_test(NAME ${TEST_EXTERNAL_LOCAL_PAYLOAD_CLIENT_LOCAL_NAME} COMMAND ${NETWORK_TEST_BIN_DIR}/${TEST_EXTERNAL_LOCAL_PAYLOAD_CLIENT_LOCAL_STARTER} ) @@ -4030,6 +4319,16 @@ if(NOT ${TESTS_BAT}) COMMAND ${NETWORK_TEST_BIN_DIR}/${TEST_DEBOUNCE_MASTER_STARTER}) set_tests_properties(${TEST_DEBOUNCE_UTILITY} PROPERTIES TIMEOUT 30) + # debounce filter tests + add_test(NAME ${TEST_DEBOUNCE_FILTER_NAME} + COMMAND ${NETWORK_TEST_BIN_DIR}/${TEST_DEBOUNCE_FILTER_MASTER_STARTER}) + set_tests_properties(${TEST_DEBOUNCE_FILTER_UTILITY} PROPERTIES TIMEOUT 30) + + # debounce frequency tests + add_test(NAME ${TEST_DEBOUNCE_FREQUENCY_NAME} + COMMAND ${NETWORK_TEST_BIN_DIR}/${TEST_DEBOUNCE_FREQUENCY_MASTER_STARTER}) + set_tests_properties(${TEST_DEBOUNCE_FREQUENCY_NAME} PROPERTIES TIMEOUT 30) + # subscribe notify tests (local communication via UDS) add_test(NAME ${TEST_SUBSCRIBE_NOTIFY_NAME}_diff_client_ids_diff_ports_udp_local_tcp COMMAND ${NETWORK_TEST_BIN_DIR}/${TEST_SUBSCRIBE_NOTIFY_MASTER_STARTER} UDP ${TEST_SUBSCRIBE_NOTIFY_DIFF_IDS_DIFF_PORTS_MASTER_UDP_LOCAL_TCP_CONFIG_FILE}) @@ -4259,10 +4558,16 @@ if(NOT ${TESTS_BAT}) add_test(NAME ${TEST_OFFER_NAME}_external COMMAND ${NETWORK_TEST_BIN_DIR}/${TEST_OFFER_EXTERNAL_MASTER_STARTER}) set_tests_properties(${TEST_OFFER_NAME}_local PROPERTIES TIMEOUT 360) + add_test(NAME ${TEST_OFFER_BIG_NAME} COMMAND ${NETWORK_TEST_BIN_DIR}/${TEST_OFFER_BIG_MASTER_STARTER}) set_tests_properties(${TEST_OFFER_BIG_NAME} PROPERTIES TIMEOUT 360) + # Multiple Offer tests + add_test(NAME ${TEST_OFFER_MULTIPLE_OFFERING} + COMMAND ${NETWORK_TEST_BIN_DIR}/${TEST_OFFER_MULTIPLE_OFFERING_STARTER}) + set_tests_properties(${TEST_OFFER_MULTIPLE_OFFERING} PROPERTIES TIMEOUT 1800) + # offered services info tets add_test(NAME ${TEST_OFFERED_SERVICES_INFO_NAME}_local COMMAND ${NETWORK_TEST_BIN_DIR}/${TEST_OFFERED_SERVICES_INFO_LOCAL_STARTER}) @@ -4308,7 +4613,7 @@ if(NOT ${TESTS_BAT}) add_test(NAME ${TEST_PENDING_SUBSCRIPTION_NAME}_subscribe_resubscribe_mixed COMMAND ${NETWORK_TEST_BIN_DIR}/${TEST_PENDING_SUBSCRIPTION_MASTER_STARTER} SUBSCRIBE_RESUBSCRIBE_MIXED) - set_tests_properties(${TEST_PENDING_SUBSCRIPTION_NAME}_subscribe_resubscribe_mixed PROPERTIES TIMEOUT 180) + set_tests_properties(${TEST_PENDING_SUBSCRIPTION_NAME}_subscribe_resubscribe_mixed PROPERTIES TIMEOUT 300) add_test(NAME ${TEST_PENDING_SUBSCRIPTION_NAME}_subscribe_stopsubscribe_subscribe COMMAND ${NETWORK_TEST_BIN_DIR}/${TEST_PENDING_SUBSCRIPTION_MASTER_STARTER} SUBSCRIBE_STOPSUBSCRIBE_SUBSCRIBE) diff --git a/test/network_tests/application_tests/application_test.cpp b/test/network_tests/application_tests/application_test.cpp index e55d7ec35..a4a1923d4 100644 --- a/test/network_tests/application_tests/application_test.cpp +++ b/test/network_tests/application_tests/application_test.cpp @@ -1,4 +1,4 @@ -// Copyright (C) 2015-2017 Bayerische Motoren Werke Aktiengesellschaft (BMW AG) +// Copyright (C) 2015-2023 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/. @@ -473,7 +473,3 @@ int main(int argc, char** argv) return RUN_ALL_TESTS(); } #endif - - - - diff --git a/test/network_tests/application_tests/application_test_availability.cpp b/test/network_tests/application_tests/application_test_availability.cpp index 48818961f..9bdf1cdb0 100644 --- a/test/network_tests/application_tests/application_test_availability.cpp +++ b/test/network_tests/application_tests/application_test_availability.cpp @@ -1,4 +1,4 @@ -// Copyright (C) 2014-2017 Bayerische Motoren Werke Aktiengesellschaft (BMW AG) +// Copyright (C) 2014-2023 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/. diff --git a/test/network_tests/application_tests/application_test_client.cpp b/test/network_tests/application_tests/application_test_client.cpp index 3a9328b72..836bdbfca 100644 --- a/test/network_tests/application_tests/application_test_client.cpp +++ b/test/network_tests/application_tests/application_test_client.cpp @@ -1,4 +1,4 @@ -// Copyright (C) 2014-2017 Bayerische Motoren Werke Aktiengesellschaft (BMW AG) +// Copyright (C) 2014-2023 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/. @@ -20,10 +20,13 @@ #include #include "application_test_globals.hpp" +#include "../someip_test_globals.hpp" +#include -class application_test_client { +class application_test_client : public vsomeip_utilities::base_logger { public: application_test_client(struct application_test::service_info _service_info) : + vsomeip_utilities::base_logger("APTC", "APPLICATION TEST CLIENT"), service_info_(_service_info), app_(vsomeip::runtime::get()->create_application("client")), wait_until_registered_(true), diff --git a/test/network_tests/application_tests/application_test_client_availability.cpp b/test/network_tests/application_tests/application_test_client_availability.cpp index 32eb4484d..96aa40521 100644 --- a/test/network_tests/application_tests/application_test_client_availability.cpp +++ b/test/network_tests/application_tests/application_test_client_availability.cpp @@ -1,4 +1,4 @@ -// Copyright (C) 2014-2017 Bayerische Motoren Werke Aktiengesellschaft (BMW AG) +// Copyright (C) 2014-2023 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/. @@ -19,11 +19,14 @@ #include #include +#include "../someip_test_globals.hpp" +#include #include "application_test_globals.hpp" -class application_test_client_availability { +class application_test_client_availability : public vsomeip_utilities::base_logger { public: application_test_client_availability(struct application_test::service_info _service_info) : + vsomeip_utilities::base_logger("ATCA", "Application Test Client Availability"), service_info_(_service_info), app_(vsomeip::runtime::get()->create_application("client")), wait_until_registered_(true), diff --git a/test/network_tests/application_tests/application_test_daemon.cpp b/test/network_tests/application_tests/application_test_daemon.cpp index 2f0b24409..4f1cb9ff6 100644 --- a/test/network_tests/application_tests/application_test_daemon.cpp +++ b/test/network_tests/application_tests/application_test_daemon.cpp @@ -1,4 +1,4 @@ -// Copyright (C) 2014-2017 Bayerische Motoren Werke Aktiengesellschaft (BMW AG) +// Copyright (C) 2014-2023 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/. @@ -9,9 +9,13 @@ #include #include -class application_test_daemon { +#include "../someip_test_globals.hpp" +#include + +class application_test_daemon : public vsomeip_utilities::base_logger { public: application_test_daemon() : + vsomeip_utilities::base_logger("APTD", "APPLICATION TEST DAEMON"), app_(vsomeip::runtime::get()->create_application("daemon")) { if (!app_->init()) { ADD_FAILURE() << "Couldn't initialize application"; diff --git a/test/network_tests/application_tests/application_test_service.cpp b/test/network_tests/application_tests/application_test_service.cpp index 77d40cdf4..6e4dbd148 100644 --- a/test/network_tests/application_tests/application_test_service.cpp +++ b/test/network_tests/application_tests/application_test_service.cpp @@ -1,4 +1,4 @@ -// Copyright (C) 2014-2017 Bayerische Motoren Werke Aktiengesellschaft (BMW AG) +// Copyright (C) 2014-2023 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/. @@ -20,10 +20,13 @@ #include #include "application_test_globals.hpp" +#include "../someip_test_globals.hpp" +#include -class application_test_service { +class application_test_service : public vsomeip_utilities::base_logger { public: application_test_service(struct application_test::service_info _service_info) : + vsomeip_utilities::base_logger("APTS", "APPLICATION TEST SERVICE"), service_info_(_service_info), // service with number 1 uses "routingmanagerd" as application name // this way the same json file can be reused for all local tests diff --git a/test/network_tests/application_tests/application_test_single_process.cpp b/test/network_tests/application_tests/application_test_single_process.cpp index f8fbe8e8e..fcd701cb2 100644 --- a/test/network_tests/application_tests/application_test_single_process.cpp +++ b/test/network_tests/application_tests/application_test_single_process.cpp @@ -1,4 +1,4 @@ -// Copyright (C) 2014-2017 Bayerische Motoren Werke Aktiengesellschaft (BMW AG) +// Copyright (C) 2014-2023 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/. diff --git a/test/network_tests/application_tests/application_test_single_process.json b/test/network_tests/application_tests/application_test_single_process.json index b604d9a7b..35eda51b2 100644 --- a/test/network_tests/application_tests/application_test_single_process.json +++ b/test/network_tests/application_tests/application_test_single_process.json @@ -9,6 +9,6 @@ "enable":"false", "path":"/tmp/someip.log" }, - "dlt":"false" + "dlt":"true" } } diff --git a/test/network_tests/application_tests/conf/application_test.json.in b/test/network_tests/application_tests/conf/application_test.json.in index ed5a7fcda..910eeeb1b 100644 --- a/test/network_tests/application_tests/conf/application_test.json.in +++ b/test/network_tests/application_tests/conf/application_test.json.in @@ -9,7 +9,7 @@ "enable":"false", "path":"/tmp/someip.log" }, - "dlt":"false" + "dlt":"true" }, "applications": [ diff --git a/test/network_tests/application_tests/conf/application_test_daemon.json.in b/test/network_tests/application_tests/conf/application_test_daemon.json.in index f7fd3dcab..5fcf8b9e2 100644 --- a/test/network_tests/application_tests/conf/application_test_daemon.json.in +++ b/test/network_tests/application_tests/conf/application_test_daemon.json.in @@ -9,7 +9,7 @@ "enable":"false", "path":"/tmp/someip.log" }, - "dlt":"false" + "dlt":"true" }, "applications": [ diff --git a/test/network_tests/application_tests/conf/application_test_no_dispatch_threads.json.in b/test/network_tests/application_tests/conf/application_test_no_dispatch_threads.json.in index 20d0ebd17..6c7769661 100644 --- a/test/network_tests/application_tests/conf/application_test_no_dispatch_threads.json.in +++ b/test/network_tests/application_tests/conf/application_test_no_dispatch_threads.json.in @@ -9,7 +9,7 @@ "enable":"false", "path":"/tmp/someip.log" }, - "dlt":"false" + "dlt":"true" }, "applications": [ diff --git a/test/network_tests/application_tests/conf/application_test_no_dispatch_threads_daemon.json.in b/test/network_tests/application_tests/conf/application_test_no_dispatch_threads_daemon.json.in index 8c7622af1..98fd965e3 100644 --- a/test/network_tests/application_tests/conf/application_test_no_dispatch_threads_daemon.json.in +++ b/test/network_tests/application_tests/conf/application_test_no_dispatch_threads_daemon.json.in @@ -9,7 +9,7 @@ "enable":"false", "path":"/tmp/someip.log" }, - "dlt":"false" + "dlt":"true" }, "applications": [ diff --git a/test/network_tests/big_payload_tests/big_payload_test_client.cpp b/test/network_tests/big_payload_tests/big_payload_test_client.cpp index db204e09d..39801beaa 100644 --- a/test/network_tests/big_payload_tests/big_payload_test_client.cpp +++ b/test/network_tests/big_payload_tests/big_payload_test_client.cpp @@ -1,10 +1,11 @@ -// Copyright (C) 2015-2017 Bayerische Motoren Werke Aktiengesellschaft (BMW AG) +// Copyright (C) 2015-2023 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/. #include "big_payload_test_client.hpp" #include "big_payload_test_globals.hpp" +#include big_payload_test_client::big_payload_test_client( bool _use_tcp, big_payload_test::test_mode _test_mode) : diff --git a/test/network_tests/big_payload_tests/big_payload_test_local.json b/test/network_tests/big_payload_tests/big_payload_test_local.json index 983dea6a2..d8f8b7ad8 100644 --- a/test/network_tests/big_payload_tests/big_payload_test_local.json +++ b/test/network_tests/big_payload_tests/big_payload_test_local.json @@ -9,7 +9,7 @@ "enable":"false", "path":"/tmp/vsomeip.log" }, - "dlt":"false" + "dlt":"true" }, "applications": [ @@ -53,4 +53,3 @@ "protocol":"udp" } } - diff --git a/test/network_tests/big_payload_tests/big_payload_test_local_limited.json b/test/network_tests/big_payload_tests/big_payload_test_local_limited.json index 4e8c6663b..d497aa41a 100644 --- a/test/network_tests/big_payload_tests/big_payload_test_local_limited.json +++ b/test/network_tests/big_payload_tests/big_payload_test_local_limited.json @@ -9,7 +9,7 @@ "enable":"false", "path":"/tmp/vsomeip.log" }, - "dlt":"false" + "dlt":"true" }, "applications": [ @@ -41,4 +41,3 @@ "protocol":"udp" } } - diff --git a/test/network_tests/big_payload_tests/big_payload_test_local_queue_limited.json b/test/network_tests/big_payload_tests/big_payload_test_local_queue_limited.json index 584e77e76..5e1ea9be9 100644 --- a/test/network_tests/big_payload_tests/big_payload_test_local_queue_limited.json +++ b/test/network_tests/big_payload_tests/big_payload_test_local_queue_limited.json @@ -9,7 +9,7 @@ "enable":"false", "path":"/tmp/vsomeip.log" }, - "dlt":"false" + "dlt":"true" }, "applications": [ @@ -41,4 +41,3 @@ "protocol":"udp" } } - diff --git a/test/network_tests/big_payload_tests/big_payload_test_local_random.json b/test/network_tests/big_payload_tests/big_payload_test_local_random.json index 0cf2081eb..0a01ca103 100644 --- a/test/network_tests/big_payload_tests/big_payload_test_local_random.json +++ b/test/network_tests/big_payload_tests/big_payload_test_local_random.json @@ -9,7 +9,7 @@ "enable":"false", "path":"/tmp/vsomeip.log" }, - "dlt":"false" + "dlt":"true" }, "applications": [ @@ -41,4 +41,3 @@ "protocol":"udp" } } - diff --git a/test/network_tests/big_payload_tests/big_payload_test_service.cpp b/test/network_tests/big_payload_tests/big_payload_test_service.cpp index 80983083b..a6bd4d7eb 100644 --- a/test/network_tests/big_payload_tests/big_payload_test_service.cpp +++ b/test/network_tests/big_payload_tests/big_payload_test_service.cpp @@ -1,4 +1,4 @@ -// Copyright (C) 2015-2017 Bayerische Motoren Werke Aktiengesellschaft (BMW AG) +// Copyright (C) 2015-2023 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/. diff --git a/test/network_tests/big_payload_tests/conf/big_payload_test_local_tcp_client.json.in b/test/network_tests/big_payload_tests/conf/big_payload_test_local_tcp_client.json.in index 41c88f59e..6821e5a55 100644 --- a/test/network_tests/big_payload_tests/conf/big_payload_test_local_tcp_client.json.in +++ b/test/network_tests/big_payload_tests/conf/big_payload_test_local_tcp_client.json.in @@ -9,7 +9,7 @@ "enable":"false", "path":"/tmp/vsomeip.log" }, - "dlt":"false" + "dlt":"true" }, "applications": [ @@ -61,4 +61,3 @@ "protocol":"udp" } } - diff --git a/test/network_tests/big_payload_tests/conf/big_payload_test_local_tcp_client_limited.json.in b/test/network_tests/big_payload_tests/conf/big_payload_test_local_tcp_client_limited.json.in index cd52a3ced..cd8dd746f 100644 --- a/test/network_tests/big_payload_tests/conf/big_payload_test_local_tcp_client_limited.json.in +++ b/test/network_tests/big_payload_tests/conf/big_payload_test_local_tcp_client_limited.json.in @@ -9,7 +9,7 @@ "enable":"false", "path":"/tmp/vsomeip.log" }, - "dlt":"false" + "dlt":"true" }, "applications": [ @@ -49,4 +49,3 @@ "protocol":"udp" } } - diff --git a/test/network_tests/big_payload_tests/conf/big_payload_test_local_tcp_client_queue_limited.json.in b/test/network_tests/big_payload_tests/conf/big_payload_test_local_tcp_client_queue_limited.json.in index b233f743c..c5f4910f5 100644 --- a/test/network_tests/big_payload_tests/conf/big_payload_test_local_tcp_client_queue_limited.json.in +++ b/test/network_tests/big_payload_tests/conf/big_payload_test_local_tcp_client_queue_limited.json.in @@ -9,7 +9,7 @@ "enable":"false", "path":"/tmp/vsomeip.log" }, - "dlt":"false" + "dlt":"true" }, "applications": [ @@ -49,4 +49,3 @@ "protocol":"udp" } } - diff --git a/test/network_tests/big_payload_tests/conf/big_payload_test_local_tcp_client_random.json.in b/test/network_tests/big_payload_tests/conf/big_payload_test_local_tcp_client_random.json.in index 521f46e18..b0f028898 100644 --- a/test/network_tests/big_payload_tests/conf/big_payload_test_local_tcp_client_random.json.in +++ b/test/network_tests/big_payload_tests/conf/big_payload_test_local_tcp_client_random.json.in @@ -9,7 +9,7 @@ "enable":"false", "path":"/tmp/vsomeip.log" }, - "dlt":"false" + "dlt":"true" }, "applications": [ @@ -49,4 +49,3 @@ "protocol":"udp" } } - diff --git a/test/network_tests/big_payload_tests/conf/big_payload_test_local_tcp_service.json.in b/test/network_tests/big_payload_tests/conf/big_payload_test_local_tcp_service.json.in index 6f64035c0..296c91034 100644 --- a/test/network_tests/big_payload_tests/conf/big_payload_test_local_tcp_service.json.in +++ b/test/network_tests/big_payload_tests/conf/big_payload_test_local_tcp_service.json.in @@ -9,7 +9,7 @@ "enable":"false", "path":"/tmp/vsomeip.log" }, - "dlt":"false" + "dlt":"true" }, "applications": [ @@ -65,4 +65,3 @@ "protocol":"udp" } } - diff --git a/test/network_tests/big_payload_tests/conf/big_payload_test_local_tcp_service_limited.json.in b/test/network_tests/big_payload_tests/conf/big_payload_test_local_tcp_service_limited.json.in index 2373eaae0..042e26a82 100644 --- a/test/network_tests/big_payload_tests/conf/big_payload_test_local_tcp_service_limited.json.in +++ b/test/network_tests/big_payload_tests/conf/big_payload_test_local_tcp_service_limited.json.in @@ -9,7 +9,7 @@ "enable":"false", "path":"/tmp/vsomeip.log" }, - "dlt":"false" + "dlt":"true" }, "applications": [ @@ -53,4 +53,3 @@ "protocol":"udp" } } - diff --git a/test/network_tests/big_payload_tests/conf/big_payload_test_local_tcp_service_queue_limited.json.in b/test/network_tests/big_payload_tests/conf/big_payload_test_local_tcp_service_queue_limited.json.in index eac3dcecf..402f416d9 100644 --- a/test/network_tests/big_payload_tests/conf/big_payload_test_local_tcp_service_queue_limited.json.in +++ b/test/network_tests/big_payload_tests/conf/big_payload_test_local_tcp_service_queue_limited.json.in @@ -9,7 +9,7 @@ "enable":"false", "path":"/tmp/vsomeip.log" }, - "dlt":"false" + "dlt":"true" }, "applications": [ @@ -53,4 +53,3 @@ "protocol":"udp" } } - diff --git a/test/network_tests/big_payload_tests/conf/big_payload_test_local_tcp_service_random.json.in b/test/network_tests/big_payload_tests/conf/big_payload_test_local_tcp_service_random.json.in index c66e09f84..203e6426e 100644 --- a/test/network_tests/big_payload_tests/conf/big_payload_test_local_tcp_service_random.json.in +++ b/test/network_tests/big_payload_tests/conf/big_payload_test_local_tcp_service_random.json.in @@ -9,7 +9,7 @@ "enable":"false", "path":"/tmp/vsomeip.log" }, - "dlt":"false" + "dlt":"true" }, "applications": [ @@ -53,4 +53,3 @@ "protocol":"udp" } } - diff --git a/test/network_tests/big_payload_tests/conf/big_payload_test_tcp_service.json.in b/test/network_tests/big_payload_tests/conf/big_payload_test_tcp_service.json.in index 08149bb33..431354336 100644 --- a/test/network_tests/big_payload_tests/conf/big_payload_test_tcp_service.json.in +++ b/test/network_tests/big_payload_tests/conf/big_payload_test_tcp_service.json.in @@ -9,7 +9,7 @@ "enable":"false", "path":"/tmp/vsomeip.log" }, - "dlt":"false" + "dlt":"true" }, "applications": [ diff --git a/test/network_tests/big_payload_tests/conf/big_payload_test_tcp_service_limited_general.json.in b/test/network_tests/big_payload_tests/conf/big_payload_test_tcp_service_limited_general.json.in index f8414f333..0e960eb9f 100644 --- a/test/network_tests/big_payload_tests/conf/big_payload_test_tcp_service_limited_general.json.in +++ b/test/network_tests/big_payload_tests/conf/big_payload_test_tcp_service_limited_general.json.in @@ -9,7 +9,7 @@ "enable":"false", "path":"/tmp/vsomeip.log" }, - "dlt":"false" + "dlt":"true" }, "applications": [ diff --git a/test/network_tests/big_payload_tests/conf/big_payload_test_tcp_service_queue_limited_general.json.in b/test/network_tests/big_payload_tests/conf/big_payload_test_tcp_service_queue_limited_general.json.in index ad5b28c82..861a7b23f 100644 --- a/test/network_tests/big_payload_tests/conf/big_payload_test_tcp_service_queue_limited_general.json.in +++ b/test/network_tests/big_payload_tests/conf/big_payload_test_tcp_service_queue_limited_general.json.in @@ -9,7 +9,7 @@ "enable":"false", "path":"/tmp/vsomeip.log" }, - "dlt":"false" + "dlt":"true" }, "applications": [ diff --git a/test/network_tests/big_payload_tests/conf/big_payload_test_tcp_service_queue_limited_specific.json.in b/test/network_tests/big_payload_tests/conf/big_payload_test_tcp_service_queue_limited_specific.json.in index 87bcdaa98..5f0547d91 100644 --- a/test/network_tests/big_payload_tests/conf/big_payload_test_tcp_service_queue_limited_specific.json.in +++ b/test/network_tests/big_payload_tests/conf/big_payload_test_tcp_service_queue_limited_specific.json.in @@ -9,7 +9,7 @@ "enable":"false", "path":"/tmp/vsomeip.log" }, - "dlt":"false" + "dlt":"true" }, "applications": [ diff --git a/test/network_tests/big_payload_tests/conf/big_payload_test_tcp_service_random.json.in b/test/network_tests/big_payload_tests/conf/big_payload_test_tcp_service_random.json.in index d583fd177..2302e103d 100644 --- a/test/network_tests/big_payload_tests/conf/big_payload_test_tcp_service_random.json.in +++ b/test/network_tests/big_payload_tests/conf/big_payload_test_tcp_service_random.json.in @@ -9,7 +9,7 @@ "enable":"false", "path":"/tmp/vsomeip.log" }, - "dlt":"false" + "dlt":"true" }, "applications": [ diff --git a/test/network_tests/big_payload_tests/conf/big_payload_test_udp_service.json.in b/test/network_tests/big_payload_tests/conf/big_payload_test_udp_service.json.in index 7f71a0573..e87ca0777 100644 --- a/test/network_tests/big_payload_tests/conf/big_payload_test_udp_service.json.in +++ b/test/network_tests/big_payload_tests/conf/big_payload_test_udp_service.json.in @@ -9,7 +9,7 @@ "enable":"false", "path":"/tmp/vsomeip.log" }, - "dlt":"false" + "dlt":"true" }, "applications": [ diff --git a/test/network_tests/client_id_tests/client_id_test_master_starter_qnx.sh b/test/network_tests/client_id_tests/client_id_test_master_starter_qnx.sh index 3c46361fa..de2f59e0b 100755 --- a/test/network_tests/client_id_tests/client_id_test_master_starter_qnx.sh +++ b/test/network_tests/client_id_tests/client_id_test_master_starter_qnx.sh @@ -1,5 +1,5 @@ #!/bin/sh -# Copyright (C) 2015-2017 Bayerische Motoren Werke Aktiengesellschaft (BMW AG) +# Copyright (C) 2015-2023 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/. diff --git a/test/network_tests/client_id_tests/client_id_test_service.cpp b/test/network_tests/client_id_tests/client_id_test_service.cpp index 0a510051d..4eeb344e7 100644 --- a/test/network_tests/client_id_tests/client_id_test_service.cpp +++ b/test/network_tests/client_id_tests/client_id_test_service.cpp @@ -1,4 +1,4 @@ -// Copyright (C) 2014-2017 Bayerische Motoren Werke Aktiengesellschaft (BMW AG) +// Copyright (C) 2014-2023 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/. @@ -18,11 +18,14 @@ #include #include "client_id_test_globals.hpp" +#include "../someip_test_globals.hpp" +#include -class client_id_test_service { +class client_id_test_service : public vsomeip_utilities::base_logger { public: client_id_test_service(struct client_id_test::service_info _service_info) : + vsomeip_utilities::base_logger("CITS", "CLIENT ID TEST SERVICE"), service_info_(_service_info), app_(vsomeip::runtime::get()->create_application()), blocked_(false), diff --git a/test/network_tests/client_id_tests/client_id_test_utility.cpp b/test/network_tests/client_id_tests/client_id_test_utility.cpp index 3be55e08d..873286051 100644 --- a/test/network_tests/client_id_tests/client_id_test_utility.cpp +++ b/test/network_tests/client_id_tests/client_id_test_utility.cpp @@ -1,4 +1,4 @@ -// Copyright (C) 2014-2017 Bayerische Motoren Werke Aktiengesellschaft (BMW AG) +// Copyright (C) 2014-2023 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/. @@ -14,6 +14,8 @@ #include "../../implementation/configuration/include/configuration.hpp" #include "../../implementation/configuration/include/configuration_plugin.hpp" #include "../../implementation/plugin/include/plugin_manager_impl.hpp" +#include "../someip_test_globals.hpp" +#include using namespace vsomeip; @@ -106,9 +108,10 @@ class client_id_utility_test: public ::testing::Test { std::thread rm_impl_thread_; }; -class app_wrapper { +class app_wrapper : public vsomeip_utilities::base_logger { public: app_wrapper(const std::string& _name) : + vsomeip_utilities::base_logger("APPW", "APP WRAPPER"), app_(vsomeip::runtime::get()->create_application(_name)), client_(VSOMEIP_CLIENT_UNSET) { EXPECT_TRUE(app_->init()); diff --git a/test/network_tests/client_id_tests/client_id_test_utility.json b/test/network_tests/client_id_tests/client_id_test_utility.json index e07eb9afc..a911b654b 100644 --- a/test/network_tests/client_id_tests/client_id_test_utility.json +++ b/test/network_tests/client_id_tests/client_id_test_utility.json @@ -9,7 +9,7 @@ "enable":"false", "path":"/tmp/vsomeip.log" }, - "dlt":"false" + "dlt":"true" }, "diagnosis":"0x63", "applications": diff --git a/test/network_tests/client_id_tests/client_id_test_utility_discontinuous_masked_511.json b/test/network_tests/client_id_tests/client_id_test_utility_discontinuous_masked_511.json index af3dfd6c5..dcaaded73 100644 --- a/test/network_tests/client_id_tests/client_id_test_utility_discontinuous_masked_511.json +++ b/test/network_tests/client_id_tests/client_id_test_utility_discontinuous_masked_511.json @@ -9,7 +9,7 @@ "enable":"false", "path":"/tmp/vsomeip.log" }, - "dlt":"false" + "dlt":"true" }, "diagnosis":"0x63", "diagnosis_mask":"0xFB00", diff --git a/test/network_tests/client_id_tests/client_id_test_utility_masked_127.json b/test/network_tests/client_id_tests/client_id_test_utility_masked_127.json index 8aa51353b..7b9067854 100644 --- a/test/network_tests/client_id_tests/client_id_test_utility_masked_127.json +++ b/test/network_tests/client_id_tests/client_id_test_utility_masked_127.json @@ -9,7 +9,7 @@ "enable":"false", "path":"/tmp/vsomeip.log" }, - "dlt":"false" + "dlt":"true" }, "diagnosis":"0x63", "diagnosis_mask":"0xFF80", diff --git a/test/network_tests/client_id_tests/client_id_test_utility_masked_4095.json b/test/network_tests/client_id_tests/client_id_test_utility_masked_4095.json index 86044350b..6cef0ebc7 100644 --- a/test/network_tests/client_id_tests/client_id_test_utility_masked_4095.json +++ b/test/network_tests/client_id_tests/client_id_test_utility_masked_4095.json @@ -9,7 +9,7 @@ "enable":"false", "path":"/tmp/vsomeip.log" }, - "dlt":"false" + "dlt":"true" }, "diagnosis":"0x60", "diagnosis_mask":"0xF000", diff --git a/test/network_tests/client_id_tests/client_id_test_utility_masked_511.json b/test/network_tests/client_id_tests/client_id_test_utility_masked_511.json index a57d382a4..2edcc7554 100644 --- a/test/network_tests/client_id_tests/client_id_test_utility_masked_511.json +++ b/test/network_tests/client_id_tests/client_id_test_utility_masked_511.json @@ -9,7 +9,7 @@ "enable":"false", "path":"/tmp/vsomeip.log" }, - "dlt":"false" + "dlt":"true" }, "diagnosis":"0x62", "diagnosis_mask":"0xFE00", diff --git a/test/network_tests/client_id_tests/conf/client_id_test_diff_client_ids_diff_ports_master.json.in b/test/network_tests/client_id_tests/conf/client_id_test_diff_client_ids_diff_ports_master.json.in index a986dd9f2..b064cb31a 100644 --- a/test/network_tests/client_id_tests/conf/client_id_test_diff_client_ids_diff_ports_master.json.in +++ b/test/network_tests/client_id_tests/conf/client_id_test_diff_client_ids_diff_ports_master.json.in @@ -9,7 +9,7 @@ "enable":"false", "path":"/tmp/vsomeip.log" }, - "dlt":"false" + "dlt":"true" }, "applications": [ @@ -67,4 +67,4 @@ "port":"30490", "protocol":"udp" } -} \ No newline at end of file +} diff --git a/test/network_tests/client_id_tests/conf/client_id_test_diff_client_ids_diff_ports_slave.json.in b/test/network_tests/client_id_tests/conf/client_id_test_diff_client_ids_diff_ports_slave.json.in index 596f84221..a743e5c94 100644 --- a/test/network_tests/client_id_tests/conf/client_id_test_diff_client_ids_diff_ports_slave.json.in +++ b/test/network_tests/client_id_tests/conf/client_id_test_diff_client_ids_diff_ports_slave.json.in @@ -9,7 +9,7 @@ "enable":"false", "path":"/tmp/vsomeip.log" }, - "dlt":"false" + "dlt":"true" }, "applications": [ @@ -67,4 +67,4 @@ "port":"30490", "protocol":"udp" } -} \ No newline at end of file +} diff --git a/test/network_tests/client_id_tests/conf/client_id_test_diff_client_ids_partial_same_ports_master.json.in b/test/network_tests/client_id_tests/conf/client_id_test_diff_client_ids_partial_same_ports_master.json.in index bb3507bd8..f7e5a4722 100644 --- a/test/network_tests/client_id_tests/conf/client_id_test_diff_client_ids_partial_same_ports_master.json.in +++ b/test/network_tests/client_id_tests/conf/client_id_test_diff_client_ids_partial_same_ports_master.json.in @@ -9,7 +9,7 @@ "enable":"false", "path":"/tmp/vsomeip.log" }, - "dlt":"false" + "dlt":"true" }, "applications": [ @@ -67,4 +67,4 @@ "port":"30490", "protocol":"udp" } -} \ No newline at end of file +} diff --git a/test/network_tests/client_id_tests/conf/client_id_test_diff_client_ids_partial_same_ports_slave.json.in b/test/network_tests/client_id_tests/conf/client_id_test_diff_client_ids_partial_same_ports_slave.json.in index a7337e9d0..48dbf5f58 100644 --- a/test/network_tests/client_id_tests/conf/client_id_test_diff_client_ids_partial_same_ports_slave.json.in +++ b/test/network_tests/client_id_tests/conf/client_id_test_diff_client_ids_partial_same_ports_slave.json.in @@ -9,7 +9,7 @@ "enable":"false", "path":"/tmp/vsomeip.log" }, - "dlt":"false" + "dlt":"true" }, "applications": [ @@ -67,4 +67,4 @@ "port":"30490", "protocol":"udp" } -} \ No newline at end of file +} diff --git a/test/network_tests/client_id_tests/conf/client_id_test_diff_client_ids_same_ports_master.json.in b/test/network_tests/client_id_tests/conf/client_id_test_diff_client_ids_same_ports_master.json.in index 9f7062fac..d606e96f7 100644 --- a/test/network_tests/client_id_tests/conf/client_id_test_diff_client_ids_same_ports_master.json.in +++ b/test/network_tests/client_id_tests/conf/client_id_test_diff_client_ids_same_ports_master.json.in @@ -9,7 +9,7 @@ "enable":"false", "path":"/tmp/vsomeip.log" }, - "dlt":"false" + "dlt":"true" }, "applications": [ @@ -67,4 +67,4 @@ "port":"30490", "protocol":"udp" } -} \ No newline at end of file +} diff --git a/test/network_tests/client_id_tests/conf/client_id_test_diff_client_ids_same_ports_slave.json.in b/test/network_tests/client_id_tests/conf/client_id_test_diff_client_ids_same_ports_slave.json.in index 1aaf2cbd2..9563b2a4f 100644 --- a/test/network_tests/client_id_tests/conf/client_id_test_diff_client_ids_same_ports_slave.json.in +++ b/test/network_tests/client_id_tests/conf/client_id_test_diff_client_ids_same_ports_slave.json.in @@ -9,7 +9,7 @@ "enable":"false", "path":"/tmp/vsomeip.log" }, - "dlt":"false" + "dlt":"true" }, "applications": [ @@ -67,4 +67,4 @@ "port":"30490", "protocol":"udp" } -} \ No newline at end of file +} diff --git a/test/network_tests/client_id_tests/conf/client_id_test_same_client_ids_diff_ports_master.json.in b/test/network_tests/client_id_tests/conf/client_id_test_same_client_ids_diff_ports_master.json.in index a986dd9f2..b064cb31a 100644 --- a/test/network_tests/client_id_tests/conf/client_id_test_same_client_ids_diff_ports_master.json.in +++ b/test/network_tests/client_id_tests/conf/client_id_test_same_client_ids_diff_ports_master.json.in @@ -9,7 +9,7 @@ "enable":"false", "path":"/tmp/vsomeip.log" }, - "dlt":"false" + "dlt":"true" }, "applications": [ @@ -67,4 +67,4 @@ "port":"30490", "protocol":"udp" } -} \ No newline at end of file +} diff --git a/test/network_tests/client_id_tests/conf/client_id_test_same_client_ids_diff_ports_slave.json.in b/test/network_tests/client_id_tests/conf/client_id_test_same_client_ids_diff_ports_slave.json.in index 2acb37b58..2f392415b 100644 --- a/test/network_tests/client_id_tests/conf/client_id_test_same_client_ids_diff_ports_slave.json.in +++ b/test/network_tests/client_id_tests/conf/client_id_test_same_client_ids_diff_ports_slave.json.in @@ -9,7 +9,7 @@ "enable":"false", "path":"/tmp/vsomeip.log" }, - "dlt":"false" + "dlt":"true" }, "applications": [ @@ -67,4 +67,4 @@ "port":"30490", "protocol":"udp" } -} \ No newline at end of file +} diff --git a/test/network_tests/client_id_tests/conf/client_id_test_same_client_ids_same_ports_master.json.in b/test/network_tests/client_id_tests/conf/client_id_test_same_client_ids_same_ports_master.json.in index 9f7062fac..d606e96f7 100644 --- a/test/network_tests/client_id_tests/conf/client_id_test_same_client_ids_same_ports_master.json.in +++ b/test/network_tests/client_id_tests/conf/client_id_test_same_client_ids_same_ports_master.json.in @@ -9,7 +9,7 @@ "enable":"false", "path":"/tmp/vsomeip.log" }, - "dlt":"false" + "dlt":"true" }, "applications": [ @@ -67,4 +67,4 @@ "port":"30490", "protocol":"udp" } -} \ No newline at end of file +} diff --git a/test/network_tests/client_id_tests/conf/client_id_test_same_client_ids_same_ports_slave.json.in b/test/network_tests/client_id_tests/conf/client_id_test_same_client_ids_same_ports_slave.json.in index ae534b14b..2335195a0 100644 --- a/test/network_tests/client_id_tests/conf/client_id_test_same_client_ids_same_ports_slave.json.in +++ b/test/network_tests/client_id_tests/conf/client_id_test_same_client_ids_same_ports_slave.json.in @@ -9,7 +9,7 @@ "enable":"false", "path":"/tmp/vsomeip.log" }, - "dlt":"false" + "dlt":"true" }, "applications": [ @@ -67,4 +67,4 @@ "port":"30490", "protocol":"udp" } -} \ No newline at end of file +} diff --git a/test/network_tests/configuration_tests/configuration-test-deprecated.json b/test/network_tests/configuration_tests/configuration-test-deprecated.json index 5a8b0ee6f..3e4c118d6 100644 --- a/test/network_tests/configuration_tests/configuration-test-deprecated.json +++ b/test/network_tests/configuration_tests/configuration-test-deprecated.json @@ -91,12 +91,52 @@ "request_debounce_time" : "10001" } ], + "suppress_missing_event_logs" : + [ + { + "service" : "0x0023", + "instance" : "0x0001", + "events" : [ "0x8001", "0x8002", + { + "first" : "0x8010", + "last" : "0x8015" + }, + "0x8020" ] + }, + { + "service" : "0x0023", + "instance" : "0x0002", + "events" : "0x8005" + }, + { + "service" : "0x0023", + "instance" : "0x0002", + "events" : [ "0x8105", "0x8106" ] + }, + { + "service" : "any", + "instance" : "0x00f2" + }, + { + "service" : "0x0102", + "instance" : "any", + "events" : [ "0x8005", "0x8006" ] + }, + { + "service" : "0x24", + "instance" : "any", + "events" : { + "first" : "0x8010", + "last" : "0x8015" + } + } + ], "servicegroups" : [ - { + { "name" : "default", "unicast" : "local", - "delays" : + "delays" : { "initial" : { "minimum" : "10", "maximum" : "100" }, "repetition-base" : "200", @@ -171,7 +211,7 @@ } ] }, - { + { "name" : "extra", "unicast" : "local", "delays" : diff --git a/test/network_tests/configuration_tests/configuration-test.cpp b/test/network_tests/configuration_tests/configuration-test.cpp index 0082d75c9..f2c8f8647 100644 --- a/test/network_tests/configuration_tests/configuration-test.cpp +++ b/test/network_tests/configuration_tests/configuration-test.cpp @@ -1,4 +1,4 @@ -// Copyright (C) 2015-2017 Bayerische Motoren Werke Aktiengesellschaft (BMW AG) +// Copyright (C) 2015-2023 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/. @@ -8,7 +8,7 @@ #include -#include "../../common/utility.hpp" +#include #include #include @@ -183,6 +183,22 @@ void check_file(const std::string &_config_file, return; } + // Check "suppress_missing_event_logs" + EXPECT_TRUE(its_configuration->check_suppress_events(0x0023, 0x0001, 0x8002)); // Multiple values + EXPECT_TRUE(its_configuration->check_suppress_events(0x0023, 0x0001, 0x8015)); // Range + EXPECT_FALSE(its_configuration->check_suppress_events(0x0023, 0x0001, 0x8016)); // Range + EXPECT_TRUE(its_configuration->check_suppress_events(0x0023, 0x0001, 0x8020)); // Single + + EXPECT_TRUE(its_configuration->check_suppress_events(0x0023, 0x0002, 0x8005)); // Single + EXPECT_FALSE(its_configuration->check_suppress_events(0x0023, 0x0002, 0x8006)); // Single + + EXPECT_TRUE(its_configuration->check_suppress_events(0x1111, 0x00f2, 0x8001)); // "ANY" Service/Event + EXPECT_TRUE(its_configuration->check_suppress_events(0x0102, 0x0010, 0x8005)); // "ANY" Instance + EXPECT_FALSE(its_configuration->check_suppress_events(0x0102, 0x0010, 0x8007)); // "ANY" Instance + + EXPECT_TRUE(its_configuration->check_suppress_events(0x0024, 0x5555, 0x8011)); // "ANY" INSTANCE + EXPECT_FALSE(its_configuration->check_suppress_events(0x0024, 0x5555, 0x8016)); // "ANY" INSTANCE + vsomeip::cfg::configuration_impl its_copied_config( static_cast(*its_configuration)); vsomeip::cfg::configuration_impl* its_new_config = @@ -527,33 +543,34 @@ void check_file(const std::string &_config_file, // security #if !defined(VSOMEIP_DISABLE_SECURITY) && !defined(__QNX__) - vsomeip_sec_client_t its_x123_x456 = utility::create_uds_client(0x123, 0x456); + vsomeip_sec_client_t its_x123_x456 = utility::create_uds_client(0x123, 0x456, 0); + EXPECT_TRUE(its_configuration->check_routing_credentials(0x7788, &its_x123_x456)); // GID does not match - vsomeip_sec_client_t its_x123_x222 = utility::create_uds_client(0x123, 0x222); + vsomeip_sec_client_t its_x123_x222 = utility::create_uds_client(0x123, 0x222, 0); EXPECT_FALSE(its_configuration->check_routing_credentials(0x7788, &its_x123_x222)); // UID does not match - vsomeip_sec_client_t its_x333_x456 = utility::create_uds_client(0x333, 0x456); + vsomeip_sec_client_t its_x333_x456 = utility::create_uds_client(0x333, 0x456, 0); EXPECT_FALSE(its_configuration->check_routing_credentials(0x7788, &its_x333_x456)); // client is not the routing manager - vsomeip_sec_client_t its_x888_x999 = utility::create_uds_client(0x888, 0x999); + vsomeip_sec_client_t its_x888_x999 = utility::create_uds_client(0x888, 0x999, 0); EXPECT_TRUE(its_configuration->check_routing_credentials(0x7777, &its_x888_x999)); EXPECT_TRUE(its_configuration->is_security_enabled()); - vsomeip_sec_client_t its_1000_1000 = utility::create_uds_client(1000, 1000); - vsomeip_sec_client_t its_1001_1001 = utility::create_uds_client(1001, 1001); - vsomeip_sec_client_t its_2000_2000 = utility::create_uds_client(2000, 2000); - vsomeip_sec_client_t its_2001_2001 = utility::create_uds_client(2001, 2001); - vsomeip_sec_client_t its_4000_4000 = utility::create_uds_client(4000, 4000); - vsomeip_sec_client_t its_4001_4001 = utility::create_uds_client(4001, 4001); - vsomeip_sec_client_t its_5000_5000 = utility::create_uds_client(5000, 5000); - vsomeip_sec_client_t its_6000_6000 = utility::create_uds_client(6000, 6000); - vsomeip_sec_client_t its_7000_7000 = utility::create_uds_client(7000, 7000); - vsomeip_sec_client_t its_8000_8000 = utility::create_uds_client(8000, 8000); - vsomeip_sec_client_t its_9000_9000 = utility::create_uds_client(9000, 9000); + vsomeip_sec_client_t its_1000_1000 = utility::create_uds_client(1000, 1000, 0); + vsomeip_sec_client_t its_1001_1001 = utility::create_uds_client(1001, 1001, 0); + vsomeip_sec_client_t its_2000_2000 = utility::create_uds_client(2000, 2000, 0); + vsomeip_sec_client_t its_2001_2001 = utility::create_uds_client(2001, 2001, 0); + vsomeip_sec_client_t its_4000_4000 = utility::create_uds_client(4000, 4000, 0); + vsomeip_sec_client_t its_4001_4001 = utility::create_uds_client(4001, 4001, 0); + vsomeip_sec_client_t its_5000_5000 = utility::create_uds_client(5000, 5000, 0); + vsomeip_sec_client_t its_6000_6000 = utility::create_uds_client(6000, 6000, 0); + vsomeip_sec_client_t its_7000_7000 = utility::create_uds_client(7000, 7000, 0); + vsomeip_sec_client_t its_8000_8000 = utility::create_uds_client(8000, 8000, 0); + vsomeip_sec_client_t its_9000_9000 = utility::create_uds_client(9000, 9000, 0); auto its_security = vsomeip::policy_manager_impl::get(); EXPECT_TRUE(its_security->is_offer_allowed(&its_1000_1000, 0x1234, 0x5678)); diff --git a/test/network_tests/configuration_tests/configuration-test.json b/test/network_tests/configuration_tests/configuration-test.json index e18026e8d..3e24819fa 100644 --- a/test/network_tests/configuration_tests/configuration-test.json +++ b/test/network_tests/configuration_tests/configuration-test.json @@ -117,6 +117,46 @@ "request_debounce_time" : "10001" } ], + "suppress_missing_event_logs" : + [ + { + "service" : "0x0023", + "instance" : "0x0001", + "events" : [ "0x8001", "0x8002", + { + "first" : "0x8010", + "last" : "0x8015" + }, + "0x8020" ] + }, + { + "service" : "0x0023", + "instance" : "0x0002", + "events" : "0x8005" + }, + { + "service" : "0x0023", + "instance" : "0x0002", + "events" : [ "0x8105", "0x8106" ] + }, + { + "service" : "any", + "instance" : "0x00f2" + }, + { + "service" : "0x0102", + "instance" : "any", + "events" : [ "0x8005", "0x8006" ] + }, + { + "service" : "0x24", + "instance" : "any", + "events" : { + "first" : "0x8010", + "last" : "0x8015" + } + } + ], "services" : [ { diff --git a/test/network_tests/cpu_load_tests/conf/cpu_load_test_client_master.json.in b/test/network_tests/cpu_load_tests/conf/cpu_load_test_client_master.json.in index ec9dcd793..4eda44a59 100644 --- a/test/network_tests/cpu_load_tests/conf/cpu_load_test_client_master.json.in +++ b/test/network_tests/cpu_load_tests/conf/cpu_load_test_client_master.json.in @@ -1,20 +1,20 @@ { "unicast" : "@TEST_IP_MASTER@", "netmask" : "255.255.255.0", - "logging" : + "logging" : { "level" : "debug", "console" : "true", - "file" : + "file" : { "enable" : "false", "path" : "/var/log/vsomeip.log" }, - "dlt" : "false" + "dlt" : "true" }, - "applications" : + "applications" : [ { "name" : "cpu_load_test_client", @@ -28,7 +28,7 @@ "max-retention-time-response" : "0" }, "routing" : "cpu_load_test_client", - "service-discovery" : + "service-discovery" : { "enable" : "true", "multicast" : "224.0.0.1", diff --git a/test/network_tests/cpu_load_tests/conf/cpu_load_test_client_slave.json.in b/test/network_tests/cpu_load_tests/conf/cpu_load_test_client_slave.json.in index 4da82f4eb..c4ac4c521 100644 --- a/test/network_tests/cpu_load_tests/conf/cpu_load_test_client_slave.json.in +++ b/test/network_tests/cpu_load_tests/conf/cpu_load_test_client_slave.json.in @@ -1,20 +1,20 @@ { "unicast" : "@TEST_IP_SLAVE@", "netmask" : "255.255.255.0", - "logging" : + "logging" : { "level" : "debug", "console" : "true", - "file" : + "file" : { "enable" : "false", "path" : "/var/log/vsomeip.log" }, - "dlt" : "false" + "dlt" : "true" }, - "applications" : + "applications" : [ { "name" : "cpu_load_test_client", @@ -28,7 +28,7 @@ "max-retention-time-response" : "0" }, "routing" : "cpu_load_test_client", - "service-discovery" : + "service-discovery" : { "enable" : "true", "multicast" : "224.0.0.1", diff --git a/test/network_tests/cpu_load_tests/conf/cpu_load_test_service_master.json.in b/test/network_tests/cpu_load_tests/conf/cpu_load_test_service_master.json.in index da34e22aa..89d41c23c 100644 --- a/test/network_tests/cpu_load_tests/conf/cpu_load_test_service_master.json.in +++ b/test/network_tests/cpu_load_tests/conf/cpu_load_test_service_master.json.in @@ -1,19 +1,19 @@ { "unicast" : "@TEST_IP_MASTER@", - "logging" : + "logging" : { "level" : "debug", "console" : "true", - "file" : + "file" : { "enable" : "false", "path" : "/tmp/vsomeip.log" }, - "dlt" : "false" + "dlt" : "true" }, - "applications" : + "applications" : [ { "name" : "cpu_load_test_service", @@ -21,13 +21,13 @@ } ], - "services" : + "services" : [ { "service" : "0x1111", "instance" : "0x1", "unreliable" : "30510", - "reliable" : + "reliable" : { "port" : "30510", "enable-magic-cookies" : "false" @@ -41,7 +41,7 @@ "max-retention-time-response" : "0" }, "routing" : "cpu_load_test_service", - "service-discovery" : + "service-discovery" : { "enable" : "true", "multicast" : "224.0.0.1", diff --git a/test/network_tests/cpu_load_tests/conf/cpu_load_test_service_slave.json.in b/test/network_tests/cpu_load_tests/conf/cpu_load_test_service_slave.json.in index 389aea050..db28f210b 100644 --- a/test/network_tests/cpu_load_tests/conf/cpu_load_test_service_slave.json.in +++ b/test/network_tests/cpu_load_tests/conf/cpu_load_test_service_slave.json.in @@ -1,19 +1,19 @@ { "unicast" : "@TEST_IP_SLAVE@", - "logging" : + "logging" : { "level" : "debug", "console" : "true", - "file" : + "file" : { "enable" : "false", "path" : "/tmp/vsomeip.log" }, - "dlt" : "false" + "dlt" : "true" }, - "applications" : + "applications" : [ { "name" : "cpu_load_test_service", @@ -21,13 +21,13 @@ } ], - "services" : + "services" : [ { "service" : "0x1111", "instance" : "0x1", "unreliable" : "30510", - "reliable" : + "reliable" : { "port" : "30510", "enable-magic-cookies" : "false" @@ -41,7 +41,7 @@ "max-retention-time-response" : "0" }, "routing" : "cpu_load_test_service", - "service-discovery" : + "service-discovery" : { "enable" : "true", "multicast" : "224.0.0.1", diff --git a/test/network_tests/cpu_load_tests/cpu_load_test_client.cpp b/test/network_tests/cpu_load_tests/cpu_load_test_client.cpp index 9bf74b5cd..0730d37e1 100644 --- a/test/network_tests/cpu_load_tests/cpu_load_test_client.cpp +++ b/test/network_tests/cpu_load_tests/cpu_load_test_client.cpp @@ -1,4 +1,4 @@ -// Copyright (C) 2015-2017 Bayerische Motoren Werke Aktiengesellschaft (BMW AG) +// Copyright (C) 2015-2023 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/. diff --git a/test/network_tests/cpu_load_tests/cpu_load_test_service.cpp b/test/network_tests/cpu_load_tests/cpu_load_test_service.cpp index 2003dff7a..3d935e395 100644 --- a/test/network_tests/cpu_load_tests/cpu_load_test_service.cpp +++ b/test/network_tests/cpu_load_tests/cpu_load_test_service.cpp @@ -1,4 +1,4 @@ -// Copyright (C) 2015-2017 Bayerische Motoren Werke Aktiengesellschaft (BMW AG) +// Copyright (C) 2015-2023 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/. diff --git a/test/network_tests/debounce_filter_tests/conf/debounce_filter_test_client.json.in b/test/network_tests/debounce_filter_tests/conf/debounce_filter_test_client.json.in new file mode 100644 index 000000000..8792425e5 --- /dev/null +++ b/test/network_tests/debounce_filter_tests/conf/debounce_filter_test_client.json.in @@ -0,0 +1,40 @@ +{ + "unicast" : "@TEST_IP_MASTER@", + "logging": { + "level": "verbose", + "console": "true", + "file": { + "enable": "true", + "path": "/tmp/foo.log" + }, + "dlt": "true" + }, + "tracing" : + { + "enable" : "true" + }, + "debounce" : + [ + { + "service" : "0xb519", + "instance" : "0x0001", + "events" : + [ + { + "event" : "0x8008", + "on_change" : "false", + "ignore" : + [] + } + ] + } + ], + "service-discovery" : + { + "enable" : "true", + "multicast" : "224.251.192.252", + "port" : "30490", + "protocol" : "udp", + "cyclic_offer_delay" : "1000" + } +} diff --git a/test/network_tests/debounce_filter_tests/conf/debounce_filter_test_service.json.in b/test/network_tests/debounce_filter_tests/conf/debounce_filter_test_service.json.in new file mode 100644 index 000000000..d5b34e5e4 --- /dev/null +++ b/test/network_tests/debounce_filter_tests/conf/debounce_filter_test_service.json.in @@ -0,0 +1,32 @@ +{ + "unicast" : "@TEST_IP_SLAVE@", + "logging": { + "level": "verbose", + "console": "true", + "file": { + "enable": "true", + "path": "/tmp/foo.log" + }, + "dlt": "true" + }, + "tracing" : + { + "enable" : "true" + }, + "services" : + [ + { + "service" : "0xb519", + "instance" : "0x0001", + "unreliable" : "30503" + } + ], + "service-discovery" : + { + "enable" : "true", + "multicast" : "224.251.192.252", + "port" : "30490", + "protocol" : "udp", + "cyclic_offer_delay" : "1000" + } +} diff --git a/test/network_tests/debounce_filter_tests/debounce_filter_test_client.cpp b/test/network_tests/debounce_filter_tests/debounce_filter_test_client.cpp new file mode 100644 index 000000000..98153163c --- /dev/null +++ b/test/network_tests/debounce_filter_tests/debounce_filter_test_client.cpp @@ -0,0 +1,237 @@ +// Copyright (C) 2023 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/. + +#include +#include + +#include + +#include "debounce_filter_test_client.hpp" + +static std::vector>> payloads__; + +debounce_test_client::debounce_test_client(int64_t _interval) + : interval(_interval), + index_(0), + is_available_(false), + runner_(std::bind(&debounce_test_client::run, this)), + app_(vsomeip::runtime::get()->create_application("debounce_test_client")) +{ +} + +bool debounce_test_client::init() +{ + dBFilter.interval_ = interval; + + bool its_result = app_->init(); + if (its_result) + { + app_->register_availability_handler( + DEBOUNCE_SERVICE, DEBOUNCE_INSTANCE, + std::bind(&debounce_test_client::on_availability, this, + std::placeholders::_1, + std::placeholders::_2, + std::placeholders::_3), + DEBOUNCE_MAJOR, DEBOUNCE_MINOR); + app_->register_message_handler( + DEBOUNCE_SERVICE, DEBOUNCE_INSTANCE, vsomeip::ANY_EVENT, + std::bind(&debounce_test_client::on_message, this, + std::placeholders::_1)); + app_->request_event(DEBOUNCE_SERVICE, DEBOUNCE_INSTANCE, + DEBOUNCE_EVENT, {DEBOUNCE_EVENTGROUP}, + vsomeip::event_type_e::ET_FIELD, + vsomeip::reliability_type_e::RT_UNRELIABLE); + app_->request_service(DEBOUNCE_SERVICE, DEBOUNCE_INSTANCE, + DEBOUNCE_MAJOR, DEBOUNCE_MINOR); + app_->subscribe_with_debounce(DEBOUNCE_SERVICE, DEBOUNCE_INSTANCE, + DEBOUNCE_EVENTGROUP, DEBOUNCE_MAJOR, DEBOUNCE_EVENT, dBFilter); + } + return its_result; +} + +void debounce_test_client::start() +{ + app_->start(); +} + +void debounce_test_client::stop() +{ + app_->stop(); +} + +void debounce_test_client::run() +{ + { + std::unique_lock its_lock(run_mutex_); + while (!is_available_) + { + auto its_status = run_condition_.wait_for(its_lock, std::chrono::milliseconds(15000)); + EXPECT_EQ(its_status, std::cv_status::no_timeout); + if (its_status == std::cv_status::timeout) + { + VSOMEIP_ERROR << __func__ << ": Debounce service did not become available after 15s."; + stop(); + return; + } + } + } + + VSOMEIP_INFO << __func__ << ": Running test."; + run_test(); + + unsubscribe_all(); + + VSOMEIP_INFO << __func__ << ": Stopping the service."; + stop_service(); + + std::this_thread::sleep_for(std::chrono::milliseconds(100)); + + stop(); +} + +void debounce_test_client::wait() +{ + if (runner_.joinable()) + runner_.join(); +} + +void debounce_test_client::on_availability( + vsomeip::service_t _service, vsomeip::instance_t _instance, + bool _is_available) +{ + if (_service == DEBOUNCE_SERVICE && _instance == DEBOUNCE_INSTANCE) + { + + if (_is_available) + { + VSOMEIP_INFO << __func__ << ": Debounce service becomes available."; + { + std::lock_guard its_lock(run_mutex_); + is_available_ = true; + } + run_condition_.notify_one(); + } + else + { + VSOMEIP_INFO << __func__ << ": Debounce service becomes unavailable."; + + std::lock_guard its_lock(run_mutex_); + is_available_ = false; + } + } +} + +void debounce_test_client::on_message( + const std::shared_ptr &_message) +{ + if (DEBOUNCE_SERVICE == _message->get_service() && DEBOUNCE_EVENT == _message->get_method()) + { + // VSOMEIP_INFO << "Got new message: " << nb_msgs_rcvd << std::endl; + nb_msgs_rcvd++; + } +} + +void debounce_test_client::run_test() +{ + // Trigger the test + auto its_runtime = vsomeip::runtime::get(); + auto its_payload = its_runtime->create_payload(); + auto its_message = its_runtime->create_request(false); + its_message->set_service(DEBOUNCE_SERVICE); + its_message->set_instance(DEBOUNCE_INSTANCE); + its_message->set_method(DEBOUNCE_START_METHOD); + its_message->set_interface_version(DEBOUNCE_MAJOR); + its_message->set_message_type(vsomeip::message_type_e::MT_REQUEST_NO_RETURN); + its_message->set_payload(its_payload); + app_->send(its_message); + + std::this_thread::sleep_for(std::chrono::seconds(15)); +} + +void debounce_test_client::unsubscribe_all() +{ + app_->unsubscribe(DEBOUNCE_SERVICE, DEBOUNCE_INSTANCE, + DEBOUNCE_EVENTGROUP); +} + +void debounce_test_client::stop_service() +{ + auto its_runtime = vsomeip::runtime::get(); + auto its_payload = its_runtime->create_payload(); + auto its_message = its_runtime->create_request(false); + its_message->set_service(DEBOUNCE_SERVICE); + its_message->set_instance(DEBOUNCE_INSTANCE); + its_message->set_method(DEBOUNCE_STOP_METHOD); + its_message->set_interface_version(DEBOUNCE_MAJOR); + its_message->set_message_type(vsomeip::message_type_e::MT_REQUEST_NO_RETURN); + its_message->set_payload(its_payload); + app_->send(its_message); +} + +int64_t debounce_test_client::getNbMsgsRcvd() { + return nb_msgs_rcvd; +} + +TEST(debounce_test, normal_interval) +{ + debounce_test_client its_client(DEBOUNCE_INTERVAL_1); + if (its_client.init()) + { + VSOMEIP_INFO << "debounce_client successfully initialized!"; + its_client.start(); + its_client.wait(); + // With a debounce interval of 100 miliseconds, the client is expected to receive a total of about 100-101 messages + // Using limits instead of comparing to one number because CI doesn't always behave as expected + EXPECT_GE(its_client.getNbMsgsRcvd(), 100); + EXPECT_LE(its_client.getNbMsgsRcvd(), 110); + + } + else + { + VSOMEIP_ERROR << "debounce_client could not be initialized!"; + } +} + +TEST(debounce_test, large_interval) +{ + debounce_test_client its_client(DEBOUNCE_INTERVAL_2); + if (its_client.init()) + { + VSOMEIP_INFO << "debounce_client successfully initialized!"; + its_client.start(); + its_client.wait(); + // With a debounce interval of 100 miliseconds, the client is expected to receive a total of about 10-11 messages + // Using limits instead of comparing to one number because CI doesn't always behave as expected + EXPECT_GE(its_client.getNbMsgsRcvd(), 9); + EXPECT_LE(its_client.getNbMsgsRcvd(), 13); + } + else + { + VSOMEIP_ERROR << "debounce_client could not be initialized!"; + } +} + +TEST(debounce_test, disable) +{ + debounce_test_client its_client(DEBOUNCE_INTERVAL_3); + if (its_client.init()) + { + VSOMEIP_INFO << "debounce_client successfully initialized!"; + its_client.start(); + its_client.wait(); + // With a debounce interval disabled (-1), the client is expected to not receive any message + EXPECT_EQ(its_client.getNbMsgsRcvd(), 0); + } + else + { + VSOMEIP_ERROR << "debounce_client could not be initialized!"; + } +} + +int main(int argc, char **argv) +{ + ::testing::InitGoogleTest(&argc, argv); + return RUN_ALL_TESTS(); +} diff --git a/test/network_tests/debounce_filter_tests/debounce_filter_test_client.hpp b/test/network_tests/debounce_filter_tests/debounce_filter_test_client.hpp new file mode 100644 index 000000000..59bf22c49 --- /dev/null +++ b/test/network_tests/debounce_filter_tests/debounce_filter_test_client.hpp @@ -0,0 +1,59 @@ +// Copyright (C) 2023 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 DEBOUNCE_TEST_CLIENT_HPP_ +#define DEBOUNCE_TEST_CLIENT_HPP_ + +#include +#include +#include + +#include + +#include + +#include "debounce_filter_test_common.hpp" + +class debounce_test_client { +public: + debounce_test_client(int64_t _interval); + + bool init(); + void start(); + void stop(); + + void run(); + void wait(); + + int64_t getNbMsgsRcvd(); + +private: + void on_availability( + vsomeip::service_t _service, vsomeip::instance_t _instance, + bool _is_available); + void on_message(const std::shared_ptr &_message); + + void run_test(); + void unsubscribe_all(); + void stop_service(); + +private: + int64_t interval; + size_t index_; + + bool is_available_; + + std::mutex run_mutex_; + std::condition_variable run_condition_; + + std::thread runner_; + std::shared_ptr app_; + + vsomeip::debounce_filter_t dBFilter; + + int64_t nb_msgs_rcvd = 0; +}; + +#endif // DEBOUNCE_TEST_CLIENT_HPP_ diff --git a/test/network_tests/debounce_filter_tests/debounce_filter_test_common.hpp b/test/network_tests/debounce_filter_tests/debounce_filter_test_common.hpp new file mode 100644 index 000000000..79f3c40d2 --- /dev/null +++ b/test/network_tests/debounce_filter_tests/debounce_filter_test_common.hpp @@ -0,0 +1,24 @@ +// Copyright (C) 2023 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 DEBOUNCE_TEST_COMMON_HPP_ +#define DEBOUNCE_TEST_COMMON_HPP_ + +#include + +const vsomeip::service_t DEBOUNCE_SERVICE = 0xb519; +const vsomeip::instance_t DEBOUNCE_INSTANCE = 0x0001; +const vsomeip::method_t DEBOUNCE_START_METHOD = 0x0998; +const vsomeip::method_t DEBOUNCE_STOP_METHOD = 0x0999; +const vsomeip::event_t DEBOUNCE_EVENT = 0x8008; +const vsomeip::eventgroup_t DEBOUNCE_EVENTGROUP = 0x0005; +const vsomeip::major_version_t DEBOUNCE_MAJOR = 0x01; +const vsomeip::minor_version_t DEBOUNCE_MINOR = 0x01; + +const int64_t DEBOUNCE_INTERVAL_1 = 100; +const int64_t DEBOUNCE_INTERVAL_2 = 1000; +const int64_t DEBOUNCE_INTERVAL_3 = -1; + +#endif // DEBOUNCE_TEST_COMMON_HPP_ diff --git a/test/network_tests/debounce_filter_tests/debounce_filter_test_master_starter.sh b/test/network_tests/debounce_filter_tests/debounce_filter_test_master_starter.sh new file mode 100755 index 000000000..62c9b990e --- /dev/null +++ b/test/network_tests/debounce_filter_tests/debounce_filter_test_master_starter.sh @@ -0,0 +1,58 @@ +#!/bin/bash +# Copyright (C) 2023 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/. + +FAIL=0 + +# Cleanup +rm -f /tmp/vsomeip* + +# Exclude external libraries from Thread Sanitizer +export TSAN_OPTIONS="suppressions=tsan-suppressions.txt" + +export VSOMEIP_CONFIGURATION=debounce_filter_test_client.json +../../examples/routingmanagerd/routingmanagerd & +PID_VSOMEIPD=$! + +sleep 1 + +./debounce_filter_test_client & +PID_MASTER=$! + +sleep 1 + +if [ ! -z "$USE_LXC_TEST" ]; then + echo "starting debounce_filter test on slave LXC debounce_filter_test_slave_starter.sh" + ssh -tt -i $SANDBOX_ROOT_DIR/commonapi_main/lxc-config/.ssh/mgc_lxc/rsa_key_file.pub -o StrictHostKeyChecking=no root@$LXC_TEST_SLAVE_IP "bash -ci \"set -m; cd \\\$SANDBOX_TARGET_DIR/vsomeip_lib/test/network_tests; ./debounce_filter_test_slave_starter.sh\"" & +elif [ ! -z "$USE_DOCKER" ]; then + docker exec $DOCKER_IMAGE sh -c "cd $DOCKER_TESTS; sleep 10; ./debounce_filter_test_slave_starter.sh" & +else +cat < + +#include "debounce_filter_test_service.hpp" + +debounce_test_service::debounce_test_service() + : is_running_(true), + runner_(std::bind(&debounce_test_service::run, this)), + app_(vsomeip::runtime::get()->create_application("debounce_test_service")) +{ +} + +bool debounce_test_service::init() +{ + bool is_initialized = app_->init(); + if (is_initialized) + { + app_->register_message_handler( + DEBOUNCE_SERVICE, DEBOUNCE_INSTANCE, DEBOUNCE_START_METHOD, + std::bind(&debounce_test_service::on_start, this, + std::placeholders::_1)); + app_->register_message_handler( + DEBOUNCE_SERVICE, DEBOUNCE_INSTANCE, DEBOUNCE_STOP_METHOD, + std::bind(&debounce_test_service::on_stop, this, + std::placeholders::_1)); + app_->offer_event(DEBOUNCE_SERVICE, DEBOUNCE_INSTANCE, + DEBOUNCE_EVENT, {DEBOUNCE_EVENTGROUP}, + vsomeip::event_type_e::ET_FIELD, + std::chrono::milliseconds::zero(), + false, true, nullptr, + vsomeip::reliability_type_e::RT_UNRELIABLE); + app_->offer_service(DEBOUNCE_SERVICE, DEBOUNCE_INSTANCE, + DEBOUNCE_MAJOR, DEBOUNCE_MINOR); + } + return is_initialized; +} + +void debounce_test_service::start() +{ + app_->start(); +} + +void debounce_test_service::stop() +{ + app_->stop(); +} + +void debounce_test_service::run() +{ + { + std::unique_lock its_lock(run_mutex_); + auto its_result = run_condition_.wait_for( + its_lock, std::chrono::milliseconds(5000)); + if (its_result == std::cv_status::timeout) + return; + } + + start_test(); +} + +void debounce_test_service::wait() +{ + if (runner_.joinable()) + runner_.join(); +} + +void debounce_test_service::on_start( + const std::shared_ptr &) +{ + VSOMEIP_INFO << __func__ << ": Starting test"; + run_condition_.notify_one(); +} + +void debounce_test_service::on_stop( + const std::shared_ptr &) +{ + VSOMEIP_INFO << __func__ << ": Received a STOP command."; + is_running_ = false; + stop(); +} + +void debounce_test_service::start_test() +{ + auto its_payload = vsomeip::runtime::get()->create_payload(); + + for (int i = 0; i <= 1000; i++) + { + its_payload->set_data({0x00, 0x02, 0x03, 0x04, 0x05, 0x06, 0x07}); + app_->notify(DEBOUNCE_SERVICE, DEBOUNCE_INSTANCE, DEBOUNCE_EVENT, its_payload); + std::this_thread::sleep_for(std::chrono::milliseconds(5)); + its_payload->set_data({0x00, 0x02, 0x03, 0x04, 0x05, 0x06, 0x07, 0x08}); + app_->notify(DEBOUNCE_SERVICE, DEBOUNCE_INSTANCE, DEBOUNCE_EVENT, its_payload); + std::this_thread::sleep_for(std::chrono::milliseconds(5)); + } +} + +TEST(debounce_test, normal_interval) +{ + debounce_test_service its_service; + if (its_service.init()) + { + its_service.start(); + its_service.wait(); + } +} + +TEST(debounce_test, large_interval) +{ + debounce_test_service its_service; + if (its_service.init()) + { + its_service.start(); + its_service.wait(); + } +} + +TEST(debounce_test, disable) +{ + debounce_test_service its_service; + if (its_service.init()) + { + its_service.start(); + its_service.wait(); + } +} + +int main(int argc, char **argv) +{ + ::testing::InitGoogleTest(&argc, argv); + return RUN_ALL_TESTS(); +} diff --git a/test/network_tests/debounce_filter_tests/debounce_filter_test_service.hpp b/test/network_tests/debounce_filter_tests/debounce_filter_test_service.hpp new file mode 100644 index 000000000..5275a8395 --- /dev/null +++ b/test/network_tests/debounce_filter_tests/debounce_filter_test_service.hpp @@ -0,0 +1,45 @@ +// Copyright (C) 2023 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 DEBOUNCE_TEST_SERVICE_HPP_ +#define DEBOUNCE_TEST_SERVICE_HPP_ + +#include +#include +#include +#include + +#include + +#include + +#include "debounce_filter_test_common.hpp" + +class debounce_test_service { +public: + debounce_test_service(); + + bool init(); + void start(); + void stop(); + + void run(); + void wait(); + +private: + void on_start(const std::shared_ptr &); + void on_stop(const std::shared_ptr &); + + void start_test(); + + std::mutex run_mutex_; + std::condition_variable run_condition_; + + std::atomic is_running_; + std::thread runner_; + std::shared_ptr app_; +}; + +#endif // DEBOUNCE_TEST_SERVICE_HPP_ diff --git a/test/network_tests/debounce_filter_tests/debounce_filter_test_slave_starter.sh b/test/network_tests/debounce_filter_tests/debounce_filter_test_slave_starter.sh new file mode 100755 index 000000000..13ff13044 --- /dev/null +++ b/test/network_tests/debounce_filter_tests/debounce_filter_test_slave_starter.sh @@ -0,0 +1,37 @@ +#!/bin/bash +# Copyright (C) 2023 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/. + +FAIL=0 + +# Cleanup +rm -f /tmp/vsomeip* + +# Exclude external libraries from Thread Sanitizer +export TSAN_OPTIONS="suppressions=tsan-suppressions.txt" + +export VSOMEIP_CONFIGURATION=debounce_filter_test_service.json +../../examples/routingmanagerd/routingmanagerd & +PID_VSOMEIPD=$! + +sleep 1 + +./debounce_filter_test_service & +PID_SLAVE=$! + +# Wait until all slaves are finished +for job in $PID_SLAVE +do + # Fail gets incremented if a client exits with a non-zero exit code + echo "waiting for $job" + wait $job || FAIL=$(($FAIL+1)) +done + +# kill the services +kill $PID_VSOMEIPD +sleep 3 + +# Check if everything went well +exit $FAIL diff --git a/test/network_tests/debounce_frequency_tests/conf/debounce_frequency_test_client.json.in b/test/network_tests/debounce_frequency_tests/conf/debounce_frequency_test_client.json.in new file mode 100644 index 000000000..ff0969870 --- /dev/null +++ b/test/network_tests/debounce_frequency_tests/conf/debounce_frequency_test_client.json.in @@ -0,0 +1,28 @@ +{ + "unicast": "@TEST_IP_MASTER@", + "debounce": [ + { + "service": "0xb657", + "instance": "0x0003", + "events": [ + { + "event": "0x8001", + "on_change": "false", + "interval": 5000 + }, + { + "event": "0x8002", + "on_change": "false", + "interval": 5000 + } + ] + } + ], + "service-discovery": { + "enable": "true", + "multicast": "224.251.192.252", + "port": "30490", + "protocol": "udp", + "cyclic_offer_delay": "1000" + } +} diff --git a/test/network_tests/debounce_frequency_tests/conf/debounce_frequency_test_service.json.in b/test/network_tests/debounce_frequency_tests/conf/debounce_frequency_test_service.json.in new file mode 100644 index 000000000..29efa708c --- /dev/null +++ b/test/network_tests/debounce_frequency_tests/conf/debounce_frequency_test_service.json.in @@ -0,0 +1,19 @@ +{ + "unicast" : "@TEST_IP_SLAVE@", + "services" : + [ + { + "service" : "0xb657", + "instance" : "0x0003", + "unreliable" : "30503" + } + ], + "service-discovery" : + { + "enable" : "true", + "multicast" : "224.251.192.252", + "port" : "30490", + "protocol" : "udp", + "cyclic_offer_delay" : "1000" + } +} diff --git a/test/network_tests/debounce_frequency_tests/debounce_frequency_test_client.cpp b/test/network_tests/debounce_frequency_tests/debounce_frequency_test_client.cpp new file mode 100644 index 000000000..2baa1ec3f --- /dev/null +++ b/test/network_tests/debounce_frequency_tests/debounce_frequency_test_client.cpp @@ -0,0 +1,133 @@ +// Copyright (C) 2023 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/. + +#include +#include + +#include + +#include "debounce_frequency_test_client.hpp" + + +// Flag the desired event availability +void test_client::on_availability(vsomeip::service_t service_, vsomeip::instance_t instance_, + bool _is_available) +{ + if (_is_available && service_ == DEBOUNCE_SERVICE && instance_ == DEBOUNCE_INSTANCE) { + std::unique_lock lk(mutex); + availability = true; + condition_availability.notify_one(); + } +} + +// When a message is received, verify if it is one of the required events +void test_client::on_message(const std::shared_ptr &_message) +{ + if (DEBOUNCE_SERVICE == _message->get_service() && DEBOUNCE_EVENT == _message->get_method()) { + std::unique_lock lk(event_counter_mutex); + event_1_recv_messages++; + return; + } + if (DEBOUNCE_SERVICE == _message->get_service() && DEBOUNCE_EVENT_2 == _message->get_method()) { + std::unique_lock lk(event_counter_mutex); + event_2_recv_messages++; + return; + } +} + +test_client::test_client(const char *app_name_, const char *app_id_) : vsomeip_utilities::base_vsip_app(app_name_, app_id_) +{ + _app->register_availability_handler(DEBOUNCE_SERVICE, DEBOUNCE_INSTANCE, + std::bind(&test_client::on_availability, this, + std::placeholders::_1, std::placeholders::_2, + std::placeholders::_3), + DEBOUNCE_MAJOR, DEBOUNCE_MINOR); + _app->register_message_handler(DEBOUNCE_SERVICE, DEBOUNCE_INSTANCE, vsomeip::ANY_EVENT, + std::bind(&test_client::on_message, this, std::placeholders::_1)); + _app->request_event(DEBOUNCE_SERVICE, DEBOUNCE_INSTANCE, DEBOUNCE_EVENT, { DEBOUNCE_EVENTGROUP }, + vsomeip::event_type_e::ET_FIELD, vsomeip::reliability_type_e::RT_UNRELIABLE); + _app->request_event(DEBOUNCE_SERVICE, DEBOUNCE_INSTANCE, DEBOUNCE_EVENT_2, + { DEBOUNCE_EVENTGROUP }, vsomeip::event_type_e::ET_FIELD, + vsomeip::reliability_type_e::RT_UNRELIABLE); + _app->request_service(DEBOUNCE_SERVICE, DEBOUNCE_INSTANCE, DEBOUNCE_MAJOR, DEBOUNCE_MINOR); + _app->subscribe(DEBOUNCE_SERVICE, DEBOUNCE_INSTANCE, DEBOUNCE_EVENTGROUP, DEBOUNCE_MAJOR, + DEBOUNCE_EVENT); + _app->subscribe(DEBOUNCE_SERVICE, DEBOUNCE_INSTANCE, DEBOUNCE_EVENTGROUP, DEBOUNCE_MAJOR, + DEBOUNCE_EVENT_2); +} + +int test_client::was_event1_recv() +{ + std::unique_lock lk(event_counter_mutex); + + return event_1_recv_messages; +} + +int test_client::was_event2_recv() +{ + std::unique_lock lk(event_counter_mutex); + + return event_2_recv_messages; +} + +void test_client::send_request() +{ + std::unique_lock lk(mutex); + // Only send the requests when the service availability is secured + if (condition_availability.wait_for(lk, std::chrono::milliseconds(15000), + [=] { return availability; })) { + + // Trigger the test + auto its_message = vsomeip_utilities::create_standard_vsip_request( + DEBOUNCE_SERVICE, DEBOUNCE_INSTANCE, DEBOUNCE_START_METHOD, DEBOUNCE_MAJOR, + vsomeip::message_type_e::MT_REQUEST_NO_RETURN); + _app->send(its_message); + } + + EXPECT_TRUE(availability) + << "Events expected by the client were not available for 15 seconds "; + + // Wait for Server to send all the messages + std::this_thread::sleep_for(std::chrono::seconds(10)); +} + +void test_client::unsubscribe_all() +{ + _app->unsubscribe(DEBOUNCE_SERVICE, DEBOUNCE_INSTANCE, DEBOUNCE_EVENTGROUP); +} + +void test_client::stop_service() +{ + auto its_message = vsomeip_utilities::create_standard_vsip_request(DEBOUNCE_SERVICE, DEBOUNCE_INSTANCE, + DEBOUNCE_STOP_METHOD, DEBOUNCE_MAJOR, + vsomeip::message_type_e::MT_REQUEST_NO_RETURN); + _app->send(its_message); +} + +test_client::~test_client() +{ + unsubscribe_all(); + stop_service(); +} + +TEST(debounce_frequency_test, client) +{ + test_client debounce_client("debounce_frequency_test_client","DFTC"); + // Request the server to send the test messages + debounce_client.send_request(); + + ASSERT_EQ(debounce_client.was_event1_recv(), 1) + << "Event 1 expected to be received once by the client, instead it was received " + << debounce_client.was_event1_recv() << " times."; + ASSERT_EQ(debounce_client.was_event2_recv(), 1) + << "Event 2 expected to be received once by the client, instead it was received " + << debounce_client.was_event2_recv() << " times."; +} + +int main(int argc, char **argv) +{ + ::testing::InitGoogleTest(&argc, argv); + return RUN_ALL_TESTS(); +} diff --git a/test/network_tests/debounce_frequency_tests/debounce_frequency_test_client.hpp b/test/network_tests/debounce_frequency_tests/debounce_frequency_test_client.hpp new file mode 100644 index 000000000..9911c9178 --- /dev/null +++ b/test/network_tests/debounce_frequency_tests/debounce_frequency_test_client.hpp @@ -0,0 +1,47 @@ +// Copyright (C) 2023 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 DEBOUNCE_FREQUENCY_TEST_CLIENT_HPP_ +#define DEBOUNCE_FREQUENCY_TEST_CLIENT_HPP_ + +#include +#include +#include + +#include + +#include + +#include "debounce_frequency_test_common.hpp" +#include + +class test_client : public vsomeip_utilities::base_vsip_app +{ + +private: + std::condition_variable condition_availability; + std::mutex mutex; + std::mutex event_counter_mutex; + bool availability { false }; + + int event_1_recv_messages { 0 }; + int event_2_recv_messages { 0 }; + + void on_availability(vsomeip::service_t service_, vsomeip::instance_t instance_, + bool _is_available); + void on_message(const std::shared_ptr &_message); + void stop_service(); + void unsubscribe_all(); + +public: + test_client(const char *app_name_, const char *app_id_); + + int was_event1_recv(); + int was_event2_recv(); + void send_request(); + ~test_client(); +}; + +#endif // DEBOUNCE_FREQUENCY_TEST_CLIENT_HPP_ diff --git a/test/network_tests/debounce_frequency_tests/debounce_frequency_test_common.hpp b/test/network_tests/debounce_frequency_tests/debounce_frequency_test_common.hpp new file mode 100644 index 000000000..2531929dd --- /dev/null +++ b/test/network_tests/debounce_frequency_tests/debounce_frequency_test_common.hpp @@ -0,0 +1,25 @@ +// Copyright (C) 2023 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 DEBOUNCE_FREQUENCY_TEST_COMMON_HPP_ +#define DEBOUNCE_FREQUENCY_TEST_COMMON_HPP_ + +#include + +const vsomeip::service_t DEBOUNCE_SERVICE = 0xb657; +const vsomeip::instance_t DEBOUNCE_INSTANCE = 0x0003; +const vsomeip::method_t DEBOUNCE_START_METHOD = 0x0998; +const vsomeip::method_t DEBOUNCE_STOP_METHOD = 0x0999; +const vsomeip::event_t DEBOUNCE_EVENT = 0x8001; +const vsomeip::event_t DEBOUNCE_EVENT_2 = 0x8002; +const vsomeip::eventgroup_t DEBOUNCE_EVENTGROUP = 0x0005; +const vsomeip::major_version_t DEBOUNCE_MAJOR = 0x01; +const vsomeip::minor_version_t DEBOUNCE_MINOR = 0x01; + +enum debounce_frequency_test_id_e : uint8_t { + DTI_FLAT = 0x00, +}; + +#endif // DEBOUNCE_FREQUENCY_TEST_COMMON_HPP_ diff --git a/test/network_tests/debounce_frequency_tests/debounce_frequency_test_master_starter.sh b/test/network_tests/debounce_frequency_tests/debounce_frequency_test_master_starter.sh new file mode 100755 index 000000000..92dd8cd94 --- /dev/null +++ b/test/network_tests/debounce_frequency_tests/debounce_frequency_test_master_starter.sh @@ -0,0 +1,52 @@ +#!/bin/bash +# Copyright (C) 2023 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/. + +FAIL=0 + +export VSOMEIP_CONFIGURATION=debounce_frequency_test_client.json +../../examples/routingmanagerd/routingmanagerd & +PID_VSOMEIPD=$! + +sleep 1 + +./debounce_frequency_test_client & +PID_MASTER=$! + +sleep 1 + +if [ ! -z "$USE_LXC_TEST" ]; then + echo "starting debounce test on slave LXC debounce_frequency_test_slave_starter.sh" + ssh -tt -i $SANDBOX_ROOT_DIR/commonapi_main/lxc-config/.ssh/mgc_lxc/rsa_key_file.pub -o StrictHostKeyChecking=no root@$LXC_TEST_SLAVE_IP "bash -ci \"set -m; cd \\\$SANDBOX_TARGET_DIR/vsomeip_lib/test/network_tests; ./debounce_frequency_test_slave_starter.sh\"" & +elif [ ! -z "$USE_DOCKER" ]; then + docker exec $DOCKER_IMAGE sh -c "cd $DOCKER_TESTS; sleep 10; ./debounce_frequency_test_slave_starter.sh" & +else +cat < +#include "debounce_frequency_test_service.hpp" + +uint64_t elapsedMilliseconds(const std::chrono::time_point &_start_time) +{ + return std::chrono::duration_cast(std::chrono::system_clock::now() + - _start_time).count(); +} + +void test_service::on_start(const std::shared_ptr /*&_message*/) +{ + std::unique_lock lk(mutex); + received_message = true; + condition_wait_start.notify_one(); +} + +void test_service::on_stop(const std::shared_ptr /*&_message*/) +{ + VSOMEIP_INFO << "service: " << __func__ << ": Received a STOP command."; +} + +test_service::test_service(const char *app_name_, const char *app_id_) : vsomeip_utilities::base_vsip_app(app_name_,app_id_) +{ + _app->register_message_handler(DEBOUNCE_SERVICE, DEBOUNCE_INSTANCE, DEBOUNCE_START_METHOD, + std::bind(&test_service::on_start, this, std::placeholders::_1)); + _app->register_message_handler(DEBOUNCE_SERVICE, DEBOUNCE_INSTANCE, DEBOUNCE_STOP_METHOD, + std::bind(&test_service::on_stop, this, std::placeholders::_1)); + _app->offer_event(DEBOUNCE_SERVICE, DEBOUNCE_INSTANCE, DEBOUNCE_EVENT, { DEBOUNCE_EVENTGROUP }, + vsomeip::event_type_e::ET_FIELD, std::chrono::milliseconds::zero(), false, + true, nullptr, vsomeip::reliability_type_e::RT_UNRELIABLE); + _app->offer_event(DEBOUNCE_SERVICE, DEBOUNCE_INSTANCE, DEBOUNCE_EVENT_2, { DEBOUNCE_EVENTGROUP }, + vsomeip::event_type_e::ET_FIELD, std::chrono::milliseconds::zero(), false, + true, nullptr, vsomeip::reliability_type_e::RT_UNRELIABLE); + _app->offer_service(DEBOUNCE_SERVICE, DEBOUNCE_INSTANCE, DEBOUNCE_MAJOR, DEBOUNCE_MINOR); +} + +// Send the debounce events with different frequencies, but configured with the same debounce time +void test_service::send_messages() +{ + std::unique_lock lk(mutex); + if (condition_wait_start.wait_for(lk, std::chrono::milliseconds(2000), + [=] { return received_message; })) { + + VSOMEIP_INFO << "service: " << __func__ << ": Starting test "; + start_time = std::chrono::system_clock::now(); + uint8_t i = 0; + while (elapsedMilliseconds(start_time) < 3000) { + + if (elapsedMilliseconds(start_time) % 30 == 0) { + auto its_payload = vsomeip::runtime::get()->create_payload(); + its_payload->set_data({ 0x00, 0x02, 0x03, 0x04, 0x05, 0x06, i++ }); + + _app->notify(DEBOUNCE_SERVICE, DEBOUNCE_INSTANCE, DEBOUNCE_EVENT, its_payload); + event_1_sent_messages = true; + } + + if (elapsedMilliseconds(start_time) % 2 == 0) { + auto its_payload = vsomeip::runtime::get()->create_payload(); + its_payload->set_data({ 0x00, 0x02, 0x03, 0x04, 0x05, 0x06, i++ }); + _app->notify(DEBOUNCE_SERVICE, DEBOUNCE_INSTANCE, DEBOUNCE_EVENT_2, its_payload); + event_2_sent_messages = true; + } + + std::this_thread::sleep_for(std::chrono::milliseconds(1)); + } + } +} + +bool test_service::was_event_1_sent() +{ + return event_1_sent_messages; +} + +bool test_service::was_event_2_sent() +{ + return event_2_sent_messages; +} + +TEST(debounce_frequency_test, server) +{ + test_service debounce_server("debounce_frequency_test_service", "DFTS"); + debounce_server.send_messages(); + + EXPECT_TRUE(debounce_server.was_event_1_sent()) << "Event 1 was not sent by the service"; + EXPECT_TRUE(debounce_server.was_event_2_sent()) << "Event 2 was not sent by the service"; +} + +int main(int argc, char **argv) +{ + ::testing::InitGoogleTest(&argc, argv); + return RUN_ALL_TESTS(); +} diff --git a/test/network_tests/debounce_frequency_tests/debounce_frequency_test_service.hpp b/test/network_tests/debounce_frequency_tests/debounce_frequency_test_service.hpp new file mode 100644 index 000000000..78939f341 --- /dev/null +++ b/test/network_tests/debounce_frequency_tests/debounce_frequency_test_service.hpp @@ -0,0 +1,42 @@ +// Copyright (C) 2023 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 DEBOUNCE_FREQUENCY_TEST_SERVICE_HPP_ +#define DEBOUNCE_FREQUENCY_TEST_SERVICE_HPP_ + +#include +#include +#include +#include + +#include + +#include + +#include "debounce_frequency_test_common.hpp" +#include + +class test_service : public vsomeip_utilities::base_vsip_app +{ +private: + std::condition_variable condition_wait_start; + std::mutex mutex; + bool received_message { false }; + std::chrono::time_point start_time; + bool event_1_sent_messages { false }; + bool event_2_sent_messages { false }; + + void on_start(const std::shared_ptr /*&_message*/); + void on_stop(const std::shared_ptr /*&_message*/); + +public: + test_service(const char *app_name_, const char *app_id_); + + void send_messages(); + bool was_event_1_sent(); + bool was_event_2_sent(); +}; + +#endif // debounce_frequency_test_SERVICE_HPP_ diff --git a/test/network_tests/debounce_frequency_tests/debounce_frequency_test_slave_starter.sh b/test/network_tests/debounce_frequency_tests/debounce_frequency_test_slave_starter.sh new file mode 100755 index 000000000..ae3343328 --- /dev/null +++ b/test/network_tests/debounce_frequency_tests/debounce_frequency_test_slave_starter.sh @@ -0,0 +1,26 @@ +#!/bin/bash +# Copyright (C) 2023 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/. + +FAIL=0 + +export VSOMEIP_CONFIGURATION=debounce_frequency_test_service.json +../../examples/routingmanagerd/routingmanagerd & +PID_VSOMEIPD=$! + +sleep 1 + +if ! ./debounce_frequency_test_service +then + # Fail gets incremented if a client exits with a non-zero exit code + FAIL=$(($FAIL+1)) +fi + +# kill the services +kill $PID_VSOMEIPD +sleep 3 + +# Check if everything went well +exit $FAIL diff --git a/test/network_tests/debounce_tests/conf/debounce_test_client.json.in b/test/network_tests/debounce_tests/conf/debounce_test_client.json.in index fd83c036d..e81836e7a 100644 --- a/test/network_tests/debounce_tests/conf/debounce_test_client.json.in +++ b/test/network_tests/debounce_tests/conf/debounce_test_client.json.in @@ -28,8 +28,8 @@ "on_change" : "true", "ignore" : [ - { - "index" : "0", + { + "index" : "0", "mask" : "0x0f" }, { @@ -37,11 +37,11 @@ "mask" : "0xfe" } ] - } + } ] } ], - "service-discovery" : + "service-discovery" : { "enable" : "true", "multicast" : "224.251.192.252", @@ -49,4 +49,4 @@ "protocol" : "udp", "cyclic_offer_delay" : "1000" } -} \ No newline at end of file +} diff --git a/test/network_tests/debounce_tests/conf/debounce_test_service.json.in b/test/network_tests/debounce_tests/conf/debounce_test_service.json.in index 48d1931d9..29efa708c 100644 --- a/test/network_tests/debounce_tests/conf/debounce_test_service.json.in +++ b/test/network_tests/debounce_tests/conf/debounce_test_service.json.in @@ -8,7 +8,7 @@ "unreliable" : "30503" } ], - "service-discovery" : + "service-discovery" : { "enable" : "true", "multicast" : "224.251.192.252", @@ -16,4 +16,4 @@ "protocol" : "udp", "cyclic_offer_delay" : "1000" } -} \ No newline at end of file +} diff --git a/test/network_tests/debounce_tests/debounce_test_client.cpp b/test/network_tests/debounce_tests/debounce_test_client.cpp index 5b702cfeb..5927300c4 100644 --- a/test/network_tests/debounce_tests/debounce_test_client.cpp +++ b/test/network_tests/debounce_tests/debounce_test_client.cpp @@ -127,6 +127,8 @@ debounce_test_client::on_availability( run_condition_.notify_one(); } else { VSOMEIP_ERROR << __func__ << ": Debounce service becomes unavailable."; + + std::lock_guard its_lock(run_mutex_); is_available_ = false; } } diff --git a/test/network_tests/e2e_tests/conf/e2e_profile_04_test_client_external.json.in b/test/network_tests/e2e_tests/conf/e2e_profile_04_test_client_external.json.in index 695245979..9fec0db05 100644 --- a/test/network_tests/e2e_tests/conf/e2e_profile_04_test_client_external.json.in +++ b/test/network_tests/e2e_tests/conf/e2e_profile_04_test_client_external.json.in @@ -6,7 +6,7 @@ "level" : "info", "console" : "true", "file" : { "enable" : "false", "path" : "/tmp/vsomeip.log" }, - "dlt" : "false" + "dlt" : "true" }, "applications" : [ diff --git a/test/network_tests/e2e_tests/conf/e2e_profile_04_test_service_external.json.in b/test/network_tests/e2e_tests/conf/e2e_profile_04_test_service_external.json.in index efeffef18..5ef256d1d 100644 --- a/test/network_tests/e2e_tests/conf/e2e_profile_04_test_service_external.json.in +++ b/test/network_tests/e2e_tests/conf/e2e_profile_04_test_service_external.json.in @@ -6,7 +6,7 @@ "level" : "info", "console" : "true", "file" : { "enable" : "false", "path" : "/tmp/vsomeip.log" }, - "dlt" : "false" + "dlt" : "true" }, "applications" : [ diff --git a/test/network_tests/e2e_tests/conf/e2e_test_client_external.json.in b/test/network_tests/e2e_tests/conf/e2e_test_client_external.json.in index d00c4bf82..77bfa32a3 100644 --- a/test/network_tests/e2e_tests/conf/e2e_test_client_external.json.in +++ b/test/network_tests/e2e_tests/conf/e2e_test_client_external.json.in @@ -6,7 +6,7 @@ "level" : "info", "console" : "true", "file" : { "enable" : "false", "path" : "/tmp/vsomeip.log" }, - "dlt" : "false" + "dlt" : "true" }, "applications" : [ diff --git a/test/network_tests/e2e_tests/conf/e2e_test_service_external.json.in b/test/network_tests/e2e_tests/conf/e2e_test_service_external.json.in index d2b8e0409..cb69f2b53 100644 --- a/test/network_tests/e2e_tests/conf/e2e_test_service_external.json.in +++ b/test/network_tests/e2e_tests/conf/e2e_test_service_external.json.in @@ -6,7 +6,7 @@ "level" : "info", "console" : "true", "file" : { "enable" : "false", "path" : "/tmp/vsomeip.log" }, - "dlt" : "false" + "dlt" : "true" }, "applications" : [ diff --git a/test/network_tests/e2e_tests/e2e_profile_04_test_service.cpp b/test/network_tests/e2e_tests/e2e_profile_04_test_service.cpp index 32c44f5fb..efd48c906 100644 --- a/test/network_tests/e2e_tests/e2e_profile_04_test_service.cpp +++ b/test/network_tests/e2e_tests/e2e_profile_04_test_service.cpp @@ -1,4 +1,4 @@ -// Copyright (C) 2020 Bayerische Motoren Werke Aktiengesellschaft (BMW AG) +// Copyright (C) 2023 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/. diff --git a/test/network_tests/e2e_tests/e2e_profile_04_test_service.hpp b/test/network_tests/e2e_tests/e2e_profile_04_test_service.hpp index 626db0545..256179179 100644 --- a/test/network_tests/e2e_tests/e2e_profile_04_test_service.hpp +++ b/test/network_tests/e2e_tests/e2e_profile_04_test_service.hpp @@ -1,4 +1,4 @@ -// Copyright (C) 2020 Bayerische Motoren Werke Aktiengesellschaft (BMW AG) +// Copyright (C) 2023 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/. @@ -11,6 +11,7 @@ #include #include "../someip_test_globals.hpp" +#include #include #include diff --git a/test/network_tests/e2e_tests/e2e_test_client.hpp b/test/network_tests/e2e_tests/e2e_test_client.hpp index 378263cdd..10f49784b 100644 --- a/test/network_tests/e2e_tests/e2e_test_client.hpp +++ b/test/network_tests/e2e_tests/e2e_test_client.hpp @@ -1,5 +1,5 @@ -// Copyright (C) 2015-2017 Bayerische Motoren Werke Aktiengesellschaft (BMW AG) +// Copyright (C) 2015-2023 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/. @@ -12,6 +12,7 @@ #include #include "../someip_test_globals.hpp" +#include #include #include diff --git a/test/network_tests/e2e_tests/e2e_test_service.cpp b/test/network_tests/e2e_tests/e2e_test_service.cpp index 236cfc8ca..46e57ae4e 100644 --- a/test/network_tests/e2e_tests/e2e_test_service.cpp +++ b/test/network_tests/e2e_tests/e2e_test_service.cpp @@ -1,4 +1,4 @@ -// Copyright (C) 2017 Bayerische Motoren Werke Aktiengesellschaft (BMW AG) +// Copyright (C) 2023 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/. diff --git a/test/network_tests/e2e_tests/e2e_test_service.hpp b/test/network_tests/e2e_tests/e2e_test_service.hpp index f7f2b96da..7fd1c5a9e 100644 --- a/test/network_tests/e2e_tests/e2e_test_service.hpp +++ b/test/network_tests/e2e_tests/e2e_test_service.hpp @@ -1,4 +1,4 @@ -// Copyright (C) 2015-2017 Bayerische Motoren Werke Aktiengesellschaft (BMW AG) +// Copyright (C) 2015-2023 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/. @@ -11,6 +11,7 @@ #include #include "../someip_test_globals.hpp" +#include #include #include diff --git a/test/network_tests/event_tests/conf/event_test_master.json.in b/test/network_tests/event_tests/conf/event_test_master.json.in index b8db14faa..effa3e9a3 100644 --- a/test/network_tests/event_tests/conf/event_test_master.json.in +++ b/test/network_tests/event_tests/conf/event_test_master.json.in @@ -9,7 +9,7 @@ "enable":"false", "path":"/tmp/vsomeip.log" }, - "dlt":"false" + "dlt":"true" }, "applications" : [ @@ -29,4 +29,4 @@ "cyclic_offer_delay" : "1000", "ttl" : "3" } -} \ No newline at end of file +} diff --git a/test/network_tests/event_tests/conf/event_test_slave_tcp.json.in b/test/network_tests/event_tests/conf/event_test_slave_tcp.json.in index d0bbed98a..a0c97c61e 100644 --- a/test/network_tests/event_tests/conf/event_test_slave_tcp.json.in +++ b/test/network_tests/event_tests/conf/event_test_slave_tcp.json.in @@ -9,7 +9,7 @@ "enable":"false", "path":"/tmp/vsomeip.log" }, - "dlt":"false" + "dlt":"true" }, "applications" : [ @@ -40,4 +40,4 @@ "cyclic_offer_delay" : "1000", "ttl" : "3" } -} \ No newline at end of file +} diff --git a/test/network_tests/event_tests/conf/event_test_slave_udp.json.in b/test/network_tests/event_tests/conf/event_test_slave_udp.json.in index 6bf693b48..c0610680c 100644 --- a/test/network_tests/event_tests/conf/event_test_slave_udp.json.in +++ b/test/network_tests/event_tests/conf/event_test_slave_udp.json.in @@ -9,7 +9,7 @@ "enable":"false", "path":"/tmp/vsomeip.log" }, - "dlt":"false" + "dlt":"true" }, "applications" : [ @@ -37,4 +37,4 @@ "cyclic_offer_delay" : "1000", "ttl" : "3" } -} \ No newline at end of file +} diff --git a/test/network_tests/event_tests/event_test_client.cpp b/test/network_tests/event_tests/event_test_client.cpp index 2474bb442..9feb68684 100644 --- a/test/network_tests/event_tests/event_test_client.cpp +++ b/test/network_tests/event_tests/event_test_client.cpp @@ -1,4 +1,4 @@ -// Copyright (C) 2014-2018 Bayerische Motoren Werke Aktiengesellschaft (BMW AG) +// Copyright (C) 2014-2023 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/. @@ -19,11 +19,14 @@ #include #include "event_test_globals.hpp" +#include "../someip_test_globals.hpp" +#include -class event_test_client { +class event_test_client : public vsomeip_utilities::base_logger { public: event_test_client(struct event_test::service_info _service_info, event_test::test_mode_e _mode, bool _use_tcp) : + vsomeip_utilities::base_logger("EVTC", "EVENT TEST CLIENT"), service_info_(_service_info), test_mode_(_mode), use_tcp_(_use_tcp), diff --git a/test/network_tests/event_tests/event_test_service.cpp b/test/network_tests/event_tests/event_test_service.cpp index 099b2b511..3728a8276 100644 --- a/test/network_tests/event_tests/event_test_service.cpp +++ b/test/network_tests/event_tests/event_test_service.cpp @@ -1,4 +1,4 @@ -// Copyright (C) 2014-2018 Bayerische Motoren Werke Aktiengesellschaft (BMW AG) +// Copyright (C) 2014-2023 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/. @@ -17,10 +17,13 @@ #include #include "event_test_globals.hpp" +#include "../someip_test_globals.hpp" +#include -class event_test_service { +class event_test_service : public vsomeip_utilities::base_logger { public: event_test_service(struct event_test::service_info _service_info, bool _use_tcp) : + vsomeip_utilities::base_logger("EVTS", "EVENT TEST SERVICE"), service_info_(_service_info), test_mode_(event_test::test_mode_e::UNKNOWN), app_(vsomeip::runtime::get()->create_application("event_test_service")), diff --git a/test/network_tests/event_tests/event_test_slave_starter.sh b/test/network_tests/event_tests/event_test_slave_starter.sh index c1bd48985..65e92b3e4 100755 --- a/test/network_tests/event_tests/event_test_slave_starter.sh +++ b/test/network_tests/event_tests/event_test_slave_starter.sh @@ -21,7 +21,6 @@ elif [ "$COMMUNICATIONMODE" = "UDP" ]; then export VSOMEIP_CONFIGURATION=event_test_slave_udp.json fi - ../../examples/routingmanagerd/./routingmanagerd & PID_VSOMEIPD=$! diff --git a/test/network_tests/header_factory_tests/header_factory_test.cpp b/test/network_tests/header_factory_tests/header_factory_test.cpp index 14865cb25..fd780ffe3 100644 --- a/test/network_tests/header_factory_tests/header_factory_test.cpp +++ b/test/network_tests/header_factory_tests/header_factory_test.cpp @@ -1,4 +1,4 @@ -// Copyright (C) 2015-2017 Bayerische Motoren Werke Aktiengesellschaft (BMW AG) +// Copyright (C) 2015-2023 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/. @@ -8,6 +8,7 @@ #include #include "../someip_test_globals.hpp" +#include class someip_header_factory_test: public ::testing::Test { diff --git a/test/network_tests/header_factory_tests/header_factory_test_client.cpp b/test/network_tests/header_factory_tests/header_factory_test_client.cpp index c653f8a80..13b1111ed 100644 --- a/test/network_tests/header_factory_tests/header_factory_test_client.cpp +++ b/test/network_tests/header_factory_tests/header_factory_test_client.cpp @@ -1,4 +1,4 @@ -// Copyright (C) 2015-2017 Bayerische Motoren Werke Aktiengesellschaft (BMW AG) +// Copyright (C) 2015-2023 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/. diff --git a/test/network_tests/header_factory_tests/header_factory_test_client.hpp b/test/network_tests/header_factory_tests/header_factory_test_client.hpp index 8e9a4c266..79461b696 100644 --- a/test/network_tests/header_factory_tests/header_factory_test_client.hpp +++ b/test/network_tests/header_factory_tests/header_factory_test_client.hpp @@ -1,4 +1,4 @@ -// Copyright (C) 2015-2017 Bayerische Motoren Werke Aktiengesellschaft (BMW AG) +// Copyright (C) 2015-2023 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/. @@ -16,6 +16,7 @@ #include #include "../someip_test_globals.hpp" +#include class header_factory_test_client { diff --git a/test/network_tests/header_factory_tests/header_factory_test_client.json b/test/network_tests/header_factory_tests/header_factory_test_client.json index 71bc75bb8..601cd5535 100644 --- a/test/network_tests/header_factory_tests/header_factory_test_client.json +++ b/test/network_tests/header_factory_tests/header_factory_test_client.json @@ -1,11 +1,11 @@ { "unicast" : "127.0.0.1", "netmask" : "255.255.255.0", - "logging" : + "logging" : { "level" : "debug", "console" : "true", - "file" : + "file" : { "enable" : "true", "path" : "/var/log/vsomeip.log" @@ -14,20 +14,20 @@ "dlt" : "true" }, - "applications" : + "applications" : [ { "name" : "header_factory_test_client", "id" : "0x1343" } ], - "services" : + "services" : [ { "service" : "0x1234", "instance" : "0x5678", "unreliable" : "30509", - "events" : + "events" : [ { "event" : "0x0777", @@ -45,11 +45,11 @@ } ], - "eventgroups" : + "eventgroups" : [ { "eventgroup" : "0x4455", - "events" : + "events" : [ "0x777", "0x778" @@ -58,7 +58,7 @@ { "eventgroup" : "0x4465", - "events" : + "events" : [ "0x778", "0x779" @@ -69,7 +69,7 @@ { "eventgroup" : "0x4555", - "events" : + "events" : [ "0x777", "0x779" @@ -80,7 +80,7 @@ ], "routing" : "header_factory_test_service", - "service-discovery" : + "service-discovery" : { "enable" : "false", "multicast" : "224.0.0.1", @@ -94,4 +94,4 @@ "cyclic_offer_delay" : "2000", "request_response_delay" : "1500" } -} \ No newline at end of file +} diff --git a/test/network_tests/header_factory_tests/header_factory_test_client_start.sh b/test/network_tests/header_factory_tests/header_factory_test_client_start.sh index 4e9c1edf1..9fa50826c 100755 --- a/test/network_tests/header_factory_tests/header_factory_test_client_start.sh +++ b/test/network_tests/header_factory_tests/header_factory_test_client_start.sh @@ -3,6 +3,7 @@ # 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/. + export VSOMEIP_APPLICATION_NAME=header_factory_test_client export VSOMEIP_CONFIGURATION=header_factory_test_client.json ./header_factory_test_client diff --git a/test/network_tests/header_factory_tests/header_factory_test_service.cpp b/test/network_tests/header_factory_tests/header_factory_test_service.cpp index 742b30db8..d647fd9b3 100644 --- a/test/network_tests/header_factory_tests/header_factory_test_service.cpp +++ b/test/network_tests/header_factory_tests/header_factory_test_service.cpp @@ -1,4 +1,4 @@ -// Copyright (C) 2015-2017 Bayerische Motoren Werke Aktiengesellschaft (BMW AG) +// Copyright (C) 2015-2023 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/. diff --git a/test/network_tests/header_factory_tests/header_factory_test_service.hpp b/test/network_tests/header_factory_tests/header_factory_test_service.hpp index 32e49e568..7879946ac 100644 --- a/test/network_tests/header_factory_tests/header_factory_test_service.hpp +++ b/test/network_tests/header_factory_tests/header_factory_test_service.hpp @@ -1,4 +1,4 @@ -// Copyright (C) 2015-2017 Bayerische Motoren Werke Aktiengesellschaft (BMW AG) +// Copyright (C) 2015-2023 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/. @@ -15,6 +15,7 @@ #include #include "../someip_test_globals.hpp" +#include class header_factory_test_service { diff --git a/test/network_tests/header_factory_tests/header_factory_test_service.json b/test/network_tests/header_factory_tests/header_factory_test_service.json index a99d0a2f6..f011629ab 100644 --- a/test/network_tests/header_factory_tests/header_factory_test_service.json +++ b/test/network_tests/header_factory_tests/header_factory_test_service.json @@ -1,18 +1,18 @@ { "unicast" : "127.0.0.1", - "logging" : + "logging" : { "level" : "debug", "console" : "true", - "file" : + "file" : { "enable" : "false", "path" : "/tmp/vsomeip.log" }, - "dlt" : "false" + "dlt" : "true" }, - "applications" : + "applications" : [ { "name" : "header_factory_test_service", @@ -20,19 +20,19 @@ } ], - "services" : + "services" : [ { "service" : "0x1234", "instance" : "0x5678", "unreliable" : "30509", - "multicast" : + "multicast" : { "address" : "224.225.226.233", "port" : "32344" }, - "events" : + "events" : [ { "event" : "0x0777", @@ -52,11 +52,11 @@ } ], - "eventgroups" : + "eventgroups" : [ { "eventgroup" : "0x4455", - "events" : + "events" : [ "0x777", "0x778" @@ -65,10 +65,10 @@ { "eventgroup" : "0x4465", - "events" : - [ - "0x778", - "0x779" + "events" : + [ + "0x778", + "0x779" ], "is_multicast" : "true" @@ -76,19 +76,19 @@ { "eventgroup" : "0x4555", - "events" : + "events" : [ "0x777", - "0x779" + "0x779" ] } ] } - ], + ], "routing" : "header_factory_test_service", - "service-discovery" : + "service-discovery" : { "enable" : "false", "multicast" : "224.0.0.1", @@ -102,4 +102,4 @@ "cyclic_offer_delay" : "2000", "request_response_delay" : "1500" } -} \ No newline at end of file +} diff --git a/test/network_tests/initial_event_tests/conf/initial_event_test_diff_client_ids_diff_ports_master.json.in b/test/network_tests/initial_event_tests/conf/initial_event_test_diff_client_ids_diff_ports_master.json.in index d7b5c7be1..a8c17d264 100644 --- a/test/network_tests/initial_event_tests/conf/initial_event_test_diff_client_ids_diff_ports_master.json.in +++ b/test/network_tests/initial_event_tests/conf/initial_event_test_diff_client_ids_diff_ports_master.json.in @@ -9,7 +9,7 @@ "enable":"false", "path":"/tmp/vsomeip.log" }, - "dlt":"false" + "dlt":"true" }, "applications": [ @@ -78,4 +78,4 @@ "cyclic_offer_delay" : "1000", "ttl" : "3" } -} \ No newline at end of file +} diff --git a/test/network_tests/initial_event_tests/conf/initial_event_test_diff_client_ids_diff_ports_master_tcp.json.in b/test/network_tests/initial_event_tests/conf/initial_event_test_diff_client_ids_diff_ports_master_tcp.json.in index a05d13f7a..fb7b8ca69 100644 --- a/test/network_tests/initial_event_tests/conf/initial_event_test_diff_client_ids_diff_ports_master_tcp.json.in +++ b/test/network_tests/initial_event_tests/conf/initial_event_test_diff_client_ids_diff_ports_master_tcp.json.in @@ -9,7 +9,7 @@ "enable":"false", "path":"/tmp/vsomeip.log" }, - "dlt":"false" + "dlt":"true" }, "applications": [ diff --git a/test/network_tests/initial_event_tests/conf/initial_event_test_diff_client_ids_diff_ports_master_udp.json.in b/test/network_tests/initial_event_tests/conf/initial_event_test_diff_client_ids_diff_ports_master_udp.json.in index 8ce06f000..40657eac4 100644 --- a/test/network_tests/initial_event_tests/conf/initial_event_test_diff_client_ids_diff_ports_master_udp.json.in +++ b/test/network_tests/initial_event_tests/conf/initial_event_test_diff_client_ids_diff_ports_master_udp.json.in @@ -9,7 +9,7 @@ "enable":"false", "path":"/tmp/vsomeip.log" }, - "dlt":"false" + "dlt":"true" }, "applications": [ diff --git a/test/network_tests/initial_event_tests/conf/initial_event_test_diff_client_ids_diff_ports_same_service_id_master.json.in b/test/network_tests/initial_event_tests/conf/initial_event_test_diff_client_ids_diff_ports_same_service_id_master.json.in index 6445025ea..363f6288d 100644 --- a/test/network_tests/initial_event_tests/conf/initial_event_test_diff_client_ids_diff_ports_same_service_id_master.json.in +++ b/test/network_tests/initial_event_tests/conf/initial_event_test_diff_client_ids_diff_ports_same_service_id_master.json.in @@ -9,7 +9,7 @@ "enable":"false", "path":"/tmp/vsomeip.log" }, - "dlt":"false" + "dlt":"true" }, "applications": [ @@ -78,4 +78,4 @@ "cyclic_offer_delay" : "1000", "ttl" : "3" } -} \ No newline at end of file +} diff --git a/test/network_tests/initial_event_tests/conf/initial_event_test_diff_client_ids_diff_ports_same_service_id_slave.json.in b/test/network_tests/initial_event_tests/conf/initial_event_test_diff_client_ids_diff_ports_same_service_id_slave.json.in index c5dddc3a2..c0af842b7 100644 --- a/test/network_tests/initial_event_tests/conf/initial_event_test_diff_client_ids_diff_ports_same_service_id_slave.json.in +++ b/test/network_tests/initial_event_tests/conf/initial_event_test_diff_client_ids_diff_ports_same_service_id_slave.json.in @@ -10,7 +10,7 @@ "enable":"false", "path":"/tmp/vsomeip.log" }, - "dlt":"false" + "dlt":"true" }, "applications": [ @@ -79,4 +79,4 @@ "cyclic_offer_delay" : "1000", "ttl" : "3" } -} \ No newline at end of file +} diff --git a/test/network_tests/initial_event_tests/conf/initial_event_test_diff_client_ids_diff_ports_slave.json.in b/test/network_tests/initial_event_tests/conf/initial_event_test_diff_client_ids_diff_ports_slave.json.in index 3e7e28633..be317ccdf 100644 --- a/test/network_tests/initial_event_tests/conf/initial_event_test_diff_client_ids_diff_ports_slave.json.in +++ b/test/network_tests/initial_event_tests/conf/initial_event_test_diff_client_ids_diff_ports_slave.json.in @@ -10,7 +10,7 @@ "enable":"false", "path":"/tmp/vsomeip.log" }, - "dlt":"false" + "dlt":"true" }, "applications": [ @@ -79,4 +79,4 @@ "cyclic_offer_delay" : "1000", "ttl" : "3" } -} \ No newline at end of file +} diff --git a/test/network_tests/initial_event_tests/conf/initial_event_test_diff_client_ids_diff_ports_slave_tcp.json.in b/test/network_tests/initial_event_tests/conf/initial_event_test_diff_client_ids_diff_ports_slave_tcp.json.in index 1fc97a440..33fb4b941 100644 --- a/test/network_tests/initial_event_tests/conf/initial_event_test_diff_client_ids_diff_ports_slave_tcp.json.in +++ b/test/network_tests/initial_event_tests/conf/initial_event_test_diff_client_ids_diff_ports_slave_tcp.json.in @@ -10,7 +10,7 @@ "enable":"false", "path":"/tmp/vsomeip.log" }, - "dlt":"false" + "dlt":"true" }, "applications": [ diff --git a/test/network_tests/initial_event_tests/conf/initial_event_test_diff_client_ids_diff_ports_slave_udp.json.in b/test/network_tests/initial_event_tests/conf/initial_event_test_diff_client_ids_diff_ports_slave_udp.json.in index d303a4c84..6aa86bf0a 100644 --- a/test/network_tests/initial_event_tests/conf/initial_event_test_diff_client_ids_diff_ports_slave_udp.json.in +++ b/test/network_tests/initial_event_tests/conf/initial_event_test_diff_client_ids_diff_ports_slave_udp.json.in @@ -10,7 +10,7 @@ "enable":"false", "path":"/tmp/vsomeip.log" }, - "dlt":"false" + "dlt":"true" }, "applications": [ diff --git a/test/network_tests/initial_event_tests/conf/initial_event_test_diff_client_ids_partial_same_ports_master.json.in b/test/network_tests/initial_event_tests/conf/initial_event_test_diff_client_ids_partial_same_ports_master.json.in index f168fae18..927fda788 100644 --- a/test/network_tests/initial_event_tests/conf/initial_event_test_diff_client_ids_partial_same_ports_master.json.in +++ b/test/network_tests/initial_event_tests/conf/initial_event_test_diff_client_ids_partial_same_ports_master.json.in @@ -9,7 +9,7 @@ "enable":"false", "path":"/tmp/vsomeip.log" }, - "dlt":"false" + "dlt":"true" }, "applications": [ @@ -78,4 +78,4 @@ "cyclic_offer_delay" : "1000", "ttl" : "3" } -} \ No newline at end of file +} diff --git a/test/network_tests/initial_event_tests/conf/initial_event_test_diff_client_ids_partial_same_ports_slave.json.in b/test/network_tests/initial_event_tests/conf/initial_event_test_diff_client_ids_partial_same_ports_slave.json.in index 30206a210..69d0bf870 100644 --- a/test/network_tests/initial_event_tests/conf/initial_event_test_diff_client_ids_partial_same_ports_slave.json.in +++ b/test/network_tests/initial_event_tests/conf/initial_event_test_diff_client_ids_partial_same_ports_slave.json.in @@ -10,7 +10,7 @@ "enable":"false", "path":"/tmp/vsomeip.log" }, - "dlt":"false" + "dlt":"true" }, "applications": [ @@ -79,4 +79,4 @@ "cyclic_offer_delay" : "1000", "ttl" : "3" } -} \ No newline at end of file +} diff --git a/test/network_tests/initial_event_tests/conf/initial_event_test_diff_client_ids_same_ports_master.json.in b/test/network_tests/initial_event_tests/conf/initial_event_test_diff_client_ids_same_ports_master.json.in index 785e65199..4a660fd6b 100644 --- a/test/network_tests/initial_event_tests/conf/initial_event_test_diff_client_ids_same_ports_master.json.in +++ b/test/network_tests/initial_event_tests/conf/initial_event_test_diff_client_ids_same_ports_master.json.in @@ -9,7 +9,7 @@ "enable":"false", "path":"/tmp/vsomeip.log" }, - "dlt":"false" + "dlt":"true" }, "applications": [ @@ -78,4 +78,4 @@ "cyclic_offer_delay" : "1000", "ttl" : "3" } -} \ No newline at end of file +} diff --git a/test/network_tests/initial_event_tests/conf/initial_event_test_diff_client_ids_same_ports_master_tcp.json.in b/test/network_tests/initial_event_tests/conf/initial_event_test_diff_client_ids_same_ports_master_tcp.json.in index b06568521..21346a921 100644 --- a/test/network_tests/initial_event_tests/conf/initial_event_test_diff_client_ids_same_ports_master_tcp.json.in +++ b/test/network_tests/initial_event_tests/conf/initial_event_test_diff_client_ids_same_ports_master_tcp.json.in @@ -9,7 +9,7 @@ "enable":"false", "path":"/tmp/vsomeip.log" }, - "dlt":"false" + "dlt":"true" }, "applications": [ @@ -75,4 +75,4 @@ "cyclic_offer_delay" : "1000", "ttl" : "3" } -} \ No newline at end of file +} diff --git a/test/network_tests/initial_event_tests/conf/initial_event_test_diff_client_ids_same_ports_master_udp.json.in b/test/network_tests/initial_event_tests/conf/initial_event_test_diff_client_ids_same_ports_master_udp.json.in index ca77daf8b..42a7e4267 100644 --- a/test/network_tests/initial_event_tests/conf/initial_event_test_diff_client_ids_same_ports_master_udp.json.in +++ b/test/network_tests/initial_event_tests/conf/initial_event_test_diff_client_ids_same_ports_master_udp.json.in @@ -9,7 +9,7 @@ "enable":"false", "path":"/tmp/vsomeip.log" }, - "dlt":"false" + "dlt":"true" }, "applications": [ @@ -63,4 +63,4 @@ "cyclic_offer_delay" : "1000", "ttl" : "3" } -} \ No newline at end of file +} diff --git a/test/network_tests/initial_event_tests/conf/initial_event_test_diff_client_ids_same_ports_slave.json.in b/test/network_tests/initial_event_tests/conf/initial_event_test_diff_client_ids_same_ports_slave.json.in index cfbdac415..2b948b16b 100644 --- a/test/network_tests/initial_event_tests/conf/initial_event_test_diff_client_ids_same_ports_slave.json.in +++ b/test/network_tests/initial_event_tests/conf/initial_event_test_diff_client_ids_same_ports_slave.json.in @@ -10,7 +10,7 @@ "enable":"false", "path":"/tmp/vsomeip.log" }, - "dlt":"false" + "dlt":"true" }, "applications": [ @@ -79,4 +79,4 @@ "cyclic_offer_delay" : "1000", "ttl" : "3" } -} \ No newline at end of file +} diff --git a/test/network_tests/initial_event_tests/conf/initial_event_test_diff_client_ids_same_ports_slave_tcp.json.in b/test/network_tests/initial_event_tests/conf/initial_event_test_diff_client_ids_same_ports_slave_tcp.json.in index eaeab4a6a..db75e78ef 100644 --- a/test/network_tests/initial_event_tests/conf/initial_event_test_diff_client_ids_same_ports_slave_tcp.json.in +++ b/test/network_tests/initial_event_tests/conf/initial_event_test_diff_client_ids_same_ports_slave_tcp.json.in @@ -10,7 +10,7 @@ "enable":"false", "path":"/tmp/vsomeip.log" }, - "dlt":"false" + "dlt":"true" }, "applications": [ @@ -76,4 +76,4 @@ "cyclic_offer_delay" : "1000", "ttl" : "3" } -} \ No newline at end of file +} diff --git a/test/network_tests/initial_event_tests/conf/initial_event_test_diff_client_ids_same_ports_slave_udp.json.in b/test/network_tests/initial_event_tests/conf/initial_event_test_diff_client_ids_same_ports_slave_udp.json.in index 5d978f0c7..10e7bb144 100644 --- a/test/network_tests/initial_event_tests/conf/initial_event_test_diff_client_ids_same_ports_slave_udp.json.in +++ b/test/network_tests/initial_event_tests/conf/initial_event_test_diff_client_ids_same_ports_slave_udp.json.in @@ -10,7 +10,7 @@ "enable":"false", "path":"/tmp/vsomeip.log" }, - "dlt":"false" + "dlt":"true" }, "applications": [ @@ -64,4 +64,4 @@ "cyclic_offer_delay" : "1000", "ttl" : "3" } -} \ No newline at end of file +} diff --git a/test/network_tests/initial_event_tests/conf/initial_event_test_same_client_ids_diff_ports_master.json.in b/test/network_tests/initial_event_tests/conf/initial_event_test_same_client_ids_diff_ports_master.json.in index d7b5c7be1..a8c17d264 100644 --- a/test/network_tests/initial_event_tests/conf/initial_event_test_same_client_ids_diff_ports_master.json.in +++ b/test/network_tests/initial_event_tests/conf/initial_event_test_same_client_ids_diff_ports_master.json.in @@ -9,7 +9,7 @@ "enable":"false", "path":"/tmp/vsomeip.log" }, - "dlt":"false" + "dlt":"true" }, "applications": [ @@ -78,4 +78,4 @@ "cyclic_offer_delay" : "1000", "ttl" : "3" } -} \ No newline at end of file +} diff --git a/test/network_tests/initial_event_tests/conf/initial_event_test_same_client_ids_diff_ports_slave.json.in b/test/network_tests/initial_event_tests/conf/initial_event_test_same_client_ids_diff_ports_slave.json.in index facc51aee..f60f80080 100644 --- a/test/network_tests/initial_event_tests/conf/initial_event_test_same_client_ids_diff_ports_slave.json.in +++ b/test/network_tests/initial_event_tests/conf/initial_event_test_same_client_ids_diff_ports_slave.json.in @@ -10,7 +10,7 @@ "enable":"false", "path":"/tmp/vsomeip.log" }, - "dlt":"false" + "dlt":"true" }, "applications": [ @@ -79,4 +79,4 @@ "cyclic_offer_delay" : "1000", "ttl" : "3" } -} \ No newline at end of file +} diff --git a/test/network_tests/initial_event_tests/conf/initial_event_test_same_client_ids_same_ports_master.json.in b/test/network_tests/initial_event_tests/conf/initial_event_test_same_client_ids_same_ports_master.json.in index 785e65199..4a660fd6b 100644 --- a/test/network_tests/initial_event_tests/conf/initial_event_test_same_client_ids_same_ports_master.json.in +++ b/test/network_tests/initial_event_tests/conf/initial_event_test_same_client_ids_same_ports_master.json.in @@ -9,7 +9,7 @@ "enable":"false", "path":"/tmp/vsomeip.log" }, - "dlt":"false" + "dlt":"true" }, "applications": [ @@ -78,4 +78,4 @@ "cyclic_offer_delay" : "1000", "ttl" : "3" } -} \ No newline at end of file +} diff --git a/test/network_tests/initial_event_tests/conf/initial_event_test_same_client_ids_same_ports_slave.json.in b/test/network_tests/initial_event_tests/conf/initial_event_test_same_client_ids_same_ports_slave.json.in index 97b5d9f93..670c5cc33 100644 --- a/test/network_tests/initial_event_tests/conf/initial_event_test_same_client_ids_same_ports_slave.json.in +++ b/test/network_tests/initial_event_tests/conf/initial_event_test_same_client_ids_same_ports_slave.json.in @@ -10,7 +10,7 @@ "enable":"false", "path":"/tmp/vsomeip.log" }, - "dlt":"false" + "dlt":"true" }, "applications": [ @@ -79,4 +79,4 @@ "cyclic_offer_delay" : "1000", "ttl" : "3" } -} \ No newline at end of file +} diff --git a/test/network_tests/initial_event_tests/initial_event_test_availability_checker.cpp b/test/network_tests/initial_event_tests/initial_event_test_availability_checker.cpp index 140649231..cbe76c2f7 100644 --- a/test/network_tests/initial_event_tests/initial_event_test_availability_checker.cpp +++ b/test/network_tests/initial_event_tests/initial_event_test_availability_checker.cpp @@ -1,4 +1,4 @@ -// Copyright (C) 2014-2017 Bayerische Motoren Werke Aktiengesellschaft (BMW AG) +// Copyright (C) 2014-2023 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/. @@ -18,12 +18,14 @@ #include #include "initial_event_test_globals.hpp" +#include "../someip_test_globals.hpp" +#include - -class initial_event_test_availability_checker { +class initial_event_test_availability_checker : public vsomeip_utilities::base_logger { public: initial_event_test_availability_checker(int _client_number, std::array _service_infos) : + vsomeip_utilities::base_logger("IETC", "INITIAL EVENT TEST AVAILABILITY CHECKER"), client_number_(_client_number), service_infos_(_service_infos), app_(vsomeip::runtime::get()->create_application()), diff --git a/test/network_tests/initial_event_tests/initial_event_test_client.cpp b/test/network_tests/initial_event_tests/initial_event_test_client.cpp index 2197b6a28..8c8b81e00 100644 --- a/test/network_tests/initial_event_tests/initial_event_test_client.cpp +++ b/test/network_tests/initial_event_tests/initial_event_test_client.cpp @@ -1,4 +1,4 @@ -// Copyright (C) 2014-2017 Bayerische Motoren Werke Aktiengesellschaft (BMW AG) +// Copyright (C) 2014-2023 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/. @@ -478,7 +478,7 @@ class initial_event_test_client { while (wait_for_stop_) { stop_condition_.wait_for(its_lock, std::chrono::milliseconds(100)); } - VSOMEIP_ERROR << "(" << std::dec << its_call_number << ") [" + VSOMEIP_ERROR << "(" << std::dec << its_call_number << ") [" << std::setw(4) << std::setfill('0') << std::hex << client_number_ << "] Received notifications from all services, going down"; diff --git a/test/network_tests/initial_event_tests/initial_event_test_master_starter_qnx.sh b/test/network_tests/initial_event_tests/initial_event_test_master_starter_qnx.sh index 88db07b3e..f302048a1 100755 --- a/test/network_tests/initial_event_tests/initial_event_test_master_starter_qnx.sh +++ b/test/network_tests/initial_event_tests/initial_event_test_master_starter_qnx.sh @@ -1,5 +1,5 @@ #!/bin/sh -# Copyright (C) 2015-2017 Bayerische Motoren Werke Aktiengesellschaft (BMW AG) +# Copyright (C) 2015-2023 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/. diff --git a/test/network_tests/initial_event_tests/initial_event_test_service.cpp b/test/network_tests/initial_event_tests/initial_event_test_service.cpp index 039dd4f68..d39b6254b 100644 --- a/test/network_tests/initial_event_tests/initial_event_test_service.cpp +++ b/test/network_tests/initial_event_tests/initial_event_test_service.cpp @@ -1,4 +1,4 @@ -// Copyright (C) 2014-2017 Bayerische Motoren Werke Aktiengesellschaft (BMW AG) +// Copyright (C) 2014-2023 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/. @@ -18,12 +18,15 @@ #include #include "initial_event_test_globals.hpp" +#include "../someip_test_globals.hpp" +#include -class initial_event_test_service { +class initial_event_test_service : public vsomeip_utilities::base_logger { public: initial_event_test_service(struct initial_event_test::service_info _service_info, std::uint32_t _events_to_offer, vsomeip::reliability_type_e _reliability_type) : + vsomeip_utilities::base_logger("IETS", "INITIAL EVENT TEST SERVICE"), service_info_(_service_info), app_(vsomeip::runtime::get()->create_application()), wait_until_registered_(true), @@ -65,6 +68,8 @@ class initial_event_test_service { } ~initial_event_test_service() { + app_->stop(); + if (offer_thread_.joinable()) { offer_thread_.join(); } diff --git a/test/network_tests/initial_event_tests/initial_event_test_stop_service.cpp b/test/network_tests/initial_event_tests/initial_event_test_stop_service.cpp index e6e6016ec..3e5bfd222 100644 --- a/test/network_tests/initial_event_tests/initial_event_test_stop_service.cpp +++ b/test/network_tests/initial_event_tests/initial_event_test_stop_service.cpp @@ -1,4 +1,4 @@ -// Copyright (C) 2014-2017 Bayerische Motoren Werke Aktiengesellschaft (BMW AG) +// Copyright (C) 2014-2023 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/. @@ -19,11 +19,13 @@ #include #include "initial_event_test_globals.hpp" +#include "../someip_test_globals.hpp" +#include - -class initial_event_test_stop_service { +class initial_event_test_stop_service : public vsomeip_utilities::base_logger { public: initial_event_test_stop_service(struct initial_event_test::service_info _service_info, bool _is_master) : + vsomeip_utilities::base_logger("IETS", "INITIAL EVENT TEST STOP SERVICE"), service_info_(_service_info), is_master_(_is_master), app_(vsomeip::runtime::get()->create_application()), @@ -198,10 +200,12 @@ class initial_event_test_stop_service { while (wait_until_shutdown_method_called_) { auto its_reason = condition_.wait_for(its_lock, std::chrono::milliseconds(250)); if (its_reason == std::cv_status::timeout) { - std::lock_guard its_lock(stop_mutex_); + its_lock.unlock(); + std::lock_guard its_guard(stop_mutex_); wait_for_stop_ = false; stop_condition_.notify_one(); wait_until_shutdown_method_called_ = false; + its_lock.lock(); } } } @@ -210,10 +214,11 @@ class initial_event_test_stop_service { void wait_for_stop() { static int its_call_number(0); its_call_number++; - - std::unique_lock its_lock(stop_mutex_); - while (wait_for_stop_) { - stop_condition_.wait(its_lock); + { + std::unique_lock its_lock(stop_mutex_); + while (wait_for_stop_) { + stop_condition_.wait(its_lock); + } } VSOMEIP_INFO << "(" << std::dec << its_call_number << ") [" << std::setw(4) << std::setfill('0') << std::hex << service_info_.service_id diff --git a/test/network_tests/magic_cookies_tests/conf/magic_cookies_test_service.json.in b/test/network_tests/magic_cookies_tests/conf/magic_cookies_test_service.json.in index 0e53c2487..dd5272890 100644 --- a/test/network_tests/magic_cookies_tests/conf/magic_cookies_test_service.json.in +++ b/test/network_tests/magic_cookies_tests/conf/magic_cookies_test_service.json.in @@ -9,7 +9,7 @@ "enable":"false", "path":"/tmp/vsomeip.log" }, - "dlt":"false" + "dlt":"true" }, "applications": [ diff --git a/test/network_tests/magic_cookies_tests/magic_cookies_test_client.cpp b/test/network_tests/magic_cookies_tests/magic_cookies_test_client.cpp index 89a002905..f7887367e 100644 --- a/test/network_tests/magic_cookies_tests/magic_cookies_test_client.cpp +++ b/test/network_tests/magic_cookies_tests/magic_cookies_test_client.cpp @@ -1,4 +1,4 @@ -// Copyright (C) 2015-2017 Bayerische Motoren Werke Aktiengesellschaft (BMW AG) +// Copyright (C) 2015-2023 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/. @@ -14,13 +14,15 @@ #include #include "../someip_test_globals.hpp" +#include #include "../implementation/runtime/include/application_impl.hpp" #include "../implementation/routing/include/routing_manager.hpp" -class magic_cookies_test_client { +class magic_cookies_test_client : public vsomeip_utilities::base_logger { public: magic_cookies_test_client() - : app_(new vsomeip::application_impl("", "")), + : vsomeip_utilities::base_logger("MCTC", "MAGIC COOKIES TEST CLIENT"), + app_(new vsomeip::application_impl("", "")), is_blocked_(false), sent_messages_good_(8), sent_messages_bad_(7), diff --git a/test/network_tests/magic_cookies_tests/magic_cookies_test_service.cpp b/test/network_tests/magic_cookies_tests/magic_cookies_test_service.cpp index d8ac4d78a..49cda1e1c 100644 --- a/test/network_tests/magic_cookies_tests/magic_cookies_test_service.cpp +++ b/test/network_tests/magic_cookies_tests/magic_cookies_test_service.cpp @@ -1,4 +1,4 @@ -// Copyright (C) 2014-2017 Bayerische Motoren Werke Aktiengesellschaft (BMW AG) +// Copyright (C) 2014-2023 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/. @@ -15,10 +15,12 @@ #include #include "../someip_test_globals.hpp" +#include -class magic_cookies_test_service { +class magic_cookies_test_service : public vsomeip_utilities::base_logger { public: magic_cookies_test_service(bool _use_static_routing) : + vsomeip_utilities::base_logger("MGTS", "MAGIC COOKIES TEST SERVICE"), app_(vsomeip::runtime::get()->create_application()), is_registered_(false), use_static_routing_(_use_static_routing), diff --git a/test/network_tests/malicious_data_tests/conf/malicious_data_test_master.json.in b/test/network_tests/malicious_data_tests/conf/malicious_data_test_master.json.in index 5c2e511ea..d16fc32d3 100644 --- a/test/network_tests/malicious_data_tests/conf/malicious_data_test_master.json.in +++ b/test/network_tests/malicious_data_tests/conf/malicious_data_test_master.json.in @@ -9,7 +9,7 @@ "enable":"false", "path":"/tmp/vsomeip.log" }, - "dlt":"false" + "dlt":"true" }, "applications" : [ @@ -41,4 +41,4 @@ "protocol":"udp", "cyclic_offer_delay" : "1000" } -} \ No newline at end of file +} diff --git a/test/network_tests/malicious_data_tests/malicious_data_test_msg_sender.cpp b/test/network_tests/malicious_data_tests/malicious_data_test_msg_sender.cpp index 96c45ada0..4c75e9f3f 100644 --- a/test/network_tests/malicious_data_tests/malicious_data_test_msg_sender.cpp +++ b/test/network_tests/malicious_data_tests/malicious_data_test_msg_sender.cpp @@ -1,4 +1,4 @@ -// Copyright (C) 2015-2017 Bayerische Motoren Werke Aktiengesellschaft (BMW AG) +// Copyright (C) 2015-2023 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/. diff --git a/test/network_tests/malicious_data_tests/malicious_data_test_service.cpp b/test/network_tests/malicious_data_tests/malicious_data_test_service.cpp index 0b91764e8..56538aec1 100644 --- a/test/network_tests/malicious_data_tests/malicious_data_test_service.cpp +++ b/test/network_tests/malicious_data_tests/malicious_data_test_service.cpp @@ -1,4 +1,4 @@ -// Copyright (C) 2014-2017 Bayerische Motoren Werke Aktiengesellschaft (BMW AG) +// Copyright (C) 2014-2023 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/. @@ -20,10 +20,13 @@ #include #include "malicious_data_test_globals.hpp" +#include "../someip_test_globals.hpp" +#include -class malicious_data_test_service { +class malicious_data_test_service : public vsomeip_utilities::base_logger { public: malicious_data_test_service(struct malicious_data_test::service_info _service_info, malicious_data_test::test_mode_e _testmode) : + vsomeip_utilities::base_logger("MDTS", "MALICIOUS DATA TEST SERVICE"), service_info_(_service_info), testmode_(_testmode), app_(vsomeip::runtime::get()->create_application("malicious_data_test_service")), diff --git a/test/network_tests/npdu_tests/npdu_test_client.cpp b/test/network_tests/npdu_tests/npdu_test_client.cpp index cb44dd1b5..08c6dbb41 100644 --- a/test/network_tests/npdu_tests/npdu_test_client.cpp +++ b/test/network_tests/npdu_tests/npdu_test_client.cpp @@ -1,4 +1,4 @@ -// Copyright (C) 2015-2019 Bayerische Motoren Werke Aktiengesellschaft (BMW AG) +// Copyright (C) 2015-2023 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/. diff --git a/test/network_tests/npdu_tests/npdu_test_client.hpp b/test/network_tests/npdu_tests/npdu_test_client.hpp index 980c16aa8..2f469d40c 100644 --- a/test/network_tests/npdu_tests/npdu_test_client.hpp +++ b/test/network_tests/npdu_tests/npdu_test_client.hpp @@ -1,4 +1,4 @@ -// Copyright (C) 2015-2019 Bayerische Motoren Werke Aktiengesellschaft (BMW AG) +// Copyright (C) 2015-2023 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/. @@ -18,6 +18,7 @@ #include "../npdu_tests/npdu_test_globals.hpp" #include "../someip_test_globals.hpp" +#include class npdu_test_client { diff --git a/test/network_tests/npdu_tests/npdu_test_service.cpp b/test/network_tests/npdu_tests/npdu_test_service.cpp index 1f9ffbff1..5fdc87dc4 100644 --- a/test/network_tests/npdu_tests/npdu_test_service.cpp +++ b/test/network_tests/npdu_tests/npdu_test_service.cpp @@ -1,4 +1,4 @@ -// Copyright (C) 2015-2019 Bayerische Motoren Werke Aktiengesellschaft (BMW AG) +// Copyright (C) 2015-2023 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/. diff --git a/test/network_tests/offer_tests/conf/offer_test_big_sd_msg_master.json.in b/test/network_tests/offer_tests/conf/offer_test_big_sd_msg_master.json.in index 06609f6d8..6f1e65965 100644 --- a/test/network_tests/offer_tests/conf/offer_test_big_sd_msg_master.json.in +++ b/test/network_tests/offer_tests/conf/offer_test_big_sd_msg_master.json.in @@ -9,7 +9,7 @@ "enable":"false", "path":"/tmp/vsomeip.log" }, - "dlt":"false" + "dlt":"true" }, "applications" : [ @@ -28,4 +28,4 @@ "protocol":"udp", "cyclic_offer_delay" : "1000" } -} \ No newline at end of file +} diff --git a/test/network_tests/offer_tests/conf/offer_test_big_sd_msg_slave.json.in b/test/network_tests/offer_tests/conf/offer_test_big_sd_msg_slave.json.in index 0c8427d20..34263fd77 100644 --- a/test/network_tests/offer_tests/conf/offer_test_big_sd_msg_slave.json.in +++ b/test/network_tests/offer_tests/conf/offer_test_big_sd_msg_slave.json.in @@ -9,7 +9,7 @@ "enable":"false", "path":"/tmp/vsomeip.log" }, - "dlt":"false" + "dlt":"true" }, "applications" : [ @@ -331,4 +331,4 @@ "port":"30490", "protocol":"udp" } -} \ No newline at end of file +} diff --git a/test/network_tests/offer_tests/conf/offer_test_external_master.json.in b/test/network_tests/offer_tests/conf/offer_test_external_master.json.in index c54d9ac4e..afe04b40b 100644 --- a/test/network_tests/offer_tests/conf/offer_test_external_master.json.in +++ b/test/network_tests/offer_tests/conf/offer_test_external_master.json.in @@ -9,7 +9,7 @@ "enable":"false", "path":"/tmp/vsomeip.log" }, - "dlt":"false" + "dlt":"true" }, "services": [ @@ -33,4 +33,4 @@ "protocol":"udp", "cyclic_offer_delay" : "500" } -} \ No newline at end of file +} diff --git a/test/network_tests/offer_tests/conf/offer_test_external_master_starter.sh.in b/test/network_tests/offer_tests/conf/offer_test_external_master_starter.sh.in index 0e75fa99c..cefdd43d6 100755 --- a/test/network_tests/offer_tests/conf/offer_test_external_master_starter.sh.in +++ b/test/network_tests/offer_tests/conf/offer_test_external_master_starter.sh.in @@ -108,12 +108,12 @@ if [ ! -z "$USE_LXC_TEST" ]; then echo "Waiting for 5s" sleep 5 echo "starting offer test on slave LXC offer_test_external_sd_msg_sender" - ssh -tt -i $SANDBOX_ROOT_DIR/commonapi_main/lxc-config/.ssh/mgc_lxc/rsa_key_file.pub -o StrictHostKeyChecking=no root@$LXC_TEST_SLAVE_IP "bash -ci \"set -m; cd \\\$SANDBOX_TARGET_DIR/vsomeip_lib/test/network_tests; ./offer_test_external_sd_msg_sender $LXC_TEST_MASTER_IP\"" & + ssh -tt -i $SANDBOX_ROOT_DIR/commonapi_main/lxc-config/.ssh/mgc_lxc/rsa_key_file.pub -o StrictHostKeyChecking=no root@$LXC_TEST_SLAVE_IP "bash -ci \"set -m; cd \\\$SANDBOX_TARGET_DIR/vsomeip_lib/test/network_tests; ./offer_test_external_sd_msg_sender @TEST_IP_MASTER@\"" & echo "remote ssh job id: $!" elif [ ! -z "$USE_DOCKER" ]; then echo "Waiting for 5s" sleep 5 - docker exec $DOCKER_IMAGE sh -c "cd $DOCKER_TESTS && sleep 10; ./offer_test_external_sd_msg_sender $DOCKER_IP" & + docker exec $DOCKER_IMAGE sh -c "cd $DOCKER_TESTS && sleep 10; ./offer_test_external_sd_msg_sender @TEST_IP_MASTER@" & else cat < #include "offer_test_globals.hpp" +#include "../someip_test_globals.hpp" +#include -class offer_test_big_sd_msg_client { +class offer_test_big_sd_msg_client : public vsomeip_utilities::base_logger { public: offer_test_big_sd_msg_client(struct offer_test::service_info _service_info) : + vsomeip_utilities::base_logger("OTBC", "OFFER TEST BIG SD MSG CLIENT"), service_info_(_service_info), app_(vsomeip::runtime::get()->create_application("offer_test_big_sd_msg_client")), wait_until_registered_(true), diff --git a/test/network_tests/offer_tests/offer_test_big_sd_msg_service.cpp b/test/network_tests/offer_tests/offer_test_big_sd_msg_service.cpp index fa009d6c9..b83870ba9 100644 --- a/test/network_tests/offer_tests/offer_test_big_sd_msg_service.cpp +++ b/test/network_tests/offer_tests/offer_test_big_sd_msg_service.cpp @@ -1,4 +1,4 @@ -// Copyright (C) 2014-2017 Bayerische Motoren Werke Aktiengesellschaft (BMW AG) +// Copyright (C) 2014-2023 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/. @@ -20,10 +20,13 @@ #include #include "offer_test_globals.hpp" +#include "../someip_test_globals.hpp" +#include -class offer_test_big_sd_msg_service { +class offer_test_big_sd_msg_service : public vsomeip_utilities::base_logger { public: offer_test_big_sd_msg_service(struct offer_test::service_info _service_info) : + vsomeip_utilities::base_logger("OTBS", "OFFER TEST BIG SD MSG SERVICE"), service_info_(_service_info), // service with number 1 uses "routingmanagerd" as application name // this way the same json file can be reused for all local tests diff --git a/test/network_tests/offer_tests/offer_test_client.cpp b/test/network_tests/offer_tests/offer_test_client.cpp index 6500c1a71..e5697cb2f 100644 --- a/test/network_tests/offer_tests/offer_test_client.cpp +++ b/test/network_tests/offer_tests/offer_test_client.cpp @@ -1,4 +1,4 @@ -// Copyright (C) 2014-2017 Bayerische Motoren Werke Aktiengesellschaft (BMW AG) +// Copyright (C) 2014-2023 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/. @@ -25,15 +25,18 @@ #endif // ANDROID #include "offer_test_globals.hpp" +#include "../someip_test_globals.hpp" +#include enum operation_mode_e { SUBSCRIBE, METHODCALL }; -class offer_test_client { +class offer_test_client : public vsomeip_utilities::base_logger { public: offer_test_client(struct offer_test::service_info _service_info, operation_mode_e _mode) : + vsomeip_utilities::base_logger("OTC1", "OFFER TEST CLIENT"), service_info_(_service_info), operation_mode_(_mode), app_(vsomeip::runtime::get()->create_application("offer_test_client")), diff --git a/test/network_tests/offer_tests/offer_test_external_sd_msg_sender.cpp b/test/network_tests/offer_tests/offer_test_external_sd_msg_sender.cpp index 269794288..f31215605 100644 --- a/test/network_tests/offer_tests/offer_test_external_sd_msg_sender.cpp +++ b/test/network_tests/offer_tests/offer_test_external_sd_msg_sender.cpp @@ -1,8 +1,9 @@ -// Copyright (C) 2015-2017 Bayerische Motoren Werke Aktiengesellschaft (BMW AG) +// Copyright (C) 2015-2023 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/. +#include #include #include @@ -58,7 +59,8 @@ TEST(someip_offer_test, send_offer_service_sd_message) boost::asio::ip::address::from_string(std::string(passed_address)), 30001); udp_socket.send_to(boost::asio::buffer(shutdown_call), target_service); - } catch (...) { + } catch (const std::exception& e) { + std::cerr << "Caught exception: " << e.what() << '\n'; ASSERT_FALSE(true); } } diff --git a/test/network_tests/offer_tests/offer_test_local.json b/test/network_tests/offer_tests/offer_test_local.json index be8aa0995..876844040 100644 --- a/test/network_tests/offer_tests/offer_test_local.json +++ b/test/network_tests/offer_tests/offer_test_local.json @@ -9,7 +9,7 @@ "enable":"false", "path":"/tmp/vsomeip.log" }, - "dlt":"false" + "dlt":"true" }, "routing":"routingmanagerd", "service-discovery": @@ -17,4 +17,3 @@ "enable":"false" } } - diff --git a/test/network_tests/offer_tests/offer_test_local_starter_qnx.sh b/test/network_tests/offer_tests/offer_test_local_starter_qnx.sh index 1eb13c9ea..1e0a20ce3 100755 --- a/test/network_tests/offer_tests/offer_test_local_starter_qnx.sh +++ b/test/network_tests/offer_tests/offer_test_local_starter_qnx.sh @@ -1,5 +1,5 @@ #!/bin/sh -# Copyright (C) 2015-2017 Bayerische Motoren Werke Aktiengesellschaft (BMW AG) +# Copyright (C) 2015-2023 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/. diff --git a/test/network_tests/offer_tests/offer_test_multiple_offerings.cpp b/test/network_tests/offer_tests/offer_test_multiple_offerings.cpp new file mode 100644 index 000000000..0c7e0f283 --- /dev/null +++ b/test/network_tests/offer_tests/offer_test_multiple_offerings.cpp @@ -0,0 +1,277 @@ +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include + +#include + +using namespace vsomeip; +using namespace std::chrono_literals; + +constexpr auto TIMEOUT_RESPONSE = 1000ms; +constexpr auto TIMEOUT_AVAILABILITY = 1000ms; +constexpr auto REQUESTS_NUMBER = 10; + +class common { +public: + virtual void on_availability(service_t _service_id, instance_t _instance_id, bool _is_available); + +public: + instance_t instance_id_; + service_t service_id_; + major_version_t major_version_; + minor_version_t minor_version_; + std::shared_ptr app_; + std::thread thread_id_; + std::condition_variable condition_availability_; + std::atomic_bool availability_; +}; + +void common::on_availability(service_t _service_id, instance_t _instance_id, bool _is_available) { + if (_service_id == service_id_ && _instance_id == instance_id_) { + if (_is_available) { + // NOTE: Using the most strict memory ordering operation. + // Refer to https://en.cppreference.com/w/cpp/atomic/memory_order for possible options + availability_.store(true); + condition_availability_.notify_one(); + } else { + availability_.store(false); + } + } +} + +class client : common { +public: + client(service_t _service_id, + instance_t _instance_id, + major_version_t _major_version, + minor_version_t _minor_version) { + service_id_ = _service_id; + instance_id_ = _instance_id; + major_version_ = _major_version; + minor_version_ = _minor_version; + + app_ = runtime::get()->create_application("client"); + app_->init(); + app_->register_availability_handler(service_id_, instance_id_, + std::bind(&client::on_availability, this, + std::placeholders::_1, std::placeholders::_2, + std::placeholders::_3)); + + app_->register_message_handler( + service_id_, instance_id_, ANY_METHOD, + std::bind(&client::on_message, this, std::placeholders::_1)); + app_->request_service(service_id_, instance_id_, major_version_, minor_version_); + + thread_id_ = std::thread(std::bind(&client::run, this)); + } + + void run() { + app_->start(); + } + + bool was_message_received() { + std::unique_lock lock(mutex_); + return condition_message_received_.wait_for(lock, std::chrono::milliseconds(TIMEOUT_AVAILABILITY), + [=] { return message_received_.load(); }); + } + + std::vector getReceivedPayload() { + std::lock_guard its_lock(payload_mutex_); + return received_payload_; + } + + bool wait_availability() { + std::unique_lock lock(mutex_); + return condition_availability_.wait_for(lock, std::chrono::milliseconds(TIMEOUT_AVAILABILITY), + [=] { return availability_.load(); }); + } + + void send_message(const std::vector& _outgoing_payload) { + auto request = runtime::get()->create_request(); + request->set_service(service_id_); + request->set_instance(instance_id_); + request->set_method(1); + + request->set_payload(runtime::get()->create_payload(_outgoing_payload)); + app_->send(request); + + std::unique_lock lock(mutex_); + condition_message_sent_.wait_for(lock, std::chrono::milliseconds(TIMEOUT_AVAILABILITY)); + } + + ~client() { + app_->stop(); + thread_id_.join(); + } + +private: + void on_availability(service_t _service_id, instance_t _instance_id, bool _is_available) { + common::on_availability(_service_id, _instance_id, _is_available); + } + + void on_message(const std::shared_ptr& _message) { + condition_message_sent_.notify_one(); + auto its_payload = _message->get_payload(); + auto const len = its_payload->get_length(); + + { + std::lock_guard its_lock(payload_mutex_); + received_payload_.clear(); + for (uint32_t i = 0; i < len; ++i) { + received_payload_.push_back(*(its_payload->get_data() + i)); + } + + } + if (_message->get_service() == service_id_ && _message->get_instance() == instance_id_) { + message_received_.store(true); + condition_message_received_.notify_one(); + } else { + message_received_.store(false); + } + } + +private: + std::condition_variable condition_message_received_; + std::condition_variable condition_message_sent_; + std::mutex mutex_; + + std::atomic_bool message_received_; + + std::vector received_payload_; + std::mutex payload_mutex_; +}; + +class server : common { +public: + server(service_t _service_id, instance_t _instance_id, major_version_t _major_version, + minor_version_t _minor_version) { + service_id_ = _service_id; + instance_id_ = _instance_id; + major_version_ = _major_version; + minor_version_ = _minor_version; + + app_ = runtime::get()->create_application("service"); + app_->init(); + + app_->register_availability_handler(service_id_, instance_id_, + std::bind(&server::on_availability, this, + std::placeholders::_1, std::placeholders::_2, + std::placeholders::_3)); + app_->register_message_handler( + service_id_, instance_id_, ANY_METHOD, + std::bind(&server::on_message, this, std::placeholders::_1)); + app_->offer_service(service_id_, instance_id_, major_version_, minor_version_); + app_->request_service(service_id_, instance_id_, major_version_, minor_version_); + + thread_id_ = std::thread(std::bind(&server::run, this)); + } + + void run() { app_->start(); } + + bool is_available() { return app_->is_available(service_id_, instance_id_); } + + bool wait_availability() { + std::unique_lock lock(mutex_); + return condition_availability_.wait_for(lock, std::chrono::milliseconds(TIMEOUT_AVAILABILITY), + [=] { return availability_.load(); }); + } + + ~server() { + app_->stop(); + thread_id_.join(); + } + +private: + void on_message(const std::shared_ptr& _message) { + const vsomeip::length_t len = _message->get_payload()->get_length(); + std::vector out_payload; + for (uint32_t i = 0; i < len; ++i) { + out_payload.push_back(*(_message->get_payload()->get_data() + i)); + } + std::shared_ptr response = runtime::get()->create_response(_message); + response->set_payload(vsomeip::runtime::get()->create_payload(out_payload)); + + app_->send(response); + } + + void on_availability(service_t _service_id, instance_t _instance_id, bool _is_available) { + common::on_availability(_service_id, _instance_id, _is_available); + } + +private: + std::mutex mutex_; +}; + +class vsomeip_daemon { +public: + vsomeip_daemon() { + app_ = vsomeip::runtime::get()->create_application("daemon"); + app_->init(); + run_daemon_thread_ = std::thread(std::bind(&vsomeip_daemon::run, this)); + } + + void set_routing_state(routing_state_e state) { app_->set_routing_state(state); } + + ~vsomeip_daemon() { + app_->stop(); + run_daemon_thread_.join(); + } +private: + void run() { app_->start(); } +private: + std::shared_ptr app_; + std::thread run_daemon_thread_; +}; + +TEST(offer_test, multiple_offerings_same_service) +{ + const service_t service_id { 0xfee2 }; + const instance_t instance_id { 0x0001 }; + const major_version_t major { 1 }; + const minor_version_t minor { 0 }; + + vsomeip_daemon daemon; + + server service_1(service_id, instance_id, major, minor); + service_1.wait_availability(); + + server service_2(service_id, instance_id, major, minor); + service_2.wait_availability(); + + client client(service_id, instance_id, major, minor); + client.wait_availability(); + + // Without suspending the deamon, the client immediatly closes. + daemon.set_routing_state(routing_state_e::RS_SUSPENDED); + + for (int i = 0; i < REQUESTS_NUMBER; ++i) { + // NOTE: Don't remove the sleep. VSOME/IP needs some time until it sends a PONG message to + // services. Otherwise we can't detect service availability correctly later. + std::this_thread::sleep_for(TIMEOUT_RESPONSE); + std::vector out_payload = { 2 }; + client.send_message(out_payload); + // Independant of the number of offerings, the client must never fail it's assertions. + ASSERT_TRUE(client.was_message_received()) << "Message was not received"; + // Should be safe to read the payload without locks. No one is reading or writing to it. + EXPECT_EQ(out_payload, client.getReceivedPayload()) << "Payload was not equal"; + } + // Both offerings must be available after the client is done. + // Failing this availability test means one of the instances has crashed. + ASSERT_TRUE(service_1.is_available()); + ASSERT_TRUE(service_2.is_available()); +} + +int main(int argc, char** argv) { + ::testing::InitGoogleTest(&argc, argv); + return RUN_ALL_TESTS(); +} diff --git a/test/network_tests/offer_tests/offer_test_multiple_offerings.json b/test/network_tests/offer_tests/offer_test_multiple_offerings.json new file mode 100644 index 000000000..07a467727 --- /dev/null +++ b/test/network_tests/offer_tests/offer_test_multiple_offerings.json @@ -0,0 +1,25 @@ +{ + "logging": { + "level": "verbose", + "console": "true", + "file": { + "enable": "false" + }, + "dlt": "false" + }, + "applications": [ + { + "name": "daemon", + "id": "0x0001" + }, + { + "name": "service", + "id": "0x0002" + }, + { + "name": "client", + "id": "0x0004" + } + ], + "routing": "daemon" +} diff --git a/test/network_tests/offer_tests/offer_test_multiple_offerings_starter.sh b/test/network_tests/offer_tests/offer_test_multiple_offerings_starter.sh new file mode 100755 index 000000000..86acd393c --- /dev/null +++ b/test/network_tests/offer_tests/offer_test_multiple_offerings_starter.sh @@ -0,0 +1,14 @@ +#!/bin/bash + +FAIL=0 +# Start the application +# Note: Every service (daemon, services, client) are per-thread in this executable + +export VSOMEIP_CONFIGURATION=offer_test_multiple_offerings.json + +if ! ./offer_test_multiple_offerings +then + ((FAIL+=1)) +fi + +exit $FAIL diff --git a/test/network_tests/offer_tests/offer_test_service.cpp b/test/network_tests/offer_tests/offer_test_service.cpp index f017f3ea7..5fa5c1234 100644 --- a/test/network_tests/offer_tests/offer_test_service.cpp +++ b/test/network_tests/offer_tests/offer_test_service.cpp @@ -1,4 +1,4 @@ -// Copyright (C) 2014-2017 Bayerische Motoren Werke Aktiengesellschaft (BMW AG) +// Copyright (C) 2014-2023 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/. @@ -19,12 +19,15 @@ #include #include "offer_test_globals.hpp" +#include "../someip_test_globals.hpp" +#include static std::string service_number; -class offer_test_service { +class offer_test_service : public vsomeip_utilities::base_logger { public: offer_test_service(struct offer_test::service_info _service_info) : + vsomeip_utilities::base_logger("OTS1", "OFFER TEST SERVICE"), service_info_(_service_info), // service with number 1 uses "routingmanagerd" as application name // this way the same json file can be reused for all local tests diff --git a/test/network_tests/offer_tests/offer_test_service_external.cpp b/test/network_tests/offer_tests/offer_test_service_external.cpp index 624b07f46..d4c8c1d1f 100644 --- a/test/network_tests/offer_tests/offer_test_service_external.cpp +++ b/test/network_tests/offer_tests/offer_test_service_external.cpp @@ -1,4 +1,4 @@ -// Copyright (C) 2014-2017 Bayerische Motoren Werke Aktiengesellschaft (BMW AG) +// Copyright (C) 2014-2023 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/. @@ -17,13 +17,16 @@ #include #include +#include "../someip_test_globals.hpp" #include "offer_test_globals.hpp" +#include static std::string service_number; -class offer_test_service { +class offer_test_service : public vsomeip_utilities::base_logger { public: offer_test_service(struct offer_test::service_info _service_info) : + vsomeip_utilities::base_logger("OTSE", "OFFER TEST SERVICE EXTERNAL"), service_info_(_service_info), // service with number 1 uses "routingmanagerd" as application name // this way the same json file can be reused for all local tests diff --git a/test/network_tests/offered_services_info_test/offered_services_info_test_client.cpp b/test/network_tests/offered_services_info_test/offered_services_info_test_client.cpp index 2af3d47b3..081da5659 100644 --- a/test/network_tests/offered_services_info_test/offered_services_info_test_client.cpp +++ b/test/network_tests/offered_services_info_test/offered_services_info_test_client.cpp @@ -1,4 +1,4 @@ -// Copyright (C) 2014-2017 Bayerische Motoren Werke Aktiengesellschaft (BMW AG) +// Copyright (C) 2014-2023 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/. @@ -26,6 +26,8 @@ #endif #include "offered_services_info_test_globals.hpp" +#include "someip_test_globals.hpp" +#include enum operation_mode_e { SUBSCRIBE, @@ -36,9 +38,10 @@ std::map> all_offered_services std::map> local_offered_services; std::map> remote_offered_services; -class offered_services_info_test_client { +class offered_services_info_test_client : public vsomeip_utilities::base_logger { public: offered_services_info_test_client(struct offer_test::service_info _service_info,offer_test::service_info _remote_service_info, operation_mode_e _mode) : + vsomeip_utilities::base_logger("OFIC", "OFFERED SERVICES INFO TEST CLIENT"), service_info_(_service_info), remote_service_info_(_remote_service_info), operation_mode_(_mode), diff --git a/test/network_tests/offered_services_info_test/offered_services_info_test_local.json b/test/network_tests/offered_services_info_test/offered_services_info_test_local.json index 872ebd2d0..42caa3504 100644 --- a/test/network_tests/offered_services_info_test/offered_services_info_test_local.json +++ b/test/network_tests/offered_services_info_test/offered_services_info_test_local.json @@ -1,20 +1,20 @@ { "unicast" : "127.0.0.1", "diagnosis":"0x12", - "logging" : + "logging" : { "level" : "warning", "console" : "true", - "file" : + "file" : { "enable" : "false", "path" : "/tmp/vsomeip.log" }, - "dlt" : "false" + "dlt" : "true" }, - "applications" : + "applications" : [ { "name" : "offered_services_info_test_service", @@ -22,7 +22,7 @@ } ], - "services" : + "services" : [ { "service" : "0x1111", @@ -47,7 +47,7 @@ ], "routing" : "routingmanagerd", - "service-discovery" : + "service-discovery" : { "enable" : "false", "multicast" : "224.0.0.1", diff --git a/test/network_tests/offered_services_info_test/offered_services_info_test_service.cpp b/test/network_tests/offered_services_info_test/offered_services_info_test_service.cpp index 3edd721d6..d1f9726d7 100644 --- a/test/network_tests/offered_services_info_test/offered_services_info_test_service.cpp +++ b/test/network_tests/offered_services_info_test/offered_services_info_test_service.cpp @@ -1,4 +1,4 @@ -// Copyright (C) 2014-2017 Bayerische Motoren Werke Aktiengesellschaft (BMW AG) +// Copyright (C) 2014-2023 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/. @@ -26,6 +26,8 @@ #endif // ANDROID #include "offered_services_info_test_globals.hpp" +#include "../someip_test_globals.hpp" +#include static std::string service_number; std::map> all_offered_services; @@ -33,9 +35,10 @@ std::map> local_offered_servic std::map> remote_offered_services; -class offer_test_service { +class offer_test_service : public vsomeip_utilities::base_logger { public: offer_test_service(struct offer_test::service_info _service_info, struct offer_test::service_info _remote_service_info) : + vsomeip_utilities::base_logger("OTS1", "OFFER TEST SERVICE"), service_info_(_service_info), remote_service_info_(_remote_service_info), // service with number 1 uses "routingmanagerd" as application name diff --git a/test/network_tests/payload_tests/conf/external_local_payload_test_client_external.json.in b/test/network_tests/payload_tests/conf/external_local_payload_test_client_external.json.in index 0abaea235..f6179cb91 100644 --- a/test/network_tests/payload_tests/conf/external_local_payload_test_client_external.json.in +++ b/test/network_tests/payload_tests/conf/external_local_payload_test_client_external.json.in @@ -1,11 +1,11 @@ { "unicast" : "@TEST_IP_SLAVE@", "netmask" : "255.255.255.0", - "logging" : + "logging" : { "level" : "debug", "console" : "true", - "file" : + "file" : { "enable" : "true", "path" : "/var/log/vsomeip.log" @@ -14,7 +14,7 @@ "dlt" : "true" }, - "applications" : + "applications" : [ { "name" : "external_local_payload_test_client_external", @@ -22,14 +22,14 @@ } ], - "services" : + "services" : [ { "service" : "0x1234", "instance" : "0x5678", "unicast" : "@TEST_IP_MASTER@", "unreliable" : "30509", - "reliable" : + "reliable" : { "port" : "30510", "enable-magic-cookies" : "false" @@ -43,7 +43,7 @@ "max-retention-time-response" : "0" }, "routing" : "external_local_payload_test_client_external", - "service-discovery" : + "service-discovery" : { "enable" : "false", "multicast" : "224.0.0.1", diff --git a/test/network_tests/payload_tests/conf/external_local_payload_test_client_local.json.in b/test/network_tests/payload_tests/conf/external_local_payload_test_client_local.json.in index 1f4fd6db8..2666c106d 100644 --- a/test/network_tests/payload_tests/conf/external_local_payload_test_client_local.json.in +++ b/test/network_tests/payload_tests/conf/external_local_payload_test_client_local.json.in @@ -1,11 +1,11 @@ { "unicast" : "@TEST_IP_MASTER@", "netmask" : "255.255.255.0", - "logging" : + "logging" : { "level" : "debug", "console" : "true", - "file" : + "file" : { "enable" : "true", "path" : "/var/log/vsomeip.log" @@ -14,7 +14,7 @@ "dlt" : "true" }, - "applications" : + "applications" : [ { "name" : "external_local_payload_test_client_local", @@ -22,15 +22,15 @@ } ], - - "services" : + + "services" : [ { "service" : "0x1234", "instance" : "0x5678", "unicast" : "@TEST_IP_MASTER@", "unreliable" : "30509", - "reliable" : + "reliable" : { "port" : "30510", "enable-magic-cookies" : "false" @@ -44,7 +44,7 @@ "max-retention-time-response" : "0" }, "routing" : "external_local_payload_test_service", - "service-discovery" : + "service-discovery" : { "enable" : "false", "multicast" : "224.0.0.1", diff --git a/test/network_tests/payload_tests/conf/external_local_payload_test_service.json.in b/test/network_tests/payload_tests/conf/external_local_payload_test_service.json.in index aaeae8273..8c08c7fae 100644 --- a/test/network_tests/payload_tests/conf/external_local_payload_test_service.json.in +++ b/test/network_tests/payload_tests/conf/external_local_payload_test_service.json.in @@ -1,19 +1,19 @@ { "unicast" : "@TEST_IP_MASTER@", - "logging" : + "logging" : { "level" : "debug", "console" : "true", - "file" : + "file" : { "enable" : "false", "path" : "/tmp/vsomeip.log" }, - "dlt" : "false" + "dlt" : "true" }, - "applications" : + "applications" : [ { "name" : "external_local_payload_test_service", @@ -21,13 +21,13 @@ } ], - "services" : + "services" : [ { "service" : "0x1234", "instance" : "0x5678", "unreliable" : "30509", - "reliable" : + "reliable" : { "port" : "30510", "enable-magic-cookies" : "false" @@ -41,7 +41,7 @@ "max-retention-time-response" : "0" }, "routing" : "external_local_payload_test_service", - "service-discovery" : + "service-discovery" : { "enable" : "false", "multicast" : "224.0.0.1", diff --git a/test/network_tests/payload_tests/local_payload_test_client.json b/test/network_tests/payload_tests/local_payload_test_client.json index 24fa1fa53..c72bb7864 100644 --- a/test/network_tests/payload_tests/local_payload_test_client.json +++ b/test/network_tests/payload_tests/local_payload_test_client.json @@ -1,11 +1,11 @@ { "unicast" : "127.0.0.1", "netmask" : "255.255.255.0", - "logging" : + "logging" : { "level" : "debug", "console" : "true", - "file" : + "file" : { "enable" : "true", "path" : "/var/log/vsomeip.log" @@ -14,19 +14,19 @@ "dlt" : "true" }, - "applications" : + "applications" : [ { "name" : "local_payload_test_client", "id" : "0x1343" } ], - "services" : - [ + "services" : + [ ], "routing" : "local_payload_test_service", - "service-discovery" : + "service-discovery" : { "enable" : "false", "multicast" : "224.0.0.1", diff --git a/test/network_tests/payload_tests/local_payload_test_service.json b/test/network_tests/payload_tests/local_payload_test_service.json index b5c83a62d..0454cfcab 100644 --- a/test/network_tests/payload_tests/local_payload_test_service.json +++ b/test/network_tests/payload_tests/local_payload_test_service.json @@ -1,19 +1,19 @@ { "unicast" : "127.0.0.1", - "logging" : + "logging" : { "level" : "debug", "console" : "true", - "file" : + "file" : { "enable" : "false", "path" : "/tmp/vsomeip.log" }, - "dlt" : "false" + "dlt" : "true" }, - "applications" : + "applications" : [ { "name" : "local_payload_test_service", @@ -21,7 +21,7 @@ } ], - "services" : + "services" : [ { "service" : "0x1234", @@ -30,7 +30,7 @@ ], "routing" : "local_payload_test_service", - "service-discovery" : + "service-discovery" : { "enable" : "false", "multicast" : "224.0.0.1", diff --git a/test/network_tests/payload_tests/payload_test_client.cpp b/test/network_tests/payload_tests/payload_test_client.cpp index 5907c9b6a..3395668b7 100644 --- a/test/network_tests/payload_tests/payload_test_client.cpp +++ b/test/network_tests/payload_tests/payload_test_client.cpp @@ -1,4 +1,4 @@ -// Copyright (C) 2015-2017 Bayerische Motoren Werke Aktiengesellschaft (BMW AG) +// Copyright (C) 2015-2023 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/. diff --git a/test/network_tests/payload_tests/payload_test_client.hpp b/test/network_tests/payload_tests/payload_test_client.hpp index 2757d0004..1bab6ba6e 100644 --- a/test/network_tests/payload_tests/payload_test_client.hpp +++ b/test/network_tests/payload_tests/payload_test_client.hpp @@ -1,4 +1,4 @@ -// Copyright (C) 2015-2017 Bayerische Motoren Werke Aktiengesellschaft (BMW AG) +// Copyright (C) 2015-2023 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/. @@ -17,6 +17,7 @@ #include #include "../someip_test_globals.hpp" +#include #include "stopwatch.hpp" diff --git a/test/network_tests/payload_tests/payload_test_service.cpp b/test/network_tests/payload_tests/payload_test_service.cpp index 92e26922f..0aa55afed 100644 --- a/test/network_tests/payload_tests/payload_test_service.cpp +++ b/test/network_tests/payload_tests/payload_test_service.cpp @@ -1,4 +1,4 @@ -// Copyright (C) 2015-2017 Bayerische Motoren Werke Aktiengesellschaft (BMW AG) +// Copyright (C) 2015-2023 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/. diff --git a/test/network_tests/payload_tests/payload_test_service.hpp b/test/network_tests/payload_tests/payload_test_service.hpp index 9054fd9ba..7d3c01d56 100644 --- a/test/network_tests/payload_tests/payload_test_service.hpp +++ b/test/network_tests/payload_tests/payload_test_service.hpp @@ -1,4 +1,4 @@ -// Copyright (C) 2015-2017 Bayerische Motoren Werke Aktiengesellschaft (BMW AG) +// Copyright (C) 2015-2023 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/. @@ -15,6 +15,7 @@ #include #include "../someip_test_globals.hpp" +#include class payload_test_service { diff --git a/test/network_tests/payload_tests/stopwatch.cpp b/test/network_tests/payload_tests/stopwatch.cpp index 59570e46e..216780f5f 100644 --- a/test/network_tests/payload_tests/stopwatch.cpp +++ b/test/network_tests/payload_tests/stopwatch.cpp @@ -1,4 +1,4 @@ -// Copyright (C) 2015-2017 Bayerische Motoren Werke Aktiengesellschaft (BMW AG) +// Copyright (C) 2015-2023 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/. @@ -39,4 +39,3 @@ stop_watch::usec_t stop_watch::now() { return (usec_t) ts.tv_sec * USEC_PER_SEC + (usec_t) ts.tv_nsec / NSEC_PER_USEC; } - diff --git a/test/network_tests/pending_subscription_tests/conf/pending_subscription_test_master.json.in b/test/network_tests/pending_subscription_tests/conf/pending_subscription_test_master.json.in index 5bcbe9a65..b3453a0cb 100644 --- a/test/network_tests/pending_subscription_tests/conf/pending_subscription_test_master.json.in +++ b/test/network_tests/pending_subscription_tests/conf/pending_subscription_test_master.json.in @@ -9,7 +9,7 @@ "enable":"false", "path":"/tmp/vsomeip.log" }, - "dlt":"false" + "dlt":"true" }, "applications" : [ @@ -52,4 +52,4 @@ "protocol":"udp", "cyclic_offer_delay" : "1000" } -} \ No newline at end of file +} diff --git a/test/network_tests/pending_subscription_tests/pending_subscription_test_sd_msg_sender.cpp b/test/network_tests/pending_subscription_tests/pending_subscription_test_sd_msg_sender.cpp index 74471a5f5..47ac36261 100644 --- a/test/network_tests/pending_subscription_tests/pending_subscription_test_sd_msg_sender.cpp +++ b/test/network_tests/pending_subscription_tests/pending_subscription_test_sd_msg_sender.cpp @@ -1,4 +1,4 @@ -// Copyright (C) 2015-2017 Bayerische Motoren Werke Aktiengesellschaft (BMW AG) +// Copyright (C) 2015-2023 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/. @@ -1097,7 +1097,7 @@ TEST_F(pending_subscription, subscribe_resubscribe_mixed) std::thread receive_thread([&](){ std::vector receive_buffer(4096); - std::vector its_received_events; + std::set its_received_events; const std::uint32_t expected_acks(3); std::atomic acks_received(0); @@ -1106,7 +1106,7 @@ TEST_F(pending_subscription, subscribe_resubscribe_mixed) std::atomic responses_received(0); const std::uint32_t expected_notifications(2); - std::atomic notifications_received(0); + std::atomic notifications_received(0); bool keep_receiving(true); bool first_initial_event_checked(false); @@ -1136,6 +1136,7 @@ TEST_F(pending_subscription, subscribe_resubscribe_mixed) receive_buffer[its_pos + VSOMEIP_SERVICE_POS_MAX]); vsomeip::method_t its_method = VSOMEIP_BYTES_TO_WORD(receive_buffer[its_pos + VSOMEIP_METHOD_POS_MIN], receive_buffer[its_pos + VSOMEIP_METHOD_POS_MAX]); + its_pos += its_message_size; bytes_transfered -= its_message_size; if (its_service == vsomeip::sd::service && its_method == vsomeip::sd::method) { @@ -1167,22 +1168,22 @@ TEST_F(pending_subscription, subscribe_resubscribe_mixed) EXPECT_EQ(0x2222, msg.get_client()); responses_received++; } else if (msg.get_message_type() == vsomeip::message_type_e::MT_NOTIFICATION) { - its_received_events.push_back(msg.get_method()); + its_received_events.insert(msg.get_method()); if (its_received_events.size() == 2) { - EXPECT_EQ(static_cast(pending_subscription_test::service.event_id + 1u), its_received_events[0]); - EXPECT_EQ(pending_subscription_test::service.event_id, its_received_events[1]); + EXPECT_TRUE(its_received_events.find(static_cast(pending_subscription_test::service.event_id + 1u)) != its_received_events.end()); + EXPECT_TRUE(its_received_events.find(pending_subscription_test::service.event_id) != its_received_events.end()); } EXPECT_EQ(1u, msg.get_payload()->get_length()); EXPECT_EQ(0xDD, *msg.get_payload()->get_data()); EXPECT_EQ(pending_subscription_test::service.service_id, msg.get_service()); EXPECT_EQ(0x0, msg.get_client()); - notifications_received++; + notifications_received = its_received_events.size(); } } if (!first_initial_event_checked && notifications_received == 1) { EXPECT_EQ(1u, its_received_events.size()); - EXPECT_EQ(static_cast(pending_subscription_test::service.event_id + 1u), its_received_events[0]); + EXPECT_TRUE(its_received_events.find(static_cast(pending_subscription_test::service.event_id + 1u)) != its_received_events.end()); // all subscribeAcks and one initial event of first event received first_initial_event_received.set_value(); first_initial_event_checked = true; @@ -1191,8 +1192,8 @@ TEST_F(pending_subscription, subscribe_resubscribe_mixed) if (!second_initial_event_checked && notifications_received == 2) { // events were received as well // all subscribeAcks and one initial event of second event received EXPECT_EQ(2u, its_received_events.size()); - EXPECT_EQ(static_cast(pending_subscription_test::service.event_id + 1u), its_received_events[0]); - EXPECT_EQ(pending_subscription_test::service.event_id, its_received_events[1]); + EXPECT_TRUE(its_received_events.find(static_cast(pending_subscription_test::service.event_id + 1u)) != its_received_events.end()); + EXPECT_TRUE(its_received_events.find(pending_subscription_test::service.event_id) != its_received_events.end()); second_initial_event_received.set_value(); second_initial_event_checked = true; } diff --git a/test/network_tests/pending_subscription_tests/pending_subscription_test_service.cpp b/test/network_tests/pending_subscription_tests/pending_subscription_test_service.cpp index e754ebd1f..1a206b34b 100644 --- a/test/network_tests/pending_subscription_tests/pending_subscription_test_service.cpp +++ b/test/network_tests/pending_subscription_tests/pending_subscription_test_service.cpp @@ -1,4 +1,4 @@ -// Copyright (C) 2014-2017 Bayerische Motoren Werke Aktiengesellschaft (BMW AG) +// Copyright (C) 2014-2023 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/. @@ -20,10 +20,13 @@ #include #include "pending_subscription_test_globals.hpp" +#include "../someip_test_globals.hpp" +#include -class pending_subscription_test_service { +class pending_subscription_test_service : public vsomeip_utilities::base_logger { public: pending_subscription_test_service(struct pending_subscription_test::service_info _service_info, pending_subscription_test::test_mode_e _testmode) : + vsomeip_utilities::base_logger("PSTS", "PENDING SUBSCRIPTION TEST SERVICE"), service_info_(_service_info), testmode_(_testmode), app_(vsomeip::runtime::get()->create_application("pending_subscription_test_service")), diff --git a/test/network_tests/restart_routing_tests/restart_routing_test_autoconfig.json b/test/network_tests/restart_routing_tests/restart_routing_test_autoconfig.json index f50dba72c..ad1d824d7 100644 --- a/test/network_tests/restart_routing_tests/restart_routing_test_autoconfig.json +++ b/test/network_tests/restart_routing_tests/restart_routing_test_autoconfig.json @@ -1,11 +1,11 @@ { "unicast" : "127.0.0.1", "netmask" : "255.255.255.0", - "logging" : + "logging" : { "level" : "warning", "console" : "true", - "file" : + "file" : { "enable" : "true", "path" : "/var/log/vsomeip.log" @@ -14,7 +14,7 @@ "dlt" : "true" }, - "service-discovery" : + "service-discovery" : { "enable" : "false", "multicast" : "224.0.0.1", diff --git a/test/network_tests/restart_routing_tests/restart_routing_test_client.hpp b/test/network_tests/restart_routing_tests/restart_routing_test_client.hpp index cd4a12fd6..8a7c9e70d 100644 --- a/test/network_tests/restart_routing_tests/restart_routing_test_client.hpp +++ b/test/network_tests/restart_routing_tests/restart_routing_test_client.hpp @@ -1,5 +1,5 @@ -// Copyright (C) 2015-2017 Bayerische Motoren Werke Aktiengesellschaft (BMW AG) +// Copyright (C) 2015-2023 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/. @@ -12,6 +12,7 @@ #include #include "../someip_test_globals.hpp" +#include #include #include diff --git a/test/network_tests/restart_routing_tests/restart_routing_test_client.json b/test/network_tests/restart_routing_tests/restart_routing_test_client.json index 93fafab31..b71adc247 100644 --- a/test/network_tests/restart_routing_tests/restart_routing_test_client.json +++ b/test/network_tests/restart_routing_tests/restart_routing_test_client.json @@ -1,11 +1,11 @@ { "unicast" : "127.0.0.1", "netmask" : "255.255.255.0", - "logging" : + "logging" : { "level" : "warning", "console" : "true", - "file" : + "file" : { "enable" : "true", "path" : "/var/log/vsomeip.log" @@ -14,7 +14,7 @@ "dlt" : "true" }, - "applications" : + "applications" : [ { "name" : "restart_routing_test_client1", @@ -31,14 +31,14 @@ { "name" : "restart_routing_test_client4", "id" : "0x1346" - } + } ], - "services" : - [ + "services" : + [ ], "routing" : "routingmanagerd", - "service-discovery" : + "service-discovery" : { "enable" : "false", "multicast" : "224.0.0.1", diff --git a/test/network_tests/restart_routing_tests/restart_routing_test_service.cpp b/test/network_tests/restart_routing_tests/restart_routing_test_service.cpp index 8130d6239..92f0ff0a2 100644 --- a/test/network_tests/restart_routing_tests/restart_routing_test_service.cpp +++ b/test/network_tests/restart_routing_tests/restart_routing_test_service.cpp @@ -1,4 +1,4 @@ -// Copyright (C) 2015-2017 Bayerische Motoren Werke Aktiengesellschaft (BMW AG) +// Copyright (C) 2015-2023 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/. diff --git a/test/network_tests/restart_routing_tests/restart_routing_test_service.hpp b/test/network_tests/restart_routing_tests/restart_routing_test_service.hpp index 3abfe1758..7660b8fcb 100644 --- a/test/network_tests/restart_routing_tests/restart_routing_test_service.hpp +++ b/test/network_tests/restart_routing_tests/restart_routing_test_service.hpp @@ -1,4 +1,4 @@ -// Copyright (C) 2015-2017 Bayerische Motoren Werke Aktiengesellschaft (BMW AG) +// Copyright (C) 2015-2023 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/. @@ -11,6 +11,7 @@ #include #include "../someip_test_globals.hpp" +#include #include #include diff --git a/test/network_tests/restart_routing_tests/restart_routing_test_service.json b/test/network_tests/restart_routing_tests/restart_routing_test_service.json index 9a1d3bfb6..516f33177 100644 --- a/test/network_tests/restart_routing_tests/restart_routing_test_service.json +++ b/test/network_tests/restart_routing_tests/restart_routing_test_service.json @@ -1,19 +1,19 @@ { "unicast" : "127.0.0.1", - "logging" : + "logging" : { "level" : "warning", "console" : "true", - "file" : + "file" : { "enable" : "false", "path" : "/tmp/vsomeip.log" }, - "dlt" : "false" + "dlt" : "true" }, - "applications" : + "applications" : [ { "name" : "routingmanagerd", @@ -25,7 +25,7 @@ } ], - "services" : + "services" : [ { "service" : "0x1234", @@ -34,7 +34,7 @@ ], "routing" : "routingmanagerd", - "service-discovery" : + "service-discovery" : { "enable" : "false", "multicast" : "224.0.0.1", diff --git a/test/network_tests/routing_tests/conf/external_local_routing_test_client_external.json.in b/test/network_tests/routing_tests/conf/external_local_routing_test_client_external.json.in index 0aaa664aa..e6b0e9df9 100644 --- a/test/network_tests/routing_tests/conf/external_local_routing_test_client_external.json.in +++ b/test/network_tests/routing_tests/conf/external_local_routing_test_client_external.json.in @@ -2,11 +2,11 @@ "unicast" : "@TEST_IP_SLAVE@", "netmask" : "255.255.255.0", "diagnosis" : "0x16", - "logging" : + "logging" : { "level" : "debug", "console" : "true", - "file" : + "file" : { "enable" : "true", "path" : "/var/log/vsomeip.log" @@ -15,7 +15,7 @@ "dlt" : "true" }, - "applications" : + "applications" : [ { "name" : "external_local_routing_test_client_external", @@ -23,7 +23,7 @@ } ], - "services" : + "services" : [ { "service" : "0x1234", @@ -37,7 +37,7 @@ "enabled": false, "host": "external_local_routing_test_client_external" }, - "service-discovery" : + "service-discovery" : { "enable" : "false", "multicast" : "224.0.0.1", diff --git a/test/network_tests/routing_tests/conf/external_local_routing_test_service.json.in b/test/network_tests/routing_tests/conf/external_local_routing_test_service.json.in index a4deb82e2..d87882b16 100644 --- a/test/network_tests/routing_tests/conf/external_local_routing_test_service.json.in +++ b/test/network_tests/routing_tests/conf/external_local_routing_test_service.json.in @@ -1,20 +1,20 @@ { "unicast" : "@TEST_IP_MASTER@", "diagnosis":"0x12", - "logging" : + "logging" : { "level" : "debug", "console" : "true", - "file" : + "file" : { "enable" : "false", "path" : "/tmp/vsomeip.log" }, - "dlt" : "false" + "dlt" : "true" }, - "applications" : + "applications" : [ { "name" : "external_local_routing_test_service", @@ -22,7 +22,7 @@ } ], - "services" : + "services" : [ { "service" : "0x1234", @@ -32,7 +32,7 @@ ], "routing" : "external_local_routing_test_service", - "service-discovery" : + "service-discovery" : { "enable" : "false", "multicast" : "224.0.0.1", diff --git a/test/network_tests/routing_tests/conf/local_routing_test_starter_qnx.sh.in b/test/network_tests/routing_tests/conf/local_routing_test_starter_qnx.sh.in index 70a51cafe..2f30486c6 100755 --- a/test/network_tests/routing_tests/conf/local_routing_test_starter_qnx.sh.in +++ b/test/network_tests/routing_tests/conf/local_routing_test_starter_qnx.sh.in @@ -1,5 +1,5 @@ #!/bin/sh -# Copyright (C) 2015-2017 Bayerische Motoren Werke Aktiengesellschaft (BMW AG) +# Copyright (C) 2015-2023 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/. diff --git a/test/network_tests/routing_tests/external_local_routing_test_service.cpp b/test/network_tests/routing_tests/external_local_routing_test_service.cpp index 658e03517..ba4cdd0c1 100644 --- a/test/network_tests/routing_tests/external_local_routing_test_service.cpp +++ b/test/network_tests/routing_tests/external_local_routing_test_service.cpp @@ -1,4 +1,4 @@ -// Copyright (C) 2015-2017 Bayerische Motoren Werke Aktiengesellschaft (BMW AG) +// Copyright (C) 2015-2023 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/. diff --git a/test/network_tests/routing_tests/external_local_routing_test_service.hpp b/test/network_tests/routing_tests/external_local_routing_test_service.hpp index a25025ec5..2499bc840 100644 --- a/test/network_tests/routing_tests/external_local_routing_test_service.hpp +++ b/test/network_tests/routing_tests/external_local_routing_test_service.hpp @@ -1,4 +1,4 @@ -// Copyright (C) 2015-2017 Bayerische Motoren Werke Aktiengesellschaft (BMW AG) +// Copyright (C) 2015-2023 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/. @@ -15,6 +15,7 @@ #include #include "../someip_test_globals.hpp" +#include class external_local_routing_test_service { diff --git a/test/network_tests/routing_tests/local_routing_test_client.cpp b/test/network_tests/routing_tests/local_routing_test_client.cpp index d637755f8..4bde183f4 100644 --- a/test/network_tests/routing_tests/local_routing_test_client.cpp +++ b/test/network_tests/routing_tests/local_routing_test_client.cpp @@ -1,4 +1,4 @@ -// Copyright (C) 2015-2017 Bayerische Motoren Werke Aktiengesellschaft (BMW AG) +// Copyright (C) 2015-2023 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/. @@ -24,10 +24,6 @@ bool local_routing_test_client::init() return false; } - app_->register_state_handler( - std::bind(&local_routing_test_client::on_state, this, - std::placeholders::_1)); - app_->register_message_handler(vsomeip::ANY_SERVICE, vsomeip_test::TEST_SERVICE_INSTANCE_ID, vsomeip::ANY_METHOD, std::bind(&local_routing_test_client::on_message, this, @@ -38,6 +34,10 @@ bool local_routing_test_client::init() std::bind(&local_routing_test_client::on_availability, this, std::placeholders::_1, std::placeholders::_2, std::placeholders::_3)); + + app_->request_service(vsomeip_test::TEST_SERVICE_SERVICE_ID, + vsomeip_test::TEST_SERVICE_INSTANCE_ID, false); + return true; } @@ -60,15 +60,6 @@ void local_routing_test_client::join_sender_thread(){ ASSERT_EQ(number_of_sent_messages_, number_of_acknowledged_messages_); } -void local_routing_test_client::on_state(vsomeip::state_type_e _state) -{ - if(_state == vsomeip::state_type_e::ST_REGISTERED) - { - app_->request_service(vsomeip_test::TEST_SERVICE_SERVICE_ID, - vsomeip_test::TEST_SERVICE_INSTANCE_ID, false); - } -} - void local_routing_test_client::on_availability(vsomeip::service_t _service, vsomeip::instance_t _instance, bool _is_available) { diff --git a/test/network_tests/routing_tests/local_routing_test_client.hpp b/test/network_tests/routing_tests/local_routing_test_client.hpp index 7cc442ad3..09af0bf06 100644 --- a/test/network_tests/routing_tests/local_routing_test_client.hpp +++ b/test/network_tests/routing_tests/local_routing_test_client.hpp @@ -1,4 +1,4 @@ -// Copyright (C) 2015-2017 Bayerische Motoren Werke Aktiengesellschaft (BMW AG) +// Copyright (C) 2015-2023 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/. @@ -16,6 +16,7 @@ #include #include "../someip_test_globals.hpp" +#include class local_routing_test_client { diff --git a/test/network_tests/routing_tests/local_routing_test_client.json b/test/network_tests/routing_tests/local_routing_test_client.json index e3521c859..e0756b960 100644 --- a/test/network_tests/routing_tests/local_routing_test_client.json +++ b/test/network_tests/routing_tests/local_routing_test_client.json @@ -2,11 +2,11 @@ "unicast" : "127.0.0.1", "netmask" : "255.255.255.0", "diagnosis":"0x12", - "logging" : + "logging" : { "level" : "debug", "console" : "true", - "file" : + "file" : { "enable" : "true", "path" : "/var/log/vsomeip.log" @@ -15,7 +15,7 @@ "dlt" : "true" }, - "applications" : + "applications" : [ { "name" : "local_routing_test_client", @@ -23,16 +23,16 @@ } ], - "services" : + "services" : [ ], "routing" : "routingmanagerd", - "service-discovery" : + "service-discovery" : { "enable" : "false", "multicast" : "224.0.0.1", "port" : "30491", "protocol" : "udp" } -} \ No newline at end of file +} diff --git a/test/network_tests/routing_tests/local_routing_test_service.cpp b/test/network_tests/routing_tests/local_routing_test_service.cpp index 9836f68cf..2a819e215 100644 --- a/test/network_tests/routing_tests/local_routing_test_service.cpp +++ b/test/network_tests/routing_tests/local_routing_test_service.cpp @@ -1,4 +1,4 @@ -// Copyright (C) 2015-2017 Bayerische Motoren Werke Aktiengesellschaft (BMW AG) +// Copyright (C) 2015-2023 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/. diff --git a/test/network_tests/routing_tests/local_routing_test_service.hpp b/test/network_tests/routing_tests/local_routing_test_service.hpp index 531fdb781..109dade40 100644 --- a/test/network_tests/routing_tests/local_routing_test_service.hpp +++ b/test/network_tests/routing_tests/local_routing_test_service.hpp @@ -1,4 +1,4 @@ -// Copyright (C) 2015-2017 Bayerische Motoren Werke Aktiengesellschaft (BMW AG) +// Copyright (C) 2015-2023 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/. @@ -15,6 +15,7 @@ #include #include "../someip_test_globals.hpp" +#include class local_routing_test_service { diff --git a/test/network_tests/routing_tests/local_routing_test_service.json b/test/network_tests/routing_tests/local_routing_test_service.json index 6b7e11d52..20c776741 100644 --- a/test/network_tests/routing_tests/local_routing_test_service.json +++ b/test/network_tests/routing_tests/local_routing_test_service.json @@ -1,20 +1,20 @@ { "unicast" : "127.0.0.1", "diagnosis":"0x12", - "logging" : + "logging" : { "level" : "debug", "console" : "true", - "file" : + "file" : { "enable" : "false", "path" : "/tmp/vsomeip.log" }, - "dlt" : "false" + "dlt" : "true" }, - "applications" : + "applications" : [ { "name" : "local_routing_test_service", @@ -22,7 +22,7 @@ } ], - "services" : + "services" : [ { "service" : "0x1234", @@ -31,7 +31,7 @@ ], "routing" : "routingmanagerd", - "service-discovery" : + "service-discovery" : { "enable" : "false", "multicast" : "224.0.0.1", diff --git a/test/network_tests/second_address_tests/conf/second_address_test_master_client.json.in b/test/network_tests/second_address_tests/conf/second_address_test_master_client.json.in index 542480f9b..4df776d96 100644 --- a/test/network_tests/second_address_tests/conf/second_address_test_master_client.json.in +++ b/test/network_tests/second_address_tests/conf/second_address_test_master_client.json.in @@ -9,7 +9,7 @@ "enable":"false", "path":"/tmp/vsomeip.log" }, - "dlt":"false" + "dlt":"true" }, "applications" : [ @@ -29,4 +29,4 @@ "cyclic_offer_delay" : "1000", "ttl" : "3" } -} \ No newline at end of file +} diff --git a/test/network_tests/second_address_tests/conf/second_address_test_master_service_udp.json.in b/test/network_tests/second_address_tests/conf/second_address_test_master_service_udp.json.in index 1b45898cf..c42083ddd 100644 --- a/test/network_tests/second_address_tests/conf/second_address_test_master_service_udp.json.in +++ b/test/network_tests/second_address_tests/conf/second_address_test_master_service_udp.json.in @@ -9,7 +9,7 @@ "enable":"false", "path":"/tmp/vsomeip.log" }, - "dlt":"false" + "dlt":"true" }, "applications" : [ @@ -37,4 +37,4 @@ "cyclic_offer_delay" : "1000", "ttl" : "3" } -} \ No newline at end of file +} diff --git a/test/network_tests/second_address_tests/conf/second_address_test_slave_client.json.in b/test/network_tests/second_address_tests/conf/second_address_test_slave_client.json.in index 303bfaed7..667198053 100644 --- a/test/network_tests/second_address_tests/conf/second_address_test_slave_client.json.in +++ b/test/network_tests/second_address_tests/conf/second_address_test_slave_client.json.in @@ -9,7 +9,7 @@ "enable":"false", "path":"/tmp/vsomeip.log" }, - "dlt":"false" + "dlt":"true" }, "applications" : [ @@ -29,4 +29,4 @@ "cyclic_offer_delay" : "1000", "ttl" : "3" } -} \ No newline at end of file +} diff --git a/test/network_tests/second_address_tests/conf/second_address_test_slave_service_udp.json.in b/test/network_tests/second_address_tests/conf/second_address_test_slave_service_udp.json.in index 9a7c06271..e6adfb127 100644 --- a/test/network_tests/second_address_tests/conf/second_address_test_slave_service_udp.json.in +++ b/test/network_tests/second_address_tests/conf/second_address_test_slave_service_udp.json.in @@ -9,7 +9,7 @@ "enable":"false", "path":"/tmp/vsomeip.log" }, - "dlt":"false" + "dlt":"true" }, "applications" : [ @@ -37,4 +37,4 @@ "cyclic_offer_delay" : "1000", "ttl" : "3" } -} \ No newline at end of file +} diff --git a/test/network_tests/second_address_tests/conf/second_address_test_slave_starter.sh.in b/test/network_tests/second_address_tests/conf/second_address_test_slave_starter.sh.in index 5694aa608..129d20905 100755 --- a/test/network_tests/second_address_tests/conf/second_address_test_slave_starter.sh.in +++ b/test/network_tests/second_address_tests/conf/second_address_test_slave_starter.sh.in @@ -35,6 +35,8 @@ elif [ "$OPERATIONMODE" = "SERVICE" ]; then fi fi +rm -f /tmp/vsomeip* + ../../examples/routingmanagerd/routingmanagerd & PID_VSOMEIPD=$! diff --git a/test/network_tests/second_address_tests/second_address_test_client.cpp b/test/network_tests/second_address_tests/second_address_test_client.cpp index 4ebbf2ce7..72aae04ad 100644 --- a/test/network_tests/second_address_tests/second_address_test_client.cpp +++ b/test/network_tests/second_address_tests/second_address_test_client.cpp @@ -1,4 +1,4 @@ -// Copyright (C) 2014-2018 Bayerische Motoren Werke Aktiengesellschaft (BMW AG) +// Copyright (C) 2014-2023 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/. @@ -19,10 +19,13 @@ #include #include "second_address_test_globals.hpp" +#include "../someip_test_globals.hpp" +#include -class second_address_test_client { +class second_address_test_client : public vsomeip_utilities::base_logger { public: second_address_test_client(struct second_address_test::service_info _service_info, bool _use_tcp) : + vsomeip_utilities::base_logger("SATC", "SECOND ADDRESS TEST CLIENT"), service_info_(_service_info), use_tcp_(_use_tcp), app_(vsomeip::runtime::get()->create_application("second_address_test_client")), diff --git a/test/network_tests/second_address_tests/second_address_test_master_starter.sh b/test/network_tests/second_address_tests/second_address_test_master_starter.sh index 03d726b62..756e22e1b 100755 --- a/test/network_tests/second_address_tests/second_address_test_master_starter.sh +++ b/test/network_tests/second_address_tests/second_address_test_master_starter.sh @@ -34,6 +34,8 @@ elif [ "$OPERATIONMODE" = "CLIENT" ]; then export VSOMEIP_CONFIGURATION=second_address_test_master_client.json fi +rm -f /tmp/vsomeip* + ../../examples/routingmanagerd/routingmanagerd & PID_VSOMEIPD=$! diff --git a/test/network_tests/second_address_tests/second_address_test_service.cpp b/test/network_tests/second_address_tests/second_address_test_service.cpp index 5b8a7a248..fc9d0a281 100644 --- a/test/network_tests/second_address_tests/second_address_test_service.cpp +++ b/test/network_tests/second_address_tests/second_address_test_service.cpp @@ -1,4 +1,4 @@ -// Copyright (C) 2014-2019 Bayerische Motoren Werke Aktiengesellschaft (BMW AG) +// Copyright (C) 2014-2023 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/. @@ -15,10 +15,13 @@ #include #include "second_address_test_globals.hpp" +#include "../someip_test_globals.hpp" +#include -class second_address_test_service { +class second_address_test_service : public vsomeip_utilities::base_logger { public: second_address_test_service(struct second_address_test::service_info _service_info) : + vsomeip_utilities::base_logger("SATS", "SECOND ADDRESS TEST SERVICE"), service_info_(_service_info), app_(vsomeip::runtime::get()->create_application("second_address_test_service")), offer_thread_(std::bind(&second_address_test_service::run, this)) { diff --git a/test/network_tests/security_tests/conf/security_test_config_client_external_allow.json.in b/test/network_tests/security_tests/conf/security_test_config_client_external_allow.json.in index e73f3dbf9..ab25fbbf0 100644 --- a/test/network_tests/security_tests/conf/security_test_config_client_external_allow.json.in +++ b/test/network_tests/security_tests/conf/security_test_config_client_external_allow.json.in @@ -6,7 +6,7 @@ "level" : "info", "console" : "true", "file" : { "enable" : "false", "path" : "/tmp/vsomeip.log" }, - "dlt" : "false" + "dlt" : "true" }, "applications" : [ diff --git a/test/network_tests/security_tests/conf/security_test_config_client_external_deny.json.in b/test/network_tests/security_tests/conf/security_test_config_client_external_deny.json.in index 1161f4f01..de5b6ab26 100644 --- a/test/network_tests/security_tests/conf/security_test_config_client_external_deny.json.in +++ b/test/network_tests/security_tests/conf/security_test_config_client_external_deny.json.in @@ -6,7 +6,7 @@ "level" : "info", "console" : "true", "file" : { "enable" : "false", "path" : "/tmp/vsomeip.log" }, - "dlt" : "false" + "dlt" : "true" }, "applications" : [ diff --git a/test/network_tests/security_tests/conf/security_test_config_service_external_allow.json.in b/test/network_tests/security_tests/conf/security_test_config_service_external_allow.json.in index 4d9129a92..25660b45b 100644 --- a/test/network_tests/security_tests/conf/security_test_config_service_external_allow.json.in +++ b/test/network_tests/security_tests/conf/security_test_config_service_external_allow.json.in @@ -6,7 +6,7 @@ "level" : "info", "console" : "true", "file" : { "enable" : "false", "path" : "/tmp/vsomeip.log" }, - "dlt" : "false" + "dlt" : "true" }, "applications" : [ diff --git a/test/network_tests/security_tests/conf/security_test_config_service_external_deny.json.in b/test/network_tests/security_tests/conf/security_test_config_service_external_deny.json.in index 769b04fe6..97b398a61 100644 --- a/test/network_tests/security_tests/conf/security_test_config_service_external_deny.json.in +++ b/test/network_tests/security_tests/conf/security_test_config_service_external_deny.json.in @@ -6,7 +6,7 @@ "level" : "info", "console" : "true", "file" : { "enable" : "false", "path" : "/tmp/vsomeip.log" }, - "dlt" : "false" + "dlt" : "true" }, "applications" : [ diff --git a/test/network_tests/security_tests/conf/security_test_local_config.json.in b/test/network_tests/security_tests/conf/security_test_local_config.json.in index 60036f8f0..51825c910 100644 --- a/test/network_tests/security_tests/conf/security_test_local_config.json.in +++ b/test/network_tests/security_tests/conf/security_test_local_config.json.in @@ -1,19 +1,19 @@ { "unicast" : "localhost", "logging" : - { + { "level" : "info", "console" : "true", "file" : { "enable" : "false", "path" : "/tmp/vsomeip.log" }, - "dlt" : "false" + "dlt" : "true" }, - "applications" : + "applications" : [ { "name" : "service-sample", "id" : "0x1277" }, - { + { "name" : "client-sample", "id" : "0x1255" }, diff --git a/test/network_tests/security_tests/security_test_client.hpp b/test/network_tests/security_tests/security_test_client.hpp index df2acc888..ab3d98b85 100644 --- a/test/network_tests/security_tests/security_test_client.hpp +++ b/test/network_tests/security_tests/security_test_client.hpp @@ -1,5 +1,5 @@ -// Copyright (C) 2015-2017 Bayerische Motoren Werke Aktiengesellschaft (BMW AG) +// Copyright (C) 2015-2023 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/. @@ -12,6 +12,7 @@ #include #include "../someip_test_globals.hpp" +#include #include #include diff --git a/test/network_tests/security_tests/security_test_service.cpp b/test/network_tests/security_tests/security_test_service.cpp index 9007df149..fdfb48bee 100644 --- a/test/network_tests/security_tests/security_test_service.cpp +++ b/test/network_tests/security_tests/security_test_service.cpp @@ -1,4 +1,4 @@ -// Copyright (C) 2017 Bayerische Motoren Werke Aktiengesellschaft (BMW AG) +// Copyright (C) 2023 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/. diff --git a/test/network_tests/security_tests/security_test_service.hpp b/test/network_tests/security_tests/security_test_service.hpp index 21f1f7c35..87fb94fdf 100644 --- a/test/network_tests/security_tests/security_test_service.hpp +++ b/test/network_tests/security_tests/security_test_service.hpp @@ -1,4 +1,4 @@ -// Copyright (C) 2015-2017 Bayerische Motoren Werke Aktiengesellschaft (BMW AG) +// Copyright (C) 2015-2023 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/. @@ -11,6 +11,7 @@ #include #include "../someip_test_globals.hpp" +#include #include #include diff --git a/test/network_tests/someip_test_globals.hpp b/test/network_tests/someip_test_globals.hpp index 4380cd31a..4f1a363b5 100644 --- a/test/network_tests/someip_test_globals.hpp +++ b/test/network_tests/someip_test_globals.hpp @@ -1,4 +1,4 @@ -// Copyright (C) 2015-2017 Bayerische Motoren Werke Aktiengesellschaft (BMW AG) +// Copyright (C) 2015-2023 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/. @@ -9,6 +9,12 @@ #include #include +#ifdef USE_DLT +#ifndef ANDROID +#include +#endif +#endif + namespace vsomeip_test { @@ -38,6 +44,7 @@ constexpr std::uint32_t MAX_PAYLOADSIZE_UDP = 1400; constexpr std::uint32_t NUMBER_OF_MESSAGES_TO_SEND_ROUTING_RESTART_TESTS = 32; constexpr std::uint32_t NUMBER_OF_MESSAGES_TO_SEND_SECURITY_TESTS = 32; + } #endif /* SOMEIP_TEST_GLOBALS_HPP_ */ diff --git a/test/network_tests/someip_tp_tests/conf/someip_tp_test_master.json.in b/test/network_tests/someip_tp_tests/conf/someip_tp_test_master.json.in index a2f67a111..6d20e54d0 100644 --- a/test/network_tests/someip_tp_tests/conf/someip_tp_test_master.json.in +++ b/test/network_tests/someip_tp_tests/conf/someip_tp_test_master.json.in @@ -42,4 +42,4 @@ "protocol":"udp", "cyclic_offer_delay" : "1000" } -} \ No newline at end of file +} diff --git a/test/network_tests/someip_tp_tests/someip_tp_test_msg_sender.cpp b/test/network_tests/someip_tp_tests/someip_tp_test_msg_sender.cpp index 9599f76ce..3f79ce6ff 100644 --- a/test/network_tests/someip_tp_tests/someip_tp_test_msg_sender.cpp +++ b/test/network_tests/someip_tp_tests/someip_tp_test_msg_sender.cpp @@ -1,4 +1,4 @@ -// Copyright (C) 2015-2017 Bayerische Motoren Werke Aktiengesellschaft (BMW AG) +// Copyright (C) 2015-2023 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/. @@ -888,7 +888,7 @@ TEST_P(someip_tp, send_in_mode) std::mutex all_fragments_received_as_server_mutex_; std::unique_lock all_fragments_received_as_server_lock(all_fragments_received_as_server_mutex_); std::condition_variable all_fragments_received_as_server_cond_; - bool wait_for_all_fragments_received_as_server_(true); + std::atomic wait_for_all_fragments_received_as_server_(true); std::atomic remote_client_request_port(0); std::thread udp_server_send_thread([&]() { diff --git a/test/network_tests/someip_tp_tests/someip_tp_test_service.cpp b/test/network_tests/someip_tp_tests/someip_tp_test_service.cpp index 54a335a86..01a2c973d 100644 --- a/test/network_tests/someip_tp_tests/someip_tp_test_service.cpp +++ b/test/network_tests/someip_tp_tests/someip_tp_test_service.cpp @@ -1,4 +1,4 @@ -// Copyright (C) 2014-2019 Bayerische Motoren Werke Aktiengesellschaft (BMW AG) +// Copyright (C) 2014-2023 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/. @@ -22,10 +22,13 @@ #include "../../implementation/endpoints/include/tp.hpp" #include "someip_tp_test_globals.hpp" +#include "../someip_test_globals.hpp" +#include -class someip_tp_test_service { +class someip_tp_test_service : public vsomeip_utilities::base_logger { public: someip_tp_test_service(struct someip_tp_test::service_info _service_info, someip_tp_test::test_mode_e _testmode) : + vsomeip_utilities::base_logger("STTS", "SOMEIP TP TEST SERVICE"), service_info_(_service_info), testmode_(_testmode), app_(vsomeip::runtime::get()->create_application("someip_tp_test_service")), @@ -38,8 +41,10 @@ class someip_tp_test_service { number_responses_of_slave_(0), wait_for_two_requests_of_slave_(true), number_requests_from_slave_(0), - wait_for_two_notifications_of_slave_(true), - offer_thread_(std::bind(&someip_tp_test_service::run, this)) { + wait_for_two_notifications_of_slave_(true) { + } + + void start() { if (!app_->init()) { ADD_FAILURE() << "Couldn't initialize application"; return; @@ -50,7 +55,7 @@ class someip_tp_test_service { // offer field std::set its_eventgroups; - its_eventgroups.insert(_service_info.eventgroup_id); + its_eventgroups.insert(service_info_.eventgroup_id); app_->offer_event(service_info_.service_id, service_info_.instance_id, service_info_.event_id, its_eventgroups, vsomeip::event_type_e::ET_EVENT, std::chrono::milliseconds::zero(), @@ -105,13 +110,14 @@ class someip_tp_test_service { someip_tp_test::service_slave.method_id, std::bind(&someip_tp_test_service::on_response_from_slave, this, std::placeholders::_1)); - app_->start(); - } - ~someip_tp_test_service() { - offer_thread_.join(); + start_thread_ = std::make_shared([this]() { + app_->start(); + }); } + ~someip_tp_test_service() {} + void offer() { app_->offer_service(service_info_.service_id, 0x1); } @@ -120,6 +126,8 @@ class someip_tp_test_service { app_->stop_offer_service(service_info_.service_id, service_info_.instance_id); app_->clear_all_handler(); app_->stop(); + + start_thread_->join(); } void on_state(vsomeip::state_type_e _state) { @@ -333,7 +341,6 @@ class someip_tp_test_service { while (wait_until_shutdown_method_called_) { condition_.wait(its_lock); } - stop(); } void subscription_handler_async(vsomeip::client_t _client, std::uint32_t _uid, std::uint32_t _gid, @@ -371,7 +378,7 @@ class someip_tp_test_service { std::uint32_t number_requests_from_slave_; bool wait_for_two_notifications_of_slave_; std::shared_ptr request_send_to_slave_; - std::thread offer_thread_; + std::shared_ptr start_thread_; }; someip_tp_test::test_mode_e its_testmode(someip_tp_test::test_mode_e::IN_SEQUENCE); @@ -379,6 +386,9 @@ someip_tp_test::test_mode_e its_testmode(someip_tp_test::test_mode_e::IN_SEQUENC TEST(someip_someip_tp_test, echo_requests) { someip_tp_test_service its_sample(someip_tp_test::service, its_testmode); + its_sample.start(); + its_sample.run(); + its_sample.stop(); } diff --git a/test/network_tests/subscribe_notify_one_tests/conf/subscribe_notify_one_test_diff_client_ids_diff_ports_master.json.in b/test/network_tests/subscribe_notify_one_tests/conf/subscribe_notify_one_test_diff_client_ids_diff_ports_master.json.in index 26d964481..dbb8868c6 100644 --- a/test/network_tests/subscribe_notify_one_tests/conf/subscribe_notify_one_test_diff_client_ids_diff_ports_master.json.in +++ b/test/network_tests/subscribe_notify_one_tests/conf/subscribe_notify_one_test_diff_client_ids_diff_ports_master.json.in @@ -9,7 +9,7 @@ "enable":"false", "path":"/tmp/vsomeip.log" }, - "dlt":"false" + "dlt":"true" }, "applications": [ @@ -101,4 +101,4 @@ { "address" : "@TEST_IP_SLAVE@" } -} \ No newline at end of file +} diff --git a/test/network_tests/subscribe_notify_one_tests/conf/subscribe_notify_one_test_diff_client_ids_diff_ports_master_tcp.json.in b/test/network_tests/subscribe_notify_one_tests/conf/subscribe_notify_one_test_diff_client_ids_diff_ports_master_tcp.json.in index 7b4b606e0..e53527302 100644 --- a/test/network_tests/subscribe_notify_one_tests/conf/subscribe_notify_one_test_diff_client_ids_diff_ports_master_tcp.json.in +++ b/test/network_tests/subscribe_notify_one_tests/conf/subscribe_notify_one_test_diff_client_ids_diff_ports_master_tcp.json.in @@ -9,7 +9,7 @@ "enable":"false", "path":"/tmp/vsomeip.log" }, - "dlt":"false" + "dlt":"true" }, "applications": [ @@ -74,4 +74,4 @@ { "address" : "@TEST_IP_SLAVE@" } -} \ No newline at end of file +} diff --git a/test/network_tests/subscribe_notify_one_tests/conf/subscribe_notify_one_test_diff_client_ids_diff_ports_master_udp.json.in b/test/network_tests/subscribe_notify_one_tests/conf/subscribe_notify_one_test_diff_client_ids_diff_ports_master_udp.json.in index e5218b3d3..e2b54b065 100644 --- a/test/network_tests/subscribe_notify_one_tests/conf/subscribe_notify_one_test_diff_client_ids_diff_ports_master_udp.json.in +++ b/test/network_tests/subscribe_notify_one_tests/conf/subscribe_notify_one_test_diff_client_ids_diff_ports_master_udp.json.in @@ -9,7 +9,7 @@ "enable":"false", "path":"/tmp/vsomeip.log" }, - "dlt":"false" + "dlt":"true" }, "applications": [ diff --git a/test/network_tests/subscribe_notify_one_tests/conf/subscribe_notify_one_test_diff_client_ids_diff_ports_slave.json.in b/test/network_tests/subscribe_notify_one_tests/conf/subscribe_notify_one_test_diff_client_ids_diff_ports_slave.json.in index a4283b98a..a9eeca9ff 100644 --- a/test/network_tests/subscribe_notify_one_tests/conf/subscribe_notify_one_test_diff_client_ids_diff_ports_slave.json.in +++ b/test/network_tests/subscribe_notify_one_tests/conf/subscribe_notify_one_test_diff_client_ids_diff_ports_slave.json.in @@ -9,7 +9,7 @@ "enable":"false", "path":"/tmp/vsomeip.log" }, - "dlt":"false" + "dlt":"true" }, "applications": [ @@ -101,4 +101,4 @@ { "address" : "@TEST_IP_MASTER@" } -} \ No newline at end of file +} diff --git a/test/network_tests/subscribe_notify_one_tests/conf/subscribe_notify_one_test_diff_client_ids_diff_ports_slave_tcp.json.in b/test/network_tests/subscribe_notify_one_tests/conf/subscribe_notify_one_test_diff_client_ids_diff_ports_slave_tcp.json.in index 1cb1feb35..d075a1ed2 100644 --- a/test/network_tests/subscribe_notify_one_tests/conf/subscribe_notify_one_test_diff_client_ids_diff_ports_slave_tcp.json.in +++ b/test/network_tests/subscribe_notify_one_tests/conf/subscribe_notify_one_test_diff_client_ids_diff_ports_slave_tcp.json.in @@ -9,7 +9,7 @@ "enable":"false", "path":"/tmp/vsomeip.log" }, - "dlt":"false" + "dlt":"true" }, "applications": [ @@ -74,4 +74,4 @@ { "address" : "@TEST_IP_MASTER@" } -} \ No newline at end of file +} diff --git a/test/network_tests/subscribe_notify_one_tests/conf/subscribe_notify_one_test_diff_client_ids_diff_ports_slave_udp.json.in b/test/network_tests/subscribe_notify_one_tests/conf/subscribe_notify_one_test_diff_client_ids_diff_ports_slave_udp.json.in index 138afaea5..2f9d8bca8 100644 --- a/test/network_tests/subscribe_notify_one_tests/conf/subscribe_notify_one_test_diff_client_ids_diff_ports_slave_udp.json.in +++ b/test/network_tests/subscribe_notify_one_tests/conf/subscribe_notify_one_test_diff_client_ids_diff_ports_slave_udp.json.in @@ -9,7 +9,7 @@ "enable":"false", "path":"/tmp/vsomeip.log" }, - "dlt":"false" + "dlt":"true" }, "applications": [ diff --git a/test/network_tests/subscribe_notify_one_tests/subscribe_notify_one_test_master_starter_qnx.sh b/test/network_tests/subscribe_notify_one_tests/subscribe_notify_one_test_master_starter_qnx.sh index 7d11f4b33..d24cae19d 100755 --- a/test/network_tests/subscribe_notify_one_tests/subscribe_notify_one_test_master_starter_qnx.sh +++ b/test/network_tests/subscribe_notify_one_tests/subscribe_notify_one_test_master_starter_qnx.sh @@ -1,5 +1,5 @@ #!/bin/sh -# Copyright (C) 2015-2017 Bayerische Motoren Werke Aktiengesellschaft (BMW AG) +# Copyright (C) 2015-2023 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/. diff --git a/test/network_tests/subscribe_notify_one_tests/subscribe_notify_one_test_service.cpp b/test/network_tests/subscribe_notify_one_tests/subscribe_notify_one_test_service.cpp index 1c880664c..62742ecdf 100644 --- a/test/network_tests/subscribe_notify_one_tests/subscribe_notify_one_test_service.cpp +++ b/test/network_tests/subscribe_notify_one_tests/subscribe_notify_one_test_service.cpp @@ -1,4 +1,4 @@ -// Copyright (C) 2014-2017 Bayerische Motoren Werke Aktiengesellschaft (BMW AG) +// Copyright (C) 2014-2023 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/. @@ -20,11 +20,13 @@ #include #include "subscribe_notify_one_test_globals.hpp" +#include "../someip_test_globals.hpp" +#include - -class subscribe_notify_one_test_service { +class subscribe_notify_one_test_service : public vsomeip_utilities::base_logger { public: subscribe_notify_one_test_service(struct subscribe_notify_one_test::service_info _service_info, vsomeip::reliability_type_e _reliability_type) : + vsomeip_utilities::base_logger("SNOS", "SUBSCRIBE NOTIFY ONE TEST SERVICE"), service_info_(_service_info), app_(vsomeip::runtime::get()->create_application()), wait_until_registered_(true), diff --git a/test/network_tests/subscribe_notify_one_tests/subscribe_notify_one_test_slave_starter.sh b/test/network_tests/subscribe_notify_one_tests/subscribe_notify_one_test_slave_starter.sh index 830484dff..a77648068 100755 --- a/test/network_tests/subscribe_notify_one_tests/subscribe_notify_one_test_slave_starter.sh +++ b/test/network_tests/subscribe_notify_one_tests/subscribe_notify_one_test_slave_starter.sh @@ -18,6 +18,7 @@ then fi FAIL=0 + # Start the services export VSOMEIP_APPLICATION_NAME=subscribe_notify_one_test_service_four export VSOMEIP_CONFIGURATION=$2 diff --git a/test/network_tests/subscribe_notify_tests/conf/subscribe_notify_test_diff_client_ids_diff_ports_autoconfig_master.json.in b/test/network_tests/subscribe_notify_tests/conf/subscribe_notify_test_diff_client_ids_diff_ports_autoconfig_master.json.in index 370cf989b..6cd1b0380 100644 --- a/test/network_tests/subscribe_notify_tests/conf/subscribe_notify_test_diff_client_ids_diff_ports_autoconfig_master.json.in +++ b/test/network_tests/subscribe_notify_tests/conf/subscribe_notify_test_diff_client_ids_diff_ports_autoconfig_master.json.in @@ -9,7 +9,7 @@ "enable":"false", "path":"/tmp/vsomeip.log" }, - "dlt":"false" + "dlt":"true" }, "services": [ @@ -57,4 +57,4 @@ "cyclic_offer_delay" : "1000", "ttl" : "3" } -} \ No newline at end of file +} diff --git a/test/network_tests/subscribe_notify_tests/conf/subscribe_notify_test_diff_client_ids_diff_ports_autoconfig_master_local_tcp.json.in b/test/network_tests/subscribe_notify_tests/conf/subscribe_notify_test_diff_client_ids_diff_ports_autoconfig_master_local_tcp.json.in index 1ce1a0548..e24a420c4 100644 --- a/test/network_tests/subscribe_notify_tests/conf/subscribe_notify_test_diff_client_ids_diff_ports_autoconfig_master_local_tcp.json.in +++ b/test/network_tests/subscribe_notify_tests/conf/subscribe_notify_test_diff_client_ids_diff_ports_autoconfig_master_local_tcp.json.in @@ -9,7 +9,7 @@ "enable":"false", "path":"/tmp/vsomeip.log" }, - "dlt":"false" + "dlt":"true" }, "services": [ @@ -65,4 +65,4 @@ "cyclic_offer_delay" : "1000", "ttl" : "3" } -} \ No newline at end of file +} diff --git a/test/network_tests/subscribe_notify_tests/conf/subscribe_notify_test_diff_client_ids_diff_ports_autoconfig_slave.json.in b/test/network_tests/subscribe_notify_tests/conf/subscribe_notify_test_diff_client_ids_diff_ports_autoconfig_slave.json.in index 46de8ffc4..db8dd4609 100644 --- a/test/network_tests/subscribe_notify_tests/conf/subscribe_notify_test_diff_client_ids_diff_ports_autoconfig_slave.json.in +++ b/test/network_tests/subscribe_notify_tests/conf/subscribe_notify_test_diff_client_ids_diff_ports_autoconfig_slave.json.in @@ -9,7 +9,7 @@ "enable":"false", "path":"/tmp/vsomeip.log" }, - "dlt":"false" + "dlt":"true" }, "services": [ @@ -57,4 +57,4 @@ "cyclic_offer_delay" : "1000", "ttl" : "3" } -} \ No newline at end of file +} diff --git a/test/network_tests/subscribe_notify_tests/conf/subscribe_notify_test_diff_client_ids_diff_ports_autoconfig_slave_local_tcp.json.in b/test/network_tests/subscribe_notify_tests/conf/subscribe_notify_test_diff_client_ids_diff_ports_autoconfig_slave_local_tcp.json.in index 46865e433..da17c41e1 100644 --- a/test/network_tests/subscribe_notify_tests/conf/subscribe_notify_test_diff_client_ids_diff_ports_autoconfig_slave_local_tcp.json.in +++ b/test/network_tests/subscribe_notify_tests/conf/subscribe_notify_test_diff_client_ids_diff_ports_autoconfig_slave_local_tcp.json.in @@ -9,7 +9,7 @@ "enable":"false", "path":"/tmp/vsomeip.log" }, - "dlt":"false" + "dlt":"true" }, "services": [ @@ -65,4 +65,4 @@ "cyclic_offer_delay" : "1000", "ttl" : "3" } -} \ No newline at end of file +} diff --git a/test/network_tests/subscribe_notify_tests/conf/subscribe_notify_test_diff_client_ids_diff_ports_master.json.in b/test/network_tests/subscribe_notify_tests/conf/subscribe_notify_test_diff_client_ids_diff_ports_master.json.in index 87299aab4..07cfdcc86 100644 --- a/test/network_tests/subscribe_notify_tests/conf/subscribe_notify_test_diff_client_ids_diff_ports_master.json.in +++ b/test/network_tests/subscribe_notify_tests/conf/subscribe_notify_test_diff_client_ids_diff_ports_master.json.in @@ -9,7 +9,7 @@ "enable":"false", "path":"/tmp/vsomeip.log" }, - "dlt":"false" + "dlt":"true" }, "applications": [ @@ -73,4 +73,4 @@ "cyclic_offer_delay" : "1000", "ttl" : "3" } -} \ No newline at end of file +} diff --git a/test/network_tests/subscribe_notify_tests/conf/subscribe_notify_test_diff_client_ids_diff_ports_master_local_tcp.json.in b/test/network_tests/subscribe_notify_tests/conf/subscribe_notify_test_diff_client_ids_diff_ports_master_local_tcp.json.in index b66fabc9b..3e89dff6a 100644 --- a/test/network_tests/subscribe_notify_tests/conf/subscribe_notify_test_diff_client_ids_diff_ports_master_local_tcp.json.in +++ b/test/network_tests/subscribe_notify_tests/conf/subscribe_notify_test_diff_client_ids_diff_ports_master_local_tcp.json.in @@ -9,7 +9,7 @@ "enable":"false", "path":"/tmp/vsomeip.log" }, - "dlt":"false" + "dlt":"true" }, "applications": [ @@ -80,4 +80,4 @@ "cyclic_offer_delay" : "1000", "ttl" : "3" } -} \ No newline at end of file +} diff --git a/test/network_tests/subscribe_notify_tests/conf/subscribe_notify_test_diff_client_ids_diff_ports_master_tcp.json.in b/test/network_tests/subscribe_notify_tests/conf/subscribe_notify_test_diff_client_ids_diff_ports_master_tcp.json.in index 99bf69aff..7223363ce 100644 --- a/test/network_tests/subscribe_notify_tests/conf/subscribe_notify_test_diff_client_ids_diff_ports_master_tcp.json.in +++ b/test/network_tests/subscribe_notify_tests/conf/subscribe_notify_test_diff_client_ids_diff_ports_master_tcp.json.in @@ -9,7 +9,7 @@ "enable":"false", "path":"/tmp/vsomeip.log" }, - "dlt":"false" + "dlt":"true" }, "applications": [ diff --git a/test/network_tests/subscribe_notify_tests/conf/subscribe_notify_test_diff_client_ids_diff_ports_master_tcp_local_tcp.json.in b/test/network_tests/subscribe_notify_tests/conf/subscribe_notify_test_diff_client_ids_diff_ports_master_tcp_local_tcp.json.in index 817a4eeb7..3d554edf3 100644 --- a/test/network_tests/subscribe_notify_tests/conf/subscribe_notify_test_diff_client_ids_diff_ports_master_tcp_local_tcp.json.in +++ b/test/network_tests/subscribe_notify_tests/conf/subscribe_notify_test_diff_client_ids_diff_ports_master_tcp_local_tcp.json.in @@ -9,7 +9,7 @@ "enable":"false", "path":"/tmp/vsomeip.log" }, - "dlt":"false" + "dlt":"true" }, "applications": [ diff --git a/test/network_tests/subscribe_notify_tests/conf/subscribe_notify_test_diff_client_ids_diff_ports_master_udp.json.in b/test/network_tests/subscribe_notify_tests/conf/subscribe_notify_test_diff_client_ids_diff_ports_master_udp.json.in index cb6620209..6eca929e2 100644 --- a/test/network_tests/subscribe_notify_tests/conf/subscribe_notify_test_diff_client_ids_diff_ports_master_udp.json.in +++ b/test/network_tests/subscribe_notify_tests/conf/subscribe_notify_test_diff_client_ids_diff_ports_master_udp.json.in @@ -9,7 +9,7 @@ "enable":"false", "path":"/tmp/vsomeip.log" }, - "dlt":"false" + "dlt":"true" }, "applications": [ diff --git a/test/network_tests/subscribe_notify_tests/conf/subscribe_notify_test_diff_client_ids_diff_ports_master_udp_local_tcp.json.in b/test/network_tests/subscribe_notify_tests/conf/subscribe_notify_test_diff_client_ids_diff_ports_master_udp_local_tcp.json.in index 4fe88822e..7cf722685 100644 --- a/test/network_tests/subscribe_notify_tests/conf/subscribe_notify_test_diff_client_ids_diff_ports_master_udp_local_tcp.json.in +++ b/test/network_tests/subscribe_notify_tests/conf/subscribe_notify_test_diff_client_ids_diff_ports_master_udp_local_tcp.json.in @@ -9,7 +9,7 @@ "enable":"false", "path":"/tmp/vsomeip.log" }, - "dlt":"false" + "dlt":"true" }, "applications": [ @@ -46,7 +46,7 @@ ], "routing": { - "host" : + "host" : { "name" : "subscribe_notify_test_service_one", "unicast" : "127.0.0.1" diff --git a/test/network_tests/subscribe_notify_tests/conf/subscribe_notify_test_diff_client_ids_diff_ports_same_service_id_master_udp.json.in b/test/network_tests/subscribe_notify_tests/conf/subscribe_notify_test_diff_client_ids_diff_ports_same_service_id_master_udp.json.in index 4de283c7e..aaa59150d 100644 --- a/test/network_tests/subscribe_notify_tests/conf/subscribe_notify_test_diff_client_ids_diff_ports_same_service_id_master_udp.json.in +++ b/test/network_tests/subscribe_notify_tests/conf/subscribe_notify_test_diff_client_ids_diff_ports_same_service_id_master_udp.json.in @@ -9,7 +9,7 @@ "enable":"false", "path":"/tmp/vsomeip.log" }, - "dlt":"false" + "dlt":"true" }, "applications": [ @@ -58,4 +58,4 @@ "cyclic_offer_delay" : "1000", "ttl" : "3" } -} \ No newline at end of file +} diff --git a/test/network_tests/subscribe_notify_tests/conf/subscribe_notify_test_diff_client_ids_diff_ports_same_service_id_master_udp_local_tcp.json.in b/test/network_tests/subscribe_notify_tests/conf/subscribe_notify_test_diff_client_ids_diff_ports_same_service_id_master_udp_local_tcp.json.in index 5960b6169..decd4fe88 100644 --- a/test/network_tests/subscribe_notify_tests/conf/subscribe_notify_test_diff_client_ids_diff_ports_same_service_id_master_udp_local_tcp.json.in +++ b/test/network_tests/subscribe_notify_tests/conf/subscribe_notify_test_diff_client_ids_diff_ports_same_service_id_master_udp_local_tcp.json.in @@ -9,7 +9,7 @@ "enable":"false", "path":"/tmp/vsomeip.log" }, - "dlt":"false" + "dlt":"true" }, "applications": [ @@ -65,4 +65,4 @@ "cyclic_offer_delay" : "1000", "ttl" : "3" } -} \ No newline at end of file +} diff --git a/test/network_tests/subscribe_notify_tests/conf/subscribe_notify_test_diff_client_ids_diff_ports_same_service_id_slave_udp.json.in b/test/network_tests/subscribe_notify_tests/conf/subscribe_notify_test_diff_client_ids_diff_ports_same_service_id_slave_udp.json.in index 5dd929961..d40783cc8 100644 --- a/test/network_tests/subscribe_notify_tests/conf/subscribe_notify_test_diff_client_ids_diff_ports_same_service_id_slave_udp.json.in +++ b/test/network_tests/subscribe_notify_tests/conf/subscribe_notify_test_diff_client_ids_diff_ports_same_service_id_slave_udp.json.in @@ -9,7 +9,7 @@ "enable":"false", "path":"/tmp/vsomeip.log" }, - "dlt":"false" + "dlt":"true" }, "applications": [ @@ -58,4 +58,4 @@ "cyclic_offer_delay" : "1000", "ttl" : "3" } -} \ No newline at end of file +} diff --git a/test/network_tests/subscribe_notify_tests/conf/subscribe_notify_test_diff_client_ids_diff_ports_same_service_id_slave_udp_local_tcp.json.in b/test/network_tests/subscribe_notify_tests/conf/subscribe_notify_test_diff_client_ids_diff_ports_same_service_id_slave_udp_local_tcp.json.in index 2521d62c9..4498037be 100644 --- a/test/network_tests/subscribe_notify_tests/conf/subscribe_notify_test_diff_client_ids_diff_ports_same_service_id_slave_udp_local_tcp.json.in +++ b/test/network_tests/subscribe_notify_tests/conf/subscribe_notify_test_diff_client_ids_diff_ports_same_service_id_slave_udp_local_tcp.json.in @@ -9,7 +9,7 @@ "enable":"false", "path":"/tmp/vsomeip.log" }, - "dlt":"false" + "dlt":"true" }, "applications": [ @@ -65,4 +65,4 @@ "cyclic_offer_delay" : "1000", "ttl" : "3" } -} \ No newline at end of file +} diff --git a/test/network_tests/subscribe_notify_tests/conf/subscribe_notify_test_diff_client_ids_diff_ports_slave.json.in b/test/network_tests/subscribe_notify_tests/conf/subscribe_notify_test_diff_client_ids_diff_ports_slave.json.in index 5b110aa25..d943ef864 100644 --- a/test/network_tests/subscribe_notify_tests/conf/subscribe_notify_test_diff_client_ids_diff_ports_slave.json.in +++ b/test/network_tests/subscribe_notify_tests/conf/subscribe_notify_test_diff_client_ids_diff_ports_slave.json.in @@ -9,7 +9,7 @@ "enable":"false", "path":"/tmp/vsomeip.log" }, - "dlt":"false" + "dlt":"true" }, "applications": [ @@ -73,4 +73,4 @@ "cyclic_offer_delay" : "1000", "ttl" : "3" } -} \ No newline at end of file +} diff --git a/test/network_tests/subscribe_notify_tests/conf/subscribe_notify_test_diff_client_ids_diff_ports_slave_local_tcp.json.in b/test/network_tests/subscribe_notify_tests/conf/subscribe_notify_test_diff_client_ids_diff_ports_slave_local_tcp.json.in index 0b2ebb880..3dd7ded31 100644 --- a/test/network_tests/subscribe_notify_tests/conf/subscribe_notify_test_diff_client_ids_diff_ports_slave_local_tcp.json.in +++ b/test/network_tests/subscribe_notify_tests/conf/subscribe_notify_test_diff_client_ids_diff_ports_slave_local_tcp.json.in @@ -9,7 +9,7 @@ "enable":"false", "path":"/tmp/vsomeip.log" }, - "dlt":"false" + "dlt":"true" }, "applications": [ @@ -80,4 +80,4 @@ "cyclic_offer_delay" : "1000", "ttl" : "3" } -} \ No newline at end of file +} diff --git a/test/network_tests/subscribe_notify_tests/conf/subscribe_notify_test_diff_client_ids_diff_ports_slave_tcp.json.in b/test/network_tests/subscribe_notify_tests/conf/subscribe_notify_test_diff_client_ids_diff_ports_slave_tcp.json.in index 628734cc7..7b010e818 100644 --- a/test/network_tests/subscribe_notify_tests/conf/subscribe_notify_test_diff_client_ids_diff_ports_slave_tcp.json.in +++ b/test/network_tests/subscribe_notify_tests/conf/subscribe_notify_test_diff_client_ids_diff_ports_slave_tcp.json.in @@ -9,7 +9,7 @@ "enable":"false", "path":"/tmp/vsomeip.log" }, - "dlt":"false" + "dlt":"true" }, "applications": [ diff --git a/test/network_tests/subscribe_notify_tests/conf/subscribe_notify_test_diff_client_ids_diff_ports_slave_tcp_local_tcp.json.in b/test/network_tests/subscribe_notify_tests/conf/subscribe_notify_test_diff_client_ids_diff_ports_slave_tcp_local_tcp.json.in index 14e53408c..75ffad90c 100644 --- a/test/network_tests/subscribe_notify_tests/conf/subscribe_notify_test_diff_client_ids_diff_ports_slave_tcp_local_tcp.json.in +++ b/test/network_tests/subscribe_notify_tests/conf/subscribe_notify_test_diff_client_ids_diff_ports_slave_tcp_local_tcp.json.in @@ -9,7 +9,7 @@ "enable":"false", "path":"/tmp/vsomeip.log" }, - "dlt":"false" + "dlt":"true" }, "applications": [ diff --git a/test/network_tests/subscribe_notify_tests/conf/subscribe_notify_test_diff_client_ids_diff_ports_slave_udp.json.in b/test/network_tests/subscribe_notify_tests/conf/subscribe_notify_test_diff_client_ids_diff_ports_slave_udp.json.in index 5b96b0ed5..7bb0a61d2 100644 --- a/test/network_tests/subscribe_notify_tests/conf/subscribe_notify_test_diff_client_ids_diff_ports_slave_udp.json.in +++ b/test/network_tests/subscribe_notify_tests/conf/subscribe_notify_test_diff_client_ids_diff_ports_slave_udp.json.in @@ -9,7 +9,7 @@ "enable":"false", "path":"/tmp/vsomeip.log" }, - "dlt":"false" + "dlt":"true" }, "applications": [ diff --git a/test/network_tests/subscribe_notify_tests/conf/subscribe_notify_test_diff_client_ids_diff_ports_slave_udp_local_tcp.json.in b/test/network_tests/subscribe_notify_tests/conf/subscribe_notify_test_diff_client_ids_diff_ports_slave_udp_local_tcp.json.in index e4e75dbbf..737cbffec 100644 --- a/test/network_tests/subscribe_notify_tests/conf/subscribe_notify_test_diff_client_ids_diff_ports_slave_udp_local_tcp.json.in +++ b/test/network_tests/subscribe_notify_tests/conf/subscribe_notify_test_diff_client_ids_diff_ports_slave_udp_local_tcp.json.in @@ -9,7 +9,7 @@ "enable":"false", "path":"/tmp/vsomeip.log" }, - "dlt":"false" + "dlt":"true" }, "applications": [ diff --git a/test/network_tests/subscribe_notify_tests/conf/subscribe_notify_test_diff_client_ids_partial_same_ports_master.json.in b/test/network_tests/subscribe_notify_tests/conf/subscribe_notify_test_diff_client_ids_partial_same_ports_master.json.in index 81bb18e86..db5802104 100644 --- a/test/network_tests/subscribe_notify_tests/conf/subscribe_notify_test_diff_client_ids_partial_same_ports_master.json.in +++ b/test/network_tests/subscribe_notify_tests/conf/subscribe_notify_test_diff_client_ids_partial_same_ports_master.json.in @@ -9,7 +9,7 @@ "enable":"false", "path":"/tmp/vsomeip.log" }, - "dlt":"false" + "dlt":"true" }, "applications": [ @@ -73,4 +73,4 @@ "cyclic_offer_delay" : "1000", "ttl" : "3" } -} \ No newline at end of file +} diff --git a/test/network_tests/subscribe_notify_tests/conf/subscribe_notify_test_diff_client_ids_partial_same_ports_master_local_tcp.json.in b/test/network_tests/subscribe_notify_tests/conf/subscribe_notify_test_diff_client_ids_partial_same_ports_master_local_tcp.json.in index acae8bb0d..ee0a61abe 100644 --- a/test/network_tests/subscribe_notify_tests/conf/subscribe_notify_test_diff_client_ids_partial_same_ports_master_local_tcp.json.in +++ b/test/network_tests/subscribe_notify_tests/conf/subscribe_notify_test_diff_client_ids_partial_same_ports_master_local_tcp.json.in @@ -9,7 +9,7 @@ "enable":"false", "path":"/tmp/vsomeip.log" }, - "dlt":"false" + "dlt":"true" }, "applications": [ @@ -80,4 +80,4 @@ "cyclic_offer_delay" : "1000", "ttl" : "3" } -} \ No newline at end of file +} diff --git a/test/network_tests/subscribe_notify_tests/conf/subscribe_notify_test_diff_client_ids_partial_same_ports_slave.json.in b/test/network_tests/subscribe_notify_tests/conf/subscribe_notify_test_diff_client_ids_partial_same_ports_slave.json.in index 98ce9a600..8f1c0603d 100644 --- a/test/network_tests/subscribe_notify_tests/conf/subscribe_notify_test_diff_client_ids_partial_same_ports_slave.json.in +++ b/test/network_tests/subscribe_notify_tests/conf/subscribe_notify_test_diff_client_ids_partial_same_ports_slave.json.in @@ -9,7 +9,7 @@ "enable":"false", "path":"/tmp/vsomeip.log" }, - "dlt":"false" + "dlt":"true" }, "applications": [ @@ -73,4 +73,4 @@ "cyclic_offer_delay" : "1000", "ttl" : "3" } -} \ No newline at end of file +} diff --git a/test/network_tests/subscribe_notify_tests/conf/subscribe_notify_test_diff_client_ids_partial_same_ports_slave_local_tcp.json.in b/test/network_tests/subscribe_notify_tests/conf/subscribe_notify_test_diff_client_ids_partial_same_ports_slave_local_tcp.json.in index 7c1762d30..20d92cd91 100644 --- a/test/network_tests/subscribe_notify_tests/conf/subscribe_notify_test_diff_client_ids_partial_same_ports_slave_local_tcp.json.in +++ b/test/network_tests/subscribe_notify_tests/conf/subscribe_notify_test_diff_client_ids_partial_same_ports_slave_local_tcp.json.in @@ -9,7 +9,7 @@ "enable":"false", "path":"/tmp/vsomeip.log" }, - "dlt":"false" + "dlt":"true" }, "applications": [ @@ -80,4 +80,4 @@ "cyclic_offer_delay" : "1000", "ttl" : "3" } -} \ No newline at end of file +} diff --git a/test/network_tests/subscribe_notify_tests/conf/subscribe_notify_test_diff_client_ids_same_ports_master.json.in b/test/network_tests/subscribe_notify_tests/conf/subscribe_notify_test_diff_client_ids_same_ports_master.json.in index 253b55ed0..07f2a2ce1 100644 --- a/test/network_tests/subscribe_notify_tests/conf/subscribe_notify_test_diff_client_ids_same_ports_master.json.in +++ b/test/network_tests/subscribe_notify_tests/conf/subscribe_notify_test_diff_client_ids_same_ports_master.json.in @@ -9,7 +9,7 @@ "enable":"false", "path":"/tmp/vsomeip.log" }, - "dlt":"false" + "dlt":"true" }, "applications": [ @@ -73,4 +73,4 @@ "cyclic_offer_delay" : "1000", "ttl" : "3" } -} \ No newline at end of file +} diff --git a/test/network_tests/subscribe_notify_tests/conf/subscribe_notify_test_diff_client_ids_same_ports_master_local_tcp.json.in b/test/network_tests/subscribe_notify_tests/conf/subscribe_notify_test_diff_client_ids_same_ports_master_local_tcp.json.in index f44a0207d..2b476cfe5 100644 --- a/test/network_tests/subscribe_notify_tests/conf/subscribe_notify_test_diff_client_ids_same_ports_master_local_tcp.json.in +++ b/test/network_tests/subscribe_notify_tests/conf/subscribe_notify_test_diff_client_ids_same_ports_master_local_tcp.json.in @@ -9,7 +9,7 @@ "enable":"false", "path":"/tmp/vsomeip.log" }, - "dlt":"false" + "dlt":"true" }, "applications": [ @@ -80,4 +80,4 @@ "cyclic_offer_delay" : "1000", "ttl" : "3" } -} \ No newline at end of file +} diff --git a/test/network_tests/subscribe_notify_tests/conf/subscribe_notify_test_diff_client_ids_same_ports_master_tcp.json.in b/test/network_tests/subscribe_notify_tests/conf/subscribe_notify_test_diff_client_ids_same_ports_master_tcp.json.in index 39696841c..adfb4c39d 100644 --- a/test/network_tests/subscribe_notify_tests/conf/subscribe_notify_test_diff_client_ids_same_ports_master_tcp.json.in +++ b/test/network_tests/subscribe_notify_tests/conf/subscribe_notify_test_diff_client_ids_same_ports_master_tcp.json.in @@ -9,7 +9,7 @@ "enable":"false", "path":"/tmp/vsomeip.log" }, - "dlt":"false" + "dlt":"true" }, "applications": [ @@ -70,4 +70,4 @@ "cyclic_offer_delay" : "1000", "ttl" : "3" } -} \ No newline at end of file +} diff --git a/test/network_tests/subscribe_notify_tests/conf/subscribe_notify_test_diff_client_ids_same_ports_master_tcp_local_tcp.json.in b/test/network_tests/subscribe_notify_tests/conf/subscribe_notify_test_diff_client_ids_same_ports_master_tcp_local_tcp.json.in index 7bc81cc95..0ff472a61 100644 --- a/test/network_tests/subscribe_notify_tests/conf/subscribe_notify_test_diff_client_ids_same_ports_master_tcp_local_tcp.json.in +++ b/test/network_tests/subscribe_notify_tests/conf/subscribe_notify_test_diff_client_ids_same_ports_master_tcp_local_tcp.json.in @@ -9,7 +9,7 @@ "enable":"false", "path":"/tmp/vsomeip.log" }, - "dlt":"false" + "dlt":"true" }, "applications": [ @@ -77,4 +77,4 @@ "cyclic_offer_delay" : "1000", "ttl" : "3" } -} \ No newline at end of file +} diff --git a/test/network_tests/subscribe_notify_tests/conf/subscribe_notify_test_diff_client_ids_same_ports_master_udp.json.in b/test/network_tests/subscribe_notify_tests/conf/subscribe_notify_test_diff_client_ids_same_ports_master_udp.json.in index 72b53fc0a..cddd880db 100644 --- a/test/network_tests/subscribe_notify_tests/conf/subscribe_notify_test_diff_client_ids_same_ports_master_udp.json.in +++ b/test/network_tests/subscribe_notify_tests/conf/subscribe_notify_test_diff_client_ids_same_ports_master_udp.json.in @@ -9,7 +9,7 @@ "enable":"false", "path":"/tmp/vsomeip.log" }, - "dlt":"false" + "dlt":"true" }, "applications": [ @@ -58,4 +58,4 @@ "cyclic_offer_delay" : "1000", "ttl" : "3" } -} \ No newline at end of file +} diff --git a/test/network_tests/subscribe_notify_tests/conf/subscribe_notify_test_diff_client_ids_same_ports_master_udp_local_tcp.json.in b/test/network_tests/subscribe_notify_tests/conf/subscribe_notify_test_diff_client_ids_same_ports_master_udp_local_tcp.json.in index 25a017b3d..0876c590c 100644 --- a/test/network_tests/subscribe_notify_tests/conf/subscribe_notify_test_diff_client_ids_same_ports_master_udp_local_tcp.json.in +++ b/test/network_tests/subscribe_notify_tests/conf/subscribe_notify_test_diff_client_ids_same_ports_master_udp_local_tcp.json.in @@ -9,7 +9,7 @@ "enable":"false", "path":"/tmp/vsomeip.log" }, - "dlt":"false" + "dlt":"true" }, "applications": [ @@ -65,4 +65,4 @@ "cyclic_offer_delay" : "1000", "ttl" : "3" } -} \ No newline at end of file +} diff --git a/test/network_tests/subscribe_notify_tests/conf/subscribe_notify_test_diff_client_ids_same_ports_slave.json.in b/test/network_tests/subscribe_notify_tests/conf/subscribe_notify_test_diff_client_ids_same_ports_slave.json.in index 556b10f22..40ab1359c 100644 --- a/test/network_tests/subscribe_notify_tests/conf/subscribe_notify_test_diff_client_ids_same_ports_slave.json.in +++ b/test/network_tests/subscribe_notify_tests/conf/subscribe_notify_test_diff_client_ids_same_ports_slave.json.in @@ -9,7 +9,7 @@ "enable":"false", "path":"/tmp/vsomeip.log" }, - "dlt":"false" + "dlt":"true" }, "applications": [ @@ -73,4 +73,4 @@ "cyclic_offer_delay" : "1000", "ttl" : "3" } -} \ No newline at end of file +} diff --git a/test/network_tests/subscribe_notify_tests/conf/subscribe_notify_test_diff_client_ids_same_ports_slave_local_tcp.json.in b/test/network_tests/subscribe_notify_tests/conf/subscribe_notify_test_diff_client_ids_same_ports_slave_local_tcp.json.in index 85847eaf7..58a75150b 100644 --- a/test/network_tests/subscribe_notify_tests/conf/subscribe_notify_test_diff_client_ids_same_ports_slave_local_tcp.json.in +++ b/test/network_tests/subscribe_notify_tests/conf/subscribe_notify_test_diff_client_ids_same_ports_slave_local_tcp.json.in @@ -9,7 +9,7 @@ "enable":"false", "path":"/tmp/vsomeip.log" }, - "dlt":"false" + "dlt":"true" }, "applications": [ @@ -80,4 +80,4 @@ "cyclic_offer_delay" : "1000", "ttl" : "3" } -} \ No newline at end of file +} diff --git a/test/network_tests/subscribe_notify_tests/conf/subscribe_notify_test_diff_client_ids_same_ports_slave_tcp.json.in b/test/network_tests/subscribe_notify_tests/conf/subscribe_notify_test_diff_client_ids_same_ports_slave_tcp.json.in index 3f9aa0b80..1b36defc3 100644 --- a/test/network_tests/subscribe_notify_tests/conf/subscribe_notify_test_diff_client_ids_same_ports_slave_tcp.json.in +++ b/test/network_tests/subscribe_notify_tests/conf/subscribe_notify_test_diff_client_ids_same_ports_slave_tcp.json.in @@ -9,7 +9,7 @@ "enable":"false", "path":"/tmp/vsomeip.log" }, - "dlt":"false" + "dlt":"true" }, "applications": [ @@ -70,4 +70,4 @@ "cyclic_offer_delay" : "1000", "ttl" : "3" } -} \ No newline at end of file +} diff --git a/test/network_tests/subscribe_notify_tests/conf/subscribe_notify_test_diff_client_ids_same_ports_slave_tcp_local_tcp.json.in b/test/network_tests/subscribe_notify_tests/conf/subscribe_notify_test_diff_client_ids_same_ports_slave_tcp_local_tcp.json.in index 4aa32f1e7..1565cc878 100644 --- a/test/network_tests/subscribe_notify_tests/conf/subscribe_notify_test_diff_client_ids_same_ports_slave_tcp_local_tcp.json.in +++ b/test/network_tests/subscribe_notify_tests/conf/subscribe_notify_test_diff_client_ids_same_ports_slave_tcp_local_tcp.json.in @@ -9,7 +9,7 @@ "enable":"false", "path":"/tmp/vsomeip.log" }, - "dlt":"false" + "dlt":"true" }, "applications": [ @@ -77,4 +77,4 @@ "cyclic_offer_delay" : "1000", "ttl" : "3" } -} \ No newline at end of file +} diff --git a/test/network_tests/subscribe_notify_tests/conf/subscribe_notify_test_diff_client_ids_same_ports_slave_udp.json.in b/test/network_tests/subscribe_notify_tests/conf/subscribe_notify_test_diff_client_ids_same_ports_slave_udp.json.in index 6e14f4f15..e035bb3f1 100644 --- a/test/network_tests/subscribe_notify_tests/conf/subscribe_notify_test_diff_client_ids_same_ports_slave_udp.json.in +++ b/test/network_tests/subscribe_notify_tests/conf/subscribe_notify_test_diff_client_ids_same_ports_slave_udp.json.in @@ -9,7 +9,7 @@ "enable":"false", "path":"/tmp/vsomeip.log" }, - "dlt":"false" + "dlt":"true" }, "applications": [ @@ -58,4 +58,4 @@ "cyclic_offer_delay" : "1000", "ttl" : "3" } -} \ No newline at end of file +} diff --git a/test/network_tests/subscribe_notify_tests/conf/subscribe_notify_test_diff_client_ids_same_ports_slave_udp_local_tcp.json.in b/test/network_tests/subscribe_notify_tests/conf/subscribe_notify_test_diff_client_ids_same_ports_slave_udp_local_tcp.json.in index baf3634d8..af0c89753 100644 --- a/test/network_tests/subscribe_notify_tests/conf/subscribe_notify_test_diff_client_ids_same_ports_slave_udp_local_tcp.json.in +++ b/test/network_tests/subscribe_notify_tests/conf/subscribe_notify_test_diff_client_ids_same_ports_slave_udp_local_tcp.json.in @@ -9,7 +9,7 @@ "enable":"false", "path":"/tmp/vsomeip.log" }, - "dlt":"false" + "dlt":"true" }, "applications": [ @@ -65,4 +65,4 @@ "cyclic_offer_delay" : "1000", "ttl" : "3" } -} \ No newline at end of file +} diff --git a/test/network_tests/subscribe_notify_tests/conf/subscribe_notify_test_one_event_two_eventgroups_master.json.in b/test/network_tests/subscribe_notify_tests/conf/subscribe_notify_test_one_event_two_eventgroups_master.json.in index 88d5ec932..1133326bf 100644 --- a/test/network_tests/subscribe_notify_tests/conf/subscribe_notify_test_one_event_two_eventgroups_master.json.in +++ b/test/network_tests/subscribe_notify_tests/conf/subscribe_notify_test_one_event_two_eventgroups_master.json.in @@ -1,11 +1,11 @@ { "unicast" : "@TEST_IP_MASTER@", - "logging" : + "logging" : { "level" : "warning", "console" : "true", "file" : { "enable" : "false", "path" : "/var/log/vsomeip.log" }, - "dlt" : "false" + "dlt" : "true" }, "applications" : [ diff --git a/test/network_tests/subscribe_notify_tests/conf/subscribe_notify_test_one_event_two_eventgroups_master_local_tcp.json.in b/test/network_tests/subscribe_notify_tests/conf/subscribe_notify_test_one_event_two_eventgroups_master_local_tcp.json.in index 45e39431d..cbb06f225 100644 --- a/test/network_tests/subscribe_notify_tests/conf/subscribe_notify_test_one_event_two_eventgroups_master_local_tcp.json.in +++ b/test/network_tests/subscribe_notify_tests/conf/subscribe_notify_test_one_event_two_eventgroups_master_local_tcp.json.in @@ -1,11 +1,11 @@ { "unicast" : "@TEST_IP_MASTER@", - "logging" : + "logging" : { "level" : "warning", "console" : "true", "file" : { "enable" : "false", "path" : "/var/log/vsomeip.log" }, - "dlt" : "false" + "dlt" : "true" }, "applications" : [ @@ -14,7 +14,7 @@ "id" : "0x9999" } ], - "routing" : + "routing" : { "host" : { diff --git a/test/network_tests/subscribe_notify_tests/conf/subscribe_notify_test_one_event_two_eventgroups_tcp_slave.json.in b/test/network_tests/subscribe_notify_tests/conf/subscribe_notify_test_one_event_two_eventgroups_tcp_slave.json.in index f712c0718..acfcc06ca 100644 --- a/test/network_tests/subscribe_notify_tests/conf/subscribe_notify_test_one_event_two_eventgroups_tcp_slave.json.in +++ b/test/network_tests/subscribe_notify_tests/conf/subscribe_notify_test_one_event_two_eventgroups_tcp_slave.json.in @@ -1,13 +1,13 @@ { "unicast" : "@TEST_IP_SLAVE@", "logging" : - { + { "level" : "warning", "console" : "true", "file" : { "enable" : "false", "path" : "/tmp/vsomeip.log" }, - "dlt" : "false" + "dlt" : "true" }, - "applications" : + "applications" : [ { "name" : "subscribe_notify_test_service", diff --git a/test/network_tests/subscribe_notify_tests/conf/subscribe_notify_test_one_event_two_eventgroups_tcp_slave_local_tcp.json.in b/test/network_tests/subscribe_notify_tests/conf/subscribe_notify_test_one_event_two_eventgroups_tcp_slave_local_tcp.json.in index d87eb34a0..405912a92 100644 --- a/test/network_tests/subscribe_notify_tests/conf/subscribe_notify_test_one_event_two_eventgroups_tcp_slave_local_tcp.json.in +++ b/test/network_tests/subscribe_notify_tests/conf/subscribe_notify_test_one_event_two_eventgroups_tcp_slave_local_tcp.json.in @@ -1,13 +1,13 @@ { "unicast" : "@TEST_IP_SLAVE@", "logging" : - { + { "level" : "info", "console" : "true", "file" : { "enable" : "false", "path" : "/tmp/vsomeip.log" }, - "dlt" : "false" + "dlt" : "true" }, - "applications" : + "applications" : [ { "name" : "subscribe_notify_test_service", @@ -22,7 +22,7 @@ "reliable" : { "port":"30509", "enable-magic-cookies":"false" } } ], - "routing" : + "routing" : { "host" : { diff --git a/test/network_tests/subscribe_notify_tests/conf/subscribe_notify_test_one_event_two_eventgroups_udp_slave.json.in b/test/network_tests/subscribe_notify_tests/conf/subscribe_notify_test_one_event_two_eventgroups_udp_slave.json.in index cd6415c50..2249cbfbe 100644 --- a/test/network_tests/subscribe_notify_tests/conf/subscribe_notify_test_one_event_two_eventgroups_udp_slave.json.in +++ b/test/network_tests/subscribe_notify_tests/conf/subscribe_notify_test_one_event_two_eventgroups_udp_slave.json.in @@ -1,13 +1,13 @@ { "unicast" : "@TEST_IP_SLAVE@", "logging" : - { + { "level" : "warning", "console" : "true", "file" : { "enable" : "false", "path" : "/tmp/vsomeip.log" }, - "dlt" : "false" + "dlt" : "true" }, - "applications" : + "applications" : [ { "name" : "subscribe_notify_test_service", diff --git a/test/network_tests/subscribe_notify_tests/conf/subscribe_notify_test_one_event_two_eventgroups_udp_slave_local_tcp.json.in b/test/network_tests/subscribe_notify_tests/conf/subscribe_notify_test_one_event_two_eventgroups_udp_slave_local_tcp.json.in index a596b3051..7319c3182 100644 --- a/test/network_tests/subscribe_notify_tests/conf/subscribe_notify_test_one_event_two_eventgroups_udp_slave_local_tcp.json.in +++ b/test/network_tests/subscribe_notify_tests/conf/subscribe_notify_test_one_event_two_eventgroups_udp_slave_local_tcp.json.in @@ -1,13 +1,13 @@ { "unicast" : "@TEST_IP_SLAVE@", "logging" : - { + { "level" : "warning", "console" : "true", "file" : { "enable" : "false", "path" : "/tmp/vsomeip.log" }, - "dlt" : "false" + "dlt" : "true" }, - "applications" : + "applications" : [ { "name" : "subscribe_notify_test_service", @@ -22,7 +22,7 @@ "unreliable" : "30509" } ], - "routing" : + "routing" : { "host" : { diff --git a/test/network_tests/subscribe_notify_tests/conf/subscribe_notify_test_same_client_ids_diff_ports_master.json.in b/test/network_tests/subscribe_notify_tests/conf/subscribe_notify_test_same_client_ids_diff_ports_master.json.in index 87299aab4..07cfdcc86 100644 --- a/test/network_tests/subscribe_notify_tests/conf/subscribe_notify_test_same_client_ids_diff_ports_master.json.in +++ b/test/network_tests/subscribe_notify_tests/conf/subscribe_notify_test_same_client_ids_diff_ports_master.json.in @@ -9,7 +9,7 @@ "enable":"false", "path":"/tmp/vsomeip.log" }, - "dlt":"false" + "dlt":"true" }, "applications": [ @@ -73,4 +73,4 @@ "cyclic_offer_delay" : "1000", "ttl" : "3" } -} \ No newline at end of file +} diff --git a/test/network_tests/subscribe_notify_tests/conf/subscribe_notify_test_same_client_ids_diff_ports_master_local_tcp.json.in b/test/network_tests/subscribe_notify_tests/conf/subscribe_notify_test_same_client_ids_diff_ports_master_local_tcp.json.in index b66fabc9b..3e89dff6a 100644 --- a/test/network_tests/subscribe_notify_tests/conf/subscribe_notify_test_same_client_ids_diff_ports_master_local_tcp.json.in +++ b/test/network_tests/subscribe_notify_tests/conf/subscribe_notify_test_same_client_ids_diff_ports_master_local_tcp.json.in @@ -9,7 +9,7 @@ "enable":"false", "path":"/tmp/vsomeip.log" }, - "dlt":"false" + "dlt":"true" }, "applications": [ @@ -80,4 +80,4 @@ "cyclic_offer_delay" : "1000", "ttl" : "3" } -} \ No newline at end of file +} diff --git a/test/network_tests/subscribe_notify_tests/conf/subscribe_notify_test_same_client_ids_diff_ports_slave.json.in b/test/network_tests/subscribe_notify_tests/conf/subscribe_notify_test_same_client_ids_diff_ports_slave.json.in index bc13f011f..f213ba951 100644 --- a/test/network_tests/subscribe_notify_tests/conf/subscribe_notify_test_same_client_ids_diff_ports_slave.json.in +++ b/test/network_tests/subscribe_notify_tests/conf/subscribe_notify_test_same_client_ids_diff_ports_slave.json.in @@ -9,7 +9,7 @@ "enable":"false", "path":"/tmp/vsomeip.log" }, - "dlt":"false" + "dlt":"true" }, "applications": [ @@ -73,4 +73,4 @@ "cyclic_offer_delay" : "1000", "ttl" : "3" } -} \ No newline at end of file +} diff --git a/test/network_tests/subscribe_notify_tests/conf/subscribe_notify_test_same_client_ids_diff_ports_slave_local_tcp.json.in b/test/network_tests/subscribe_notify_tests/conf/subscribe_notify_test_same_client_ids_diff_ports_slave_local_tcp.json.in index 654ec6588..75f7ad2c6 100644 --- a/test/network_tests/subscribe_notify_tests/conf/subscribe_notify_test_same_client_ids_diff_ports_slave_local_tcp.json.in +++ b/test/network_tests/subscribe_notify_tests/conf/subscribe_notify_test_same_client_ids_diff_ports_slave_local_tcp.json.in @@ -9,7 +9,7 @@ "enable":"false", "path":"/tmp/vsomeip.log" }, - "dlt":"false" + "dlt":"true" }, "applications": [ @@ -80,4 +80,4 @@ "cyclic_offer_delay" : "1000", "ttl" : "3" } -} \ No newline at end of file +} diff --git a/test/network_tests/subscribe_notify_tests/conf/subscribe_notify_test_same_client_ids_same_ports_master.json.in b/test/network_tests/subscribe_notify_tests/conf/subscribe_notify_test_same_client_ids_same_ports_master.json.in index 253b55ed0..07f2a2ce1 100644 --- a/test/network_tests/subscribe_notify_tests/conf/subscribe_notify_test_same_client_ids_same_ports_master.json.in +++ b/test/network_tests/subscribe_notify_tests/conf/subscribe_notify_test_same_client_ids_same_ports_master.json.in @@ -9,7 +9,7 @@ "enable":"false", "path":"/tmp/vsomeip.log" }, - "dlt":"false" + "dlt":"true" }, "applications": [ @@ -73,4 +73,4 @@ "cyclic_offer_delay" : "1000", "ttl" : "3" } -} \ No newline at end of file +} diff --git a/test/network_tests/subscribe_notify_tests/conf/subscribe_notify_test_same_client_ids_same_ports_master_local_tcp.json.in b/test/network_tests/subscribe_notify_tests/conf/subscribe_notify_test_same_client_ids_same_ports_master_local_tcp.json.in index f44a0207d..2b476cfe5 100644 --- a/test/network_tests/subscribe_notify_tests/conf/subscribe_notify_test_same_client_ids_same_ports_master_local_tcp.json.in +++ b/test/network_tests/subscribe_notify_tests/conf/subscribe_notify_test_same_client_ids_same_ports_master_local_tcp.json.in @@ -9,7 +9,7 @@ "enable":"false", "path":"/tmp/vsomeip.log" }, - "dlt":"false" + "dlt":"true" }, "applications": [ @@ -80,4 +80,4 @@ "cyclic_offer_delay" : "1000", "ttl" : "3" } -} \ No newline at end of file +} diff --git a/test/network_tests/subscribe_notify_tests/conf/subscribe_notify_test_same_client_ids_same_ports_slave.json.in b/test/network_tests/subscribe_notify_tests/conf/subscribe_notify_test_same_client_ids_same_ports_slave.json.in index c203e80d3..78defe5ec 100644 --- a/test/network_tests/subscribe_notify_tests/conf/subscribe_notify_test_same_client_ids_same_ports_slave.json.in +++ b/test/network_tests/subscribe_notify_tests/conf/subscribe_notify_test_same_client_ids_same_ports_slave.json.in @@ -9,7 +9,7 @@ "enable":"false", "path":"/tmp/vsomeip.log" }, - "dlt":"false" + "dlt":"true" }, "applications": [ @@ -73,4 +73,4 @@ "cyclic_offer_delay" : "1000", "ttl" : "3" } -} \ No newline at end of file +} diff --git a/test/network_tests/subscribe_notify_tests/conf/subscribe_notify_test_same_client_ids_same_ports_slave_local_tcp.json.in b/test/network_tests/subscribe_notify_tests/conf/subscribe_notify_test_same_client_ids_same_ports_slave_local_tcp.json.in index 91e900663..0e076a122 100644 --- a/test/network_tests/subscribe_notify_tests/conf/subscribe_notify_test_same_client_ids_same_ports_slave_local_tcp.json.in +++ b/test/network_tests/subscribe_notify_tests/conf/subscribe_notify_test_same_client_ids_same_ports_slave_local_tcp.json.in @@ -9,7 +9,7 @@ "enable":"false", "path":"/tmp/vsomeip.log" }, - "dlt":"false" + "dlt":"true" }, "applications": [ @@ -80,4 +80,4 @@ "cyclic_offer_delay" : "1000", "ttl" : "3" } -} \ No newline at end of file +} diff --git a/test/network_tests/subscribe_notify_tests/subscribe_notify_test_master_starter_qnx.sh b/test/network_tests/subscribe_notify_tests/subscribe_notify_test_master_starter_qnx.sh index eec7dd72c..96a71e6ec 100755 --- a/test/network_tests/subscribe_notify_tests/subscribe_notify_test_master_starter_qnx.sh +++ b/test/network_tests/subscribe_notify_tests/subscribe_notify_test_master_starter_qnx.sh @@ -1,5 +1,5 @@ #!/bin/sh -# Copyright (C) 2015-2017 Bayerische Motoren Werke Aktiengesellschaft (BMW AG) +# Copyright (C) 2015-2023 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/. diff --git a/test/network_tests/subscribe_notify_tests/subscribe_notify_test_one_event_two_eventgroups_client.cpp b/test/network_tests/subscribe_notify_tests/subscribe_notify_test_one_event_two_eventgroups_client.cpp index 1cc7b1d35..6b3ae2940 100644 --- a/test/network_tests/subscribe_notify_tests/subscribe_notify_test_one_event_two_eventgroups_client.cpp +++ b/test/network_tests/subscribe_notify_tests/subscribe_notify_test_one_event_two_eventgroups_client.cpp @@ -1,4 +1,4 @@ -// Copyright (C) 2014-2017 Bayerische Motoren Werke Aktiengesellschaft (BMW AG) +// Copyright (C) 2014-2023 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/. @@ -19,11 +19,14 @@ #include #include "subscribe_notify_test_globals.hpp" +#include "../someip_test_globals.hpp" +#include -class subscribe_notify_test_one_event_two_eventgroups_client { +class subscribe_notify_test_one_event_two_eventgroups_client : public vsomeip_utilities::base_logger { public: subscribe_notify_test_one_event_two_eventgroups_client( struct subscribe_notify_test::service_info _info, bool _use_tcp) : + vsomeip_utilities::base_logger("SNC1", "SUBSCRIBE NOTIFY TEST ONE EVENT TWO EVENTGROUPS CLIENT"), app_( vsomeip::runtime::get()->create_application( "subscribe_notify_test_client")), diff --git a/test/network_tests/subscribe_notify_tests/subscribe_notify_test_one_event_two_eventgroups_service.cpp b/test/network_tests/subscribe_notify_tests/subscribe_notify_test_one_event_two_eventgroups_service.cpp index 9b0600cf5..243273228 100644 --- a/test/network_tests/subscribe_notify_tests/subscribe_notify_test_one_event_two_eventgroups_service.cpp +++ b/test/network_tests/subscribe_notify_tests/subscribe_notify_test_one_event_two_eventgroups_service.cpp @@ -1,4 +1,4 @@ -// Copyright (C) 2014-2017 Bayerische Motoren Werke Aktiengesellschaft (BMW AG) +// Copyright (C) 2014-2023 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/. @@ -19,10 +19,13 @@ #include #include "subscribe_notify_test_globals.hpp" +#include "../someip_test_globals.hpp" +#include -class subscribe_notify_test_one_event_two_eventgroups_service { +class subscribe_notify_test_one_event_two_eventgroups_service : public vsomeip_utilities::base_logger { public: subscribe_notify_test_one_event_two_eventgroups_service(subscribe_notify_test::service_info _info, bool _use_tcp) : + vsomeip_utilities::base_logger("SNS1", "SUBSCRIBE NOTIFY TEST ONE EVENT TWO EVENTGROUPS SERVICE"), app_(vsomeip::runtime::get()->create_application()), wait_for_shutdown_(true), info_(_info), @@ -244,5 +247,3 @@ int main(int argc, char** argv) return RUN_ALL_TESTS(); } #endif - - diff --git a/test/network_tests/subscribe_notify_tests/subscribe_notify_test_service.cpp b/test/network_tests/subscribe_notify_tests/subscribe_notify_test_service.cpp index bf895b183..3c8c038da 100644 --- a/test/network_tests/subscribe_notify_tests/subscribe_notify_test_service.cpp +++ b/test/network_tests/subscribe_notify_tests/subscribe_notify_test_service.cpp @@ -1,4 +1,4 @@ -// Copyright (C) 2014-2017 Bayerische Motoren Werke Aktiengesellschaft (BMW AG) +// Copyright (C) 2014-2023 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/. @@ -19,13 +19,15 @@ #include #include "subscribe_notify_test_globals.hpp" +#include "../someip_test_globals.hpp" +#include - -class subscribe_notify_test_service { +class subscribe_notify_test_service : public vsomeip_utilities::base_logger { public: subscribe_notify_test_service(struct subscribe_notify_test::service_info _service_info, std::array _service_infos, vsomeip::reliability_type_e _reliability_type) : + vsomeip_utilities::base_logger("SNTS", "SUBSCRIBE NOTIFY TEST SERVICE"), service_info_(_service_info), service_infos_(_service_infos), app_(vsomeip::runtime::get()->create_application()), @@ -37,7 +39,6 @@ class subscribe_notify_test_service { stop_thread_(std::bind(&subscribe_notify_test_service::wait_for_stop, this)), wait_for_notify_(true), notify_thread_(std::bind(&subscribe_notify_test_service::notify, this)), - subscription_state_handler_called_(0), subscription_error_occured_(false), reliability_type_(_reliability_type) { if (!app_->init()) { @@ -161,13 +162,11 @@ class subscribe_notify_test_service { void on_subscription_state_change(const vsomeip::service_t _service, const vsomeip::instance_t _instance, const vsomeip::eventgroup_t _eventgroup, const vsomeip::event_t _event, const uint16_t _error) { - (void)_service; - (void)_instance; - (void)_eventgroup; (void)_event; + std::lock_guard its_lock(subscription_state_handler_called_mutex_); if (!_error) { - subscription_state_handler_called_++; + subscription_state_handler_called_.insert(std::make_tuple(_service, _instance, _eventgroup)); } else { subscription_error_occured_ = true; VSOMEIP_WARNING << std::hex << app_->get_client() @@ -331,11 +330,12 @@ class subscribe_notify_test_service { // is processed in the server - due to resubscribing the error handler // count may differ from expected value, but its not a real but as // the subscription takes places anyways and all events will be received. + std::lock_guard its_subscription_lock(subscription_state_handler_called_mutex_); if (!subscription_error_occured_) { - ASSERT_EQ(subscribe_count, subscription_state_handler_called_); + ASSERT_EQ(subscribe_count, subscription_state_handler_called_.size()); } else { VSOMEIP_WARNING << "Subscription state handler check skipped: CallCount=" - << std::dec << subscription_state_handler_called_; + << std::dec << subscription_state_handler_called_.size(); } } @@ -450,8 +450,11 @@ class subscribe_notify_test_service { std::mutex notify_mutex_; std::condition_variable notify_condition_; std::thread notify_thread_; - std::atomic subscription_state_handler_called_; - std::atomic subscription_error_occured_; + + std::mutex subscription_state_handler_called_mutex_; + bool subscription_error_occured_; + std::set > subscription_state_handler_called_; std::mutex subscribers_mutex_; vsomeip::reliability_type_e reliability_type_; diff --git a/test/network_tests/subscribe_notify_tests/subscribe_notify_test_slave_starter.sh b/test/network_tests/subscribe_notify_tests/subscribe_notify_test_slave_starter.sh index 813316120..84b401088 100755 --- a/test/network_tests/subscribe_notify_tests/subscribe_notify_test_slave_starter.sh +++ b/test/network_tests/subscribe_notify_tests/subscribe_notify_test_slave_starter.sh @@ -23,6 +23,7 @@ SLAVE_JSON_FILE=$2 SAME_SERVICE_ID=$3 FAIL=0 + # Start the services export VSOMEIP_APPLICATION_NAME=subscribe_notify_test_service_four export VSOMEIP_CONFIGURATION=$SLAVE_JSON_FILE diff --git a/test/network_tests/suspend_resume_tests/conf/suspend_resume_test_client.json.in b/test/network_tests/suspend_resume_tests/conf/suspend_resume_test_client.json.in index db94ceab7..352e4fdca 100644 --- a/test/network_tests/suspend_resume_tests/conf/suspend_resume_test_client.json.in +++ b/test/network_tests/suspend_resume_tests/conf/suspend_resume_test_client.json.in @@ -6,7 +6,7 @@ "level" : "debug", "console" : "true", "file" : { "enable" : "false", "path" : "" }, - "dlt" : "false" + "dlt" : "true" }, "applications" : [ @@ -29,4 +29,4 @@ "cyclic_offer_delay" : "1000", "ttl" : "3" } -} \ No newline at end of file +} diff --git a/test/network_tests/suspend_resume_tests/conf/suspend_resume_test_service.json.in b/test/network_tests/suspend_resume_tests/conf/suspend_resume_test_service.json.in index 44b510b91..582740c6c 100644 --- a/test/network_tests/suspend_resume_tests/conf/suspend_resume_test_service.json.in +++ b/test/network_tests/suspend_resume_tests/conf/suspend_resume_test_service.json.in @@ -6,7 +6,7 @@ "level" : "debug", "console" : "true", "file" : { "enable" : "false", "path" : "" }, - "dlt" : "false" + "dlt" : "true" }, "applications" : [ @@ -37,4 +37,4 @@ "cyclic_offer_delay" : "1000", "ttl" : "3" } -} \ No newline at end of file +} diff --git a/test/network_tests/suspend_resume_tests/suspend_resume_test.hpp b/test/network_tests/suspend_resume_tests/suspend_resume_test.hpp index 5271bba01..7eae22399 100644 --- a/test/network_tests/suspend_resume_tests/suspend_resume_test.hpp +++ b/test/network_tests/suspend_resume_tests/suspend_resume_test.hpp @@ -1,4 +1,4 @@ -// Copyright (C) 2021 Bayerische Motoren Werke Aktiengesellschaft (BMW AG) +// Copyright (C) 2023 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/. @@ -6,6 +6,9 @@ #ifndef SUSPEND_RESUME_TEST_ #define SUSPEND_RESUME_TEST_ +#include "../someip_test_globals.hpp" +#include + #define TEST_SERVICE 0x6311 #define TEST_INSTANCE 0x0002 #define TEST_MAJOR 0x01 diff --git a/test/network_tests/suspend_resume_tests/suspend_resume_test_client.cpp b/test/network_tests/suspend_resume_tests/suspend_resume_test_client.cpp index c491d9acc..552ddea5e 100644 --- a/test/network_tests/suspend_resume_tests/suspend_resume_test_client.cpp +++ b/test/network_tests/suspend_resume_tests/suspend_resume_test_client.cpp @@ -1,4 +1,4 @@ -// Copyright (C) 2021 Bayerische Motoren Werke Aktiengesellschaft (BMW AG) +// Copyright (C) 2023 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/. @@ -13,11 +13,14 @@ #include #include "suspend_resume_test.hpp" +#include "../someip_test_globals.hpp" +#include -class suspend_resume_test_client { +class suspend_resume_test_client : public vsomeip_utilities::base_logger { public: suspend_resume_test_client() - : name_("suspend_resume_test_client"), + : vsomeip_utilities::base_logger("SRTC", "SUSPEND RESUME TEST CLIENT"), + name_("suspend_resume_test_client"), app_(vsomeip::runtime::get()->create_application(name_)), has_received_(false), runner_(std::bind(&suspend_resume_test_client::run, this)) { diff --git a/test/network_tests/suspend_resume_tests/suspend_resume_test_service.cpp b/test/network_tests/suspend_resume_tests/suspend_resume_test_service.cpp index 4e2ecbc29..6f099ce7c 100644 --- a/test/network_tests/suspend_resume_tests/suspend_resume_test_service.cpp +++ b/test/network_tests/suspend_resume_tests/suspend_resume_test_service.cpp @@ -1,4 +1,4 @@ -// Copyright (C) 2021 Bayerische Motoren Werke Aktiengesellschaft (BMW AG) +// Copyright (C) 2023 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/. @@ -14,13 +14,16 @@ #include #include "suspend_resume_test.hpp" +#include "../someip_test_globals.hpp" +#include pid_t daemon_pid__; -class suspend_resume_test_service { +class suspend_resume_test_service : public vsomeip_utilities::base_logger { public: suspend_resume_test_service() - : name_("suspend_resume_test_service"), + : vsomeip_utilities::base_logger("ATCA", "APPLICATION TEST CLIENT AVAILABILITY"), + name_("suspend_resume_test_service"), app_(vsomeip::runtime::get()->create_application(name_)), is_running_(true), is_unblocked_(false), diff --git a/test/tsan-suppressions.txt b/test/tsan-suppressions.txt new file mode 100644 index 000000000..7c9fddd83 --- /dev/null +++ b/test/tsan-suppressions.txt @@ -0,0 +1 @@ +mutex:libdlt.so \ No newline at end of file diff --git a/test/unit_tests/CMakeLists.txt b/test/unit_tests/CMakeLists.txt index ed63f6fff..49935739a 100644 --- a/test/unit_tests/CMakeLists.txt +++ b/test/unit_tests/CMakeLists.txt @@ -1,11 +1,11 @@ -# Copyright (C) 2015-2022 Bayerische Motoren Werke Aktiengesellschaft (BMW AG) +# Copyright (C) 2015-2023 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/. project ("unit_tests_bin" LANGUAGES CXX) -file (GLOB SRCS main.cpp **/*.cpp ../common/utility.cpp) +file (GLOB SRCS main.cpp **/*.cpp) set(THREADS_PREFER_PTHREAD_FLAG ON) @@ -24,6 +24,7 @@ target_link_libraries ( ${Boost_LIBRARIES} ${DL_LIBRARY} gtest + vsomeip_utilities ) add_dependencies(build_unit_tests ${PROJECT_NAME}) diff --git a/test/unit_tests/security_tests/ut_check_credentials.cpp b/test/unit_tests/security_tests/ut_check_credentials.cpp index 7696892b7..2fe4e9dee 100644 --- a/test/unit_tests/security_tests/ut_check_credentials.cpp +++ b/test/unit_tests/security_tests/ut_check_credentials.cpp @@ -1,11 +1,11 @@ -// Copyright (C) 2022 Bayerische Motoren Werke Aktiengesellschaft (BMW AG) +// Copyright (C) 2023 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/. #include -#include "../../common/utility.hpp" +#include namespace { vsomeip_v3::client_t client = 1; @@ -13,6 +13,7 @@ namespace { vsomeip_v3::uid_t valid_uid = 4004201; vsomeip_v3::gid_t invalid_gid = 1; vsomeip_v3::gid_t valid_gid = 4004200; + vsomeip_sec_ip_addr_t host_address = 0; } TEST(check_credentials_test, check_no_policies_loaded) { @@ -24,7 +25,7 @@ TEST(check_credentials_test, check_no_policies_loaded) { ASSERT_FALSE(its_manager->is_enabled()); // create security clients - vsomeip_sec_client_t its_sec_client_invalid = utility::create_uds_client(invalid_uid, invalid_gid); + vsomeip_sec_client_t its_sec_client_invalid = utility::create_uds_client(invalid_uid, invalid_gid, host_address); EXPECT_TRUE(its_manager->check_credentials(client, &its_sec_client_invalid)); } @@ -53,9 +54,9 @@ TEST(check_credentials_test, check_policies_loaded) { ASSERT_TRUE(its_manager->is_enabled()); // create security clients - vsomeip_sec_client_t its_sec_client_valid = utility::create_uds_client(valid_uid, valid_gid); + vsomeip_sec_client_t its_sec_client_valid = utility::create_uds_client(valid_uid, valid_gid, host_address); - vsomeip_sec_client_t its_sec_client_invalid = utility::create_uds_client(invalid_uid, invalid_gid); + vsomeip_sec_client_t its_sec_client_invalid = utility::create_uds_client(invalid_uid, invalid_gid, host_address); //invalid uid and gid -> the check must return false EXPECT_FALSE(its_manager->check_credentials(client, &its_sec_client_invalid)); @@ -102,10 +103,10 @@ TEST(check_credentials_test, check_policies_loaded_in_audit_mode) { ASSERT_TRUE(its_manager->is_enabled()); // create security clients - vsomeip_sec_client_t its_sec_client_valid = utility::create_uds_client(valid_uid, valid_gid); - vsomeip_sec_client_t its_sec_client_invalid_valid = utility::create_uds_client(invalid_uid, valid_gid); - vsomeip_sec_client_t its_sec_client_valid_invalid = utility::create_uds_client(valid_uid, invalid_gid); - vsomeip_sec_client_t its_sec_client_invalid = utility::create_uds_client(invalid_uid, invalid_gid); + vsomeip_sec_client_t its_sec_client_valid = utility::create_uds_client(valid_uid, valid_gid, host_address); + vsomeip_sec_client_t its_sec_client_invalid_valid = utility::create_uds_client(invalid_uid, valid_gid, host_address); + vsomeip_sec_client_t its_sec_client_valid_invalid = utility::create_uds_client(valid_uid, invalid_gid, host_address); + vsomeip_sec_client_t its_sec_client_invalid = utility::create_uds_client(invalid_uid, invalid_gid, host_address); // is expected check_credentials method always return true //invalid uid and gid @@ -119,4 +120,4 @@ TEST(check_credentials_test, check_policies_loaded_in_audit_mode) { //valid uid and gid EXPECT_TRUE(its_manager->check_credentials(client, &its_sec_client_valid)); -} \ No newline at end of file +} diff --git a/test/unit_tests/security_tests/ut_check_routing_credentials.cpp b/test/unit_tests/security_tests/ut_check_routing_credentials.cpp index ef9040d59..0112cadb5 100644 --- a/test/unit_tests/security_tests/ut_check_routing_credentials.cpp +++ b/test/unit_tests/security_tests/ut_check_routing_credentials.cpp @@ -1,17 +1,18 @@ -// Copyright (C) 2022 Bayerische Motoren Werke Aktiengesellschaft (BMW AG) +// Copyright (C) 2023 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/. #include #include -#include "../../common/utility.hpp" +#include namespace { vsomeip_v3::uid_t invalid_uid = 1; vsomeip_v3::uid_t valid_uid = 4003017; vsomeip_v3::gid_t invalid_gid = 1; vsomeip_v3::gid_t valid_gid = 5002; +vsomeip_sec_ip_addr_t host_address = 0; } TEST(check_routing_credentials, check_policies_loaded) { @@ -31,10 +32,10 @@ TEST(check_routing_credentials, check_policies_loaded) { ASSERT_TRUE(its_failed.size() == 0); // create security clients - vsomeip_sec_client_t its_sec_client_valid = utility::create_uds_client(valid_uid, valid_gid); - vsomeip_sec_client_t its_sec_client_invalid = utility::create_uds_client(invalid_uid, invalid_gid); - vsomeip_sec_client_t its_sec_client_valid_uid_invalid_gid = utility::create_uds_client(valid_uid, invalid_gid); - vsomeip_sec_client_t its_sec_client_invalid_uid_valid_gid = utility::create_uds_client(invalid_uid, valid_gid); + vsomeip_sec_client_t its_sec_client_valid = utility::create_uds_client(valid_uid, valid_gid, host_address); + vsomeip_sec_client_t its_sec_client_invalid = utility::create_uds_client(invalid_uid, invalid_gid, host_address); + vsomeip_sec_client_t its_sec_client_valid_uid_invalid_gid = utility::create_uds_client(valid_uid, invalid_gid, host_address); + vsomeip_sec_client_t its_sec_client_invalid_uid_valid_gid = utility::create_uds_client(invalid_uid, valid_gid, host_address); //valid uid and gid -> the check must return true EXPECT_TRUE(security->check_routing_credentials(&its_sec_client_valid)); @@ -72,10 +73,10 @@ TEST(check_routing_credentials, check_policies_loaded_lazy_load) { ASSERT_TRUE(its_failed.size() == 0); // create security clients - vsomeip_sec_client_t its_sec_client_valid = utility::create_uds_client(valid_uid, valid_gid); - vsomeip_sec_client_t its_sec_client_invalid = utility::create_uds_client(invalid_uid, invalid_gid); - vsomeip_sec_client_t its_sec_client_valid_uid_invalid_gid = utility::create_uds_client(valid_uid, invalid_gid); - vsomeip_sec_client_t its_sec_client_invalid_uid_valid_gid = utility::create_uds_client(invalid_uid, valid_gid); + vsomeip_sec_client_t its_sec_client_valid = utility::create_uds_client(valid_uid, valid_gid, host_address); + vsomeip_sec_client_t its_sec_client_invalid = utility::create_uds_client(invalid_uid, invalid_gid, host_address); + vsomeip_sec_client_t its_sec_client_valid_uid_invalid_gid = utility::create_uds_client(valid_uid, invalid_gid, host_address); + vsomeip_sec_client_t its_sec_client_invalid_uid_valid_gid = utility::create_uds_client(invalid_uid, valid_gid, host_address); //expect check_routing_credentials_ false so method always returns true EXPECT_TRUE(security->check_routing_credentials(&its_sec_client_valid)); diff --git a/test/unit_tests/security_tests/ut_get_client_to_sec_client_mapping.cpp b/test/unit_tests/security_tests/ut_get_client_to_sec_client_mapping.cpp index efcb826d6..c47d404e3 100644 --- a/test/unit_tests/security_tests/ut_get_client_to_sec_client_mapping.cpp +++ b/test/unit_tests/security_tests/ut_get_client_to_sec_client_mapping.cpp @@ -1,11 +1,11 @@ -// Copyright (C) 2022 Bayerische Motoren Werke Aktiengesellschaft (BMW AG) +// Copyright (C) 2023 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/. #include #include -#include "../../common/utility.hpp" +#include namespace { vsomeip_v3::client_t client = 10; @@ -16,15 +16,16 @@ vsomeip_v3::uid_t uid_2 = 1; vsomeip_v3::gid_t gid_2 = 1; vsomeip_v3::uid_t uid_3 = 2; vsomeip_v3::gid_t gid_3 = 2; +vsomeip_sec_ip_addr_t host_address = 0; } TEST(get_client_to_sec_client_mapping, test) { std::unique_ptr security(new vsomeip_v3::policy_manager_impl); - vsomeip_sec_client_t its_sec_client_uid_gid_1 = utility::create_uds_client(uid_1, gid_1); - vsomeip_sec_client_t its_sec_client_uid_gid_2 = utility::create_uds_client(uid_2, gid_2); - vsomeip_sec_client_t its_sec_client_uid_gid_3 = utility::create_uds_client(uid_3, gid_3); + vsomeip_sec_client_t its_sec_client_uid_gid_1 = utility::create_uds_client(uid_1, gid_1, host_address); + vsomeip_sec_client_t its_sec_client_uid_gid_2 = utility::create_uds_client(uid_2, gid_2, host_address); + vsomeip_sec_client_t its_sec_client_uid_gid_3 = utility::create_uds_client(uid_3, gid_3, host_address); // Client and uid_gid should not be stored yet. EXPECT_FALSE(security->get_client_to_sec_client_mapping(client, its_sec_client_uid_gid_1)); @@ -33,15 +34,15 @@ TEST(get_client_to_sec_client_mapping, test) security->store_client_to_sec_client_mapping(client, &its_sec_client_uid_gid_1); // uid_gid and uid_gid_2 should not be equal. - EXPECT_NE(its_sec_client_uid_gid_1.client.uds_client.group, its_sec_client_uid_gid_2.client.uds_client.group); - EXPECT_NE(its_sec_client_uid_gid_1.client.uds_client.user, its_sec_client_uid_gid_2.client.uds_client.user); + EXPECT_NE(its_sec_client_uid_gid_1.group, its_sec_client_uid_gid_2.group); + EXPECT_NE(its_sec_client_uid_gid_1.user, its_sec_client_uid_gid_2.user); // Client and uid_gid mapping should be returned. EXPECT_TRUE(security->get_client_to_sec_client_mapping(client, its_sec_client_uid_gid_2)); // uid_gid and uid_gid_2 should be equal if get was successful. - EXPECT_EQ(its_sec_client_uid_gid_1.client.uds_client.group, its_sec_client_uid_gid_2.client.uds_client.group); - EXPECT_EQ(its_sec_client_uid_gid_1.client.uds_client.user, its_sec_client_uid_gid_2.client.uds_client.user); + EXPECT_EQ(its_sec_client_uid_gid_1.group, its_sec_client_uid_gid_2.group); + EXPECT_EQ(its_sec_client_uid_gid_1.user, its_sec_client_uid_gid_2.user); // Alternate_client is not stored, this should return false. EXPECT_FALSE(security->get_client_to_sec_client_mapping(alternate_client, its_sec_client_uid_gid_1)); @@ -50,13 +51,13 @@ TEST(get_client_to_sec_client_mapping, test) security->store_client_to_sec_client_mapping(alternate_client, &its_sec_client_uid_gid_1); // uid_gid and uid_gid_3 should not be equal. - EXPECT_NE(its_sec_client_uid_gid_1.client.uds_client.group, its_sec_client_uid_gid_3.client.uds_client.group); - EXPECT_NE(its_sec_client_uid_gid_1.client.uds_client.user, its_sec_client_uid_gid_3.client.uds_client.user); + EXPECT_NE(its_sec_client_uid_gid_1.group, its_sec_client_uid_gid_3.group); + EXPECT_NE(its_sec_client_uid_gid_1.user, its_sec_client_uid_gid_3.user); // Alternate client and uid_gid mapping should be returned. EXPECT_TRUE(security->get_client_to_sec_client_mapping(alternate_client, its_sec_client_uid_gid_3)); // uid_gid and uid_gid_3 should be equal if get was successful. - EXPECT_EQ(its_sec_client_uid_gid_1.client.uds_client.group, its_sec_client_uid_gid_3.client.uds_client.group); - EXPECT_EQ(its_sec_client_uid_gid_1.client.uds_client.user, its_sec_client_uid_gid_3.client.uds_client.user); + EXPECT_EQ(its_sec_client_uid_gid_1.group, its_sec_client_uid_gid_3.group); + EXPECT_EQ(its_sec_client_uid_gid_1.user, its_sec_client_uid_gid_3.user); } diff --git a/test/unit_tests/security_tests/ut_get_clients.cpp b/test/unit_tests/security_tests/ut_get_clients.cpp index 093200c90..49a4b09c1 100644 --- a/test/unit_tests/security_tests/ut_get_clients.cpp +++ b/test/unit_tests/security_tests/ut_get_clients.cpp @@ -1,11 +1,11 @@ -// Copyright (C) 2022 Bayerische Motoren Werke Aktiengesellschaft (BMW AG) +// Copyright (C) 2023 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/. #include #include -#include "../../common/utility.hpp" +#include namespace { std::unordered_set clients; @@ -15,13 +15,14 @@ vsomeip_v3::client_t client_2 = 11; vsomeip_v3::client_t client_3 = 12; vsomeip_v3::uid_t uid = 4003030; vsomeip_v3::gid_t gid = 4003032; +vsomeip_sec_ip_addr_t host_address = 0; } TEST(get_clients, test) { std::unique_ptr security(new vsomeip_v3::policy_manager_impl); - vsomeip_sec_client_t its_sec_client_uid_gid = utility::create_uds_client(uid, gid); + vsomeip_sec_client_t its_sec_client_uid_gid = utility::create_uds_client(uid, gid, host_address); // Local_clients has now one client(10). local_clients.insert(client_1); diff --git a/test/unit_tests/security_tests/ut_get_sec_client_to_clients_mapping.cpp b/test/unit_tests/security_tests/ut_get_sec_client_to_clients_mapping.cpp index 96ae41605..ad2986ded 100644 --- a/test/unit_tests/security_tests/ut_get_sec_client_to_clients_mapping.cpp +++ b/test/unit_tests/security_tests/ut_get_sec_client_to_clients_mapping.cpp @@ -1,11 +1,11 @@ -// Copyright (C) 2022 Bayerische Motoren Werke Aktiengesellschaft (BMW AG) +// Copyright (C) 2023 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/. #include #include -#include "../../common/utility.hpp" +#include namespace{ vsomeip_v3::client_t client = 10; @@ -13,6 +13,7 @@ vsomeip_v3::uid_t uid_1 = 4003030; vsomeip_v3::gid_t gid_1 = 4003032; vsomeip_v3::uid_t uid_2 = 1; vsomeip_v3::gid_t gid_2 = 1; +vsomeip_sec_ip_addr_t host_address = 0; } TEST(get_sec_client_to_clients_mapping, test) @@ -22,8 +23,8 @@ TEST(get_sec_client_to_clients_mapping, test) std::set clients_1; clients_1.insert(client); - vsomeip_sec_client_t its_sec_client_uid_gid = utility::create_uds_client(uid_1, gid_1); - vsomeip_sec_client_t its_sec_client_uid_gid_alternate = utility::create_uds_client(uid_2, gid_2); + vsomeip_sec_client_t its_sec_client_uid_gid = utility::create_uds_client(uid_1, gid_1, host_address); + vsomeip_sec_client_t its_sec_client_uid_gid_alternate = utility::create_uds_client(uid_2, gid_2, host_address); // Client and uid_gid should not be stored yet. EXPECT_FALSE(security->get_sec_client_to_clients_mapping(&its_sec_client_uid_gid, clients_1)); diff --git a/test/unit_tests/security_tests/ut_is_client_allowed.cpp b/test/unit_tests/security_tests/ut_is_client_allowed.cpp index ab6515343..bd6f72f07 100644 --- a/test/unit_tests/security_tests/ut_is_client_allowed.cpp +++ b/test/unit_tests/security_tests/ut_is_client_allowed.cpp @@ -1,10 +1,16 @@ +// Copyright (C) 2023 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/. + #include #include "gtest/gtest.h" -#include "../../common/utility.hpp" +#include namespace { vsomeip_v3::uid_t uid_1 = 4003031; vsomeip_v3::gid_t gid_1 = 4003031; + vsomeip_sec_ip_addr_t host_address = 0; vsomeip_v3::service_t service_1 = 0xf913; vsomeip_v3::service_t service_2 = 0x41; // service not defined in policies @@ -30,7 +36,7 @@ TEST(is_client_allowed_test, check_no_policies_loaded) { //no policies loaded -> is_client_allowed must return true ASSERT_FALSE(its_manager->is_enabled()); - vsomeip_sec_client_t its_sec_client_invalid = utility::create_uds_client(invalid_uid, invalid_gid); + vsomeip_sec_client_t its_sec_client_invalid = utility::create_uds_client(invalid_uid, invalid_gid, host_address); EXPECT_TRUE(its_manager->is_client_allowed(&its_sec_client_invalid, service_1, instance, method)); } @@ -56,11 +62,11 @@ TEST(is_client_allowed_test, check_policies_loaded) { ASSERT_FALSE(its_manager->is_audit()); // create security clients - vsomeip_sec_client_t its_sec_client = utility::create_uds_client(uid_1, gid_1); - vsomeip_sec_client_t its_sec_client_invalid_uid = utility::create_uds_client(invalid_uid, gid_1); - vsomeip_sec_client_t its_sec_client_invalid_gid = utility::create_uds_client(uid_1, invalid_gid); - vsomeip_sec_client_t its_sec_client_any = utility::create_uds_client(ANY_UID, ANY_GID); - vsomeip_sec_client_t its_sec_client_deny = utility::create_uds_client(deny_uid, deny_gid); + vsomeip_sec_client_t its_sec_client = utility::create_uds_client(uid_1, gid_1, host_address); + vsomeip_sec_client_t its_sec_client_invalid_uid = utility::create_uds_client(invalid_uid, gid_1, host_address); + vsomeip_sec_client_t its_sec_client_invalid_gid = utility::create_uds_client(uid_1, invalid_gid, host_address); + vsomeip_sec_client_t its_sec_client_any = utility::create_uds_client(ANY_UID, ANY_GID, host_address); + vsomeip_sec_client_t its_sec_client_deny = utility::create_uds_client(deny_uid, deny_gid, host_address); //valid credential for valid service / istance / method EXPECT_TRUE(its_manager->is_client_allowed(&its_sec_client, service_1, instance, method)); @@ -117,11 +123,11 @@ TEST(is_client_allowed_test, check_policies_loaded) { ASSERT_TRUE(its_manager->is_audit()); // create security clients - vsomeip_sec_client_t its_sec_client = utility::create_uds_client(uid_1, gid_1); - vsomeip_sec_client_t its_sec_client_invalid_uid = utility::create_uds_client(invalid_uid, gid_1); - vsomeip_sec_client_t its_sec_client_invalid_gid = utility::create_uds_client(uid_1, invalid_gid); - vsomeip_sec_client_t its_sec_client_any = utility::create_uds_client(ANY_UID, ANY_GID); - vsomeip_sec_client_t its_sec_client_deny = utility::create_uds_client(deny_uid, deny_gid); + vsomeip_sec_client_t its_sec_client = utility::create_uds_client(uid_1, gid_1, host_address); + vsomeip_sec_client_t its_sec_client_invalid_uid = utility::create_uds_client(invalid_uid, gid_1, host_address); + vsomeip_sec_client_t its_sec_client_invalid_gid = utility::create_uds_client(uid_1, invalid_gid, host_address); + vsomeip_sec_client_t its_sec_client_any = utility::create_uds_client(ANY_UID, ANY_GID, host_address); + vsomeip_sec_client_t its_sec_client_deny = utility::create_uds_client(deny_uid, deny_gid, host_address); // is expected is_client_allowed method always returns true // valid credential for valid service / istance / method @@ -146,4 +152,4 @@ TEST(is_client_allowed_test, check_policies_loaded) { EXPECT_TRUE(its_manager->is_client_allowed(&its_sec_client_deny, deny_service, instance, method)); // credencials exists in deny policy, but not for that service EXPECT_TRUE(its_manager->is_client_allowed(&its_sec_client_deny, service_2, instance, method)); -} \ No newline at end of file +} diff --git a/test/unit_tests/security_tests/ut_is_offer_allowed.cpp b/test/unit_tests/security_tests/ut_is_offer_allowed.cpp index f60d4ed3c..005eaf007 100644 --- a/test/unit_tests/security_tests/ut_is_offer_allowed.cpp +++ b/test/unit_tests/security_tests/ut_is_offer_allowed.cpp @@ -1,15 +1,16 @@ -// Copyright (C) 2022 Bayerische Motoren Werke Aktiengesellschaft (BMW AG) +// Copyright (C) 2023 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/. #include #include -#include "../../common/utility.hpp" +#include namespace{ vsomeip_v3::uid_t uid_1 = 4003016; vsomeip_v3::gid_t gid_1 = 4003016; +vsomeip_sec_ip_addr_t host_address = 0; vsomeip_v3::service_t service_1 = 0xf8c2; vsomeip_v3::service_t deny_service = 0x40; @@ -32,7 +33,7 @@ TEST(is_offer_allowed, check_no_policies_loaded) ASSERT_FALSE(security->is_enabled()); - vsomeip_sec_client_t its_sec_client_invalid = utility::create_uds_client(invalid_uid, invalid_gid); + vsomeip_sec_client_t its_sec_client_invalid = utility::create_uds_client(invalid_uid, invalid_gid, host_address); // no policies loaded -> is_offer_allowed must return true EXPECT_TRUE(security->is_offer_allowed(&its_sec_client_invalid, service_1, instance)); @@ -62,12 +63,12 @@ TEST(is_offer_allowed, check_policies_loaded) ASSERT_FALSE(security->is_audit()); // create security clients - vsomeip_sec_client_t its_sec_client_valid = utility::create_uds_client(uid_1, gid_1); - vsomeip_sec_client_t its_sec_client_invalid = utility::create_uds_client(invalid_uid, invalid_gid); - vsomeip_sec_client_t its_sec_client_valid_uid_invalid_gid = utility::create_uds_client(uid_1, invalid_gid); - vsomeip_sec_client_t its_sec_client_invalid_uid_valid_gid = utility::create_uds_client(invalid_uid, gid_1); - vsomeip_sec_client_t its_sec_client_deny = utility::create_uds_client(deny_uid, deny_gid); - vsomeip_sec_client_t its_sec_client_any = utility::create_uds_client(ANY_UID, ANY_GID); + vsomeip_sec_client_t its_sec_client_valid = utility::create_uds_client(uid_1, gid_1, host_address); + vsomeip_sec_client_t its_sec_client_invalid = utility::create_uds_client(invalid_uid, invalid_gid, host_address); + vsomeip_sec_client_t its_sec_client_valid_uid_invalid_gid = utility::create_uds_client(uid_1, invalid_gid, host_address); + vsomeip_sec_client_t its_sec_client_invalid_uid_valid_gid = utility::create_uds_client(invalid_uid, gid_1, host_address); + vsomeip_sec_client_t its_sec_client_deny = utility::create_uds_client(deny_uid, deny_gid, host_address); + vsomeip_sec_client_t its_sec_client_any = utility::create_uds_client(ANY_UID, ANY_GID, host_address); // valid credential for valid service / instance EXPECT_TRUE(security->is_offer_allowed(&its_sec_client_valid, service_1, instance)); @@ -102,12 +103,12 @@ TEST(is_offer_allowed, check_policies_loaded_in_audit_mode) std::unique_ptr security(new vsomeip_v3::policy_manager_impl); // create security clients - vsomeip_sec_client_t its_sec_client_valid = utility::create_uds_client(uid_1, gid_1); - vsomeip_sec_client_t its_sec_client_invalid = utility::create_uds_client(invalid_uid, invalid_gid); - vsomeip_sec_client_t its_sec_client_valid_uid_invalid_gid = utility::create_uds_client(uid_1, invalid_gid); - vsomeip_sec_client_t its_sec_client_invalid_uid_valid_gid = utility::create_uds_client(invalid_uid, gid_1); - vsomeip_sec_client_t its_sec_client_deny = utility::create_uds_client(deny_uid, deny_gid); - vsomeip_sec_client_t its_sec_client_any = utility::create_uds_client(ANY_UID, ANY_GID); + vsomeip_sec_client_t its_sec_client_valid = utility::create_uds_client(uid_1, gid_1, host_address); + vsomeip_sec_client_t its_sec_client_invalid = utility::create_uds_client(invalid_uid, invalid_gid, host_address); + vsomeip_sec_client_t its_sec_client_valid_uid_invalid_gid = utility::create_uds_client(uid_1, invalid_gid, host_address); + vsomeip_sec_client_t its_sec_client_invalid_uid_valid_gid = utility::create_uds_client(invalid_uid, gid_1, host_address); + vsomeip_sec_client_t its_sec_client_deny = utility::create_uds_client(deny_uid, deny_gid, host_address); + vsomeip_sec_client_t its_sec_client_any = utility::create_uds_client(ANY_UID, ANY_GID, host_address); // force load of some policies std::set its_failed; diff --git a/test/unit_tests/security_tests/ut_is_policy_update_allowed.cpp b/test/unit_tests/security_tests/ut_is_policy_update_allowed.cpp index 14e151d97..8bb57404c 100644 --- a/test/unit_tests/security_tests/ut_is_policy_update_allowed.cpp +++ b/test/unit_tests/security_tests/ut_is_policy_update_allowed.cpp @@ -1,4 +1,4 @@ -// Copyright (C) 2022 Bayerische Motoren Werke Aktiengesellschaft (BMW AG) +// Copyright (C) 2023 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/. @@ -6,7 +6,7 @@ #include #include #include -#include "../../common/utility.hpp" +#include namespace { std::string configuration_file { "/vsomeip/0_0/vsomeip_security.json" }; diff --git a/test/unit_tests/security_tests/ut_load.cpp b/test/unit_tests/security_tests/ut_load.cpp index bf2758995..793d77f57 100644 --- a/test/unit_tests/security_tests/ut_load.cpp +++ b/test/unit_tests/security_tests/ut_load.cpp @@ -1,4 +1,4 @@ -// Copyright (C) 2022 Bayerische Motoren Werke Aktiengesellschaft (BMW AG) +// Copyright (C) 2023 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/. @@ -7,7 +7,7 @@ #include -#include "../../common/utility.hpp" +#include namespace { diff --git a/test/unit_tests/security_tests/ut_load_policies.cpp b/test/unit_tests/security_tests/ut_load_policies.cpp index 83d7b3a80..6bcb7e629 100644 --- a/test/unit_tests/security_tests/ut_load_policies.cpp +++ b/test/unit_tests/security_tests/ut_load_policies.cpp @@ -1,11 +1,11 @@ -// Copyright (C) 2022 Bayerische Motoren Werke Aktiengesellschaft (BMW AG) +// Copyright (C) 2023 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/. #include #include -#include "../../common/utility.hpp" +#include namespace { std::string configuration_file { "/vsomeip/0_0/vsomeip_security.json" }; diff --git a/test/unit_tests/security_tests/ut_load_security_policy_extensions.cpp b/test/unit_tests/security_tests/ut_load_security_policy_extensions.cpp new file mode 100644 index 000000000..1efb14fff --- /dev/null +++ b/test/unit_tests/security_tests/ut_load_security_policy_extensions.cpp @@ -0,0 +1,159 @@ +// Copyright (C) 2023 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/. + +#include +#include +#include + +// create valid and invalid user credentials +namespace +{ + std::string configuration_file{ + "/vsomeip/vsomeip_policy_extensions.json"}; // set configuration file policy + +} // namespace + +TEST(load_security_policy_extensions, no_configuration_element) +{ + // Test object path. + std::unique_ptr security{ + new vsomeip_v3::policy_manager_impl}; + + // Set element. + std::vector element; + std::vector full_element; + + // Save init size values. + auto element_size = element.size(); + auto full_element_size = full_element.size(); + + // Check element and full element size init =zero. + ASSERT_TRUE(element.size() == 0) << " Initial element size is not zero"; + + // After load try again and check size. + std::set its_failed; + std::vector dir_skip; + utility::read_data( + utility::get_all_files_in_dir(utility::get_policies_path(), dir_skip), + full_element, its_failed); + + // Load each e into policy_elements. + for (const auto &e : full_element) + { + security->load(e, false); + } + + ASSERT_EQ(element_size, full_element_size) + << "Policy element before load is not zero. Size = " << element_size + << " And size after load = " << full_element_size; + + // Check size of full_element after load >0 + ASSERT_TRUE(full_element.size() > 0) + << "Full element size is zero after load, should be >0 since policy was " + "loaded"; +} + +TEST(load_security_policy_extensions, configuration_element) +{ + // Test object path. + std::unique_ptr security{ + new vsomeip_v3::policy_manager_impl}; + + // Set element. + std::vector policy_elements; + std::vector element; + + // Force load of policies. + std::set its_failed; + std::vector dir_skip; + utility::read_data( + utility::get_all_files_in_dir(utility::get_policies_path(), dir_skip), + policy_elements, its_failed); + + // Load each e into policy_elements. + for (const auto &e : policy_elements) + { + security->load(e, false); + } + + ASSERT_TRUE(policy_elements.size() > 0); + ASSERT_GT(policy_elements.size(), element.size()) << "Policies did not load"; +} + +TEST(load_security_policy_extensions, is_policy_extension_loaded) +{ + // Test object path. + std::unique_ptr security{ + new vsomeip_v3::policy_manager_impl}; + + // Set element. + std::vector policy_elements; + + // Force Load of policies. + std::set its_failed; + std::set input{utility::get_policies_path() + + configuration_file}; + utility::read_data(input, policy_elements, its_failed); + + // Load policies. + security->load(policy_elements.at(0)); + + // Check JSON container string. + std::string policy_extension_container{"android-rse"}; + + // Set extension loaded. + bool loaded_extension = true; + security->set_is_policy_extension_loaded(policy_extension_container, loaded_extension); + + // Print path for "android-rse". + std::cout << "Policy Extension Path: " << security->get_policy_extension_path(policy_extension_container) << std::endl; + + // Check if policy extension is loaded and path found. + ASSERT_EQ(security->is_policy_extension_loaded(policy_extension_container), vsomeip_v3::policy_manager_impl::policy_loaded_e:: + POLICY_PATH_FOUND_AND_LOADED); +} + +TEST(load_security_policy_extensions, is_policy_extension_NOT_loaded) +{ + // Test object path. + std::unique_ptr security{ + new vsomeip_v3::policy_manager_impl}; + + // Set element. + std::vector policy_elements; + + // Force load of policies and read data. + std::set its_failed; + std::set input{utility::get_policies_path() + + configuration_file}; + utility::read_data(input, policy_elements, its_failed); + + // Load Policies. + security->load(policy_elements.at(0)); + + // Check JSON container string. + std::string policy_extension_container{"android-rse"}; + + // Set extension as not loaded. + bool loaded_extension = false; + security->set_is_policy_extension_loaded(policy_extension_container, loaded_extension); + + // Print path for "android-rse". + std::cout << "Policy Extension Path: " << security->get_policy_extension_path(policy_extension_container) << std::endl; + + // Check if policy extension is loaded and path found. + ASSERT_EQ(security->is_policy_extension_loaded(policy_extension_container), vsomeip_v3::policy_manager_impl::policy_loaded_e:: + POLICY_PATH_FOUND_AND_NOT_LOADED); +} + +TEST(load_security_policy_extensions, is_policy_extension_NOT_found) +{ + // Test object path. + std::unique_ptr security{ + new vsomeip_v3::policy_manager_impl}; + + // Check path not found and extension not loaded. + ASSERT_EQ(security->is_policy_extension_loaded(""), vsomeip_v3::policy_manager_impl::policy_loaded_e::POLICY_PATH_INEXISTENT); +} diff --git a/test/unit_tests/security_tests/ut_load_security_update_whitelist.cpp b/test/unit_tests/security_tests/ut_load_security_update_whitelist.cpp index 5fcd5dae7..94b52c7f3 100644 --- a/test/unit_tests/security_tests/ut_load_security_update_whitelist.cpp +++ b/test/unit_tests/security_tests/ut_load_security_update_whitelist.cpp @@ -1,11 +1,11 @@ -// Copyright (C) 2022 Bayerische Motoren Werke Aktiengesellschaft (BMW AG) +// Copyright (C) 2023 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/. #include #include -#include "../../common/utility.hpp" +#include namespace { std::string configuration_file { "/vsomeip/0_0/vsomeip_security.json" }; diff --git a/test/unit_tests/security_tests/ut_remove_client_to_sec_client_mapping.cpp b/test/unit_tests/security_tests/ut_remove_client_to_sec_client_mapping.cpp index 3aff27a85..17e4addd7 100644 --- a/test/unit_tests/security_tests/ut_remove_client_to_sec_client_mapping.cpp +++ b/test/unit_tests/security_tests/ut_remove_client_to_sec_client_mapping.cpp @@ -1,24 +1,25 @@ -// Copyright (C) 2022 Bayerische Motoren Werke Aktiengesellschaft (BMW AG) +// Copyright (C) 2023 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/. #include #include -#include "../../common/utility.hpp" +#include namespace { vsomeip_v3::client_t client = 10; vsomeip_v3::uid_t uid = 4003030; vsomeip_v3::gid_t gid = 4003032; +vsomeip_sec_ip_addr_t host_address = 0; } TEST(remove_client_to_sec_client_mapping, check_no_policies_loaded) { std::unique_ptr security(new vsomeip_v3::policy_manager_impl); - vsomeip_sec_client_t its_sec_client = utility::create_uds_client(uid, gid); + vsomeip_sec_client_t its_sec_client = utility::create_uds_client(uid, gid, host_address); // client and uid_gid should not be stored yet EXPECT_FALSE(security->get_client_to_sec_client_mapping (client, its_sec_client)); diff --git a/test/unit_tests/security_tests/ut_remove_security_policy.cpp b/test/unit_tests/security_tests/ut_remove_security_policy.cpp index b3d677018..e334978e0 100644 --- a/test/unit_tests/security_tests/ut_remove_security_policy.cpp +++ b/test/unit_tests/security_tests/ut_remove_security_policy.cpp @@ -1,11 +1,11 @@ -// Copyright (C) 2022 Bayerische Motoren Werke Aktiengesellschaft (BMW AG) +// Copyright (C) 2023 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/. #include -#include "../../common/utility.hpp" +#include namespace { vsomeip_v3::uid_t invalid_uid = 1;